* df-scan.c (df_collection_rec): Adjust.
[official-gcc.git] / gcc / doc / extend.texi
blob7623a5e550e925db7c1c3088deb5deef3823bde9
1 @c Copyright (C) 1988-2013 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Attribute Syntax::    Formal syntax for attributes.
59 * Function Prototypes:: Prototype declarations and old-style definitions.
60 * C++ Comments::        C++ comments are recognized.
61 * Dollar Signs::        Dollar sign is allowed in identifiers.
62 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes::     Specifying attributes of types.
65 * Alignment::           Inquiring about the alignment of a type or variable.
66 * Inline::              Defining inline functions (as fast as macros).
67 * Volatiles::           What constitutes an access to a volatile object.
68 * Extended Asm::        Assembler instructions with C expressions as operands.
69                         (With them you can define ``built-in'' functions.)
70 * Constraints::         Constraints for asm operands
71 * Asm Labels::          Specifying the assembler name to use for a C symbol.
72 * Explicit Reg Vars::   Defining variables residing in specified registers.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
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 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
86 * Other Builtins::      Other built-in functions.
87 * Target Builtins::     Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas::             Pragmas accepted by GCC.
90 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
91 * Thread-Local::        Per-thread variables.
92 * Binary constants::    Binary constants using the @samp{0b} prefix.
93 @end menu
95 @node Statement Exprs
96 @section Statements and Declarations in Expressions
97 @cindex statements inside expressions
98 @cindex declarations inside expressions
99 @cindex expressions containing statements
100 @cindex macros, statements in expressions
102 @c the above section title wrapped and causes an underfull hbox.. i
103 @c changed it from "within" to "in". --mew 4feb93
104 A compound statement enclosed in parentheses may appear as an expression
105 in GNU C@.  This allows you to use loops, switches, and local variables
106 within an expression.
108 Recall that a compound statement is a sequence of statements surrounded
109 by braces; in this construct, parentheses go around the braces.  For
110 example:
112 @smallexample
113 (@{ int y = foo (); int z;
114    if (y > 0) z = y;
115    else z = - y;
116    z; @})
117 @end smallexample
119 @noindent
120 is a valid (though slightly more complex than necessary) expression
121 for the absolute value of @code{foo ()}.
123 The last thing in the compound statement should be an expression
124 followed by a semicolon; the value of this subexpression serves as the
125 value of the entire construct.  (If you use some other kind of statement
126 last within the braces, the construct has type @code{void}, and thus
127 effectively no value.)
129 This feature is especially useful in making macro definitions ``safe'' (so
130 that they evaluate each operand exactly once).  For example, the
131 ``maximum'' function is commonly defined as a macro in standard C as
132 follows:
134 @smallexample
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 @end smallexample
138 @noindent
139 @cindex side effects, macro argument
140 But this definition computes either @var{a} or @var{b} twice, with bad
141 results if the operand has side effects.  In GNU C, if you know the
142 type of the operands (here taken as @code{int}), you can define
143 the macro safely as follows:
145 @smallexample
146 #define maxint(a,b) \
147   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
148 @end smallexample
150 Embedded statements are not allowed in constant expressions, such as
151 the value of an enumeration constant, the width of a bit-field, or
152 the initial value of a static variable.
154 If you don't know the type of the operand, you can still do this, but you
155 must use @code{typeof} (@pxref{Typeof}).
157 In G++, the result value of a statement expression undergoes array and
158 function pointer decay, and is returned by value to the enclosing
159 expression.  For instance, if @code{A} is a class, then
161 @smallexample
162         A a;
164         (@{a;@}).Foo ()
165 @end smallexample
167 @noindent
168 constructs a temporary @code{A} object to hold the result of the
169 statement expression, and that is used to invoke @code{Foo}.
170 Therefore the @code{this} pointer observed by @code{Foo} is not the
171 address of @code{a}.
173 In a statement expression, any temporaries created within a statement
174 are destroyed at that statement's end.  This makes statement
175 expressions inside macros slightly different from function calls.  In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call.  In the statement expression case they are destroyed during
179 the statement expression.  For instance,
181 @smallexample
182 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
183 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
185 void foo ()
187   macro (X ());
188   function (X ());
190 @end smallexample
192 @noindent
193 has different places where temporaries are destroyed.  For the
194 @code{macro} case, the temporary @code{X} is destroyed just after
195 the initialization of @code{b}.  In the @code{function} case that
196 temporary is destroyed when the function returns.
198 These considerations mean that it is probably a bad idea to use
199 statement expressions of this form in header files that are designed to
200 work with C++.  (Note that some versions of the GNU C Library contained
201 header files using statement expressions that lead to precisely this
202 bug.)
204 Jumping into a statement expression with @code{goto} or using a
205 @code{switch} statement outside the statement expression with a
206 @code{case} or @code{default} label inside the statement expression is
207 not permitted.  Jumping into a statement expression with a computed
208 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression.  In any case, as with a function call, the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression.  For example,
218 @smallexample
219   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}.  If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope.  A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
237 A local label declaration looks like this:
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
243 @noindent
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself.  You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
257 The local label feature is useful for complex macros.  If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them.  However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function.  A
262 local label avoids this problem.  For example:
264 @smallexample
265 #define SEARCH(value, array, target)              \
266 do @{                                              \
267   __label__ found;                                \
268   typeof (target) _SEARCH_target = (target);      \
269   typeof (*(array)) *_SEARCH_array = (array);     \
270   int i, j;                                       \
271   int value;                                      \
272   for (i = 0; i < max; i++)                       \
273     for (j = 0; j < max; j++)                     \
274       if (_SEARCH_array[i][j] == _SEARCH_target)  \
275         @{ (value) = i; goto found; @}              \
276   (value) = -1;                                   \
277  found:;                                          \
278 @} while (0)
279 @end smallexample
281 This could also be written using a statement expression:
283 @smallexample
284 #define SEARCH(array, target)                     \
285 (@{                                                \
286   __label__ found;                                \
287   typeof (target) _SEARCH_target = (target);      \
288   typeof (*(array)) *_SEARCH_array = (array);     \
289   int i, j;                                       \
290   int value;                                      \
291   for (i = 0; i < max; i++)                       \
292     for (j = 0; j < max; j++)                     \
293       if (_SEARCH_array[i][j] == _SEARCH_target)  \
294         @{ value = i; goto found; @}                \
295   value = -1;                                     \
296  found:                                           \
297   value;                                          \
299 @end smallexample
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any.  @xref{Nested Functions}, for details.
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}.  The
313 value has type @code{void *}.  This value is a constant and can be used
314 wherever a constant of that type is valid.  For example:
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
322 To use these values, you need to be able to jump to one.  This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}.  For example,
328 @smallexample
329 goto *ptr;
330 @end smallexample
332 @noindent
333 Any expression of type @code{void *} is allowed.
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
342 @noindent
343 Then you can select a label with indexing, like this:
345 @smallexample
346 goto *array[i];
347 @end smallexample
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement.  The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen.  The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
367 An alternate way to write the above example is
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371                              &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
380 The @code{&&foo} expressions for the same label might have different
381 values if the containing function is inlined or cloned.  If a program
382 relies on them being always the same,
383 @code{__attribute__((__noinline__,__noclone__))} should be used to
384 prevent inlining and cloning.  If @code{&&foo} is used in a static
385 variable initializer, inlining and cloning is forbidden.
387 @node Nested Functions
388 @section Nested Functions
389 @cindex nested functions
390 @cindex downward funargs
391 @cindex thunks
393 A @dfn{nested function} is a function defined inside another function.
394 Nested functions are supported as an extension in GNU C, but are not
395 supported by GNU C++.
397 The nested function's name is local to the block where it is defined.
398 For example, here we define a nested function named @code{square}, and
399 call it twice:
401 @smallexample
402 @group
403 foo (double a, double b)
405   double square (double z) @{ return z * z; @}
407   return square (a) + square (b);
409 @end group
410 @end smallexample
412 The nested function can access all the variables of the containing
413 function that are visible at the point of its definition.  This is
414 called @dfn{lexical scoping}.  For example, here we show a nested
415 function which uses an inherited variable named @code{offset}:
417 @smallexample
418 @group
419 bar (int *array, int offset, int size)
421   int access (int *array, int index)
422     @{ return array[index + offset]; @}
423   int i;
424   /* @r{@dots{}} */
425   for (i = 0; i < size; i++)
426     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
428 @end group
429 @end smallexample
431 Nested function definitions are permitted within functions in the places
432 where variable definitions are allowed; that is, in any block, mixed
433 with the other declarations and statements in the block.
435 It is possible to call the nested function from outside the scope of its
436 name by storing its address or passing the address to another function:
438 @smallexample
439 hack (int *array, int size)
441   void store (int index, int value)
442     @{ array[index] = value; @}
444   intermediate (store, size);
446 @end smallexample
448 Here, the function @code{intermediate} receives the address of
449 @code{store} as an argument.  If @code{intermediate} calls @code{store},
450 the arguments given to @code{store} are used to store into @code{array}.
451 But this technique works only so long as the containing function
452 (@code{hack}, in this example) does not exit.
454 If you try to call the nested function through its address after the
455 containing function exits, all hell breaks loose.  If you try
456 to call it after a containing scope level exits, and if it refers
457 to some of the variables that are no longer in scope, you may be lucky,
458 but it's not wise to take the risk.  If, however, the nested function
459 does not refer to anything that has gone out of scope, you should be
460 safe.
462 GCC implements taking the address of a nested function using a technique
463 called @dfn{trampolines}.  This technique was described in
464 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
465 C++ Conference Proceedings, October 17-21, 1988).
467 A nested function can jump to a label inherited from a containing
468 function, provided the label is explicitly declared in the containing
469 function (@pxref{Local Labels}).  Such a jump returns instantly to the
470 containing function, exiting the nested function that did the
471 @code{goto} and any intermediate functions as well.  Here is an example:
473 @smallexample
474 @group
475 bar (int *array, int offset, int size)
477   __label__ failure;
478   int access (int *array, int index)
479     @{
480       if (index > size)
481         goto failure;
482       return array[index + offset];
483     @}
484   int i;
485   /* @r{@dots{}} */
486   for (i = 0; i < size; i++)
487     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
488   /* @r{@dots{}} */
489   return 0;
491  /* @r{Control comes here from @code{access}
492     if it detects an error.}  */
493  failure:
494   return -1;
496 @end group
497 @end smallexample
499 A nested function always has no linkage.  Declaring one with
500 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
501 before its definition, use @code{auto} (which is otherwise meaningless
502 for function declarations).
504 @smallexample
505 bar (int *array, int offset, int size)
507   __label__ failure;
508   auto int access (int *, int);
509   /* @r{@dots{}} */
510   int access (int *array, int index)
511     @{
512       if (index > size)
513         goto failure;
514       return array[index + offset];
515     @}
516   /* @r{@dots{}} */
518 @end smallexample
520 @node Constructing Calls
521 @section Constructing Function Calls
522 @cindex constructing calls
523 @cindex forwarding calls
525 Using the built-in functions described below, you can record
526 the arguments a function received, and call another function
527 with the same arguments, without knowing the number or types
528 of the arguments.
530 You can also record the return value of that function call,
531 and later return that value, without knowing what data type
532 the function tried to return (as long as your caller expects
533 that data type).
535 However, these built-in functions may interact badly with some
536 sophisticated features or other extensions of the language.  It
537 is, therefore, not recommended to use them outside very simple
538 functions acting as mere forwarders for their arguments.
540 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
541 This built-in function returns a pointer to data
542 describing how to perform a call with the same arguments as are passed
543 to the current function.
545 The function saves the arg pointer register, structure value address,
546 and all registers that might be used to pass arguments to a function
547 into a block of memory allocated on the stack.  Then it returns the
548 address of that block.
549 @end deftypefn
551 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
552 This built-in function invokes @var{function}
553 with a copy of the parameters described by @var{arguments}
554 and @var{size}.
556 The value of @var{arguments} should be the value returned by
557 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
558 of the stack argument data, in bytes.
560 This function returns a pointer to data describing
561 how to return whatever value is returned by @var{function}.  The data
562 is saved in a block of memory allocated on the stack.
564 It is not always simple to compute the proper value for @var{size}.  The
565 value is used by @code{__builtin_apply} to compute the amount of data
566 that should be pushed on the stack and copied from the incoming argument
567 area.
568 @end deftypefn
570 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
571 This built-in function returns the value described by @var{result} from
572 the containing function.  You should specify, for @var{result}, a value
573 returned by @code{__builtin_apply}.
574 @end deftypefn
576 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
577 This built-in function represents all anonymous arguments of an inline
578 function.  It can be used only in inline functions that are always
579 inlined, never compiled as a separate function, such as those using
580 @code{__attribute__ ((__always_inline__))} or
581 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
582 It must be only passed as last argument to some other function
583 with variable arguments.  This is useful for writing small wrapper
584 inlines for variable argument functions, when using preprocessor
585 macros is undesirable.  For example:
586 @smallexample
587 extern int myprintf (FILE *f, const char *format, ...);
588 extern inline __attribute__ ((__gnu_inline__)) int
589 myprintf (FILE *f, const char *format, ...)
591   int r = fprintf (f, "myprintf: ");
592   if (r < 0)
593     return r;
594   int s = fprintf (f, format, __builtin_va_arg_pack ());
595   if (s < 0)
596     return s;
597   return r + s;
599 @end smallexample
600 @end deftypefn
602 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
603 This built-in function returns the number of anonymous arguments of
604 an inline function.  It can be used only in inline functions that
605 are always inlined, never compiled as a separate function, such
606 as those using @code{__attribute__ ((__always_inline__))} or
607 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
608 For example following does link- or run-time checking of open
609 arguments for optimized code:
610 @smallexample
611 #ifdef __OPTIMIZE__
612 extern inline __attribute__((__gnu_inline__)) int
613 myopen (const char *path, int oflag, ...)
615   if (__builtin_va_arg_pack_len () > 1)
616     warn_open_too_many_arguments ();
618   if (__builtin_constant_p (oflag))
619     @{
620       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
621         @{
622           warn_open_missing_mode ();
623           return __open_2 (path, oflag);
624         @}
625       return open (path, oflag, __builtin_va_arg_pack ());
626     @}
628   if (__builtin_va_arg_pack_len () < 1)
629     return __open_2 (path, oflag);
631   return open (path, oflag, __builtin_va_arg_pack ());
633 #endif
634 @end smallexample
635 @end deftypefn
637 @node Typeof
638 @section Referring to a Type with @code{typeof}
639 @findex typeof
640 @findex sizeof
641 @cindex macros, types of arguments
643 Another way to refer to the type of an expression is with @code{typeof}.
644 The syntax of using of this keyword looks like @code{sizeof}, but the
645 construct acts semantically like a type name defined with @code{typedef}.
647 There are two ways of writing the argument to @code{typeof}: with an
648 expression or with a type.  Here is an example with an expression:
650 @smallexample
651 typeof (x[0](1))
652 @end smallexample
654 @noindent
655 This assumes that @code{x} is an array of pointers to functions;
656 the type described is that of the values of the functions.
658 Here is an example with a typename as the argument:
660 @smallexample
661 typeof (int *)
662 @end smallexample
664 @noindent
665 Here the type described is that of pointers to @code{int}.
667 If you are writing a header file that must work when included in ISO C
668 programs, write @code{__typeof__} instead of @code{typeof}.
669 @xref{Alternate Keywords}.
671 A @code{typeof} construct can be used anywhere a typedef name can be
672 used.  For example, you can use it in a declaration, in a cast, or inside
673 of @code{sizeof} or @code{typeof}.
675 The operand of @code{typeof} is evaluated for its side effects if and
676 only if it is an expression of variably modified type or the name of
677 such a type.
679 @code{typeof} is often useful in conjunction with
680 statement expressions (@pxref{Statement Exprs}).
681 Here is how the two together can
682 be used to define a safe ``maximum'' macro which operates on any
683 arithmetic type and evaluates each of its arguments exactly once:
685 @smallexample
686 #define max(a,b) \
687   (@{ typeof (a) _a = (a); \
688       typeof (b) _b = (b); \
689     _a > _b ? _a : _b; @})
690 @end smallexample
692 @cindex underscores in variables in macros
693 @cindex @samp{_} in variables in macros
694 @cindex local variables in macros
695 @cindex variables, local, in macros
696 @cindex macros, local variables in
698 The reason for using names that start with underscores for the local
699 variables is to avoid conflicts with variable names that occur within the
700 expressions that are substituted for @code{a} and @code{b}.  Eventually we
701 hope to design a new form of declaration syntax that allows you to declare
702 variables whose scopes start only after their initializers; this will be a
703 more reliable way to prevent such conflicts.
705 @noindent
706 Some more examples of the use of @code{typeof}:
708 @itemize @bullet
709 @item
710 This declares @code{y} with the type of what @code{x} points to.
712 @smallexample
713 typeof (*x) y;
714 @end smallexample
716 @item
717 This declares @code{y} as an array of such values.
719 @smallexample
720 typeof (*x) y[4];
721 @end smallexample
723 @item
724 This declares @code{y} as an array of pointers to characters:
726 @smallexample
727 typeof (typeof (char *)[4]) y;
728 @end smallexample
730 @noindent
731 It is equivalent to the following traditional C declaration:
733 @smallexample
734 char *y[4];
735 @end smallexample
737 To see the meaning of the declaration using @code{typeof}, and why it
738 might be a useful way to write, rewrite it with these macros:
740 @smallexample
741 #define pointer(T)  typeof(T *)
742 #define array(T, N) typeof(T [N])
743 @end smallexample
745 @noindent
746 Now the declaration can be rewritten this way:
748 @smallexample
749 array (pointer (char), 4) y;
750 @end smallexample
752 @noindent
753 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
754 pointers to @code{char}.
755 @end itemize
757 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
758 a more limited extension that permitted one to write
760 @smallexample
761 typedef @var{T} = @var{expr};
762 @end smallexample
764 @noindent
765 with the effect of declaring @var{T} to have the type of the expression
766 @var{expr}.  This extension does not work with GCC 3 (versions between
767 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
768 relies on it should be rewritten to use @code{typeof}:
770 @smallexample
771 typedef typeof(@var{expr}) @var{T};
772 @end smallexample
774 @noindent
775 This works with all versions of GCC@.
777 @node Conditionals
778 @section Conditionals with Omitted Operands
779 @cindex conditional expressions, extensions
780 @cindex omitted middle-operands
781 @cindex middle-operands, omitted
782 @cindex extensions, @code{?:}
783 @cindex @code{?:} extensions
785 The middle operand in a conditional expression may be omitted.  Then
786 if the first operand is nonzero, its value is the value of the conditional
787 expression.
789 Therefore, the expression
791 @smallexample
792 x ? : y
793 @end smallexample
795 @noindent
796 has the value of @code{x} if that is nonzero; otherwise, the value of
797 @code{y}.
799 This example is perfectly equivalent to
801 @smallexample
802 x ? x : y
803 @end smallexample
805 @cindex side effect in @code{?:}
806 @cindex @code{?:} side effect
807 @noindent
808 In this simple case, the ability to omit the middle operand is not
809 especially useful.  When it becomes useful is when the first operand does,
810 or may (if it is a macro argument), contain a side effect.  Then repeating
811 the operand in the middle would perform the side effect twice.  Omitting
812 the middle operand uses the value already computed without the undesirable
813 effects of recomputing it.
815 @node __int128
816 @section 128-bit integers
817 @cindex @code{__int128} data types
819 As an extension the integer scalar type @code{__int128} is supported for
820 targets which have an integer mode wide enough to hold 128 bits.
821 Simply write @code{__int128} for a signed 128-bit integer, or
822 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
823 support in GCC for expressing an integer constant of type @code{__int128}
824 for targets with @code{long long} integer less than 128 bits wide.
826 @node Long Long
827 @section Double-Word Integers
828 @cindex @code{long long} data types
829 @cindex double-word arithmetic
830 @cindex multiprecision arithmetic
831 @cindex @code{LL} integer suffix
832 @cindex @code{ULL} integer suffix
834 ISO C99 supports data types for integers that are at least 64 bits wide,
835 and as an extension GCC supports them in C90 mode and in C++.
836 Simply write @code{long long int} for a signed integer, or
837 @code{unsigned long long int} for an unsigned integer.  To make an
838 integer constant of type @code{long long int}, add the suffix @samp{LL}
839 to the integer.  To make an integer constant of type @code{unsigned long
840 long int}, add the suffix @samp{ULL} to the integer.
842 You can use these types in arithmetic like any other integer types.
843 Addition, subtraction, and bitwise boolean operations on these types
844 are open-coded on all types of machines.  Multiplication is open-coded
845 if the machine supports a fullword-to-doubleword widening multiply
846 instruction.  Division and shifts are open-coded only on machines that
847 provide special support.  The operations that are not open-coded use
848 special library routines that come with GCC@.
850 There may be pitfalls when you use @code{long long} types for function
851 arguments without function prototypes.  If a function
852 expects type @code{int} for its argument, and you pass a value of type
853 @code{long long int}, confusion results because the caller and the
854 subroutine disagree about the number of bytes for the argument.
855 Likewise, if the function expects @code{long long int} and you pass
856 @code{int}.  The best way to avoid such problems is to use prototypes.
858 @node Complex
859 @section Complex Numbers
860 @cindex complex numbers
861 @cindex @code{_Complex} keyword
862 @cindex @code{__complex__} keyword
864 ISO C99 supports complex floating data types, and as an extension GCC
865 supports them in C90 mode and in C++.  GCC also supports complex integer data
866 types which are not part of ISO C99.  You can declare complex types
867 using the keyword @code{_Complex}.  As an extension, the older GNU
868 keyword @code{__complex__} is also supported.
870 For example, @samp{_Complex double x;} declares @code{x} as a
871 variable whose real part and imaginary part are both of type
872 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
873 have real and imaginary parts of type @code{short int}; this is not
874 likely to be useful, but it shows that the set of complex types is
875 complete.
877 To write a constant with a complex data type, use the suffix @samp{i} or
878 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
879 has type @code{_Complex float} and @code{3i} has type
880 @code{_Complex int}.  Such a constant always has a pure imaginary
881 value, but you can form any complex value you like by adding one to a
882 real constant.  This is a GNU extension; if you have an ISO C99
883 conforming C library (such as the GNU C Library), and want to construct complex
884 constants of floating type, you should include @code{<complex.h>} and
885 use the macros @code{I} or @code{_Complex_I} instead.
887 @cindex @code{__real__} keyword
888 @cindex @code{__imag__} keyword
889 To extract the real part of a complex-valued expression @var{exp}, write
890 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
891 extract the imaginary part.  This is a GNU extension; for values of
892 floating type, you should use the ISO C99 functions @code{crealf},
893 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
894 @code{cimagl}, declared in @code{<complex.h>} and also provided as
895 built-in functions by GCC@.
897 @cindex complex conjugation
898 The operator @samp{~} performs complex conjugation when used on a value
899 with a complex type.  This is a GNU extension; for values of
900 floating type, you should use the ISO C99 functions @code{conjf},
901 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
902 provided as built-in functions by GCC@.
904 GCC can allocate complex automatic variables in a noncontiguous
905 fashion; it's even possible for the real part to be in a register while
906 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
907 debug info format can represent this, so use of DWARF 2 is recommended.
908 If you are using the stabs debug info format, GCC describes a noncontiguous
909 complex variable as if it were two separate variables of noncomplex type.
910 If the variable's actual name is @code{foo}, the two fictitious
911 variables are named @code{foo$real} and @code{foo$imag}.  You can
912 examine and set these two fictitious variables with your debugger.
914 @node Floating Types
915 @section Additional Floating Types
916 @cindex additional floating types
917 @cindex @code{__float80} data type
918 @cindex @code{__float128} data type
919 @cindex @code{w} floating point suffix
920 @cindex @code{q} floating point suffix
921 @cindex @code{W} floating point suffix
922 @cindex @code{Q} floating point suffix
924 As an extension, GNU C supports additional floating
925 types, @code{__float80} and @code{__float128} to support 80-bit
926 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
927 Support for additional types includes the arithmetic operators:
928 add, subtract, multiply, divide; unary arithmetic operators;
929 relational operators; equality operators; and conversions to and from
930 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
931 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
932 for @code{_float128}.  You can declare complex types using the
933 corresponding internal complex type, @code{XCmode} for @code{__float80}
934 type and @code{TCmode} for @code{__float128} type:
936 @smallexample
937 typedef _Complex float __attribute__((mode(TC))) _Complex128;
938 typedef _Complex float __attribute__((mode(XC))) _Complex80;
939 @end smallexample
941 Not all targets support additional floating-point types.  @code{__float80}
942 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
943 The @code{__float128} type is supported on hppa HP-UX targets.
945 @node Half-Precision
946 @section Half-Precision Floating Point
947 @cindex half-precision floating point
948 @cindex @code{__fp16} data type
950 On ARM targets, GCC supports half-precision (16-bit) floating point via
951 the @code{__fp16} type.  You must enable this type explicitly
952 with the @option{-mfp16-format} command-line option in order to use it.
954 ARM supports two incompatible representations for half-precision
955 floating-point values.  You must choose one of the representations and
956 use it consistently in your program.
958 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
959 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
960 There are 11 bits of significand precision, approximately 3
961 decimal digits.
963 Specifying @option{-mfp16-format=alternative} selects the ARM
964 alternative format.  This representation is similar to the IEEE
965 format, but does not support infinities or NaNs.  Instead, the range
966 of exponents is extended, so that this format can represent normalized
967 values in the range of @math{2^{-14}} to 131008.
969 The @code{__fp16} type is a storage format only.  For purposes
970 of arithmetic and other operations, @code{__fp16} values in C or C++
971 expressions are automatically promoted to @code{float}.  In addition,
972 you cannot declare a function with a return value or parameters
973 of type @code{__fp16}.
975 Note that conversions from @code{double} to @code{__fp16}
976 involve an intermediate conversion to @code{float}.  Because
977 of rounding, this can sometimes produce a different result than a
978 direct conversion.
980 ARM provides hardware support for conversions between
981 @code{__fp16} and @code{float} values
982 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
983 code using these hardware instructions if you compile with
984 options to select an FPU that provides them;
985 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
986 in addition to the @option{-mfp16-format} option to select
987 a half-precision format.
989 Language-level support for the @code{__fp16} data type is
990 independent of whether GCC generates code using hardware floating-point
991 instructions.  In cases where hardware support is not specified, GCC
992 implements conversions between @code{__fp16} and @code{float} values
993 as library calls.
995 @node Decimal Float
996 @section Decimal Floating Types
997 @cindex decimal floating types
998 @cindex @code{_Decimal32} data type
999 @cindex @code{_Decimal64} data type
1000 @cindex @code{_Decimal128} data type
1001 @cindex @code{df} integer suffix
1002 @cindex @code{dd} integer suffix
1003 @cindex @code{dl} integer suffix
1004 @cindex @code{DF} integer suffix
1005 @cindex @code{DD} integer suffix
1006 @cindex @code{DL} integer suffix
1008 As an extension, GNU C supports decimal floating types as
1009 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1010 floating types in GCC will evolve as the draft technical report changes.
1011 Calling conventions for any target might also change.  Not all targets
1012 support decimal floating types.
1014 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1015 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1016 @code{float}, @code{double}, and @code{long double} whose radix is not
1017 specified by the C standard but is usually two.
1019 Support for decimal floating types includes the arithmetic operators
1020 add, subtract, multiply, divide; unary arithmetic operators;
1021 relational operators; equality operators; and conversions to and from
1022 integer and other floating types.  Use a suffix @samp{df} or
1023 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1024 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1025 @code{_Decimal128}.
1027 GCC support of decimal float as specified by the draft technical report
1028 is incomplete:
1030 @itemize @bullet
1031 @item
1032 When the value of a decimal floating type cannot be represented in the
1033 integer type to which it is being converted, the result is undefined
1034 rather than the result value specified by the draft technical report.
1036 @item
1037 GCC does not provide the C library functionality associated with
1038 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1039 @file{wchar.h}, which must come from a separate C library implementation.
1040 Because of this the GNU C compiler does not define macro
1041 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1042 the technical report.
1043 @end itemize
1045 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1046 are supported by the DWARF 2 debug information format.
1048 @node Hex Floats
1049 @section Hex Floats
1050 @cindex hex floats
1052 ISO C99 supports floating-point numbers written not only in the usual
1053 decimal notation, such as @code{1.55e1}, but also numbers such as
1054 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1055 supports this in C90 mode (except in some cases when strictly
1056 conforming) and in C++.  In that format the
1057 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1058 mandatory.  The exponent is a decimal number that indicates the power of
1059 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1060 @tex
1061 $1 {15\over16}$,
1062 @end tex
1063 @ifnottex
1064 1 15/16,
1065 @end ifnottex
1066 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1067 is the same as @code{1.55e1}.
1069 Unlike for floating-point numbers in the decimal notation the exponent
1070 is always required in the hexadecimal notation.  Otherwise the compiler
1071 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1072 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1073 extension for floating-point constants of type @code{float}.
1075 @node Fixed-Point
1076 @section Fixed-Point Types
1077 @cindex fixed-point types
1078 @cindex @code{_Fract} data type
1079 @cindex @code{_Accum} data type
1080 @cindex @code{_Sat} data type
1081 @cindex @code{hr} fixed-suffix
1082 @cindex @code{r} fixed-suffix
1083 @cindex @code{lr} fixed-suffix
1084 @cindex @code{llr} fixed-suffix
1085 @cindex @code{uhr} fixed-suffix
1086 @cindex @code{ur} fixed-suffix
1087 @cindex @code{ulr} fixed-suffix
1088 @cindex @code{ullr} fixed-suffix
1089 @cindex @code{hk} fixed-suffix
1090 @cindex @code{k} fixed-suffix
1091 @cindex @code{lk} fixed-suffix
1092 @cindex @code{llk} fixed-suffix
1093 @cindex @code{uhk} fixed-suffix
1094 @cindex @code{uk} fixed-suffix
1095 @cindex @code{ulk} fixed-suffix
1096 @cindex @code{ullk} fixed-suffix
1097 @cindex @code{HR} fixed-suffix
1098 @cindex @code{R} fixed-suffix
1099 @cindex @code{LR} fixed-suffix
1100 @cindex @code{LLR} fixed-suffix
1101 @cindex @code{UHR} fixed-suffix
1102 @cindex @code{UR} fixed-suffix
1103 @cindex @code{ULR} fixed-suffix
1104 @cindex @code{ULLR} fixed-suffix
1105 @cindex @code{HK} fixed-suffix
1106 @cindex @code{K} fixed-suffix
1107 @cindex @code{LK} fixed-suffix
1108 @cindex @code{LLK} fixed-suffix
1109 @cindex @code{UHK} fixed-suffix
1110 @cindex @code{UK} fixed-suffix
1111 @cindex @code{ULK} fixed-suffix
1112 @cindex @code{ULLK} fixed-suffix
1114 As an extension, GNU C supports fixed-point types as
1115 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1116 types in GCC will evolve as the draft technical report changes.
1117 Calling conventions for any target might also change.  Not all targets
1118 support fixed-point types.
1120 The fixed-point types are
1121 @code{short _Fract},
1122 @code{_Fract},
1123 @code{long _Fract},
1124 @code{long long _Fract},
1125 @code{unsigned short _Fract},
1126 @code{unsigned _Fract},
1127 @code{unsigned long _Fract},
1128 @code{unsigned long long _Fract},
1129 @code{_Sat short _Fract},
1130 @code{_Sat _Fract},
1131 @code{_Sat long _Fract},
1132 @code{_Sat long long _Fract},
1133 @code{_Sat unsigned short _Fract},
1134 @code{_Sat unsigned _Fract},
1135 @code{_Sat unsigned long _Fract},
1136 @code{_Sat unsigned long long _Fract},
1137 @code{short _Accum},
1138 @code{_Accum},
1139 @code{long _Accum},
1140 @code{long long _Accum},
1141 @code{unsigned short _Accum},
1142 @code{unsigned _Accum},
1143 @code{unsigned long _Accum},
1144 @code{unsigned long long _Accum},
1145 @code{_Sat short _Accum},
1146 @code{_Sat _Accum},
1147 @code{_Sat long _Accum},
1148 @code{_Sat long long _Accum},
1149 @code{_Sat unsigned short _Accum},
1150 @code{_Sat unsigned _Accum},
1151 @code{_Sat unsigned long _Accum},
1152 @code{_Sat unsigned long long _Accum}.
1154 Fixed-point data values contain fractional and optional integral parts.
1155 The format of fixed-point data varies and depends on the target machine.
1157 Support for fixed-point types includes:
1158 @itemize @bullet
1159 @item
1160 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1161 @item
1162 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1163 @item
1164 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1165 @item
1166 binary shift operators (@code{<<}, @code{>>})
1167 @item
1168 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1169 @item
1170 equality operators (@code{==}, @code{!=})
1171 @item
1172 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1173 @code{<<=}, @code{>>=})
1174 @item
1175 conversions to and from integer, floating-point, or fixed-point types
1176 @end itemize
1178 Use a suffix in a fixed-point literal constant:
1179 @itemize
1180 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1181 @code{_Sat short _Fract}
1182 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1183 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1184 @code{_Sat long _Fract}
1185 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1186 @code{_Sat long long _Fract}
1187 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1188 @code{_Sat unsigned short _Fract}
1189 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1190 @code{_Sat unsigned _Fract}
1191 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1192 @code{_Sat unsigned long _Fract}
1193 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1194 and @code{_Sat unsigned long long _Fract}
1195 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1196 @code{_Sat short _Accum}
1197 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1198 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1199 @code{_Sat long _Accum}
1200 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1201 @code{_Sat long long _Accum}
1202 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1203 @code{_Sat unsigned short _Accum}
1204 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1205 @code{_Sat unsigned _Accum}
1206 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1207 @code{_Sat unsigned long _Accum}
1208 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1209 and @code{_Sat unsigned long long _Accum}
1210 @end itemize
1212 GCC support of fixed-point types as specified by the draft technical report
1213 is incomplete:
1215 @itemize @bullet
1216 @item
1217 Pragmas to control overflow and rounding behaviors are not implemented.
1218 @end itemize
1220 Fixed-point types are supported by the DWARF 2 debug information format.
1222 @node Named Address Spaces
1223 @section Named Address Spaces
1224 @cindex Named Address Spaces
1226 As an extension, GNU C supports named address spaces as
1227 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1228 address spaces in GCC will evolve as the draft technical report
1229 changes.  Calling conventions for any target might also change.  At
1230 present, only the AVR, SPU, M32C, and RL78 targets support address
1231 spaces other than the generic address space.
1233 Address space identifiers may be used exactly like any other C type
1234 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1235 document for more details.
1237 @anchor{AVR Named Address Spaces}
1238 @subsection AVR Named Address Spaces
1240 On the AVR target, there are several address spaces that can be used
1241 in order to put read-only data into the flash memory and access that
1242 data by means of the special instructions @code{LPM} or @code{ELPM}
1243 needed to read from flash.
1245 Per default, any data including read-only data is located in RAM
1246 (the generic address space) so that non-generic address spaces are
1247 needed to locate read-only data in flash memory
1248 @emph{and} to generate the right instructions to access this data
1249 without using (inline) assembler code.
1251 @table @code
1252 @item __flash
1253 @cindex @code{__flash} AVR Named Address Spaces
1254 The @code{__flash} qualifier locates data in the
1255 @code{.progmem.data} section. Data is read using the @code{LPM}
1256 instruction. Pointers to this address space are 16 bits wide.
1258 @item __flash1
1259 @itemx __flash2
1260 @itemx __flash3
1261 @itemx __flash4
1262 @itemx __flash5
1263 @cindex @code{__flash1} AVR Named Address Spaces
1264 @cindex @code{__flash2} AVR Named Address Spaces
1265 @cindex @code{__flash3} AVR Named Address Spaces
1266 @cindex @code{__flash4} AVR Named Address Spaces
1267 @cindex @code{__flash5} AVR Named Address Spaces
1268 These are 16-bit address spaces locating data in section
1269 @code{.progmem@var{N}.data} where @var{N} refers to
1270 address space @code{__flash@var{N}}.
1271 The compiler sets the @code{RAMPZ} segment register appropriately 
1272 before reading data by means of the @code{ELPM} instruction.
1274 @item __memx
1275 @cindex @code{__memx} AVR Named Address Spaces
1276 This is a 24-bit address space that linearizes flash and RAM:
1277 If the high bit of the address is set, data is read from
1278 RAM using the lower two bytes as RAM address.
1279 If the high bit of the address is clear, data is read from flash
1280 with @code{RAMPZ} set according to the high byte of the address.
1281 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1283 Objects in this address space are located in @code{.progmemx.data}.
1284 @end table
1286 @b{Example}
1288 @smallexample
1289 char my_read (const __flash char ** p)
1291     /* p is a pointer to RAM that points to a pointer to flash.
1292        The first indirection of p reads that flash pointer
1293        from RAM and the second indirection reads a char from this
1294        flash address.  */
1296     return **p;
1299 /* Locate array[] in flash memory */
1300 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1302 int i = 1;
1304 int main (void)
1306    /* Return 17 by reading from flash memory */
1307    return array[array[i]];
1309 @end smallexample
1311 @noindent
1312 For each named address space supported by avr-gcc there is an equally
1313 named but uppercase built-in macro defined. 
1314 The purpose is to facilitate testing if respective address space
1315 support is available or not:
1317 @smallexample
1318 #ifdef __FLASH
1319 const __flash int var = 1;
1321 int read_var (void)
1323     return var;
1325 #else
1326 #include <avr/pgmspace.h> /* From AVR-LibC */
1328 const int var PROGMEM = 1;
1330 int read_var (void)
1332     return (int) pgm_read_word (&var);
1334 #endif /* __FLASH */
1335 @end smallexample
1337 @noindent
1338 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1339 locates data in flash but
1340 accesses to these data read from generic address space, i.e.@:
1341 from RAM,
1342 so that you need special accessors like @code{pgm_read_byte}
1343 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1344 together with attribute @code{progmem}.
1346 @noindent
1347 @b{Limitations and caveats}
1349 @itemize
1350 @item
1351 Reading across the 64@tie{}KiB section boundary of
1352 the @code{__flash} or @code{__flash@var{N}} address spaces
1353 shows undefined behavior. The only address space that
1354 supports reading across the 64@tie{}KiB flash segment boundaries is
1355 @code{__memx}.
1357 @item
1358 If you use one of the @code{__flash@var{N}} address spaces
1359 you must arrange your linker script to locate the
1360 @code{.progmem@var{N}.data} sections according to your needs.
1362 @item
1363 Any data or pointers to the non-generic address spaces must
1364 be qualified as @code{const}, i.e.@: as read-only data.
1365 This still applies if the data in one of these address
1366 spaces like software version number or calibration lookup table are intended to
1367 be changed after load time by, say, a boot loader. In this case
1368 the right qualification is @code{const} @code{volatile} so that the compiler
1369 must not optimize away known values or insert them
1370 as immediates into operands of instructions.
1372 @item
1373 The following code initializes a variable @code{pfoo}
1374 located in static storage with a 24-bit address:
1375 @smallexample
1376 extern const __memx char foo;
1377 const __memx void *pfoo = &foo;
1378 @end smallexample
1380 @noindent
1381 Such code requires at least binutils 2.23, see
1382 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1384 @end itemize
1386 @subsection M32C Named Address Spaces
1387 @cindex @code{__far} M32C Named Address Spaces
1389 On the M32C target, with the R8C and M16C CPU variants, variables
1390 qualified with @code{__far} are accessed using 32-bit addresses in
1391 order to access memory beyond the first 64@tie{}Ki bytes.  If
1392 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1393 effect.
1395 @subsection RL78 Named Address Spaces
1396 @cindex @code{__far} RL78 Named Address Spaces
1398 On the RL78 target, variables qualified with @code{__far} are accessed
1399 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1400 addresses.  Non-far variables are assumed to appear in the topmost
1401 64@tie{}KiB of the address space.
1403 @subsection SPU Named Address Spaces
1404 @cindex @code{__ea} SPU Named Address Spaces
1406 On the SPU target variables may be declared as
1407 belonging to another address space by qualifying the type with the
1408 @code{__ea} address space identifier:
1410 @smallexample
1411 extern int __ea i;
1412 @end smallexample
1414 @noindent 
1415 The compiler generates special code to access the variable @code{i}.
1416 It may use runtime library
1417 support, or generate special machine instructions to access that address
1418 space.
1420 @node Zero Length
1421 @section Arrays of Length Zero
1422 @cindex arrays of length zero
1423 @cindex zero-length arrays
1424 @cindex length-zero arrays
1425 @cindex flexible array members
1427 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1428 last element of a structure that is really a header for a variable-length
1429 object:
1431 @smallexample
1432 struct line @{
1433   int length;
1434   char contents[0];
1437 struct line *thisline = (struct line *)
1438   malloc (sizeof (struct line) + this_length);
1439 thisline->length = this_length;
1440 @end smallexample
1442 In ISO C90, you would have to give @code{contents} a length of 1, which
1443 means either you waste space or complicate the argument to @code{malloc}.
1445 In ISO C99, you would use a @dfn{flexible array member}, which is
1446 slightly different in syntax and semantics:
1448 @itemize @bullet
1449 @item
1450 Flexible array members are written as @code{contents[]} without
1451 the @code{0}.
1453 @item
1454 Flexible array members have incomplete type, and so the @code{sizeof}
1455 operator may not be applied.  As a quirk of the original implementation
1456 of zero-length arrays, @code{sizeof} evaluates to zero.
1458 @item
1459 Flexible array members may only appear as the last member of a
1460 @code{struct} that is otherwise non-empty.
1462 @item
1463 A structure containing a flexible array member, or a union containing
1464 such a structure (possibly recursively), may not be a member of a
1465 structure or an element of an array.  (However, these uses are
1466 permitted by GCC as extensions.)
1467 @end itemize
1469 GCC versions before 3.0 allowed zero-length arrays to be statically
1470 initialized, as if they were flexible arrays.  In addition to those
1471 cases that were useful, it also allowed initializations in situations
1472 that would corrupt later data.  Non-empty initialization of zero-length
1473 arrays is now treated like any case where there are more initializer
1474 elements than the array holds, in that a suitable warning about ``excess
1475 elements in array'' is given, and the excess elements (all of them, in
1476 this case) are ignored.
1478 Instead GCC allows static initialization of flexible array members.
1479 This is equivalent to defining a new structure containing the original
1480 structure followed by an array of sufficient size to contain the data.
1481 E.g.@: in the following, @code{f1} is constructed as if it were declared
1482 like @code{f2}.
1484 @smallexample
1485 struct f1 @{
1486   int x; int y[];
1487 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1489 struct f2 @{
1490   struct f1 f1; int data[3];
1491 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1492 @end smallexample
1494 @noindent
1495 The convenience of this extension is that @code{f1} has the desired
1496 type, eliminating the need to consistently refer to @code{f2.f1}.
1498 This has symmetry with normal static arrays, in that an array of
1499 unknown size is also written with @code{[]}.
1501 Of course, this extension only makes sense if the extra data comes at
1502 the end of a top-level object, as otherwise we would be overwriting
1503 data at subsequent offsets.  To avoid undue complication and confusion
1504 with initialization of deeply nested arrays, we simply disallow any
1505 non-empty initialization except when the structure is the top-level
1506 object.  For example:
1508 @smallexample
1509 struct foo @{ int x; int y[]; @};
1510 struct bar @{ struct foo z; @};
1512 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1513 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1514 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1515 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1516 @end smallexample
1518 @node Empty Structures
1519 @section Structures With No Members
1520 @cindex empty structures
1521 @cindex zero-size structures
1523 GCC permits a C structure to have no members:
1525 @smallexample
1526 struct empty @{
1528 @end smallexample
1530 The structure has size zero.  In C++, empty structures are part
1531 of the language.  G++ treats empty structures as if they had a single
1532 member of type @code{char}.
1534 @node Variable Length
1535 @section Arrays of Variable Length
1536 @cindex variable-length arrays
1537 @cindex arrays of variable length
1538 @cindex VLAs
1540 Variable-length automatic arrays are allowed in ISO C99, and as an
1541 extension GCC accepts them in C90 mode and in C++.  These arrays are
1542 declared like any other automatic arrays, but with a length that is not
1543 a constant expression.  The storage is allocated at the point of
1544 declaration and deallocated when the block scope containing the declaration
1545 exits.  For
1546 example:
1548 @smallexample
1549 FILE *
1550 concat_fopen (char *s1, char *s2, char *mode)
1552   char str[strlen (s1) + strlen (s2) + 1];
1553   strcpy (str, s1);
1554   strcat (str, s2);
1555   return fopen (str, mode);
1557 @end smallexample
1559 @cindex scope of a variable length array
1560 @cindex variable-length array scope
1561 @cindex deallocating variable length arrays
1562 Jumping or breaking out of the scope of the array name deallocates the
1563 storage.  Jumping into the scope is not allowed; you get an error
1564 message for it.
1566 @cindex @code{alloca} vs variable-length arrays
1567 You can use the function @code{alloca} to get an effect much like
1568 variable-length arrays.  The function @code{alloca} is available in
1569 many other C implementations (but not in all).  On the other hand,
1570 variable-length arrays are more elegant.
1572 There are other differences between these two methods.  Space allocated
1573 with @code{alloca} exists until the containing @emph{function} returns.
1574 The space for a variable-length array is deallocated as soon as the array
1575 name's scope ends.  (If you use both variable-length arrays and
1576 @code{alloca} in the same function, deallocation of a variable-length array
1577 also deallocates anything more recently allocated with @code{alloca}.)
1579 You can also use variable-length arrays as arguments to functions:
1581 @smallexample
1582 struct entry
1583 tester (int len, char data[len][len])
1585   /* @r{@dots{}} */
1587 @end smallexample
1589 The length of an array is computed once when the storage is allocated
1590 and is remembered for the scope of the array in case you access it with
1591 @code{sizeof}.
1593 If you want to pass the array first and the length afterward, you can
1594 use a forward declaration in the parameter list---another GNU extension.
1596 @smallexample
1597 struct entry
1598 tester (int len; char data[len][len], int len)
1600   /* @r{@dots{}} */
1602 @end smallexample
1604 @cindex parameter forward declaration
1605 The @samp{int len} before the semicolon is a @dfn{parameter forward
1606 declaration}, and it serves the purpose of making the name @code{len}
1607 known when the declaration of @code{data} is parsed.
1609 You can write any number of such parameter forward declarations in the
1610 parameter list.  They can be separated by commas or semicolons, but the
1611 last one must end with a semicolon, which is followed by the ``real''
1612 parameter declarations.  Each forward declaration must match a ``real''
1613 declaration in parameter name and data type.  ISO C99 does not support
1614 parameter forward declarations.
1616 @node Variadic Macros
1617 @section Macros with a Variable Number of Arguments.
1618 @cindex variable number of arguments
1619 @cindex macro with variable arguments
1620 @cindex rest argument (in macro)
1621 @cindex variadic macros
1623 In the ISO C standard of 1999, a macro can be declared to accept a
1624 variable number of arguments much as a function can.  The syntax for
1625 defining the macro is similar to that of a function.  Here is an
1626 example:
1628 @smallexample
1629 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1630 @end smallexample
1632 @noindent
1633 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1634 such a macro, it represents the zero or more tokens until the closing
1635 parenthesis that ends the invocation, including any commas.  This set of
1636 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1637 wherever it appears.  See the CPP manual for more information.
1639 GCC has long supported variadic macros, and used a different syntax that
1640 allowed you to give a name to the variable arguments just like any other
1641 argument.  Here is an example:
1643 @smallexample
1644 #define debug(format, args...) fprintf (stderr, format, args)
1645 @end smallexample
1647 @noindent
1648 This is in all ways equivalent to the ISO C example above, but arguably
1649 more readable and descriptive.
1651 GNU CPP has two further variadic macro extensions, and permits them to
1652 be used with either of the above forms of macro definition.
1654 In standard C, you are not allowed to leave the variable argument out
1655 entirely; but you are allowed to pass an empty argument.  For example,
1656 this invocation is invalid in ISO C, because there is no comma after
1657 the string:
1659 @smallexample
1660 debug ("A message")
1661 @end smallexample
1663 GNU CPP permits you to completely omit the variable arguments in this
1664 way.  In the above examples, the compiler would complain, though since
1665 the expansion of the macro still has the extra comma after the format
1666 string.
1668 To help solve this problem, CPP behaves specially for variable arguments
1669 used with the token paste operator, @samp{##}.  If instead you write
1671 @smallexample
1672 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1673 @end smallexample
1675 @noindent
1676 and if the variable arguments are omitted or empty, the @samp{##}
1677 operator causes the preprocessor to remove the comma before it.  If you
1678 do provide some variable arguments in your macro invocation, GNU CPP
1679 does not complain about the paste operation and instead places the
1680 variable arguments after the comma.  Just like any other pasted macro
1681 argument, these arguments are not macro expanded.
1683 @node Escaped Newlines
1684 @section Slightly Looser Rules for Escaped Newlines
1685 @cindex escaped newlines
1686 @cindex newlines (escaped)
1688 Recently, the preprocessor has relaxed its treatment of escaped
1689 newlines.  Previously, the newline had to immediately follow a
1690 backslash.  The current implementation allows whitespace in the form
1691 of spaces, horizontal and vertical tabs, and form feeds between the
1692 backslash and the subsequent newline.  The preprocessor issues a
1693 warning, but treats it as a valid escaped newline and combines the two
1694 lines to form a single logical line.  This works within comments and
1695 tokens, as well as between tokens.  Comments are @emph{not} treated as
1696 whitespace for the purposes of this relaxation, since they have not
1697 yet been replaced with spaces.
1699 @node Subscripting
1700 @section Non-Lvalue Arrays May Have Subscripts
1701 @cindex subscripting
1702 @cindex arrays, non-lvalue
1704 @cindex subscripting and function values
1705 In ISO C99, arrays that are not lvalues still decay to pointers, and
1706 may be subscripted, although they may not be modified or used after
1707 the next sequence point and the unary @samp{&} operator may not be
1708 applied to them.  As an extension, GNU C allows such arrays to be
1709 subscripted in C90 mode, though otherwise they do not decay to
1710 pointers outside C99 mode.  For example,
1711 this is valid in GNU C though not valid in C90:
1713 @smallexample
1714 @group
1715 struct foo @{int a[4];@};
1717 struct foo f();
1719 bar (int index)
1721   return f().a[index];
1723 @end group
1724 @end smallexample
1726 @node Pointer Arith
1727 @section Arithmetic on @code{void}- and Function-Pointers
1728 @cindex void pointers, arithmetic
1729 @cindex void, size of pointer to
1730 @cindex function pointers, arithmetic
1731 @cindex function, size of pointer to
1733 In GNU C, addition and subtraction operations are supported on pointers to
1734 @code{void} and on pointers to functions.  This is done by treating the
1735 size of a @code{void} or of a function as 1.
1737 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1738 and on function types, and returns 1.
1740 @opindex Wpointer-arith
1741 The option @option{-Wpointer-arith} requests a warning if these extensions
1742 are used.
1744 @node Initializers
1745 @section Non-Constant Initializers
1746 @cindex initializers, non-constant
1747 @cindex non-constant initializers
1749 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1750 automatic variable are not required to be constant expressions in GNU C@.
1751 Here is an example of an initializer with run-time varying elements:
1753 @smallexample
1754 foo (float f, float g)
1756   float beat_freqs[2] = @{ f-g, f+g @};
1757   /* @r{@dots{}} */
1759 @end smallexample
1761 @node Compound Literals
1762 @section Compound Literals
1763 @cindex constructor expressions
1764 @cindex initializations in expressions
1765 @cindex structures, constructor expression
1766 @cindex expressions, constructor
1767 @cindex compound literals
1768 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1770 ISO C99 supports compound literals.  A compound literal looks like
1771 a cast containing an initializer.  Its value is an object of the
1772 type specified in the cast, containing the elements specified in
1773 the initializer; it is an lvalue.  As an extension, GCC supports
1774 compound literals in C90 mode and in C++, though the semantics are
1775 somewhat different in C++.
1777 Usually, the specified type is a structure.  Assume that
1778 @code{struct foo} and @code{structure} are declared as shown:
1780 @smallexample
1781 struct foo @{int a; char b[2];@} structure;
1782 @end smallexample
1784 @noindent
1785 Here is an example of constructing a @code{struct foo} with a compound literal:
1787 @smallexample
1788 structure = ((struct foo) @{x + y, 'a', 0@});
1789 @end smallexample
1791 @noindent
1792 This is equivalent to writing the following:
1794 @smallexample
1796   struct foo temp = @{x + y, 'a', 0@};
1797   structure = temp;
1799 @end smallexample
1801 You can also construct an array, though this is dangerous in C++, as
1802 explained below.  If all the elements of the compound literal are
1803 (made up of) simple constant expressions, suitable for use in
1804 initializers of objects of static storage duration, then the compound
1805 literal can be coerced to a pointer to its first element and used in
1806 such an initializer, as shown here:
1808 @smallexample
1809 char **foo = (char *[]) @{ "x", "y", "z" @};
1810 @end smallexample
1812 Compound literals for scalar types and union types are
1813 also allowed, but then the compound literal is equivalent
1814 to a cast.
1816 As a GNU extension, GCC allows initialization of objects with static storage
1817 duration by compound literals (which is not possible in ISO C99, because
1818 the initializer is not a constant).
1819 It is handled as if the object is initialized only with the bracket
1820 enclosed list if the types of the compound literal and the object match.
1821 The initializer list of the compound literal must be constant.
1822 If the object being initialized has array type of unknown size, the size is
1823 determined by compound literal size.
1825 @smallexample
1826 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1827 static int y[] = (int []) @{1, 2, 3@};
1828 static int z[] = (int [3]) @{1@};
1829 @end smallexample
1831 @noindent
1832 The above lines are equivalent to the following:
1833 @smallexample
1834 static struct foo x = @{1, 'a', 'b'@};
1835 static int y[] = @{1, 2, 3@};
1836 static int z[] = @{1, 0, 0@};
1837 @end smallexample
1839 In C, a compound literal designates an unnamed object with static or
1840 automatic storage duration.  In C++, a compound literal designates a
1841 temporary object, which only lives until the end of its
1842 full-expression.  As a result, well-defined C code that takes the
1843 address of a subobject of a compound literal can be undefined in C++.
1844 For instance, if the array compound literal example above appeared
1845 inside a function, any subsequent use of @samp{foo} in C++ has
1846 undefined behavior because the lifetime of the array ends after the
1847 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1848 the conversion of a temporary array to a pointer.
1850 As an optimization, the C++ compiler sometimes gives array compound
1851 literals longer lifetimes: when the array either appears outside a
1852 function or has const-qualified type.  If @samp{foo} and its
1853 initializer had elements of @samp{char *const} type rather than
1854 @samp{char *}, or if @samp{foo} were a global variable, the array
1855 would have static storage duration.  But it is probably safest just to
1856 avoid the use of array compound literals in code compiled as C++.
1858 @node Designated Inits
1859 @section Designated Initializers
1860 @cindex initializers with labeled elements
1861 @cindex labeled elements in initializers
1862 @cindex case labels in initializers
1863 @cindex designated initializers
1865 Standard C90 requires the elements of an initializer to appear in a fixed
1866 order, the same as the order of the elements in the array or structure
1867 being initialized.
1869 In ISO C99 you can give the elements in any order, specifying the array
1870 indices or structure field names they apply to, and GNU C allows this as
1871 an extension in C90 mode as well.  This extension is not
1872 implemented in GNU C++.
1874 To specify an array index, write
1875 @samp{[@var{index}] =} before the element value.  For example,
1877 @smallexample
1878 int a[6] = @{ [4] = 29, [2] = 15 @};
1879 @end smallexample
1881 @noindent
1882 is equivalent to
1884 @smallexample
1885 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1886 @end smallexample
1888 @noindent
1889 The index values must be constant expressions, even if the array being
1890 initialized is automatic.
1892 An alternative syntax for this that has been obsolete since GCC 2.5 but
1893 GCC still accepts is to write @samp{[@var{index}]} before the element
1894 value, with no @samp{=}.
1896 To initialize a range of elements to the same value, write
1897 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1898 extension.  For example,
1900 @smallexample
1901 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1902 @end smallexample
1904 @noindent
1905 If the value in it has side-effects, the side-effects happen only once,
1906 not for each initialized field by the range initializer.
1908 @noindent
1909 Note that the length of the array is the highest value specified
1910 plus one.
1912 In a structure initializer, specify the name of a field to initialize
1913 with @samp{.@var{fieldname} =} before the element value.  For example,
1914 given the following structure,
1916 @smallexample
1917 struct point @{ int x, y; @};
1918 @end smallexample
1920 @noindent
1921 the following initialization
1923 @smallexample
1924 struct point p = @{ .y = yvalue, .x = xvalue @};
1925 @end smallexample
1927 @noindent
1928 is equivalent to
1930 @smallexample
1931 struct point p = @{ xvalue, yvalue @};
1932 @end smallexample
1934 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1935 @samp{@var{fieldname}:}, as shown here:
1937 @smallexample
1938 struct point p = @{ y: yvalue, x: xvalue @};
1939 @end smallexample
1941 @cindex designators
1942 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1943 @dfn{designator}.  You can also use a designator (or the obsolete colon
1944 syntax) when initializing a union, to specify which element of the union
1945 should be used.  For example,
1947 @smallexample
1948 union foo @{ int i; double d; @};
1950 union foo f = @{ .d = 4 @};
1951 @end smallexample
1953 @noindent
1954 converts 4 to a @code{double} to store it in the union using
1955 the second element.  By contrast, casting 4 to type @code{union foo}
1956 stores it into the union as the integer @code{i}, since it is
1957 an integer.  (@xref{Cast to Union}.)
1959 You can combine this technique of naming elements with ordinary C
1960 initialization of successive elements.  Each initializer element that
1961 does not have a designator applies to the next consecutive element of the
1962 array or structure.  For example,
1964 @smallexample
1965 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1966 @end smallexample
1968 @noindent
1969 is equivalent to
1971 @smallexample
1972 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1973 @end smallexample
1975 Labeling the elements of an array initializer is especially useful
1976 when the indices are characters or belong to an @code{enum} type.
1977 For example:
1979 @smallexample
1980 int whitespace[256]
1981   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1982       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1983 @end smallexample
1985 @cindex designator lists
1986 You can also write a series of @samp{.@var{fieldname}} and
1987 @samp{[@var{index}]} designators before an @samp{=} to specify a
1988 nested subobject to initialize; the list is taken relative to the
1989 subobject corresponding to the closest surrounding brace pair.  For
1990 example, with the @samp{struct point} declaration above:
1992 @smallexample
1993 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1994 @end smallexample
1996 @noindent
1997 If the same field is initialized multiple times, it has the value from
1998 the last initialization.  If any such overridden initialization has
1999 side-effect, it is unspecified whether the side-effect happens or not.
2000 Currently, GCC discards them and issues a warning.
2002 @node Case Ranges
2003 @section Case Ranges
2004 @cindex case ranges
2005 @cindex ranges in case statements
2007 You can specify a range of consecutive values in a single @code{case} label,
2008 like this:
2010 @smallexample
2011 case @var{low} ... @var{high}:
2012 @end smallexample
2014 @noindent
2015 This has the same effect as the proper number of individual @code{case}
2016 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2018 This feature is especially useful for ranges of ASCII character codes:
2020 @smallexample
2021 case 'A' ... 'Z':
2022 @end smallexample
2024 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2025 it may be parsed wrong when you use it with integer values.  For example,
2026 write this:
2028 @smallexample
2029 case 1 ... 5:
2030 @end smallexample
2032 @noindent
2033 rather than this:
2035 @smallexample
2036 case 1...5:
2037 @end smallexample
2039 @node Cast to Union
2040 @section Cast to a Union Type
2041 @cindex cast to a union
2042 @cindex union, casting to a
2044 A cast to union type is similar to other casts, except that the type
2045 specified is a union type.  You can specify the type either with
2046 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2047 a constructor, not a cast, and hence does not yield an lvalue like
2048 normal casts.  (@xref{Compound Literals}.)
2050 The types that may be cast to the union type are those of the members
2051 of the union.  Thus, given the following union and variables:
2053 @smallexample
2054 union foo @{ int i; double d; @};
2055 int x;
2056 double y;
2057 @end smallexample
2059 @noindent
2060 both @code{x} and @code{y} can be cast to type @code{union foo}.
2062 Using the cast as the right-hand side of an assignment to a variable of
2063 union type is equivalent to storing in a member of the union:
2065 @smallexample
2066 union foo u;
2067 /* @r{@dots{}} */
2068 u = (union foo) x  @equiv{}  u.i = x
2069 u = (union foo) y  @equiv{}  u.d = y
2070 @end smallexample
2072 You can also use the union cast as a function argument:
2074 @smallexample
2075 void hack (union foo);
2076 /* @r{@dots{}} */
2077 hack ((union foo) x);
2078 @end smallexample
2080 @node Mixed Declarations
2081 @section Mixed Declarations and Code
2082 @cindex mixed declarations and code
2083 @cindex declarations, mixed with code
2084 @cindex code, mixed with declarations
2086 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2087 within compound statements.  As an extension, GNU C also allows this in
2088 C90 mode.  For example, you could do:
2090 @smallexample
2091 int i;
2092 /* @r{@dots{}} */
2093 i++;
2094 int j = i + 2;
2095 @end smallexample
2097 Each identifier is visible from where it is declared until the end of
2098 the enclosing block.
2100 @node Function Attributes
2101 @section Declaring Attributes of Functions
2102 @cindex function attributes
2103 @cindex declaring attributes of functions
2104 @cindex functions that never return
2105 @cindex functions that return more than once
2106 @cindex functions that have no side effects
2107 @cindex functions in arbitrary sections
2108 @cindex functions that behave like malloc
2109 @cindex @code{volatile} applied to function
2110 @cindex @code{const} applied to function
2111 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2112 @cindex functions with non-null pointer arguments
2113 @cindex functions that are passed arguments in registers on the 386
2114 @cindex functions that pop the argument stack on the 386
2115 @cindex functions that do not pop the argument stack on the 386
2116 @cindex functions that have different compilation options on the 386
2117 @cindex functions that have different optimization options
2118 @cindex functions that are dynamically resolved
2120 In GNU C, you declare certain things about functions called in your program
2121 which help the compiler optimize function calls and check your code more
2122 carefully.
2124 The keyword @code{__attribute__} allows you to specify special
2125 attributes when making a declaration.  This keyword is followed by an
2126 attribute specification inside double parentheses.  The following
2127 attributes are currently defined for functions on all targets:
2128 @code{aligned}, @code{alloc_size}, @code{noreturn},
2129 @code{returns_twice}, @code{noinline}, @code{noclone},
2130 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2131 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2132 @code{no_instrument_function}, @code{no_split_stack},
2133 @code{section}, @code{constructor},
2134 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2135 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2136 @code{warn_unused_result}, @code{nonnull},
2137 @code{returns_nonnull}, @code{gnu_inline},
2138 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2139 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2140 @code{no_sanitize_undefined},
2141 @code{error} and @code{warning}.
2142 Several other attributes are defined for functions on particular
2143 target systems.  Other attributes, including @code{section} are
2144 supported for variables declarations (@pxref{Variable Attributes})
2145 and for types (@pxref{Type Attributes}).
2147 GCC plugins may provide their own attributes.
2149 You may also specify attributes with @samp{__} preceding and following
2150 each keyword.  This allows you to use them in header files without
2151 being concerned about a possible macro of the same name.  For example,
2152 you may use @code{__noreturn__} instead of @code{noreturn}.
2154 @xref{Attribute Syntax}, for details of the exact syntax for using
2155 attributes.
2157 @table @code
2158 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2160 @item alias ("@var{target}")
2161 @cindex @code{alias} attribute
2162 The @code{alias} attribute causes the declaration to be emitted as an
2163 alias for another symbol, which must be specified.  For instance,
2165 @smallexample
2166 void __f () @{ /* @r{Do something.} */; @}
2167 void f () __attribute__ ((weak, alias ("__f")));
2168 @end smallexample
2170 @noindent
2171 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2172 mangled name for the target must be used.  It is an error if @samp{__f}
2173 is not defined in the same translation unit.
2175 Not all target machines support this attribute.
2177 @item aligned (@var{alignment})
2178 @cindex @code{aligned} attribute
2179 This attribute specifies a minimum alignment for the function,
2180 measured in bytes.
2182 You cannot use this attribute to decrease the alignment of a function,
2183 only to increase it.  However, when you explicitly specify a function
2184 alignment this overrides the effect of the
2185 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2186 function.
2188 Note that the effectiveness of @code{aligned} attributes may be
2189 limited by inherent limitations in your linker.  On many systems, the
2190 linker is only able to arrange for functions to be aligned up to a
2191 certain maximum alignment.  (For some linkers, the maximum supported
2192 alignment may be very very small.)  See your linker documentation for
2193 further information.
2195 The @code{aligned} attribute can also be used for variables and fields
2196 (@pxref{Variable Attributes}.)
2198 @item alloc_size
2199 @cindex @code{alloc_size} attribute
2200 The @code{alloc_size} attribute is used to tell the compiler that the
2201 function return value points to memory, where the size is given by
2202 one or two of the functions parameters.  GCC uses this
2203 information to improve the correctness of @code{__builtin_object_size}.
2205 The function parameter(s) denoting the allocated size are specified by
2206 one or two integer arguments supplied to the attribute.  The allocated size
2207 is either the value of the single function argument specified or the product
2208 of the two function arguments specified.  Argument numbering starts at
2209 one.
2211 For instance,
2213 @smallexample
2214 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2215 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2216 @end smallexample
2218 @noindent
2219 declares that @code{my_calloc} returns memory of the size given by
2220 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2221 of the size given by parameter 2.
2223 @item always_inline
2224 @cindex @code{always_inline} function attribute
2225 Generally, functions are not inlined unless optimization is specified.
2226 For functions declared inline, this attribute inlines the function even
2227 if no optimization level is specified.
2229 @item gnu_inline
2230 @cindex @code{gnu_inline} function attribute
2231 This attribute should be used with a function that is also declared
2232 with the @code{inline} keyword.  It directs GCC to treat the function
2233 as if it were defined in gnu90 mode even when compiling in C99 or
2234 gnu99 mode.
2236 If the function is declared @code{extern}, then this definition of the
2237 function is used only for inlining.  In no case is the function
2238 compiled as a standalone function, not even if you take its address
2239 explicitly.  Such an address becomes an external reference, as if you
2240 had only declared the function, and had not defined it.  This has
2241 almost the effect of a macro.  The way to use this is to put a
2242 function definition in a header file with this attribute, and put
2243 another copy of the function, without @code{extern}, in a library
2244 file.  The definition in the header file causes most calls to the
2245 function to be inlined.  If any uses of the function remain, they
2246 refer to the single copy in the library.  Note that the two
2247 definitions of the functions need not be precisely the same, although
2248 if they do not have the same effect your program may behave oddly.
2250 In C, if the function is neither @code{extern} nor @code{static}, then
2251 the function is compiled as a standalone function, as well as being
2252 inlined where possible.
2254 This is how GCC traditionally handled functions declared
2255 @code{inline}.  Since ISO C99 specifies a different semantics for
2256 @code{inline}, this function attribute is provided as a transition
2257 measure and as a useful feature in its own right.  This attribute is
2258 available in GCC 4.1.3 and later.  It is available if either of the
2259 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2260 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2261 Function is As Fast As a Macro}.
2263 In C++, this attribute does not depend on @code{extern} in any way,
2264 but it still requires the @code{inline} keyword to enable its special
2265 behavior.
2267 @item artificial
2268 @cindex @code{artificial} function attribute
2269 This attribute is useful for small inline wrappers that if possible
2270 should appear during debugging as a unit.  Depending on the debug
2271 info format it either means marking the function as artificial
2272 or using the caller location for all instructions within the inlined
2273 body.
2275 @item bank_switch
2276 @cindex interrupt handler functions
2277 When added to an interrupt handler with the M32C port, causes the
2278 prologue and epilogue to use bank switching to preserve the registers
2279 rather than saving them on the stack.
2281 @item flatten
2282 @cindex @code{flatten} function attribute
2283 Generally, inlining into a function is limited.  For a function marked with
2284 this attribute, every call inside this function is inlined, if possible.
2285 Whether the function itself is considered for inlining depends on its size and
2286 the current inlining parameters.
2288 @item error ("@var{message}")
2289 @cindex @code{error} function attribute
2290 If this attribute is used on a function declaration and a call to such a function
2291 is not eliminated through dead code elimination or other optimizations, an error
2292 that includes @var{message} is diagnosed.  This is useful
2293 for compile-time checking, especially together with @code{__builtin_constant_p}
2294 and inline functions where checking the inline function arguments is not
2295 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2296 While it is possible to leave the function undefined and thus invoke
2297 a link failure, when using this attribute the problem is diagnosed
2298 earlier and with exact location of the call even in presence of inline
2299 functions or when not emitting debugging information.
2301 @item warning ("@var{message}")
2302 @cindex @code{warning} function attribute
2303 If this attribute is used on a function declaration and a call to such a function
2304 is not eliminated through dead code elimination or other optimizations, a warning
2305 that includes @var{message} is diagnosed.  This is useful
2306 for compile-time checking, especially together with @code{__builtin_constant_p}
2307 and inline functions.  While it is possible to define the function with
2308 a message in @code{.gnu.warning*} section, when using this attribute the problem
2309 is diagnosed earlier and with exact location of the call even in presence
2310 of inline functions or when not emitting debugging information.
2312 @item cdecl
2313 @cindex functions that do pop the argument stack on the 386
2314 @opindex mrtd
2315 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2316 assume that the calling function pops off the stack space used to
2317 pass arguments.  This is
2318 useful to override the effects of the @option{-mrtd} switch.
2320 @item const
2321 @cindex @code{const} function attribute
2322 Many functions do not examine any values except their arguments, and
2323 have no effects except the return value.  Basically this is just slightly
2324 more strict class than the @code{pure} attribute below, since function is not
2325 allowed to read global memory.
2327 @cindex pointer arguments
2328 Note that a function that has pointer arguments and examines the data
2329 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2330 function that calls a non-@code{const} function usually must not be
2331 @code{const}.  It does not make sense for a @code{const} function to
2332 return @code{void}.
2334 The attribute @code{const} is not implemented in GCC versions earlier
2335 than 2.5.  An alternative way to declare that a function has no side
2336 effects, which works in the current version and in some older versions,
2337 is as follows:
2339 @smallexample
2340 typedef int intfn ();
2342 extern const intfn square;
2343 @end smallexample
2345 @noindent
2346 This approach does not work in GNU C++ from 2.6.0 on, since the language
2347 specifies that the @samp{const} must be attached to the return value.
2349 @item constructor
2350 @itemx destructor
2351 @itemx constructor (@var{priority})
2352 @itemx destructor (@var{priority})
2353 @cindex @code{constructor} function attribute
2354 @cindex @code{destructor} function attribute
2355 The @code{constructor} attribute causes the function to be called
2356 automatically before execution enters @code{main ()}.  Similarly, the
2357 @code{destructor} attribute causes the function to be called
2358 automatically after @code{main ()} completes or @code{exit ()} is
2359 called.  Functions with these attributes are useful for
2360 initializing data that is used implicitly during the execution of
2361 the program.
2363 You may provide an optional integer priority to control the order in
2364 which constructor and destructor functions are run.  A constructor
2365 with a smaller priority number runs before a constructor with a larger
2366 priority number; the opposite relationship holds for destructors.  So,
2367 if you have a constructor that allocates a resource and a destructor
2368 that deallocates the same resource, both functions typically have the
2369 same priority.  The priorities for constructor and destructor
2370 functions are the same as those specified for namespace-scope C++
2371 objects (@pxref{C++ Attributes}).
2373 These attributes are not currently implemented for Objective-C@.
2375 @item deprecated
2376 @itemx deprecated (@var{msg})
2377 @cindex @code{deprecated} attribute.
2378 The @code{deprecated} attribute results in a warning if the function
2379 is used anywhere in the source file.  This is useful when identifying
2380 functions that are expected to be removed in a future version of a
2381 program.  The warning also includes the location of the declaration
2382 of the deprecated function, to enable users to easily find further
2383 information about why the function is deprecated, or what they should
2384 do instead.  Note that the warnings only occurs for uses:
2386 @smallexample
2387 int old_fn () __attribute__ ((deprecated));
2388 int old_fn ();
2389 int (*fn_ptr)() = old_fn;
2390 @end smallexample
2392 @noindent
2393 results in a warning on line 3 but not line 2.  The optional @var{msg}
2394 argument, which must be a string, is printed in the warning if
2395 present.
2397 The @code{deprecated} attribute can also be used for variables and
2398 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2400 @item disinterrupt
2401 @cindex @code{disinterrupt} attribute
2402 On Epiphany and MeP targets, this attribute causes the compiler to emit
2403 instructions to disable interrupts for the duration of the given
2404 function.
2406 @item dllexport
2407 @cindex @code{__declspec(dllexport)}
2408 On Microsoft Windows targets and Symbian OS targets the
2409 @code{dllexport} attribute causes the compiler to provide a global
2410 pointer to a pointer in a DLL, so that it can be referenced with the
2411 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2412 name is formed by combining @code{_imp__} and the function or variable
2413 name.
2415 You can use @code{__declspec(dllexport)} as a synonym for
2416 @code{__attribute__ ((dllexport))} for compatibility with other
2417 compilers.
2419 On systems that support the @code{visibility} attribute, this
2420 attribute also implies ``default'' visibility.  It is an error to
2421 explicitly specify any other visibility.
2423 In previous versions of GCC, the @code{dllexport} attribute was ignored
2424 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2425 had been used.  The default behavior now is to emit all dllexported
2426 inline functions; however, this can cause object file-size bloat, in
2427 which case the old behavior can be restored by using
2428 @option{-fno-keep-inline-dllexport}.
2430 The attribute is also ignored for undefined symbols.
2432 When applied to C++ classes, the attribute marks defined non-inlined
2433 member functions and static data members as exports.  Static consts
2434 initialized in-class are not marked unless they are also defined
2435 out-of-class.
2437 For Microsoft Windows targets there are alternative methods for
2438 including the symbol in the DLL's export table such as using a
2439 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2440 the @option{--export-all} linker flag.
2442 @item dllimport
2443 @cindex @code{__declspec(dllimport)}
2444 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2445 attribute causes the compiler to reference a function or variable via
2446 a global pointer to a pointer that is set up by the DLL exporting the
2447 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2448 targets, the pointer name is formed by combining @code{_imp__} and the
2449 function or variable name.
2451 You can use @code{__declspec(dllimport)} as a synonym for
2452 @code{__attribute__ ((dllimport))} for compatibility with other
2453 compilers.
2455 On systems that support the @code{visibility} attribute, this
2456 attribute also implies ``default'' visibility.  It is an error to
2457 explicitly specify any other visibility.
2459 Currently, the attribute is ignored for inlined functions.  If the
2460 attribute is applied to a symbol @emph{definition}, an error is reported.
2461 If a symbol previously declared @code{dllimport} is later defined, the
2462 attribute is ignored in subsequent references, and a warning is emitted.
2463 The attribute is also overridden by a subsequent declaration as
2464 @code{dllexport}.
2466 When applied to C++ classes, the attribute marks non-inlined
2467 member functions and static data members as imports.  However, the
2468 attribute is ignored for virtual methods to allow creation of vtables
2469 using thunks.
2471 On the SH Symbian OS target the @code{dllimport} attribute also has
2472 another affect---it can cause the vtable and run-time type information
2473 for a class to be exported.  This happens when the class has a
2474 dllimported constructor or a non-inline, non-pure virtual function
2475 and, for either of those two conditions, the class also has an inline
2476 constructor or destructor and has a key function that is defined in
2477 the current translation unit.
2479 For Microsoft Windows targets the use of the @code{dllimport}
2480 attribute on functions is not necessary, but provides a small
2481 performance benefit by eliminating a thunk in the DLL@.  The use of the
2482 @code{dllimport} attribute on imported variables was required on older
2483 versions of the GNU linker, but can now be avoided by passing the
2484 @option{--enable-auto-import} switch to the GNU linker.  As with
2485 functions, using the attribute for a variable eliminates a thunk in
2486 the DLL@.
2488 One drawback to using this attribute is that a pointer to a
2489 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2490 address. However, a pointer to a @emph{function} with the
2491 @code{dllimport} attribute can be used as a constant initializer; in
2492 this case, the address of a stub function in the import lib is
2493 referenced.  On Microsoft Windows targets, the attribute can be disabled
2494 for functions by setting the @option{-mnop-fun-dllimport} flag.
2496 @item eightbit_data
2497 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2498 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2499 variable should be placed into the eight-bit data section.
2500 The compiler generates more efficient code for certain operations
2501 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2502 256 bytes of data.
2504 You must use GAS and GLD from GNU binutils version 2.7 or later for
2505 this attribute to work correctly.
2507 @item exception_handler
2508 @cindex exception handler functions on the Blackfin processor
2509 Use this attribute on the Blackfin to indicate that the specified function
2510 is an exception handler.  The compiler generates function entry and
2511 exit sequences suitable for use in an exception handler when this
2512 attribute is present.
2514 @item externally_visible
2515 @cindex @code{externally_visible} attribute.
2516 This attribute, attached to a global variable or function, nullifies
2517 the effect of the @option{-fwhole-program} command-line option, so the
2518 object remains visible outside the current compilation unit.
2520 If @option{-fwhole-program} is used together with @option{-flto} and 
2521 @command{gold} is used as the linker plugin, 
2522 @code{externally_visible} attributes are automatically added to functions 
2523 (not variable yet due to a current @command{gold} issue) 
2524 that are accessed outside of LTO objects according to resolution file
2525 produced by @command{gold}.
2526 For other linkers that cannot generate resolution file,
2527 explicit @code{externally_visible} attributes are still necessary.
2529 @item far
2530 @cindex functions that handle memory bank switching
2531 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2532 use a calling convention that takes care of switching memory banks when
2533 entering and leaving a function.  This calling convention is also the
2534 default when using the @option{-mlong-calls} option.
2536 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2537 to call and return from a function.
2539 On 68HC11 the compiler generates a sequence of instructions
2540 to invoke a board-specific routine to switch the memory bank and call the
2541 real function.  The board-specific routine simulates a @code{call}.
2542 At the end of a function, it jumps to a board-specific routine
2543 instead of using @code{rts}.  The board-specific return routine simulates
2544 the @code{rtc}.
2546 On MeP targets this causes the compiler to use a calling convention
2547 that assumes the called function is too far away for the built-in
2548 addressing modes.
2550 @item fast_interrupt
2551 @cindex interrupt handler functions
2552 Use this attribute on the M32C and RX ports to indicate that the specified
2553 function is a fast interrupt handler.  This is just like the
2554 @code{interrupt} attribute, except that @code{freit} is used to return
2555 instead of @code{reit}.
2557 @item fastcall
2558 @cindex functions that pop the argument stack on the 386
2559 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2560 pass the first argument (if of integral type) in the register ECX and
2561 the second argument (if of integral type) in the register EDX@.  Subsequent
2562 and other typed arguments are passed on the stack.  The called function
2563 pops the arguments off the stack.  If the number of arguments is variable all
2564 arguments are pushed on the stack.
2566 @item thiscall
2567 @cindex functions that pop the argument stack on the 386
2568 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2569 pass the first argument (if of integral type) in the register ECX.
2570 Subsequent and other typed arguments are passed on the stack. The called
2571 function pops the arguments off the stack.
2572 If the number of arguments is variable all arguments are pushed on the
2573 stack.
2574 The @code{thiscall} attribute is intended for C++ non-static member functions.
2575 As a GCC extension, this calling convention can be used for C functions
2576 and for static member methods.
2578 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2579 @cindex @code{format} function attribute
2580 @opindex Wformat
2581 The @code{format} attribute specifies that a function takes @code{printf},
2582 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2583 should be type-checked against a format string.  For example, the
2584 declaration:
2586 @smallexample
2587 extern int
2588 my_printf (void *my_object, const char *my_format, ...)
2589       __attribute__ ((format (printf, 2, 3)));
2590 @end smallexample
2592 @noindent
2593 causes the compiler to check the arguments in calls to @code{my_printf}
2594 for consistency with the @code{printf} style format string argument
2595 @code{my_format}.
2597 The parameter @var{archetype} determines how the format string is
2598 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2599 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2600 @code{strfmon}.  (You can also use @code{__printf__},
2601 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2602 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2603 @code{ms_strftime} are also present.
2604 @var{archetype} values such as @code{printf} refer to the formats accepted
2605 by the system's C runtime library,
2606 while values prefixed with @samp{gnu_} always refer
2607 to the formats accepted by the GNU C Library.  On Microsoft Windows
2608 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2609 @file{msvcrt.dll} library.
2610 The parameter @var{string-index}
2611 specifies which argument is the format string argument (starting
2612 from 1), while @var{first-to-check} is the number of the first
2613 argument to check against the format string.  For functions
2614 where the arguments are not available to be checked (such as
2615 @code{vprintf}), specify the third parameter as zero.  In this case the
2616 compiler only checks the format string for consistency.  For
2617 @code{strftime} formats, the third parameter is required to be zero.
2618 Since non-static C++ methods have an implicit @code{this} argument, the
2619 arguments of such methods should be counted from two, not one, when
2620 giving values for @var{string-index} and @var{first-to-check}.
2622 In the example above, the format string (@code{my_format}) is the second
2623 argument of the function @code{my_print}, and the arguments to check
2624 start with the third argument, so the correct parameters for the format
2625 attribute are 2 and 3.
2627 @opindex ffreestanding
2628 @opindex fno-builtin
2629 The @code{format} attribute allows you to identify your own functions
2630 that take format strings as arguments, so that GCC can check the
2631 calls to these functions for errors.  The compiler always (unless
2632 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2633 for the standard library functions @code{printf}, @code{fprintf},
2634 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2635 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2636 warnings are requested (using @option{-Wformat}), so there is no need to
2637 modify the header file @file{stdio.h}.  In C99 mode, the functions
2638 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2639 @code{vsscanf} are also checked.  Except in strictly conforming C
2640 standard modes, the X/Open function @code{strfmon} is also checked as
2641 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2642 @xref{C Dialect Options,,Options Controlling C Dialect}.
2644 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2645 recognized in the same context.  Declarations including these format attributes
2646 are parsed for correct syntax, however the result of checking of such format
2647 strings is not yet defined, and is not carried out by this version of the
2648 compiler.
2650 The target may also provide additional types of format checks.
2651 @xref{Target Format Checks,,Format Checks Specific to Particular
2652 Target Machines}.
2654 @item format_arg (@var{string-index})
2655 @cindex @code{format_arg} function attribute
2656 @opindex Wformat-nonliteral
2657 The @code{format_arg} attribute specifies that a function takes a format
2658 string for a @code{printf}, @code{scanf}, @code{strftime} or
2659 @code{strfmon} style function and modifies it (for example, to translate
2660 it into another language), so the result can be passed to a
2661 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2662 function (with the remaining arguments to the format function the same
2663 as they would have been for the unmodified string).  For example, the
2664 declaration:
2666 @smallexample
2667 extern char *
2668 my_dgettext (char *my_domain, const char *my_format)
2669       __attribute__ ((format_arg (2)));
2670 @end smallexample
2672 @noindent
2673 causes the compiler to check the arguments in calls to a @code{printf},
2674 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2675 format string argument is a call to the @code{my_dgettext} function, for
2676 consistency with the format string argument @code{my_format}.  If the
2677 @code{format_arg} attribute had not been specified, all the compiler
2678 could tell in such calls to format functions would be that the format
2679 string argument is not constant; this would generate a warning when
2680 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2681 without the attribute.
2683 The parameter @var{string-index} specifies which argument is the format
2684 string argument (starting from one).  Since non-static C++ methods have
2685 an implicit @code{this} argument, the arguments of such methods should
2686 be counted from two.
2688 The @code{format_arg} attribute allows you to identify your own
2689 functions that modify format strings, so that GCC can check the
2690 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2691 type function whose operands are a call to one of your own function.
2692 The compiler always treats @code{gettext}, @code{dgettext}, and
2693 @code{dcgettext} in this manner except when strict ISO C support is
2694 requested by @option{-ansi} or an appropriate @option{-std} option, or
2695 @option{-ffreestanding} or @option{-fno-builtin}
2696 is used.  @xref{C Dialect Options,,Options
2697 Controlling C Dialect}.
2699 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2700 @code{NSString} reference for compatibility with the @code{format} attribute
2701 above.
2703 The target may also allow additional types in @code{format-arg} attributes.
2704 @xref{Target Format Checks,,Format Checks Specific to Particular
2705 Target Machines}.
2707 @item function_vector
2708 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2709 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2710 function should be called through the function vector.  Calling a
2711 function through the function vector reduces code size, however;
2712 the function vector has a limited size (maximum 128 entries on the H8/300
2713 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2715 On SH2A targets, this attribute declares a function to be called using the
2716 TBR relative addressing mode.  The argument to this attribute is the entry
2717 number of the same function in a vector table containing all the TBR
2718 relative addressable functions.  For correct operation the TBR must be setup
2719 accordingly to point to the start of the vector table before any functions with
2720 this attribute are invoked.  Usually a good place to do the initialization is
2721 the startup routine.  The TBR relative vector table can have at max 256 function
2722 entries.  The jumps to these functions are generated using a SH2A specific,
2723 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2724 from GNU binutils version 2.7 or later for this attribute to work correctly.
2726 Please refer the example of M16C target, to see the use of this
2727 attribute while declaring a function,
2729 In an application, for a function being called once, this attribute
2730 saves at least 8 bytes of code; and if other successive calls are being
2731 made to the same function, it saves 2 bytes of code per each of these
2732 calls.
2734 On M16C/M32C targets, the @code{function_vector} attribute declares a
2735 special page subroutine call function. Use of this attribute reduces
2736 the code size by 2 bytes for each call generated to the
2737 subroutine. The argument to the attribute is the vector number entry
2738 from the special page vector table which contains the 16 low-order
2739 bits of the subroutine's entry address. Each vector table has special
2740 page number (18 to 255) that is used in @code{jsrs} instructions.
2741 Jump addresses of the routines are generated by adding 0x0F0000 (in
2742 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2743 2-byte addresses set in the vector table. Therefore you need to ensure
2744 that all the special page vector routines should get mapped within the
2745 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2746 (for M32C).
2748 In the following example 2 bytes are saved for each call to
2749 function @code{foo}.
2751 @smallexample
2752 void foo (void) __attribute__((function_vector(0x18)));
2753 void foo (void)
2757 void bar (void)
2759     foo();
2761 @end smallexample
2763 If functions are defined in one file and are called in another file,
2764 then be sure to write this declaration in both files.
2766 This attribute is ignored for R8C target.
2768 @item ifunc ("@var{resolver}")
2769 @cindex @code{ifunc} attribute
2770 The @code{ifunc} attribute is used to mark a function as an indirect
2771 function using the STT_GNU_IFUNC symbol type extension to the ELF
2772 standard.  This allows the resolution of the symbol value to be
2773 determined dynamically at load time, and an optimized version of the
2774 routine can be selected for the particular processor or other system
2775 characteristics determined then.  To use this attribute, first define
2776 the implementation functions available, and a resolver function that
2777 returns a pointer to the selected implementation function.  The
2778 implementation functions' declarations must match the API of the
2779 function being implemented, the resolver's declaration is be a
2780 function returning pointer to void function returning void:
2782 @smallexample
2783 void *my_memcpy (void *dst, const void *src, size_t len)
2785   @dots{}
2788 static void (*resolve_memcpy (void)) (void)
2790   return my_memcpy; // we'll just always select this routine
2792 @end smallexample
2794 @noindent
2795 The exported header file declaring the function the user calls would
2796 contain:
2798 @smallexample
2799 extern void *memcpy (void *, const void *, size_t);
2800 @end smallexample
2802 @noindent
2803 allowing the user to call this as a regular function, unaware of the
2804 implementation.  Finally, the indirect function needs to be defined in
2805 the same translation unit as the resolver function:
2807 @smallexample
2808 void *memcpy (void *, const void *, size_t)
2809      __attribute__ ((ifunc ("resolve_memcpy")));
2810 @end smallexample
2812 Indirect functions cannot be weak, and require a recent binutils (at
2813 least version 2.20.1), and GNU C library (at least version 2.11.1).
2815 @item interrupt
2816 @cindex interrupt handler functions
2817 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2818 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2819 the specified function is an
2820 interrupt handler.  The compiler generates function entry and exit
2821 sequences suitable for use in an interrupt handler when this attribute
2822 is present.  With Epiphany targets it may also generate a special section with
2823 code to initialize the interrupt vector table.
2825 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2826 and SH processors can be specified via the @code{interrupt_handler} attribute.
2828 Note, on the ARC, you must specify the kind of interrupt to be handled
2829 in a parameter to the interrupt attribute like this:
2831 @smallexample
2832 void f () __attribute__ ((interrupt ("ilink1")));
2833 @end smallexample
2835 Permissible values for this parameter are: @w{@code{ilink1}} and
2836 @w{@code{ilink2}}.
2838 Note, on the AVR, the hardware globally disables interrupts when an
2839 interrupt is executed.  The first instruction of an interrupt handler
2840 declared with this attribute is a @code{SEI} instruction to
2841 re-enable interrupts.  See also the @code{signal} function attribute
2842 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2843 @code{interrupt} are specified for the same function, @code{signal}
2844 is silently ignored.
2846 Note, for the ARM, you can specify the kind of interrupt to be handled by
2847 adding an optional parameter to the interrupt attribute like this:
2849 @smallexample
2850 void f () __attribute__ ((interrupt ("IRQ")));
2851 @end smallexample
2853 @noindent
2854 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2855 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2857 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2858 may be called with a word-aligned stack pointer.
2860 Note, for the MSP430 you can provide an argument to the interrupt
2861 attribute which specifies a name or number.  If the argument is a
2862 number it indicates the slot in the interrupt vector table (0 - 31) to
2863 which this handler should be assigned.  If the argument is a name it
2864 is treated as a symbolic name for the vector slot.  These names should
2865 match up with appropriate entries in the linker script.  By default
2866 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2867 @code{reset} for vector 31 are recognised.
2869 You can also use the following function attributes to modify how
2870 normal functions interact with interrupt functions:
2872 @table @code
2873 @item critical
2874 @cindex @code{critical} attribute
2875 Critical functions disable interrupts upon entry and restore the
2876 previous interrupt state upon exit.  Critical functions cannot also
2877 have the @code{naked} or @code{reentrant} attributes.  They can have
2878 the @code{interrupt} attribute.
2880 @item reentrant
2881 @cindex @code{reentrant} attribute
2882 Reentrant functions disable interrupts upon entry and enable them
2883 upon exit.  Reentrant functions cannot also have the @code{naked}
2884 or @code{critical} attributes.  They can have the @code{interrupt}
2885 attribute.
2887 @end table
2889 On Epiphany targets one or more optional parameters can be added like this:
2891 @smallexample
2892 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2893 @end smallexample
2895 Permissible values for these parameters are: @w{@code{reset}},
2896 @w{@code{software_exception}}, @w{@code{page_miss}},
2897 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2898 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2899 Multiple parameters indicate that multiple entries in the interrupt
2900 vector table should be initialized for this function, i.e.@: for each
2901 parameter @w{@var{name}}, a jump to the function is emitted in
2902 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
2903 entirely, in which case no interrupt vector table entry is provided.
2905 Note, on Epiphany targets, interrupts are enabled inside the function
2906 unless the @code{disinterrupt} attribute is also specified.
2908 On Epiphany targets, you can also use the following attribute to
2909 modify the behavior of an interrupt handler:
2910 @table @code
2911 @item forwarder_section
2912 @cindex @code{forwarder_section} attribute
2913 The interrupt handler may be in external memory which cannot be
2914 reached by a branch instruction, so generate a local memory trampoline
2915 to transfer control.  The single parameter identifies the section where
2916 the trampoline is placed.
2917 @end table
2919 The following examples are all valid uses of these attributes on
2920 Epiphany targets:
2921 @smallexample
2922 void __attribute__ ((interrupt)) universal_handler ();
2923 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2924 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2925 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2926   fast_timer_handler ();
2927 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2928   external_dma_handler ();
2929 @end smallexample
2931 On MIPS targets, you can use the following attributes to modify the behavior
2932 of an interrupt handler:
2933 @table @code
2934 @item use_shadow_register_set
2935 @cindex @code{use_shadow_register_set} attribute
2936 Assume that the handler uses a shadow register set, instead of
2937 the main general-purpose registers.
2939 @item keep_interrupts_masked
2940 @cindex @code{keep_interrupts_masked} attribute
2941 Keep interrupts masked for the whole function.  Without this attribute,
2942 GCC tries to reenable interrupts for as much of the function as it can.
2944 @item use_debug_exception_return
2945 @cindex @code{use_debug_exception_return} attribute
2946 Return using the @code{deret} instruction.  Interrupt handlers that don't
2947 have this attribute return using @code{eret} instead.
2948 @end table
2950 You can use any combination of these attributes, as shown below:
2951 @smallexample
2952 void __attribute__ ((interrupt)) v0 ();
2953 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2954 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2955 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2956 void __attribute__ ((interrupt, use_shadow_register_set,
2957                      keep_interrupts_masked)) v4 ();
2958 void __attribute__ ((interrupt, use_shadow_register_set,
2959                      use_debug_exception_return)) v5 ();
2960 void __attribute__ ((interrupt, keep_interrupts_masked,
2961                      use_debug_exception_return)) v6 ();
2962 void __attribute__ ((interrupt, use_shadow_register_set,
2963                      keep_interrupts_masked,
2964                      use_debug_exception_return)) v7 ();
2965 @end smallexample
2967 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
2968 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
2969 that must end with @code{RETB} instead of @code{RETI}).
2971 @item interrupt_handler
2972 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2973 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2974 indicate that the specified function is an interrupt handler.  The compiler
2975 generates function entry and exit sequences suitable for use in an
2976 interrupt handler when this attribute is present.
2978 @item interrupt_thread
2979 @cindex interrupt thread functions on fido
2980 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2981 that the specified function is an interrupt handler that is designed
2982 to run as a thread.  The compiler omits generate prologue/epilogue
2983 sequences and replaces the return instruction with a @code{sleep}
2984 instruction.  This attribute is available only on fido.
2986 @item isr
2987 @cindex interrupt service routines on ARM
2988 Use this attribute on ARM to write Interrupt Service Routines. This is an
2989 alias to the @code{interrupt} attribute above.
2991 @item kspisusp
2992 @cindex User stack pointer in interrupts on the Blackfin
2993 When used together with @code{interrupt_handler}, @code{exception_handler}
2994 or @code{nmi_handler}, code is generated to load the stack pointer
2995 from the USP register in the function prologue.
2997 @item l1_text
2998 @cindex @code{l1_text} function attribute
2999 This attribute specifies a function to be placed into L1 Instruction
3000 SRAM@. The function is put into a specific section named @code{.l1.text}.
3001 With @option{-mfdpic}, function calls with a such function as the callee
3002 or caller uses inlined PLT.
3004 @item l2
3005 @cindex @code{l2} function attribute
3006 On the Blackfin, this attribute specifies a function to be placed into L2
3007 SRAM. The function is put into a specific section named
3008 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3009 an inlined PLT.
3011 @item leaf
3012 @cindex @code{leaf} function attribute
3013 Calls to external functions with this attribute must return to the current
3014 compilation unit only by return or by exception handling.  In particular, leaf
3015 functions are not allowed to call callback function passed to it from the current
3016 compilation unit or directly call functions exported by the unit or longjmp
3017 into the unit.  Leaf function might still call functions from other compilation
3018 units and thus they are not necessarily leaf in the sense that they contain no
3019 function calls at all.
3021 The attribute is intended for library functions to improve dataflow analysis.
3022 The compiler takes the hint that any data not escaping the current compilation unit can
3023 not be used or modified by the leaf function.  For example, the @code{sin} function
3024 is a leaf function, but @code{qsort} is not.
3026 Note that leaf functions might invoke signals and signal handlers might be
3027 defined in the current compilation unit and use static variables.  The only
3028 compliant way to write such a signal handler is to declare such variables
3029 @code{volatile}.
3031 The attribute has no effect on functions defined within the current compilation
3032 unit.  This is to allow easy merging of multiple compilation units into one,
3033 for example, by using the link-time optimization.  For this reason the
3034 attribute is not allowed on types to annotate indirect calls.
3036 @item long_call/medium_call/short_call
3037 @cindex indirect calls on ARC
3038 @cindex indirect calls on ARM
3039 @cindex indirect calls on Epiphany
3040 These attributes specify how a particular function is called on
3041 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3042 These attributes override the
3043 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3044 and @option{-mmedium-calls} (@pxref{ARC Options})
3045 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3046 @code{long_call} attribute indicates that the function might be far
3047 away from the call site and require a different (more expensive)
3048 calling sequence.   The @code{short_call} attribute always places
3049 the offset to the function from the call site into the @samp{BL}
3050 instruction directly.
3052 For ARC, a function marked with the @code{long_call} attribute is
3053 always called using register-indirect jump-and-link instructions,
3054 thereby enabling the called function to be placed anywhere within the
3055 32-bit address space.  A function marked with the @code{medium_call}
3056 attribute will always be close enough to be called with an unconditional
3057 branch-and-link instruction, which has a 25-bit offset from
3058 the call site.  A function marked with the @code{short_call}
3059 attribute will always be close enough to be called with a conditional
3060 branch-and-link instruction, which has a 21-bit offset from
3061 the call site.
3063 @item longcall/shortcall
3064 @cindex functions called via pointer on the RS/6000 and PowerPC
3065 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3066 indicates that the function might be far away from the call site and
3067 require a different (more expensive) calling sequence.  The
3068 @code{shortcall} attribute indicates that the function is always close
3069 enough for the shorter calling sequence to be used.  These attributes
3070 override both the @option{-mlongcall} switch and, on the RS/6000 and
3071 PowerPC, the @code{#pragma longcall} setting.
3073 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3074 calls are necessary.
3076 @item long_call/near/far
3077 @cindex indirect calls on MIPS
3078 These attributes specify how a particular function is called on MIPS@.
3079 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3080 command-line switch.  The @code{long_call} and @code{far} attributes are
3081 synonyms, and cause the compiler to always call
3082 the function by first loading its address into a register, and then using
3083 the contents of that register.  The @code{near} attribute has the opposite
3084 effect; it specifies that non-PIC calls should be made using the more
3085 efficient @code{jal} instruction.
3087 @item malloc
3088 @cindex @code{malloc} attribute
3089 The @code{malloc} attribute is used to tell the compiler that a function
3090 may be treated as if any non-@code{NULL} pointer it returns cannot
3091 alias any other pointer valid when the function returns and that the memory
3092 has undefined content.
3093 This often improves optimization.
3094 Standard functions with this property include @code{malloc} and
3095 @code{calloc}.  @code{realloc}-like functions do not have this
3096 property as the memory pointed to does not have undefined content.
3098 @item mips16/nomips16
3099 @cindex @code{mips16} attribute
3100 @cindex @code{nomips16} attribute
3102 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3103 function attributes to locally select or turn off MIPS16 code generation.
3104 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3105 while MIPS16 code generation is disabled for functions with the
3106 @code{nomips16} attribute.  These attributes override the
3107 @option{-mips16} and @option{-mno-mips16} options on the command line
3108 (@pxref{MIPS Options}).
3110 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3111 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3112 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3113 may interact badly with some GCC extensions such as @code{__builtin_apply}
3114 (@pxref{Constructing Calls}).
3116 @item micromips/nomicromips
3117 @cindex @code{micromips} attribute
3118 @cindex @code{nomicromips} attribute
3120 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3121 function attributes to locally select or turn off microMIPS code generation.
3122 A function with the @code{micromips} attribute is emitted as microMIPS code,
3123 while microMIPS code generation is disabled for functions with the
3124 @code{nomicromips} attribute.  These attributes override the
3125 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3126 (@pxref{MIPS Options}).
3128 When compiling files containing mixed microMIPS and non-microMIPS code, the
3129 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3130 command line,
3131 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3132 may interact badly with some GCC extensions such as @code{__builtin_apply}
3133 (@pxref{Constructing Calls}).
3135 @item model (@var{model-name})
3136 @cindex function addressability on the M32R/D
3137 @cindex variable addressability on the IA-64
3139 On the M32R/D, use this attribute to set the addressability of an
3140 object, and of the code generated for a function.  The identifier
3141 @var{model-name} is one of @code{small}, @code{medium}, or
3142 @code{large}, representing each of the code models.
3144 Small model objects live in the lower 16MB of memory (so that their
3145 addresses can be loaded with the @code{ld24} instruction), and are
3146 callable with the @code{bl} instruction.
3148 Medium model objects may live anywhere in the 32-bit address space (the
3149 compiler generates @code{seth/add3} instructions to load their addresses),
3150 and are callable with the @code{bl} instruction.
3152 Large model objects may live anywhere in the 32-bit address space (the
3153 compiler generates @code{seth/add3} instructions to load their addresses),
3154 and may not be reachable with the @code{bl} instruction (the compiler
3155 generates the much slower @code{seth/add3/jl} instruction sequence).
3157 On IA-64, use this attribute to set the addressability of an object.
3158 At present, the only supported identifier for @var{model-name} is
3159 @code{small}, indicating addressability via ``small'' (22-bit)
3160 addresses (so that their addresses can be loaded with the @code{addl}
3161 instruction).  Caveat: such addressing is by definition not position
3162 independent and hence this attribute must not be used for objects
3163 defined by shared libraries.
3165 @item ms_abi/sysv_abi
3166 @cindex @code{ms_abi} attribute
3167 @cindex @code{sysv_abi} attribute
3169 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3170 to indicate which calling convention should be used for a function.  The
3171 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3172 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3173 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3174 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3176 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3177 requires the @option{-maccumulate-outgoing-args} option.
3179 @item callee_pop_aggregate_return (@var{number})
3180 @cindex @code{callee_pop_aggregate_return} attribute
3182 On 32-bit i?86-*-* targets, you can use this attribute to control how
3183 aggregates are returned in memory.  If the caller is responsible for
3184 popping the hidden pointer together with the rest of the arguments, specify
3185 @var{number} equal to zero.  If callee is responsible for popping the
3186 hidden pointer, specify @var{number} equal to one.  
3188 The default i386 ABI assumes that the callee pops the
3189 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3190 the compiler assumes that the
3191 caller pops the stack for hidden pointer.
3193 @item ms_hook_prologue
3194 @cindex @code{ms_hook_prologue} attribute
3196 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3197 this function attribute to make GCC generate the ``hot-patching'' function
3198 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3199 and newer.
3201 @item naked
3202 @cindex function without a prologue/epilogue code
3203 Use this attribute on the ARM, AVR, MCORE, MSP430, RL78, RX and SPU ports to indicate that
3204 the specified function does not need prologue/epilogue sequences generated by
3205 the compiler.  It is up to the programmer to provide these sequences. The
3206 only statements that can be safely included in naked functions are
3207 @code{asm} statements that do not have operands.  All other statements,
3208 including declarations of local variables, @code{if} statements, and so
3209 forth, should be avoided.  Naked functions should be used to implement the
3210 body of an assembly function, while allowing the compiler to construct
3211 the requisite function declaration for the assembler.
3213 @item near
3214 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3215 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3216 use the normal calling convention based on @code{jsr} and @code{rts}.
3217 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3218 option.
3220 On MeP targets this attribute causes the compiler to assume the called
3221 function is close enough to use the normal calling convention,
3222 overriding the @option{-mtf} command-line option.
3224 @item nesting
3225 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3226 Use this attribute together with @code{interrupt_handler},
3227 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3228 entry code should enable nested interrupts or exceptions.
3230 @item nmi_handler
3231 @cindex NMI handler functions on the Blackfin processor
3232 Use this attribute on the Blackfin to indicate that the specified function
3233 is an NMI handler.  The compiler generates function entry and
3234 exit sequences suitable for use in an NMI handler when this
3235 attribute is present.
3237 @item nocompression
3238 @cindex @code{nocompression} attribute
3239 On MIPS targets, you can use the @code{nocompression} function attribute
3240 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3241 overrides the @option{-mips16} and @option{-mmicromips} options on the
3242 command line (@pxref{MIPS Options}).
3244 @item no_instrument_function
3245 @cindex @code{no_instrument_function} function attribute
3246 @opindex finstrument-functions
3247 If @option{-finstrument-functions} is given, profiling function calls are
3248 generated at entry and exit of most user-compiled functions.
3249 Functions with this attribute are not so instrumented.
3251 @item no_split_stack
3252 @cindex @code{no_split_stack} function attribute
3253 @opindex fsplit-stack
3254 If @option{-fsplit-stack} is given, functions have a small
3255 prologue which decides whether to split the stack.  Functions with the
3256 @code{no_split_stack} attribute do not have that prologue, and thus
3257 may run with only a small amount of stack space available.
3259 @item noinline
3260 @cindex @code{noinline} function attribute
3261 This function attribute prevents a function from being considered for
3262 inlining.
3263 @c Don't enumerate the optimizations by name here; we try to be
3264 @c future-compatible with this mechanism.
3265 If the function does not have side-effects, there are optimizations
3266 other than inlining that cause function calls to be optimized away,
3267 although the function call is live.  To keep such calls from being
3268 optimized away, put
3269 @smallexample
3270 asm ("");
3271 @end smallexample
3273 @noindent
3274 (@pxref{Extended Asm}) in the called function, to serve as a special
3275 side-effect.
3277 @item noclone
3278 @cindex @code{noclone} function attribute
3279 This function attribute prevents a function from being considered for
3280 cloning---a mechanism that produces specialized copies of functions
3281 and which is (currently) performed by interprocedural constant
3282 propagation.
3284 @item nonnull (@var{arg-index}, @dots{})
3285 @cindex @code{nonnull} function attribute
3286 The @code{nonnull} attribute specifies that some function parameters should
3287 be non-null pointers.  For instance, the declaration:
3289 @smallexample
3290 extern void *
3291 my_memcpy (void *dest, const void *src, size_t len)
3292         __attribute__((nonnull (1, 2)));
3293 @end smallexample
3295 @noindent
3296 causes the compiler to check that, in calls to @code{my_memcpy},
3297 arguments @var{dest} and @var{src} are non-null.  If the compiler
3298 determines that a null pointer is passed in an argument slot marked
3299 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3300 is issued.  The compiler may also choose to make optimizations based
3301 on the knowledge that certain function arguments will never be null.
3303 If no argument index list is given to the @code{nonnull} attribute,
3304 all pointer arguments are marked as non-null.  To illustrate, the
3305 following declaration is equivalent to the previous example:
3307 @smallexample
3308 extern void *
3309 my_memcpy (void *dest, const void *src, size_t len)
3310         __attribute__((nonnull));
3311 @end smallexample
3313 @item returns_nonnull
3314 @cindex @code{returns_nonnull} function attribute
3315 The @code{returns_nonnull} attribute specifies that the function
3316 return value should be a non-null pointer.  For instance, the declaration:
3318 @smallexample
3319 extern void *
3320 mymalloc (size_t len) __attribute__((returns_nonnull));
3321 @end smallexample
3323 @noindent
3324 lets the compiler optimize callers based on the knowledge
3325 that the return value will never be null.
3327 @item noreturn
3328 @cindex @code{noreturn} function attribute
3329 A few standard library functions, such as @code{abort} and @code{exit},
3330 cannot return.  GCC knows this automatically.  Some programs define
3331 their own functions that never return.  You can declare them
3332 @code{noreturn} to tell the compiler this fact.  For example,
3334 @smallexample
3335 @group
3336 void fatal () __attribute__ ((noreturn));
3338 void
3339 fatal (/* @r{@dots{}} */)
3341   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3342   exit (1);
3344 @end group
3345 @end smallexample
3347 The @code{noreturn} keyword tells the compiler to assume that
3348 @code{fatal} cannot return.  It can then optimize without regard to what
3349 would happen if @code{fatal} ever did return.  This makes slightly
3350 better code.  More importantly, it helps avoid spurious warnings of
3351 uninitialized variables.
3353 The @code{noreturn} keyword does not affect the exceptional path when that
3354 applies: a @code{noreturn}-marked function may still return to the caller
3355 by throwing an exception or calling @code{longjmp}.
3357 Do not assume that registers saved by the calling function are
3358 restored before calling the @code{noreturn} function.
3360 It does not make sense for a @code{noreturn} function to have a return
3361 type other than @code{void}.
3363 The attribute @code{noreturn} is not implemented in GCC versions
3364 earlier than 2.5.  An alternative way to declare that a function does
3365 not return, which works in the current version and in some older
3366 versions, is as follows:
3368 @smallexample
3369 typedef void voidfn ();
3371 volatile voidfn fatal;
3372 @end smallexample
3374 @noindent
3375 This approach does not work in GNU C++.
3377 @item nothrow
3378 @cindex @code{nothrow} function attribute
3379 The @code{nothrow} attribute is used to inform the compiler that a
3380 function cannot throw an exception.  For example, most functions in
3381 the standard C library can be guaranteed not to throw an exception
3382 with the notable exceptions of @code{qsort} and @code{bsearch} that
3383 take function pointer arguments.  The @code{nothrow} attribute is not
3384 implemented in GCC versions earlier than 3.3.
3386 @item nosave_low_regs
3387 @cindex @code{nosave_low_regs} attribute
3388 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3389 function should not save and restore registers R0..R7.  This can be used on SH3*
3390 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3391 interrupt handlers.
3393 @item optimize
3394 @cindex @code{optimize} function attribute
3395 The @code{optimize} attribute is used to specify that a function is to
3396 be compiled with different optimization options than specified on the
3397 command line.  Arguments can either be numbers or strings.  Numbers
3398 are assumed to be an optimization level.  Strings that begin with
3399 @code{O} are assumed to be an optimization option, while other options
3400 are assumed to be used with a @code{-f} prefix.  You can also use the
3401 @samp{#pragma GCC optimize} pragma to set the optimization options
3402 that affect more than one function.
3403 @xref{Function Specific Option Pragmas}, for details about the
3404 @samp{#pragma GCC optimize} pragma.
3406 This can be used for instance to have frequently-executed functions
3407 compiled with more aggressive optimization options that produce faster
3408 and larger code, while other functions can be compiled with less
3409 aggressive options.
3411 @item OS_main/OS_task
3412 @cindex @code{OS_main} AVR function attribute
3413 @cindex @code{OS_task} AVR function attribute
3414 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3415 do not save/restore any call-saved register in their prologue/epilogue.
3417 The @code{OS_main} attribute can be used when there @emph{is
3418 guarantee} that interrupts are disabled at the time when the function
3419 is entered.  This saves resources when the stack pointer has to be
3420 changed to set up a frame for local variables.
3422 The @code{OS_task} attribute can be used when there is @emph{no
3423 guarantee} that interrupts are disabled at that time when the function
3424 is entered like for, e@.g@. task functions in a multi-threading operating
3425 system. In that case, changing the stack pointer register is
3426 guarded by save/clear/restore of the global interrupt enable flag.
3428 The differences to the @code{naked} function attribute are:
3429 @itemize @bullet
3430 @item @code{naked} functions do not have a return instruction whereas 
3431 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3432 @code{RETI} return instruction.
3433 @item @code{naked} functions do not set up a frame for local variables
3434 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3435 as needed.
3436 @end itemize
3438 @item pcs
3439 @cindex @code{pcs} function attribute
3441 The @code{pcs} attribute can be used to control the calling convention
3442 used for a function on ARM.  The attribute takes an argument that specifies
3443 the calling convention to use.
3445 When compiling using the AAPCS ABI (or a variant of it) then valid
3446 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3447 order to use a variant other than @code{"aapcs"} then the compiler must
3448 be permitted to use the appropriate co-processor registers (i.e., the
3449 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3450 For example,
3452 @smallexample
3453 /* Argument passed in r0, and result returned in r0+r1.  */
3454 double f2d (float) __attribute__((pcs("aapcs")));
3455 @end smallexample
3457 Variadic functions always use the @code{"aapcs"} calling convention and
3458 the compiler rejects attempts to specify an alternative.
3460 @item pure
3461 @cindex @code{pure} function attribute
3462 Many functions have no effects except the return value and their
3463 return value depends only on the parameters and/or global variables.
3464 Such a function can be subject
3465 to common subexpression elimination and loop optimization just as an
3466 arithmetic operator would be.  These functions should be declared
3467 with the attribute @code{pure}.  For example,
3469 @smallexample
3470 int square (int) __attribute__ ((pure));
3471 @end smallexample
3473 @noindent
3474 says that the hypothetical function @code{square} is safe to call
3475 fewer times than the program says.
3477 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3478 Interesting non-pure functions are functions with infinite loops or those
3479 depending on volatile memory or other system resource, that may change between
3480 two consecutive calls (such as @code{feof} in a multithreading environment).
3482 The attribute @code{pure} is not implemented in GCC versions earlier
3483 than 2.96.
3485 @item hot
3486 @cindex @code{hot} function attribute
3487 The @code{hot} attribute on a function is used to inform the compiler that
3488 the function is a hot spot of the compiled program.  The function is
3489 optimized more aggressively and on many target it is placed into special
3490 subsection of the text section so all hot functions appears close together
3491 improving locality.
3493 When profile feedback is available, via @option{-fprofile-use}, hot functions
3494 are automatically detected and this attribute is ignored.
3496 The @code{hot} attribute on functions is not implemented in GCC versions
3497 earlier than 4.3.
3499 @cindex @code{hot} label attribute
3500 The @code{hot} attribute on a label is used to inform the compiler that
3501 path following the label are more likely than paths that are not so
3502 annotated.  This attribute is used in cases where @code{__builtin_expect}
3503 cannot be used, for instance with computed goto or @code{asm goto}.
3505 The @code{hot} attribute on labels is not implemented in GCC versions
3506 earlier than 4.8.
3508 @item cold
3509 @cindex @code{cold} function attribute
3510 The @code{cold} attribute on functions is used to inform the compiler that
3511 the function is unlikely to be executed.  The function is optimized for
3512 size rather than speed and on many targets it is placed into special
3513 subsection of the text section so all cold functions appears close together
3514 improving code locality of non-cold parts of program.  The paths leading
3515 to call of cold functions within code are marked as unlikely by the branch
3516 prediction mechanism.  It is thus useful to mark functions used to handle
3517 unlikely conditions, such as @code{perror}, as cold to improve optimization
3518 of hot functions that do call marked functions in rare occasions.
3520 When profile feedback is available, via @option{-fprofile-use}, cold functions
3521 are automatically detected and this attribute is ignored.
3523 The @code{cold} attribute on functions is not implemented in GCC versions
3524 earlier than 4.3.
3526 @cindex @code{cold} label attribute
3527 The @code{cold} attribute on labels is used to inform the compiler that
3528 the path following the label is unlikely to be executed.  This attribute
3529 is used in cases where @code{__builtin_expect} cannot be used, for instance
3530 with computed goto or @code{asm goto}.
3532 The @code{cold} attribute on labels is not implemented in GCC versions
3533 earlier than 4.8.
3535 @item no_sanitize_address
3536 @itemx no_address_safety_analysis
3537 @cindex @code{no_sanitize_address} function attribute
3538 The @code{no_sanitize_address} attribute on functions is used
3539 to inform the compiler that it should not instrument memory accesses
3540 in the function when compiling with the @option{-fsanitize=address} option.
3541 The @code{no_address_safety_analysis} is a deprecated alias of the
3542 @code{no_sanitize_address} attribute, new code should use
3543 @code{no_sanitize_address}.
3545 @item no_sanitize_undefined
3546 @cindex @code{no_sanitize_undefined} function attribute
3547 The @code{no_sanitize_undefined} attribute on functions is used
3548 to inform the compiler that it should not check for undefined behavior
3549 in the function when compiling with the @option{-fsanitize=undefined} option.
3551 @item regparm (@var{number})
3552 @cindex @code{regparm} attribute
3553 @cindex functions that are passed arguments in registers on the 386
3554 On the Intel 386, the @code{regparm} attribute causes the compiler to
3555 pass arguments number one to @var{number} if they are of integral type
3556 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3557 take a variable number of arguments continue to be passed all of their
3558 arguments on the stack.
3560 Beware that on some ELF systems this attribute is unsuitable for
3561 global functions in shared libraries with lazy binding (which is the
3562 default).  Lazy binding sends the first call via resolving code in
3563 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3564 per the standard calling conventions.  Solaris 8 is affected by this.
3565 Systems with the GNU C Library version 2.1 or higher
3566 and FreeBSD are believed to be
3567 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3568 disabled with the linker or the loader if desired, to avoid the
3569 problem.)
3571 @item sseregparm
3572 @cindex @code{sseregparm} attribute
3573 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3574 causes the compiler to pass up to 3 floating-point arguments in
3575 SSE registers instead of on the stack.  Functions that take a
3576 variable number of arguments continue to pass all of their
3577 floating-point arguments on the stack.
3579 @item force_align_arg_pointer
3580 @cindex @code{force_align_arg_pointer} attribute
3581 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3582 applied to individual function definitions, generating an alternate
3583 prologue and epilogue that realigns the run-time stack if necessary.
3584 This supports mixing legacy codes that run with a 4-byte aligned stack
3585 with modern codes that keep a 16-byte stack for SSE compatibility.
3587 @item renesas
3588 @cindex @code{renesas} attribute
3589 On SH targets this attribute specifies that the function or struct follows the
3590 Renesas ABI.
3592 @item resbank
3593 @cindex @code{resbank} attribute
3594 On the SH2A target, this attribute enables the high-speed register
3595 saving and restoration using a register bank for @code{interrupt_handler}
3596 routines.  Saving to the bank is performed automatically after the CPU
3597 accepts an interrupt that uses a register bank.
3599 The nineteen 32-bit registers comprising general register R0 to R14,
3600 control register GBR, and system registers MACH, MACL, and PR and the
3601 vector table address offset are saved into a register bank.  Register
3602 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3603 from the bank is executed by issuing a RESBANK instruction.
3605 @item returns_twice
3606 @cindex @code{returns_twice} attribute
3607 The @code{returns_twice} attribute tells the compiler that a function may
3608 return more than one time.  The compiler ensures that all registers
3609 are dead before calling such a function and emits a warning about
3610 the variables that may be clobbered after the second return from the
3611 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3612 The @code{longjmp}-like counterpart of such function, if any, might need
3613 to be marked with the @code{noreturn} attribute.
3615 @item saveall
3616 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3617 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3618 all registers except the stack pointer should be saved in the prologue
3619 regardless of whether they are used or not.
3621 @item save_volatiles
3622 @cindex save volatile registers on the MicroBlaze
3623 Use this attribute on the MicroBlaze to indicate that the function is
3624 an interrupt handler.  All volatile registers (in addition to non-volatile
3625 registers) are saved in the function prologue.  If the function is a leaf
3626 function, only volatiles used by the function are saved.  A normal function
3627 return is generated instead of a return from interrupt.
3629 @item section ("@var{section-name}")
3630 @cindex @code{section} function attribute
3631 Normally, the compiler places the code it generates in the @code{text} section.
3632 Sometimes, however, you need additional sections, or you need certain
3633 particular functions to appear in special sections.  The @code{section}
3634 attribute specifies that a function lives in a particular section.
3635 For example, the declaration:
3637 @smallexample
3638 extern void foobar (void) __attribute__ ((section ("bar")));
3639 @end smallexample
3641 @noindent
3642 puts the function @code{foobar} in the @code{bar} section.
3644 Some file formats do not support arbitrary sections so the @code{section}
3645 attribute is not available on all platforms.
3646 If you need to map the entire contents of a module to a particular
3647 section, consider using the facilities of the linker instead.
3649 @item sentinel
3650 @cindex @code{sentinel} function attribute
3651 This function attribute ensures that a parameter in a function call is
3652 an explicit @code{NULL}.  The attribute is only valid on variadic
3653 functions.  By default, the sentinel is located at position zero, the
3654 last parameter of the function call.  If an optional integer position
3655 argument P is supplied to the attribute, the sentinel must be located at
3656 position P counting backwards from the end of the argument list.
3658 @smallexample
3659 __attribute__ ((sentinel))
3660 is equivalent to
3661 __attribute__ ((sentinel(0)))
3662 @end smallexample
3664 The attribute is automatically set with a position of 0 for the built-in
3665 functions @code{execl} and @code{execlp}.  The built-in function
3666 @code{execle} has the attribute set with a position of 1.
3668 A valid @code{NULL} in this context is defined as zero with any pointer
3669 type.  If your system defines the @code{NULL} macro with an integer type
3670 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3671 with a copy that redefines NULL appropriately.
3673 The warnings for missing or incorrect sentinels are enabled with
3674 @option{-Wformat}.
3676 @item short_call
3677 See @code{long_call/short_call}.
3679 @item shortcall
3680 See @code{longcall/shortcall}.
3682 @item signal
3683 @cindex interrupt handler functions on the AVR processors
3684 Use this attribute on the AVR to indicate that the specified
3685 function is an interrupt handler.  The compiler generates function
3686 entry and exit sequences suitable for use in an interrupt handler when this
3687 attribute is present.
3689 See also the @code{interrupt} function attribute. 
3691 The AVR hardware globally disables interrupts when an interrupt is executed.
3692 Interrupt handler functions defined with the @code{signal} attribute
3693 do not re-enable interrupts.  It is save to enable interrupts in a
3694 @code{signal} handler.  This ``save'' only applies to the code
3695 generated by the compiler and not to the IRQ layout of the
3696 application which is responsibility of the application.
3698 If both @code{signal} and @code{interrupt} are specified for the same
3699 function, @code{signal} is silently ignored.
3701 @item sp_switch
3702 @cindex @code{sp_switch} attribute
3703 Use this attribute on the SH to indicate an @code{interrupt_handler}
3704 function should switch to an alternate stack.  It expects a string
3705 argument that names a global variable holding the address of the
3706 alternate stack.
3708 @smallexample
3709 void *alt_stack;
3710 void f () __attribute__ ((interrupt_handler,
3711                           sp_switch ("alt_stack")));
3712 @end smallexample
3714 @item stdcall
3715 @cindex functions that pop the argument stack on the 386
3716 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3717 assume that the called function pops off the stack space used to
3718 pass arguments, unless it takes a variable number of arguments.
3720 @item syscall_linkage
3721 @cindex @code{syscall_linkage} attribute
3722 This attribute is used to modify the IA-64 calling convention by marking
3723 all input registers as live at all function exits.  This makes it possible
3724 to restart a system call after an interrupt without having to save/restore
3725 the input registers.  This also prevents kernel data from leaking into
3726 application code.
3728 @item target
3729 @cindex @code{target} function attribute
3730 The @code{target} attribute is used to specify that a function is to
3731 be compiled with different target options than specified on the
3732 command line.  This can be used for instance to have functions
3733 compiled with a different ISA (instruction set architecture) than the
3734 default.  You can also use the @samp{#pragma GCC target} pragma to set
3735 more than one function to be compiled with specific target options.
3736 @xref{Function Specific Option Pragmas}, for details about the
3737 @samp{#pragma GCC target} pragma.
3739 For instance on a 386, you could compile one function with
3740 @code{target("sse4.1,arch=core2")} and another with
3741 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3742 compiling the first function with @option{-msse4.1} and
3743 @option{-march=core2} options, and the second function with
3744 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3745 user to make sure that a function is only invoked on a machine that
3746 supports the particular ISA it is compiled for (for example by using
3747 @code{cpuid} on 386 to determine what feature bits and architecture
3748 family are used).
3750 @smallexample
3751 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3752 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3753 @end smallexample
3755 On the 386, the following options are allowed:
3757 @table @samp
3758 @item abm
3759 @itemx no-abm
3760 @cindex @code{target("abm")} attribute
3761 Enable/disable the generation of the advanced bit instructions.
3763 @item aes
3764 @itemx no-aes
3765 @cindex @code{target("aes")} attribute
3766 Enable/disable the generation of the AES instructions.
3768 @item default
3769 @cindex @code{target("default")} attribute
3770 @xref{Function Multiversioning}, where it is used to specify the
3771 default function version.
3773 @item mmx
3774 @itemx no-mmx
3775 @cindex @code{target("mmx")} attribute
3776 Enable/disable the generation of the MMX instructions.
3778 @item pclmul
3779 @itemx no-pclmul
3780 @cindex @code{target("pclmul")} attribute
3781 Enable/disable the generation of the PCLMUL instructions.
3783 @item popcnt
3784 @itemx no-popcnt
3785 @cindex @code{target("popcnt")} attribute
3786 Enable/disable the generation of the POPCNT instruction.
3788 @item sse
3789 @itemx no-sse
3790 @cindex @code{target("sse")} attribute
3791 Enable/disable the generation of the SSE instructions.
3793 @item sse2
3794 @itemx no-sse2
3795 @cindex @code{target("sse2")} attribute
3796 Enable/disable the generation of the SSE2 instructions.
3798 @item sse3
3799 @itemx no-sse3
3800 @cindex @code{target("sse3")} attribute
3801 Enable/disable the generation of the SSE3 instructions.
3803 @item sse4
3804 @itemx no-sse4
3805 @cindex @code{target("sse4")} attribute
3806 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3807 and SSE4.2).
3809 @item sse4.1
3810 @itemx no-sse4.1
3811 @cindex @code{target("sse4.1")} attribute
3812 Enable/disable the generation of the sse4.1 instructions.
3814 @item sse4.2
3815 @itemx no-sse4.2
3816 @cindex @code{target("sse4.2")} attribute
3817 Enable/disable the generation of the sse4.2 instructions.
3819 @item sse4a
3820 @itemx no-sse4a
3821 @cindex @code{target("sse4a")} attribute
3822 Enable/disable the generation of the SSE4A instructions.
3824 @item fma4
3825 @itemx no-fma4
3826 @cindex @code{target("fma4")} attribute
3827 Enable/disable the generation of the FMA4 instructions.
3829 @item xop
3830 @itemx no-xop
3831 @cindex @code{target("xop")} attribute
3832 Enable/disable the generation of the XOP instructions.
3834 @item lwp
3835 @itemx no-lwp
3836 @cindex @code{target("lwp")} attribute
3837 Enable/disable the generation of the LWP instructions.
3839 @item ssse3
3840 @itemx no-ssse3
3841 @cindex @code{target("ssse3")} attribute
3842 Enable/disable the generation of the SSSE3 instructions.
3844 @item cld
3845 @itemx no-cld
3846 @cindex @code{target("cld")} attribute
3847 Enable/disable the generation of the CLD before string moves.
3849 @item fancy-math-387
3850 @itemx no-fancy-math-387
3851 @cindex @code{target("fancy-math-387")} attribute
3852 Enable/disable the generation of the @code{sin}, @code{cos}, and
3853 @code{sqrt} instructions on the 387 floating-point unit.
3855 @item fused-madd
3856 @itemx no-fused-madd
3857 @cindex @code{target("fused-madd")} attribute
3858 Enable/disable the generation of the fused multiply/add instructions.
3860 @item ieee-fp
3861 @itemx no-ieee-fp
3862 @cindex @code{target("ieee-fp")} attribute
3863 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3865 @item inline-all-stringops
3866 @itemx no-inline-all-stringops
3867 @cindex @code{target("inline-all-stringops")} attribute
3868 Enable/disable inlining of string operations.
3870 @item inline-stringops-dynamically
3871 @itemx no-inline-stringops-dynamically
3872 @cindex @code{target("inline-stringops-dynamically")} attribute
3873 Enable/disable the generation of the inline code to do small string
3874 operations and calling the library routines for large operations.
3876 @item align-stringops
3877 @itemx no-align-stringops
3878 @cindex @code{target("align-stringops")} attribute
3879 Do/do not align destination of inlined string operations.
3881 @item recip
3882 @itemx no-recip
3883 @cindex @code{target("recip")} attribute
3884 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3885 instructions followed an additional Newton-Raphson step instead of
3886 doing a floating-point division.
3888 @item arch=@var{ARCH}
3889 @cindex @code{target("arch=@var{ARCH}")} attribute
3890 Specify the architecture to generate code for in compiling the function.
3892 @item tune=@var{TUNE}
3893 @cindex @code{target("tune=@var{TUNE}")} attribute
3894 Specify the architecture to tune for in compiling the function.
3896 @item fpmath=@var{FPMATH}
3897 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3898 Specify which floating-point unit to use.  The
3899 @code{target("fpmath=sse,387")} option must be specified as
3900 @code{target("fpmath=sse+387")} because the comma would separate
3901 different options.
3902 @end table
3904 On the PowerPC, the following options are allowed:
3906 @table @samp
3907 @item altivec
3908 @itemx no-altivec
3909 @cindex @code{target("altivec")} attribute
3910 Generate code that uses (does not use) AltiVec instructions.  In
3911 32-bit code, you cannot enable AltiVec instructions unless
3912 @option{-mabi=altivec} is used on the command line.
3914 @item cmpb
3915 @itemx no-cmpb
3916 @cindex @code{target("cmpb")} attribute
3917 Generate code that uses (does not use) the compare bytes instruction
3918 implemented on the POWER6 processor and other processors that support
3919 the PowerPC V2.05 architecture.
3921 @item dlmzb
3922 @itemx no-dlmzb
3923 @cindex @code{target("dlmzb")} attribute
3924 Generate code that uses (does not use) the string-search @samp{dlmzb}
3925 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
3926 generated by default when targeting those processors.
3928 @item fprnd
3929 @itemx no-fprnd
3930 @cindex @code{target("fprnd")} attribute
3931 Generate code that uses (does not use) the FP round to integer
3932 instructions implemented on the POWER5+ processor and other processors
3933 that support the PowerPC V2.03 architecture.
3935 @item hard-dfp
3936 @itemx no-hard-dfp
3937 @cindex @code{target("hard-dfp")} attribute
3938 Generate code that uses (does not use) the decimal floating-point
3939 instructions implemented on some POWER processors.
3941 @item isel
3942 @itemx no-isel
3943 @cindex @code{target("isel")} attribute
3944 Generate code that uses (does not use) ISEL instruction.
3946 @item mfcrf
3947 @itemx no-mfcrf
3948 @cindex @code{target("mfcrf")} attribute
3949 Generate code that uses (does not use) the move from condition
3950 register field instruction implemented on the POWER4 processor and
3951 other processors that support the PowerPC V2.01 architecture.
3953 @item mfpgpr
3954 @itemx no-mfpgpr
3955 @cindex @code{target("mfpgpr")} attribute
3956 Generate code that uses (does not use) the FP move to/from general
3957 purpose register instructions implemented on the POWER6X processor and
3958 other processors that support the extended PowerPC V2.05 architecture.
3960 @item mulhw
3961 @itemx no-mulhw
3962 @cindex @code{target("mulhw")} attribute
3963 Generate code that uses (does not use) the half-word multiply and
3964 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
3965 These instructions are generated by default when targeting those
3966 processors.
3968 @item multiple
3969 @itemx no-multiple
3970 @cindex @code{target("multiple")} attribute
3971 Generate code that uses (does not use) the load multiple word
3972 instructions and the store multiple word instructions.
3974 @item update
3975 @itemx no-update
3976 @cindex @code{target("update")} attribute
3977 Generate code that uses (does not use) the load or store instructions
3978 that update the base register to the address of the calculated memory
3979 location.
3981 @item popcntb
3982 @itemx no-popcntb
3983 @cindex @code{target("popcntb")} attribute
3984 Generate code that uses (does not use) the popcount and double-precision
3985 FP reciprocal estimate instruction implemented on the POWER5
3986 processor and other processors that support the PowerPC V2.02
3987 architecture.
3989 @item popcntd
3990 @itemx no-popcntd
3991 @cindex @code{target("popcntd")} attribute
3992 Generate code that uses (does not use) the popcount instruction
3993 implemented on the POWER7 processor and other processors that support
3994 the PowerPC V2.06 architecture.
3996 @item powerpc-gfxopt
3997 @itemx no-powerpc-gfxopt
3998 @cindex @code{target("powerpc-gfxopt")} attribute
3999 Generate code that uses (does not use) the optional PowerPC
4000 architecture instructions in the Graphics group, including
4001 floating-point select.
4003 @item powerpc-gpopt
4004 @itemx no-powerpc-gpopt
4005 @cindex @code{target("powerpc-gpopt")} attribute
4006 Generate code that uses (does not use) the optional PowerPC
4007 architecture instructions in the General Purpose group, including
4008 floating-point square root.
4010 @item recip-precision
4011 @itemx no-recip-precision
4012 @cindex @code{target("recip-precision")} attribute
4013 Assume (do not assume) that the reciprocal estimate instructions
4014 provide higher-precision estimates than is mandated by the powerpc
4015 ABI.
4017 @item string
4018 @itemx no-string
4019 @cindex @code{target("string")} attribute
4020 Generate code that uses (does not use) the load string instructions
4021 and the store string word instructions to save multiple registers and
4022 do small block moves.
4024 @item vsx
4025 @itemx no-vsx
4026 @cindex @code{target("vsx")} attribute
4027 Generate code that uses (does not use) vector/scalar (VSX)
4028 instructions, and also enable the use of built-in functions that allow
4029 more direct access to the VSX instruction set.  In 32-bit code, you
4030 cannot enable VSX or AltiVec instructions unless
4031 @option{-mabi=altivec} is used on the command line.
4033 @item friz
4034 @itemx no-friz
4035 @cindex @code{target("friz")} attribute
4036 Generate (do not generate) the @code{friz} instruction when the
4037 @option{-funsafe-math-optimizations} option is used to optimize
4038 rounding a floating-point value to 64-bit integer and back to floating
4039 point.  The @code{friz} instruction does not return the same value if
4040 the floating-point number is too large to fit in an integer.
4042 @item avoid-indexed-addresses
4043 @itemx no-avoid-indexed-addresses
4044 @cindex @code{target("avoid-indexed-addresses")} attribute
4045 Generate code that tries to avoid (not avoid) the use of indexed load
4046 or store instructions.
4048 @item paired
4049 @itemx no-paired
4050 @cindex @code{target("paired")} attribute
4051 Generate code that uses (does not use) the generation of PAIRED simd
4052 instructions.
4054 @item longcall
4055 @itemx no-longcall
4056 @cindex @code{target("longcall")} attribute
4057 Generate code that assumes (does not assume) that all calls are far
4058 away so that a longer more expensive calling sequence is required.
4060 @item cpu=@var{CPU}
4061 @cindex @code{target("cpu=@var{CPU}")} attribute
4062 Specify the architecture to generate code for when compiling the
4063 function.  If you select the @code{target("cpu=power7")} attribute when
4064 generating 32-bit code, VSX and AltiVec instructions are not generated
4065 unless you use the @option{-mabi=altivec} option on the command line.
4067 @item tune=@var{TUNE}
4068 @cindex @code{target("tune=@var{TUNE}")} attribute
4069 Specify the architecture to tune for when compiling the function.  If
4070 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4071 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4072 compilation tunes for the @var{CPU} architecture, and not the
4073 default tuning specified on the command line.
4074 @end table
4076 On the 386/x86_64 and PowerPC back ends, you can use either multiple
4077 strings to specify multiple options, or you can separate the option
4078 with a comma (@code{,}).
4080 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4081 function that has different target options than the caller, unless the
4082 callee has a subset of the target options of the caller.  For example
4083 a function declared with @code{target("sse3")} can inline a function
4084 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4086 The @code{target} attribute is not implemented in GCC versions earlier
4087 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends.  It is
4088 not currently implemented for other back ends.
4090 @item tiny_data
4091 @cindex tiny data section on the H8/300H and H8S
4092 Use this attribute on the H8/300H and H8S to indicate that the specified
4093 variable should be placed into the tiny data section.
4094 The compiler generates more efficient code for loads and stores
4095 on data in the tiny data section.  Note the tiny data area is limited to
4096 slightly under 32KB of data.
4098 @item trap_exit
4099 @cindex @code{trap_exit} attribute
4100 Use this attribute on the SH for an @code{interrupt_handler} to return using
4101 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4102 argument specifying the trap number to be used.
4104 @item trapa_handler
4105 @cindex @code{trapa_handler} attribute
4106 On SH targets this function attribute is similar to @code{interrupt_handler}
4107 but it does not save and restore all registers.
4109 @item unused
4110 @cindex @code{unused} attribute.
4111 This attribute, attached to a function, means that the function is meant
4112 to be possibly unused.  GCC does not produce a warning for this
4113 function.
4115 @item used
4116 @cindex @code{used} attribute.
4117 This attribute, attached to a function, means that code must be emitted
4118 for the function even if it appears that the function is not referenced.
4119 This is useful, for example, when the function is referenced only in
4120 inline assembly.
4122 When applied to a member function of a C++ class template, the
4123 attribute also means that the function is instantiated if the
4124 class itself is instantiated.
4126 @item version_id
4127 @cindex @code{version_id} attribute
4128 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4129 symbol to contain a version string, thus allowing for function level
4130 versioning.  HP-UX system header files may use function level versioning
4131 for some system calls.
4133 @smallexample
4134 extern int foo () __attribute__((version_id ("20040821")));
4135 @end smallexample
4137 @noindent
4138 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4140 @item visibility ("@var{visibility_type}")
4141 @cindex @code{visibility} attribute
4142 This attribute affects the linkage of the declaration to which it is attached.
4143 There are four supported @var{visibility_type} values: default,
4144 hidden, protected or internal visibility.
4146 @smallexample
4147 void __attribute__ ((visibility ("protected")))
4148 f () @{ /* @r{Do something.} */; @}
4149 int i __attribute__ ((visibility ("hidden")));
4150 @end smallexample
4152 The possible values of @var{visibility_type} correspond to the
4153 visibility settings in the ELF gABI.
4155 @table @dfn
4156 @c keep this list of visibilities in alphabetical order.
4158 @item default
4159 Default visibility is the normal case for the object file format.
4160 This value is available for the visibility attribute to override other
4161 options that may change the assumed visibility of entities.
4163 On ELF, default visibility means that the declaration is visible to other
4164 modules and, in shared libraries, means that the declared entity may be
4165 overridden.
4167 On Darwin, default visibility means that the declaration is visible to
4168 other modules.
4170 Default visibility corresponds to ``external linkage'' in the language.
4172 @item hidden
4173 Hidden visibility indicates that the entity declared has a new
4174 form of linkage, which we call ``hidden linkage''.  Two
4175 declarations of an object with hidden linkage refer to the same object
4176 if they are in the same shared object.
4178 @item internal
4179 Internal visibility is like hidden visibility, but with additional
4180 processor specific semantics.  Unless otherwise specified by the
4181 psABI, GCC defines internal visibility to mean that a function is
4182 @emph{never} called from another module.  Compare this with hidden
4183 functions which, while they cannot be referenced directly by other
4184 modules, can be referenced indirectly via function pointers.  By
4185 indicating that a function cannot be called from outside the module,
4186 GCC may for instance omit the load of a PIC register since it is known
4187 that the calling function loaded the correct value.
4189 @item protected
4190 Protected visibility is like default visibility except that it
4191 indicates that references within the defining module bind to the
4192 definition in that module.  That is, the declared entity cannot be
4193 overridden by another module.
4195 @end table
4197 All visibilities are supported on many, but not all, ELF targets
4198 (supported when the assembler supports the @samp{.visibility}
4199 pseudo-op).  Default visibility is supported everywhere.  Hidden
4200 visibility is supported on Darwin targets.
4202 The visibility attribute should be applied only to declarations that
4203 would otherwise have external linkage.  The attribute should be applied
4204 consistently, so that the same entity should not be declared with
4205 different settings of the attribute.
4207 In C++, the visibility attribute applies to types as well as functions
4208 and objects, because in C++ types have linkage.  A class must not have
4209 greater visibility than its non-static data member types and bases,
4210 and class members default to the visibility of their class.  Also, a
4211 declaration without explicit visibility is limited to the visibility
4212 of its type.
4214 In C++, you can mark member functions and static member variables of a
4215 class with the visibility attribute.  This is useful if you know a
4216 particular method or static member variable should only be used from
4217 one shared object; then you can mark it hidden while the rest of the
4218 class has default visibility.  Care must be taken to avoid breaking
4219 the One Definition Rule; for example, it is usually not useful to mark
4220 an inline method as hidden without marking the whole class as hidden.
4222 A C++ namespace declaration can also have the visibility attribute.
4223 This attribute applies only to the particular namespace body, not to
4224 other definitions of the same namespace; it is equivalent to using
4225 @samp{#pragma GCC visibility} before and after the namespace
4226 definition (@pxref{Visibility Pragmas}).
4228 In C++, if a template argument has limited visibility, this
4229 restriction is implicitly propagated to the template instantiation.
4230 Otherwise, template instantiations and specializations default to the
4231 visibility of their template.
4233 If both the template and enclosing class have explicit visibility, the
4234 visibility from the template is used.
4236 @item vliw
4237 @cindex @code{vliw} attribute
4238 On MeP, the @code{vliw} attribute tells the compiler to emit
4239 instructions in VLIW mode instead of core mode.  Note that this
4240 attribute is not allowed unless a VLIW coprocessor has been configured
4241 and enabled through command-line options.
4243 @item warn_unused_result
4244 @cindex @code{warn_unused_result} attribute
4245 The @code{warn_unused_result} attribute causes a warning to be emitted
4246 if a caller of the function with this attribute does not use its
4247 return value.  This is useful for functions where not checking
4248 the result is either a security problem or always a bug, such as
4249 @code{realloc}.
4251 @smallexample
4252 int fn () __attribute__ ((warn_unused_result));
4253 int foo ()
4255   if (fn () < 0) return -1;
4256   fn ();
4257   return 0;
4259 @end smallexample
4261 @noindent
4262 results in warning on line 5.
4264 @item weak
4265 @cindex @code{weak} attribute
4266 The @code{weak} attribute causes the declaration to be emitted as a weak
4267 symbol rather than a global.  This is primarily useful in defining
4268 library functions that can be overridden in user code, though it can
4269 also be used with non-function declarations.  Weak symbols are supported
4270 for ELF targets, and also for a.out targets when using the GNU assembler
4271 and linker.
4273 @item weakref
4274 @itemx weakref ("@var{target}")
4275 @cindex @code{weakref} attribute
4276 The @code{weakref} attribute marks a declaration as a weak reference.
4277 Without arguments, it should be accompanied by an @code{alias} attribute
4278 naming the target symbol.  Optionally, the @var{target} may be given as
4279 an argument to @code{weakref} itself.  In either case, @code{weakref}
4280 implicitly marks the declaration as @code{weak}.  Without a
4281 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4282 @code{weakref} is equivalent to @code{weak}.
4284 @smallexample
4285 static int x() __attribute__ ((weakref ("y")));
4286 /* is equivalent to... */
4287 static int x() __attribute__ ((weak, weakref, alias ("y")));
4288 /* and to... */
4289 static int x() __attribute__ ((weakref));
4290 static int x() __attribute__ ((alias ("y")));
4291 @end smallexample
4293 A weak reference is an alias that does not by itself require a
4294 definition to be given for the target symbol.  If the target symbol is
4295 only referenced through weak references, then it becomes a @code{weak}
4296 undefined symbol.  If it is directly referenced, however, then such
4297 strong references prevail, and a definition is required for the
4298 symbol, not necessarily in the same translation unit.
4300 The effect is equivalent to moving all references to the alias to a
4301 separate translation unit, renaming the alias to the aliased symbol,
4302 declaring it as weak, compiling the two separate translation units and
4303 performing a reloadable link on them.
4305 At present, a declaration to which @code{weakref} is attached can
4306 only be @code{static}.
4308 @end table
4310 You can specify multiple attributes in a declaration by separating them
4311 by commas within the double parentheses or by immediately following an
4312 attribute declaration with another attribute declaration.
4314 @cindex @code{#pragma}, reason for not using
4315 @cindex pragma, reason for not using
4316 Some people object to the @code{__attribute__} feature, suggesting that
4317 ISO C's @code{#pragma} should be used instead.  At the time
4318 @code{__attribute__} was designed, there were two reasons for not doing
4319 this.
4321 @enumerate
4322 @item
4323 It is impossible to generate @code{#pragma} commands from a macro.
4325 @item
4326 There is no telling what the same @code{#pragma} might mean in another
4327 compiler.
4328 @end enumerate
4330 These two reasons applied to almost any application that might have been
4331 proposed for @code{#pragma}.  It was basically a mistake to use
4332 @code{#pragma} for @emph{anything}.
4334 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4335 to be generated from macros.  In addition, a @code{#pragma GCC}
4336 namespace is now in use for GCC-specific pragmas.  However, it has been
4337 found convenient to use @code{__attribute__} to achieve a natural
4338 attachment of attributes to their corresponding declarations, whereas
4339 @code{#pragma GCC} is of use for constructs that do not naturally form
4340 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4342 @node Attribute Syntax
4343 @section Attribute Syntax
4344 @cindex attribute syntax
4346 This section describes the syntax with which @code{__attribute__} may be
4347 used, and the constructs to which attribute specifiers bind, for the C
4348 language.  Some details may vary for C++ and Objective-C@.  Because of
4349 infelicities in the grammar for attributes, some forms described here
4350 may not be successfully parsed in all cases.
4352 There are some problems with the semantics of attributes in C++.  For
4353 example, there are no manglings for attributes, although they may affect
4354 code generation, so problems may arise when attributed types are used in
4355 conjunction with templates or overloading.  Similarly, @code{typeid}
4356 does not distinguish between types with different attributes.  Support
4357 for attributes in C++ may be restricted in future to attributes on
4358 declarations only, but not on nested declarators.
4360 @xref{Function Attributes}, for details of the semantics of attributes
4361 applying to functions.  @xref{Variable Attributes}, for details of the
4362 semantics of attributes applying to variables.  @xref{Type Attributes},
4363 for details of the semantics of attributes applying to structure, union
4364 and enumerated types.
4366 An @dfn{attribute specifier} is of the form
4367 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4368 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4369 each attribute is one of the following:
4371 @itemize @bullet
4372 @item
4373 Empty.  Empty attributes are ignored.
4375 @item
4376 A word (which may be an identifier such as @code{unused}, or a reserved
4377 word such as @code{const}).
4379 @item
4380 A word, followed by, in parentheses, parameters for the attribute.
4381 These parameters take one of the following forms:
4383 @itemize @bullet
4384 @item
4385 An identifier.  For example, @code{mode} attributes use this form.
4387 @item
4388 An identifier followed by a comma and a non-empty comma-separated list
4389 of expressions.  For example, @code{format} attributes use this form.
4391 @item
4392 A possibly empty comma-separated list of expressions.  For example,
4393 @code{format_arg} attributes use this form with the list being a single
4394 integer constant expression, and @code{alias} attributes use this form
4395 with the list being a single string constant.
4396 @end itemize
4397 @end itemize
4399 An @dfn{attribute specifier list} is a sequence of one or more attribute
4400 specifiers, not separated by any other tokens.
4402 In GNU C, an attribute specifier list may appear after the colon following a
4403 label, other than a @code{case} or @code{default} label.  The only
4404 attribute it makes sense to use after a label is @code{unused}.  This
4405 feature is intended for program-generated code that may contain unused labels,
4406 but which is compiled with @option{-Wall}.  It is
4407 not normally appropriate to use in it human-written code, though it
4408 could be useful in cases where the code that jumps to the label is
4409 contained within an @code{#ifdef} conditional.  GNU C++ only permits
4410 attributes on labels if the attribute specifier is immediately
4411 followed by a semicolon (i.e., the label applies to an empty
4412 statement).  If the semicolon is missing, C++ label attributes are
4413 ambiguous, as it is permissible for a declaration, which could begin
4414 with an attribute list, to be labelled in C++.  Declarations cannot be
4415 labelled in C90 or C99, so the ambiguity does not arise there.
4417 An attribute specifier list may appear as part of a @code{struct},
4418 @code{union} or @code{enum} specifier.  It may go either immediately
4419 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4420 the closing brace.  The former syntax is preferred.
4421 Where attribute specifiers follow the closing brace, they are considered
4422 to relate to the structure, union or enumerated type defined, not to any
4423 enclosing declaration the type specifier appears in, and the type
4424 defined is not complete until after the attribute specifiers.
4425 @c Otherwise, there would be the following problems: a shift/reduce
4426 @c conflict between attributes binding the struct/union/enum and
4427 @c binding to the list of specifiers/qualifiers; and "aligned"
4428 @c attributes could use sizeof for the structure, but the size could be
4429 @c changed later by "packed" attributes.
4431 Otherwise, an attribute specifier appears as part of a declaration,
4432 counting declarations of unnamed parameters and type names, and relates
4433 to that declaration (which may be nested in another declaration, for
4434 example in the case of a parameter declaration), or to a particular declarator
4435 within a declaration.  Where an
4436 attribute specifier is applied to a parameter declared as a function or
4437 an array, it should apply to the function or array rather than the
4438 pointer to which the parameter is implicitly converted, but this is not
4439 yet correctly implemented.
4441 Any list of specifiers and qualifiers at the start of a declaration may
4442 contain attribute specifiers, whether or not such a list may in that
4443 context contain storage class specifiers.  (Some attributes, however,
4444 are essentially in the nature of storage class specifiers, and only make
4445 sense where storage class specifiers may be used; for example,
4446 @code{section}.)  There is one necessary limitation to this syntax: the
4447 first old-style parameter declaration in a function definition cannot
4448 begin with an attribute specifier, because such an attribute applies to
4449 the function instead by syntax described below (which, however, is not
4450 yet implemented in this case).  In some other cases, attribute
4451 specifiers are permitted by this grammar but not yet supported by the
4452 compiler.  All attribute specifiers in this place relate to the
4453 declaration as a whole.  In the obsolescent usage where a type of
4454 @code{int} is implied by the absence of type specifiers, such a list of
4455 specifiers and qualifiers may be an attribute specifier list with no
4456 other specifiers or qualifiers.
4458 At present, the first parameter in a function prototype must have some
4459 type specifier that is not an attribute specifier; this resolves an
4460 ambiguity in the interpretation of @code{void f(int
4461 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4462 the parentheses of a function declarator contain only attributes then
4463 those attributes are ignored, rather than yielding an error or warning
4464 or implying a single parameter of type int, but this is subject to
4465 change.
4467 An attribute specifier list may appear immediately before a declarator
4468 (other than the first) in a comma-separated list of declarators in a
4469 declaration of more than one identifier using a single list of
4470 specifiers and qualifiers.  Such attribute specifiers apply
4471 only to the identifier before whose declarator they appear.  For
4472 example, in
4474 @smallexample
4475 __attribute__((noreturn)) void d0 (void),
4476     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4477      d2 (void)
4478 @end smallexample
4480 @noindent
4481 the @code{noreturn} attribute applies to all the functions
4482 declared; the @code{format} attribute only applies to @code{d1}.
4484 An attribute specifier list may appear immediately before the comma,
4485 @code{=} or semicolon terminating the declaration of an identifier other
4486 than a function definition.  Such attribute specifiers apply
4487 to the declared object or function.  Where an
4488 assembler name for an object or function is specified (@pxref{Asm
4489 Labels}), the attribute must follow the @code{asm}
4490 specification.
4492 An attribute specifier list may, in future, be permitted to appear after
4493 the declarator in a function definition (before any old-style parameter
4494 declarations or the function body).
4496 Attribute specifiers may be mixed with type qualifiers appearing inside
4497 the @code{[]} of a parameter array declarator, in the C99 construct by
4498 which such qualifiers are applied to the pointer to which the array is
4499 implicitly converted.  Such attribute specifiers apply to the pointer,
4500 not to the array, but at present this is not implemented and they are
4501 ignored.
4503 An attribute specifier list may appear at the start of a nested
4504 declarator.  At present, there are some limitations in this usage: the
4505 attributes correctly apply to the declarator, but for most individual
4506 attributes the semantics this implies are not implemented.
4507 When attribute specifiers follow the @code{*} of a pointer
4508 declarator, they may be mixed with any type qualifiers present.
4509 The following describes the formal semantics of this syntax.  It makes the
4510 most sense if you are familiar with the formal specification of
4511 declarators in the ISO C standard.
4513 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4514 D1}, where @code{T} contains declaration specifiers that specify a type
4515 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4516 contains an identifier @var{ident}.  The type specified for @var{ident}
4517 for derived declarators whose type does not include an attribute
4518 specifier is as in the ISO C standard.
4520 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4521 and the declaration @code{T D} specifies the type
4522 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4523 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4524 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4526 If @code{D1} has the form @code{*
4527 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4528 declaration @code{T D} specifies the type
4529 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4530 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4531 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4532 @var{ident}.
4534 For example,
4536 @smallexample
4537 void (__attribute__((noreturn)) ****f) (void);
4538 @end smallexample
4540 @noindent
4541 specifies the type ``pointer to pointer to pointer to pointer to
4542 non-returning function returning @code{void}''.  As another example,
4544 @smallexample
4545 char *__attribute__((aligned(8))) *f;
4546 @end smallexample
4548 @noindent
4549 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4550 Note again that this does not work with most attributes; for example,
4551 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4552 is not yet supported.
4554 For compatibility with existing code written for compiler versions that
4555 did not implement attributes on nested declarators, some laxity is
4556 allowed in the placing of attributes.  If an attribute that only applies
4557 to types is applied to a declaration, it is treated as applying to
4558 the type of that declaration.  If an attribute that only applies to
4559 declarations is applied to the type of a declaration, it is treated
4560 as applying to that declaration; and, for compatibility with code
4561 placing the attributes immediately before the identifier declared, such
4562 an attribute applied to a function return type is treated as
4563 applying to the function type, and such an attribute applied to an array
4564 element type is treated as applying to the array type.  If an
4565 attribute that only applies to function types is applied to a
4566 pointer-to-function type, it is treated as applying to the pointer
4567 target type; if such an attribute is applied to a function return type
4568 that is not a pointer-to-function type, it is treated as applying
4569 to the function type.
4571 @node Function Prototypes
4572 @section Prototypes and Old-Style Function Definitions
4573 @cindex function prototype declarations
4574 @cindex old-style function definitions
4575 @cindex promotion of formal parameters
4577 GNU C extends ISO C to allow a function prototype to override a later
4578 old-style non-prototype definition.  Consider the following example:
4580 @smallexample
4581 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4582 #ifdef __STDC__
4583 #define P(x) x
4584 #else
4585 #define P(x) ()
4586 #endif
4588 /* @r{Prototype function declaration.}  */
4589 int isroot P((uid_t));
4591 /* @r{Old-style function definition.}  */
4593 isroot (x)   /* @r{??? lossage here ???} */
4594      uid_t x;
4596   return x == 0;
4598 @end smallexample
4600 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4601 not allow this example, because subword arguments in old-style
4602 non-prototype definitions are promoted.  Therefore in this example the
4603 function definition's argument is really an @code{int}, which does not
4604 match the prototype argument type of @code{short}.
4606 This restriction of ISO C makes it hard to write code that is portable
4607 to traditional C compilers, because the programmer does not know
4608 whether the @code{uid_t} type is @code{short}, @code{int}, or
4609 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4610 to override a later old-style definition.  More precisely, in GNU C, a
4611 function prototype argument type overrides the argument type specified
4612 by a later old-style definition if the former type is the same as the
4613 latter type before promotion.  Thus in GNU C the above example is
4614 equivalent to the following:
4616 @smallexample
4617 int isroot (uid_t);
4620 isroot (uid_t x)
4622   return x == 0;
4624 @end smallexample
4626 @noindent
4627 GNU C++ does not support old-style function definitions, so this
4628 extension is irrelevant.
4630 @node C++ Comments
4631 @section C++ Style Comments
4632 @cindex @code{//}
4633 @cindex C++ comments
4634 @cindex comments, C++ style
4636 In GNU C, you may use C++ style comments, which start with @samp{//} and
4637 continue until the end of the line.  Many other C implementations allow
4638 such comments, and they are included in the 1999 C standard.  However,
4639 C++ style comments are not recognized if you specify an @option{-std}
4640 option specifying a version of ISO C before C99, or @option{-ansi}
4641 (equivalent to @option{-std=c90}).
4643 @node Dollar Signs
4644 @section Dollar Signs in Identifier Names
4645 @cindex $
4646 @cindex dollar signs in identifier names
4647 @cindex identifier names, dollar signs in
4649 In GNU C, you may normally use dollar signs in identifier names.
4650 This is because many traditional C implementations allow such identifiers.
4651 However, dollar signs in identifiers are not supported on a few target
4652 machines, typically because the target assembler does not allow them.
4654 @node Character Escapes
4655 @section The Character @key{ESC} in Constants
4657 You can use the sequence @samp{\e} in a string or character constant to
4658 stand for the ASCII character @key{ESC}.
4660 @node Variable Attributes
4661 @section Specifying Attributes of Variables
4662 @cindex attribute of variables
4663 @cindex variable attributes
4665 The keyword @code{__attribute__} allows you to specify special
4666 attributes of variables or structure fields.  This keyword is followed
4667 by an attribute specification inside double parentheses.  Some
4668 attributes are currently defined generically for variables.
4669 Other attributes are defined for variables on particular target
4670 systems.  Other attributes are available for functions
4671 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4672 Other front ends might define more attributes
4673 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4675 You may also specify attributes with @samp{__} preceding and following
4676 each keyword.  This allows you to use them in header files without
4677 being concerned about a possible macro of the same name.  For example,
4678 you may use @code{__aligned__} instead of @code{aligned}.
4680 @xref{Attribute Syntax}, for details of the exact syntax for using
4681 attributes.
4683 @table @code
4684 @cindex @code{aligned} attribute
4685 @item aligned (@var{alignment})
4686 This attribute specifies a minimum alignment for the variable or
4687 structure field, measured in bytes.  For example, the declaration:
4689 @smallexample
4690 int x __attribute__ ((aligned (16))) = 0;
4691 @end smallexample
4693 @noindent
4694 causes the compiler to allocate the global variable @code{x} on a
4695 16-byte boundary.  On a 68040, this could be used in conjunction with
4696 an @code{asm} expression to access the @code{move16} instruction which
4697 requires 16-byte aligned operands.
4699 You can also specify the alignment of structure fields.  For example, to
4700 create a double-word aligned @code{int} pair, you could write:
4702 @smallexample
4703 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4704 @end smallexample
4706 @noindent
4707 This is an alternative to creating a union with a @code{double} member,
4708 which forces the union to be double-word aligned.
4710 As in the preceding examples, you can explicitly specify the alignment
4711 (in bytes) that you wish the compiler to use for a given variable or
4712 structure field.  Alternatively, you can leave out the alignment factor
4713 and just ask the compiler to align a variable or field to the
4714 default alignment for the target architecture you are compiling for.
4715 The default alignment is sufficient for all scalar types, but may not be
4716 enough for all vector types on a target that supports vector operations.
4717 The default alignment is fixed for a particular target ABI.
4719 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4720 which is the largest alignment ever used for any data type on the
4721 target machine you are compiling for.  For example, you could write:
4723 @smallexample
4724 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4725 @end smallexample
4727 The compiler automatically sets the alignment for the declared
4728 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
4729 often make copy operations more efficient, because the compiler can
4730 use whatever instructions copy the biggest chunks of memory when
4731 performing copies to or from the variables or fields that you have
4732 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
4733 may change depending on command-line options.
4735 When used on a struct, or struct member, the @code{aligned} attribute can
4736 only increase the alignment; in order to decrease it, the @code{packed}
4737 attribute must be specified as well.  When used as part of a typedef, the
4738 @code{aligned} attribute can both increase and decrease alignment, and
4739 specifying the @code{packed} attribute generates a warning.
4741 Note that the effectiveness of @code{aligned} attributes may be limited
4742 by inherent limitations in your linker.  On many systems, the linker is
4743 only able to arrange for variables to be aligned up to a certain maximum
4744 alignment.  (For some linkers, the maximum supported alignment may
4745 be very very small.)  If your linker is only able to align variables
4746 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4747 in an @code{__attribute__} still only provides you with 8-byte
4748 alignment.  See your linker documentation for further information.
4750 The @code{aligned} attribute can also be used for functions
4751 (@pxref{Function Attributes}.)
4753 @item cleanup (@var{cleanup_function})
4754 @cindex @code{cleanup} attribute
4755 The @code{cleanup} attribute runs a function when the variable goes
4756 out of scope.  This attribute can only be applied to auto function
4757 scope variables; it may not be applied to parameters or variables
4758 with static storage duration.  The function must take one parameter,
4759 a pointer to a type compatible with the variable.  The return value
4760 of the function (if any) is ignored.
4762 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4763 is run during the stack unwinding that happens during the
4764 processing of the exception.  Note that the @code{cleanup} attribute
4765 does not allow the exception to be caught, only to perform an action.
4766 It is undefined what happens if @var{cleanup_function} does not
4767 return normally.
4769 @item common
4770 @itemx nocommon
4771 @cindex @code{common} attribute
4772 @cindex @code{nocommon} attribute
4773 @opindex fcommon
4774 @opindex fno-common
4775 The @code{common} attribute requests GCC to place a variable in
4776 ``common'' storage.  The @code{nocommon} attribute requests the
4777 opposite---to allocate space for it directly.
4779 These attributes override the default chosen by the
4780 @option{-fno-common} and @option{-fcommon} flags respectively.
4782 @item deprecated
4783 @itemx deprecated (@var{msg})
4784 @cindex @code{deprecated} attribute
4785 The @code{deprecated} attribute results in a warning if the variable
4786 is used anywhere in the source file.  This is useful when identifying
4787 variables that are expected to be removed in a future version of a
4788 program.  The warning also includes the location of the declaration
4789 of the deprecated variable, to enable users to easily find further
4790 information about why the variable is deprecated, or what they should
4791 do instead.  Note that the warning only occurs for uses:
4793 @smallexample
4794 extern int old_var __attribute__ ((deprecated));
4795 extern int old_var;
4796 int new_fn () @{ return old_var; @}
4797 @end smallexample
4799 @noindent
4800 results in a warning on line 3 but not line 2.  The optional @var{msg}
4801 argument, which must be a string, is printed in the warning if
4802 present.
4804 The @code{deprecated} attribute can also be used for functions and
4805 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4807 @item mode (@var{mode})
4808 @cindex @code{mode} attribute
4809 This attribute specifies the data type for the declaration---whichever
4810 type corresponds to the mode @var{mode}.  This in effect lets you
4811 request an integer or floating-point type according to its width.
4813 You may also specify a mode of @code{byte} or @code{__byte__} to
4814 indicate the mode corresponding to a one-byte integer, @code{word} or
4815 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4816 or @code{__pointer__} for the mode used to represent pointers.
4818 @item packed
4819 @cindex @code{packed} attribute
4820 The @code{packed} attribute specifies that a variable or structure field
4821 should have the smallest possible alignment---one byte for a variable,
4822 and one bit for a field, unless you specify a larger value with the
4823 @code{aligned} attribute.
4825 Here is a structure in which the field @code{x} is packed, so that it
4826 immediately follows @code{a}:
4828 @smallexample
4829 struct foo
4831   char a;
4832   int x[2] __attribute__ ((packed));
4834 @end smallexample
4836 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4837 @code{packed} attribute on bit-fields of type @code{char}.  This has
4838 been fixed in GCC 4.4 but the change can lead to differences in the
4839 structure layout.  See the documentation of
4840 @option{-Wpacked-bitfield-compat} for more information.
4842 @item section ("@var{section-name}")
4843 @cindex @code{section} variable attribute
4844 Normally, the compiler places the objects it generates in sections like
4845 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
4846 or you need certain particular variables to appear in special sections,
4847 for example to map to special hardware.  The @code{section}
4848 attribute specifies that a variable (or function) lives in a particular
4849 section.  For example, this small program uses several specific section names:
4851 @smallexample
4852 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4853 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4854 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4855 int init_data __attribute__ ((section ("INITDATA")));
4857 main()
4859   /* @r{Initialize stack pointer} */
4860   init_sp (stack + sizeof (stack));
4862   /* @r{Initialize initialized data} */
4863   memcpy (&init_data, &data, &edata - &data);
4865   /* @r{Turn on the serial ports} */
4866   init_duart (&a);
4867   init_duart (&b);
4869 @end smallexample
4871 @noindent
4872 Use the @code{section} attribute with
4873 @emph{global} variables and not @emph{local} variables,
4874 as shown in the example.
4876 You may use the @code{section} attribute with initialized or
4877 uninitialized global variables but the linker requires
4878 each object be defined once, with the exception that uninitialized
4879 variables tentatively go in the @code{common} (or @code{bss}) section
4880 and can be multiply ``defined''.  Using the @code{section} attribute
4881 changes what section the variable goes into and may cause the
4882 linker to issue an error if an uninitialized variable has multiple
4883 definitions.  You can force a variable to be initialized with the
4884 @option{-fno-common} flag or the @code{nocommon} attribute.
4886 Some file formats do not support arbitrary sections so the @code{section}
4887 attribute is not available on all platforms.
4888 If you need to map the entire contents of a module to a particular
4889 section, consider using the facilities of the linker instead.
4891 @item shared
4892 @cindex @code{shared} variable attribute
4893 On Microsoft Windows, in addition to putting variable definitions in a named
4894 section, the section can also be shared among all running copies of an
4895 executable or DLL@.  For example, this small program defines shared data
4896 by putting it in a named section @code{shared} and marking the section
4897 shareable:
4899 @smallexample
4900 int foo __attribute__((section ("shared"), shared)) = 0;
4903 main()
4905   /* @r{Read and write foo.  All running
4906      copies see the same value.}  */
4907   return 0;
4909 @end smallexample
4911 @noindent
4912 You may only use the @code{shared} attribute along with @code{section}
4913 attribute with a fully-initialized global definition because of the way
4914 linkers work.  See @code{section} attribute for more information.
4916 The @code{shared} attribute is only available on Microsoft Windows@.
4918 @item tls_model ("@var{tls_model}")
4919 @cindex @code{tls_model} attribute
4920 The @code{tls_model} attribute sets thread-local storage model
4921 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4922 overriding @option{-ftls-model=} command-line switch on a per-variable
4923 basis.
4924 The @var{tls_model} argument should be one of @code{global-dynamic},
4925 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4927 Not all targets support this attribute.
4929 @item unused
4930 This attribute, attached to a variable, means that the variable is meant
4931 to be possibly unused.  GCC does not produce a warning for this
4932 variable.
4934 @item used
4935 This attribute, attached to a variable with the static storage, means that
4936 the variable must be emitted even if it appears that the variable is not
4937 referenced.
4939 When applied to a static data member of a C++ class template, the
4940 attribute also means that the member is instantiated if the
4941 class itself is instantiated.
4943 @item vector_size (@var{bytes})
4944 This attribute specifies the vector size for the variable, measured in
4945 bytes.  For example, the declaration:
4947 @smallexample
4948 int foo __attribute__ ((vector_size (16)));
4949 @end smallexample
4951 @noindent
4952 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4953 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
4954 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
4956 This attribute is only applicable to integral and float scalars,
4957 although arrays, pointers, and function return values are allowed in
4958 conjunction with this construct.
4960 Aggregates with this attribute are invalid, even if they are of the same
4961 size as a corresponding scalar.  For example, the declaration:
4963 @smallexample
4964 struct S @{ int a; @};
4965 struct S  __attribute__ ((vector_size (16))) foo;
4966 @end smallexample
4968 @noindent
4969 is invalid even if the size of the structure is the same as the size of
4970 the @code{int}.
4972 @item selectany
4973 The @code{selectany} attribute causes an initialized global variable to
4974 have link-once semantics.  When multiple definitions of the variable are
4975 encountered by the linker, the first is selected and the remainder are
4976 discarded.  Following usage by the Microsoft compiler, the linker is told
4977 @emph{not} to warn about size or content differences of the multiple
4978 definitions.
4980 Although the primary usage of this attribute is for POD types, the
4981 attribute can also be applied to global C++ objects that are initialized
4982 by a constructor.  In this case, the static initialization and destruction
4983 code for the object is emitted in each translation defining the object,
4984 but the calls to the constructor and destructor are protected by a
4985 link-once guard variable.
4987 The @code{selectany} attribute is only available on Microsoft Windows
4988 targets.  You can use @code{__declspec (selectany)} as a synonym for
4989 @code{__attribute__ ((selectany))} for compatibility with other
4990 compilers.
4992 @item weak
4993 The @code{weak} attribute is described in @ref{Function Attributes}.
4995 @item dllimport
4996 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4998 @item dllexport
4999 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5001 @end table
5003 @anchor{AVR Variable Attributes}
5004 @subsection AVR Variable Attributes
5006 @table @code
5007 @item progmem
5008 @cindex @code{progmem} AVR variable attribute
5009 The @code{progmem} attribute is used on the AVR to place read-only
5010 data in the non-volatile program memory (flash). The @code{progmem}
5011 attribute accomplishes this by putting respective variables into a
5012 section whose name starts with @code{.progmem}.
5014 This attribute works similar to the @code{section} attribute
5015 but adds additional checking. Notice that just like the
5016 @code{section} attribute, @code{progmem} affects the location
5017 of the data but not how this data is accessed.
5019 In order to read data located with the @code{progmem} attribute
5020 (inline) assembler must be used.
5021 @smallexample
5022 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5023 #include <avr/pgmspace.h> 
5025 /* Locate var in flash memory */
5026 const int var[2] PROGMEM = @{ 1, 2 @};
5028 int read_var (int i)
5030     /* Access var[] by accessor macro from avr/pgmspace.h */
5031     return (int) pgm_read_word (& var[i]);
5033 @end smallexample
5035 AVR is a Harvard architecture processor and data and read-only data
5036 normally resides in the data memory (RAM).
5038 See also the @ref{AVR Named Address Spaces} section for
5039 an alternate way to locate and access data in flash memory.
5040 @end table
5042 @subsection Blackfin Variable Attributes
5044 Three attributes are currently defined for the Blackfin.
5046 @table @code
5047 @item l1_data
5048 @itemx l1_data_A
5049 @itemx l1_data_B
5050 @cindex @code{l1_data} variable attribute
5051 @cindex @code{l1_data_A} variable attribute
5052 @cindex @code{l1_data_B} variable attribute
5053 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5054 Variables with @code{l1_data} attribute are put into the specific section
5055 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5056 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5057 attribute are put into the specific section named @code{.l1.data.B}.
5059 @item l2
5060 @cindex @code{l2} variable attribute
5061 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5062 Variables with @code{l2} attribute are put into the specific section
5063 named @code{.l2.data}.
5064 @end table
5066 @subsection M32R/D Variable Attributes
5068 One attribute is currently defined for the M32R/D@.
5070 @table @code
5071 @item model (@var{model-name})
5072 @cindex variable addressability on the M32R/D
5073 Use this attribute on the M32R/D to set the addressability of an object.
5074 The identifier @var{model-name} is one of @code{small}, @code{medium},
5075 or @code{large}, representing each of the code models.
5077 Small model objects live in the lower 16MB of memory (so that their
5078 addresses can be loaded with the @code{ld24} instruction).
5080 Medium and large model objects may live anywhere in the 32-bit address space
5081 (the compiler generates @code{seth/add3} instructions to load their
5082 addresses).
5083 @end table
5085 @anchor{MeP Variable Attributes}
5086 @subsection MeP Variable Attributes
5088 The MeP target has a number of addressing modes and busses.  The
5089 @code{near} space spans the standard memory space's first 16 megabytes
5090 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5091 The @code{based} space is a 128-byte region in the memory space that
5092 is addressed relative to the @code{$tp} register.  The @code{tiny}
5093 space is a 65536-byte region relative to the @code{$gp} register.  In
5094 addition to these memory regions, the MeP target has a separate 16-bit
5095 control bus which is specified with @code{cb} attributes.
5097 @table @code
5099 @item based
5100 Any variable with the @code{based} attribute is assigned to the
5101 @code{.based} section, and is accessed with relative to the
5102 @code{$tp} register.
5104 @item tiny
5105 Likewise, the @code{tiny} attribute assigned variables to the
5106 @code{.tiny} section, relative to the @code{$gp} register.
5108 @item near
5109 Variables with the @code{near} attribute are assumed to have addresses
5110 that fit in a 24-bit addressing mode.  This is the default for large
5111 variables (@code{-mtiny=4} is the default) but this attribute can
5112 override @code{-mtiny=} for small variables, or override @code{-ml}.
5114 @item far
5115 Variables with the @code{far} attribute are addressed using a full
5116 32-bit address.  Since this covers the entire memory space, this
5117 allows modules to make no assumptions about where variables might be
5118 stored.
5120 @item io
5121 @itemx io (@var{addr})
5122 Variables with the @code{io} attribute are used to address
5123 memory-mapped peripherals.  If an address is specified, the variable
5124 is assigned that address, else it is not assigned an address (it is
5125 assumed some other module assigns an address).  Example:
5127 @smallexample
5128 int timer_count __attribute__((io(0x123)));
5129 @end smallexample
5131 @item cb
5132 @itemx cb (@var{addr})
5133 Variables with the @code{cb} attribute are used to access the control
5134 bus, using special instructions.  @code{addr} indicates the control bus
5135 address.  Example:
5137 @smallexample
5138 int cpu_clock __attribute__((cb(0x123)));
5139 @end smallexample
5141 @end table
5143 @anchor{i386 Variable Attributes}
5144 @subsection i386 Variable Attributes
5146 Two attributes are currently defined for i386 configurations:
5147 @code{ms_struct} and @code{gcc_struct}
5149 @table @code
5150 @item ms_struct
5151 @itemx gcc_struct
5152 @cindex @code{ms_struct} attribute
5153 @cindex @code{gcc_struct} attribute
5155 If @code{packed} is used on a structure, or if bit-fields are used,
5156 it may be that the Microsoft ABI lays out the structure differently
5157 than the way GCC normally does.  Particularly when moving packed
5158 data between functions compiled with GCC and the native Microsoft compiler
5159 (either via function call or as data in a file), it may be necessary to access
5160 either format.
5162 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5163 compilers to match the native Microsoft compiler.
5165 The Microsoft structure layout algorithm is fairly simple with the exception
5166 of the bit-field packing.  
5167 The padding and alignment of members of structures and whether a bit-field 
5168 can straddle a storage-unit boundary are determine by these rules:
5170 @enumerate
5171 @item Structure members are stored sequentially in the order in which they are
5172 declared: the first member has the lowest memory address and the last member
5173 the highest.
5175 @item Every data object has an alignment requirement.  The alignment requirement
5176 for all data except structures, unions, and arrays is either the size of the
5177 object or the current packing size (specified with either the
5178 @code{aligned} attribute or the @code{pack} pragma),
5179 whichever is less.  For structures, unions, and arrays,
5180 the alignment requirement is the largest alignment requirement of its members.
5181 Every object is allocated an offset so that:
5183 @smallexample
5184 offset % alignment_requirement == 0
5185 @end smallexample
5187 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5188 unit if the integral types are the same size and if the next bit-field fits
5189 into the current allocation unit without crossing the boundary imposed by the
5190 common alignment requirements of the bit-fields.
5191 @end enumerate
5193 MSVC interprets zero-length bit-fields in the following ways:
5195 @enumerate
5196 @item If a zero-length bit-field is inserted between two bit-fields that
5197 are normally coalesced, the bit-fields are not coalesced.
5199 For example:
5201 @smallexample
5202 struct
5203  @{
5204    unsigned long bf_1 : 12;
5205    unsigned long : 0;
5206    unsigned long bf_2 : 12;
5207  @} t1;
5208 @end smallexample
5210 @noindent
5211 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5212 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5214 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5215 alignment of the zero-length bit-field is greater than the member that follows it,
5216 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5218 For example:
5220 @smallexample
5221 struct
5222  @{
5223    char foo : 4;
5224    short : 0;
5225    char bar;
5226  @} t2;
5228 struct
5229  @{
5230    char foo : 4;
5231    short : 0;
5232    double bar;
5233  @} t3;
5234 @end smallexample
5236 @noindent
5237 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5238 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5239 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5240 of the structure.
5242 Taking this into account, it is important to note the following:
5244 @enumerate
5245 @item If a zero-length bit-field follows a normal bit-field, the type of the
5246 zero-length bit-field may affect the alignment of the structure as whole. For
5247 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5248 normal bit-field, and is of type short.
5250 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5251 still affect the alignment of the structure:
5253 @smallexample
5254 struct
5255  @{
5256    char foo : 6;
5257    long : 0;
5258  @} t4;
5259 @end smallexample
5261 @noindent
5262 Here, @code{t4} takes up 4 bytes.
5263 @end enumerate
5265 @item Zero-length bit-fields following non-bit-field members are ignored:
5267 @smallexample
5268 struct
5269  @{
5270    char foo;
5271    long : 0;
5272    char bar;
5273  @} t5;
5274 @end smallexample
5276 @noindent
5277 Here, @code{t5} takes up 2 bytes.
5278 @end enumerate
5279 @end table
5281 @subsection PowerPC Variable Attributes
5283 Three attributes currently are defined for PowerPC configurations:
5284 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5286 For full documentation of the struct attributes please see the
5287 documentation in @ref{i386 Variable Attributes}.
5289 For documentation of @code{altivec} attribute please see the
5290 documentation in @ref{PowerPC Type Attributes}.
5292 @subsection SPU Variable Attributes
5294 The SPU supports the @code{spu_vector} attribute for variables.  For
5295 documentation of this attribute please see the documentation in
5296 @ref{SPU Type Attributes}.
5298 @subsection Xstormy16 Variable Attributes
5300 One attribute is currently defined for xstormy16 configurations:
5301 @code{below100}.
5303 @table @code
5304 @item below100
5305 @cindex @code{below100} attribute
5307 If a variable has the @code{below100} attribute (@code{BELOW100} is
5308 allowed also), GCC places the variable in the first 0x100 bytes of
5309 memory and use special opcodes to access it.  Such variables are
5310 placed in either the @code{.bss_below100} section or the
5311 @code{.data_below100} section.
5313 @end table
5315 @node Type Attributes
5316 @section Specifying Attributes of Types
5317 @cindex attribute of types
5318 @cindex type attributes
5320 The keyword @code{__attribute__} allows you to specify special
5321 attributes of @code{struct} and @code{union} types when you define
5322 such types.  This keyword is followed by an attribute specification
5323 inside double parentheses.  Seven attributes are currently defined for
5324 types: @code{aligned}, @code{packed}, @code{transparent_union},
5325 @code{unused}, @code{deprecated}, @code{visibility}, and
5326 @code{may_alias}.  Other attributes are defined for functions
5327 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5328 Attributes}).
5330 You may also specify any one of these attributes with @samp{__}
5331 preceding and following its keyword.  This allows you to use these
5332 attributes in header files without being concerned about a possible
5333 macro of the same name.  For example, you may use @code{__aligned__}
5334 instead of @code{aligned}.
5336 You may specify type attributes in an enum, struct or union type
5337 declaration or definition, or for other types in a @code{typedef}
5338 declaration.
5340 For an enum, struct or union type, you may specify attributes either
5341 between the enum, struct or union tag and the name of the type, or
5342 just past the closing curly brace of the @emph{definition}.  The
5343 former syntax is preferred.
5345 @xref{Attribute Syntax}, for details of the exact syntax for using
5346 attributes.
5348 @table @code
5349 @cindex @code{aligned} attribute
5350 @item aligned (@var{alignment})
5351 This attribute specifies a minimum alignment (in bytes) for variables
5352 of the specified type.  For example, the declarations:
5354 @smallexample
5355 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5356 typedef int more_aligned_int __attribute__ ((aligned (8)));
5357 @end smallexample
5359 @noindent
5360 force the compiler to ensure (as far as it can) that each variable whose
5361 type is @code{struct S} or @code{more_aligned_int} is allocated and
5362 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5363 variables of type @code{struct S} aligned to 8-byte boundaries allows
5364 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5365 store) instructions when copying one variable of type @code{struct S} to
5366 another, thus improving run-time efficiency.
5368 Note that the alignment of any given @code{struct} or @code{union} type
5369 is required by the ISO C standard to be at least a perfect multiple of
5370 the lowest common multiple of the alignments of all of the members of
5371 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5372 effectively adjust the alignment of a @code{struct} or @code{union}
5373 type by attaching an @code{aligned} attribute to any one of the members
5374 of such a type, but the notation illustrated in the example above is a
5375 more obvious, intuitive, and readable way to request the compiler to
5376 adjust the alignment of an entire @code{struct} or @code{union} type.
5378 As in the preceding example, you can explicitly specify the alignment
5379 (in bytes) that you wish the compiler to use for a given @code{struct}
5380 or @code{union} type.  Alternatively, you can leave out the alignment factor
5381 and just ask the compiler to align a type to the maximum
5382 useful alignment for the target machine you are compiling for.  For
5383 example, you could write:
5385 @smallexample
5386 struct S @{ short f[3]; @} __attribute__ ((aligned));
5387 @end smallexample
5389 Whenever you leave out the alignment factor in an @code{aligned}
5390 attribute specification, the compiler automatically sets the alignment
5391 for the type to the largest alignment that is ever used for any data
5392 type on the target machine you are compiling for.  Doing this can often
5393 make copy operations more efficient, because the compiler can use
5394 whatever instructions copy the biggest chunks of memory when performing
5395 copies to or from the variables that have types that you have aligned
5396 this way.
5398 In the example above, if the size of each @code{short} is 2 bytes, then
5399 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5400 power of two that is greater than or equal to that is 8, so the
5401 compiler sets the alignment for the entire @code{struct S} type to 8
5402 bytes.
5404 Note that although you can ask the compiler to select a time-efficient
5405 alignment for a given type and then declare only individual stand-alone
5406 objects of that type, the compiler's ability to select a time-efficient
5407 alignment is primarily useful only when you plan to create arrays of
5408 variables having the relevant (efficiently aligned) type.  If you
5409 declare or use arrays of variables of an efficiently-aligned type, then
5410 it is likely that your program also does pointer arithmetic (or
5411 subscripting, which amounts to the same thing) on pointers to the
5412 relevant type, and the code that the compiler generates for these
5413 pointer arithmetic operations is often more efficient for
5414 efficiently-aligned types than for other types.
5416 The @code{aligned} attribute can only increase the alignment; but you
5417 can decrease it by specifying @code{packed} as well.  See below.
5419 Note that the effectiveness of @code{aligned} attributes may be limited
5420 by inherent limitations in your linker.  On many systems, the linker is
5421 only able to arrange for variables to be aligned up to a certain maximum
5422 alignment.  (For some linkers, the maximum supported alignment may
5423 be very very small.)  If your linker is only able to align variables
5424 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5425 in an @code{__attribute__} still only provides you with 8-byte
5426 alignment.  See your linker documentation for further information.
5428 @item packed
5429 This attribute, attached to @code{struct} or @code{union} type
5430 definition, specifies that each member (other than zero-width bit-fields)
5431 of the structure or union is placed to minimize the memory required.  When
5432 attached to an @code{enum} definition, it indicates that the smallest
5433 integral type should be used.
5435 @opindex fshort-enums
5436 Specifying this attribute for @code{struct} and @code{union} types is
5437 equivalent to specifying the @code{packed} attribute on each of the
5438 structure or union members.  Specifying the @option{-fshort-enums}
5439 flag on the line is equivalent to specifying the @code{packed}
5440 attribute on all @code{enum} definitions.
5442 In the following example @code{struct my_packed_struct}'s members are
5443 packed closely together, but the internal layout of its @code{s} member
5444 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5445 be packed too.
5447 @smallexample
5448 struct my_unpacked_struct
5449  @{
5450     char c;
5451     int i;
5452  @};
5454 struct __attribute__ ((__packed__)) my_packed_struct
5455   @{
5456      char c;
5457      int  i;
5458      struct my_unpacked_struct s;
5459   @};
5460 @end smallexample
5462 You may only specify this attribute on the definition of an @code{enum},
5463 @code{struct} or @code{union}, not on a @code{typedef} that does not
5464 also define the enumerated type, structure or union.
5466 @item transparent_union
5467 This attribute, attached to a @code{union} type definition, indicates
5468 that any function parameter having that union type causes calls to that
5469 function to be treated in a special way.
5471 First, the argument corresponding to a transparent union type can be of
5472 any type in the union; no cast is required.  Also, if the union contains
5473 a pointer type, the corresponding argument can be a null pointer
5474 constant or a void pointer expression; and if the union contains a void
5475 pointer type, the corresponding argument can be any pointer expression.
5476 If the union member type is a pointer, qualifiers like @code{const} on
5477 the referenced type must be respected, just as with normal pointer
5478 conversions.
5480 Second, the argument is passed to the function using the calling
5481 conventions of the first member of the transparent union, not the calling
5482 conventions of the union itself.  All members of the union must have the
5483 same machine representation; this is necessary for this argument passing
5484 to work properly.
5486 Transparent unions are designed for library functions that have multiple
5487 interfaces for compatibility reasons.  For example, suppose the
5488 @code{wait} function must accept either a value of type @code{int *} to
5489 comply with POSIX, or a value of type @code{union wait *} to comply with
5490 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5491 @code{wait} would accept both kinds of arguments, but it would also
5492 accept any other pointer type and this would make argument type checking
5493 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5494 as follows:
5496 @smallexample
5497 typedef union __attribute__ ((__transparent_union__))
5498   @{
5499     int *__ip;
5500     union wait *__up;
5501   @} wait_status_ptr_t;
5503 pid_t wait (wait_status_ptr_t);
5504 @end smallexample
5506 @noindent
5507 This interface allows either @code{int *} or @code{union wait *}
5508 arguments to be passed, using the @code{int *} calling convention.
5509 The program can call @code{wait} with arguments of either type:
5511 @smallexample
5512 int w1 () @{ int w; return wait (&w); @}
5513 int w2 () @{ union wait w; return wait (&w); @}
5514 @end smallexample
5516 @noindent
5517 With this interface, @code{wait}'s implementation might look like this:
5519 @smallexample
5520 pid_t wait (wait_status_ptr_t p)
5522   return waitpid (-1, p.__ip, 0);
5524 @end smallexample
5526 @item unused
5527 When attached to a type (including a @code{union} or a @code{struct}),
5528 this attribute means that variables of that type are meant to appear
5529 possibly unused.  GCC does not produce a warning for any variables of
5530 that type, even if the variable appears to do nothing.  This is often
5531 the case with lock or thread classes, which are usually defined and then
5532 not referenced, but contain constructors and destructors that have
5533 nontrivial bookkeeping functions.
5535 @item deprecated
5536 @itemx deprecated (@var{msg})
5537 The @code{deprecated} attribute results in a warning if the type
5538 is used anywhere in the source file.  This is useful when identifying
5539 types that are expected to be removed in a future version of a program.
5540 If possible, the warning also includes the location of the declaration
5541 of the deprecated type, to enable users to easily find further
5542 information about why the type is deprecated, or what they should do
5543 instead.  Note that the warnings only occur for uses and then only
5544 if the type is being applied to an identifier that itself is not being
5545 declared as deprecated.
5547 @smallexample
5548 typedef int T1 __attribute__ ((deprecated));
5549 T1 x;
5550 typedef T1 T2;
5551 T2 y;
5552 typedef T1 T3 __attribute__ ((deprecated));
5553 T3 z __attribute__ ((deprecated));
5554 @end smallexample
5556 @noindent
5557 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5558 warning is issued for line 4 because T2 is not explicitly
5559 deprecated.  Line 5 has no warning because T3 is explicitly
5560 deprecated.  Similarly for line 6.  The optional @var{msg}
5561 argument, which must be a string, is printed in the warning if
5562 present.
5564 The @code{deprecated} attribute can also be used for functions and
5565 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5567 @item may_alias
5568 Accesses through pointers to types with this attribute are not subject
5569 to type-based alias analysis, but are instead assumed to be able to alias
5570 any other type of objects.
5571 In the context of section 6.5 paragraph 7 of the C99 standard,
5572 an lvalue expression
5573 dereferencing such a pointer is treated like having a character type.
5574 See @option{-fstrict-aliasing} for more information on aliasing issues.
5575 This extension exists to support some vector APIs, in which pointers to
5576 one vector type are permitted to alias pointers to a different vector type.
5578 Note that an object of a type with this attribute does not have any
5579 special semantics.
5581 Example of use:
5583 @smallexample
5584 typedef short __attribute__((__may_alias__)) short_a;
5587 main (void)
5589   int a = 0x12345678;
5590   short_a *b = (short_a *) &a;
5592   b[1] = 0;
5594   if (a == 0x12345678)
5595     abort();
5597   exit(0);
5599 @end smallexample
5601 @noindent
5602 If you replaced @code{short_a} with @code{short} in the variable
5603 declaration, the above program would abort when compiled with
5604 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5605 above in recent GCC versions.
5607 @item visibility
5608 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5609 applied to class, struct, union and enum types.  Unlike other type
5610 attributes, the attribute must appear between the initial keyword and
5611 the name of the type; it cannot appear after the body of the type.
5613 Note that the type visibility is applied to vague linkage entities
5614 associated with the class (vtable, typeinfo node, etc.).  In
5615 particular, if a class is thrown as an exception in one shared object
5616 and caught in another, the class must have default visibility.
5617 Otherwise the two shared objects are unable to use the same
5618 typeinfo node and exception handling will break.
5620 @end table
5622 To specify multiple attributes, separate them by commas within the
5623 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5624 packed))}.
5626 @subsection ARM Type Attributes
5628 On those ARM targets that support @code{dllimport} (such as Symbian
5629 OS), you can use the @code{notshared} attribute to indicate that the
5630 virtual table and other similar data for a class should not be
5631 exported from a DLL@.  For example:
5633 @smallexample
5634 class __declspec(notshared) C @{
5635 public:
5636   __declspec(dllimport) C();
5637   virtual void f();
5640 __declspec(dllexport)
5641 C::C() @{@}
5642 @end smallexample
5644 @noindent
5645 In this code, @code{C::C} is exported from the current DLL, but the
5646 virtual table for @code{C} is not exported.  (You can use
5647 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5648 most Symbian OS code uses @code{__declspec}.)
5650 @anchor{MeP Type Attributes}
5651 @subsection MeP Type Attributes
5653 Many of the MeP variable attributes may be applied to types as well.
5654 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5655 @code{far} attributes may be applied to either.  The @code{io} and
5656 @code{cb} attributes may not be applied to types.
5658 @anchor{i386 Type Attributes}
5659 @subsection i386 Type Attributes
5661 Two attributes are currently defined for i386 configurations:
5662 @code{ms_struct} and @code{gcc_struct}.
5664 @table @code
5666 @item ms_struct
5667 @itemx gcc_struct
5668 @cindex @code{ms_struct}
5669 @cindex @code{gcc_struct}
5671 If @code{packed} is used on a structure, or if bit-fields are used
5672 it may be that the Microsoft ABI packs them differently
5673 than GCC normally packs them.  Particularly when moving packed
5674 data between functions compiled with GCC and the native Microsoft compiler
5675 (either via function call or as data in a file), it may be necessary to access
5676 either format.
5678 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5679 compilers to match the native Microsoft compiler.
5680 @end table
5682 @anchor{PowerPC Type Attributes}
5683 @subsection PowerPC Type Attributes
5685 Three attributes currently are defined for PowerPC configurations:
5686 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5688 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5689 attributes please see the documentation in @ref{i386 Type Attributes}.
5691 The @code{altivec} attribute allows one to declare AltiVec vector data
5692 types supported by the AltiVec Programming Interface Manual.  The
5693 attribute requires an argument to specify one of three vector types:
5694 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5695 and @code{bool__} (always followed by unsigned).
5697 @smallexample
5698 __attribute__((altivec(vector__)))
5699 __attribute__((altivec(pixel__))) unsigned short
5700 __attribute__((altivec(bool__))) unsigned
5701 @end smallexample
5703 These attributes mainly are intended to support the @code{__vector},
5704 @code{__pixel}, and @code{__bool} AltiVec keywords.
5706 @anchor{SPU Type Attributes}
5707 @subsection SPU Type Attributes
5709 The SPU supports the @code{spu_vector} attribute for types.  This attribute
5710 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5711 Language Extensions Specification.  It is intended to support the
5712 @code{__vector} keyword.
5714 @node Alignment
5715 @section Inquiring on Alignment of Types or Variables
5716 @cindex alignment
5717 @cindex type alignment
5718 @cindex variable alignment
5720 The keyword @code{__alignof__} allows you to inquire about how an object
5721 is aligned, or the minimum alignment usually required by a type.  Its
5722 syntax is just like @code{sizeof}.
5724 For example, if the target machine requires a @code{double} value to be
5725 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5726 This is true on many RISC machines.  On more traditional machine
5727 designs, @code{__alignof__ (double)} is 4 or even 2.
5729 Some machines never actually require alignment; they allow reference to any
5730 data type even at an odd address.  For these machines, @code{__alignof__}
5731 reports the smallest alignment that GCC gives the data type, usually as
5732 mandated by the target ABI.
5734 If the operand of @code{__alignof__} is an lvalue rather than a type,
5735 its value is the required alignment for its type, taking into account
5736 any minimum alignment specified with GCC's @code{__attribute__}
5737 extension (@pxref{Variable Attributes}).  For example, after this
5738 declaration:
5740 @smallexample
5741 struct foo @{ int x; char y; @} foo1;
5742 @end smallexample
5744 @noindent
5745 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5746 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5748 It is an error to ask for the alignment of an incomplete type.
5751 @node Inline
5752 @section An Inline Function is As Fast As a Macro
5753 @cindex inline functions
5754 @cindex integrating function code
5755 @cindex open coding
5756 @cindex macros, inline alternative
5758 By declaring a function inline, you can direct GCC to make
5759 calls to that function faster.  One way GCC can achieve this is to
5760 integrate that function's code into the code for its callers.  This
5761 makes execution faster by eliminating the function-call overhead; in
5762 addition, if any of the actual argument values are constant, their
5763 known values may permit simplifications at compile time so that not
5764 all of the inline function's code needs to be included.  The effect on
5765 code size is less predictable; object code may be larger or smaller
5766 with function inlining, depending on the particular case.  You can
5767 also direct GCC to try to integrate all ``simple enough'' functions
5768 into their callers with the option @option{-finline-functions}.
5770 GCC implements three different semantics of declaring a function
5771 inline.  One is available with @option{-std=gnu89} or
5772 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5773 on all inline declarations, another when
5774 @option{-std=c99}, @option{-std=c11},
5775 @option{-std=gnu99} or @option{-std=gnu11}
5776 (without @option{-fgnu89-inline}), and the third
5777 is used when compiling C++.
5779 To declare a function inline, use the @code{inline} keyword in its
5780 declaration, like this:
5782 @smallexample
5783 static inline int
5784 inc (int *a)
5786   return (*a)++;
5788 @end smallexample
5790 If you are writing a header file to be included in ISO C90 programs, write
5791 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
5793 The three types of inlining behave similarly in two important cases:
5794 when the @code{inline} keyword is used on a @code{static} function,
5795 like the example above, and when a function is first declared without
5796 using the @code{inline} keyword and then is defined with
5797 @code{inline}, like this:
5799 @smallexample
5800 extern int inc (int *a);
5801 inline int
5802 inc (int *a)
5804   return (*a)++;
5806 @end smallexample
5808 In both of these common cases, the program behaves the same as if you
5809 had not used the @code{inline} keyword, except for its speed.
5811 @cindex inline functions, omission of
5812 @opindex fkeep-inline-functions
5813 When a function is both inline and @code{static}, if all calls to the
5814 function are integrated into the caller, and the function's address is
5815 never used, then the function's own assembler code is never referenced.
5816 In this case, GCC does not actually output assembler code for the
5817 function, unless you specify the option @option{-fkeep-inline-functions}.
5818 Some calls cannot be integrated for various reasons (in particular,
5819 calls that precede the function's definition cannot be integrated, and
5820 neither can recursive calls within the definition).  If there is a
5821 nonintegrated call, then the function is compiled to assembler code as
5822 usual.  The function must also be compiled as usual if the program
5823 refers to its address, because that can't be inlined.
5825 @opindex Winline
5826 Note that certain usages in a function definition can make it unsuitable
5827 for inline substitution.  Among these usages are: variadic functions, use of
5828 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
5829 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5830 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
5831 warns when a function marked @code{inline} could not be substituted,
5832 and gives the reason for the failure.
5834 @cindex automatic @code{inline} for C++ member fns
5835 @cindex @code{inline} automatic for C++ member fns
5836 @cindex member fns, automatically @code{inline}
5837 @cindex C++ member fns, automatically @code{inline}
5838 @opindex fno-default-inline
5839 As required by ISO C++, GCC considers member functions defined within
5840 the body of a class to be marked inline even if they are
5841 not explicitly declared with the @code{inline} keyword.  You can
5842 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5843 Options,,Options Controlling C++ Dialect}.
5845 GCC does not inline any functions when not optimizing unless you specify
5846 the @samp{always_inline} attribute for the function, like this:
5848 @smallexample
5849 /* @r{Prototype.}  */
5850 inline void foo (const char) __attribute__((always_inline));
5851 @end smallexample
5853 The remainder of this section is specific to GNU C90 inlining.
5855 @cindex non-static inline function
5856 When an inline function is not @code{static}, then the compiler must assume
5857 that there may be calls from other source files; since a global symbol can
5858 be defined only once in any program, the function must not be defined in
5859 the other source files, so the calls therein cannot be integrated.
5860 Therefore, a non-@code{static} inline function is always compiled on its
5861 own in the usual fashion.
5863 If you specify both @code{inline} and @code{extern} in the function
5864 definition, then the definition is used only for inlining.  In no case
5865 is the function compiled on its own, not even if you refer to its
5866 address explicitly.  Such an address becomes an external reference, as
5867 if you had only declared the function, and had not defined it.
5869 This combination of @code{inline} and @code{extern} has almost the
5870 effect of a macro.  The way to use it is to put a function definition in
5871 a header file with these keywords, and put another copy of the
5872 definition (lacking @code{inline} and @code{extern}) in a library file.
5873 The definition in the header file causes most calls to the function
5874 to be inlined.  If any uses of the function remain, they refer to
5875 the single copy in the library.
5877 @node Volatiles
5878 @section When is a Volatile Object Accessed?
5879 @cindex accessing volatiles
5880 @cindex volatile read
5881 @cindex volatile write
5882 @cindex volatile access
5884 C has the concept of volatile objects.  These are normally accessed by
5885 pointers and used for accessing hardware or inter-thread
5886 communication.  The standard encourages compilers to refrain from
5887 optimizations concerning accesses to volatile objects, but leaves it
5888 implementation defined as to what constitutes a volatile access.  The
5889 minimum requirement is that at a sequence point all previous accesses
5890 to volatile objects have stabilized and no subsequent accesses have
5891 occurred.  Thus an implementation is free to reorder and combine
5892 volatile accesses that occur between sequence points, but cannot do
5893 so for accesses across a sequence point.  The use of volatile does
5894 not allow you to violate the restriction on updating objects multiple
5895 times between two sequence points.
5897 Accesses to non-volatile objects are not ordered with respect to
5898 volatile accesses.  You cannot use a volatile object as a memory
5899 barrier to order a sequence of writes to non-volatile memory.  For
5900 instance:
5902 @smallexample
5903 int *ptr = @var{something};
5904 volatile int vobj;
5905 *ptr = @var{something};
5906 vobj = 1;
5907 @end smallexample
5909 @noindent
5910 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5911 that the write to @var{*ptr} occurs by the time the update
5912 of @var{vobj} happens.  If you need this guarantee, you must use
5913 a stronger memory barrier such as:
5915 @smallexample
5916 int *ptr = @var{something};
5917 volatile int vobj;
5918 *ptr = @var{something};
5919 asm volatile ("" : : : "memory");
5920 vobj = 1;
5921 @end smallexample
5923 A scalar volatile object is read when it is accessed in a void context:
5925 @smallexample
5926 volatile int *src = @var{somevalue};
5927 *src;
5928 @end smallexample
5930 Such expressions are rvalues, and GCC implements this as a
5931 read of the volatile object being pointed to.
5933 Assignments are also expressions and have an rvalue.  However when
5934 assigning to a scalar volatile, the volatile object is not reread,
5935 regardless of whether the assignment expression's rvalue is used or
5936 not.  If the assignment's rvalue is used, the value is that assigned
5937 to the volatile object.  For instance, there is no read of @var{vobj}
5938 in all the following cases:
5940 @smallexample
5941 int obj;
5942 volatile int vobj;
5943 vobj = @var{something};
5944 obj = vobj = @var{something};
5945 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
5946 obj = (@var{something}, vobj = @var{anotherthing});
5947 @end smallexample
5949 If you need to read the volatile object after an assignment has
5950 occurred, you must use a separate expression with an intervening
5951 sequence point.
5953 As bit-fields are not individually addressable, volatile bit-fields may
5954 be implicitly read when written to, or when adjacent bit-fields are
5955 accessed.  Bit-field operations may be optimized such that adjacent
5956 bit-fields are only partially accessed, if they straddle a storage unit
5957 boundary.  For these reasons it is unwise to use volatile bit-fields to
5958 access hardware.
5960 @node Extended Asm
5961 @section Assembler Instructions with C Expression Operands
5962 @cindex extended @code{asm}
5963 @cindex @code{asm} expressions
5964 @cindex assembler instructions
5965 @cindex registers
5967 In an assembler instruction using @code{asm}, you can specify the
5968 operands of the instruction using C expressions.  This means you need not
5969 guess which registers or memory locations contain the data you want
5970 to use.
5972 You must specify an assembler instruction template much like what
5973 appears in a machine description, plus an operand constraint string for
5974 each operand.
5976 For example, here is how to use the 68881's @code{fsinx} instruction:
5978 @smallexample
5979 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5980 @end smallexample
5982 @noindent
5983 Here @code{angle} is the C expression for the input operand while
5984 @code{result} is that of the output operand.  Each has @samp{"f"} as its
5985 operand constraint, saying that a floating-point register is required.
5986 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5987 output operands' constraints must use @samp{=}.  The constraints use the
5988 same language used in the machine description (@pxref{Constraints}).
5990 Each operand is described by an operand-constraint string followed by
5991 the C expression in parentheses.  A colon separates the assembler
5992 template from the first output operand and another separates the last
5993 output operand from the first input, if any.  Commas separate the
5994 operands within each group.  The total number of operands is currently
5995 limited to 30; this limitation may be lifted in some future version of
5996 GCC@.
5998 If there are no output operands but there are input operands, you must
5999 place two consecutive colons surrounding the place where the output
6000 operands would go.
6002 As of GCC version 3.1, it is also possible to specify input and output
6003 operands using symbolic names which can be referenced within the
6004 assembler code.  These names are specified inside square brackets
6005 preceding the constraint string, and can be referenced inside the
6006 assembler code using @code{%[@var{name}]} instead of a percentage sign
6007 followed by the operand number.  Using named operands the above example
6008 could look like:
6010 @smallexample
6011 asm ("fsinx %[angle],%[output]"
6012      : [output] "=f" (result)
6013      : [angle] "f" (angle));
6014 @end smallexample
6016 @noindent
6017 Note that the symbolic operand names have no relation whatsoever to
6018 other C identifiers.  You may use any name you like, even those of
6019 existing C symbols, but you must ensure that no two operands within the same
6020 assembler construct use the same symbolic name.
6022 Output operand expressions must be lvalues; the compiler can check this.
6023 The input operands need not be lvalues.  The compiler cannot check
6024 whether the operands have data types that are reasonable for the
6025 instruction being executed.  It does not parse the assembler instruction
6026 template and does not know what it means or even whether it is valid
6027 assembler input.  The extended @code{asm} feature is most often used for
6028 machine instructions the compiler itself does not know exist.  If
6029 the output expression cannot be directly addressed (for example, it is a
6030 bit-field), your constraint must allow a register.  In that case, GCC
6031 uses the register as the output of the @code{asm}, and then stores
6032 that register into the output.
6034 The ordinary output operands must be write-only; GCC assumes that
6035 the values in these operands before the instruction are dead and need
6036 not be generated.  Extended asm supports input-output or read-write
6037 operands.  Use the constraint character @samp{+} to indicate such an
6038 operand and list it with the output operands.
6040 You may, as an alternative, logically split its function into two
6041 separate operands, one input operand and one write-only output
6042 operand.  The connection between them is expressed by constraints
6043 that say they need to be in the same location when the instruction
6044 executes.  You can use the same C expression for both operands, or
6045 different expressions.  For example, here we write the (fictitious)
6046 @samp{combine} instruction with @code{bar} as its read-only source
6047 operand and @code{foo} as its read-write destination:
6049 @smallexample
6050 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
6051 @end smallexample
6053 @noindent
6054 The constraint @samp{"0"} for operand 1 says that it must occupy the
6055 same location as operand 0.  A number in constraint is allowed only in
6056 an input operand and it must refer to an output operand.
6058 Only a number in the constraint can guarantee that one operand is in
6059 the same place as another.  The mere fact that @code{foo} is the value
6060 of both operands is not enough to guarantee that they are in the
6061 same place in the generated assembler code.  The following does not
6062 work reliably:
6064 @smallexample
6065 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
6066 @end smallexample
6068 Various optimizations or reloading could cause operands 0 and 1 to be in
6069 different registers; GCC knows no reason not to do so.  For example, the
6070 compiler might find a copy of the value of @code{foo} in one register and
6071 use it for operand 1, but generate the output operand 0 in a different
6072 register (copying it afterward to @code{foo}'s own address).  Of course,
6073 since the register for operand 1 is not even mentioned in the assembler
6074 code, the result will not work, but GCC can't tell that.
6076 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
6077 the operand number for a matching constraint.  For example:
6079 @smallexample
6080 asm ("cmoveq %1,%2,%[result]"
6081      : [result] "=r"(result)
6082      : "r" (test), "r"(new), "[result]"(old));
6083 @end smallexample
6085 Sometimes you need to make an @code{asm} operand be a specific register,
6086 but there's no matching constraint letter for that register @emph{by
6087 itself}.  To force the operand into that register, use a local variable
6088 for the operand and specify the register in the variable declaration.
6089 @xref{Explicit Reg Vars}.  Then for the @code{asm} operand, use any
6090 register constraint letter that matches the register:
6092 @smallexample
6093 register int *p1 asm ("r0") = @dots{};
6094 register int *p2 asm ("r1") = @dots{};
6095 register int *result asm ("r0");
6096 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6097 @end smallexample
6099 @anchor{Example of asm with clobbered asm reg}
6100 In the above example, beware that a register that is call-clobbered by
6101 the target ABI will be overwritten by any function call in the
6102 assignment, including library calls for arithmetic operators.
6103 Also a register may be clobbered when generating some operations,
6104 like variable shift, memory copy or memory move on x86.
6105 Assuming it is a call-clobbered register, this may happen to @code{r0}
6106 above by the assignment to @code{p2}.  If you have to use such a
6107 register, use temporary variables for expressions between the register
6108 assignment and use:
6110 @smallexample
6111 int t1 = @dots{};
6112 register int *p1 asm ("r0") = @dots{};
6113 register int *p2 asm ("r1") = t1;
6114 register int *result asm ("r0");
6115 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6116 @end smallexample
6118 Some instructions clobber specific hard registers.  To describe this,
6119 write a third colon after the input operands, followed by the names of
6120 the clobbered hard registers (given as strings).  Here is a realistic
6121 example for the VAX:
6123 @smallexample
6124 asm volatile ("movc3 %0,%1,%2"
6125               : /* @r{no outputs} */
6126               : "g" (from), "g" (to), "g" (count)
6127               : "r0", "r1", "r2", "r3", "r4", "r5");
6128 @end smallexample
6130 You may not write a clobber description in a way that overlaps with an
6131 input or output operand.  For example, you may not have an operand
6132 describing a register class with one member if you mention that register
6133 in the clobber list.  Variables declared to live in specific registers
6134 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6135 have no part mentioned in the clobber description.
6136 There is no way for you to specify that an input
6137 operand is modified without also specifying it as an output
6138 operand.  Note that if all the output operands you specify are for this
6139 purpose (and hence unused), you then also need to specify
6140 @code{volatile} for the @code{asm} construct, as described below, to
6141 prevent GCC from deleting the @code{asm} statement as unused.
6143 If you refer to a particular hardware register from the assembler code,
6144 you probably have to list the register after the third colon to
6145 tell the compiler the register's value is modified.  In some assemblers,
6146 the register names begin with @samp{%}; to produce one @samp{%} in the
6147 assembler code, you must write @samp{%%} in the input.
6149 If your assembler instruction can alter the condition code register, add
6150 @samp{cc} to the list of clobbered registers.  GCC on some machines
6151 represents the condition codes as a specific hardware register;
6152 @samp{cc} serves to name this register.  On other machines, the
6153 condition code is handled differently, and specifying @samp{cc} has no
6154 effect.  But it is valid no matter what the machine.
6156 If your assembler instructions access memory in an unpredictable
6157 fashion, add @samp{memory} to the list of clobbered registers.  This
6158 causes GCC to not keep memory values cached in registers across the
6159 assembler instruction and not optimize stores or loads to that memory.
6160 You also should add the @code{volatile} keyword if the memory
6161 affected is not listed in the inputs or outputs of the @code{asm}, as
6162 the @samp{memory} clobber does not count as a side-effect of the
6163 @code{asm}.  If you know how large the accessed memory is, you can add
6164 it as input or output but if this is not known, you should add
6165 @samp{memory}.  As an example, if you access ten bytes of a string, you
6166 can use a memory input like:
6168 @smallexample
6169 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6170 @end smallexample
6172 Note that in the following example the memory input is necessary,
6173 otherwise GCC might optimize the store to @code{x} away:
6174 @smallexample
6175 int foo ()
6177   int x = 42;
6178   int *y = &x;
6179   int result;
6180   asm ("magic stuff accessing an 'int' pointed to by '%1'"
6181        : "=&d" (r) : "a" (y), "m" (*y));
6182   return result;
6184 @end smallexample
6186 You can put multiple assembler instructions together in a single
6187 @code{asm} template, separated by the characters normally used in assembly
6188 code for the system.  A combination that works in most places is a newline
6189 to break the line, plus a tab character to move to the instruction field
6190 (written as @samp{\n\t}).  Sometimes semicolons can be used, if the
6191 assembler allows semicolons as a line-breaking character.  Note that some
6192 assembler dialects use semicolons to start a comment.
6193 The input operands are guaranteed not to use any of the clobbered
6194 registers, and neither do the output operands' addresses, so you can
6195 read and write the clobbered registers as many times as you like.  Here
6196 is an example of multiple instructions in a template; it assumes the
6197 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6199 @smallexample
6200 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6201      : /* no outputs */
6202      : "g" (from), "g" (to)
6203      : "r9", "r10");
6204 @end smallexample
6206 Unless an output operand has the @samp{&} constraint modifier, GCC
6207 may allocate it in the same register as an unrelated input operand, on
6208 the assumption the inputs are consumed before the outputs are produced.
6209 This assumption may be false if the assembler code actually consists of
6210 more than one instruction.  In such a case, use @samp{&} for each output
6211 operand that may not overlap an input.  @xref{Modifiers}.
6213 If you want to test the condition code produced by an assembler
6214 instruction, you must include a branch and a label in the @code{asm}
6215 construct, as follows:
6217 @smallexample
6218 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6219      : "g" (result)
6220      : "g" (input));
6221 @end smallexample
6223 @noindent
6224 This assumes your assembler supports local labels, as the GNU assembler
6225 and most Unix assemblers do.
6227 Speaking of labels, jumps from one @code{asm} to another are not
6228 supported.  The compiler's optimizers do not know about these jumps, and
6229 therefore they cannot take account of them when deciding how to
6230 optimize.  @xref{Extended asm with goto}.
6232 @cindex macros containing @code{asm}
6233 Usually the most convenient way to use these @code{asm} instructions is to
6234 encapsulate them in macros that look like functions.  For example,
6236 @smallexample
6237 #define sin(x)       \
6238 (@{ double __value, __arg = (x);   \
6239    asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
6240    __value; @})
6241 @end smallexample
6243 @noindent
6244 Here the variable @code{__arg} is used to make sure that the instruction
6245 operates on a proper @code{double} value, and to accept only those
6246 arguments @code{x} that can convert automatically to a @code{double}.
6248 Another way to make sure the instruction operates on the correct data
6249 type is to use a cast in the @code{asm}.  This is different from using a
6250 variable @code{__arg} in that it converts more different types.  For
6251 example, if the desired type is @code{int}, casting the argument to
6252 @code{int} accepts a pointer with no complaint, while assigning the
6253 argument to an @code{int} variable named @code{__arg} warns about
6254 using a pointer unless the caller explicitly casts it.
6256 If an @code{asm} has output operands, GCC assumes for optimization
6257 purposes the instruction has no side effects except to change the output
6258 operands.  This does not mean instructions with a side effect cannot be
6259 used, but you must be careful, because the compiler may eliminate them
6260 if the output operands aren't used, or move them out of loops, or
6261 replace two with one if they constitute a common subexpression.  Also,
6262 if your instruction does have a side effect on a variable that otherwise
6263 appears not to change, the old value of the variable may be reused later
6264 if it happens to be found in a register.
6266 You can prevent an @code{asm} instruction from being deleted
6267 by writing the keyword @code{volatile} after
6268 the @code{asm}.  For example:
6270 @smallexample
6271 #define get_and_set_priority(new)              \
6272 (@{ int __old;                                  \
6273    asm volatile ("get_and_set_priority %0, %1" \
6274                  : "=g" (__old) : "g" (new));  \
6275    __old; @})
6276 @end smallexample
6278 @noindent
6279 The @code{volatile} keyword indicates that the instruction has
6280 important side-effects.  GCC does not delete a volatile @code{asm} if
6281 it is reachable.  (The instruction can still be deleted if GCC can
6282 prove that control flow never reaches the location of the
6283 instruction.)  Note that even a volatile @code{asm} instruction
6284 can be moved relative to other code, including across jump
6285 instructions.  For example, on many targets there is a system
6286 register that can be set to control the rounding mode of
6287 floating-point operations.  You might try
6288 setting it with a volatile @code{asm}, like this PowerPC example:
6290 @smallexample
6291        asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6292        sum = x + y;
6293 @end smallexample
6295 @noindent
6296 This does not work reliably, as the compiler may move the addition back
6297 before the volatile @code{asm}.  To make it work you need to add an
6298 artificial dependency to the @code{asm} referencing a variable in the code
6299 you don't want moved, for example:
6301 @smallexample
6302     asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6303     sum = x + y;
6304 @end smallexample
6306 Similarly, you can't expect a
6307 sequence of volatile @code{asm} instructions to remain perfectly
6308 consecutive.  If you want consecutive output, use a single @code{asm}.
6309 Also, GCC performs some optimizations across a volatile @code{asm}
6310 instruction; GCC does not ``forget everything'' when it encounters
6311 a volatile @code{asm} instruction the way some other compilers do.
6313 An @code{asm} instruction without any output operands is treated
6314 identically to a volatile @code{asm} instruction.
6316 It is a natural idea to look for a way to give access to the condition
6317 code left by the assembler instruction.  However, when we attempted to
6318 implement this, we found no way to make it work reliably.  The problem
6319 is that output operands might need reloading, which result in
6320 additional following ``store'' instructions.  On most machines, these
6321 instructions alter the condition code before there is time to
6322 test it.  This problem doesn't arise for ordinary ``test'' and
6323 ``compare'' instructions because they don't have any output operands.
6325 For reasons similar to those described above, it is not possible to give
6326 an assembler instruction access to the condition code left by previous
6327 instructions.
6329 @anchor{Extended asm with goto}
6330 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6331 jump to one or more C labels.  In this form, a fifth section after the
6332 clobber list contains a list of all C labels to which the assembly may jump.
6333 Each label operand is implicitly self-named.  The @code{asm} is also assumed
6334 to fall through to the next statement.
6336 This form of @code{asm} is restricted to not have outputs.  This is due
6337 to a internal restriction in the compiler that control transfer instructions
6338 cannot have outputs.  This restriction on @code{asm goto} may be lifted
6339 in some future version of the compiler.  In the meantime, @code{asm goto}
6340 may include a memory clobber, and so leave outputs in memory.
6342 @smallexample
6343 int frob(int x)
6345   int y;
6346   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6347             : : "r"(x), "r"(&y) : "r5", "memory" : error);
6348   return y;
6349  error:
6350   return -1;
6352 @end smallexample
6354 @noindent
6355 In this (inefficient) example, the @code{frob} instruction sets the
6356 carry bit to indicate an error.  The @code{jc} instruction detects
6357 this and branches to the @code{error} label.  Finally, the output
6358 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6359 for variable @code{y}, which is later read by the @code{return} statement.
6361 @smallexample
6362 void doit(void)
6364   int i = 0;
6365   asm goto ("mfsr %%r1, 123; jmp %%r1;"
6366             ".pushsection doit_table;"
6367             ".long %l0, %l1, %l2, %l3;"
6368             ".popsection"
6369             : : : "r1" : label1, label2, label3, label4);
6370   __builtin_unreachable ();
6372  label1:
6373   f1();
6374   return;
6375  label2:
6376   f2();
6377   return;
6378  label3:
6379   i = 1;
6380  label4:
6381   f3(i);
6383 @end smallexample
6385 @noindent
6386 In this (also inefficient) example, the @code{mfsr} instruction reads
6387 an address from some out-of-band machine register, and the following
6388 @code{jmp} instruction branches to that address.  The address read by
6389 the @code{mfsr} instruction is assumed to have been previously set via
6390 some application-specific mechanism to be one of the four values stored
6391 in the @code{doit_table} section.  Finally, the @code{asm} is followed
6392 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6393 does not in fact fall through.
6395 @smallexample
6396 #define TRACE1(NUM)                         \
6397   do @{                                      \
6398     asm goto ("0: nop;"                     \
6399               ".pushsection trace_table;"   \
6400               ".long 0b, %l0;"              \
6401               ".popsection"                 \
6402               : : : : trace#NUM);           \
6403     if (0) @{ trace#NUM: trace(); @}          \
6404   @} while (0)
6405 #define TRACE  TRACE1(__COUNTER__)
6406 @end smallexample
6408 @noindent
6409 In this example (which in fact inspired the @code{asm goto} feature)
6410 we want on rare occasions to call the @code{trace} function; on other
6411 occasions we'd like to keep the overhead to the absolute minimum.
6412 The normal code path consists of a single @code{nop} instruction.
6413 However, we record the address of this @code{nop} together with the
6414 address of a label that calls the @code{trace} function.  This allows
6415 the @code{nop} instruction to be patched at run time to be an
6416 unconditional branch to the stored label.  It is assumed that an
6417 optimizing compiler moves the labeled block out of line, to
6418 optimize the fall through path from the @code{asm}.
6420 If you are writing a header file that should be includable in ISO C
6421 programs, write @code{__asm__} instead of @code{asm}.  @xref{Alternate
6422 Keywords}.
6424 @subsection Size of an @code{asm}
6426 Some targets require that GCC track the size of each instruction used in
6427 order to generate correct code.  Because the final length of an
6428 @code{asm} is only known by the assembler, GCC must make an estimate as
6429 to how big it will be.  The estimate is formed by counting the number of
6430 statements in the pattern of the @code{asm} and multiplying that by the
6431 length of the longest instruction on that processor.  Statements in the
6432 @code{asm} are identified by newline characters and whatever statement
6433 separator characters are supported by the assembler; on most processors
6434 this is the @samp{;} character.
6436 Normally, GCC's estimate is perfectly adequate to ensure that correct
6437 code is generated, but it is possible to confuse the compiler if you use
6438 pseudo instructions or assembler macros that expand into multiple real
6439 instructions or if you use assembler directives that expand to more
6440 space in the object file than is needed for a single instruction.
6441 If this happens then the assembler produces a diagnostic saying that
6442 a label is unreachable.
6444 @subsection i386 floating-point asm operands
6446 On i386 targets, there are several rules on the usage of stack-like registers
6447 in the operands of an @code{asm}.  These rules apply only to the operands
6448 that are stack-like registers:
6450 @enumerate
6451 @item
6452 Given a set of input registers that die in an @code{asm}, it is
6453 necessary to know which are implicitly popped by the @code{asm}, and
6454 which must be explicitly popped by GCC@.
6456 An input register that is implicitly popped by the @code{asm} must be
6457 explicitly clobbered, unless it is constrained to match an
6458 output operand.
6460 @item
6461 For any input register that is implicitly popped by an @code{asm}, it is
6462 necessary to know how to adjust the stack to compensate for the pop.
6463 If any non-popped input is closer to the top of the reg-stack than
6464 the implicitly popped register, it would not be possible to know what the
6465 stack looked like---it's not clear how the rest of the stack ``slides
6466 up''.
6468 All implicitly popped input registers must be closer to the top of
6469 the reg-stack than any input that is not implicitly popped.
6471 It is possible that if an input dies in an @code{asm}, the compiler might
6472 use the input register for an output reload.  Consider this example:
6474 @smallexample
6475 asm ("foo" : "=t" (a) : "f" (b));
6476 @end smallexample
6478 @noindent
6479 This code says that input @code{b} is not popped by the @code{asm}, and that
6480 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
6481 deeper after the @code{asm} than it was before.  But, it is possible that
6482 reload may think that it can use the same register for both the input and
6483 the output.
6485 To prevent this from happening,
6486 if any input operand uses the @code{f} constraint, all output register
6487 constraints must use the @code{&} early-clobber modifier.
6489 The example above would be correctly written as:
6491 @smallexample
6492 asm ("foo" : "=&t" (a) : "f" (b));
6493 @end smallexample
6495 @item
6496 Some operands need to be in particular places on the stack.  All
6497 output operands fall in this category---GCC has no other way to
6498 know which registers the outputs appear in unless you indicate
6499 this in the constraints.
6501 Output operands must specifically indicate which register an output
6502 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
6503 constraints must select a class with a single register.
6505 @item
6506 Output operands may not be ``inserted'' between existing stack registers.
6507 Since no 387 opcode uses a read/write operand, all output operands
6508 are dead before the @code{asm}, and are pushed by the @code{asm}.
6509 It makes no sense to push anywhere but the top of the reg-stack.
6511 Output operands must start at the top of the reg-stack: output
6512 operands may not ``skip'' a register.
6514 @item
6515 Some @code{asm} statements may need extra stack space for internal
6516 calculations.  This can be guaranteed by clobbering stack registers
6517 unrelated to the inputs and outputs.
6519 @end enumerate
6521 Here are a couple of reasonable @code{asm}s to want to write.  This
6522 @code{asm}
6523 takes one input, which is internally popped, and produces two outputs.
6525 @smallexample
6526 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6527 @end smallexample
6529 @noindent
6530 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6531 and replaces them with one output.  The @code{st(1)} clobber is necessary 
6532 for the compiler to know that @code{fyl2xp1} pops both inputs.
6534 @smallexample
6535 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6536 @end smallexample
6538 @include md.texi
6540 @node Asm Labels
6541 @section Controlling Names Used in Assembler Code
6542 @cindex assembler names for identifiers
6543 @cindex names used in assembler code
6544 @cindex identifiers, names in assembler code
6546 You can specify the name to be used in the assembler code for a C
6547 function or variable by writing the @code{asm} (or @code{__asm__})
6548 keyword after the declarator as follows:
6550 @smallexample
6551 int foo asm ("myfoo") = 2;
6552 @end smallexample
6554 @noindent
6555 This specifies that the name to be used for the variable @code{foo} in
6556 the assembler code should be @samp{myfoo} rather than the usual
6557 @samp{_foo}.
6559 On systems where an underscore is normally prepended to the name of a C
6560 function or variable, this feature allows you to define names for the
6561 linker that do not start with an underscore.
6563 It does not make sense to use this feature with a non-static local
6564 variable since such variables do not have assembler names.  If you are
6565 trying to put the variable in a particular register, see @ref{Explicit
6566 Reg Vars}.  GCC presently accepts such code with a warning, but will
6567 probably be changed to issue an error, rather than a warning, in the
6568 future.
6570 You cannot use @code{asm} in this way in a function @emph{definition}; but
6571 you can get the same effect by writing a declaration for the function
6572 before its definition and putting @code{asm} there, like this:
6574 @smallexample
6575 extern func () asm ("FUNC");
6577 func (x, y)
6578      int x, y;
6579 /* @r{@dots{}} */
6580 @end smallexample
6582 It is up to you to make sure that the assembler names you choose do not
6583 conflict with any other assembler symbols.  Also, you must not use a
6584 register name; that would produce completely invalid assembler code.  GCC
6585 does not as yet have the ability to store static variables in registers.
6586 Perhaps that will be added.
6588 @node Explicit Reg Vars
6589 @section Variables in Specified Registers
6590 @cindex explicit register variables
6591 @cindex variables in specified registers
6592 @cindex specified registers
6593 @cindex registers, global allocation
6595 GNU C allows you to put a few global variables into specified hardware
6596 registers.  You can also specify the register in which an ordinary
6597 register variable should be allocated.
6599 @itemize @bullet
6600 @item
6601 Global register variables reserve registers throughout the program.
6602 This may be useful in programs such as programming language
6603 interpreters that have a couple of global variables that are accessed
6604 very often.
6606 @item
6607 Local register variables in specific registers do not reserve the
6608 registers, except at the point where they are used as input or output
6609 operands in an @code{asm} statement and the @code{asm} statement itself is
6610 not deleted.  The compiler's data flow analysis is capable of determining
6611 where the specified registers contain live values, and where they are
6612 available for other uses.  Stores into local register variables may be deleted
6613 when they appear to be dead according to dataflow analysis.  References
6614 to local register variables may be deleted or moved or simplified.
6616 These local variables are sometimes convenient for use with the extended
6617 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6618 output of the assembler instruction directly into a particular register.
6619 (This works provided the register you specify fits the constraints
6620 specified for that operand in the @code{asm}.)
6621 @end itemize
6623 @menu
6624 * Global Reg Vars::
6625 * Local Reg Vars::
6626 @end menu
6628 @node Global Reg Vars
6629 @subsection Defining Global Register Variables
6630 @cindex global register variables
6631 @cindex registers, global variables in
6633 You can define a global register variable in GNU C like this:
6635 @smallexample
6636 register int *foo asm ("a5");
6637 @end smallexample
6639 @noindent
6640 Here @code{a5} is the name of the register that should be used.  Choose a
6641 register that is normally saved and restored by function calls on your
6642 machine, so that library routines will not clobber it.
6644 Naturally the register name is cpu-dependent, so you need to
6645 conditionalize your program according to cpu type.  The register
6646 @code{a5} is a good choice on a 68000 for a variable of pointer
6647 type.  On machines with register windows, be sure to choose a ``global''
6648 register that is not affected magically by the function call mechanism.
6650 In addition, different operating systems on the same CPU may differ in how they
6651 name the registers; then you need additional conditionals.  For
6652 example, some 68000 operating systems call this register @code{%a5}.
6654 Eventually there may be a way of asking the compiler to choose a register
6655 automatically, but first we need to figure out how it should choose and
6656 how to enable you to guide the choice.  No solution is evident.
6658 Defining a global register variable in a certain register reserves that
6659 register entirely for this use, at least within the current compilation.
6660 The register is not allocated for any other purpose in the functions
6661 in the current compilation, and is not saved and restored by
6662 these functions.  Stores into this register are never deleted even if they
6663 appear to be dead, but references may be deleted or moved or
6664 simplified.
6666 It is not safe to access the global register variables from signal
6667 handlers, or from more than one thread of control, because the system
6668 library routines may temporarily use the register for other things (unless
6669 you recompile them specially for the task at hand).
6671 @cindex @code{qsort}, and global register variables
6672 It is not safe for one function that uses a global register variable to
6673 call another such function @code{foo} by way of a third function
6674 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6675 different source file in which the variable isn't declared).  This is
6676 because @code{lose} might save the register and put some other value there.
6677 For example, you can't expect a global register variable to be available in
6678 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6679 might have put something else in that register.  (If you are prepared to
6680 recompile @code{qsort} with the same global register variable, you can
6681 solve this problem.)
6683 If you want to recompile @code{qsort} or other source files that do not
6684 actually use your global register variable, so that they do not use that
6685 register for any other purpose, then it suffices to specify the compiler
6686 option @option{-ffixed-@var{reg}}.  You need not actually add a global
6687 register declaration to their source code.
6689 A function that can alter the value of a global register variable cannot
6690 safely be called from a function compiled without this variable, because it
6691 could clobber the value the caller expects to find there on return.
6692 Therefore, the function that is the entry point into the part of the
6693 program that uses the global register variable must explicitly save and
6694 restore the value that belongs to its caller.
6696 @cindex register variable after @code{longjmp}
6697 @cindex global register after @code{longjmp}
6698 @cindex value after @code{longjmp}
6699 @findex longjmp
6700 @findex setjmp
6701 On most machines, @code{longjmp} restores to each global register
6702 variable the value it had at the time of the @code{setjmp}.  On some
6703 machines, however, @code{longjmp} does not change the value of global
6704 register variables.  To be portable, the function that called @code{setjmp}
6705 should make other arrangements to save the values of the global register
6706 variables, and to restore them in a @code{longjmp}.  This way, the same
6707 thing happens regardless of what @code{longjmp} does.
6709 All global register variable declarations must precede all function
6710 definitions.  If such a declaration could appear after function
6711 definitions, the declaration would be too late to prevent the register from
6712 being used for other purposes in the preceding functions.
6714 Global register variables may not have initial values, because an
6715 executable file has no means to supply initial contents for a register.
6717 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6718 registers, but certain library functions, such as @code{getwd}, as well
6719 as the subroutines for division and remainder, modify g3 and g4.  g1 and
6720 g2 are local temporaries.
6722 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6723 Of course, it does not do to use more than a few of those.
6725 @node Local Reg Vars
6726 @subsection Specifying Registers for Local Variables
6727 @cindex local variables, specifying registers
6728 @cindex specifying registers for local variables
6729 @cindex registers for local variables
6731 You can define a local register variable with a specified register
6732 like this:
6734 @smallexample
6735 register int *foo asm ("a5");
6736 @end smallexample
6738 @noindent
6739 Here @code{a5} is the name of the register that should be used.  Note
6740 that this is the same syntax used for defining global register
6741 variables, but for a local variable it appears within a function.
6743 Naturally the register name is cpu-dependent, but this is not a
6744 problem, since specific registers are most often useful with explicit
6745 assembler instructions (@pxref{Extended Asm}).  Both of these things
6746 generally require that you conditionalize your program according to
6747 cpu type.
6749 In addition, operating systems on one type of cpu may differ in how they
6750 name the registers; then you need additional conditionals.  For
6751 example, some 68000 operating systems call this register @code{%a5}.
6753 Defining such a register variable does not reserve the register; it
6754 remains available for other uses in places where flow control determines
6755 the variable's value is not live.
6757 This option does not guarantee that GCC generates code that has
6758 this variable in the register you specify at all times.  You may not
6759 code an explicit reference to this register in the @emph{assembler
6760 instruction template} part of an @code{asm} statement and assume it
6761 always refers to this variable.  However, using the variable as an
6762 @code{asm} @emph{operand} guarantees that the specified register is used
6763 for the operand.
6765 Stores into local register variables may be deleted when they appear to be dead
6766 according to dataflow analysis.  References to local register variables may
6767 be deleted or moved or simplified.
6769 As for global register variables, it's recommended that you choose a
6770 register that is normally saved and restored by function calls on
6771 your machine, so that library routines will not clobber it.  A common
6772 pitfall is to initialize multiple call-clobbered registers with
6773 arbitrary expressions, where a function call or library call for an
6774 arithmetic operator overwrites a register value from a previous
6775 assignment, for example @code{r0} below:
6776 @smallexample
6777 register int *p1 asm ("r0") = @dots{};
6778 register int *p2 asm ("r1") = @dots{};
6779 @end smallexample
6781 @noindent
6782 In those cases, a solution is to use a temporary variable for
6783 each arbitrary expression.   @xref{Example of asm with clobbered asm reg}.
6785 @node Alternate Keywords
6786 @section Alternate Keywords
6787 @cindex alternate keywords
6788 @cindex keywords, alternate
6790 @option{-ansi} and the various @option{-std} options disable certain
6791 keywords.  This causes trouble when you want to use GNU C extensions, or
6792 a general-purpose header file that should be usable by all programs,
6793 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
6794 @code{inline} are not available in programs compiled with
6795 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6796 program compiled with @option{-std=c99} or @option{-std=c11}).  The
6797 ISO C99 keyword
6798 @code{restrict} is only available when @option{-std=gnu99} (which will
6799 eventually be the default) or @option{-std=c99} (or the equivalent
6800 @option{-std=iso9899:1999}), or an option for a later standard
6801 version, is used.
6803 The way to solve these problems is to put @samp{__} at the beginning and
6804 end of each problematical keyword.  For example, use @code{__asm__}
6805 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6807 Other C compilers won't accept these alternative keywords; if you want to
6808 compile with another compiler, you can define the alternate keywords as
6809 macros to replace them with the customary keywords.  It looks like this:
6811 @smallexample
6812 #ifndef __GNUC__
6813 #define __asm__ asm
6814 #endif
6815 @end smallexample
6817 @findex __extension__
6818 @opindex pedantic
6819 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6820 You can
6821 prevent such warnings within one expression by writing
6822 @code{__extension__} before the expression.  @code{__extension__} has no
6823 effect aside from this.
6825 @node Incomplete Enums
6826 @section Incomplete @code{enum} Types
6828 You can define an @code{enum} tag without specifying its possible values.
6829 This results in an incomplete type, much like what you get if you write
6830 @code{struct foo} without describing the elements.  A later declaration
6831 that does specify the possible values completes the type.
6833 You can't allocate variables or storage using the type while it is
6834 incomplete.  However, you can work with pointers to that type.
6836 This extension may not be very useful, but it makes the handling of
6837 @code{enum} more consistent with the way @code{struct} and @code{union}
6838 are handled.
6840 This extension is not supported by GNU C++.
6842 @node Function Names
6843 @section Function Names as Strings
6844 @cindex @code{__func__} identifier
6845 @cindex @code{__FUNCTION__} identifier
6846 @cindex @code{__PRETTY_FUNCTION__} identifier
6848 GCC provides three magic variables that hold the name of the current
6849 function, as a string.  The first of these is @code{__func__}, which
6850 is part of the C99 standard:
6852 The identifier @code{__func__} is implicitly declared by the translator
6853 as if, immediately following the opening brace of each function
6854 definition, the declaration
6856 @smallexample
6857 static const char __func__[] = "function-name";
6858 @end smallexample
6860 @noindent
6861 appeared, where function-name is the name of the lexically-enclosing
6862 function.  This name is the unadorned name of the function.
6864 @code{__FUNCTION__} is another name for @code{__func__}.  Older
6865 versions of GCC recognize only this name.  However, it is not
6866 standardized.  For maximum portability, we recommend you use
6867 @code{__func__}, but provide a fallback definition with the
6868 preprocessor:
6870 @smallexample
6871 #if __STDC_VERSION__ < 199901L
6872 # if __GNUC__ >= 2
6873 #  define __func__ __FUNCTION__
6874 # else
6875 #  define __func__ "<unknown>"
6876 # endif
6877 #endif
6878 @end smallexample
6880 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6881 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
6882 the type signature of the function as well as its bare name.  For
6883 example, this program:
6885 @smallexample
6886 extern "C" @{
6887 extern int printf (char *, ...);
6890 class a @{
6891  public:
6892   void sub (int i)
6893     @{
6894       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6895       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6896     @}
6900 main (void)
6902   a ax;
6903   ax.sub (0);
6904   return 0;
6906 @end smallexample
6908 @noindent
6909 gives this output:
6911 @smallexample
6912 __FUNCTION__ = sub
6913 __PRETTY_FUNCTION__ = void a::sub(int)
6914 @end smallexample
6916 These identifiers are not preprocessor macros.  In GCC 3.3 and
6917 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6918 were treated as string literals; they could be used to initialize
6919 @code{char} arrays, and they could be concatenated with other string
6920 literals.  GCC 3.4 and later treat them as variables, like
6921 @code{__func__}.  In C++, @code{__FUNCTION__} and
6922 @code{__PRETTY_FUNCTION__} have always been variables.
6924 @node Return Address
6925 @section Getting the Return or Frame Address of a Function
6927 These functions may be used to get information about the callers of a
6928 function.
6930 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6931 This function returns the return address of the current function, or of
6932 one of its callers.  The @var{level} argument is number of frames to
6933 scan up the call stack.  A value of @code{0} yields the return address
6934 of the current function, a value of @code{1} yields the return address
6935 of the caller of the current function, and so forth.  When inlining
6936 the expected behavior is that the function returns the address of
6937 the function that is returned to.  To work around this behavior use
6938 the @code{noinline} function attribute.
6940 The @var{level} argument must be a constant integer.
6942 On some machines it may be impossible to determine the return address of
6943 any function other than the current one; in such cases, or when the top
6944 of the stack has been reached, this function returns @code{0} or a
6945 random value.  In addition, @code{__builtin_frame_address} may be used
6946 to determine if the top of the stack has been reached.
6948 Additional post-processing of the returned value may be needed, see
6949 @code{__builtin_extract_return_addr}.
6951 This function should only be used with a nonzero argument for debugging
6952 purposes.
6953 @end deftypefn
6955 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
6956 The address as returned by @code{__builtin_return_address} may have to be fed
6957 through this function to get the actual encoded address.  For example, on the
6958 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6959 platforms an offset has to be added for the true next instruction to be
6960 executed.
6962 If no fixup is needed, this function simply passes through @var{addr}.
6963 @end deftypefn
6965 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6966 This function does the reverse of @code{__builtin_extract_return_addr}.
6967 @end deftypefn
6969 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6970 This function is similar to @code{__builtin_return_address}, but it
6971 returns the address of the function frame rather than the return address
6972 of the function.  Calling @code{__builtin_frame_address} with a value of
6973 @code{0} yields the frame address of the current function, a value of
6974 @code{1} yields the frame address of the caller of the current function,
6975 and so forth.
6977 The frame is the area on the stack that holds local variables and saved
6978 registers.  The frame address is normally the address of the first word
6979 pushed on to the stack by the function.  However, the exact definition
6980 depends upon the processor and the calling convention.  If the processor
6981 has a dedicated frame pointer register, and the function has a frame,
6982 then @code{__builtin_frame_address} returns the value of the frame
6983 pointer register.
6985 On some machines it may be impossible to determine the frame address of
6986 any function other than the current one; in such cases, or when the top
6987 of the stack has been reached, this function returns @code{0} if
6988 the first frame pointer is properly initialized by the startup code.
6990 This function should only be used with a nonzero argument for debugging
6991 purposes.
6992 @end deftypefn
6994 @node Vector Extensions
6995 @section Using Vector Instructions through Built-in Functions
6997 On some targets, the instruction set contains SIMD vector instructions which
6998 operate on multiple values contained in one large register at the same time.
6999 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7000 this way.
7002 The first step in using these extensions is to provide the necessary data
7003 types.  This should be done using an appropriate @code{typedef}:
7005 @smallexample
7006 typedef int v4si __attribute__ ((vector_size (16)));
7007 @end smallexample
7009 @noindent
7010 The @code{int} type specifies the base type, while the attribute specifies
7011 the vector size for the variable, measured in bytes.  For example, the
7012 declaration above causes the compiler to set the mode for the @code{v4si}
7013 type to be 16 bytes wide and divided into @code{int} sized units.  For
7014 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7015 corresponding mode of @code{foo} is @acronym{V4SI}.
7017 The @code{vector_size} attribute is only applicable to integral and
7018 float scalars, although arrays, pointers, and function return values
7019 are allowed in conjunction with this construct. Only sizes that are
7020 a power of two are currently allowed.
7022 All the basic integer types can be used as base types, both as signed
7023 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7024 @code{long long}.  In addition, @code{float} and @code{double} can be
7025 used to build floating-point vector types.
7027 Specifying a combination that is not valid for the current architecture
7028 causes GCC to synthesize the instructions using a narrower mode.
7029 For example, if you specify a variable of type @code{V4SI} and your
7030 architecture does not allow for this specific SIMD type, GCC
7031 produces code that uses 4 @code{SIs}.
7033 The types defined in this manner can be used with a subset of normal C
7034 operations.  Currently, GCC allows using the following operators
7035 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7037 The operations behave like C++ @code{valarrays}.  Addition is defined as
7038 the addition of the corresponding elements of the operands.  For
7039 example, in the code below, each of the 4 elements in @var{a} is
7040 added to the corresponding 4 elements in @var{b} and the resulting
7041 vector is stored in @var{c}.
7043 @smallexample
7044 typedef int v4si __attribute__ ((vector_size (16)));
7046 v4si a, b, c;
7048 c = a + b;
7049 @end smallexample
7051 Subtraction, multiplication, division, and the logical operations
7052 operate in a similar manner.  Likewise, the result of using the unary
7053 minus or complement operators on a vector type is a vector whose
7054 elements are the negative or complemented values of the corresponding
7055 elements in the operand.
7057 It is possible to use shifting operators @code{<<}, @code{>>} on
7058 integer-type vectors. The operation is defined as following: @code{@{a0,
7059 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7060 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7061 elements. 
7063 For convenience, it is allowed to use a binary vector operation
7064 where one operand is a scalar. In that case the compiler transforms
7065 the scalar operand into a vector where each element is the scalar from
7066 the operation. The transformation happens only if the scalar could be
7067 safely converted to the vector-element type.
7068 Consider the following code.
7070 @smallexample
7071 typedef int v4si __attribute__ ((vector_size (16)));
7073 v4si a, b, c;
7074 long l;
7076 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7077 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7079 a = l + a;    /* Error, cannot convert long to int. */
7080 @end smallexample
7082 Vectors can be subscripted as if the vector were an array with
7083 the same number of elements and base type.  Out of bound accesses
7084 invoke undefined behavior at run time.  Warnings for out of bound
7085 accesses for vector subscription can be enabled with
7086 @option{-Warray-bounds}.
7088 Vector comparison is supported with standard comparison
7089 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7090 vector expressions of integer-type or real-type. Comparison between
7091 integer-type vectors and real-type vectors are not supported.  The
7092 result of the comparison is a vector of the same width and number of
7093 elements as the comparison operands with a signed integral element
7094 type.
7096 Vectors are compared element-wise producing 0 when comparison is false
7097 and -1 (constant of the appropriate type where all bits are set)
7098 otherwise. Consider the following example.
7100 @smallexample
7101 typedef int v4si __attribute__ ((vector_size (16)));
7103 v4si a = @{1,2,3,4@};
7104 v4si b = @{3,2,1,4@};
7105 v4si c;
7107 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7108 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7109 @end smallexample
7111 Vector shuffling is available using functions
7112 @code{__builtin_shuffle (vec, mask)} and
7113 @code{__builtin_shuffle (vec0, vec1, mask)}.
7114 Both functions construct a permutation of elements from one or two
7115 vectors and return a vector of the same type as the input vector(s).
7116 The @var{mask} is an integral vector with the same width (@var{W})
7117 and element count (@var{N}) as the output vector.
7119 The elements of the input vectors are numbered in memory ordering of
7120 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
7121 elements of @var{mask} are considered modulo @var{N} in the single-operand
7122 case and modulo @math{2*@var{N}} in the two-operand case.
7124 Consider the following example,
7126 @smallexample
7127 typedef int v4si __attribute__ ((vector_size (16)));
7129 v4si a = @{1,2,3,4@};
7130 v4si b = @{5,6,7,8@};
7131 v4si mask1 = @{0,1,1,3@};
7132 v4si mask2 = @{0,4,2,5@};
7133 v4si res;
7135 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
7136 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
7137 @end smallexample
7139 Note that @code{__builtin_shuffle} is intentionally semantically
7140 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7142 You can declare variables and use them in function calls and returns, as
7143 well as in assignments and some casts.  You can specify a vector type as
7144 a return type for a function.  Vector types can also be used as function
7145 arguments.  It is possible to cast from one vector type to another,
7146 provided they are of the same size (in fact, you can also cast vectors
7147 to and from other datatypes of the same size).
7149 You cannot operate between vectors of different lengths or different
7150 signedness without a cast.
7152 @node Offsetof
7153 @section Offsetof
7154 @findex __builtin_offsetof
7156 GCC implements for both C and C++ a syntactic extension to implement
7157 the @code{offsetof} macro.
7159 @smallexample
7160 primary:
7161         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7163 offsetof_member_designator:
7164           @code{identifier}
7165         | offsetof_member_designator "." @code{identifier}
7166         | offsetof_member_designator "[" @code{expr} "]"
7167 @end smallexample
7169 This extension is sufficient such that
7171 @smallexample
7172 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
7173 @end smallexample
7175 @noindent
7176 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
7177 may be dependent.  In either case, @var{member} may consist of a single
7178 identifier, or a sequence of member accesses and array references.
7180 @node __sync Builtins
7181 @section Legacy __sync Built-in Functions for Atomic Memory Access
7183 The following built-in functions
7184 are intended to be compatible with those described
7185 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7186 section 7.4.  As such, they depart from the normal GCC practice of using
7187 the @samp{__builtin_} prefix, and further that they are overloaded such that
7188 they work on multiple types.
7190 The definition given in the Intel documentation allows only for the use of
7191 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7192 counterparts.  GCC allows any integral scalar or pointer type that is
7193 1, 2, 4 or 8 bytes in length.
7195 Not all operations are supported by all target processors.  If a particular
7196 operation cannot be implemented on the target processor, a warning is
7197 generated and a call an external function is generated.  The external
7198 function carries the same name as the built-in version,
7199 with an additional suffix
7200 @samp{_@var{n}} where @var{n} is the size of the data type.
7202 @c ??? Should we have a mechanism to suppress this warning?  This is almost
7203 @c useful for implementing the operation under the control of an external
7204 @c mutex.
7206 In most cases, these built-in functions are considered a @dfn{full barrier}.
7207 That is,
7208 no memory operand is moved across the operation, either forward or
7209 backward.  Further, instructions are issued as necessary to prevent the
7210 processor from speculating loads across the operation and from queuing stores
7211 after the operation.
7213 All of the routines are described in the Intel documentation to take
7214 ``an optional list of variables protected by the memory barrier''.  It's
7215 not clear what is meant by that; it could mean that @emph{only} the
7216 following variables are protected, or it could mean that these variables
7217 should in addition be protected.  At present GCC ignores this list and
7218 protects all variables that are globally accessible.  If in the future
7219 we make some use of this list, an empty list will continue to mean all
7220 globally accessible variables.
7222 @table @code
7223 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7224 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7225 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7226 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7227 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7228 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7229 @findex __sync_fetch_and_add
7230 @findex __sync_fetch_and_sub
7231 @findex __sync_fetch_and_or
7232 @findex __sync_fetch_and_and
7233 @findex __sync_fetch_and_xor
7234 @findex __sync_fetch_and_nand
7235 These built-in functions perform the operation suggested by the name, and
7236 returns the value that had previously been in memory.  That is,
7238 @smallexample
7239 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7240 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
7241 @end smallexample
7243 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7244 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7246 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7247 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7248 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7249 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7250 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7251 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7252 @findex __sync_add_and_fetch
7253 @findex __sync_sub_and_fetch
7254 @findex __sync_or_and_fetch
7255 @findex __sync_and_and_fetch
7256 @findex __sync_xor_and_fetch
7257 @findex __sync_nand_and_fetch
7258 These built-in functions perform the operation suggested by the name, and
7259 return the new value.  That is,
7261 @smallexample
7262 @{ *ptr @var{op}= value; return *ptr; @}
7263 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
7264 @end smallexample
7266 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7267 as @code{*ptr = ~(*ptr & value)} instead of
7268 @code{*ptr = ~*ptr & value}.
7270 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7271 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7272 @findex __sync_bool_compare_and_swap
7273 @findex __sync_val_compare_and_swap
7274 These built-in functions perform an atomic compare and swap.
7275 That is, if the current
7276 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7277 @code{*@var{ptr}}.
7279 The ``bool'' version returns true if the comparison is successful and
7280 @var{newval} is written.  The ``val'' version returns the contents
7281 of @code{*@var{ptr}} before the operation.
7283 @item __sync_synchronize (...)
7284 @findex __sync_synchronize
7285 This built-in function issues a full memory barrier.
7287 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7288 @findex __sync_lock_test_and_set
7289 This built-in function, as described by Intel, is not a traditional test-and-set
7290 operation, but rather an atomic exchange operation.  It writes @var{value}
7291 into @code{*@var{ptr}}, and returns the previous contents of
7292 @code{*@var{ptr}}.
7294 Many targets have only minimal support for such locks, and do not support
7295 a full exchange operation.  In this case, a target may support reduced
7296 functionality here by which the @emph{only} valid value to store is the
7297 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
7298 is implementation defined.
7300 This built-in function is not a full barrier,
7301 but rather an @dfn{acquire barrier}.
7302 This means that references after the operation cannot move to (or be
7303 speculated to) before the operation, but previous memory stores may not
7304 be globally visible yet, and previous memory loads may not yet be
7305 satisfied.
7307 @item void __sync_lock_release (@var{type} *ptr, ...)
7308 @findex __sync_lock_release
7309 This built-in function releases the lock acquired by
7310 @code{__sync_lock_test_and_set}.
7311 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7313 This built-in function is not a full barrier,
7314 but rather a @dfn{release barrier}.
7315 This means that all previous memory stores are globally visible, and all
7316 previous memory loads have been satisfied, but following memory reads
7317 are not prevented from being speculated to before the barrier.
7318 @end table
7320 @node __atomic Builtins
7321 @section Built-in functions for memory model aware atomic operations
7323 The following built-in functions approximately match the requirements for
7324 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7325 functions, but all also have a memory model parameter.  These are all
7326 identified by being prefixed with @samp{__atomic}, and most are overloaded
7327 such that they work with multiple types.
7329 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7330 bytes in length. 16-byte integral types are also allowed if
7331 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7333 Target architectures are encouraged to provide their own patterns for
7334 each of these built-in functions.  If no target is provided, the original 
7335 non-memory model set of @samp{__sync} atomic built-in functions are
7336 utilized, along with any required synchronization fences surrounding it in
7337 order to achieve the proper behavior.  Execution in this case is subject
7338 to the same restrictions as those built-in functions.
7340 If there is no pattern or mechanism to provide a lock free instruction
7341 sequence, a call is made to an external routine with the same parameters
7342 to be resolved at run time.
7344 The four non-arithmetic functions (load, store, exchange, and 
7345 compare_exchange) all have a generic version as well.  This generic
7346 version works on any data type.  If the data type size maps to one
7347 of the integral sizes that may have lock free support, the generic
7348 version utilizes the lock free built-in function.  Otherwise an
7349 external call is left to be resolved at run time.  This external call is
7350 the same format with the addition of a @samp{size_t} parameter inserted
7351 as the first parameter indicating the size of the object being pointed to.
7352 All objects must be the same size.
7354 There are 6 different memory models that can be specified.  These map
7355 to the same names in the C++11 standard.  Refer there or to the
7356 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7357 atomic synchronization} for more detailed definitions.  These memory
7358 models integrate both barriers to code motion as well as synchronization
7359 requirements with other threads. These are listed in approximately
7360 ascending order of strength. It is also possible to use target specific
7361 flags for memory model flags, like Hardware Lock Elision.
7363 @table  @code
7364 @item __ATOMIC_RELAXED
7365 No barriers or synchronization.
7366 @item __ATOMIC_CONSUME
7367 Data dependency only for both barrier and synchronization with another
7368 thread.
7369 @item __ATOMIC_ACQUIRE
7370 Barrier to hoisting of code and synchronizes with release (or stronger)
7371 semantic stores from another thread.
7372 @item __ATOMIC_RELEASE
7373 Barrier to sinking of code and synchronizes with acquire (or stronger)
7374 semantic loads from another thread.
7375 @item __ATOMIC_ACQ_REL
7376 Full barrier in both directions and synchronizes with acquire loads and
7377 release stores in another thread.
7378 @item __ATOMIC_SEQ_CST
7379 Full barrier in both directions and synchronizes with acquire loads and
7380 release stores in all threads.
7381 @end table
7383 When implementing patterns for these built-in functions, the memory model
7384 parameter can be ignored as long as the pattern implements the most
7385 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
7386 execute correctly with this memory model but they may not execute as
7387 efficiently as they could with a more appropriate implementation of the
7388 relaxed requirements.
7390 Note that the C++11 standard allows for the memory model parameter to be
7391 determined at run time rather than at compile time.  These built-in
7392 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7393 than invoke a runtime library call or inline a switch statement.  This is
7394 standard compliant, safe, and the simplest approach for now.
7396 The memory model parameter is a signed int, but only the lower 8 bits are
7397 reserved for the memory model.  The remainder of the signed int is reserved
7398 for future use and should be 0.  Use of the predefined atomic values
7399 ensures proper usage.
7401 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7402 This built-in function implements an atomic load operation.  It returns the
7403 contents of @code{*@var{ptr}}.
7405 The valid memory model variants are
7406 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7407 and @code{__ATOMIC_CONSUME}.
7409 @end deftypefn
7411 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7412 This is the generic version of an atomic load.  It returns the
7413 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7415 @end deftypefn
7417 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7418 This built-in function implements an atomic store operation.  It writes 
7419 @code{@var{val}} into @code{*@var{ptr}}.  
7421 The valid memory model variants are
7422 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7424 @end deftypefn
7426 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7427 This is the generic version of an atomic store.  It stores the value
7428 of @code{*@var{val}} into @code{*@var{ptr}}.
7430 @end deftypefn
7432 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7433 This built-in function implements an atomic exchange operation.  It writes
7434 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7435 @code{*@var{ptr}}.
7437 The valid memory model variants are
7438 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7439 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7441 @end deftypefn
7443 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7444 This is the generic version of an atomic exchange.  It stores the
7445 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7446 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7448 @end deftypefn
7450 @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)
7451 This built-in function implements an atomic compare and exchange operation.
7452 This compares the contents of @code{*@var{ptr}} with the contents of
7453 @code{*@var{expected}} and if equal, writes @var{desired} into
7454 @code{*@var{ptr}}.  If they are not equal, the current contents of
7455 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
7456 for weak compare_exchange, and false for the strong variation.  Many targets 
7457 only offer the strong variation and ignore the parameter.  When in doubt, use
7458 the strong variation.
7460 True is returned if @var{desired} is written into
7461 @code{*@var{ptr}} and the execution is considered to conform to the
7462 memory model specified by @var{success_memmodel}.  There are no
7463 restrictions on what memory model can be used here.
7465 False is returned otherwise, and the execution is considered to conform
7466 to @var{failure_memmodel}. This memory model cannot be
7467 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
7468 stronger model than that specified by @var{success_memmodel}.
7470 @end deftypefn
7472 @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)
7473 This built-in function implements the generic version of
7474 @code{__atomic_compare_exchange}.  The function is virtually identical to
7475 @code{__atomic_compare_exchange_n}, except the desired value is also a
7476 pointer.
7478 @end deftypefn
7480 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7481 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7482 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7483 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7484 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7485 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7486 These built-in functions perform the operation suggested by the name, and
7487 return the result of the operation. That is,
7489 @smallexample
7490 @{ *ptr @var{op}= val; return *ptr; @}
7491 @end smallexample
7493 All memory models are valid.
7495 @end deftypefn
7497 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7498 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7499 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7500 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7501 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7502 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7503 These built-in functions perform the operation suggested by the name, and
7504 return the value that had previously been in @code{*@var{ptr}}.  That is,
7506 @smallexample
7507 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7508 @end smallexample
7510 All memory models are valid.
7512 @end deftypefn
7514 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7516 This built-in function performs an atomic test-and-set operation on
7517 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
7518 defined nonzero ``set'' value and the return value is @code{true} if and only
7519 if the previous contents were ``set''.
7520 It should be only used for operands of type @code{bool} or @code{char}. For 
7521 other types only part of the value may be set.
7523 All memory models are valid.
7525 @end deftypefn
7527 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7529 This built-in function performs an atomic clear operation on
7530 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
7531 It should be only used for operands of type @code{bool} or @code{char} and 
7532 in conjunction with @code{__atomic_test_and_set}.
7533 For other types it may only clear partially. If the type is not @code{bool}
7534 prefer using @code{__atomic_store}.
7536 The valid memory model variants are
7537 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7538 @code{__ATOMIC_RELEASE}.
7540 @end deftypefn
7542 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7544 This built-in function acts as a synchronization fence between threads
7545 based on the specified memory model.
7547 All memory orders are valid.
7549 @end deftypefn
7551 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7553 This built-in function acts as a synchronization fence between a thread
7554 and signal handlers based in the same thread.
7556 All memory orders are valid.
7558 @end deftypefn
7560 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
7562 This built-in function returns true if objects of @var{size} bytes always
7563 generate lock free atomic instructions for the target architecture.  
7564 @var{size} must resolve to a compile-time constant and the result also
7565 resolves to a compile-time constant.
7567 @var{ptr} is an optional pointer to the object that may be used to determine
7568 alignment.  A value of 0 indicates typical alignment should be used.  The 
7569 compiler may also ignore this parameter.
7571 @smallexample
7572 if (_atomic_always_lock_free (sizeof (long long), 0))
7573 @end smallexample
7575 @end deftypefn
7577 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7579 This built-in function returns true if objects of @var{size} bytes always
7580 generate lock free atomic instructions for the target architecture.  If
7581 it is not known to be lock free a call is made to a runtime routine named
7582 @code{__atomic_is_lock_free}.
7584 @var{ptr} is an optional pointer to the object that may be used to determine
7585 alignment.  A value of 0 indicates typical alignment should be used.  The 
7586 compiler may also ignore this parameter.
7587 @end deftypefn
7589 @node x86 specific memory model extensions for transactional memory
7590 @section x86 specific memory model extensions for transactional memory
7592 The i386 architecture supports additional memory ordering flags
7593 to mark lock critical sections for hardware lock elision. 
7594 These must be specified in addition to an existing memory model to 
7595 atomic intrinsics.
7597 @table @code
7598 @item __ATOMIC_HLE_ACQUIRE
7599 Start lock elision on a lock variable.
7600 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
7601 @item __ATOMIC_HLE_RELEASE
7602 End lock elision on a lock variable.
7603 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
7604 @end table
7606 When a lock acquire fails it is required for good performance to abort
7607 the transaction quickly. This can be done with a @code{_mm_pause}
7609 @smallexample
7610 #include <immintrin.h> // For _mm_pause
7612 int lockvar;
7614 /* Acquire lock with lock elision */
7615 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
7616     _mm_pause(); /* Abort failed transaction */
7618 /* Free lock with lock elision */
7619 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
7620 @end smallexample
7622 @node Object Size Checking
7623 @section Object Size Checking Built-in Functions
7624 @findex __builtin_object_size
7625 @findex __builtin___memcpy_chk
7626 @findex __builtin___mempcpy_chk
7627 @findex __builtin___memmove_chk
7628 @findex __builtin___memset_chk
7629 @findex __builtin___strcpy_chk
7630 @findex __builtin___stpcpy_chk
7631 @findex __builtin___strncpy_chk
7632 @findex __builtin___strcat_chk
7633 @findex __builtin___strncat_chk
7634 @findex __builtin___sprintf_chk
7635 @findex __builtin___snprintf_chk
7636 @findex __builtin___vsprintf_chk
7637 @findex __builtin___vsnprintf_chk
7638 @findex __builtin___printf_chk
7639 @findex __builtin___vprintf_chk
7640 @findex __builtin___fprintf_chk
7641 @findex __builtin___vfprintf_chk
7643 GCC implements a limited buffer overflow protection mechanism
7644 that can prevent some buffer overflow attacks.
7646 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7647 is a built-in construct that returns a constant number of bytes from
7648 @var{ptr} to the end of the object @var{ptr} pointer points to
7649 (if known at compile time).  @code{__builtin_object_size} never evaluates
7650 its arguments for side-effects.  If there are any side-effects in them, it
7651 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7652 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
7653 point to and all of them are known at compile time, the returned number
7654 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7655 0 and minimum if nonzero.  If it is not possible to determine which objects
7656 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7657 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7658 for @var{type} 2 or 3.
7660 @var{type} is an integer constant from 0 to 3.  If the least significant
7661 bit is clear, objects are whole variables, if it is set, a closest
7662 surrounding subobject is considered the object a pointer points to.
7663 The second bit determines if maximum or minimum of remaining bytes
7664 is computed.
7666 @smallexample
7667 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7668 char *p = &var.buf1[1], *q = &var.b;
7670 /* Here the object p points to is var.  */
7671 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7672 /* The subobject p points to is var.buf1.  */
7673 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7674 /* The object q points to is var.  */
7675 assert (__builtin_object_size (q, 0)
7676         == (char *) (&var + 1) - (char *) &var.b);
7677 /* The subobject q points to is var.b.  */
7678 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7679 @end smallexample
7680 @end deftypefn
7682 There are built-in functions added for many common string operation
7683 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7684 built-in is provided.  This built-in has an additional last argument,
7685 which is the number of bytes remaining in object the @var{dest}
7686 argument points to or @code{(size_t) -1} if the size is not known.
7688 The built-in functions are optimized into the normal string functions
7689 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7690 it is known at compile time that the destination object will not
7691 be overflown.  If the compiler can determine at compile time the
7692 object will be always overflown, it issues a warning.
7694 The intended use can be e.g.@:
7696 @smallexample
7697 #undef memcpy
7698 #define bos0(dest) __builtin_object_size (dest, 0)
7699 #define memcpy(dest, src, n) \
7700   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7702 char *volatile p;
7703 char buf[10];
7704 /* It is unknown what object p points to, so this is optimized
7705    into plain memcpy - no checking is possible.  */
7706 memcpy (p, "abcde", n);
7707 /* Destination is known and length too.  It is known at compile
7708    time there will be no overflow.  */
7709 memcpy (&buf[5], "abcde", 5);
7710 /* Destination is known, but the length is not known at compile time.
7711    This will result in __memcpy_chk call that can check for overflow
7712    at run time.  */
7713 memcpy (&buf[5], "abcde", n);
7714 /* Destination is known and it is known at compile time there will
7715    be overflow.  There will be a warning and __memcpy_chk call that
7716    will abort the program at run time.  */
7717 memcpy (&buf[6], "abcde", 5);
7718 @end smallexample
7720 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7721 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7722 @code{strcat} and @code{strncat}.
7724 There are also checking built-in functions for formatted output functions.
7725 @smallexample
7726 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7727 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7728                               const char *fmt, ...);
7729 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7730                               va_list ap);
7731 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7732                                const char *fmt, va_list ap);
7733 @end smallexample
7735 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7736 etc.@: functions and can contain implementation specific flags on what
7737 additional security measures the checking function might take, such as
7738 handling @code{%n} differently.
7740 The @var{os} argument is the object size @var{s} points to, like in the
7741 other built-in functions.  There is a small difference in the behavior
7742 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7743 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7744 the checking function is called with @var{os} argument set to
7745 @code{(size_t) -1}.
7747 In addition to this, there are checking built-in functions
7748 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7749 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7750 These have just one additional argument, @var{flag}, right before
7751 format string @var{fmt}.  If the compiler is able to optimize them to
7752 @code{fputc} etc.@: functions, it does, otherwise the checking function
7753 is called and the @var{flag} argument passed to it.
7755 @node Other Builtins
7756 @section Other Built-in Functions Provided by GCC
7757 @cindex built-in functions
7758 @findex __builtin_fpclassify
7759 @findex __builtin_isfinite
7760 @findex __builtin_isnormal
7761 @findex __builtin_isgreater
7762 @findex __builtin_isgreaterequal
7763 @findex __builtin_isinf_sign
7764 @findex __builtin_isless
7765 @findex __builtin_islessequal
7766 @findex __builtin_islessgreater
7767 @findex __builtin_isunordered
7768 @findex __builtin_powi
7769 @findex __builtin_powif
7770 @findex __builtin_powil
7771 @findex _Exit
7772 @findex _exit
7773 @findex abort
7774 @findex abs
7775 @findex acos
7776 @findex acosf
7777 @findex acosh
7778 @findex acoshf
7779 @findex acoshl
7780 @findex acosl
7781 @findex alloca
7782 @findex asin
7783 @findex asinf
7784 @findex asinh
7785 @findex asinhf
7786 @findex asinhl
7787 @findex asinl
7788 @findex atan
7789 @findex atan2
7790 @findex atan2f
7791 @findex atan2l
7792 @findex atanf
7793 @findex atanh
7794 @findex atanhf
7795 @findex atanhl
7796 @findex atanl
7797 @findex bcmp
7798 @findex bzero
7799 @findex cabs
7800 @findex cabsf
7801 @findex cabsl
7802 @findex cacos
7803 @findex cacosf
7804 @findex cacosh
7805 @findex cacoshf
7806 @findex cacoshl
7807 @findex cacosl
7808 @findex calloc
7809 @findex carg
7810 @findex cargf
7811 @findex cargl
7812 @findex casin
7813 @findex casinf
7814 @findex casinh
7815 @findex casinhf
7816 @findex casinhl
7817 @findex casinl
7818 @findex catan
7819 @findex catanf
7820 @findex catanh
7821 @findex catanhf
7822 @findex catanhl
7823 @findex catanl
7824 @findex cbrt
7825 @findex cbrtf
7826 @findex cbrtl
7827 @findex ccos
7828 @findex ccosf
7829 @findex ccosh
7830 @findex ccoshf
7831 @findex ccoshl
7832 @findex ccosl
7833 @findex ceil
7834 @findex ceilf
7835 @findex ceill
7836 @findex cexp
7837 @findex cexpf
7838 @findex cexpl
7839 @findex cimag
7840 @findex cimagf
7841 @findex cimagl
7842 @findex clog
7843 @findex clogf
7844 @findex clogl
7845 @findex conj
7846 @findex conjf
7847 @findex conjl
7848 @findex copysign
7849 @findex copysignf
7850 @findex copysignl
7851 @findex cos
7852 @findex cosf
7853 @findex cosh
7854 @findex coshf
7855 @findex coshl
7856 @findex cosl
7857 @findex cpow
7858 @findex cpowf
7859 @findex cpowl
7860 @findex cproj
7861 @findex cprojf
7862 @findex cprojl
7863 @findex creal
7864 @findex crealf
7865 @findex creall
7866 @findex csin
7867 @findex csinf
7868 @findex csinh
7869 @findex csinhf
7870 @findex csinhl
7871 @findex csinl
7872 @findex csqrt
7873 @findex csqrtf
7874 @findex csqrtl
7875 @findex ctan
7876 @findex ctanf
7877 @findex ctanh
7878 @findex ctanhf
7879 @findex ctanhl
7880 @findex ctanl
7881 @findex dcgettext
7882 @findex dgettext
7883 @findex drem
7884 @findex dremf
7885 @findex dreml
7886 @findex erf
7887 @findex erfc
7888 @findex erfcf
7889 @findex erfcl
7890 @findex erff
7891 @findex erfl
7892 @findex exit
7893 @findex exp
7894 @findex exp10
7895 @findex exp10f
7896 @findex exp10l
7897 @findex exp2
7898 @findex exp2f
7899 @findex exp2l
7900 @findex expf
7901 @findex expl
7902 @findex expm1
7903 @findex expm1f
7904 @findex expm1l
7905 @findex fabs
7906 @findex fabsf
7907 @findex fabsl
7908 @findex fdim
7909 @findex fdimf
7910 @findex fdiml
7911 @findex ffs
7912 @findex floor
7913 @findex floorf
7914 @findex floorl
7915 @findex fma
7916 @findex fmaf
7917 @findex fmal
7918 @findex fmax
7919 @findex fmaxf
7920 @findex fmaxl
7921 @findex fmin
7922 @findex fminf
7923 @findex fminl
7924 @findex fmod
7925 @findex fmodf
7926 @findex fmodl
7927 @findex fprintf
7928 @findex fprintf_unlocked
7929 @findex fputs
7930 @findex fputs_unlocked
7931 @findex frexp
7932 @findex frexpf
7933 @findex frexpl
7934 @findex fscanf
7935 @findex gamma
7936 @findex gammaf
7937 @findex gammal
7938 @findex gamma_r
7939 @findex gammaf_r
7940 @findex gammal_r
7941 @findex gettext
7942 @findex hypot
7943 @findex hypotf
7944 @findex hypotl
7945 @findex ilogb
7946 @findex ilogbf
7947 @findex ilogbl
7948 @findex imaxabs
7949 @findex index
7950 @findex isalnum
7951 @findex isalpha
7952 @findex isascii
7953 @findex isblank
7954 @findex iscntrl
7955 @findex isdigit
7956 @findex isgraph
7957 @findex islower
7958 @findex isprint
7959 @findex ispunct
7960 @findex isspace
7961 @findex isupper
7962 @findex iswalnum
7963 @findex iswalpha
7964 @findex iswblank
7965 @findex iswcntrl
7966 @findex iswdigit
7967 @findex iswgraph
7968 @findex iswlower
7969 @findex iswprint
7970 @findex iswpunct
7971 @findex iswspace
7972 @findex iswupper
7973 @findex iswxdigit
7974 @findex isxdigit
7975 @findex j0
7976 @findex j0f
7977 @findex j0l
7978 @findex j1
7979 @findex j1f
7980 @findex j1l
7981 @findex jn
7982 @findex jnf
7983 @findex jnl
7984 @findex labs
7985 @findex ldexp
7986 @findex ldexpf
7987 @findex ldexpl
7988 @findex lgamma
7989 @findex lgammaf
7990 @findex lgammal
7991 @findex lgamma_r
7992 @findex lgammaf_r
7993 @findex lgammal_r
7994 @findex llabs
7995 @findex llrint
7996 @findex llrintf
7997 @findex llrintl
7998 @findex llround
7999 @findex llroundf
8000 @findex llroundl
8001 @findex log
8002 @findex log10
8003 @findex log10f
8004 @findex log10l
8005 @findex log1p
8006 @findex log1pf
8007 @findex log1pl
8008 @findex log2
8009 @findex log2f
8010 @findex log2l
8011 @findex logb
8012 @findex logbf
8013 @findex logbl
8014 @findex logf
8015 @findex logl
8016 @findex lrint
8017 @findex lrintf
8018 @findex lrintl
8019 @findex lround
8020 @findex lroundf
8021 @findex lroundl
8022 @findex malloc
8023 @findex memchr
8024 @findex memcmp
8025 @findex memcpy
8026 @findex mempcpy
8027 @findex memset
8028 @findex modf
8029 @findex modff
8030 @findex modfl
8031 @findex nearbyint
8032 @findex nearbyintf
8033 @findex nearbyintl
8034 @findex nextafter
8035 @findex nextafterf
8036 @findex nextafterl
8037 @findex nexttoward
8038 @findex nexttowardf
8039 @findex nexttowardl
8040 @findex pow
8041 @findex pow10
8042 @findex pow10f
8043 @findex pow10l
8044 @findex powf
8045 @findex powl
8046 @findex printf
8047 @findex printf_unlocked
8048 @findex putchar
8049 @findex puts
8050 @findex remainder
8051 @findex remainderf
8052 @findex remainderl
8053 @findex remquo
8054 @findex remquof
8055 @findex remquol
8056 @findex rindex
8057 @findex rint
8058 @findex rintf
8059 @findex rintl
8060 @findex round
8061 @findex roundf
8062 @findex roundl
8063 @findex scalb
8064 @findex scalbf
8065 @findex scalbl
8066 @findex scalbln
8067 @findex scalblnf
8068 @findex scalblnf
8069 @findex scalbn
8070 @findex scalbnf
8071 @findex scanfnl
8072 @findex signbit
8073 @findex signbitf
8074 @findex signbitl
8075 @findex signbitd32
8076 @findex signbitd64
8077 @findex signbitd128
8078 @findex significand
8079 @findex significandf
8080 @findex significandl
8081 @findex sin
8082 @findex sincos
8083 @findex sincosf
8084 @findex sincosl
8085 @findex sinf
8086 @findex sinh
8087 @findex sinhf
8088 @findex sinhl
8089 @findex sinl
8090 @findex snprintf
8091 @findex sprintf
8092 @findex sqrt
8093 @findex sqrtf
8094 @findex sqrtl
8095 @findex sscanf
8096 @findex stpcpy
8097 @findex stpncpy
8098 @findex strcasecmp
8099 @findex strcat
8100 @findex strchr
8101 @findex strcmp
8102 @findex strcpy
8103 @findex strcspn
8104 @findex strdup
8105 @findex strfmon
8106 @findex strftime
8107 @findex strlen
8108 @findex strncasecmp
8109 @findex strncat
8110 @findex strncmp
8111 @findex strncpy
8112 @findex strndup
8113 @findex strpbrk
8114 @findex strrchr
8115 @findex strspn
8116 @findex strstr
8117 @findex tan
8118 @findex tanf
8119 @findex tanh
8120 @findex tanhf
8121 @findex tanhl
8122 @findex tanl
8123 @findex tgamma
8124 @findex tgammaf
8125 @findex tgammal
8126 @findex toascii
8127 @findex tolower
8128 @findex toupper
8129 @findex towlower
8130 @findex towupper
8131 @findex trunc
8132 @findex truncf
8133 @findex truncl
8134 @findex vfprintf
8135 @findex vfscanf
8136 @findex vprintf
8137 @findex vscanf
8138 @findex vsnprintf
8139 @findex vsprintf
8140 @findex vsscanf
8141 @findex y0
8142 @findex y0f
8143 @findex y0l
8144 @findex y1
8145 @findex y1f
8146 @findex y1l
8147 @findex yn
8148 @findex ynf
8149 @findex ynl
8151 GCC provides a large number of built-in functions other than the ones
8152 mentioned above.  Some of these are for internal use in the processing
8153 of exceptions or variable-length argument lists and are not
8154 documented here because they may change from time to time; we do not
8155 recommend general use of these functions.
8157 The remaining functions are provided for optimization purposes.
8159 @opindex fno-builtin
8160 GCC includes built-in versions of many of the functions in the standard
8161 C library.  The versions prefixed with @code{__builtin_} are always
8162 treated as having the same meaning as the C library function even if you
8163 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
8164 Many of these functions are only optimized in certain cases; if they are
8165 not optimized in a particular case, a call to the library function is
8166 emitted.
8168 @opindex ansi
8169 @opindex std
8170 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8171 @option{-std=c99} or @option{-std=c11}), the functions
8172 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8173 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8174 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8175 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8176 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8177 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8178 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8179 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8180 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8181 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8182 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8183 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8184 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8185 @code{significandl}, @code{significand}, @code{sincosf},
8186 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8187 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8188 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8189 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8190 @code{yn}
8191 may be handled as built-in functions.
8192 All these functions have corresponding versions
8193 prefixed with @code{__builtin_}, which may be used even in strict C90
8194 mode.
8196 The ISO C99 functions
8197 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8198 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8199 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8200 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8201 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8202 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8203 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8204 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8205 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8206 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8207 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8208 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8209 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8210 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8211 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8212 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8213 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8214 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8215 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8216 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8217 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8218 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8219 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8220 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8221 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8222 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8223 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8224 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8225 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8226 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8227 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8228 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8229 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8230 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8231 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8232 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8233 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8234 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8235 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8236 are handled as built-in functions
8237 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8239 There are also built-in versions of the ISO C99 functions
8240 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8241 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8242 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8243 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8244 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8245 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8246 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8247 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8248 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8249 that are recognized in any mode since ISO C90 reserves these names for
8250 the purpose to which ISO C99 puts them.  All these functions have
8251 corresponding versions prefixed with @code{__builtin_}.
8253 The ISO C94 functions
8254 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8255 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8256 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8257 @code{towupper}
8258 are handled as built-in functions
8259 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8261 The ISO C90 functions
8262 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8263 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8264 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8265 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8266 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8267 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8268 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8269 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8270 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8271 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8272 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8273 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8274 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8275 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8276 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8277 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8278 are all recognized as built-in functions unless
8279 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8280 is specified for an individual function).  All of these functions have
8281 corresponding versions prefixed with @code{__builtin_}.
8283 GCC provides built-in versions of the ISO C99 floating-point comparison
8284 macros that avoid raising exceptions for unordered operands.  They have
8285 the same names as the standard macros ( @code{isgreater},
8286 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8287 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8288 prefixed.  We intend for a library implementor to be able to simply
8289 @code{#define} each standard macro to its built-in equivalent.
8290 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8291 @code{isinf_sign} and @code{isnormal} built-ins used with
8292 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
8293 built-in functions appear both with and without the @code{__builtin_} prefix.
8295 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8297 You can use the built-in function @code{__builtin_types_compatible_p} to
8298 determine whether two types are the same.
8300 This built-in function returns 1 if the unqualified versions of the
8301 types @var{type1} and @var{type2} (which are types, not expressions) are
8302 compatible, 0 otherwise.  The result of this built-in function can be
8303 used in integer constant expressions.
8305 This built-in function ignores top level qualifiers (e.g., @code{const},
8306 @code{volatile}).  For example, @code{int} is equivalent to @code{const
8307 int}.
8309 The type @code{int[]} and @code{int[5]} are compatible.  On the other
8310 hand, @code{int} and @code{char *} are not compatible, even if the size
8311 of their types, on the particular architecture are the same.  Also, the
8312 amount of pointer indirection is taken into account when determining
8313 similarity.  Consequently, @code{short *} is not similar to
8314 @code{short **}.  Furthermore, two types that are typedefed are
8315 considered compatible if their underlying types are compatible.
8317 An @code{enum} type is not considered to be compatible with another
8318 @code{enum} type even if both are compatible with the same integer
8319 type; this is what the C standard specifies.
8320 For example, @code{enum @{foo, bar@}} is not similar to
8321 @code{enum @{hot, dog@}}.
8323 You typically use this function in code whose execution varies
8324 depending on the arguments' types.  For example:
8326 @smallexample
8327 #define foo(x)                                                  \
8328   (@{                                                           \
8329     typeof (x) tmp = (x);                                       \
8330     if (__builtin_types_compatible_p (typeof (x), long double)) \
8331       tmp = foo_long_double (tmp);                              \
8332     else if (__builtin_types_compatible_p (typeof (x), double)) \
8333       tmp = foo_double (tmp);                                   \
8334     else if (__builtin_types_compatible_p (typeof (x), float))  \
8335       tmp = foo_float (tmp);                                    \
8336     else                                                        \
8337       abort ();                                                 \
8338     tmp;                                                        \
8339   @})
8340 @end smallexample
8342 @emph{Note:} This construct is only available for C@.
8344 @end deftypefn
8346 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8348 You can use the built-in function @code{__builtin_choose_expr} to
8349 evaluate code depending on the value of a constant expression.  This
8350 built-in function returns @var{exp1} if @var{const_exp}, which is an
8351 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
8353 This built-in function is analogous to the @samp{? :} operator in C,
8354 except that the expression returned has its type unaltered by promotion
8355 rules.  Also, the built-in function does not evaluate the expression
8356 that is not chosen.  For example, if @var{const_exp} evaluates to true,
8357 @var{exp2} is not evaluated even if it has side-effects.
8359 This built-in function can return an lvalue if the chosen argument is an
8360 lvalue.
8362 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8363 type.  Similarly, if @var{exp2} is returned, its return type is the same
8364 as @var{exp2}.
8366 Example:
8368 @smallexample
8369 #define foo(x)                                                    \
8370   __builtin_choose_expr (                                         \
8371     __builtin_types_compatible_p (typeof (x), double),            \
8372     foo_double (x),                                               \
8373     __builtin_choose_expr (                                       \
8374       __builtin_types_compatible_p (typeof (x), float),           \
8375       foo_float (x),                                              \
8376       /* @r{The void expression results in a compile-time error}  \
8377          @r{when assigning the result to something.}  */          \
8378       (void)0))
8379 @end smallexample
8381 @emph{Note:} This construct is only available for C@.  Furthermore, the
8382 unused expression (@var{exp1} or @var{exp2} depending on the value of
8383 @var{const_exp}) may still generate syntax errors.  This may change in
8384 future revisions.
8386 @end deftypefn
8388 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8390 The built-in function @code{__builtin_complex} is provided for use in
8391 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8392 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
8393 real binary floating-point type, and the result has the corresponding
8394 complex type with real and imaginary parts @var{real} and @var{imag}.
8395 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8396 infinities, NaNs and negative zeros are involved.
8398 @end deftypefn
8400 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8401 You can use the built-in function @code{__builtin_constant_p} to
8402 determine if a value is known to be constant at compile time and hence
8403 that GCC can perform constant-folding on expressions involving that
8404 value.  The argument of the function is the value to test.  The function
8405 returns the integer 1 if the argument is known to be a compile-time
8406 constant and 0 if it is not known to be a compile-time constant.  A
8407 return of 0 does not indicate that the value is @emph{not} a constant,
8408 but merely that GCC cannot prove it is a constant with the specified
8409 value of the @option{-O} option.
8411 You typically use this function in an embedded application where
8412 memory is a critical resource.  If you have some complex calculation,
8413 you may want it to be folded if it involves constants, but need to call
8414 a function if it does not.  For example:
8416 @smallexample
8417 #define Scale_Value(X)      \
8418   (__builtin_constant_p (X) \
8419   ? ((X) * SCALE + OFFSET) : Scale (X))
8420 @end smallexample
8422 You may use this built-in function in either a macro or an inline
8423 function.  However, if you use it in an inlined function and pass an
8424 argument of the function as the argument to the built-in, GCC 
8425 never returns 1 when you call the inline function with a string constant
8426 or compound literal (@pxref{Compound Literals}) and does not return 1
8427 when you pass a constant numeric value to the inline function unless you
8428 specify the @option{-O} option.
8430 You may also use @code{__builtin_constant_p} in initializers for static
8431 data.  For instance, you can write
8433 @smallexample
8434 static const int table[] = @{
8435    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8436    /* @r{@dots{}} */
8438 @end smallexample
8440 @noindent
8441 This is an acceptable initializer even if @var{EXPRESSION} is not a
8442 constant expression, including the case where
8443 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8444 folded to a constant but @var{EXPRESSION} contains operands that are
8445 not otherwise permitted in a static initializer (for example,
8446 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
8447 built-in in this case, because it has no opportunity to perform
8448 optimization.
8450 Previous versions of GCC did not accept this built-in in data
8451 initializers.  The earliest version where it is completely safe is
8452 3.0.1.
8453 @end deftypefn
8455 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8456 @opindex fprofile-arcs
8457 You may use @code{__builtin_expect} to provide the compiler with
8458 branch prediction information.  In general, you should prefer to
8459 use actual profile feedback for this (@option{-fprofile-arcs}), as
8460 programmers are notoriously bad at predicting how their programs
8461 actually perform.  However, there are applications in which this
8462 data is hard to collect.
8464 The return value is the value of @var{exp}, which should be an integral
8465 expression.  The semantics of the built-in are that it is expected that
8466 @var{exp} == @var{c}.  For example:
8468 @smallexample
8469 if (__builtin_expect (x, 0))
8470   foo ();
8471 @end smallexample
8473 @noindent
8474 indicates that we do not expect to call @code{foo}, since
8475 we expect @code{x} to be zero.  Since you are limited to integral
8476 expressions for @var{exp}, you should use constructions such as
8478 @smallexample
8479 if (__builtin_expect (ptr != NULL, 1))
8480   foo (*ptr);
8481 @end smallexample
8483 @noindent
8484 when testing pointer or floating-point values.
8485 @end deftypefn
8487 @deftypefn {Built-in Function} void __builtin_trap (void)
8488 This function causes the program to exit abnormally.  GCC implements
8489 this function by using a target-dependent mechanism (such as
8490 intentionally executing an illegal instruction) or by calling
8491 @code{abort}.  The mechanism used may vary from release to release so
8492 you should not rely on any particular implementation.
8493 @end deftypefn
8495 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8496 If control flow reaches the point of the @code{__builtin_unreachable},
8497 the program is undefined.  It is useful in situations where the
8498 compiler cannot deduce the unreachability of the code.
8500 One such case is immediately following an @code{asm} statement that
8501 either never terminates, or one that transfers control elsewhere
8502 and never returns.  In this example, without the
8503 @code{__builtin_unreachable}, GCC issues a warning that control
8504 reaches the end of a non-void function.  It also generates code
8505 to return after the @code{asm}.
8507 @smallexample
8508 int f (int c, int v)
8510   if (c)
8511     @{
8512       return v;
8513     @}
8514   else
8515     @{
8516       asm("jmp error_handler");
8517       __builtin_unreachable ();
8518     @}
8520 @end smallexample
8522 @noindent
8523 Because the @code{asm} statement unconditionally transfers control out
8524 of the function, control never reaches the end of the function
8525 body.  The @code{__builtin_unreachable} is in fact unreachable and
8526 communicates this fact to the compiler.
8528 Another use for @code{__builtin_unreachable} is following a call a
8529 function that never returns but that is not declared
8530 @code{__attribute__((noreturn))}, as in this example:
8532 @smallexample
8533 void function_that_never_returns (void);
8535 int g (int c)
8537   if (c)
8538     @{
8539       return 1;
8540     @}
8541   else
8542     @{
8543       function_that_never_returns ();
8544       __builtin_unreachable ();
8545     @}
8547 @end smallexample
8549 @end deftypefn
8551 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8552 This function returns its first argument, and allows the compiler
8553 to assume that the returned pointer is at least @var{align} bytes
8554 aligned.  This built-in can have either two or three arguments,
8555 if it has three, the third argument should have integer type, and
8556 if it is nonzero means misalignment offset.  For example:
8558 @smallexample
8559 void *x = __builtin_assume_aligned (arg, 16);
8560 @end smallexample
8562 @noindent
8563 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8564 16-byte aligned, while:
8566 @smallexample
8567 void *x = __builtin_assume_aligned (arg, 32, 8);
8568 @end smallexample
8570 @noindent
8571 means that the compiler can assume for @code{x}, set to @code{arg}, that
8572 @code{(char *) x - 8} is 32-byte aligned.
8573 @end deftypefn
8575 @deftypefn {Built-in Function} int __builtin_LINE ()
8576 This function is the equivalent to the preprocessor @code{__LINE__}
8577 macro and returns the line number of the invocation of the built-in.
8578 @end deftypefn
8580 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8581 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8582 macro and returns the function name the invocation of the built-in is in.
8583 @end deftypefn
8585 @deftypefn {Built-in Function} int __builtin_FILE ()
8586 This function is the equivalent to the preprocessor @code{__FILE__}
8587 macro and returns the file name the invocation of the built-in is in.
8588 @end deftypefn
8590 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8591 This function is used to flush the processor's instruction cache for
8592 the region of memory between @var{begin} inclusive and @var{end}
8593 exclusive.  Some targets require that the instruction cache be
8594 flushed, after modifying memory containing code, in order to obtain
8595 deterministic behavior.
8597 If the target does not require instruction cache flushes,
8598 @code{__builtin___clear_cache} has no effect.  Otherwise either
8599 instructions are emitted in-line to clear the instruction cache or a
8600 call to the @code{__clear_cache} function in libgcc is made.
8601 @end deftypefn
8603 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8604 This function is used to minimize cache-miss latency by moving data into
8605 a cache before it is accessed.
8606 You can insert calls to @code{__builtin_prefetch} into code for which
8607 you know addresses of data in memory that is likely to be accessed soon.
8608 If the target supports them, data prefetch instructions are generated.
8609 If the prefetch is done early enough before the access then the data will
8610 be in the cache by the time it is accessed.
8612 The value of @var{addr} is the address of the memory to prefetch.
8613 There are two optional arguments, @var{rw} and @var{locality}.
8614 The value of @var{rw} is a compile-time constant one or zero; one
8615 means that the prefetch is preparing for a write to the memory address
8616 and zero, the default, means that the prefetch is preparing for a read.
8617 The value @var{locality} must be a compile-time constant integer between
8618 zero and three.  A value of zero means that the data has no temporal
8619 locality, so it need not be left in the cache after the access.  A value
8620 of three means that the data has a high degree of temporal locality and
8621 should be left in all levels of cache possible.  Values of one and two
8622 mean, respectively, a low or moderate degree of temporal locality.  The
8623 default is three.
8625 @smallexample
8626 for (i = 0; i < n; i++)
8627   @{
8628     a[i] = a[i] + b[i];
8629     __builtin_prefetch (&a[i+j], 1, 1);
8630     __builtin_prefetch (&b[i+j], 0, 1);
8631     /* @r{@dots{}} */
8632   @}
8633 @end smallexample
8635 Data prefetch does not generate faults if @var{addr} is invalid, but
8636 the address expression itself must be valid.  For example, a prefetch
8637 of @code{p->next} does not fault if @code{p->next} is not a valid
8638 address, but evaluation faults if @code{p} is not a valid address.
8640 If the target does not support data prefetch, the address expression
8641 is evaluated if it includes side effects but no other code is generated
8642 and GCC does not issue a warning.
8643 @end deftypefn
8645 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8646 Returns a positive infinity, if supported by the floating-point format,
8647 else @code{DBL_MAX}.  This function is suitable for implementing the
8648 ISO C macro @code{HUGE_VAL}.
8649 @end deftypefn
8651 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8652 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8653 @end deftypefn
8655 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8656 Similar to @code{__builtin_huge_val}, except the return
8657 type is @code{long double}.
8658 @end deftypefn
8660 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8661 This built-in implements the C99 fpclassify functionality.  The first
8662 five int arguments should be the target library's notion of the
8663 possible FP classes and are used for return values.  They must be
8664 constant values and they must appear in this order: @code{FP_NAN},
8665 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8666 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
8667 to classify.  GCC treats the last argument as type-generic, which
8668 means it does not do default promotion from float to double.
8669 @end deftypefn
8671 @deftypefn {Built-in Function} double __builtin_inf (void)
8672 Similar to @code{__builtin_huge_val}, except a warning is generated
8673 if the target floating-point format does not support infinities.
8674 @end deftypefn
8676 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8677 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8678 @end deftypefn
8680 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8681 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8682 @end deftypefn
8684 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8685 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8686 @end deftypefn
8688 @deftypefn {Built-in Function} float __builtin_inff (void)
8689 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8690 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8691 @end deftypefn
8693 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8694 Similar to @code{__builtin_inf}, except the return
8695 type is @code{long double}.
8696 @end deftypefn
8698 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8699 Similar to @code{isinf}, except the return value is -1 for
8700 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
8701 Note while the parameter list is an
8702 ellipsis, this function only accepts exactly one floating-point
8703 argument.  GCC treats this parameter as type-generic, which means it
8704 does not do default promotion from float to double.
8705 @end deftypefn
8707 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8708 This is an implementation of the ISO C99 function @code{nan}.
8710 Since ISO C99 defines this function in terms of @code{strtod}, which we
8711 do not implement, a description of the parsing is in order.  The string
8712 is parsed as by @code{strtol}; that is, the base is recognized by
8713 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
8714 in the significand such that the least significant bit of the number
8715 is at the least significant bit of the significand.  The number is
8716 truncated to fit the significand field provided.  The significand is
8717 forced to be a quiet NaN@.
8719 This function, if given a string literal all of which would have been
8720 consumed by @code{strtol}, is evaluated early enough that it is considered a
8721 compile-time constant.
8722 @end deftypefn
8724 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8725 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8726 @end deftypefn
8728 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8729 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8730 @end deftypefn
8732 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8733 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8734 @end deftypefn
8736 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8737 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8738 @end deftypefn
8740 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8741 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8742 @end deftypefn
8744 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8745 Similar to @code{__builtin_nan}, except the significand is forced
8746 to be a signaling NaN@.  The @code{nans} function is proposed by
8747 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8748 @end deftypefn
8750 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8751 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8752 @end deftypefn
8754 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8755 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8756 @end deftypefn
8758 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8759 Returns one plus the index of the least significant 1-bit of @var{x}, or
8760 if @var{x} is zero, returns zero.
8761 @end deftypefn
8763 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8764 Returns the number of leading 0-bits in @var{x}, starting at the most
8765 significant bit position.  If @var{x} is 0, the result is undefined.
8766 @end deftypefn
8768 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8769 Returns the number of trailing 0-bits in @var{x}, starting at the least
8770 significant bit position.  If @var{x} is 0, the result is undefined.
8771 @end deftypefn
8773 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8774 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
8775 number of bits following the most significant bit that are identical
8776 to it.  There are no special cases for 0 or other values. 
8777 @end deftypefn
8779 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8780 Returns the number of 1-bits in @var{x}.
8781 @end deftypefn
8783 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8784 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8785 modulo 2.
8786 @end deftypefn
8788 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8789 Similar to @code{__builtin_ffs}, except the argument type is
8790 @code{unsigned long}.
8791 @end deftypefn
8793 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8794 Similar to @code{__builtin_clz}, except the argument type is
8795 @code{unsigned long}.
8796 @end deftypefn
8798 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8799 Similar to @code{__builtin_ctz}, except the argument type is
8800 @code{unsigned long}.
8801 @end deftypefn
8803 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8804 Similar to @code{__builtin_clrsb}, except the argument type is
8805 @code{long}.
8806 @end deftypefn
8808 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8809 Similar to @code{__builtin_popcount}, except the argument type is
8810 @code{unsigned long}.
8811 @end deftypefn
8813 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8814 Similar to @code{__builtin_parity}, except the argument type is
8815 @code{unsigned long}.
8816 @end deftypefn
8818 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8819 Similar to @code{__builtin_ffs}, except the argument type is
8820 @code{unsigned long long}.
8821 @end deftypefn
8823 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8824 Similar to @code{__builtin_clz}, except the argument type is
8825 @code{unsigned long long}.
8826 @end deftypefn
8828 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8829 Similar to @code{__builtin_ctz}, except the argument type is
8830 @code{unsigned long long}.
8831 @end deftypefn
8833 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8834 Similar to @code{__builtin_clrsb}, except the argument type is
8835 @code{long long}.
8836 @end deftypefn
8838 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8839 Similar to @code{__builtin_popcount}, except the argument type is
8840 @code{unsigned long long}.
8841 @end deftypefn
8843 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8844 Similar to @code{__builtin_parity}, except the argument type is
8845 @code{unsigned long long}.
8846 @end deftypefn
8848 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8849 Returns the first argument raised to the power of the second.  Unlike the
8850 @code{pow} function no guarantees about precision and rounding are made.
8851 @end deftypefn
8853 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8854 Similar to @code{__builtin_powi}, except the argument and return types
8855 are @code{float}.
8856 @end deftypefn
8858 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8859 Similar to @code{__builtin_powi}, except the argument and return types
8860 are @code{long double}.
8861 @end deftypefn
8863 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8864 Returns @var{x} with the order of the bytes reversed; for example,
8865 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
8866 exactly 8 bits.
8867 @end deftypefn
8869 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8870 Similar to @code{__builtin_bswap16}, except the argument and return types
8871 are 32 bit.
8872 @end deftypefn
8874 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
8875 Similar to @code{__builtin_bswap32}, except the argument and return types
8876 are 64 bit.
8877 @end deftypefn
8879 @node Cilk Plus Builtins
8880 @section Cilk Plus C/C++ language extension Built-in Functions.
8882 GCC provides support for the following built-in reduction funtions if Cilk Plus
8883 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8885 @itemize @bullet
8886 @item __sec_implicit_index
8887 @item __sec_reduce
8888 @item __sec_reduce_add
8889 @item __sec_reduce_all_nonzero
8890 @item __sec_reduce_all_zero
8891 @item __sec_reduce_any_nonzero
8892 @item __sec_reduce_any_zero
8893 @item __sec_reduce_max
8894 @item __sec_reduce_min
8895 @item __sec_reduce_max_ind
8896 @item __sec_reduce_min_ind
8897 @item __sec_reduce_mul
8898 @item __sec_reduce_mutating
8899 @end itemize
8901 Further details and examples about these built-in functions are described 
8902 in the Cilk Plus language manual which can be found at 
8903 @uref{http://www.cilkplus.org}.
8905 @node Target Builtins
8906 @section Built-in Functions Specific to Particular Target Machines
8908 On some target machines, GCC supports many built-in functions specific
8909 to those machines.  Generally these generate calls to specific machine
8910 instructions, but allow the compiler to schedule those calls.
8912 @menu
8913 * Alpha Built-in Functions::
8914 * ARC Built-in Functions::
8915 * ARC SIMD Built-in Functions::
8916 * ARM iWMMXt Built-in Functions::
8917 * ARM NEON Intrinsics::
8918 * AVR Built-in Functions::
8919 * Blackfin Built-in Functions::
8920 * FR-V Built-in Functions::
8921 * X86 Built-in Functions::
8922 * X86 transactional memory intrinsics::
8923 * MIPS DSP Built-in Functions::
8924 * MIPS Paired-Single Support::
8925 * MIPS Loongson Built-in Functions::
8926 * Other MIPS Built-in Functions::
8927 * MSP430 Built-in Functions::
8928 * picoChip Built-in Functions::
8929 * PowerPC Built-in Functions::
8930 * PowerPC AltiVec/VSX Built-in Functions::
8931 * RX Built-in Functions::
8932 * S/390 System z Built-in Functions::
8933 * SH Built-in Functions::
8934 * SPARC VIS Built-in Functions::
8935 * SPU Built-in Functions::
8936 * TI C6X Built-in Functions::
8937 * TILE-Gx Built-in Functions::
8938 * TILEPro Built-in Functions::
8939 @end menu
8941 @node Alpha Built-in Functions
8942 @subsection Alpha Built-in Functions
8944 These built-in functions are available for the Alpha family of
8945 processors, depending on the command-line switches used.
8947 The following built-in functions are always available.  They
8948 all generate the machine instruction that is part of the name.
8950 @smallexample
8951 long __builtin_alpha_implver (void)
8952 long __builtin_alpha_rpcc (void)
8953 long __builtin_alpha_amask (long)
8954 long __builtin_alpha_cmpbge (long, long)
8955 long __builtin_alpha_extbl (long, long)
8956 long __builtin_alpha_extwl (long, long)
8957 long __builtin_alpha_extll (long, long)
8958 long __builtin_alpha_extql (long, long)
8959 long __builtin_alpha_extwh (long, long)
8960 long __builtin_alpha_extlh (long, long)
8961 long __builtin_alpha_extqh (long, long)
8962 long __builtin_alpha_insbl (long, long)
8963 long __builtin_alpha_inswl (long, long)
8964 long __builtin_alpha_insll (long, long)
8965 long __builtin_alpha_insql (long, long)
8966 long __builtin_alpha_inswh (long, long)
8967 long __builtin_alpha_inslh (long, long)
8968 long __builtin_alpha_insqh (long, long)
8969 long __builtin_alpha_mskbl (long, long)
8970 long __builtin_alpha_mskwl (long, long)
8971 long __builtin_alpha_mskll (long, long)
8972 long __builtin_alpha_mskql (long, long)
8973 long __builtin_alpha_mskwh (long, long)
8974 long __builtin_alpha_msklh (long, long)
8975 long __builtin_alpha_mskqh (long, long)
8976 long __builtin_alpha_umulh (long, long)
8977 long __builtin_alpha_zap (long, long)
8978 long __builtin_alpha_zapnot (long, long)
8979 @end smallexample
8981 The following built-in functions are always with @option{-mmax}
8982 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
8983 later.  They all generate the machine instruction that is part
8984 of the name.
8986 @smallexample
8987 long __builtin_alpha_pklb (long)
8988 long __builtin_alpha_pkwb (long)
8989 long __builtin_alpha_unpkbl (long)
8990 long __builtin_alpha_unpkbw (long)
8991 long __builtin_alpha_minub8 (long, long)
8992 long __builtin_alpha_minsb8 (long, long)
8993 long __builtin_alpha_minuw4 (long, long)
8994 long __builtin_alpha_minsw4 (long, long)
8995 long __builtin_alpha_maxub8 (long, long)
8996 long __builtin_alpha_maxsb8 (long, long)
8997 long __builtin_alpha_maxuw4 (long, long)
8998 long __builtin_alpha_maxsw4 (long, long)
8999 long __builtin_alpha_perr (long, long)
9000 @end smallexample
9002 The following built-in functions are always with @option{-mcix}
9003 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9004 later.  They all generate the machine instruction that is part
9005 of the name.
9007 @smallexample
9008 long __builtin_alpha_cttz (long)
9009 long __builtin_alpha_ctlz (long)
9010 long __builtin_alpha_ctpop (long)
9011 @end smallexample
9013 The following built-in functions are available on systems that use the OSF/1
9014 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
9015 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9016 @code{rdval} and @code{wrval}.
9018 @smallexample
9019 void *__builtin_thread_pointer (void)
9020 void __builtin_set_thread_pointer (void *)
9021 @end smallexample
9023 @node ARC Built-in Functions
9024 @subsection ARC Built-in Functions
9026 The following built-in functions are provided for ARC targets.  The
9027 built-ins generate the corresponding assembly instructions.  In the
9028 examples given below, the generated code often requires an operand or
9029 result to be in a register.  Where necessary further code will be
9030 generated to ensure this is true, but for brevity this is not
9031 described in each case.
9033 @emph{Note:} Using a built-in to generate an instruction not supported
9034 by a target may cause problems. At present the compiler is not
9035 guaranteed to detect such misuse, and as a result an internal compiler
9036 error may be generated.
9038 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9039 Return 1 if @var{val} is known to have the byte alignment given
9040 by @var{alignval}, otherwise return 0.
9041 Note that this is different from
9042 @smallexample
9043 __alignof__(*(char *)@var{val}) >= alignval
9044 @end smallexample
9045 because __alignof__ sees only the type of the dereference, whereas
9046 __builtin_arc_align uses alignment information from the pointer
9047 as well as from the pointed-to type.
9048 The information available will depend on optimization level.
9049 @end deftypefn
9051 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9052 Generates
9053 @example
9055 @end example
9056 @end deftypefn
9058 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9059 The operand is the number of a register to be read.  Generates:
9060 @example
9061 mov  @var{dest}, r@var{regno}
9062 @end example
9063 where the value in @var{dest} will be the result returned from the
9064 built-in.
9065 @end deftypefn
9067 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9068 The first operand is the number of a register to be written, the
9069 second operand is a compile time constant to write into that
9070 register.  Generates:
9071 @example
9072 mov  r@var{regno}, @var{val}
9073 @end example
9074 @end deftypefn
9076 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9077 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9078 Generates:
9079 @example
9080 divaw  @var{dest}, @var{a}, @var{b}
9081 @end example
9082 where the value in @var{dest} will be the result returned from the
9083 built-in.
9084 @end deftypefn
9086 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9087 Generates
9088 @example
9089 flag  @var{a}
9090 @end example
9091 @end deftypefn
9093 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9094 The operand, @var{auxv}, is the address of an auxiliary register and
9095 must be a compile time constant.  Generates:
9096 @example
9097 lr  @var{dest}, [@var{auxr}]
9098 @end example
9099 Where the value in @var{dest} will be the result returned from the
9100 built-in.
9101 @end deftypefn
9103 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
9104 Only available with @option{-mmul64}.  Generates:
9105 @example
9106 mul64  @var{a}, @var{b}
9107 @end example
9108 @end deftypefn
9110 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
9111 Only available with @option{-mmul64}.  Generates:
9112 @example
9113 mulu64  @var{a}, @var{b}
9114 @end example
9115 @end deftypefn
9117 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
9118 Generates:
9119 @example
9121 @end example
9122 @end deftypefn
9124 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
9125 Only valid if the @samp{norm} instruction is available through the
9126 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9127 Generates:
9128 @example
9129 norm  @var{dest}, @var{src}
9130 @end example
9131 Where the value in @var{dest} will be the result returned from the
9132 built-in.
9133 @end deftypefn
9135 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
9136 Only valid if the @samp{normw} instruction is available through the
9137 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9138 Generates:
9139 @example
9140 normw  @var{dest}, @var{src}
9141 @end example
9142 Where the value in @var{dest} will be the result returned from the
9143 built-in.
9144 @end deftypefn
9146 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
9147 Generates:
9148 @example
9149 rtie
9150 @end example
9151 @end deftypefn
9153 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
9154 Generates:
9155 @example
9156 sleep  @var{a}
9157 @end example
9158 @end deftypefn
9160 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
9161 The first argument, @var{auxv}, is the address of an auxiliary
9162 register, the second argument, @var{val}, is a compile time constant
9163 to be written to the register.  Generates:
9164 @example
9165 sr  @var{auxr}, [@var{val}]
9166 @end example
9167 @end deftypefn
9169 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
9170 Only valid with @option{-mswap}.  Generates:
9171 @example
9172 swap  @var{dest}, @var{src}
9173 @end example
9174 Where the value in @var{dest} will be the result returned from the
9175 built-in.
9176 @end deftypefn
9178 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
9179 Generates:
9180 @example
9182 @end example
9183 @end deftypefn
9185 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
9186 Only available with @option{-mcpu=ARC700}.  Generates:
9187 @example
9188 sync
9189 @end example
9190 @end deftypefn
9192 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
9193 Only available with @option{-mcpu=ARC700}.  Generates:
9194 @example
9195 trap_s  @var{c}
9196 @end example
9197 @end deftypefn
9199 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
9200 Only available with @option{-mcpu=ARC700}.  Generates:
9201 @example
9202 unimp_s
9203 @end example
9204 @end deftypefn
9206 The instructions generated by the following builtins are not
9207 considered as candidates for scheduling.  They are not moved around by
9208 the compiler during scheduling, and thus can be expected to appear
9209 where they are put in the C code:
9210 @example
9211 __builtin_arc_brk()
9212 __builtin_arc_core_read()
9213 __builtin_arc_core_write()
9214 __builtin_arc_flag()
9215 __builtin_arc_lr()
9216 __builtin_arc_sleep()
9217 __builtin_arc_sr()
9218 __builtin_arc_swi()
9219 @end example
9221 @node ARC SIMD Built-in Functions
9222 @subsection ARC SIMD Built-in Functions
9224 SIMD builtins provided by the compiler can be used to generate the
9225 vector instructions.  This section describes the available builtins
9226 and their usage in programs.  With the @option{-msimd} option, the
9227 compiler provides 128-bit vector types, which can be specified using
9228 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
9229 can be included to use the following predefined types:
9230 @example
9231 typedef int __v4si   __attribute__((vector_size(16)));
9232 typedef short __v8hi __attribute__((vector_size(16)));
9233 @end example
9235 These types can be used to define 128-bit variables.  The built-in
9236 functions listed in the following section can be used on these
9237 variables to generate the vector operations.
9239 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
9240 @file{arc-simd.h} also provides equivalent macros called
9241 @code{_@var{someinsn}} that can be used for programming ease and
9242 improved readability.  The following macros for DMA control are also
9243 provided:
9244 @example
9245 #define _setup_dma_in_channel_reg _vdiwr
9246 #define _setup_dma_out_channel_reg _vdowr
9247 @end example
9249 The following is a complete list of all the SIMD built-ins provided
9250 for ARC, grouped by calling signature.
9252 The following take two @code{__v8hi} arguments and return a
9253 @code{__v8hi} result:
9254 @example
9255 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
9256 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
9257 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
9258 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
9259 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
9260 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
9261 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
9262 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
9263 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
9264 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
9265 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
9266 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
9267 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
9268 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
9269 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
9270 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
9271 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
9272 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
9273 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
9274 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
9275 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
9276 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
9277 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
9278 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
9279 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
9280 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
9281 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
9282 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
9283 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
9284 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
9285 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
9286 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
9287 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
9288 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
9289 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
9290 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
9291 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
9292 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
9293 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
9294 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
9295 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
9296 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
9297 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
9298 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
9299 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
9300 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
9301 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
9302 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
9303 @end example
9305 The following take one @code{__v8hi} and one @code{int} argument and return a
9306 @code{__v8hi} result:
9308 @example
9309 __v8hi __builtin_arc_vbaddw (__v8hi, int)
9310 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
9311 __v8hi __builtin_arc_vbminw (__v8hi, int)
9312 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
9313 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
9314 __v8hi __builtin_arc_vbmulw (__v8hi, int)
9315 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
9316 __v8hi __builtin_arc_vbsubw (__v8hi, int)
9317 @end example
9319 The following take one @code{__v8hi} argument and one @code{int} argument which
9320 must be a 3-bit compile time constant indicating a register number
9321 I0-I7.  They return a @code{__v8hi} result.
9322 @example
9323 __v8hi __builtin_arc_vasrw (__v8hi, const int)
9324 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
9325 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
9326 @end example
9328 The following take one @code{__v8hi} argument and one @code{int}
9329 argument which must be a 6-bit compile time constant.  They return a
9330 @code{__v8hi} result.
9331 @example
9332 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
9333 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
9334 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
9335 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
9336 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
9337 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
9338 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
9339 @end example
9341 The following take one @code{__v8hi} argument and one @code{int} argument which
9342 must be a 8-bit compile time constant.  They return a @code{__v8hi}
9343 result.
9344 @example
9345 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
9346 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
9347 __v8hi __builtin_arc_vmvw (__v8hi, const int)
9348 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
9349 @end example
9351 The following take two @code{int} arguments, the second of which which
9352 must be a 8-bit compile time constant.  They return a @code{__v8hi}
9353 result:
9354 @example
9355 __v8hi __builtin_arc_vmovaw (int, const int)
9356 __v8hi __builtin_arc_vmovw (int, const int)
9357 __v8hi __builtin_arc_vmovzw (int, const int)
9358 @end example
9360 The following take a single @code{__v8hi} argument and return a
9361 @code{__v8hi} result:
9362 @example
9363 __v8hi __builtin_arc_vabsaw (__v8hi)
9364 __v8hi __builtin_arc_vabsw (__v8hi)
9365 __v8hi __builtin_arc_vaddsuw (__v8hi)
9366 __v8hi __builtin_arc_vexch1 (__v8hi)
9367 __v8hi __builtin_arc_vexch2 (__v8hi)
9368 __v8hi __builtin_arc_vexch4 (__v8hi)
9369 __v8hi __builtin_arc_vsignw (__v8hi)
9370 __v8hi __builtin_arc_vupbaw (__v8hi)
9371 __v8hi __builtin_arc_vupbw (__v8hi)
9372 __v8hi __builtin_arc_vupsbaw (__v8hi)
9373 __v8hi __builtin_arc_vupsbw (__v8hi)
9374 @end example
9376 The followign take two @code{int} arguments and return no result:
9377 @example
9378 void __builtin_arc_vdirun (int, int)
9379 void __builtin_arc_vdorun (int, int)
9380 @end example
9382 The following take two @code{int} arguments and return no result.  The
9383 first argument must a 3-bit compile time constant indicating one of
9384 the DR0-DR7 DMA setup channels:
9385 @example
9386 void __builtin_arc_vdiwr (const int, int)
9387 void __builtin_arc_vdowr (const int, int)
9388 @end example
9390 The following take an @code{int} argument and return no result:
9391 @example
9392 void __builtin_arc_vendrec (int)
9393 void __builtin_arc_vrec (int)
9394 void __builtin_arc_vrecrun (int)
9395 void __builtin_arc_vrun (int)
9396 @end example
9398 The following take a @code{__v8hi} argument and two @code{int}
9399 arguments and return a @code{__v8hi} result.  The second argument must
9400 be a 3-bit compile time constants, indicating one the registers I0-I7,
9401 and the third argument must be an 8-bit compile time constant.
9403 @emph{Note:} Although the equivalent hardware instructions do not take
9404 an SIMD register as an operand, these builtins overwrite the relevant
9405 bits of the @code{__v8hi} register provided as the first argument with
9406 the value loaded from the @code{[Ib, u8]} location in the SDM.
9408 @example
9409 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
9410 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
9411 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
9412 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
9413 @end example
9415 The following take two @code{int} arguments and return a @code{__v8hi}
9416 result.  The first argument must be a 3-bit compile time constants,
9417 indicating one the registers I0-I7, and the second argument must be an
9418 8-bit compile time constant.
9420 @example
9421 __v8hi __builtin_arc_vld128 (const int, const int)
9422 __v8hi __builtin_arc_vld64w (const int, const int)
9423 @end example
9425 The following take a @code{__v8hi} argument and two @code{int}
9426 arguments and return no result.  The second argument must be a 3-bit
9427 compile time constants, indicating one the registers I0-I7, and the
9428 third argument must be an 8-bit compile time constant.
9430 @example
9431 void __builtin_arc_vst128 (__v8hi, const int, const int)
9432 void __builtin_arc_vst64 (__v8hi, const int, const int)
9433 @end example
9435 The following take a @code{__v8hi} argument and three @code{int}
9436 arguments and return no result.  The second argument must be a 3-bit
9437 compile-time constant, identifying the 16-bit sub-register to be
9438 stored, the third argument must be a 3-bit compile time constants,
9439 indicating one the registers I0-I7, and the fourth argument must be an
9440 8-bit compile time constant.
9442 @example
9443 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
9444 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
9445 @end example
9447 @node ARM iWMMXt Built-in Functions
9448 @subsection ARM iWMMXt Built-in Functions
9450 These built-in functions are available for the ARM family of
9451 processors when the @option{-mcpu=iwmmxt} switch is used:
9453 @smallexample
9454 typedef int v2si __attribute__ ((vector_size (8)));
9455 typedef short v4hi __attribute__ ((vector_size (8)));
9456 typedef char v8qi __attribute__ ((vector_size (8)));
9458 int __builtin_arm_getwcgr0 (void)
9459 void __builtin_arm_setwcgr0 (int)
9460 int __builtin_arm_getwcgr1 (void)
9461 void __builtin_arm_setwcgr1 (int)
9462 int __builtin_arm_getwcgr2 (void)
9463 void __builtin_arm_setwcgr2 (int)
9464 int __builtin_arm_getwcgr3 (void)
9465 void __builtin_arm_setwcgr3 (int)
9466 int __builtin_arm_textrmsb (v8qi, int)
9467 int __builtin_arm_textrmsh (v4hi, int)
9468 int __builtin_arm_textrmsw (v2si, int)
9469 int __builtin_arm_textrmub (v8qi, int)
9470 int __builtin_arm_textrmuh (v4hi, int)
9471 int __builtin_arm_textrmuw (v2si, int)
9472 v8qi __builtin_arm_tinsrb (v8qi, int, int)
9473 v4hi __builtin_arm_tinsrh (v4hi, int, int)
9474 v2si __builtin_arm_tinsrw (v2si, int, int)
9475 long long __builtin_arm_tmia (long long, int, int)
9476 long long __builtin_arm_tmiabb (long long, int, int)
9477 long long __builtin_arm_tmiabt (long long, int, int)
9478 long long __builtin_arm_tmiaph (long long, int, int)
9479 long long __builtin_arm_tmiatb (long long, int, int)
9480 long long __builtin_arm_tmiatt (long long, int, int)
9481 int __builtin_arm_tmovmskb (v8qi)
9482 int __builtin_arm_tmovmskh (v4hi)
9483 int __builtin_arm_tmovmskw (v2si)
9484 long long __builtin_arm_waccb (v8qi)
9485 long long __builtin_arm_wacch (v4hi)
9486 long long __builtin_arm_waccw (v2si)
9487 v8qi __builtin_arm_waddb (v8qi, v8qi)
9488 v8qi __builtin_arm_waddbss (v8qi, v8qi)
9489 v8qi __builtin_arm_waddbus (v8qi, v8qi)
9490 v4hi __builtin_arm_waddh (v4hi, v4hi)
9491 v4hi __builtin_arm_waddhss (v4hi, v4hi)
9492 v4hi __builtin_arm_waddhus (v4hi, v4hi)
9493 v2si __builtin_arm_waddw (v2si, v2si)
9494 v2si __builtin_arm_waddwss (v2si, v2si)
9495 v2si __builtin_arm_waddwus (v2si, v2si)
9496 v8qi __builtin_arm_walign (v8qi, v8qi, int)
9497 long long __builtin_arm_wand(long long, long long)
9498 long long __builtin_arm_wandn (long long, long long)
9499 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
9500 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
9501 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
9502 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
9503 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
9504 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
9505 v2si __builtin_arm_wcmpeqw (v2si, v2si)
9506 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
9507 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
9508 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
9509 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
9510 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
9511 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
9512 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
9513 long long __builtin_arm_wmacsz (v4hi, v4hi)
9514 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
9515 long long __builtin_arm_wmacuz (v4hi, v4hi)
9516 v4hi __builtin_arm_wmadds (v4hi, v4hi)
9517 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
9518 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
9519 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
9520 v2si __builtin_arm_wmaxsw (v2si, v2si)
9521 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
9522 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
9523 v2si __builtin_arm_wmaxuw (v2si, v2si)
9524 v8qi __builtin_arm_wminsb (v8qi, v8qi)
9525 v4hi __builtin_arm_wminsh (v4hi, v4hi)
9526 v2si __builtin_arm_wminsw (v2si, v2si)
9527 v8qi __builtin_arm_wminub (v8qi, v8qi)
9528 v4hi __builtin_arm_wminuh (v4hi, v4hi)
9529 v2si __builtin_arm_wminuw (v2si, v2si)
9530 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
9531 v4hi __builtin_arm_wmulul (v4hi, v4hi)
9532 v4hi __builtin_arm_wmulum (v4hi, v4hi)
9533 long long __builtin_arm_wor (long long, long long)
9534 v2si __builtin_arm_wpackdss (long long, long long)
9535 v2si __builtin_arm_wpackdus (long long, long long)
9536 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
9537 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
9538 v4hi __builtin_arm_wpackwss (v2si, v2si)
9539 v4hi __builtin_arm_wpackwus (v2si, v2si)
9540 long long __builtin_arm_wrord (long long, long long)
9541 long long __builtin_arm_wrordi (long long, int)
9542 v4hi __builtin_arm_wrorh (v4hi, long long)
9543 v4hi __builtin_arm_wrorhi (v4hi, int)
9544 v2si __builtin_arm_wrorw (v2si, long long)
9545 v2si __builtin_arm_wrorwi (v2si, int)
9546 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
9547 v2si __builtin_arm_wsadbz (v8qi, v8qi)
9548 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
9549 v2si __builtin_arm_wsadhz (v4hi, v4hi)
9550 v4hi __builtin_arm_wshufh (v4hi, int)
9551 long long __builtin_arm_wslld (long long, long long)
9552 long long __builtin_arm_wslldi (long long, int)
9553 v4hi __builtin_arm_wsllh (v4hi, long long)
9554 v4hi __builtin_arm_wsllhi (v4hi, int)
9555 v2si __builtin_arm_wsllw (v2si, long long)
9556 v2si __builtin_arm_wsllwi (v2si, int)
9557 long long __builtin_arm_wsrad (long long, long long)
9558 long long __builtin_arm_wsradi (long long, int)
9559 v4hi __builtin_arm_wsrah (v4hi, long long)
9560 v4hi __builtin_arm_wsrahi (v4hi, int)
9561 v2si __builtin_arm_wsraw (v2si, long long)
9562 v2si __builtin_arm_wsrawi (v2si, int)
9563 long long __builtin_arm_wsrld (long long, long long)
9564 long long __builtin_arm_wsrldi (long long, int)
9565 v4hi __builtin_arm_wsrlh (v4hi, long long)
9566 v4hi __builtin_arm_wsrlhi (v4hi, int)
9567 v2si __builtin_arm_wsrlw (v2si, long long)
9568 v2si __builtin_arm_wsrlwi (v2si, int)
9569 v8qi __builtin_arm_wsubb (v8qi, v8qi)
9570 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
9571 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
9572 v4hi __builtin_arm_wsubh (v4hi, v4hi)
9573 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
9574 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
9575 v2si __builtin_arm_wsubw (v2si, v2si)
9576 v2si __builtin_arm_wsubwss (v2si, v2si)
9577 v2si __builtin_arm_wsubwus (v2si, v2si)
9578 v4hi __builtin_arm_wunpckehsb (v8qi)
9579 v2si __builtin_arm_wunpckehsh (v4hi)
9580 long long __builtin_arm_wunpckehsw (v2si)
9581 v4hi __builtin_arm_wunpckehub (v8qi)
9582 v2si __builtin_arm_wunpckehuh (v4hi)
9583 long long __builtin_arm_wunpckehuw (v2si)
9584 v4hi __builtin_arm_wunpckelsb (v8qi)
9585 v2si __builtin_arm_wunpckelsh (v4hi)
9586 long long __builtin_arm_wunpckelsw (v2si)
9587 v4hi __builtin_arm_wunpckelub (v8qi)
9588 v2si __builtin_arm_wunpckeluh (v4hi)
9589 long long __builtin_arm_wunpckeluw (v2si)
9590 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
9591 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
9592 v2si __builtin_arm_wunpckihw (v2si, v2si)
9593 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
9594 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
9595 v2si __builtin_arm_wunpckilw (v2si, v2si)
9596 long long __builtin_arm_wxor (long long, long long)
9597 long long __builtin_arm_wzero ()
9598 @end smallexample
9600 @node ARM NEON Intrinsics
9601 @subsection ARM NEON Intrinsics
9603 These built-in intrinsics for the ARM Advanced SIMD extension are available
9604 when the @option{-mfpu=neon} switch is used:
9606 @include arm-neon-intrinsics.texi
9608 @node AVR Built-in Functions
9609 @subsection AVR Built-in Functions
9611 For each built-in function for AVR, there is an equally named,
9612 uppercase built-in macro defined. That way users can easily query if
9613 or if not a specific built-in is implemented or not. For example, if
9614 @code{__builtin_avr_nop} is available the macro
9615 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
9617 The following built-in functions map to the respective machine
9618 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
9619 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
9620 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
9621 as library call if no hardware multiplier is available.
9623 @smallexample
9624 void __builtin_avr_nop (void)
9625 void __builtin_avr_sei (void)
9626 void __builtin_avr_cli (void)
9627 void __builtin_avr_sleep (void)
9628 void __builtin_avr_wdr (void)
9629 unsigned char __builtin_avr_swap (unsigned char)
9630 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9631 int __builtin_avr_fmuls (char, char)
9632 int __builtin_avr_fmulsu (char, unsigned char)
9633 @end smallexample
9635 In order to delay execution for a specific number of cycles, GCC
9636 implements
9637 @smallexample
9638 void __builtin_avr_delay_cycles (unsigned long ticks)
9639 @end smallexample
9641 @noindent
9642 @code{ticks} is the number of ticks to delay execution. Note that this
9643 built-in does not take into account the effect of interrupts that
9644 might increase delay time. @code{ticks} must be a compile-time
9645 integer constant; delays with a variable number of cycles are not supported.
9647 @smallexample
9648 char __builtin_avr_flash_segment (const __memx void*)
9649 @end smallexample
9651 @noindent
9652 This built-in takes a byte address to the 24-bit
9653 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9654 the number of the flash segment (the 64 KiB chunk) where the address
9655 points to.  Counting starts at @code{0}.
9656 If the address does not point to flash memory, return @code{-1}.
9658 @smallexample
9659 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9660 @end smallexample
9662 @noindent
9663 Insert bits from @var{bits} into @var{val} and return the resulting
9664 value. The nibbles of @var{map} determine how the insertion is
9665 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9666 @enumerate
9667 @item If @var{X} is @code{0xf},
9668 then the @var{n}-th bit of @var{val} is returned unaltered.
9670 @item If X is in the range 0@dots{}7,
9671 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9673 @item If X is in the range 8@dots{}@code{0xe},
9674 then the @var{n}-th result bit is undefined.
9675 @end enumerate
9677 @noindent
9678 One typical use case for this built-in is adjusting input and
9679 output values to non-contiguous port layouts. Some examples:
9681 @smallexample
9682 // same as val, bits is unused
9683 __builtin_avr_insert_bits (0xffffffff, bits, val)
9684 @end smallexample
9686 @smallexample
9687 // same as bits, val is unused
9688 __builtin_avr_insert_bits (0x76543210, bits, val)
9689 @end smallexample
9691 @smallexample
9692 // same as rotating bits by 4
9693 __builtin_avr_insert_bits (0x32107654, bits, 0)
9694 @end smallexample
9696 @smallexample
9697 // high nibble of result is the high nibble of val
9698 // low nibble of result is the low nibble of bits
9699 __builtin_avr_insert_bits (0xffff3210, bits, val)
9700 @end smallexample
9702 @smallexample
9703 // reverse the bit order of bits
9704 __builtin_avr_insert_bits (0x01234567, bits, 0)
9705 @end smallexample
9707 @node Blackfin Built-in Functions
9708 @subsection Blackfin Built-in Functions
9710 Currently, there are two Blackfin-specific built-in functions.  These are
9711 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9712 using inline assembly; by using these built-in functions the compiler can
9713 automatically add workarounds for hardware errata involving these
9714 instructions.  These functions are named as follows:
9716 @smallexample
9717 void __builtin_bfin_csync (void)
9718 void __builtin_bfin_ssync (void)
9719 @end smallexample
9721 @node FR-V Built-in Functions
9722 @subsection FR-V Built-in Functions
9724 GCC provides many FR-V-specific built-in functions.  In general,
9725 these functions are intended to be compatible with those described
9726 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9727 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
9728 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9729 pointer rather than by value.
9731 Most of the functions are named after specific FR-V instructions.
9732 Such functions are said to be ``directly mapped'' and are summarized
9733 here in tabular form.
9735 @menu
9736 * Argument Types::
9737 * Directly-mapped Integer Functions::
9738 * Directly-mapped Media Functions::
9739 * Raw read/write Functions::
9740 * Other Built-in Functions::
9741 @end menu
9743 @node Argument Types
9744 @subsubsection Argument Types
9746 The arguments to the built-in functions can be divided into three groups:
9747 register numbers, compile-time constants and run-time values.  In order
9748 to make this classification clear at a glance, the arguments and return
9749 values are given the following pseudo types:
9751 @multitable @columnfractions .20 .30 .15 .35
9752 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9753 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9754 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9755 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9756 @item @code{uw2} @tab @code{unsigned long long} @tab No
9757 @tab an unsigned doubleword
9758 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9759 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9760 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9761 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9762 @end multitable
9764 These pseudo types are not defined by GCC, they are simply a notational
9765 convenience used in this manual.
9767 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9768 and @code{sw2} are evaluated at run time.  They correspond to
9769 register operands in the underlying FR-V instructions.
9771 @code{const} arguments represent immediate operands in the underlying
9772 FR-V instructions.  They must be compile-time constants.
9774 @code{acc} arguments are evaluated at compile time and specify the number
9775 of an accumulator register.  For example, an @code{acc} argument of 2
9776 selects the ACC2 register.
9778 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9779 number of an IACC register.  See @pxref{Other Built-in Functions}
9780 for more details.
9782 @node Directly-mapped Integer Functions
9783 @subsubsection Directly-mapped Integer Functions
9785 The functions listed below map directly to FR-V I-type instructions.
9787 @multitable @columnfractions .45 .32 .23
9788 @item Function prototype @tab Example usage @tab Assembly output
9789 @item @code{sw1 __ADDSS (sw1, sw1)}
9790 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9791 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9792 @item @code{sw1 __SCAN (sw1, sw1)}
9793 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9794 @tab @code{SCAN @var{a},@var{b},@var{c}}
9795 @item @code{sw1 __SCUTSS (sw1)}
9796 @tab @code{@var{b} = __SCUTSS (@var{a})}
9797 @tab @code{SCUTSS @var{a},@var{b}}
9798 @item @code{sw1 __SLASS (sw1, sw1)}
9799 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9800 @tab @code{SLASS @var{a},@var{b},@var{c}}
9801 @item @code{void __SMASS (sw1, sw1)}
9802 @tab @code{__SMASS (@var{a}, @var{b})}
9803 @tab @code{SMASS @var{a},@var{b}}
9804 @item @code{void __SMSSS (sw1, sw1)}
9805 @tab @code{__SMSSS (@var{a}, @var{b})}
9806 @tab @code{SMSSS @var{a},@var{b}}
9807 @item @code{void __SMU (sw1, sw1)}
9808 @tab @code{__SMU (@var{a}, @var{b})}
9809 @tab @code{SMU @var{a},@var{b}}
9810 @item @code{sw2 __SMUL (sw1, sw1)}
9811 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9812 @tab @code{SMUL @var{a},@var{b},@var{c}}
9813 @item @code{sw1 __SUBSS (sw1, sw1)}
9814 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9815 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9816 @item @code{uw2 __UMUL (uw1, uw1)}
9817 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9818 @tab @code{UMUL @var{a},@var{b},@var{c}}
9819 @end multitable
9821 @node Directly-mapped Media Functions
9822 @subsubsection Directly-mapped Media Functions
9824 The functions listed below map directly to FR-V M-type instructions.
9826 @multitable @columnfractions .45 .32 .23
9827 @item Function prototype @tab Example usage @tab Assembly output
9828 @item @code{uw1 __MABSHS (sw1)}
9829 @tab @code{@var{b} = __MABSHS (@var{a})}
9830 @tab @code{MABSHS @var{a},@var{b}}
9831 @item @code{void __MADDACCS (acc, acc)}
9832 @tab @code{__MADDACCS (@var{b}, @var{a})}
9833 @tab @code{MADDACCS @var{a},@var{b}}
9834 @item @code{sw1 __MADDHSS (sw1, sw1)}
9835 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9836 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9837 @item @code{uw1 __MADDHUS (uw1, uw1)}
9838 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9839 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9840 @item @code{uw1 __MAND (uw1, uw1)}
9841 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9842 @tab @code{MAND @var{a},@var{b},@var{c}}
9843 @item @code{void __MASACCS (acc, acc)}
9844 @tab @code{__MASACCS (@var{b}, @var{a})}
9845 @tab @code{MASACCS @var{a},@var{b}}
9846 @item @code{uw1 __MAVEH (uw1, uw1)}
9847 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9848 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9849 @item @code{uw2 __MBTOH (uw1)}
9850 @tab @code{@var{b} = __MBTOH (@var{a})}
9851 @tab @code{MBTOH @var{a},@var{b}}
9852 @item @code{void __MBTOHE (uw1 *, uw1)}
9853 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9854 @tab @code{MBTOHE @var{a},@var{b}}
9855 @item @code{void __MCLRACC (acc)}
9856 @tab @code{__MCLRACC (@var{a})}
9857 @tab @code{MCLRACC @var{a}}
9858 @item @code{void __MCLRACCA (void)}
9859 @tab @code{__MCLRACCA ()}
9860 @tab @code{MCLRACCA}
9861 @item @code{uw1 __Mcop1 (uw1, uw1)}
9862 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9863 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9864 @item @code{uw1 __Mcop2 (uw1, uw1)}
9865 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9866 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9867 @item @code{uw1 __MCPLHI (uw2, const)}
9868 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9869 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9870 @item @code{uw1 __MCPLI (uw2, const)}
9871 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9872 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9873 @item @code{void __MCPXIS (acc, sw1, sw1)}
9874 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9875 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9876 @item @code{void __MCPXIU (acc, uw1, uw1)}
9877 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9878 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9879 @item @code{void __MCPXRS (acc, sw1, sw1)}
9880 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9881 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9882 @item @code{void __MCPXRU (acc, uw1, uw1)}
9883 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9884 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9885 @item @code{uw1 __MCUT (acc, uw1)}
9886 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9887 @tab @code{MCUT @var{a},@var{b},@var{c}}
9888 @item @code{uw1 __MCUTSS (acc, sw1)}
9889 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9890 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9891 @item @code{void __MDADDACCS (acc, acc)}
9892 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9893 @tab @code{MDADDACCS @var{a},@var{b}}
9894 @item @code{void __MDASACCS (acc, acc)}
9895 @tab @code{__MDASACCS (@var{b}, @var{a})}
9896 @tab @code{MDASACCS @var{a},@var{b}}
9897 @item @code{uw2 __MDCUTSSI (acc, const)}
9898 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
9899 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
9900 @item @code{uw2 __MDPACKH (uw2, uw2)}
9901 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
9902 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
9903 @item @code{uw2 __MDROTLI (uw2, const)}
9904 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
9905 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
9906 @item @code{void __MDSUBACCS (acc, acc)}
9907 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
9908 @tab @code{MDSUBACCS @var{a},@var{b}}
9909 @item @code{void __MDUNPACKH (uw1 *, uw2)}
9910 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
9911 @tab @code{MDUNPACKH @var{a},@var{b}}
9912 @item @code{uw2 __MEXPDHD (uw1, const)}
9913 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
9914 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
9915 @item @code{uw1 __MEXPDHW (uw1, const)}
9916 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
9917 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
9918 @item @code{uw1 __MHDSETH (uw1, const)}
9919 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
9920 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
9921 @item @code{sw1 __MHDSETS (const)}
9922 @tab @code{@var{b} = __MHDSETS (@var{a})}
9923 @tab @code{MHDSETS #@var{a},@var{b}}
9924 @item @code{uw1 __MHSETHIH (uw1, const)}
9925 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
9926 @tab @code{MHSETHIH #@var{a},@var{b}}
9927 @item @code{sw1 __MHSETHIS (sw1, const)}
9928 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
9929 @tab @code{MHSETHIS #@var{a},@var{b}}
9930 @item @code{uw1 __MHSETLOH (uw1, const)}
9931 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
9932 @tab @code{MHSETLOH #@var{a},@var{b}}
9933 @item @code{sw1 __MHSETLOS (sw1, const)}
9934 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
9935 @tab @code{MHSETLOS #@var{a},@var{b}}
9936 @item @code{uw1 __MHTOB (uw2)}
9937 @tab @code{@var{b} = __MHTOB (@var{a})}
9938 @tab @code{MHTOB @var{a},@var{b}}
9939 @item @code{void __MMACHS (acc, sw1, sw1)}
9940 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
9941 @tab @code{MMACHS @var{a},@var{b},@var{c}}
9942 @item @code{void __MMACHU (acc, uw1, uw1)}
9943 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
9944 @tab @code{MMACHU @var{a},@var{b},@var{c}}
9945 @item @code{void __MMRDHS (acc, sw1, sw1)}
9946 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
9947 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
9948 @item @code{void __MMRDHU (acc, uw1, uw1)}
9949 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
9950 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
9951 @item @code{void __MMULHS (acc, sw1, sw1)}
9952 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
9953 @tab @code{MMULHS @var{a},@var{b},@var{c}}
9954 @item @code{void __MMULHU (acc, uw1, uw1)}
9955 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
9956 @tab @code{MMULHU @var{a},@var{b},@var{c}}
9957 @item @code{void __MMULXHS (acc, sw1, sw1)}
9958 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
9959 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
9960 @item @code{void __MMULXHU (acc, uw1, uw1)}
9961 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
9962 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
9963 @item @code{uw1 __MNOT (uw1)}
9964 @tab @code{@var{b} = __MNOT (@var{a})}
9965 @tab @code{MNOT @var{a},@var{b}}
9966 @item @code{uw1 __MOR (uw1, uw1)}
9967 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
9968 @tab @code{MOR @var{a},@var{b},@var{c}}
9969 @item @code{uw1 __MPACKH (uh, uh)}
9970 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
9971 @tab @code{MPACKH @var{a},@var{b},@var{c}}
9972 @item @code{sw2 __MQADDHSS (sw2, sw2)}
9973 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
9974 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
9975 @item @code{uw2 __MQADDHUS (uw2, uw2)}
9976 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
9977 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
9978 @item @code{void __MQCPXIS (acc, sw2, sw2)}
9979 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
9980 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
9981 @item @code{void __MQCPXIU (acc, uw2, uw2)}
9982 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
9983 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
9984 @item @code{void __MQCPXRS (acc, sw2, sw2)}
9985 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
9986 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
9987 @item @code{void __MQCPXRU (acc, uw2, uw2)}
9988 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
9989 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
9990 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
9991 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
9992 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
9993 @item @code{sw2 __MQLMTHS (sw2, sw2)}
9994 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
9995 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
9996 @item @code{void __MQMACHS (acc, sw2, sw2)}
9997 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
9998 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
9999 @item @code{void __MQMACHU (acc, uw2, uw2)}
10000 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10001 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10002 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10003 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10004 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10005 @item @code{void __MQMULHS (acc, sw2, sw2)}
10006 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10007 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10008 @item @code{void __MQMULHU (acc, uw2, uw2)}
10009 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10010 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10011 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10012 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10013 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10014 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10015 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10016 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10017 @item @code{sw2 __MQSATHS (sw2, sw2)}
10018 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10019 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10020 @item @code{uw2 __MQSLLHI (uw2, int)}
10021 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10022 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10023 @item @code{sw2 __MQSRAHI (sw2, int)}
10024 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10025 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10026 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10027 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10028 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10029 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10030 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10031 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10032 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10033 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10034 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10035 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10036 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10037 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10038 @item @code{uw1 __MRDACC (acc)}
10039 @tab @code{@var{b} = __MRDACC (@var{a})}
10040 @tab @code{MRDACC @var{a},@var{b}}
10041 @item @code{uw1 __MRDACCG (acc)}
10042 @tab @code{@var{b} = __MRDACCG (@var{a})}
10043 @tab @code{MRDACCG @var{a},@var{b}}
10044 @item @code{uw1 __MROTLI (uw1, const)}
10045 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10046 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10047 @item @code{uw1 __MROTRI (uw1, const)}
10048 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10049 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10050 @item @code{sw1 __MSATHS (sw1, sw1)}
10051 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10052 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10053 @item @code{uw1 __MSATHU (uw1, uw1)}
10054 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10055 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10056 @item @code{uw1 __MSLLHI (uw1, const)}
10057 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10058 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10059 @item @code{sw1 __MSRAHI (sw1, const)}
10060 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10061 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10062 @item @code{uw1 __MSRLHI (uw1, const)}
10063 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10064 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10065 @item @code{void __MSUBACCS (acc, acc)}
10066 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10067 @tab @code{MSUBACCS @var{a},@var{b}}
10068 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10069 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10070 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10071 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10072 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10073 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10074 @item @code{void __MTRAP (void)}
10075 @tab @code{__MTRAP ()}
10076 @tab @code{MTRAP}
10077 @item @code{uw2 __MUNPACKH (uw1)}
10078 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10079 @tab @code{MUNPACKH @var{a},@var{b}}
10080 @item @code{uw1 __MWCUT (uw2, uw1)}
10081 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10082 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10083 @item @code{void __MWTACC (acc, uw1)}
10084 @tab @code{__MWTACC (@var{b}, @var{a})}
10085 @tab @code{MWTACC @var{a},@var{b}}
10086 @item @code{void __MWTACCG (acc, uw1)}
10087 @tab @code{__MWTACCG (@var{b}, @var{a})}
10088 @tab @code{MWTACCG @var{a},@var{b}}
10089 @item @code{uw1 __MXOR (uw1, uw1)}
10090 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
10091 @tab @code{MXOR @var{a},@var{b},@var{c}}
10092 @end multitable
10094 @node Raw read/write Functions
10095 @subsubsection Raw read/write Functions
10097 This sections describes built-in functions related to read and write
10098 instructions to access memory.  These functions generate
10099 @code{membar} instructions to flush the I/O load and stores where
10100 appropriate, as described in Fujitsu's manual described above.
10102 @table @code
10104 @item unsigned char __builtin_read8 (void *@var{data})
10105 @item unsigned short __builtin_read16 (void *@var{data})
10106 @item unsigned long __builtin_read32 (void *@var{data})
10107 @item unsigned long long __builtin_read64 (void *@var{data})
10109 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
10110 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
10111 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
10112 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
10113 @end table
10115 @node Other Built-in Functions
10116 @subsubsection Other Built-in Functions
10118 This section describes built-in functions that are not named after
10119 a specific FR-V instruction.
10121 @table @code
10122 @item sw2 __IACCreadll (iacc @var{reg})
10123 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
10124 for future expansion and must be 0.
10126 @item sw1 __IACCreadl (iacc @var{reg})
10127 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
10128 Other values of @var{reg} are rejected as invalid.
10130 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
10131 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
10132 is reserved for future expansion and must be 0.
10134 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
10135 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
10136 is 1.  Other values of @var{reg} are rejected as invalid.
10138 @item void __data_prefetch0 (const void *@var{x})
10139 Use the @code{dcpl} instruction to load the contents of address @var{x}
10140 into the data cache.
10142 @item void __data_prefetch (const void *@var{x})
10143 Use the @code{nldub} instruction to load the contents of address @var{x}
10144 into the data cache.  The instruction is issued in slot I1@.
10145 @end table
10147 @node X86 Built-in Functions
10148 @subsection X86 Built-in Functions
10150 These built-in functions are available for the i386 and x86-64 family
10151 of computers, depending on the command-line switches used.
10153 If you specify command-line switches such as @option{-msse},
10154 the compiler could use the extended instruction sets even if the built-ins
10155 are not used explicitly in the program.  For this reason, applications
10156 that perform run-time CPU detection must compile separate files for each
10157 supported architecture, using the appropriate flags.  In particular,
10158 the file containing the CPU detection code should be compiled without
10159 these options.
10161 The following machine modes are available for use with MMX built-in functions
10162 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
10163 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
10164 vector of eight 8-bit integers.  Some of the built-in functions operate on
10165 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
10167 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
10168 of two 32-bit floating-point values.
10170 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
10171 floating-point values.  Some instructions use a vector of four 32-bit
10172 integers, these use @code{V4SI}.  Finally, some instructions operate on an
10173 entire vector register, interpreting it as a 128-bit integer, these use mode
10174 @code{TI}.
10176 In 64-bit mode, the x86-64 family of processors uses additional built-in
10177 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
10178 floating point and @code{TC} 128-bit complex floating-point values.
10180 The following floating-point built-in functions are available in 64-bit
10181 mode.  All of them implement the function that is part of the name.
10183 @smallexample
10184 __float128 __builtin_fabsq (__float128)
10185 __float128 __builtin_copysignq (__float128, __float128)
10186 @end smallexample
10188 The following built-in function is always available.
10190 @table @code
10191 @item void __builtin_ia32_pause (void)
10192 Generates the @code{pause} machine instruction with a compiler memory
10193 barrier.
10194 @end table
10196 The following floating-point built-in functions are made available in the
10197 64-bit mode.
10199 @table @code
10200 @item __float128 __builtin_infq (void)
10201 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
10202 @findex __builtin_infq
10204 @item __float128 __builtin_huge_valq (void)
10205 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
10206 @findex __builtin_huge_valq
10207 @end table
10209 The following built-in functions are always available and can be used to
10210 check the target platform type.
10212 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
10213 This function runs the CPU detection code to check the type of CPU and the
10214 features supported.  This built-in function needs to be invoked along with the built-in functions
10215 to check CPU type and features, @code{__builtin_cpu_is} and
10216 @code{__builtin_cpu_supports}, only when used in a function that is
10217 executed before any constructors are called.  The CPU detection code is
10218 automatically executed in a very high priority constructor.
10220 For example, this function has to be used in @code{ifunc} resolvers that
10221 check for CPU type using the built-in functions @code{__builtin_cpu_is}
10222 and @code{__builtin_cpu_supports}, or in constructors on targets that
10223 don't support constructor priority.
10224 @smallexample
10226 static void (*resolve_memcpy (void)) (void)
10228   // ifunc resolvers fire before constructors, explicitly call the init
10229   // function.
10230   __builtin_cpu_init ();
10231   if (__builtin_cpu_supports ("ssse3"))
10232     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
10233   else
10234     return default_memcpy;
10237 void *memcpy (void *, const void *, size_t)
10238      __attribute__ ((ifunc ("resolve_memcpy")));
10239 @end smallexample
10241 @end deftypefn
10243 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
10244 This function returns a positive integer if the run-time CPU
10245 is of type @var{cpuname}
10246 and returns @code{0} otherwise. The following CPU names can be detected:
10248 @table @samp
10249 @item intel
10250 Intel CPU.
10252 @item atom
10253 Intel Atom CPU.
10255 @item core2
10256 Intel Core 2 CPU.
10258 @item corei7
10259 Intel Core i7 CPU.
10261 @item nehalem
10262 Intel Core i7 Nehalem CPU.
10264 @item westmere
10265 Intel Core i7 Westmere CPU.
10267 @item sandybridge
10268 Intel Core i7 Sandy Bridge CPU.
10270 @item amd
10271 AMD CPU.
10273 @item amdfam10h
10274 AMD Family 10h CPU.
10276 @item barcelona
10277 AMD Family 10h Barcelona CPU.
10279 @item shanghai
10280 AMD Family 10h Shanghai CPU.
10282 @item istanbul
10283 AMD Family 10h Istanbul CPU.
10285 @item btver1
10286 AMD Family 14h CPU.
10288 @item amdfam15h
10289 AMD Family 15h CPU.
10291 @item bdver1
10292 AMD Family 15h Bulldozer version 1.
10294 @item bdver2
10295 AMD Family 15h Bulldozer version 2.
10297 @item bdver3
10298 AMD Family 15h Bulldozer version 3.
10300 @item btver2
10301 AMD Family 16h CPU.
10302 @end table
10304 Here is an example:
10305 @smallexample
10306 if (__builtin_cpu_is ("corei7"))
10307   @{
10308      do_corei7 (); // Core i7 specific implementation.
10309   @}
10310 else
10311   @{
10312      do_generic (); // Generic implementation.
10313   @}
10314 @end smallexample
10315 @end deftypefn
10317 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
10318 This function returns a positive integer if the run-time CPU
10319 supports @var{feature}
10320 and returns @code{0} otherwise. The following features can be detected:
10322 @table @samp
10323 @item cmov
10324 CMOV instruction.
10325 @item mmx
10326 MMX instructions.
10327 @item popcnt
10328 POPCNT instruction.
10329 @item sse
10330 SSE instructions.
10331 @item sse2
10332 SSE2 instructions.
10333 @item sse3
10334 SSE3 instructions.
10335 @item ssse3
10336 SSSE3 instructions.
10337 @item sse4.1
10338 SSE4.1 instructions.
10339 @item sse4.2
10340 SSE4.2 instructions.
10341 @item avx
10342 AVX instructions.
10343 @item avx2
10344 AVX2 instructions.
10345 @end table
10347 Here is an example:
10348 @smallexample
10349 if (__builtin_cpu_supports ("popcnt"))
10350   @{
10351      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
10352   @}
10353 else
10354   @{
10355      count = generic_countbits (n); //generic implementation.
10356   @}
10357 @end smallexample
10358 @end deftypefn
10361 The following built-in functions are made available by @option{-mmmx}.
10362 All of them generate the machine instruction that is part of the name.
10364 @smallexample
10365 v8qi __builtin_ia32_paddb (v8qi, v8qi)
10366 v4hi __builtin_ia32_paddw (v4hi, v4hi)
10367 v2si __builtin_ia32_paddd (v2si, v2si)
10368 v8qi __builtin_ia32_psubb (v8qi, v8qi)
10369 v4hi __builtin_ia32_psubw (v4hi, v4hi)
10370 v2si __builtin_ia32_psubd (v2si, v2si)
10371 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
10372 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
10373 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
10374 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
10375 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
10376 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
10377 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
10378 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
10379 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
10380 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
10381 di __builtin_ia32_pand (di, di)
10382 di __builtin_ia32_pandn (di,di)
10383 di __builtin_ia32_por (di, di)
10384 di __builtin_ia32_pxor (di, di)
10385 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
10386 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
10387 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
10388 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
10389 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
10390 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
10391 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
10392 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
10393 v2si __builtin_ia32_punpckhdq (v2si, v2si)
10394 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
10395 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
10396 v2si __builtin_ia32_punpckldq (v2si, v2si)
10397 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
10398 v4hi __builtin_ia32_packssdw (v2si, v2si)
10399 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
10401 v4hi __builtin_ia32_psllw (v4hi, v4hi)
10402 v2si __builtin_ia32_pslld (v2si, v2si)
10403 v1di __builtin_ia32_psllq (v1di, v1di)
10404 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
10405 v2si __builtin_ia32_psrld (v2si, v2si)
10406 v1di __builtin_ia32_psrlq (v1di, v1di)
10407 v4hi __builtin_ia32_psraw (v4hi, v4hi)
10408 v2si __builtin_ia32_psrad (v2si, v2si)
10409 v4hi __builtin_ia32_psllwi (v4hi, int)
10410 v2si __builtin_ia32_pslldi (v2si, int)
10411 v1di __builtin_ia32_psllqi (v1di, int)
10412 v4hi __builtin_ia32_psrlwi (v4hi, int)
10413 v2si __builtin_ia32_psrldi (v2si, int)
10414 v1di __builtin_ia32_psrlqi (v1di, int)
10415 v4hi __builtin_ia32_psrawi (v4hi, int)
10416 v2si __builtin_ia32_psradi (v2si, int)
10418 @end smallexample
10420 The following built-in functions are made available either with
10421 @option{-msse}, or with a combination of @option{-m3dnow} and
10422 @option{-march=athlon}.  All of them generate the machine
10423 instruction that is part of the name.
10425 @smallexample
10426 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
10427 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
10428 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
10429 v1di __builtin_ia32_psadbw (v8qi, v8qi)
10430 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
10431 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
10432 v8qi __builtin_ia32_pminub (v8qi, v8qi)
10433 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
10434 int __builtin_ia32_pmovmskb (v8qi)
10435 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
10436 void __builtin_ia32_movntq (di *, di)
10437 void __builtin_ia32_sfence (void)
10438 @end smallexample
10440 The following built-in functions are available when @option{-msse} is used.
10441 All of them generate the machine instruction that is part of the name.
10443 @smallexample
10444 int __builtin_ia32_comieq (v4sf, v4sf)
10445 int __builtin_ia32_comineq (v4sf, v4sf)
10446 int __builtin_ia32_comilt (v4sf, v4sf)
10447 int __builtin_ia32_comile (v4sf, v4sf)
10448 int __builtin_ia32_comigt (v4sf, v4sf)
10449 int __builtin_ia32_comige (v4sf, v4sf)
10450 int __builtin_ia32_ucomieq (v4sf, v4sf)
10451 int __builtin_ia32_ucomineq (v4sf, v4sf)
10452 int __builtin_ia32_ucomilt (v4sf, v4sf)
10453 int __builtin_ia32_ucomile (v4sf, v4sf)
10454 int __builtin_ia32_ucomigt (v4sf, v4sf)
10455 int __builtin_ia32_ucomige (v4sf, v4sf)
10456 v4sf __builtin_ia32_addps (v4sf, v4sf)
10457 v4sf __builtin_ia32_subps (v4sf, v4sf)
10458 v4sf __builtin_ia32_mulps (v4sf, v4sf)
10459 v4sf __builtin_ia32_divps (v4sf, v4sf)
10460 v4sf __builtin_ia32_addss (v4sf, v4sf)
10461 v4sf __builtin_ia32_subss (v4sf, v4sf)
10462 v4sf __builtin_ia32_mulss (v4sf, v4sf)
10463 v4sf __builtin_ia32_divss (v4sf, v4sf)
10464 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
10465 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
10466 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
10467 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
10468 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
10469 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
10470 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
10471 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
10472 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
10473 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
10474 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
10475 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
10476 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
10477 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
10478 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
10479 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
10480 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
10481 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
10482 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
10483 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
10484 v4sf __builtin_ia32_maxps (v4sf, v4sf)
10485 v4sf __builtin_ia32_maxss (v4sf, v4sf)
10486 v4sf __builtin_ia32_minps (v4sf, v4sf)
10487 v4sf __builtin_ia32_minss (v4sf, v4sf)
10488 v4sf __builtin_ia32_andps (v4sf, v4sf)
10489 v4sf __builtin_ia32_andnps (v4sf, v4sf)
10490 v4sf __builtin_ia32_orps (v4sf, v4sf)
10491 v4sf __builtin_ia32_xorps (v4sf, v4sf)
10492 v4sf __builtin_ia32_movss (v4sf, v4sf)
10493 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
10494 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
10495 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
10496 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
10497 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
10498 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
10499 v2si __builtin_ia32_cvtps2pi (v4sf)
10500 int __builtin_ia32_cvtss2si (v4sf)
10501 v2si __builtin_ia32_cvttps2pi (v4sf)
10502 int __builtin_ia32_cvttss2si (v4sf)
10503 v4sf __builtin_ia32_rcpps (v4sf)
10504 v4sf __builtin_ia32_rsqrtps (v4sf)
10505 v4sf __builtin_ia32_sqrtps (v4sf)
10506 v4sf __builtin_ia32_rcpss (v4sf)
10507 v4sf __builtin_ia32_rsqrtss (v4sf)
10508 v4sf __builtin_ia32_sqrtss (v4sf)
10509 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
10510 void __builtin_ia32_movntps (float *, v4sf)
10511 int __builtin_ia32_movmskps (v4sf)
10512 @end smallexample
10514 The following built-in functions are available when @option{-msse} is used.
10516 @table @code
10517 @item v4sf __builtin_ia32_loadups (float *)
10518 Generates the @code{movups} machine instruction as a load from memory.
10519 @item void __builtin_ia32_storeups (float *, v4sf)
10520 Generates the @code{movups} machine instruction as a store to memory.
10521 @item v4sf __builtin_ia32_loadss (float *)
10522 Generates the @code{movss} machine instruction as a load from memory.
10523 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
10524 Generates the @code{movhps} machine instruction as a load from memory.
10525 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
10526 Generates the @code{movlps} machine instruction as a load from memory
10527 @item void __builtin_ia32_storehps (v2sf *, v4sf)
10528 Generates the @code{movhps} machine instruction as a store to memory.
10529 @item void __builtin_ia32_storelps (v2sf *, v4sf)
10530 Generates the @code{movlps} machine instruction as a store to memory.
10531 @end table
10533 The following built-in functions are available when @option{-msse2} is used.
10534 All of them generate the machine instruction that is part of the name.
10536 @smallexample
10537 int __builtin_ia32_comisdeq (v2df, v2df)
10538 int __builtin_ia32_comisdlt (v2df, v2df)
10539 int __builtin_ia32_comisdle (v2df, v2df)
10540 int __builtin_ia32_comisdgt (v2df, v2df)
10541 int __builtin_ia32_comisdge (v2df, v2df)
10542 int __builtin_ia32_comisdneq (v2df, v2df)
10543 int __builtin_ia32_ucomisdeq (v2df, v2df)
10544 int __builtin_ia32_ucomisdlt (v2df, v2df)
10545 int __builtin_ia32_ucomisdle (v2df, v2df)
10546 int __builtin_ia32_ucomisdgt (v2df, v2df)
10547 int __builtin_ia32_ucomisdge (v2df, v2df)
10548 int __builtin_ia32_ucomisdneq (v2df, v2df)
10549 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
10550 v2df __builtin_ia32_cmpltpd (v2df, v2df)
10551 v2df __builtin_ia32_cmplepd (v2df, v2df)
10552 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
10553 v2df __builtin_ia32_cmpgepd (v2df, v2df)
10554 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
10555 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
10556 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
10557 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
10558 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
10559 v2df __builtin_ia32_cmpngepd (v2df, v2df)
10560 v2df __builtin_ia32_cmpordpd (v2df, v2df)
10561 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
10562 v2df __builtin_ia32_cmpltsd (v2df, v2df)
10563 v2df __builtin_ia32_cmplesd (v2df, v2df)
10564 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
10565 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
10566 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
10567 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
10568 v2df __builtin_ia32_cmpordsd (v2df, v2df)
10569 v2di __builtin_ia32_paddq (v2di, v2di)
10570 v2di __builtin_ia32_psubq (v2di, v2di)
10571 v2df __builtin_ia32_addpd (v2df, v2df)
10572 v2df __builtin_ia32_subpd (v2df, v2df)
10573 v2df __builtin_ia32_mulpd (v2df, v2df)
10574 v2df __builtin_ia32_divpd (v2df, v2df)
10575 v2df __builtin_ia32_addsd (v2df, v2df)
10576 v2df __builtin_ia32_subsd (v2df, v2df)
10577 v2df __builtin_ia32_mulsd (v2df, v2df)
10578 v2df __builtin_ia32_divsd (v2df, v2df)
10579 v2df __builtin_ia32_minpd (v2df, v2df)
10580 v2df __builtin_ia32_maxpd (v2df, v2df)
10581 v2df __builtin_ia32_minsd (v2df, v2df)
10582 v2df __builtin_ia32_maxsd (v2df, v2df)
10583 v2df __builtin_ia32_andpd (v2df, v2df)
10584 v2df __builtin_ia32_andnpd (v2df, v2df)
10585 v2df __builtin_ia32_orpd (v2df, v2df)
10586 v2df __builtin_ia32_xorpd (v2df, v2df)
10587 v2df __builtin_ia32_movsd (v2df, v2df)
10588 v2df __builtin_ia32_unpckhpd (v2df, v2df)
10589 v2df __builtin_ia32_unpcklpd (v2df, v2df)
10590 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
10591 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
10592 v4si __builtin_ia32_paddd128 (v4si, v4si)
10593 v2di __builtin_ia32_paddq128 (v2di, v2di)
10594 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
10595 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
10596 v4si __builtin_ia32_psubd128 (v4si, v4si)
10597 v2di __builtin_ia32_psubq128 (v2di, v2di)
10598 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
10599 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
10600 v2di __builtin_ia32_pand128 (v2di, v2di)
10601 v2di __builtin_ia32_pandn128 (v2di, v2di)
10602 v2di __builtin_ia32_por128 (v2di, v2di)
10603 v2di __builtin_ia32_pxor128 (v2di, v2di)
10604 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
10605 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
10606 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
10607 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
10608 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
10609 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
10610 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
10611 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
10612 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
10613 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
10614 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
10615 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
10616 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
10617 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
10618 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
10619 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
10620 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
10621 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
10622 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10623 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10624 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10625 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10626 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10627 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10628 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10629 v2df __builtin_ia32_loadupd (double *)
10630 void __builtin_ia32_storeupd (double *, v2df)
10631 v2df __builtin_ia32_loadhpd (v2df, double const *)
10632 v2df __builtin_ia32_loadlpd (v2df, double const *)
10633 int __builtin_ia32_movmskpd (v2df)
10634 int __builtin_ia32_pmovmskb128 (v16qi)
10635 void __builtin_ia32_movnti (int *, int)
10636 void __builtin_ia32_movnti64 (long long int *, long long int)
10637 void __builtin_ia32_movntpd (double *, v2df)
10638 void __builtin_ia32_movntdq (v2df *, v2df)
10639 v4si __builtin_ia32_pshufd (v4si, int)
10640 v8hi __builtin_ia32_pshuflw (v8hi, int)
10641 v8hi __builtin_ia32_pshufhw (v8hi, int)
10642 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10643 v2df __builtin_ia32_sqrtpd (v2df)
10644 v2df __builtin_ia32_sqrtsd (v2df)
10645 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10646 v2df __builtin_ia32_cvtdq2pd (v4si)
10647 v4sf __builtin_ia32_cvtdq2ps (v4si)
10648 v4si __builtin_ia32_cvtpd2dq (v2df)
10649 v2si __builtin_ia32_cvtpd2pi (v2df)
10650 v4sf __builtin_ia32_cvtpd2ps (v2df)
10651 v4si __builtin_ia32_cvttpd2dq (v2df)
10652 v2si __builtin_ia32_cvttpd2pi (v2df)
10653 v2df __builtin_ia32_cvtpi2pd (v2si)
10654 int __builtin_ia32_cvtsd2si (v2df)
10655 int __builtin_ia32_cvttsd2si (v2df)
10656 long long __builtin_ia32_cvtsd2si64 (v2df)
10657 long long __builtin_ia32_cvttsd2si64 (v2df)
10658 v4si __builtin_ia32_cvtps2dq (v4sf)
10659 v2df __builtin_ia32_cvtps2pd (v4sf)
10660 v4si __builtin_ia32_cvttps2dq (v4sf)
10661 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10662 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10663 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10664 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10665 void __builtin_ia32_clflush (const void *)
10666 void __builtin_ia32_lfence (void)
10667 void __builtin_ia32_mfence (void)
10668 v16qi __builtin_ia32_loaddqu (const char *)
10669 void __builtin_ia32_storedqu (char *, v16qi)
10670 v1di __builtin_ia32_pmuludq (v2si, v2si)
10671 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10672 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10673 v4si __builtin_ia32_pslld128 (v4si, v4si)
10674 v2di __builtin_ia32_psllq128 (v2di, v2di)
10675 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10676 v4si __builtin_ia32_psrld128 (v4si, v4si)
10677 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10678 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10679 v4si __builtin_ia32_psrad128 (v4si, v4si)
10680 v2di __builtin_ia32_pslldqi128 (v2di, int)
10681 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10682 v4si __builtin_ia32_pslldi128 (v4si, int)
10683 v2di __builtin_ia32_psllqi128 (v2di, int)
10684 v2di __builtin_ia32_psrldqi128 (v2di, int)
10685 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10686 v4si __builtin_ia32_psrldi128 (v4si, int)
10687 v2di __builtin_ia32_psrlqi128 (v2di, int)
10688 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10689 v4si __builtin_ia32_psradi128 (v4si, int)
10690 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10691 v2di __builtin_ia32_movq128 (v2di)
10692 @end smallexample
10694 The following built-in functions are available when @option{-msse3} is used.
10695 All of them generate the machine instruction that is part of the name.
10697 @smallexample
10698 v2df __builtin_ia32_addsubpd (v2df, v2df)
10699 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10700 v2df __builtin_ia32_haddpd (v2df, v2df)
10701 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10702 v2df __builtin_ia32_hsubpd (v2df, v2df)
10703 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10704 v16qi __builtin_ia32_lddqu (char const *)
10705 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10706 v4sf __builtin_ia32_movshdup (v4sf)
10707 v4sf __builtin_ia32_movsldup (v4sf)
10708 void __builtin_ia32_mwait (unsigned int, unsigned int)
10709 @end smallexample
10711 The following built-in functions are available when @option{-mssse3} is used.
10712 All of them generate the machine instruction that is part of the name.
10714 @smallexample
10715 v2si __builtin_ia32_phaddd (v2si, v2si)
10716 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10717 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10718 v2si __builtin_ia32_phsubd (v2si, v2si)
10719 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10720 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10721 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10722 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10723 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10724 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10725 v2si __builtin_ia32_psignd (v2si, v2si)
10726 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10727 v1di __builtin_ia32_palignr (v1di, v1di, int)
10728 v8qi __builtin_ia32_pabsb (v8qi)
10729 v2si __builtin_ia32_pabsd (v2si)
10730 v4hi __builtin_ia32_pabsw (v4hi)
10731 @end smallexample
10733 The following built-in functions are available when @option{-mssse3} is used.
10734 All of them generate the machine instruction that is part of the name.
10736 @smallexample
10737 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10738 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10739 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10740 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10741 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10742 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10743 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10744 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10745 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10746 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10747 v4si __builtin_ia32_psignd128 (v4si, v4si)
10748 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10749 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10750 v16qi __builtin_ia32_pabsb128 (v16qi)
10751 v4si __builtin_ia32_pabsd128 (v4si)
10752 v8hi __builtin_ia32_pabsw128 (v8hi)
10753 @end smallexample
10755 The following built-in functions are available when @option{-msse4.1} is
10756 used.  All of them generate the machine instruction that is part of the
10757 name.
10759 @smallexample
10760 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10761 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10762 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10763 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10764 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10765 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10766 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10767 v2di __builtin_ia32_movntdqa (v2di *);
10768 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10769 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10770 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10771 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10772 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10773 v8hi __builtin_ia32_phminposuw128 (v8hi)
10774 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10775 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10776 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10777 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10778 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10779 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10780 v4si __builtin_ia32_pminud128 (v4si, v4si)
10781 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10782 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10783 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10784 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10785 v2di __builtin_ia32_pmovsxdq128 (v4si)
10786 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10787 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10788 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10789 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10790 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10791 v2di __builtin_ia32_pmovzxdq128 (v4si)
10792 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10793 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10794 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10795 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10796 int __builtin_ia32_ptestc128 (v2di, v2di)
10797 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10798 int __builtin_ia32_ptestz128 (v2di, v2di)
10799 v2df __builtin_ia32_roundpd (v2df, const int)
10800 v4sf __builtin_ia32_roundps (v4sf, const int)
10801 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10802 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10803 @end smallexample
10805 The following built-in functions are available when @option{-msse4.1} is
10806 used.
10808 @table @code
10809 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10810 Generates the @code{insertps} machine instruction.
10811 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10812 Generates the @code{pextrb} machine instruction.
10813 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10814 Generates the @code{pinsrb} machine instruction.
10815 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10816 Generates the @code{pinsrd} machine instruction.
10817 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10818 Generates the @code{pinsrq} machine instruction in 64bit mode.
10819 @end table
10821 The following built-in functions are changed to generate new SSE4.1
10822 instructions when @option{-msse4.1} is used.
10824 @table @code
10825 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10826 Generates the @code{extractps} machine instruction.
10827 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10828 Generates the @code{pextrd} machine instruction.
10829 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10830 Generates the @code{pextrq} machine instruction in 64bit mode.
10831 @end table
10833 The following built-in functions are available when @option{-msse4.2} is
10834 used.  All of them generate the machine instruction that is part of the
10835 name.
10837 @smallexample
10838 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10839 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10840 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10841 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10842 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10843 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10844 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10845 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10846 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10847 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10848 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10849 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10850 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10851 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10852 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10853 @end smallexample
10855 The following built-in functions are available when @option{-msse4.2} is
10856 used.
10858 @table @code
10859 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10860 Generates the @code{crc32b} machine instruction.
10861 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10862 Generates the @code{crc32w} machine instruction.
10863 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10864 Generates the @code{crc32l} machine instruction.
10865 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10866 Generates the @code{crc32q} machine instruction.
10867 @end table
10869 The following built-in functions are changed to generate new SSE4.2
10870 instructions when @option{-msse4.2} is used.
10872 @table @code
10873 @item int __builtin_popcount (unsigned int)
10874 Generates the @code{popcntl} machine instruction.
10875 @item int __builtin_popcountl (unsigned long)
10876 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10877 depending on the size of @code{unsigned long}.
10878 @item int __builtin_popcountll (unsigned long long)
10879 Generates the @code{popcntq} machine instruction.
10880 @end table
10882 The following built-in functions are available when @option{-mavx} is
10883 used. All of them generate the machine instruction that is part of the
10884 name.
10886 @smallexample
10887 v4df __builtin_ia32_addpd256 (v4df,v4df)
10888 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10889 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10890 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10891 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10892 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10893 v4df __builtin_ia32_andpd256 (v4df,v4df)
10894 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
10895 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
10896 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
10897 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
10898 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
10899 v2df __builtin_ia32_cmppd (v2df,v2df,int)
10900 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
10901 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
10902 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
10903 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
10904 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
10905 v4df __builtin_ia32_cvtdq2pd256 (v4si)
10906 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
10907 v4si __builtin_ia32_cvtpd2dq256 (v4df)
10908 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
10909 v8si __builtin_ia32_cvtps2dq256 (v8sf)
10910 v4df __builtin_ia32_cvtps2pd256 (v4sf)
10911 v4si __builtin_ia32_cvttpd2dq256 (v4df)
10912 v8si __builtin_ia32_cvttps2dq256 (v8sf)
10913 v4df __builtin_ia32_divpd256 (v4df,v4df)
10914 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
10915 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
10916 v4df __builtin_ia32_haddpd256 (v4df,v4df)
10917 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
10918 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
10919 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
10920 v32qi __builtin_ia32_lddqu256 (pcchar)
10921 v32qi __builtin_ia32_loaddqu256 (pcchar)
10922 v4df __builtin_ia32_loadupd256 (pcdouble)
10923 v8sf __builtin_ia32_loadups256 (pcfloat)
10924 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
10925 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
10926 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
10927 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
10928 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
10929 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
10930 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
10931 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
10932 v4df __builtin_ia32_maxpd256 (v4df,v4df)
10933 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
10934 v4df __builtin_ia32_minpd256 (v4df,v4df)
10935 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
10936 v4df __builtin_ia32_movddup256 (v4df)
10937 int __builtin_ia32_movmskpd256 (v4df)
10938 int __builtin_ia32_movmskps256 (v8sf)
10939 v8sf __builtin_ia32_movshdup256 (v8sf)
10940 v8sf __builtin_ia32_movsldup256 (v8sf)
10941 v4df __builtin_ia32_mulpd256 (v4df,v4df)
10942 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
10943 v4df __builtin_ia32_orpd256 (v4df,v4df)
10944 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
10945 v2df __builtin_ia32_pd_pd256 (v4df)
10946 v4df __builtin_ia32_pd256_pd (v2df)
10947 v4sf __builtin_ia32_ps_ps256 (v8sf)
10948 v8sf __builtin_ia32_ps256_ps (v4sf)
10949 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
10950 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
10951 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
10952 v8sf __builtin_ia32_rcpps256 (v8sf)
10953 v4df __builtin_ia32_roundpd256 (v4df,int)
10954 v8sf __builtin_ia32_roundps256 (v8sf,int)
10955 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
10956 v8sf __builtin_ia32_rsqrtps256 (v8sf)
10957 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
10958 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
10959 v4si __builtin_ia32_si_si256 (v8si)
10960 v8si __builtin_ia32_si256_si (v4si)
10961 v4df __builtin_ia32_sqrtpd256 (v4df)
10962 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
10963 v8sf __builtin_ia32_sqrtps256 (v8sf)
10964 void __builtin_ia32_storedqu256 (pchar,v32qi)
10965 void __builtin_ia32_storeupd256 (pdouble,v4df)
10966 void __builtin_ia32_storeups256 (pfloat,v8sf)
10967 v4df __builtin_ia32_subpd256 (v4df,v4df)
10968 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
10969 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
10970 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
10971 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
10972 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
10973 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
10974 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
10975 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
10976 v4sf __builtin_ia32_vbroadcastss (pcfloat)
10977 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
10978 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
10979 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
10980 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
10981 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
10982 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
10983 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
10984 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
10985 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
10986 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
10987 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
10988 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
10989 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
10990 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
10991 v2df __builtin_ia32_vpermilpd (v2df,int)
10992 v4df __builtin_ia32_vpermilpd256 (v4df,int)
10993 v4sf __builtin_ia32_vpermilps (v4sf,int)
10994 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
10995 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
10996 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
10997 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
10998 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
10999 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11000 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11001 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11002 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11003 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11004 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11005 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11006 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11007 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11008 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11009 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11010 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11011 void __builtin_ia32_vzeroall (void)
11012 void __builtin_ia32_vzeroupper (void)
11013 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11014 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11015 @end smallexample
11017 The following built-in functions are available when @option{-mavx2} is
11018 used. All of them generate the machine instruction that is part of the
11019 name.
11021 @smallexample
11022 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
11023 v32qi __builtin_ia32_pabsb256 (v32qi)
11024 v16hi __builtin_ia32_pabsw256 (v16hi)
11025 v8si __builtin_ia32_pabsd256 (v8si)
11026 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11027 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11028 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11029 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11030 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11031 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11032 v8si __builtin_ia32_paddd256 (v8si,v8si)
11033 v4di __builtin_ia32_paddq256 (v4di,v4di)
11034 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11035 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11036 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11037 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11038 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11039 v4di __builtin_ia32_andsi256 (v4di,v4di)
11040 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11041 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11042 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11043 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11044 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11045 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11046 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11047 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11048 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11049 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11050 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11051 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11052 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11053 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11054 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11055 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11056 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11057 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11058 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11059 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11060 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11061 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11062 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11063 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11064 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11065 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11066 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11067 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11068 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11069 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11070 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11071 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11072 v8si __builtin_ia32_pminud256 (v8si,v8si)
11073 int __builtin_ia32_pmovmskb256 (v32qi)
11074 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11075 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11076 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11077 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11078 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11079 v4di __builtin_ia32_pmovsxdq256 (v4si)
11080 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11081 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11082 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11083 v8si __builtin_ia32_pmovzxwd256 (v8hi)
11084 v4di __builtin_ia32_pmovzxwq256 (v8hi)
11085 v4di __builtin_ia32_pmovzxdq256 (v4si)
11086 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
11087 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
11088 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
11089 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
11090 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
11091 v8si __builtin_ia32_pmulld256 (v8si,v8si)
11092 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
11093 v4di __builtin_ia32_por256 (v4di,v4di)
11094 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
11095 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
11096 v8si __builtin_ia32_pshufd256 (v8si,int)
11097 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
11098 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
11099 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
11100 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
11101 v8si __builtin_ia32_psignd256 (v8si,v8si)
11102 v4di __builtin_ia32_pslldqi256 (v4di,int)
11103 v16hi __builtin_ia32_psllwi256 (16hi,int)
11104 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
11105 v8si __builtin_ia32_pslldi256 (v8si,int)
11106 v8si __builtin_ia32_pslld256(v8si,v4si)
11107 v4di __builtin_ia32_psllqi256 (v4di,int)
11108 v4di __builtin_ia32_psllq256(v4di,v2di)
11109 v16hi __builtin_ia32_psrawi256 (v16hi,int)
11110 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
11111 v8si __builtin_ia32_psradi256 (v8si,int)
11112 v8si __builtin_ia32_psrad256 (v8si,v4si)
11113 v4di __builtin_ia32_psrldqi256 (v4di, int)
11114 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
11115 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
11116 v8si __builtin_ia32_psrldi256 (v8si,int)
11117 v8si __builtin_ia32_psrld256 (v8si,v4si)
11118 v4di __builtin_ia32_psrlqi256 (v4di,int)
11119 v4di __builtin_ia32_psrlq256(v4di,v2di)
11120 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
11121 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
11122 v8si __builtin_ia32_psubd256 (v8si,v8si)
11123 v4di __builtin_ia32_psubq256 (v4di,v4di)
11124 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
11125 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
11126 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
11127 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
11128 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
11129 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
11130 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
11131 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
11132 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
11133 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
11134 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
11135 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
11136 v4di __builtin_ia32_pxor256 (v4di,v4di)
11137 v4di __builtin_ia32_movntdqa256 (pv4di)
11138 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
11139 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
11140 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
11141 v4di __builtin_ia32_vbroadcastsi256 (v2di)
11142 v4si __builtin_ia32_pblendd128 (v4si,v4si)
11143 v8si __builtin_ia32_pblendd256 (v8si,v8si)
11144 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
11145 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
11146 v8si __builtin_ia32_pbroadcastd256 (v4si)
11147 v4di __builtin_ia32_pbroadcastq256 (v2di)
11148 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
11149 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
11150 v4si __builtin_ia32_pbroadcastd128 (v4si)
11151 v2di __builtin_ia32_pbroadcastq128 (v2di)
11152 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
11153 v4df __builtin_ia32_permdf256 (v4df,int)
11154 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
11155 v4di __builtin_ia32_permdi256 (v4di,int)
11156 v4di __builtin_ia32_permti256 (v4di,v4di,int)
11157 v4di __builtin_ia32_extract128i256 (v4di,int)
11158 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
11159 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
11160 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
11161 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
11162 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
11163 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
11164 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
11165 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
11166 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
11167 v8si __builtin_ia32_psllv8si (v8si,v8si)
11168 v4si __builtin_ia32_psllv4si (v4si,v4si)
11169 v4di __builtin_ia32_psllv4di (v4di,v4di)
11170 v2di __builtin_ia32_psllv2di (v2di,v2di)
11171 v8si __builtin_ia32_psrav8si (v8si,v8si)
11172 v4si __builtin_ia32_psrav4si (v4si,v4si)
11173 v8si __builtin_ia32_psrlv8si (v8si,v8si)
11174 v4si __builtin_ia32_psrlv4si (v4si,v4si)
11175 v4di __builtin_ia32_psrlv4di (v4di,v4di)
11176 v2di __builtin_ia32_psrlv2di (v2di,v2di)
11177 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
11178 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
11179 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
11180 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
11181 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
11182 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
11183 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
11184 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
11185 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
11186 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
11187 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
11188 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
11189 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
11190 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
11191 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
11192 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
11193 @end smallexample
11195 The following built-in functions are available when @option{-maes} is
11196 used.  All of them generate the machine instruction that is part of the
11197 name.
11199 @smallexample
11200 v2di __builtin_ia32_aesenc128 (v2di, v2di)
11201 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
11202 v2di __builtin_ia32_aesdec128 (v2di, v2di)
11203 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
11204 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
11205 v2di __builtin_ia32_aesimc128 (v2di)
11206 @end smallexample
11208 The following built-in function is available when @option{-mpclmul} is
11209 used.
11211 @table @code
11212 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
11213 Generates the @code{pclmulqdq} machine instruction.
11214 @end table
11216 The following built-in function is available when @option{-mfsgsbase} is
11217 used.  All of them generate the machine instruction that is part of the
11218 name.
11220 @smallexample
11221 unsigned int __builtin_ia32_rdfsbase32 (void)
11222 unsigned long long __builtin_ia32_rdfsbase64 (void)
11223 unsigned int __builtin_ia32_rdgsbase32 (void)
11224 unsigned long long __builtin_ia32_rdgsbase64 (void)
11225 void _writefsbase_u32 (unsigned int)
11226 void _writefsbase_u64 (unsigned long long)
11227 void _writegsbase_u32 (unsigned int)
11228 void _writegsbase_u64 (unsigned long long)
11229 @end smallexample
11231 The following built-in function is available when @option{-mrdrnd} is
11232 used.  All of them generate the machine instruction that is part of the
11233 name.
11235 @smallexample
11236 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
11237 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
11238 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
11239 @end smallexample
11241 The following built-in functions are available when @option{-msse4a} is used.
11242 All of them generate the machine instruction that is part of the name.
11244 @smallexample
11245 void __builtin_ia32_movntsd (double *, v2df)
11246 void __builtin_ia32_movntss (float *, v4sf)
11247 v2di __builtin_ia32_extrq  (v2di, v16qi)
11248 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
11249 v2di __builtin_ia32_insertq (v2di, v2di)
11250 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
11251 @end smallexample
11253 The following built-in functions are available when @option{-mxop} is used.
11254 @smallexample
11255 v2df __builtin_ia32_vfrczpd (v2df)
11256 v4sf __builtin_ia32_vfrczps (v4sf)
11257 v2df __builtin_ia32_vfrczsd (v2df, v2df)
11258 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
11259 v4df __builtin_ia32_vfrczpd256 (v4df)
11260 v8sf __builtin_ia32_vfrczps256 (v8sf)
11261 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
11262 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
11263 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
11264 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
11265 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
11266 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
11267 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
11268 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
11269 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
11270 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
11271 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
11272 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
11273 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
11274 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
11275 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11276 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
11277 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
11278 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
11279 v4si __builtin_ia32_vpcomequd (v4si, v4si)
11280 v2di __builtin_ia32_vpcomequq (v2di, v2di)
11281 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
11282 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11283 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
11284 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
11285 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
11286 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
11287 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
11288 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
11289 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
11290 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
11291 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
11292 v4si __builtin_ia32_vpcomged (v4si, v4si)
11293 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
11294 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
11295 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
11296 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
11297 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
11298 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
11299 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
11300 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
11301 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
11302 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
11303 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
11304 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
11305 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
11306 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
11307 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
11308 v4si __builtin_ia32_vpcomled (v4si, v4si)
11309 v2di __builtin_ia32_vpcomleq (v2di, v2di)
11310 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
11311 v4si __builtin_ia32_vpcomleud (v4si, v4si)
11312 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
11313 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
11314 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
11315 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
11316 v4si __builtin_ia32_vpcomltd (v4si, v4si)
11317 v2di __builtin_ia32_vpcomltq (v2di, v2di)
11318 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
11319 v4si __builtin_ia32_vpcomltud (v4si, v4si)
11320 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
11321 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
11322 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
11323 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
11324 v4si __builtin_ia32_vpcomned (v4si, v4si)
11325 v2di __builtin_ia32_vpcomneq (v2di, v2di)
11326 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
11327 v4si __builtin_ia32_vpcomneud (v4si, v4si)
11328 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
11329 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
11330 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
11331 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
11332 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
11333 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
11334 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
11335 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
11336 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
11337 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
11338 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
11339 v4si __builtin_ia32_vphaddbd (v16qi)
11340 v2di __builtin_ia32_vphaddbq (v16qi)
11341 v8hi __builtin_ia32_vphaddbw (v16qi)
11342 v2di __builtin_ia32_vphadddq (v4si)
11343 v4si __builtin_ia32_vphaddubd (v16qi)
11344 v2di __builtin_ia32_vphaddubq (v16qi)
11345 v8hi __builtin_ia32_vphaddubw (v16qi)
11346 v2di __builtin_ia32_vphaddudq (v4si)
11347 v4si __builtin_ia32_vphadduwd (v8hi)
11348 v2di __builtin_ia32_vphadduwq (v8hi)
11349 v4si __builtin_ia32_vphaddwd (v8hi)
11350 v2di __builtin_ia32_vphaddwq (v8hi)
11351 v8hi __builtin_ia32_vphsubbw (v16qi)
11352 v2di __builtin_ia32_vphsubdq (v4si)
11353 v4si __builtin_ia32_vphsubwd (v8hi)
11354 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
11355 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
11356 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
11357 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
11358 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
11359 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
11360 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
11361 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
11362 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
11363 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
11364 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
11365 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
11366 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
11367 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
11368 v4si __builtin_ia32_vprotd (v4si, v4si)
11369 v2di __builtin_ia32_vprotq (v2di, v2di)
11370 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
11371 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
11372 v4si __builtin_ia32_vpshad (v4si, v4si)
11373 v2di __builtin_ia32_vpshaq (v2di, v2di)
11374 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
11375 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
11376 v4si __builtin_ia32_vpshld (v4si, v4si)
11377 v2di __builtin_ia32_vpshlq (v2di, v2di)
11378 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
11379 @end smallexample
11381 The following built-in functions are available when @option{-mfma4} is used.
11382 All of them generate the machine instruction that is part of the name.
11384 @smallexample
11385 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
11386 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
11387 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
11388 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
11389 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
11390 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
11391 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
11392 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
11393 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
11394 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
11395 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
11396 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
11397 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
11398 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
11399 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
11400 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
11401 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
11402 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
11403 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
11404 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
11405 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
11406 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
11407 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
11408 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
11409 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
11410 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
11411 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
11412 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
11413 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
11414 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
11415 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
11416 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
11418 @end smallexample
11420 The following built-in functions are available when @option{-mlwp} is used.
11422 @smallexample
11423 void __builtin_ia32_llwpcb16 (void *);
11424 void __builtin_ia32_llwpcb32 (void *);
11425 void __builtin_ia32_llwpcb64 (void *);
11426 void * __builtin_ia32_llwpcb16 (void);
11427 void * __builtin_ia32_llwpcb32 (void);
11428 void * __builtin_ia32_llwpcb64 (void);
11429 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
11430 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
11431 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
11432 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
11433 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
11434 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
11435 @end smallexample
11437 The following built-in functions are available when @option{-mbmi} is used.
11438 All of them generate the machine instruction that is part of the name.
11439 @smallexample
11440 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
11441 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
11442 @end smallexample
11444 The following built-in functions are available when @option{-mbmi2} is used.
11445 All of them generate the machine instruction that is part of the name.
11446 @smallexample
11447 unsigned int _bzhi_u32 (unsigned int, unsigned int)
11448 unsigned int _pdep_u32 (unsigned int, unsigned int)
11449 unsigned int _pext_u32 (unsigned int, unsigned int)
11450 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
11451 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
11452 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
11453 @end smallexample
11455 The following built-in functions are available when @option{-mlzcnt} is used.
11456 All of them generate the machine instruction that is part of the name.
11457 @smallexample
11458 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
11459 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
11460 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
11461 @end smallexample
11463 The following built-in functions are available when @option{-mfxsr} is used.
11464 All of them generate the machine instruction that is part of the name.
11465 @smallexample
11466 void __builtin_ia32_fxsave (void *)
11467 void __builtin_ia32_fxrstor (void *)
11468 void __builtin_ia32_fxsave64 (void *)
11469 void __builtin_ia32_fxrstor64 (void *)
11470 @end smallexample
11472 The following built-in functions are available when @option{-mxsave} is used.
11473 All of them generate the machine instruction that is part of the name.
11474 @smallexample
11475 void __builtin_ia32_xsave (void *, long long)
11476 void __builtin_ia32_xrstor (void *, long long)
11477 void __builtin_ia32_xsave64 (void *, long long)
11478 void __builtin_ia32_xrstor64 (void *, long long)
11479 @end smallexample
11481 The following built-in functions are available when @option{-mxsaveopt} is used.
11482 All of them generate the machine instruction that is part of the name.
11483 @smallexample
11484 void __builtin_ia32_xsaveopt (void *, long long)
11485 void __builtin_ia32_xsaveopt64 (void *, long long)
11486 @end smallexample
11488 The following built-in functions are available when @option{-mtbm} is used.
11489 Both of them generate the immediate form of the bextr machine instruction.
11490 @smallexample
11491 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
11492 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
11493 @end smallexample
11496 The following built-in functions are available when @option{-m3dnow} is used.
11497 All of them generate the machine instruction that is part of the name.
11499 @smallexample
11500 void __builtin_ia32_femms (void)
11501 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
11502 v2si __builtin_ia32_pf2id (v2sf)
11503 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
11504 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
11505 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
11506 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
11507 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
11508 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
11509 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
11510 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
11511 v2sf __builtin_ia32_pfrcp (v2sf)
11512 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
11513 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
11514 v2sf __builtin_ia32_pfrsqrt (v2sf)
11515 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
11516 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
11517 v2sf __builtin_ia32_pi2fd (v2si)
11518 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
11519 @end smallexample
11521 The following built-in functions are available when both @option{-m3dnow}
11522 and @option{-march=athlon} are used.  All of them generate the machine
11523 instruction that is part of the name.
11525 @smallexample
11526 v2si __builtin_ia32_pf2iw (v2sf)
11527 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
11528 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
11529 v2sf __builtin_ia32_pi2fw (v2si)
11530 v2sf __builtin_ia32_pswapdsf (v2sf)
11531 v2si __builtin_ia32_pswapdsi (v2si)
11532 @end smallexample
11534 The following built-in functions are available when @option{-mrtm} is used
11535 They are used for restricted transactional memory. These are the internal
11536 low level functions. Normally the functions in 
11537 @ref{X86 transactional memory intrinsics} should be used instead.
11539 @smallexample
11540 int __builtin_ia32_xbegin ()
11541 void __builtin_ia32_xend ()
11542 void __builtin_ia32_xabort (status)
11543 int __builtin_ia32_xtest ()
11544 @end smallexample
11546 @node X86 transactional memory intrinsics
11547 @subsection X86 transaction memory intrinsics
11549 Hardware transactional memory intrinsics for i386. These allow to use
11550 memory transactions with RTM (Restricted Transactional Memory).
11551 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
11552 This support is enabled with the @option{-mrtm} option.
11554 A memory transaction commits all changes to memory in an atomic way,
11555 as visible to other threads. If the transaction fails it is rolled back
11556 and all side effects discarded.
11558 Generally there is no guarantee that a memory transaction ever succeeds
11559 and suitable fallback code always needs to be supplied.
11561 @deftypefn {RTM Function} {unsigned} _xbegin ()
11562 Start a RTM (Restricted Transactional Memory) transaction. 
11563 Returns _XBEGIN_STARTED when the transaction
11564 started successfully (note this is not 0, so the constant has to be 
11565 explicitely tested). When the transaction aborts all side effects
11566 are undone and an abort code is returned. There is no guarantee
11567 any transaction ever succeeds, so there always needs to be a valid
11568 tested fallback path.
11569 @end deftypefn
11571 @smallexample
11572 #include <immintrin.h>
11574 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
11575     ... transaction code...
11576     _xend ();
11577 @} else @{
11578     ... non transactional fallback path...
11580 @end smallexample
11582 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
11584 @table @code
11585 @item _XABORT_EXPLICIT
11586 Transaction explicitely aborted with @code{_xabort}. The parameter passed
11587 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
11588 @item _XABORT_RETRY
11589 Transaction retry is possible.
11590 @item _XABORT_CONFLICT
11591 Transaction abort due to a memory conflict with another thread
11592 @item _XABORT_CAPACITY
11593 Transaction abort due to the transaction using too much memory
11594 @item _XABORT_DEBUG
11595 Transaction abort due to a debug trap
11596 @item _XABORT_NESTED
11597 Transaction abort in a inner nested transaction
11598 @end table
11600 @deftypefn {RTM Function} {void} _xend ()
11601 Commit the current transaction. When no transaction is active this will
11602 fault. All memory side effects of the transactions will become visible
11603 to other threads in an atomic matter.
11604 @end deftypefn
11606 @deftypefn {RTM Function} {int} _xtest ()
11607 Return a value not zero when a transaction is currently active, otherwise 0.
11608 @end deftypefn
11610 @deftypefn {RTM Function} {void} _xabort (status)
11611 Abort the current transaction. When no transaction is active this is a no-op.
11612 status must be a 8bit constant, that is included in the status code returned
11613 by @code{_xbegin}
11614 @end deftypefn
11616 @node MIPS DSP Built-in Functions
11617 @subsection MIPS DSP Built-in Functions
11619 The MIPS DSP Application-Specific Extension (ASE) includes new
11620 instructions that are designed to improve the performance of DSP and
11621 media applications.  It provides instructions that operate on packed
11622 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11624 GCC supports MIPS DSP operations using both the generic
11625 vector extensions (@pxref{Vector Extensions}) and a collection of
11626 MIPS-specific built-in functions.  Both kinds of support are
11627 enabled by the @option{-mdsp} command-line option.
11629 Revision 2 of the ASE was introduced in the second half of 2006.
11630 This revision adds extra instructions to the original ASE, but is
11631 otherwise backwards-compatible with it.  You can select revision 2
11632 using the command-line option @option{-mdspr2}; this option implies
11633 @option{-mdsp}.
11635 The SCOUNT and POS bits of the DSP control register are global.  The
11636 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11637 POS bits.  During optimization, the compiler does not delete these
11638 instructions and it does not delete calls to functions containing
11639 these instructions.
11641 At present, GCC only provides support for operations on 32-bit
11642 vectors.  The vector type associated with 8-bit integer data is
11643 usually called @code{v4i8}, the vector type associated with Q7
11644 is usually called @code{v4q7}, the vector type associated with 16-bit
11645 integer data is usually called @code{v2i16}, and the vector type
11646 associated with Q15 is usually called @code{v2q15}.  They can be
11647 defined in C as follows:
11649 @smallexample
11650 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11651 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11652 typedef short v2i16 __attribute__ ((vector_size(4)));
11653 typedef short v2q15 __attribute__ ((vector_size(4)));
11654 @end smallexample
11656 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11657 initialized in the same way as aggregates.  For example:
11659 @smallexample
11660 v4i8 a = @{1, 2, 3, 4@};
11661 v4i8 b;
11662 b = (v4i8) @{5, 6, 7, 8@};
11664 v2q15 c = @{0x0fcb, 0x3a75@};
11665 v2q15 d;
11666 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11667 @end smallexample
11669 @emph{Note:} The CPU's endianness determines the order in which values
11670 are packed.  On little-endian targets, the first value is the least
11671 significant and the last value is the most significant.  The opposite
11672 order applies to big-endian targets.  For example, the code above
11673 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11674 and @code{4} on big-endian targets.
11676 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11677 representation.  As shown in this example, the integer representation
11678 of a Q7 value can be obtained by multiplying the fractional value by
11679 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
11680 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
11681 @code{0x1.0p31}.
11683 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11684 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
11685 and @code{c} and @code{d} are @code{v2q15} values.
11687 @multitable @columnfractions .50 .50
11688 @item C code @tab MIPS instruction
11689 @item @code{a + b} @tab @code{addu.qb}
11690 @item @code{c + d} @tab @code{addq.ph}
11691 @item @code{a - b} @tab @code{subu.qb}
11692 @item @code{c - d} @tab @code{subq.ph}
11693 @end multitable
11695 The table below lists the @code{v2i16} operation for which
11696 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
11697 @code{v2i16} values.
11699 @multitable @columnfractions .50 .50
11700 @item C code @tab MIPS instruction
11701 @item @code{e * f} @tab @code{mul.ph}
11702 @end multitable
11704 It is easier to describe the DSP built-in functions if we first define
11705 the following types:
11707 @smallexample
11708 typedef int q31;
11709 typedef int i32;
11710 typedef unsigned int ui32;
11711 typedef long long a64;
11712 @end smallexample
11714 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11715 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11716 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
11717 @code{long long}, but we use @code{a64} to indicate values that are
11718 placed in one of the four DSP accumulators (@code{$ac0},
11719 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11721 Also, some built-in functions prefer or require immediate numbers as
11722 parameters, because the corresponding DSP instructions accept both immediate
11723 numbers and register operands, or accept immediate numbers only.  The
11724 immediate parameters are listed as follows.
11726 @smallexample
11727 imm0_3: 0 to 3.
11728 imm0_7: 0 to 7.
11729 imm0_15: 0 to 15.
11730 imm0_31: 0 to 31.
11731 imm0_63: 0 to 63.
11732 imm0_255: 0 to 255.
11733 imm_n32_31: -32 to 31.
11734 imm_n512_511: -512 to 511.
11735 @end smallexample
11737 The following built-in functions map directly to a particular MIPS DSP
11738 instruction.  Please refer to the architecture specification
11739 for details on what each instruction does.
11741 @smallexample
11742 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11743 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11744 q31 __builtin_mips_addq_s_w (q31, q31)
11745 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11746 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11747 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11748 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11749 q31 __builtin_mips_subq_s_w (q31, q31)
11750 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11751 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11752 i32 __builtin_mips_addsc (i32, i32)
11753 i32 __builtin_mips_addwc (i32, i32)
11754 i32 __builtin_mips_modsub (i32, i32)
11755 i32 __builtin_mips_raddu_w_qb (v4i8)
11756 v2q15 __builtin_mips_absq_s_ph (v2q15)
11757 q31 __builtin_mips_absq_s_w (q31)
11758 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11759 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11760 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11761 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11762 q31 __builtin_mips_preceq_w_phl (v2q15)
11763 q31 __builtin_mips_preceq_w_phr (v2q15)
11764 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11765 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11766 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11767 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11768 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11769 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11770 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11771 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11772 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11773 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11774 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11775 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11776 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11777 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11778 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11779 q31 __builtin_mips_shll_s_w (q31, i32)
11780 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11781 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11782 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11783 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11784 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11785 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11786 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11787 q31 __builtin_mips_shra_r_w (q31, i32)
11788 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11789 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11790 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11791 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11792 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11793 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11794 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11795 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11796 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11797 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11798 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11799 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11800 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11801 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11802 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11803 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11804 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11805 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11806 i32 __builtin_mips_bitrev (i32)
11807 i32 __builtin_mips_insv (i32, i32)
11808 v4i8 __builtin_mips_repl_qb (imm0_255)
11809 v4i8 __builtin_mips_repl_qb (i32)
11810 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11811 v2q15 __builtin_mips_repl_ph (i32)
11812 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11813 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11814 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11815 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11816 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11817 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11818 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11819 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11820 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11821 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11822 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11823 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11824 i32 __builtin_mips_extr_w (a64, imm0_31)
11825 i32 __builtin_mips_extr_w (a64, i32)
11826 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11827 i32 __builtin_mips_extr_s_h (a64, i32)
11828 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11829 i32 __builtin_mips_extr_rs_w (a64, i32)
11830 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11831 i32 __builtin_mips_extr_r_w (a64, i32)
11832 i32 __builtin_mips_extp (a64, imm0_31)
11833 i32 __builtin_mips_extp (a64, i32)
11834 i32 __builtin_mips_extpdp (a64, imm0_31)
11835 i32 __builtin_mips_extpdp (a64, i32)
11836 a64 __builtin_mips_shilo (a64, imm_n32_31)
11837 a64 __builtin_mips_shilo (a64, i32)
11838 a64 __builtin_mips_mthlip (a64, i32)
11839 void __builtin_mips_wrdsp (i32, imm0_63)
11840 i32 __builtin_mips_rddsp (imm0_63)
11841 i32 __builtin_mips_lbux (void *, i32)
11842 i32 __builtin_mips_lhx (void *, i32)
11843 i32 __builtin_mips_lwx (void *, i32)
11844 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11845 i32 __builtin_mips_bposge32 (void)
11846 a64 __builtin_mips_madd (a64, i32, i32);
11847 a64 __builtin_mips_maddu (a64, ui32, ui32);
11848 a64 __builtin_mips_msub (a64, i32, i32);
11849 a64 __builtin_mips_msubu (a64, ui32, ui32);
11850 a64 __builtin_mips_mult (i32, i32);
11851 a64 __builtin_mips_multu (ui32, ui32);
11852 @end smallexample
11854 The following built-in functions map directly to a particular MIPS DSP REV 2
11855 instruction.  Please refer to the architecture specification
11856 for details on what each instruction does.
11858 @smallexample
11859 v4q7 __builtin_mips_absq_s_qb (v4q7);
11860 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11861 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11862 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11863 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11864 i32 __builtin_mips_append (i32, i32, imm0_31);
11865 i32 __builtin_mips_balign (i32, i32, imm0_3);
11866 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11867 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11868 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11869 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11870 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11871 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11872 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11873 q31 __builtin_mips_mulq_rs_w (q31, q31);
11874 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11875 q31 __builtin_mips_mulq_s_w (q31, q31);
11876 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11877 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11878 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11879 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11880 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11881 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11882 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11883 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11884 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11885 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11886 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11887 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11888 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11889 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11890 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11891 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11892 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11893 q31 __builtin_mips_addqh_w (q31, q31);
11894 q31 __builtin_mips_addqh_r_w (q31, q31);
11895 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11896 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11897 q31 __builtin_mips_subqh_w (q31, q31);
11898 q31 __builtin_mips_subqh_r_w (q31, q31);
11899 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11900 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11901 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11902 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11903 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11904 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11905 @end smallexample
11908 @node MIPS Paired-Single Support
11909 @subsection MIPS Paired-Single Support
11911 The MIPS64 architecture includes a number of instructions that
11912 operate on pairs of single-precision floating-point values.
11913 Each pair is packed into a 64-bit floating-point register,
11914 with one element being designated the ``upper half'' and
11915 the other being designated the ``lower half''.
11917 GCC supports paired-single operations using both the generic
11918 vector extensions (@pxref{Vector Extensions}) and a collection of
11919 MIPS-specific built-in functions.  Both kinds of support are
11920 enabled by the @option{-mpaired-single} command-line option.
11922 The vector type associated with paired-single values is usually
11923 called @code{v2sf}.  It can be defined in C as follows:
11925 @smallexample
11926 typedef float v2sf __attribute__ ((vector_size (8)));
11927 @end smallexample
11929 @code{v2sf} values are initialized in the same way as aggregates.
11930 For example:
11932 @smallexample
11933 v2sf a = @{1.5, 9.1@};
11934 v2sf b;
11935 float e, f;
11936 b = (v2sf) @{e, f@};
11937 @end smallexample
11939 @emph{Note:} The CPU's endianness determines which value is stored in
11940 the upper half of a register and which value is stored in the lower half.
11941 On little-endian targets, the first value is the lower one and the second
11942 value is the upper one.  The opposite order applies to big-endian targets.
11943 For example, the code above sets the lower half of @code{a} to
11944 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11946 @node MIPS Loongson Built-in Functions
11947 @subsection MIPS Loongson Built-in Functions
11949 GCC provides intrinsics to access the SIMD instructions provided by the
11950 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
11951 available after inclusion of the @code{loongson.h} header file,
11952 operate on the following 64-bit vector types:
11954 @itemize
11955 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11956 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11957 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11958 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11959 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11960 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11961 @end itemize
11963 The intrinsics provided are listed below; each is named after the
11964 machine instruction to which it corresponds, with suffixes added as
11965 appropriate to distinguish intrinsics that expand to the same machine
11966 instruction yet have different argument types.  Refer to the architecture
11967 documentation for a description of the functionality of each
11968 instruction.
11970 @smallexample
11971 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11972 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11973 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11974 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11975 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11976 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11977 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11978 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11979 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11980 uint64_t paddd_u (uint64_t s, uint64_t t);
11981 int64_t paddd_s (int64_t s, int64_t t);
11982 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11983 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11984 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11985 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11986 uint64_t pandn_ud (uint64_t s, uint64_t t);
11987 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11988 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11989 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11990 int64_t pandn_sd (int64_t s, int64_t t);
11991 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11992 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11993 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11994 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11995 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11996 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11997 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11998 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11999 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12000 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12001 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12002 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12003 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12004 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12005 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12006 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12007 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12008 uint16x4_t pextrh_u (uint16x4_t s, int field);
12009 int16x4_t pextrh_s (int16x4_t s, int field);
12010 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12011 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12012 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12013 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12014 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12015 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12016 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12017 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12018 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12019 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12020 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12021 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12022 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12023 uint8x8_t pmovmskb_u (uint8x8_t s);
12024 int8x8_t pmovmskb_s (int8x8_t s);
12025 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12026 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12027 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12028 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12029 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12030 uint16x4_t biadd (uint8x8_t s);
12031 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12032 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12033 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12034 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12035 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12036 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12037 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12038 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12039 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12040 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12041 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12042 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12043 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12044 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12045 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12046 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12047 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12048 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12049 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12050 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12051 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12052 uint64_t psubd_u (uint64_t s, uint64_t t);
12053 int64_t psubd_s (int64_t s, int64_t t);
12054 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12055 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12056 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12057 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12058 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12059 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12060 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12061 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12062 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12063 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12064 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12065 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12066 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12067 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12068 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12069 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12070 @end smallexample
12072 @menu
12073 * Paired-Single Arithmetic::
12074 * Paired-Single Built-in Functions::
12075 * MIPS-3D Built-in Functions::
12076 @end menu
12078 @node Paired-Single Arithmetic
12079 @subsubsection Paired-Single Arithmetic
12081 The table below lists the @code{v2sf} operations for which hardware
12082 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12083 values and @code{x} is an integral value.
12085 @multitable @columnfractions .50 .50
12086 @item C code @tab MIPS instruction
12087 @item @code{a + b} @tab @code{add.ps}
12088 @item @code{a - b} @tab @code{sub.ps}
12089 @item @code{-a} @tab @code{neg.ps}
12090 @item @code{a * b} @tab @code{mul.ps}
12091 @item @code{a * b + c} @tab @code{madd.ps}
12092 @item @code{a * b - c} @tab @code{msub.ps}
12093 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12094 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12095 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12096 @end multitable
12098 Note that the multiply-accumulate instructions can be disabled
12099 using the command-line option @code{-mno-fused-madd}.
12101 @node Paired-Single Built-in Functions
12102 @subsubsection Paired-Single Built-in Functions
12104 The following paired-single functions map directly to a particular
12105 MIPS instruction.  Please refer to the architecture specification
12106 for details on what each instruction does.
12108 @table @code
12109 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12110 Pair lower lower (@code{pll.ps}).
12112 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12113 Pair upper lower (@code{pul.ps}).
12115 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12116 Pair lower upper (@code{plu.ps}).
12118 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12119 Pair upper upper (@code{puu.ps}).
12121 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12122 Convert pair to paired single (@code{cvt.ps.s}).
12124 @item float __builtin_mips_cvt_s_pl (v2sf)
12125 Convert pair lower to single (@code{cvt.s.pl}).
12127 @item float __builtin_mips_cvt_s_pu (v2sf)
12128 Convert pair upper to single (@code{cvt.s.pu}).
12130 @item v2sf __builtin_mips_abs_ps (v2sf)
12131 Absolute value (@code{abs.ps}).
12133 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12134 Align variable (@code{alnv.ps}).
12136 @emph{Note:} The value of the third parameter must be 0 or 4
12137 modulo 8, otherwise the result is unpredictable.  Please read the
12138 instruction description for details.
12139 @end table
12141 The following multi-instruction functions are also available.
12142 In each case, @var{cond} can be any of the 16 floating-point conditions:
12143 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12144 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12145 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12147 @table @code
12148 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12149 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12150 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12151 @code{movt.ps}/@code{movf.ps}).
12153 The @code{movt} functions return the value @var{x} computed by:
12155 @smallexample
12156 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12157 mov.ps @var{x},@var{c}
12158 movt.ps @var{x},@var{d},@var{cc}
12159 @end smallexample
12161 The @code{movf} functions are similar but use @code{movf.ps} instead
12162 of @code{movt.ps}.
12164 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12165 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12166 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12167 @code{bc1t}/@code{bc1f}).
12169 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12170 and return either the upper or lower half of the result.  For example:
12172 @smallexample
12173 v2sf a, b;
12174 if (__builtin_mips_upper_c_eq_ps (a, b))
12175   upper_halves_are_equal ();
12176 else
12177   upper_halves_are_unequal ();
12179 if (__builtin_mips_lower_c_eq_ps (a, b))
12180   lower_halves_are_equal ();
12181 else
12182   lower_halves_are_unequal ();
12183 @end smallexample
12184 @end table
12186 @node MIPS-3D Built-in Functions
12187 @subsubsection MIPS-3D Built-in Functions
12189 The MIPS-3D Application-Specific Extension (ASE) includes additional
12190 paired-single instructions that are designed to improve the performance
12191 of 3D graphics operations.  Support for these instructions is controlled
12192 by the @option{-mips3d} command-line option.
12194 The functions listed below map directly to a particular MIPS-3D
12195 instruction.  Please refer to the architecture specification for
12196 more details on what each instruction does.
12198 @table @code
12199 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12200 Reduction add (@code{addr.ps}).
12202 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12203 Reduction multiply (@code{mulr.ps}).
12205 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12206 Convert paired single to paired word (@code{cvt.pw.ps}).
12208 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12209 Convert paired word to paired single (@code{cvt.ps.pw}).
12211 @item float __builtin_mips_recip1_s (float)
12212 @itemx double __builtin_mips_recip1_d (double)
12213 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12214 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12216 @item float __builtin_mips_recip2_s (float, float)
12217 @itemx double __builtin_mips_recip2_d (double, double)
12218 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12219 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12221 @item float __builtin_mips_rsqrt1_s (float)
12222 @itemx double __builtin_mips_rsqrt1_d (double)
12223 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12224 Reduced-precision reciprocal square root (sequence step 1)
12225 (@code{rsqrt1.@var{fmt}}).
12227 @item float __builtin_mips_rsqrt2_s (float, float)
12228 @itemx double __builtin_mips_rsqrt2_d (double, double)
12229 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12230 Reduced-precision reciprocal square root (sequence step 2)
12231 (@code{rsqrt2.@var{fmt}}).
12232 @end table
12234 The following multi-instruction functions are also available.
12235 In each case, @var{cond} can be any of the 16 floating-point conditions:
12236 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12237 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12238 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12240 @table @code
12241 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12242 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12243 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12244 @code{bc1t}/@code{bc1f}).
12246 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12247 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12248 For example:
12250 @smallexample
12251 float a, b;
12252 if (__builtin_mips_cabs_eq_s (a, b))
12253   true ();
12254 else
12255   false ();
12256 @end smallexample
12258 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12259 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12260 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12261 @code{bc1t}/@code{bc1f}).
12263 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12264 and return either the upper or lower half of the result.  For example:
12266 @smallexample
12267 v2sf a, b;
12268 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12269   upper_halves_are_equal ();
12270 else
12271   upper_halves_are_unequal ();
12273 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12274   lower_halves_are_equal ();
12275 else
12276   lower_halves_are_unequal ();
12277 @end smallexample
12279 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12280 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12281 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12282 @code{movt.ps}/@code{movf.ps}).
12284 The @code{movt} functions return the value @var{x} computed by:
12286 @smallexample
12287 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12288 mov.ps @var{x},@var{c}
12289 movt.ps @var{x},@var{d},@var{cc}
12290 @end smallexample
12292 The @code{movf} functions are similar but use @code{movf.ps} instead
12293 of @code{movt.ps}.
12295 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12296 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12297 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12298 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12299 Comparison of two paired-single values
12300 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12301 @code{bc1any2t}/@code{bc1any2f}).
12303 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12304 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12305 result is true and the @code{all} forms return true if both results are true.
12306 For example:
12308 @smallexample
12309 v2sf a, b;
12310 if (__builtin_mips_any_c_eq_ps (a, b))
12311   one_is_true ();
12312 else
12313   both_are_false ();
12315 if (__builtin_mips_all_c_eq_ps (a, b))
12316   both_are_true ();
12317 else
12318   one_is_false ();
12319 @end smallexample
12321 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12322 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12323 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12324 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12325 Comparison of four paired-single values
12326 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12327 @code{bc1any4t}/@code{bc1any4f}).
12329 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12330 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12331 The @code{any} forms return true if any of the four results are true
12332 and the @code{all} forms return true if all four results are true.
12333 For example:
12335 @smallexample
12336 v2sf a, b, c, d;
12337 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12338   some_are_true ();
12339 else
12340   all_are_false ();
12342 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12343   all_are_true ();
12344 else
12345   some_are_false ();
12346 @end smallexample
12347 @end table
12349 @node Other MIPS Built-in Functions
12350 @subsection Other MIPS Built-in Functions
12352 GCC provides other MIPS-specific built-in functions:
12354 @table @code
12355 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12356 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12357 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12358 when this function is available.
12359 @end table
12361 @node MSP430 Built-in Functions
12362 @subsection MSP430 Built-in Functions
12364 GCC provides a couple of special builtin functions to aid in the
12365 writing of interrupt handlers in C.
12367 @table @code
12368 @item __bic_SR_register_on_exit (int @var{mask})
12369 This clears the indicated bits in the saved copy of the status register
12370 currently residing on the stack.  This only works inside interrupt
12371 handlers and the changes to the status register will only take affect
12372 once the handler returns.
12374 @item __bis_SR_register_on_exit (int @var{mask})
12375 This sets the indicated bits in the saved copy of the status register
12376 currently residing on the stack.  This only works inside interrupt
12377 handlers and the changes to the status register will only take affect
12378 once the handler returns.
12379 @end table
12381 @node picoChip Built-in Functions
12382 @subsection picoChip Built-in Functions
12384 GCC provides an interface to selected machine instructions from the
12385 picoChip instruction set.
12387 @table @code
12388 @item int __builtin_sbc (int @var{value})
12389 Sign bit count.  Return the number of consecutive bits in @var{value}
12390 that have the same value as the sign bit.  The result is the number of
12391 leading sign bits minus one, giving the number of redundant sign bits in
12392 @var{value}.
12394 @item int __builtin_byteswap (int @var{value})
12395 Byte swap.  Return the result of swapping the upper and lower bytes of
12396 @var{value}.
12398 @item int __builtin_brev (int @var{value})
12399 Bit reversal.  Return the result of reversing the bits in
12400 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12401 and so on.
12403 @item int __builtin_adds (int @var{x}, int @var{y})
12404 Saturating addition.  Return the result of adding @var{x} and @var{y},
12405 storing the value 32767 if the result overflows.
12407 @item int __builtin_subs (int @var{x}, int @var{y})
12408 Saturating subtraction.  Return the result of subtracting @var{y} from
12409 @var{x}, storing the value @minus{}32768 if the result overflows.
12411 @item void __builtin_halt (void)
12412 Halt.  The processor stops execution.  This built-in is useful for
12413 implementing assertions.
12415 @end table
12417 @node PowerPC Built-in Functions
12418 @subsection PowerPC Built-in Functions
12420 These built-in functions are available for the PowerPC family of
12421 processors:
12422 @smallexample
12423 float __builtin_recipdivf (float, float);
12424 float __builtin_rsqrtf (float);
12425 double __builtin_recipdiv (double, double);
12426 double __builtin_rsqrt (double);
12427 long __builtin_bpermd (long, long);
12428 uint64_t __builtin_ppc_get_timebase ();
12429 unsigned long __builtin_ppc_mftb ();
12430 @end smallexample
12432 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12433 @code{__builtin_rsqrtf} functions generate multiple instructions to
12434 implement the reciprocal sqrt functionality using reciprocal sqrt
12435 estimate instructions.
12437 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12438 functions generate multiple instructions to implement division using
12439 the reciprocal estimate instructions.
12441 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12442 functions generate instructions to read the Time Base Register.  The
12443 @code{__builtin_ppc_get_timebase} function may generate multiple
12444 instructions and always returns the 64 bits of the Time Base Register.
12445 The @code{__builtin_ppc_mftb} function always generates one instruction and
12446 returns the Time Base Register value as an unsigned long, throwing away
12447 the most significant word on 32-bit environments.
12449 @node PowerPC AltiVec/VSX Built-in Functions
12450 @subsection PowerPC AltiVec Built-in Functions
12452 GCC provides an interface for the PowerPC family of processors to access
12453 the AltiVec operations described in Motorola's AltiVec Programming
12454 Interface Manual.  The interface is made available by including
12455 @code{<altivec.h>} and using @option{-maltivec} and
12456 @option{-mabi=altivec}.  The interface supports the following vector
12457 types.
12459 @smallexample
12460 vector unsigned char
12461 vector signed char
12462 vector bool char
12464 vector unsigned short
12465 vector signed short
12466 vector bool short
12467 vector pixel
12469 vector unsigned int
12470 vector signed int
12471 vector bool int
12472 vector float
12473 @end smallexample
12475 If @option{-mvsx} is used the following additional vector types are
12476 implemented.
12478 @smallexample
12479 vector unsigned long
12480 vector signed long
12481 vector double
12482 @end smallexample
12484 The long types are only implemented for 64-bit code generation, and
12485 the long type is only used in the floating point/integer conversion
12486 instructions.
12488 GCC's implementation of the high-level language interface available from
12489 C and C++ code differs from Motorola's documentation in several ways.
12491 @itemize @bullet
12493 @item
12494 A vector constant is a list of constant expressions within curly braces.
12496 @item
12497 A vector initializer requires no cast if the vector constant is of the
12498 same type as the variable it is initializing.
12500 @item
12501 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12502 vector type is the default signedness of the base type.  The default
12503 varies depending on the operating system, so a portable program should
12504 always specify the signedness.
12506 @item
12507 Compiling with @option{-maltivec} adds keywords @code{__vector},
12508 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
12509 @code{bool}.  When compiling ISO C, the context-sensitive substitution
12510 of the keywords @code{vector}, @code{pixel} and @code{bool} is
12511 disabled.  To use them, you must include @code{<altivec.h>} instead.
12513 @item
12514 GCC allows using a @code{typedef} name as the type specifier for a
12515 vector type.
12517 @item
12518 For C, overloaded functions are implemented with macros so the following
12519 does not work:
12521 @smallexample
12522   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12523 @end smallexample
12525 @noindent
12526 Since @code{vec_add} is a macro, the vector constant in the example
12527 is treated as four separate arguments.  Wrap the entire argument in
12528 parentheses for this to work.
12529 @end itemize
12531 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
12532 Internally, GCC uses built-in functions to achieve the functionality in
12533 the aforementioned header file, but they are not supported and are
12534 subject to change without notice.
12536 The following interfaces are supported for the generic and specific
12537 AltiVec operations and the AltiVec predicates.  In cases where there
12538 is a direct mapping between generic and specific operations, only the
12539 generic names are shown here, although the specific operations can also
12540 be used.
12542 Arguments that are documented as @code{const int} require literal
12543 integral values within the range required for that operation.
12545 @smallexample
12546 vector signed char vec_abs (vector signed char);
12547 vector signed short vec_abs (vector signed short);
12548 vector signed int vec_abs (vector signed int);
12549 vector float vec_abs (vector float);
12551 vector signed char vec_abss (vector signed char);
12552 vector signed short vec_abss (vector signed short);
12553 vector signed int vec_abss (vector signed int);
12555 vector signed char vec_add (vector bool char, vector signed char);
12556 vector signed char vec_add (vector signed char, vector bool char);
12557 vector signed char vec_add (vector signed char, vector signed char);
12558 vector unsigned char vec_add (vector bool char, vector unsigned char);
12559 vector unsigned char vec_add (vector unsigned char, vector bool char);
12560 vector unsigned char vec_add (vector unsigned char,
12561                               vector unsigned char);
12562 vector signed short vec_add (vector bool short, vector signed short);
12563 vector signed short vec_add (vector signed short, vector bool short);
12564 vector signed short vec_add (vector signed short, vector signed short);
12565 vector unsigned short vec_add (vector bool short,
12566                                vector unsigned short);
12567 vector unsigned short vec_add (vector unsigned short,
12568                                vector bool short);
12569 vector unsigned short vec_add (vector unsigned short,
12570                                vector unsigned short);
12571 vector signed int vec_add (vector bool int, vector signed int);
12572 vector signed int vec_add (vector signed int, vector bool int);
12573 vector signed int vec_add (vector signed int, vector signed int);
12574 vector unsigned int vec_add (vector bool int, vector unsigned int);
12575 vector unsigned int vec_add (vector unsigned int, vector bool int);
12576 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12577 vector float vec_add (vector float, vector float);
12579 vector float vec_vaddfp (vector float, vector float);
12581 vector signed int vec_vadduwm (vector bool int, vector signed int);
12582 vector signed int vec_vadduwm (vector signed int, vector bool int);
12583 vector signed int vec_vadduwm (vector signed int, vector signed int);
12584 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12585 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12586 vector unsigned int vec_vadduwm (vector unsigned int,
12587                                  vector unsigned int);
12589 vector signed short vec_vadduhm (vector bool short,
12590                                  vector signed short);
12591 vector signed short vec_vadduhm (vector signed short,
12592                                  vector bool short);
12593 vector signed short vec_vadduhm (vector signed short,
12594                                  vector signed short);
12595 vector unsigned short vec_vadduhm (vector bool short,
12596                                    vector unsigned short);
12597 vector unsigned short vec_vadduhm (vector unsigned short,
12598                                    vector bool short);
12599 vector unsigned short vec_vadduhm (vector unsigned short,
12600                                    vector unsigned short);
12602 vector signed char vec_vaddubm (vector bool char, vector signed char);
12603 vector signed char vec_vaddubm (vector signed char, vector bool char);
12604 vector signed char vec_vaddubm (vector signed char, vector signed char);
12605 vector unsigned char vec_vaddubm (vector bool char,
12606                                   vector unsigned char);
12607 vector unsigned char vec_vaddubm (vector unsigned char,
12608                                   vector bool char);
12609 vector unsigned char vec_vaddubm (vector unsigned char,
12610                                   vector unsigned char);
12612 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12614 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12615 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12616 vector unsigned char vec_adds (vector unsigned char,
12617                                vector unsigned char);
12618 vector signed char vec_adds (vector bool char, vector signed char);
12619 vector signed char vec_adds (vector signed char, vector bool char);
12620 vector signed char vec_adds (vector signed char, vector signed char);
12621 vector unsigned short vec_adds (vector bool short,
12622                                 vector unsigned short);
12623 vector unsigned short vec_adds (vector unsigned short,
12624                                 vector bool short);
12625 vector unsigned short vec_adds (vector unsigned short,
12626                                 vector unsigned short);
12627 vector signed short vec_adds (vector bool short, vector signed short);
12628 vector signed short vec_adds (vector signed short, vector bool short);
12629 vector signed short vec_adds (vector signed short, vector signed short);
12630 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12631 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12632 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12633 vector signed int vec_adds (vector bool int, vector signed int);
12634 vector signed int vec_adds (vector signed int, vector bool int);
12635 vector signed int vec_adds (vector signed int, vector signed int);
12637 vector signed int vec_vaddsws (vector bool int, vector signed int);
12638 vector signed int vec_vaddsws (vector signed int, vector bool int);
12639 vector signed int vec_vaddsws (vector signed int, vector signed int);
12641 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12642 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12643 vector unsigned int vec_vadduws (vector unsigned int,
12644                                  vector unsigned int);
12646 vector signed short vec_vaddshs (vector bool short,
12647                                  vector signed short);
12648 vector signed short vec_vaddshs (vector signed short,
12649                                  vector bool short);
12650 vector signed short vec_vaddshs (vector signed short,
12651                                  vector signed short);
12653 vector unsigned short vec_vadduhs (vector bool short,
12654                                    vector unsigned short);
12655 vector unsigned short vec_vadduhs (vector unsigned short,
12656                                    vector bool short);
12657 vector unsigned short vec_vadduhs (vector unsigned short,
12658                                    vector unsigned short);
12660 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12661 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12662 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12664 vector unsigned char vec_vaddubs (vector bool char,
12665                                   vector unsigned char);
12666 vector unsigned char vec_vaddubs (vector unsigned char,
12667                                   vector bool char);
12668 vector unsigned char vec_vaddubs (vector unsigned char,
12669                                   vector unsigned char);
12671 vector float vec_and (vector float, vector float);
12672 vector float vec_and (vector float, vector bool int);
12673 vector float vec_and (vector bool int, vector float);
12674 vector bool int vec_and (vector bool int, vector bool int);
12675 vector signed int vec_and (vector bool int, vector signed int);
12676 vector signed int vec_and (vector signed int, vector bool int);
12677 vector signed int vec_and (vector signed int, vector signed int);
12678 vector unsigned int vec_and (vector bool int, vector unsigned int);
12679 vector unsigned int vec_and (vector unsigned int, vector bool int);
12680 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12681 vector bool short vec_and (vector bool short, vector bool short);
12682 vector signed short vec_and (vector bool short, vector signed short);
12683 vector signed short vec_and (vector signed short, vector bool short);
12684 vector signed short vec_and (vector signed short, vector signed short);
12685 vector unsigned short vec_and (vector bool short,
12686                                vector unsigned short);
12687 vector unsigned short vec_and (vector unsigned short,
12688                                vector bool short);
12689 vector unsigned short vec_and (vector unsigned short,
12690                                vector unsigned short);
12691 vector signed char vec_and (vector bool char, vector signed char);
12692 vector bool char vec_and (vector bool char, vector bool char);
12693 vector signed char vec_and (vector signed char, vector bool char);
12694 vector signed char vec_and (vector signed char, vector signed char);
12695 vector unsigned char vec_and (vector bool char, vector unsigned char);
12696 vector unsigned char vec_and (vector unsigned char, vector bool char);
12697 vector unsigned char vec_and (vector unsigned char,
12698                               vector unsigned char);
12700 vector float vec_andc (vector float, vector float);
12701 vector float vec_andc (vector float, vector bool int);
12702 vector float vec_andc (vector bool int, vector float);
12703 vector bool int vec_andc (vector bool int, vector bool int);
12704 vector signed int vec_andc (vector bool int, vector signed int);
12705 vector signed int vec_andc (vector signed int, vector bool int);
12706 vector signed int vec_andc (vector signed int, vector signed int);
12707 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12708 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12709 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12710 vector bool short vec_andc (vector bool short, vector bool short);
12711 vector signed short vec_andc (vector bool short, vector signed short);
12712 vector signed short vec_andc (vector signed short, vector bool short);
12713 vector signed short vec_andc (vector signed short, vector signed short);
12714 vector unsigned short vec_andc (vector bool short,
12715                                 vector unsigned short);
12716 vector unsigned short vec_andc (vector unsigned short,
12717                                 vector bool short);
12718 vector unsigned short vec_andc (vector unsigned short,
12719                                 vector unsigned short);
12720 vector signed char vec_andc (vector bool char, vector signed char);
12721 vector bool char vec_andc (vector bool char, vector bool char);
12722 vector signed char vec_andc (vector signed char, vector bool char);
12723 vector signed char vec_andc (vector signed char, vector signed char);
12724 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12725 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12726 vector unsigned char vec_andc (vector unsigned char,
12727                                vector unsigned char);
12729 vector unsigned char vec_avg (vector unsigned char,
12730                               vector unsigned char);
12731 vector signed char vec_avg (vector signed char, vector signed char);
12732 vector unsigned short vec_avg (vector unsigned short,
12733                                vector unsigned short);
12734 vector signed short vec_avg (vector signed short, vector signed short);
12735 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12736 vector signed int vec_avg (vector signed int, vector signed int);
12738 vector signed int vec_vavgsw (vector signed int, vector signed int);
12740 vector unsigned int vec_vavguw (vector unsigned int,
12741                                 vector unsigned int);
12743 vector signed short vec_vavgsh (vector signed short,
12744                                 vector signed short);
12746 vector unsigned short vec_vavguh (vector unsigned short,
12747                                   vector unsigned short);
12749 vector signed char vec_vavgsb (vector signed char, vector signed char);
12751 vector unsigned char vec_vavgub (vector unsigned char,
12752                                  vector unsigned char);
12754 vector float vec_copysign (vector float);
12756 vector float vec_ceil (vector float);
12758 vector signed int vec_cmpb (vector float, vector float);
12760 vector bool char vec_cmpeq (vector signed char, vector signed char);
12761 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12762 vector bool short vec_cmpeq (vector signed short, vector signed short);
12763 vector bool short vec_cmpeq (vector unsigned short,
12764                              vector unsigned short);
12765 vector bool int vec_cmpeq (vector signed int, vector signed int);
12766 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12767 vector bool int vec_cmpeq (vector float, vector float);
12769 vector bool int vec_vcmpeqfp (vector float, vector float);
12771 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12772 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12774 vector bool short vec_vcmpequh (vector signed short,
12775                                 vector signed short);
12776 vector bool short vec_vcmpequh (vector unsigned short,
12777                                 vector unsigned short);
12779 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12780 vector bool char vec_vcmpequb (vector unsigned char,
12781                                vector unsigned char);
12783 vector bool int vec_cmpge (vector float, vector float);
12785 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12786 vector bool char vec_cmpgt (vector signed char, vector signed char);
12787 vector bool short vec_cmpgt (vector unsigned short,
12788                              vector unsigned short);
12789 vector bool short vec_cmpgt (vector signed short, vector signed short);
12790 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12791 vector bool int vec_cmpgt (vector signed int, vector signed int);
12792 vector bool int vec_cmpgt (vector float, vector float);
12794 vector bool int vec_vcmpgtfp (vector float, vector float);
12796 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12798 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12800 vector bool short vec_vcmpgtsh (vector signed short,
12801                                 vector signed short);
12803 vector bool short vec_vcmpgtuh (vector unsigned short,
12804                                 vector unsigned short);
12806 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12808 vector bool char vec_vcmpgtub (vector unsigned char,
12809                                vector unsigned char);
12811 vector bool int vec_cmple (vector float, vector float);
12813 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12814 vector bool char vec_cmplt (vector signed char, vector signed char);
12815 vector bool short vec_cmplt (vector unsigned short,
12816                              vector unsigned short);
12817 vector bool short vec_cmplt (vector signed short, vector signed short);
12818 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12819 vector bool int vec_cmplt (vector signed int, vector signed int);
12820 vector bool int vec_cmplt (vector float, vector float);
12822 vector float vec_ctf (vector unsigned int, const int);
12823 vector float vec_ctf (vector signed int, const int);
12825 vector float vec_vcfsx (vector signed int, const int);
12827 vector float vec_vcfux (vector unsigned int, const int);
12829 vector signed int vec_cts (vector float, const int);
12831 vector unsigned int vec_ctu (vector float, const int);
12833 void vec_dss (const int);
12835 void vec_dssall (void);
12837 void vec_dst (const vector unsigned char *, int, const int);
12838 void vec_dst (const vector signed char *, int, const int);
12839 void vec_dst (const vector bool char *, int, const int);
12840 void vec_dst (const vector unsigned short *, int, const int);
12841 void vec_dst (const vector signed short *, int, const int);
12842 void vec_dst (const vector bool short *, int, const int);
12843 void vec_dst (const vector pixel *, int, const int);
12844 void vec_dst (const vector unsigned int *, int, const int);
12845 void vec_dst (const vector signed int *, int, const int);
12846 void vec_dst (const vector bool int *, int, const int);
12847 void vec_dst (const vector float *, int, const int);
12848 void vec_dst (const unsigned char *, int, const int);
12849 void vec_dst (const signed char *, int, const int);
12850 void vec_dst (const unsigned short *, int, const int);
12851 void vec_dst (const short *, int, const int);
12852 void vec_dst (const unsigned int *, int, const int);
12853 void vec_dst (const int *, int, const int);
12854 void vec_dst (const unsigned long *, int, const int);
12855 void vec_dst (const long *, int, const int);
12856 void vec_dst (const float *, int, const int);
12858 void vec_dstst (const vector unsigned char *, int, const int);
12859 void vec_dstst (const vector signed char *, int, const int);
12860 void vec_dstst (const vector bool char *, int, const int);
12861 void vec_dstst (const vector unsigned short *, int, const int);
12862 void vec_dstst (const vector signed short *, int, const int);
12863 void vec_dstst (const vector bool short *, int, const int);
12864 void vec_dstst (const vector pixel *, int, const int);
12865 void vec_dstst (const vector unsigned int *, int, const int);
12866 void vec_dstst (const vector signed int *, int, const int);
12867 void vec_dstst (const vector bool int *, int, const int);
12868 void vec_dstst (const vector float *, int, const int);
12869 void vec_dstst (const unsigned char *, int, const int);
12870 void vec_dstst (const signed char *, int, const int);
12871 void vec_dstst (const unsigned short *, int, const int);
12872 void vec_dstst (const short *, int, const int);
12873 void vec_dstst (const unsigned int *, int, const int);
12874 void vec_dstst (const int *, int, const int);
12875 void vec_dstst (const unsigned long *, int, const int);
12876 void vec_dstst (const long *, int, const int);
12877 void vec_dstst (const float *, int, const int);
12879 void vec_dststt (const vector unsigned char *, int, const int);
12880 void vec_dststt (const vector signed char *, int, const int);
12881 void vec_dststt (const vector bool char *, int, const int);
12882 void vec_dststt (const vector unsigned short *, int, const int);
12883 void vec_dststt (const vector signed short *, int, const int);
12884 void vec_dststt (const vector bool short *, int, const int);
12885 void vec_dststt (const vector pixel *, int, const int);
12886 void vec_dststt (const vector unsigned int *, int, const int);
12887 void vec_dststt (const vector signed int *, int, const int);
12888 void vec_dststt (const vector bool int *, int, const int);
12889 void vec_dststt (const vector float *, int, const int);
12890 void vec_dststt (const unsigned char *, int, const int);
12891 void vec_dststt (const signed char *, int, const int);
12892 void vec_dststt (const unsigned short *, int, const int);
12893 void vec_dststt (const short *, int, const int);
12894 void vec_dststt (const unsigned int *, int, const int);
12895 void vec_dststt (const int *, int, const int);
12896 void vec_dststt (const unsigned long *, int, const int);
12897 void vec_dststt (const long *, int, const int);
12898 void vec_dststt (const float *, int, const int);
12900 void vec_dstt (const vector unsigned char *, int, const int);
12901 void vec_dstt (const vector signed char *, int, const int);
12902 void vec_dstt (const vector bool char *, int, const int);
12903 void vec_dstt (const vector unsigned short *, int, const int);
12904 void vec_dstt (const vector signed short *, int, const int);
12905 void vec_dstt (const vector bool short *, int, const int);
12906 void vec_dstt (const vector pixel *, int, const int);
12907 void vec_dstt (const vector unsigned int *, int, const int);
12908 void vec_dstt (const vector signed int *, int, const int);
12909 void vec_dstt (const vector bool int *, int, const int);
12910 void vec_dstt (const vector float *, int, const int);
12911 void vec_dstt (const unsigned char *, int, const int);
12912 void vec_dstt (const signed char *, int, const int);
12913 void vec_dstt (const unsigned short *, int, const int);
12914 void vec_dstt (const short *, int, const int);
12915 void vec_dstt (const unsigned int *, int, const int);
12916 void vec_dstt (const int *, int, const int);
12917 void vec_dstt (const unsigned long *, int, const int);
12918 void vec_dstt (const long *, int, const int);
12919 void vec_dstt (const float *, int, const int);
12921 vector float vec_expte (vector float);
12923 vector float vec_floor (vector float);
12925 vector float vec_ld (int, const vector float *);
12926 vector float vec_ld (int, const float *);
12927 vector bool int vec_ld (int, const vector bool int *);
12928 vector signed int vec_ld (int, const vector signed int *);
12929 vector signed int vec_ld (int, const int *);
12930 vector signed int vec_ld (int, const long *);
12931 vector unsigned int vec_ld (int, const vector unsigned int *);
12932 vector unsigned int vec_ld (int, const unsigned int *);
12933 vector unsigned int vec_ld (int, const unsigned long *);
12934 vector bool short vec_ld (int, const vector bool short *);
12935 vector pixel vec_ld (int, const vector pixel *);
12936 vector signed short vec_ld (int, const vector signed short *);
12937 vector signed short vec_ld (int, const short *);
12938 vector unsigned short vec_ld (int, const vector unsigned short *);
12939 vector unsigned short vec_ld (int, const unsigned short *);
12940 vector bool char vec_ld (int, const vector bool char *);
12941 vector signed char vec_ld (int, const vector signed char *);
12942 vector signed char vec_ld (int, const signed char *);
12943 vector unsigned char vec_ld (int, const vector unsigned char *);
12944 vector unsigned char vec_ld (int, const unsigned char *);
12946 vector signed char vec_lde (int, const signed char *);
12947 vector unsigned char vec_lde (int, const unsigned char *);
12948 vector signed short vec_lde (int, const short *);
12949 vector unsigned short vec_lde (int, const unsigned short *);
12950 vector float vec_lde (int, const float *);
12951 vector signed int vec_lde (int, const int *);
12952 vector unsigned int vec_lde (int, const unsigned int *);
12953 vector signed int vec_lde (int, const long *);
12954 vector unsigned int vec_lde (int, const unsigned long *);
12956 vector float vec_lvewx (int, float *);
12957 vector signed int vec_lvewx (int, int *);
12958 vector unsigned int vec_lvewx (int, unsigned int *);
12959 vector signed int vec_lvewx (int, long *);
12960 vector unsigned int vec_lvewx (int, unsigned long *);
12962 vector signed short vec_lvehx (int, short *);
12963 vector unsigned short vec_lvehx (int, unsigned short *);
12965 vector signed char vec_lvebx (int, char *);
12966 vector unsigned char vec_lvebx (int, unsigned char *);
12968 vector float vec_ldl (int, const vector float *);
12969 vector float vec_ldl (int, const float *);
12970 vector bool int vec_ldl (int, const vector bool int *);
12971 vector signed int vec_ldl (int, const vector signed int *);
12972 vector signed int vec_ldl (int, const int *);
12973 vector signed int vec_ldl (int, const long *);
12974 vector unsigned int vec_ldl (int, const vector unsigned int *);
12975 vector unsigned int vec_ldl (int, const unsigned int *);
12976 vector unsigned int vec_ldl (int, const unsigned long *);
12977 vector bool short vec_ldl (int, const vector bool short *);
12978 vector pixel vec_ldl (int, const vector pixel *);
12979 vector signed short vec_ldl (int, const vector signed short *);
12980 vector signed short vec_ldl (int, const short *);
12981 vector unsigned short vec_ldl (int, const vector unsigned short *);
12982 vector unsigned short vec_ldl (int, const unsigned short *);
12983 vector bool char vec_ldl (int, const vector bool char *);
12984 vector signed char vec_ldl (int, const vector signed char *);
12985 vector signed char vec_ldl (int, const signed char *);
12986 vector unsigned char vec_ldl (int, const vector unsigned char *);
12987 vector unsigned char vec_ldl (int, const unsigned char *);
12989 vector float vec_loge (vector float);
12991 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12992 vector unsigned char vec_lvsl (int, const volatile signed char *);
12993 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12994 vector unsigned char vec_lvsl (int, const volatile short *);
12995 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12996 vector unsigned char vec_lvsl (int, const volatile int *);
12997 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12998 vector unsigned char vec_lvsl (int, const volatile long *);
12999 vector unsigned char vec_lvsl (int, const volatile float *);
13001 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13002 vector unsigned char vec_lvsr (int, const volatile signed char *);
13003 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13004 vector unsigned char vec_lvsr (int, const volatile short *);
13005 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13006 vector unsigned char vec_lvsr (int, const volatile int *);
13007 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13008 vector unsigned char vec_lvsr (int, const volatile long *);
13009 vector unsigned char vec_lvsr (int, const volatile float *);
13011 vector float vec_madd (vector float, vector float, vector float);
13013 vector signed short vec_madds (vector signed short,
13014                                vector signed short,
13015                                vector signed short);
13017 vector unsigned char vec_max (vector bool char, vector unsigned char);
13018 vector unsigned char vec_max (vector unsigned char, vector bool char);
13019 vector unsigned char vec_max (vector unsigned char,
13020                               vector unsigned char);
13021 vector signed char vec_max (vector bool char, vector signed char);
13022 vector signed char vec_max (vector signed char, vector bool char);
13023 vector signed char vec_max (vector signed char, vector signed char);
13024 vector unsigned short vec_max (vector bool short,
13025                                vector unsigned short);
13026 vector unsigned short vec_max (vector unsigned short,
13027                                vector bool short);
13028 vector unsigned short vec_max (vector unsigned short,
13029                                vector unsigned short);
13030 vector signed short vec_max (vector bool short, vector signed short);
13031 vector signed short vec_max (vector signed short, vector bool short);
13032 vector signed short vec_max (vector signed short, vector signed short);
13033 vector unsigned int vec_max (vector bool int, vector unsigned int);
13034 vector unsigned int vec_max (vector unsigned int, vector bool int);
13035 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13036 vector signed int vec_max (vector bool int, vector signed int);
13037 vector signed int vec_max (vector signed int, vector bool int);
13038 vector signed int vec_max (vector signed int, vector signed int);
13039 vector float vec_max (vector float, vector float);
13041 vector float vec_vmaxfp (vector float, vector float);
13043 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13044 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13045 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13047 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13048 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13049 vector unsigned int vec_vmaxuw (vector unsigned int,
13050                                 vector unsigned int);
13052 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13053 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13054 vector signed short vec_vmaxsh (vector signed short,
13055                                 vector signed short);
13057 vector unsigned short vec_vmaxuh (vector bool short,
13058                                   vector unsigned short);
13059 vector unsigned short vec_vmaxuh (vector unsigned short,
13060                                   vector bool short);
13061 vector unsigned short vec_vmaxuh (vector unsigned short,
13062                                   vector unsigned short);
13064 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13065 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13066 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13068 vector unsigned char vec_vmaxub (vector bool char,
13069                                  vector unsigned char);
13070 vector unsigned char vec_vmaxub (vector unsigned char,
13071                                  vector bool char);
13072 vector unsigned char vec_vmaxub (vector unsigned char,
13073                                  vector unsigned char);
13075 vector bool char vec_mergeh (vector bool char, vector bool char);
13076 vector signed char vec_mergeh (vector signed char, vector signed char);
13077 vector unsigned char vec_mergeh (vector unsigned char,
13078                                  vector unsigned char);
13079 vector bool short vec_mergeh (vector bool short, vector bool short);
13080 vector pixel vec_mergeh (vector pixel, vector pixel);
13081 vector signed short vec_mergeh (vector signed short,
13082                                 vector signed short);
13083 vector unsigned short vec_mergeh (vector unsigned short,
13084                                   vector unsigned short);
13085 vector float vec_mergeh (vector float, vector float);
13086 vector bool int vec_mergeh (vector bool int, vector bool int);
13087 vector signed int vec_mergeh (vector signed int, vector signed int);
13088 vector unsigned int vec_mergeh (vector unsigned int,
13089                                 vector unsigned int);
13091 vector float vec_vmrghw (vector float, vector float);
13092 vector bool int vec_vmrghw (vector bool int, vector bool int);
13093 vector signed int vec_vmrghw (vector signed int, vector signed int);
13094 vector unsigned int vec_vmrghw (vector unsigned int,
13095                                 vector unsigned int);
13097 vector bool short vec_vmrghh (vector bool short, vector bool short);
13098 vector signed short vec_vmrghh (vector signed short,
13099                                 vector signed short);
13100 vector unsigned short vec_vmrghh (vector unsigned short,
13101                                   vector unsigned short);
13102 vector pixel vec_vmrghh (vector pixel, vector pixel);
13104 vector bool char vec_vmrghb (vector bool char, vector bool char);
13105 vector signed char vec_vmrghb (vector signed char, vector signed char);
13106 vector unsigned char vec_vmrghb (vector unsigned char,
13107                                  vector unsigned char);
13109 vector bool char vec_mergel (vector bool char, vector bool char);
13110 vector signed char vec_mergel (vector signed char, vector signed char);
13111 vector unsigned char vec_mergel (vector unsigned char,
13112                                  vector unsigned char);
13113 vector bool short vec_mergel (vector bool short, vector bool short);
13114 vector pixel vec_mergel (vector pixel, vector pixel);
13115 vector signed short vec_mergel (vector signed short,
13116                                 vector signed short);
13117 vector unsigned short vec_mergel (vector unsigned short,
13118                                   vector unsigned short);
13119 vector float vec_mergel (vector float, vector float);
13120 vector bool int vec_mergel (vector bool int, vector bool int);
13121 vector signed int vec_mergel (vector signed int, vector signed int);
13122 vector unsigned int vec_mergel (vector unsigned int,
13123                                 vector unsigned int);
13125 vector float vec_vmrglw (vector float, vector float);
13126 vector signed int vec_vmrglw (vector signed int, vector signed int);
13127 vector unsigned int vec_vmrglw (vector unsigned int,
13128                                 vector unsigned int);
13129 vector bool int vec_vmrglw (vector bool int, vector bool int);
13131 vector bool short vec_vmrglh (vector bool short, vector bool short);
13132 vector signed short vec_vmrglh (vector signed short,
13133                                 vector signed short);
13134 vector unsigned short vec_vmrglh (vector unsigned short,
13135                                   vector unsigned short);
13136 vector pixel vec_vmrglh (vector pixel, vector pixel);
13138 vector bool char vec_vmrglb (vector bool char, vector bool char);
13139 vector signed char vec_vmrglb (vector signed char, vector signed char);
13140 vector unsigned char vec_vmrglb (vector unsigned char,
13141                                  vector unsigned char);
13143 vector unsigned short vec_mfvscr (void);
13145 vector unsigned char vec_min (vector bool char, vector unsigned char);
13146 vector unsigned char vec_min (vector unsigned char, vector bool char);
13147 vector unsigned char vec_min (vector unsigned char,
13148                               vector unsigned char);
13149 vector signed char vec_min (vector bool char, vector signed char);
13150 vector signed char vec_min (vector signed char, vector bool char);
13151 vector signed char vec_min (vector signed char, vector signed char);
13152 vector unsigned short vec_min (vector bool short,
13153                                vector unsigned short);
13154 vector unsigned short vec_min (vector unsigned short,
13155                                vector bool short);
13156 vector unsigned short vec_min (vector unsigned short,
13157                                vector unsigned short);
13158 vector signed short vec_min (vector bool short, vector signed short);
13159 vector signed short vec_min (vector signed short, vector bool short);
13160 vector signed short vec_min (vector signed short, vector signed short);
13161 vector unsigned int vec_min (vector bool int, vector unsigned int);
13162 vector unsigned int vec_min (vector unsigned int, vector bool int);
13163 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13164 vector signed int vec_min (vector bool int, vector signed int);
13165 vector signed int vec_min (vector signed int, vector bool int);
13166 vector signed int vec_min (vector signed int, vector signed int);
13167 vector float vec_min (vector float, vector float);
13169 vector float vec_vminfp (vector float, vector float);
13171 vector signed int vec_vminsw (vector bool int, vector signed int);
13172 vector signed int vec_vminsw (vector signed int, vector bool int);
13173 vector signed int vec_vminsw (vector signed int, vector signed int);
13175 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13176 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13177 vector unsigned int vec_vminuw (vector unsigned int,
13178                                 vector unsigned int);
13180 vector signed short vec_vminsh (vector bool short, vector signed short);
13181 vector signed short vec_vminsh (vector signed short, vector bool short);
13182 vector signed short vec_vminsh (vector signed short,
13183                                 vector signed short);
13185 vector unsigned short vec_vminuh (vector bool short,
13186                                   vector unsigned short);
13187 vector unsigned short vec_vminuh (vector unsigned short,
13188                                   vector bool short);
13189 vector unsigned short vec_vminuh (vector unsigned short,
13190                                   vector unsigned short);
13192 vector signed char vec_vminsb (vector bool char, vector signed char);
13193 vector signed char vec_vminsb (vector signed char, vector bool char);
13194 vector signed char vec_vminsb (vector signed char, vector signed char);
13196 vector unsigned char vec_vminub (vector bool char,
13197                                  vector unsigned char);
13198 vector unsigned char vec_vminub (vector unsigned char,
13199                                  vector bool char);
13200 vector unsigned char vec_vminub (vector unsigned char,
13201                                  vector unsigned char);
13203 vector signed short vec_mladd (vector signed short,
13204                                vector signed short,
13205                                vector signed short);
13206 vector signed short vec_mladd (vector signed short,
13207                                vector unsigned short,
13208                                vector unsigned short);
13209 vector signed short vec_mladd (vector unsigned short,
13210                                vector signed short,
13211                                vector signed short);
13212 vector unsigned short vec_mladd (vector unsigned short,
13213                                  vector unsigned short,
13214                                  vector unsigned short);
13216 vector signed short vec_mradds (vector signed short,
13217                                 vector signed short,
13218                                 vector signed short);
13220 vector unsigned int vec_msum (vector unsigned char,
13221                               vector unsigned char,
13222                               vector unsigned int);
13223 vector signed int vec_msum (vector signed char,
13224                             vector unsigned char,
13225                             vector signed int);
13226 vector unsigned int vec_msum (vector unsigned short,
13227                               vector unsigned short,
13228                               vector unsigned int);
13229 vector signed int vec_msum (vector signed short,
13230                             vector signed short,
13231                             vector signed int);
13233 vector signed int vec_vmsumshm (vector signed short,
13234                                 vector signed short,
13235                                 vector signed int);
13237 vector unsigned int vec_vmsumuhm (vector unsigned short,
13238                                   vector unsigned short,
13239                                   vector unsigned int);
13241 vector signed int vec_vmsummbm (vector signed char,
13242                                 vector unsigned char,
13243                                 vector signed int);
13245 vector unsigned int vec_vmsumubm (vector unsigned char,
13246                                   vector unsigned char,
13247                                   vector unsigned int);
13249 vector unsigned int vec_msums (vector unsigned short,
13250                                vector unsigned short,
13251                                vector unsigned int);
13252 vector signed int vec_msums (vector signed short,
13253                              vector signed short,
13254                              vector signed int);
13256 vector signed int vec_vmsumshs (vector signed short,
13257                                 vector signed short,
13258                                 vector signed int);
13260 vector unsigned int vec_vmsumuhs (vector unsigned short,
13261                                   vector unsigned short,
13262                                   vector unsigned int);
13264 void vec_mtvscr (vector signed int);
13265 void vec_mtvscr (vector unsigned int);
13266 void vec_mtvscr (vector bool int);
13267 void vec_mtvscr (vector signed short);
13268 void vec_mtvscr (vector unsigned short);
13269 void vec_mtvscr (vector bool short);
13270 void vec_mtvscr (vector pixel);
13271 void vec_mtvscr (vector signed char);
13272 void vec_mtvscr (vector unsigned char);
13273 void vec_mtvscr (vector bool char);
13275 vector unsigned short vec_mule (vector unsigned char,
13276                                 vector unsigned char);
13277 vector signed short vec_mule (vector signed char,
13278                               vector signed char);
13279 vector unsigned int vec_mule (vector unsigned short,
13280                               vector unsigned short);
13281 vector signed int vec_mule (vector signed short, vector signed short);
13283 vector signed int vec_vmulesh (vector signed short,
13284                                vector signed short);
13286 vector unsigned int vec_vmuleuh (vector unsigned short,
13287                                  vector unsigned short);
13289 vector signed short vec_vmulesb (vector signed char,
13290                                  vector signed char);
13292 vector unsigned short vec_vmuleub (vector unsigned char,
13293                                   vector unsigned char);
13295 vector unsigned short vec_mulo (vector unsigned char,
13296                                 vector unsigned char);
13297 vector signed short vec_mulo (vector signed char, vector signed char);
13298 vector unsigned int vec_mulo (vector unsigned short,
13299                               vector unsigned short);
13300 vector signed int vec_mulo (vector signed short, vector signed short);
13302 vector signed int vec_vmulosh (vector signed short,
13303                                vector signed short);
13305 vector unsigned int vec_vmulouh (vector unsigned short,
13306                                  vector unsigned short);
13308 vector signed short vec_vmulosb (vector signed char,
13309                                  vector signed char);
13311 vector unsigned short vec_vmuloub (vector unsigned char,
13312                                    vector unsigned char);
13314 vector float vec_nmsub (vector float, vector float, vector float);
13316 vector float vec_nor (vector float, vector float);
13317 vector signed int vec_nor (vector signed int, vector signed int);
13318 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13319 vector bool int vec_nor (vector bool int, vector bool int);
13320 vector signed short vec_nor (vector signed short, vector signed short);
13321 vector unsigned short vec_nor (vector unsigned short,
13322                                vector unsigned short);
13323 vector bool short vec_nor (vector bool short, vector bool short);
13324 vector signed char vec_nor (vector signed char, vector signed char);
13325 vector unsigned char vec_nor (vector unsigned char,
13326                               vector unsigned char);
13327 vector bool char vec_nor (vector bool char, vector bool char);
13329 vector float vec_or (vector float, vector float);
13330 vector float vec_or (vector float, vector bool int);
13331 vector float vec_or (vector bool int, vector float);
13332 vector bool int vec_or (vector bool int, vector bool int);
13333 vector signed int vec_or (vector bool int, vector signed int);
13334 vector signed int vec_or (vector signed int, vector bool int);
13335 vector signed int vec_or (vector signed int, vector signed int);
13336 vector unsigned int vec_or (vector bool int, vector unsigned int);
13337 vector unsigned int vec_or (vector unsigned int, vector bool int);
13338 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13339 vector bool short vec_or (vector bool short, vector bool short);
13340 vector signed short vec_or (vector bool short, vector signed short);
13341 vector signed short vec_or (vector signed short, vector bool short);
13342 vector signed short vec_or (vector signed short, vector signed short);
13343 vector unsigned short vec_or (vector bool short, vector unsigned short);
13344 vector unsigned short vec_or (vector unsigned short, vector bool short);
13345 vector unsigned short vec_or (vector unsigned short,
13346                               vector unsigned short);
13347 vector signed char vec_or (vector bool char, vector signed char);
13348 vector bool char vec_or (vector bool char, vector bool char);
13349 vector signed char vec_or (vector signed char, vector bool char);
13350 vector signed char vec_or (vector signed char, vector signed char);
13351 vector unsigned char vec_or (vector bool char, vector unsigned char);
13352 vector unsigned char vec_or (vector unsigned char, vector bool char);
13353 vector unsigned char vec_or (vector unsigned char,
13354                              vector unsigned char);
13356 vector signed char vec_pack (vector signed short, vector signed short);
13357 vector unsigned char vec_pack (vector unsigned short,
13358                                vector unsigned short);
13359 vector bool char vec_pack (vector bool short, vector bool short);
13360 vector signed short vec_pack (vector signed int, vector signed int);
13361 vector unsigned short vec_pack (vector unsigned int,
13362                                 vector unsigned int);
13363 vector bool short vec_pack (vector bool int, vector bool int);
13365 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13366 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13367 vector unsigned short vec_vpkuwum (vector unsigned int,
13368                                    vector unsigned int);
13370 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13371 vector signed char vec_vpkuhum (vector signed short,
13372                                 vector signed short);
13373 vector unsigned char vec_vpkuhum (vector unsigned short,
13374                                   vector unsigned short);
13376 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13378 vector unsigned char vec_packs (vector unsigned short,
13379                                 vector unsigned short);
13380 vector signed char vec_packs (vector signed short, vector signed short);
13381 vector unsigned short vec_packs (vector unsigned int,
13382                                  vector unsigned int);
13383 vector signed short vec_packs (vector signed int, vector signed int);
13385 vector signed short vec_vpkswss (vector signed int, vector signed int);
13387 vector unsigned short vec_vpkuwus (vector unsigned int,
13388                                    vector unsigned int);
13390 vector signed char vec_vpkshss (vector signed short,
13391                                 vector signed short);
13393 vector unsigned char vec_vpkuhus (vector unsigned short,
13394                                   vector unsigned short);
13396 vector unsigned char vec_packsu (vector unsigned short,
13397                                  vector unsigned short);
13398 vector unsigned char vec_packsu (vector signed short,
13399                                  vector signed short);
13400 vector unsigned short vec_packsu (vector unsigned int,
13401                                   vector unsigned int);
13402 vector unsigned short vec_packsu (vector signed int, vector signed int);
13404 vector unsigned short vec_vpkswus (vector signed int,
13405                                    vector signed int);
13407 vector unsigned char vec_vpkshus (vector signed short,
13408                                   vector signed short);
13410 vector float vec_perm (vector float,
13411                        vector float,
13412                        vector unsigned char);
13413 vector signed int vec_perm (vector signed int,
13414                             vector signed int,
13415                             vector unsigned char);
13416 vector unsigned int vec_perm (vector unsigned int,
13417                               vector unsigned int,
13418                               vector unsigned char);
13419 vector bool int vec_perm (vector bool int,
13420                           vector bool int,
13421                           vector unsigned char);
13422 vector signed short vec_perm (vector signed short,
13423                               vector signed short,
13424                               vector unsigned char);
13425 vector unsigned short vec_perm (vector unsigned short,
13426                                 vector unsigned short,
13427                                 vector unsigned char);
13428 vector bool short vec_perm (vector bool short,
13429                             vector bool short,
13430                             vector unsigned char);
13431 vector pixel vec_perm (vector pixel,
13432                        vector pixel,
13433                        vector unsigned char);
13434 vector signed char vec_perm (vector signed char,
13435                              vector signed char,
13436                              vector unsigned char);
13437 vector unsigned char vec_perm (vector unsigned char,
13438                                vector unsigned char,
13439                                vector unsigned char);
13440 vector bool char vec_perm (vector bool char,
13441                            vector bool char,
13442                            vector unsigned char);
13444 vector float vec_re (vector float);
13446 vector signed char vec_rl (vector signed char,
13447                            vector unsigned char);
13448 vector unsigned char vec_rl (vector unsigned char,
13449                              vector unsigned char);
13450 vector signed short vec_rl (vector signed short, vector unsigned short);
13451 vector unsigned short vec_rl (vector unsigned short,
13452                               vector unsigned short);
13453 vector signed int vec_rl (vector signed int, vector unsigned int);
13454 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13456 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13457 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
13459 vector signed short vec_vrlh (vector signed short,
13460                               vector unsigned short);
13461 vector unsigned short vec_vrlh (vector unsigned short,
13462                                 vector unsigned short);
13464 vector signed char vec_vrlb (vector signed char, vector unsigned char);
13465 vector unsigned char vec_vrlb (vector unsigned char,
13466                                vector unsigned char);
13468 vector float vec_round (vector float);
13470 vector float vec_recip (vector float, vector float);
13472 vector float vec_rsqrt (vector float);
13474 vector float vec_rsqrte (vector float);
13476 vector float vec_sel (vector float, vector float, vector bool int);
13477 vector float vec_sel (vector float, vector float, vector unsigned int);
13478 vector signed int vec_sel (vector signed int,
13479                            vector signed int,
13480                            vector bool int);
13481 vector signed int vec_sel (vector signed int,
13482                            vector signed int,
13483                            vector unsigned int);
13484 vector unsigned int vec_sel (vector unsigned int,
13485                              vector unsigned int,
13486                              vector bool int);
13487 vector unsigned int vec_sel (vector unsigned int,
13488                              vector unsigned int,
13489                              vector unsigned int);
13490 vector bool int vec_sel (vector bool int,
13491                          vector bool int,
13492                          vector bool int);
13493 vector bool int vec_sel (vector bool int,
13494                          vector bool int,
13495                          vector unsigned int);
13496 vector signed short vec_sel (vector signed short,
13497                              vector signed short,
13498                              vector bool short);
13499 vector signed short vec_sel (vector signed short,
13500                              vector signed short,
13501                              vector unsigned short);
13502 vector unsigned short vec_sel (vector unsigned short,
13503                                vector unsigned short,
13504                                vector bool short);
13505 vector unsigned short vec_sel (vector unsigned short,
13506                                vector unsigned short,
13507                                vector unsigned short);
13508 vector bool short vec_sel (vector bool short,
13509                            vector bool short,
13510                            vector bool short);
13511 vector bool short vec_sel (vector bool short,
13512                            vector bool short,
13513                            vector unsigned short);
13514 vector signed char vec_sel (vector signed char,
13515                             vector signed char,
13516                             vector bool char);
13517 vector signed char vec_sel (vector signed char,
13518                             vector signed char,
13519                             vector unsigned char);
13520 vector unsigned char vec_sel (vector unsigned char,
13521                               vector unsigned char,
13522                               vector bool char);
13523 vector unsigned char vec_sel (vector unsigned char,
13524                               vector unsigned char,
13525                               vector unsigned char);
13526 vector bool char vec_sel (vector bool char,
13527                           vector bool char,
13528                           vector bool char);
13529 vector bool char vec_sel (vector bool char,
13530                           vector bool char,
13531                           vector unsigned char);
13533 vector signed char vec_sl (vector signed char,
13534                            vector unsigned char);
13535 vector unsigned char vec_sl (vector unsigned char,
13536                              vector unsigned char);
13537 vector signed short vec_sl (vector signed short, vector unsigned short);
13538 vector unsigned short vec_sl (vector unsigned short,
13539                               vector unsigned short);
13540 vector signed int vec_sl (vector signed int, vector unsigned int);
13541 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13543 vector signed int vec_vslw (vector signed int, vector unsigned int);
13544 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13546 vector signed short vec_vslh (vector signed short,
13547                               vector unsigned short);
13548 vector unsigned short vec_vslh (vector unsigned short,
13549                                 vector unsigned short);
13551 vector signed char vec_vslb (vector signed char, vector unsigned char);
13552 vector unsigned char vec_vslb (vector unsigned char,
13553                                vector unsigned char);
13555 vector float vec_sld (vector float, vector float, const int);
13556 vector signed int vec_sld (vector signed int,
13557                            vector signed int,
13558                            const int);
13559 vector unsigned int vec_sld (vector unsigned int,
13560                              vector unsigned int,
13561                              const int);
13562 vector bool int vec_sld (vector bool int,
13563                          vector bool int,
13564                          const int);
13565 vector signed short vec_sld (vector signed short,
13566                              vector signed short,
13567                              const int);
13568 vector unsigned short vec_sld (vector unsigned short,
13569                                vector unsigned short,
13570                                const int);
13571 vector bool short vec_sld (vector bool short,
13572                            vector bool short,
13573                            const int);
13574 vector pixel vec_sld (vector pixel,
13575                       vector pixel,
13576                       const int);
13577 vector signed char vec_sld (vector signed char,
13578                             vector signed char,
13579                             const int);
13580 vector unsigned char vec_sld (vector unsigned char,
13581                               vector unsigned char,
13582                               const int);
13583 vector bool char vec_sld (vector bool char,
13584                           vector bool char,
13585                           const int);
13587 vector signed int vec_sll (vector signed int,
13588                            vector unsigned int);
13589 vector signed int vec_sll (vector signed int,
13590                            vector unsigned short);
13591 vector signed int vec_sll (vector signed int,
13592                            vector unsigned char);
13593 vector unsigned int vec_sll (vector unsigned int,
13594                              vector unsigned int);
13595 vector unsigned int vec_sll (vector unsigned int,
13596                              vector unsigned short);
13597 vector unsigned int vec_sll (vector unsigned int,
13598                              vector unsigned char);
13599 vector bool int vec_sll (vector bool int,
13600                          vector unsigned int);
13601 vector bool int vec_sll (vector bool int,
13602                          vector unsigned short);
13603 vector bool int vec_sll (vector bool int,
13604                          vector unsigned char);
13605 vector signed short vec_sll (vector signed short,
13606                              vector unsigned int);
13607 vector signed short vec_sll (vector signed short,
13608                              vector unsigned short);
13609 vector signed short vec_sll (vector signed short,
13610                              vector unsigned char);
13611 vector unsigned short vec_sll (vector unsigned short,
13612                                vector unsigned int);
13613 vector unsigned short vec_sll (vector unsigned short,
13614                                vector unsigned short);
13615 vector unsigned short vec_sll (vector unsigned short,
13616                                vector unsigned char);
13617 vector bool short vec_sll (vector bool short, vector unsigned int);
13618 vector bool short vec_sll (vector bool short, vector unsigned short);
13619 vector bool short vec_sll (vector bool short, vector unsigned char);
13620 vector pixel vec_sll (vector pixel, vector unsigned int);
13621 vector pixel vec_sll (vector pixel, vector unsigned short);
13622 vector pixel vec_sll (vector pixel, vector unsigned char);
13623 vector signed char vec_sll (vector signed char, vector unsigned int);
13624 vector signed char vec_sll (vector signed char, vector unsigned short);
13625 vector signed char vec_sll (vector signed char, vector unsigned char);
13626 vector unsigned char vec_sll (vector unsigned char,
13627                               vector unsigned int);
13628 vector unsigned char vec_sll (vector unsigned char,
13629                               vector unsigned short);
13630 vector unsigned char vec_sll (vector unsigned char,
13631                               vector unsigned char);
13632 vector bool char vec_sll (vector bool char, vector unsigned int);
13633 vector bool char vec_sll (vector bool char, vector unsigned short);
13634 vector bool char vec_sll (vector bool char, vector unsigned char);
13636 vector float vec_slo (vector float, vector signed char);
13637 vector float vec_slo (vector float, vector unsigned char);
13638 vector signed int vec_slo (vector signed int, vector signed char);
13639 vector signed int vec_slo (vector signed int, vector unsigned char);
13640 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13641 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13642 vector signed short vec_slo (vector signed short, vector signed char);
13643 vector signed short vec_slo (vector signed short, vector unsigned char);
13644 vector unsigned short vec_slo (vector unsigned short,
13645                                vector signed char);
13646 vector unsigned short vec_slo (vector unsigned short,
13647                                vector unsigned char);
13648 vector pixel vec_slo (vector pixel, vector signed char);
13649 vector pixel vec_slo (vector pixel, vector unsigned char);
13650 vector signed char vec_slo (vector signed char, vector signed char);
13651 vector signed char vec_slo (vector signed char, vector unsigned char);
13652 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13653 vector unsigned char vec_slo (vector unsigned char,
13654                               vector unsigned char);
13656 vector signed char vec_splat (vector signed char, const int);
13657 vector unsigned char vec_splat (vector unsigned char, const int);
13658 vector bool char vec_splat (vector bool char, const int);
13659 vector signed short vec_splat (vector signed short, const int);
13660 vector unsigned short vec_splat (vector unsigned short, const int);
13661 vector bool short vec_splat (vector bool short, const int);
13662 vector pixel vec_splat (vector pixel, const int);
13663 vector float vec_splat (vector float, const int);
13664 vector signed int vec_splat (vector signed int, const int);
13665 vector unsigned int vec_splat (vector unsigned int, const int);
13666 vector bool int vec_splat (vector bool int, const int);
13668 vector float vec_vspltw (vector float, const int);
13669 vector signed int vec_vspltw (vector signed int, const int);
13670 vector unsigned int vec_vspltw (vector unsigned int, const int);
13671 vector bool int vec_vspltw (vector bool int, const int);
13673 vector bool short vec_vsplth (vector bool short, const int);
13674 vector signed short vec_vsplth (vector signed short, const int);
13675 vector unsigned short vec_vsplth (vector unsigned short, const int);
13676 vector pixel vec_vsplth (vector pixel, const int);
13678 vector signed char vec_vspltb (vector signed char, const int);
13679 vector unsigned char vec_vspltb (vector unsigned char, const int);
13680 vector bool char vec_vspltb (vector bool char, const int);
13682 vector signed char vec_splat_s8 (const int);
13684 vector signed short vec_splat_s16 (const int);
13686 vector signed int vec_splat_s32 (const int);
13688 vector unsigned char vec_splat_u8 (const int);
13690 vector unsigned short vec_splat_u16 (const int);
13692 vector unsigned int vec_splat_u32 (const int);
13694 vector signed char vec_sr (vector signed char, vector unsigned char);
13695 vector unsigned char vec_sr (vector unsigned char,
13696                              vector unsigned char);
13697 vector signed short vec_sr (vector signed short,
13698                             vector unsigned short);
13699 vector unsigned short vec_sr (vector unsigned short,
13700                               vector unsigned short);
13701 vector signed int vec_sr (vector signed int, vector unsigned int);
13702 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13704 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13705 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13707 vector signed short vec_vsrh (vector signed short,
13708                               vector unsigned short);
13709 vector unsigned short vec_vsrh (vector unsigned short,
13710                                 vector unsigned short);
13712 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13713 vector unsigned char vec_vsrb (vector unsigned char,
13714                                vector unsigned char);
13716 vector signed char vec_sra (vector signed char, vector unsigned char);
13717 vector unsigned char vec_sra (vector unsigned char,
13718                               vector unsigned char);
13719 vector signed short vec_sra (vector signed short,
13720                              vector unsigned short);
13721 vector unsigned short vec_sra (vector unsigned short,
13722                                vector unsigned short);
13723 vector signed int vec_sra (vector signed int, vector unsigned int);
13724 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13726 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13727 vector unsigned int vec_vsraw (vector unsigned int,
13728                                vector unsigned int);
13730 vector signed short vec_vsrah (vector signed short,
13731                                vector unsigned short);
13732 vector unsigned short vec_vsrah (vector unsigned short,
13733                                  vector unsigned short);
13735 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13736 vector unsigned char vec_vsrab (vector unsigned char,
13737                                 vector unsigned char);
13739 vector signed int vec_srl (vector signed int, vector unsigned int);
13740 vector signed int vec_srl (vector signed int, vector unsigned short);
13741 vector signed int vec_srl (vector signed int, vector unsigned char);
13742 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13743 vector unsigned int vec_srl (vector unsigned int,
13744                              vector unsigned short);
13745 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13746 vector bool int vec_srl (vector bool int, vector unsigned int);
13747 vector bool int vec_srl (vector bool int, vector unsigned short);
13748 vector bool int vec_srl (vector bool int, vector unsigned char);
13749 vector signed short vec_srl (vector signed short, vector unsigned int);
13750 vector signed short vec_srl (vector signed short,
13751                              vector unsigned short);
13752 vector signed short vec_srl (vector signed short, vector unsigned char);
13753 vector unsigned short vec_srl (vector unsigned short,
13754                                vector unsigned int);
13755 vector unsigned short vec_srl (vector unsigned short,
13756                                vector unsigned short);
13757 vector unsigned short vec_srl (vector unsigned short,
13758                                vector unsigned char);
13759 vector bool short vec_srl (vector bool short, vector unsigned int);
13760 vector bool short vec_srl (vector bool short, vector unsigned short);
13761 vector bool short vec_srl (vector bool short, vector unsigned char);
13762 vector pixel vec_srl (vector pixel, vector unsigned int);
13763 vector pixel vec_srl (vector pixel, vector unsigned short);
13764 vector pixel vec_srl (vector pixel, vector unsigned char);
13765 vector signed char vec_srl (vector signed char, vector unsigned int);
13766 vector signed char vec_srl (vector signed char, vector unsigned short);
13767 vector signed char vec_srl (vector signed char, vector unsigned char);
13768 vector unsigned char vec_srl (vector unsigned char,
13769                               vector unsigned int);
13770 vector unsigned char vec_srl (vector unsigned char,
13771                               vector unsigned short);
13772 vector unsigned char vec_srl (vector unsigned char,
13773                               vector unsigned char);
13774 vector bool char vec_srl (vector bool char, vector unsigned int);
13775 vector bool char vec_srl (vector bool char, vector unsigned short);
13776 vector bool char vec_srl (vector bool char, vector unsigned char);
13778 vector float vec_sro (vector float, vector signed char);
13779 vector float vec_sro (vector float, vector unsigned char);
13780 vector signed int vec_sro (vector signed int, vector signed char);
13781 vector signed int vec_sro (vector signed int, vector unsigned char);
13782 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13783 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13784 vector signed short vec_sro (vector signed short, vector signed char);
13785 vector signed short vec_sro (vector signed short, vector unsigned char);
13786 vector unsigned short vec_sro (vector unsigned short,
13787                                vector signed char);
13788 vector unsigned short vec_sro (vector unsigned short,
13789                                vector unsigned char);
13790 vector pixel vec_sro (vector pixel, vector signed char);
13791 vector pixel vec_sro (vector pixel, vector unsigned char);
13792 vector signed char vec_sro (vector signed char, vector signed char);
13793 vector signed char vec_sro (vector signed char, vector unsigned char);
13794 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13795 vector unsigned char vec_sro (vector unsigned char,
13796                               vector unsigned char);
13798 void vec_st (vector float, int, vector float *);
13799 void vec_st (vector float, int, float *);
13800 void vec_st (vector signed int, int, vector signed int *);
13801 void vec_st (vector signed int, int, int *);
13802 void vec_st (vector unsigned int, int, vector unsigned int *);
13803 void vec_st (vector unsigned int, int, unsigned int *);
13804 void vec_st (vector bool int, int, vector bool int *);
13805 void vec_st (vector bool int, int, unsigned int *);
13806 void vec_st (vector bool int, int, int *);
13807 void vec_st (vector signed short, int, vector signed short *);
13808 void vec_st (vector signed short, int, short *);
13809 void vec_st (vector unsigned short, int, vector unsigned short *);
13810 void vec_st (vector unsigned short, int, unsigned short *);
13811 void vec_st (vector bool short, int, vector bool short *);
13812 void vec_st (vector bool short, int, unsigned short *);
13813 void vec_st (vector pixel, int, vector pixel *);
13814 void vec_st (vector pixel, int, unsigned short *);
13815 void vec_st (vector pixel, int, short *);
13816 void vec_st (vector bool short, int, short *);
13817 void vec_st (vector signed char, int, vector signed char *);
13818 void vec_st (vector signed char, int, signed char *);
13819 void vec_st (vector unsigned char, int, vector unsigned char *);
13820 void vec_st (vector unsigned char, int, unsigned char *);
13821 void vec_st (vector bool char, int, vector bool char *);
13822 void vec_st (vector bool char, int, unsigned char *);
13823 void vec_st (vector bool char, int, signed char *);
13825 void vec_ste (vector signed char, int, signed char *);
13826 void vec_ste (vector unsigned char, int, unsigned char *);
13827 void vec_ste (vector bool char, int, signed char *);
13828 void vec_ste (vector bool char, int, unsigned char *);
13829 void vec_ste (vector signed short, int, short *);
13830 void vec_ste (vector unsigned short, int, unsigned short *);
13831 void vec_ste (vector bool short, int, short *);
13832 void vec_ste (vector bool short, int, unsigned short *);
13833 void vec_ste (vector pixel, int, short *);
13834 void vec_ste (vector pixel, int, unsigned short *);
13835 void vec_ste (vector float, int, float *);
13836 void vec_ste (vector signed int, int, int *);
13837 void vec_ste (vector unsigned int, int, unsigned int *);
13838 void vec_ste (vector bool int, int, int *);
13839 void vec_ste (vector bool int, int, unsigned int *);
13841 void vec_stvewx (vector float, int, float *);
13842 void vec_stvewx (vector signed int, int, int *);
13843 void vec_stvewx (vector unsigned int, int, unsigned int *);
13844 void vec_stvewx (vector bool int, int, int *);
13845 void vec_stvewx (vector bool int, int, unsigned int *);
13847 void vec_stvehx (vector signed short, int, short *);
13848 void vec_stvehx (vector unsigned short, int, unsigned short *);
13849 void vec_stvehx (vector bool short, int, short *);
13850 void vec_stvehx (vector bool short, int, unsigned short *);
13851 void vec_stvehx (vector pixel, int, short *);
13852 void vec_stvehx (vector pixel, int, unsigned short *);
13854 void vec_stvebx (vector signed char, int, signed char *);
13855 void vec_stvebx (vector unsigned char, int, unsigned char *);
13856 void vec_stvebx (vector bool char, int, signed char *);
13857 void vec_stvebx (vector bool char, int, unsigned char *);
13859 void vec_stl (vector float, int, vector float *);
13860 void vec_stl (vector float, int, float *);
13861 void vec_stl (vector signed int, int, vector signed int *);
13862 void vec_stl (vector signed int, int, int *);
13863 void vec_stl (vector unsigned int, int, vector unsigned int *);
13864 void vec_stl (vector unsigned int, int, unsigned int *);
13865 void vec_stl (vector bool int, int, vector bool int *);
13866 void vec_stl (vector bool int, int, unsigned int *);
13867 void vec_stl (vector bool int, int, int *);
13868 void vec_stl (vector signed short, int, vector signed short *);
13869 void vec_stl (vector signed short, int, short *);
13870 void vec_stl (vector unsigned short, int, vector unsigned short *);
13871 void vec_stl (vector unsigned short, int, unsigned short *);
13872 void vec_stl (vector bool short, int, vector bool short *);
13873 void vec_stl (vector bool short, int, unsigned short *);
13874 void vec_stl (vector bool short, int, short *);
13875 void vec_stl (vector pixel, int, vector pixel *);
13876 void vec_stl (vector pixel, int, unsigned short *);
13877 void vec_stl (vector pixel, int, short *);
13878 void vec_stl (vector signed char, int, vector signed char *);
13879 void vec_stl (vector signed char, int, signed char *);
13880 void vec_stl (vector unsigned char, int, vector unsigned char *);
13881 void vec_stl (vector unsigned char, int, unsigned char *);
13882 void vec_stl (vector bool char, int, vector bool char *);
13883 void vec_stl (vector bool char, int, unsigned char *);
13884 void vec_stl (vector bool char, int, signed char *);
13886 vector signed char vec_sub (vector bool char, vector signed char);
13887 vector signed char vec_sub (vector signed char, vector bool char);
13888 vector signed char vec_sub (vector signed char, vector signed char);
13889 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13890 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13891 vector unsigned char vec_sub (vector unsigned char,
13892                               vector unsigned char);
13893 vector signed short vec_sub (vector bool short, vector signed short);
13894 vector signed short vec_sub (vector signed short, vector bool short);
13895 vector signed short vec_sub (vector signed short, vector signed short);
13896 vector unsigned short vec_sub (vector bool short,
13897                                vector unsigned short);
13898 vector unsigned short vec_sub (vector unsigned short,
13899                                vector bool short);
13900 vector unsigned short vec_sub (vector unsigned short,
13901                                vector unsigned short);
13902 vector signed int vec_sub (vector bool int, vector signed int);
13903 vector signed int vec_sub (vector signed int, vector bool int);
13904 vector signed int vec_sub (vector signed int, vector signed int);
13905 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13906 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13907 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13908 vector float vec_sub (vector float, vector float);
13910 vector float vec_vsubfp (vector float, vector float);
13912 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13913 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13914 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13915 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13916 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13917 vector unsigned int vec_vsubuwm (vector unsigned int,
13918                                  vector unsigned int);
13920 vector signed short vec_vsubuhm (vector bool short,
13921                                  vector signed short);
13922 vector signed short vec_vsubuhm (vector signed short,
13923                                  vector bool short);
13924 vector signed short vec_vsubuhm (vector signed short,
13925                                  vector signed short);
13926 vector unsigned short vec_vsubuhm (vector bool short,
13927                                    vector unsigned short);
13928 vector unsigned short vec_vsubuhm (vector unsigned short,
13929                                    vector bool short);
13930 vector unsigned short vec_vsubuhm (vector unsigned short,
13931                                    vector unsigned short);
13933 vector signed char vec_vsububm (vector bool char, vector signed char);
13934 vector signed char vec_vsububm (vector signed char, vector bool char);
13935 vector signed char vec_vsububm (vector signed char, vector signed char);
13936 vector unsigned char vec_vsububm (vector bool char,
13937                                   vector unsigned char);
13938 vector unsigned char vec_vsububm (vector unsigned char,
13939                                   vector bool char);
13940 vector unsigned char vec_vsububm (vector unsigned char,
13941                                   vector unsigned char);
13943 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13945 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13946 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13947 vector unsigned char vec_subs (vector unsigned char,
13948                                vector unsigned char);
13949 vector signed char vec_subs (vector bool char, vector signed char);
13950 vector signed char vec_subs (vector signed char, vector bool char);
13951 vector signed char vec_subs (vector signed char, vector signed char);
13952 vector unsigned short vec_subs (vector bool short,
13953                                 vector unsigned short);
13954 vector unsigned short vec_subs (vector unsigned short,
13955                                 vector bool short);
13956 vector unsigned short vec_subs (vector unsigned short,
13957                                 vector unsigned short);
13958 vector signed short vec_subs (vector bool short, vector signed short);
13959 vector signed short vec_subs (vector signed short, vector bool short);
13960 vector signed short vec_subs (vector signed short, vector signed short);
13961 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13962 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13963 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13964 vector signed int vec_subs (vector bool int, vector signed int);
13965 vector signed int vec_subs (vector signed int, vector bool int);
13966 vector signed int vec_subs (vector signed int, vector signed int);
13968 vector signed int vec_vsubsws (vector bool int, vector signed int);
13969 vector signed int vec_vsubsws (vector signed int, vector bool int);
13970 vector signed int vec_vsubsws (vector signed int, vector signed int);
13972 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13973 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13974 vector unsigned int vec_vsubuws (vector unsigned int,
13975                                  vector unsigned int);
13977 vector signed short vec_vsubshs (vector bool short,
13978                                  vector signed short);
13979 vector signed short vec_vsubshs (vector signed short,
13980                                  vector bool short);
13981 vector signed short vec_vsubshs (vector signed short,
13982                                  vector signed short);
13984 vector unsigned short vec_vsubuhs (vector bool short,
13985                                    vector unsigned short);
13986 vector unsigned short vec_vsubuhs (vector unsigned short,
13987                                    vector bool short);
13988 vector unsigned short vec_vsubuhs (vector unsigned short,
13989                                    vector unsigned short);
13991 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13992 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13993 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13995 vector unsigned char vec_vsububs (vector bool char,
13996                                   vector unsigned char);
13997 vector unsigned char vec_vsububs (vector unsigned char,
13998                                   vector bool char);
13999 vector unsigned char vec_vsububs (vector unsigned char,
14000                                   vector unsigned char);
14002 vector unsigned int vec_sum4s (vector unsigned char,
14003                                vector unsigned int);
14004 vector signed int vec_sum4s (vector signed char, vector signed int);
14005 vector signed int vec_sum4s (vector signed short, vector signed int);
14007 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14009 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14011 vector unsigned int vec_vsum4ubs (vector unsigned char,
14012                                   vector unsigned int);
14014 vector signed int vec_sum2s (vector signed int, vector signed int);
14016 vector signed int vec_sums (vector signed int, vector signed int);
14018 vector float vec_trunc (vector float);
14020 vector signed short vec_unpackh (vector signed char);
14021 vector bool short vec_unpackh (vector bool char);
14022 vector signed int vec_unpackh (vector signed short);
14023 vector bool int vec_unpackh (vector bool short);
14024 vector unsigned int vec_unpackh (vector pixel);
14026 vector bool int vec_vupkhsh (vector bool short);
14027 vector signed int vec_vupkhsh (vector signed short);
14029 vector unsigned int vec_vupkhpx (vector pixel);
14031 vector bool short vec_vupkhsb (vector bool char);
14032 vector signed short vec_vupkhsb (vector signed char);
14034 vector signed short vec_unpackl (vector signed char);
14035 vector bool short vec_unpackl (vector bool char);
14036 vector unsigned int vec_unpackl (vector pixel);
14037 vector signed int vec_unpackl (vector signed short);
14038 vector bool int vec_unpackl (vector bool short);
14040 vector unsigned int vec_vupklpx (vector pixel);
14042 vector bool int vec_vupklsh (vector bool short);
14043 vector signed int vec_vupklsh (vector signed short);
14045 vector bool short vec_vupklsb (vector bool char);
14046 vector signed short vec_vupklsb (vector signed char);
14048 vector float vec_xor (vector float, vector float);
14049 vector float vec_xor (vector float, vector bool int);
14050 vector float vec_xor (vector bool int, vector float);
14051 vector bool int vec_xor (vector bool int, vector bool int);
14052 vector signed int vec_xor (vector bool int, vector signed int);
14053 vector signed int vec_xor (vector signed int, vector bool int);
14054 vector signed int vec_xor (vector signed int, vector signed int);
14055 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14056 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14057 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14058 vector bool short vec_xor (vector bool short, vector bool short);
14059 vector signed short vec_xor (vector bool short, vector signed short);
14060 vector signed short vec_xor (vector signed short, vector bool short);
14061 vector signed short vec_xor (vector signed short, vector signed short);
14062 vector unsigned short vec_xor (vector bool short,
14063                                vector unsigned short);
14064 vector unsigned short vec_xor (vector unsigned short,
14065                                vector bool short);
14066 vector unsigned short vec_xor (vector unsigned short,
14067                                vector unsigned short);
14068 vector signed char vec_xor (vector bool char, vector signed char);
14069 vector bool char vec_xor (vector bool char, vector bool char);
14070 vector signed char vec_xor (vector signed char, vector bool char);
14071 vector signed char vec_xor (vector signed char, vector signed char);
14072 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14073 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14074 vector unsigned char vec_xor (vector unsigned char,
14075                               vector unsigned char);
14077 int vec_all_eq (vector signed char, vector bool char);
14078 int vec_all_eq (vector signed char, vector signed char);
14079 int vec_all_eq (vector unsigned char, vector bool char);
14080 int vec_all_eq (vector unsigned char, vector unsigned char);
14081 int vec_all_eq (vector bool char, vector bool char);
14082 int vec_all_eq (vector bool char, vector unsigned char);
14083 int vec_all_eq (vector bool char, vector signed char);
14084 int vec_all_eq (vector signed short, vector bool short);
14085 int vec_all_eq (vector signed short, vector signed short);
14086 int vec_all_eq (vector unsigned short, vector bool short);
14087 int vec_all_eq (vector unsigned short, vector unsigned short);
14088 int vec_all_eq (vector bool short, vector bool short);
14089 int vec_all_eq (vector bool short, vector unsigned short);
14090 int vec_all_eq (vector bool short, vector signed short);
14091 int vec_all_eq (vector pixel, vector pixel);
14092 int vec_all_eq (vector signed int, vector bool int);
14093 int vec_all_eq (vector signed int, vector signed int);
14094 int vec_all_eq (vector unsigned int, vector bool int);
14095 int vec_all_eq (vector unsigned int, vector unsigned int);
14096 int vec_all_eq (vector bool int, vector bool int);
14097 int vec_all_eq (vector bool int, vector unsigned int);
14098 int vec_all_eq (vector bool int, vector signed int);
14099 int vec_all_eq (vector float, vector float);
14101 int vec_all_ge (vector bool char, vector unsigned char);
14102 int vec_all_ge (vector unsigned char, vector bool char);
14103 int vec_all_ge (vector unsigned char, vector unsigned char);
14104 int vec_all_ge (vector bool char, vector signed char);
14105 int vec_all_ge (vector signed char, vector bool char);
14106 int vec_all_ge (vector signed char, vector signed char);
14107 int vec_all_ge (vector bool short, vector unsigned short);
14108 int vec_all_ge (vector unsigned short, vector bool short);
14109 int vec_all_ge (vector unsigned short, vector unsigned short);
14110 int vec_all_ge (vector signed short, vector signed short);
14111 int vec_all_ge (vector bool short, vector signed short);
14112 int vec_all_ge (vector signed short, vector bool short);
14113 int vec_all_ge (vector bool int, vector unsigned int);
14114 int vec_all_ge (vector unsigned int, vector bool int);
14115 int vec_all_ge (vector unsigned int, vector unsigned int);
14116 int vec_all_ge (vector bool int, vector signed int);
14117 int vec_all_ge (vector signed int, vector bool int);
14118 int vec_all_ge (vector signed int, vector signed int);
14119 int vec_all_ge (vector float, vector float);
14121 int vec_all_gt (vector bool char, vector unsigned char);
14122 int vec_all_gt (vector unsigned char, vector bool char);
14123 int vec_all_gt (vector unsigned char, vector unsigned char);
14124 int vec_all_gt (vector bool char, vector signed char);
14125 int vec_all_gt (vector signed char, vector bool char);
14126 int vec_all_gt (vector signed char, vector signed char);
14127 int vec_all_gt (vector bool short, vector unsigned short);
14128 int vec_all_gt (vector unsigned short, vector bool short);
14129 int vec_all_gt (vector unsigned short, vector unsigned short);
14130 int vec_all_gt (vector bool short, vector signed short);
14131 int vec_all_gt (vector signed short, vector bool short);
14132 int vec_all_gt (vector signed short, vector signed short);
14133 int vec_all_gt (vector bool int, vector unsigned int);
14134 int vec_all_gt (vector unsigned int, vector bool int);
14135 int vec_all_gt (vector unsigned int, vector unsigned int);
14136 int vec_all_gt (vector bool int, vector signed int);
14137 int vec_all_gt (vector signed int, vector bool int);
14138 int vec_all_gt (vector signed int, vector signed int);
14139 int vec_all_gt (vector float, vector float);
14141 int vec_all_in (vector float, vector float);
14143 int vec_all_le (vector bool char, vector unsigned char);
14144 int vec_all_le (vector unsigned char, vector bool char);
14145 int vec_all_le (vector unsigned char, vector unsigned char);
14146 int vec_all_le (vector bool char, vector signed char);
14147 int vec_all_le (vector signed char, vector bool char);
14148 int vec_all_le (vector signed char, vector signed char);
14149 int vec_all_le (vector bool short, vector unsigned short);
14150 int vec_all_le (vector unsigned short, vector bool short);
14151 int vec_all_le (vector unsigned short, vector unsigned short);
14152 int vec_all_le (vector bool short, vector signed short);
14153 int vec_all_le (vector signed short, vector bool short);
14154 int vec_all_le (vector signed short, vector signed short);
14155 int vec_all_le (vector bool int, vector unsigned int);
14156 int vec_all_le (vector unsigned int, vector bool int);
14157 int vec_all_le (vector unsigned int, vector unsigned int);
14158 int vec_all_le (vector bool int, vector signed int);
14159 int vec_all_le (vector signed int, vector bool int);
14160 int vec_all_le (vector signed int, vector signed int);
14161 int vec_all_le (vector float, vector float);
14163 int vec_all_lt (vector bool char, vector unsigned char);
14164 int vec_all_lt (vector unsigned char, vector bool char);
14165 int vec_all_lt (vector unsigned char, vector unsigned char);
14166 int vec_all_lt (vector bool char, vector signed char);
14167 int vec_all_lt (vector signed char, vector bool char);
14168 int vec_all_lt (vector signed char, vector signed char);
14169 int vec_all_lt (vector bool short, vector unsigned short);
14170 int vec_all_lt (vector unsigned short, vector bool short);
14171 int vec_all_lt (vector unsigned short, vector unsigned short);
14172 int vec_all_lt (vector bool short, vector signed short);
14173 int vec_all_lt (vector signed short, vector bool short);
14174 int vec_all_lt (vector signed short, vector signed short);
14175 int vec_all_lt (vector bool int, vector unsigned int);
14176 int vec_all_lt (vector unsigned int, vector bool int);
14177 int vec_all_lt (vector unsigned int, vector unsigned int);
14178 int vec_all_lt (vector bool int, vector signed int);
14179 int vec_all_lt (vector signed int, vector bool int);
14180 int vec_all_lt (vector signed int, vector signed int);
14181 int vec_all_lt (vector float, vector float);
14183 int vec_all_nan (vector float);
14185 int vec_all_ne (vector signed char, vector bool char);
14186 int vec_all_ne (vector signed char, vector signed char);
14187 int vec_all_ne (vector unsigned char, vector bool char);
14188 int vec_all_ne (vector unsigned char, vector unsigned char);
14189 int vec_all_ne (vector bool char, vector bool char);
14190 int vec_all_ne (vector bool char, vector unsigned char);
14191 int vec_all_ne (vector bool char, vector signed char);
14192 int vec_all_ne (vector signed short, vector bool short);
14193 int vec_all_ne (vector signed short, vector signed short);
14194 int vec_all_ne (vector unsigned short, vector bool short);
14195 int vec_all_ne (vector unsigned short, vector unsigned short);
14196 int vec_all_ne (vector bool short, vector bool short);
14197 int vec_all_ne (vector bool short, vector unsigned short);
14198 int vec_all_ne (vector bool short, vector signed short);
14199 int vec_all_ne (vector pixel, vector pixel);
14200 int vec_all_ne (vector signed int, vector bool int);
14201 int vec_all_ne (vector signed int, vector signed int);
14202 int vec_all_ne (vector unsigned int, vector bool int);
14203 int vec_all_ne (vector unsigned int, vector unsigned int);
14204 int vec_all_ne (vector bool int, vector bool int);
14205 int vec_all_ne (vector bool int, vector unsigned int);
14206 int vec_all_ne (vector bool int, vector signed int);
14207 int vec_all_ne (vector float, vector float);
14209 int vec_all_nge (vector float, vector float);
14211 int vec_all_ngt (vector float, vector float);
14213 int vec_all_nle (vector float, vector float);
14215 int vec_all_nlt (vector float, vector float);
14217 int vec_all_numeric (vector float);
14219 int vec_any_eq (vector signed char, vector bool char);
14220 int vec_any_eq (vector signed char, vector signed char);
14221 int vec_any_eq (vector unsigned char, vector bool char);
14222 int vec_any_eq (vector unsigned char, vector unsigned char);
14223 int vec_any_eq (vector bool char, vector bool char);
14224 int vec_any_eq (vector bool char, vector unsigned char);
14225 int vec_any_eq (vector bool char, vector signed char);
14226 int vec_any_eq (vector signed short, vector bool short);
14227 int vec_any_eq (vector signed short, vector signed short);
14228 int vec_any_eq (vector unsigned short, vector bool short);
14229 int vec_any_eq (vector unsigned short, vector unsigned short);
14230 int vec_any_eq (vector bool short, vector bool short);
14231 int vec_any_eq (vector bool short, vector unsigned short);
14232 int vec_any_eq (vector bool short, vector signed short);
14233 int vec_any_eq (vector pixel, vector pixel);
14234 int vec_any_eq (vector signed int, vector bool int);
14235 int vec_any_eq (vector signed int, vector signed int);
14236 int vec_any_eq (vector unsigned int, vector bool int);
14237 int vec_any_eq (vector unsigned int, vector unsigned int);
14238 int vec_any_eq (vector bool int, vector bool int);
14239 int vec_any_eq (vector bool int, vector unsigned int);
14240 int vec_any_eq (vector bool int, vector signed int);
14241 int vec_any_eq (vector float, vector float);
14243 int vec_any_ge (vector signed char, vector bool char);
14244 int vec_any_ge (vector unsigned char, vector bool char);
14245 int vec_any_ge (vector unsigned char, vector unsigned char);
14246 int vec_any_ge (vector signed char, vector signed char);
14247 int vec_any_ge (vector bool char, vector unsigned char);
14248 int vec_any_ge (vector bool char, vector signed char);
14249 int vec_any_ge (vector unsigned short, vector bool short);
14250 int vec_any_ge (vector unsigned short, vector unsigned short);
14251 int vec_any_ge (vector signed short, vector signed short);
14252 int vec_any_ge (vector signed short, vector bool short);
14253 int vec_any_ge (vector bool short, vector unsigned short);
14254 int vec_any_ge (vector bool short, vector signed short);
14255 int vec_any_ge (vector signed int, vector bool int);
14256 int vec_any_ge (vector unsigned int, vector bool int);
14257 int vec_any_ge (vector unsigned int, vector unsigned int);
14258 int vec_any_ge (vector signed int, vector signed int);
14259 int vec_any_ge (vector bool int, vector unsigned int);
14260 int vec_any_ge (vector bool int, vector signed int);
14261 int vec_any_ge (vector float, vector float);
14263 int vec_any_gt (vector bool char, vector unsigned char);
14264 int vec_any_gt (vector unsigned char, vector bool char);
14265 int vec_any_gt (vector unsigned char, vector unsigned char);
14266 int vec_any_gt (vector bool char, vector signed char);
14267 int vec_any_gt (vector signed char, vector bool char);
14268 int vec_any_gt (vector signed char, vector signed char);
14269 int vec_any_gt (vector bool short, vector unsigned short);
14270 int vec_any_gt (vector unsigned short, vector bool short);
14271 int vec_any_gt (vector unsigned short, vector unsigned short);
14272 int vec_any_gt (vector bool short, vector signed short);
14273 int vec_any_gt (vector signed short, vector bool short);
14274 int vec_any_gt (vector signed short, vector signed short);
14275 int vec_any_gt (vector bool int, vector unsigned int);
14276 int vec_any_gt (vector unsigned int, vector bool int);
14277 int vec_any_gt (vector unsigned int, vector unsigned int);
14278 int vec_any_gt (vector bool int, vector signed int);
14279 int vec_any_gt (vector signed int, vector bool int);
14280 int vec_any_gt (vector signed int, vector signed int);
14281 int vec_any_gt (vector float, vector float);
14283 int vec_any_le (vector bool char, vector unsigned char);
14284 int vec_any_le (vector unsigned char, vector bool char);
14285 int vec_any_le (vector unsigned char, vector unsigned char);
14286 int vec_any_le (vector bool char, vector signed char);
14287 int vec_any_le (vector signed char, vector bool char);
14288 int vec_any_le (vector signed char, vector signed char);
14289 int vec_any_le (vector bool short, vector unsigned short);
14290 int vec_any_le (vector unsigned short, vector bool short);
14291 int vec_any_le (vector unsigned short, vector unsigned short);
14292 int vec_any_le (vector bool short, vector signed short);
14293 int vec_any_le (vector signed short, vector bool short);
14294 int vec_any_le (vector signed short, vector signed short);
14295 int vec_any_le (vector bool int, vector unsigned int);
14296 int vec_any_le (vector unsigned int, vector bool int);
14297 int vec_any_le (vector unsigned int, vector unsigned int);
14298 int vec_any_le (vector bool int, vector signed int);
14299 int vec_any_le (vector signed int, vector bool int);
14300 int vec_any_le (vector signed int, vector signed int);
14301 int vec_any_le (vector float, vector float);
14303 int vec_any_lt (vector bool char, vector unsigned char);
14304 int vec_any_lt (vector unsigned char, vector bool char);
14305 int vec_any_lt (vector unsigned char, vector unsigned char);
14306 int vec_any_lt (vector bool char, vector signed char);
14307 int vec_any_lt (vector signed char, vector bool char);
14308 int vec_any_lt (vector signed char, vector signed char);
14309 int vec_any_lt (vector bool short, vector unsigned short);
14310 int vec_any_lt (vector unsigned short, vector bool short);
14311 int vec_any_lt (vector unsigned short, vector unsigned short);
14312 int vec_any_lt (vector bool short, vector signed short);
14313 int vec_any_lt (vector signed short, vector bool short);
14314 int vec_any_lt (vector signed short, vector signed short);
14315 int vec_any_lt (vector bool int, vector unsigned int);
14316 int vec_any_lt (vector unsigned int, vector bool int);
14317 int vec_any_lt (vector unsigned int, vector unsigned int);
14318 int vec_any_lt (vector bool int, vector signed int);
14319 int vec_any_lt (vector signed int, vector bool int);
14320 int vec_any_lt (vector signed int, vector signed int);
14321 int vec_any_lt (vector float, vector float);
14323 int vec_any_nan (vector float);
14325 int vec_any_ne (vector signed char, vector bool char);
14326 int vec_any_ne (vector signed char, vector signed char);
14327 int vec_any_ne (vector unsigned char, vector bool char);
14328 int vec_any_ne (vector unsigned char, vector unsigned char);
14329 int vec_any_ne (vector bool char, vector bool char);
14330 int vec_any_ne (vector bool char, vector unsigned char);
14331 int vec_any_ne (vector bool char, vector signed char);
14332 int vec_any_ne (vector signed short, vector bool short);
14333 int vec_any_ne (vector signed short, vector signed short);
14334 int vec_any_ne (vector unsigned short, vector bool short);
14335 int vec_any_ne (vector unsigned short, vector unsigned short);
14336 int vec_any_ne (vector bool short, vector bool short);
14337 int vec_any_ne (vector bool short, vector unsigned short);
14338 int vec_any_ne (vector bool short, vector signed short);
14339 int vec_any_ne (vector pixel, vector pixel);
14340 int vec_any_ne (vector signed int, vector bool int);
14341 int vec_any_ne (vector signed int, vector signed int);
14342 int vec_any_ne (vector unsigned int, vector bool int);
14343 int vec_any_ne (vector unsigned int, vector unsigned int);
14344 int vec_any_ne (vector bool int, vector bool int);
14345 int vec_any_ne (vector bool int, vector unsigned int);
14346 int vec_any_ne (vector bool int, vector signed int);
14347 int vec_any_ne (vector float, vector float);
14349 int vec_any_nge (vector float, vector float);
14351 int vec_any_ngt (vector float, vector float);
14353 int vec_any_nle (vector float, vector float);
14355 int vec_any_nlt (vector float, vector float);
14357 int vec_any_numeric (vector float);
14359 int vec_any_out (vector float, vector float);
14360 @end smallexample
14362 If the vector/scalar (VSX) instruction set is available, the following
14363 additional functions are available:
14365 @smallexample
14366 vector double vec_abs (vector double);
14367 vector double vec_add (vector double, vector double);
14368 vector double vec_and (vector double, vector double);
14369 vector double vec_and (vector double, vector bool long);
14370 vector double vec_and (vector bool long, vector double);
14371 vector double vec_andc (vector double, vector double);
14372 vector double vec_andc (vector double, vector bool long);
14373 vector double vec_andc (vector bool long, vector double);
14374 vector double vec_ceil (vector double);
14375 vector bool long vec_cmpeq (vector double, vector double);
14376 vector bool long vec_cmpge (vector double, vector double);
14377 vector bool long vec_cmpgt (vector double, vector double);
14378 vector bool long vec_cmple (vector double, vector double);
14379 vector bool long vec_cmplt (vector double, vector double);
14380 vector float vec_div (vector float, vector float);
14381 vector double vec_div (vector double, vector double);
14382 vector double vec_floor (vector double);
14383 vector double vec_ld (int, const vector double *);
14384 vector double vec_ld (int, const double *);
14385 vector double vec_ldl (int, const vector double *);
14386 vector double vec_ldl (int, const double *);
14387 vector unsigned char vec_lvsl (int, const volatile double *);
14388 vector unsigned char vec_lvsr (int, const volatile double *);
14389 vector double vec_madd (vector double, vector double, vector double);
14390 vector double vec_max (vector double, vector double);
14391 vector double vec_min (vector double, vector double);
14392 vector float vec_msub (vector float, vector float, vector float);
14393 vector double vec_msub (vector double, vector double, vector double);
14394 vector float vec_mul (vector float, vector float);
14395 vector double vec_mul (vector double, vector double);
14396 vector float vec_nearbyint (vector float);
14397 vector double vec_nearbyint (vector double);
14398 vector float vec_nmadd (vector float, vector float, vector float);
14399 vector double vec_nmadd (vector double, vector double, vector double);
14400 vector double vec_nmsub (vector double, vector double, vector double);
14401 vector double vec_nor (vector double, vector double);
14402 vector double vec_or (vector double, vector double);
14403 vector double vec_or (vector double, vector bool long);
14404 vector double vec_or (vector bool long, vector double);
14405 vector double vec_perm (vector double,
14406                         vector double,
14407                         vector unsigned char);
14408 vector double vec_rint (vector double);
14409 vector double vec_recip (vector double, vector double);
14410 vector double vec_rsqrt (vector double);
14411 vector double vec_rsqrte (vector double);
14412 vector double vec_sel (vector double, vector double, vector bool long);
14413 vector double vec_sel (vector double, vector double, vector unsigned long);
14414 vector double vec_sub (vector double, vector double);
14415 vector float vec_sqrt (vector float);
14416 vector double vec_sqrt (vector double);
14417 void vec_st (vector double, int, vector double *);
14418 void vec_st (vector double, int, double *);
14419 vector double vec_trunc (vector double);
14420 vector double vec_xor (vector double, vector double);
14421 vector double vec_xor (vector double, vector bool long);
14422 vector double vec_xor (vector bool long, vector double);
14423 int vec_all_eq (vector double, vector double);
14424 int vec_all_ge (vector double, vector double);
14425 int vec_all_gt (vector double, vector double);
14426 int vec_all_le (vector double, vector double);
14427 int vec_all_lt (vector double, vector double);
14428 int vec_all_nan (vector double);
14429 int vec_all_ne (vector double, vector double);
14430 int vec_all_nge (vector double, vector double);
14431 int vec_all_ngt (vector double, vector double);
14432 int vec_all_nle (vector double, vector double);
14433 int vec_all_nlt (vector double, vector double);
14434 int vec_all_numeric (vector double);
14435 int vec_any_eq (vector double, vector double);
14436 int vec_any_ge (vector double, vector double);
14437 int vec_any_gt (vector double, vector double);
14438 int vec_any_le (vector double, vector double);
14439 int vec_any_lt (vector double, vector double);
14440 int vec_any_nan (vector double);
14441 int vec_any_ne (vector double, vector double);
14442 int vec_any_nge (vector double, vector double);
14443 int vec_any_ngt (vector double, vector double);
14444 int vec_any_nle (vector double, vector double);
14445 int vec_any_nlt (vector double, vector double);
14446 int vec_any_numeric (vector double);
14448 vector double vec_vsx_ld (int, const vector double *);
14449 vector double vec_vsx_ld (int, const double *);
14450 vector float vec_vsx_ld (int, const vector float *);
14451 vector float vec_vsx_ld (int, const float *);
14452 vector bool int vec_vsx_ld (int, const vector bool int *);
14453 vector signed int vec_vsx_ld (int, const vector signed int *);
14454 vector signed int vec_vsx_ld (int, const int *);
14455 vector signed int vec_vsx_ld (int, const long *);
14456 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
14457 vector unsigned int vec_vsx_ld (int, const unsigned int *);
14458 vector unsigned int vec_vsx_ld (int, const unsigned long *);
14459 vector bool short vec_vsx_ld (int, const vector bool short *);
14460 vector pixel vec_vsx_ld (int, const vector pixel *);
14461 vector signed short vec_vsx_ld (int, const vector signed short *);
14462 vector signed short vec_vsx_ld (int, const short *);
14463 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
14464 vector unsigned short vec_vsx_ld (int, const unsigned short *);
14465 vector bool char vec_vsx_ld (int, const vector bool char *);
14466 vector signed char vec_vsx_ld (int, const vector signed char *);
14467 vector signed char vec_vsx_ld (int, const signed char *);
14468 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
14469 vector unsigned char vec_vsx_ld (int, const unsigned char *);
14471 void vec_vsx_st (vector double, int, vector double *);
14472 void vec_vsx_st (vector double, int, double *);
14473 void vec_vsx_st (vector float, int, vector float *);
14474 void vec_vsx_st (vector float, int, float *);
14475 void vec_vsx_st (vector signed int, int, vector signed int *);
14476 void vec_vsx_st (vector signed int, int, int *);
14477 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
14478 void vec_vsx_st (vector unsigned int, int, unsigned int *);
14479 void vec_vsx_st (vector bool int, int, vector bool int *);
14480 void vec_vsx_st (vector bool int, int, unsigned int *);
14481 void vec_vsx_st (vector bool int, int, int *);
14482 void vec_vsx_st (vector signed short, int, vector signed short *);
14483 void vec_vsx_st (vector signed short, int, short *);
14484 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
14485 void vec_vsx_st (vector unsigned short, int, unsigned short *);
14486 void vec_vsx_st (vector bool short, int, vector bool short *);
14487 void vec_vsx_st (vector bool short, int, unsigned short *);
14488 void vec_vsx_st (vector pixel, int, vector pixel *);
14489 void vec_vsx_st (vector pixel, int, unsigned short *);
14490 void vec_vsx_st (vector pixel, int, short *);
14491 void vec_vsx_st (vector bool short, int, short *);
14492 void vec_vsx_st (vector signed char, int, vector signed char *);
14493 void vec_vsx_st (vector signed char, int, signed char *);
14494 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
14495 void vec_vsx_st (vector unsigned char, int, unsigned char *);
14496 void vec_vsx_st (vector bool char, int, vector bool char *);
14497 void vec_vsx_st (vector bool char, int, unsigned char *);
14498 void vec_vsx_st (vector bool char, int, signed char *);
14499 @end smallexample
14501 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
14502 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
14503 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
14504 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
14505 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
14507 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14508 instruction set is available, the following additional functions are
14509 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
14510 can use @var{vector long} instead of @var{vector long long},
14511 @var{vector bool long} instead of @var{vector bool long long}, and
14512 @var{vector unsigned long} instead of @var{vector unsigned long long}.
14514 @smallexample
14515 vector long long vec_abs (vector long long);
14517 vector long long vec_add (vector long long, vector long long);
14518 vector unsigned long long vec_add (vector unsigned long long,
14519                                    vector unsigned long long);
14521 int vec_all_eq (vector long long, vector long long);
14522 int vec_all_ge (vector long long, vector long long);
14523 int vec_all_gt (vector long long, vector long long);
14524 int vec_all_le (vector long long, vector long long);
14525 int vec_all_lt (vector long long, vector long long);
14526 int vec_all_ne (vector long long, vector long long);
14527 int vec_any_eq (vector long long, vector long long);
14528 int vec_any_ge (vector long long, vector long long);
14529 int vec_any_gt (vector long long, vector long long);
14530 int vec_any_le (vector long long, vector long long);
14531 int vec_any_lt (vector long long, vector long long);
14532 int vec_any_ne (vector long long, vector long long);
14534 vector long long vec_eqv (vector long long, vector long long);
14535 vector long long vec_eqv (vector bool long long, vector long long);
14536 vector long long vec_eqv (vector long long, vector bool long long);
14537 vector unsigned long long vec_eqv (vector unsigned long long,
14538                                    vector unsigned long long);
14539 vector unsigned long long vec_eqv (vector bool long long,
14540                                    vector unsigned long long);
14541 vector unsigned long long vec_eqv (vector unsigned long long,
14542                                    vector bool long long);
14543 vector int vec_eqv (vector int, vector int);
14544 vector int vec_eqv (vector bool int, vector int);
14545 vector int vec_eqv (vector int, vector bool int);
14546 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14547 vector unsigned int vec_eqv (vector bool unsigned int,
14548                              vector unsigned int);
14549 vector unsigned int vec_eqv (vector unsigned int,
14550                              vector bool unsigned int);
14551 vector short vec_eqv (vector short, vector short);
14552 vector short vec_eqv (vector bool short, vector short);
14553 vector short vec_eqv (vector short, vector bool short);
14554 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14555 vector unsigned short vec_eqv (vector bool unsigned short,
14556                                vector unsigned short);
14557 vector unsigned short vec_eqv (vector unsigned short,
14558                                vector bool unsigned short);
14559 vector signed char vec_eqv (vector signed char, vector signed char);
14560 vector signed char vec_eqv (vector bool signed char, vector signed char);
14561 vector signed char vec_eqv (vector signed char, vector bool signed char);
14562 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14563 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14564 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14566 vector long long vec_max (vector long long, vector long long);
14567 vector unsigned long long vec_max (vector unsigned long long,
14568                                    vector unsigned long long);
14570 vector long long vec_min (vector long long, vector long long);
14571 vector unsigned long long vec_min (vector unsigned long long,
14572                                    vector unsigned long long);
14574 vector long long vec_nand (vector long long, vector long long);
14575 vector long long vec_nand (vector bool long long, vector long long);
14576 vector long long vec_nand (vector long long, vector bool long long);
14577 vector unsigned long long vec_nand (vector unsigned long long,
14578                                     vector unsigned long long);
14579 vector unsigned long long vec_nand (vector bool long long,
14580                                    vector unsigned long long);
14581 vector unsigned long long vec_nand (vector unsigned long long,
14582                                     vector bool long long);
14583 vector int vec_nand (vector int, vector int);
14584 vector int vec_nand (vector bool int, vector int);
14585 vector int vec_nand (vector int, vector bool int);
14586 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14587 vector unsigned int vec_nand (vector bool unsigned int,
14588                               vector unsigned int);
14589 vector unsigned int vec_nand (vector unsigned int,
14590                               vector bool unsigned int);
14591 vector short vec_nand (vector short, vector short);
14592 vector short vec_nand (vector bool short, vector short);
14593 vector short vec_nand (vector short, vector bool short);
14594 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14595 vector unsigned short vec_nand (vector bool unsigned short,
14596                                 vector unsigned short);
14597 vector unsigned short vec_nand (vector unsigned short,
14598                                 vector bool unsigned short);
14599 vector signed char vec_nand (vector signed char, vector signed char);
14600 vector signed char vec_nand (vector bool signed char, vector signed char);
14601 vector signed char vec_nand (vector signed char, vector bool signed char);
14602 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14603 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14604 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14606 vector long long vec_orc (vector long long, vector long long);
14607 vector long long vec_orc (vector bool long long, vector long long);
14608 vector long long vec_orc (vector long long, vector bool long long);
14609 vector unsigned long long vec_orc (vector unsigned long long,
14610                                    vector unsigned long long);
14611 vector unsigned long long vec_orc (vector bool long long,
14612                                    vector unsigned long long);
14613 vector unsigned long long vec_orc (vector unsigned long long,
14614                                    vector bool long long);
14615 vector int vec_orc (vector int, vector int);
14616 vector int vec_orc (vector bool int, vector int);
14617 vector int vec_orc (vector int, vector bool int);
14618 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14619 vector unsigned int vec_orc (vector bool unsigned int,
14620                              vector unsigned int);
14621 vector unsigned int vec_orc (vector unsigned int,
14622                              vector bool unsigned int);
14623 vector short vec_orc (vector short, vector short);
14624 vector short vec_orc (vector bool short, vector short);
14625 vector short vec_orc (vector short, vector bool short);
14626 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14627 vector unsigned short vec_orc (vector bool unsigned short,
14628                                vector unsigned short);
14629 vector unsigned short vec_orc (vector unsigned short,
14630                                vector bool unsigned short);
14631 vector signed char vec_orc (vector signed char, vector signed char);
14632 vector signed char vec_orc (vector bool signed char, vector signed char);
14633 vector signed char vec_orc (vector signed char, vector bool signed char);
14634 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14635 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14636 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14638 vector int vec_pack (vector long long, vector long long);
14639 vector unsigned int vec_pack (vector unsigned long long,
14640                               vector unsigned long long);
14641 vector bool int vec_pack (vector bool long long, vector bool long long);
14643 vector int vec_packs (vector long long, vector long long);
14644 vector unsigned int vec_packs (vector unsigned long long,
14645                                vector unsigned long long);
14647 vector unsigned int vec_packsu (vector long long, vector long long);
14649 vector long long vec_rl (vector long long,
14650                          vector unsigned long long);
14651 vector long long vec_rl (vector unsigned long long,
14652                          vector unsigned long long);
14654 vector long long vec_sl (vector long long, vector unsigned long long);
14655 vector long long vec_sl (vector unsigned long long,
14656                          vector unsigned long long);
14658 vector long long vec_sr (vector long long, vector unsigned long long);
14659 vector unsigned long long char vec_sr (vector unsigned long long,
14660                                        vector unsigned long long);
14662 vector long long vec_sra (vector long long, vector unsigned long long);
14663 vector unsigned long long vec_sra (vector unsigned long long,
14664                                    vector unsigned long long);
14666 vector long long vec_sub (vector long long, vector long long);
14667 vector unsigned long long vec_sub (vector unsigned long long,
14668                                    vector unsigned long long);
14670 vector long long vec_unpackh (vector int);
14671 vector unsigned long long vec_unpackh (vector unsigned int);
14673 vector long long vec_unpackl (vector int);
14674 vector unsigned long long vec_unpackl (vector unsigned int);
14676 vector long long vec_vaddudm (vector long long, vector long long);
14677 vector long long vec_vaddudm (vector bool long long, vector long long);
14678 vector long long vec_vaddudm (vector long long, vector bool long long);
14679 vector unsigned long long vec_vaddudm (vector unsigned long long,
14680                                        vector unsigned long long);
14681 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14682                                        vector unsigned long long);
14683 vector unsigned long long vec_vaddudm (vector unsigned long long,
14684                                        vector bool unsigned long long);
14686 vector long long vec_vclz (vector long long);
14687 vector unsigned long long vec_vclz (vector unsigned long long);
14688 vector int vec_vclz (vector int);
14689 vector unsigned int vec_vclz (vector int);
14690 vector short vec_vclz (vector short);
14691 vector unsigned short vec_vclz (vector unsigned short);
14692 vector signed char vec_vclz (vector signed char);
14693 vector unsigned char vec_vclz (vector unsigned char);
14695 vector signed char vec_vclzb (vector signed char);
14696 vector unsigned char vec_vclzb (vector unsigned char);
14698 vector long long vec_vclzd (vector long long);
14699 vector unsigned long long vec_vclzd (vector unsigned long long);
14701 vector short vec_vclzh (vector short);
14702 vector unsigned short vec_vclzh (vector unsigned short);
14704 vector int vec_vclzw (vector int);
14705 vector unsigned int vec_vclzw (vector int);
14707 vector long long vec_vmaxsd (vector long long, vector long long);
14709 vector unsigned long long vec_vmaxud (vector unsigned long long,
14710                                       unsigned vector long long);
14712 vector long long vec_vminsd (vector long long, vector long long);
14714 vector unsigned long long vec_vminud (vector long long,
14715                                       vector long long);
14717 vector int vec_vpksdss (vector long long, vector long long);
14718 vector unsigned int vec_vpksdss (vector long long, vector long long);
14720 vector unsigned int vec_vpkudus (vector unsigned long long,
14721                                  vector unsigned long long);
14723 vector int vec_vpkudum (vector long long, vector long long);
14724 vector unsigned int vec_vpkudum (vector unsigned long long,
14725                                  vector unsigned long long);
14726 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
14728 vector long long vec_vpopcnt (vector long long);
14729 vector unsigned long long vec_vpopcnt (vector unsigned long long);
14730 vector int vec_vpopcnt (vector int);
14731 vector unsigned int vec_vpopcnt (vector int);
14732 vector short vec_vpopcnt (vector short);
14733 vector unsigned short vec_vpopcnt (vector unsigned short);
14734 vector signed char vec_vpopcnt (vector signed char);
14735 vector unsigned char vec_vpopcnt (vector unsigned char);
14737 vector signed char vec_vpopcntb (vector signed char);
14738 vector unsigned char vec_vpopcntb (vector unsigned char);
14740 vector long long vec_vpopcntd (vector long long);
14741 vector unsigned long long vec_vpopcntd (vector unsigned long long);
14743 vector short vec_vpopcnth (vector short);
14744 vector unsigned short vec_vpopcnth (vector unsigned short);
14746 vector int vec_vpopcntw (vector int);
14747 vector unsigned int vec_vpopcntw (vector int);
14749 vector long long vec_vrld (vector long long, vector unsigned long long);
14750 vector unsigned long long vec_vrld (vector unsigned long long,
14751                                     vector unsigned long long);
14753 vector long long vec_vsld (vector long long, vector unsigned long long);
14754 vector long long vec_vsld (vector unsigned long long,
14755                            vector unsigned long long);
14757 vector long long vec_vsrad (vector long long, vector unsigned long long);
14758 vector unsigned long long vec_vsrad (vector unsigned long long,
14759                                      vector unsigned long long);
14761 vector long long vec_vsrd (vector long long, vector unsigned long long);
14762 vector unsigned long long char vec_vsrd (vector unsigned long long,
14763                                          vector unsigned long long);
14765 vector long long vec_vsubudm (vector long long, vector long long);
14766 vector long long vec_vsubudm (vector bool long long, vector long long);
14767 vector long long vec_vsubudm (vector long long, vector bool long long);
14768 vector unsigned long long vec_vsubudm (vector unsigned long long,
14769                                        vector unsigned long long);
14770 vector unsigned long long vec_vsubudm (vector bool long long,
14771                                        vector unsigned long long);
14772 vector unsigned long long vec_vsubudm (vector unsigned long long,
14773                                        vector bool long long);
14775 vector long long vec_vupkhsw (vector int);
14776 vector unsigned long long vec_vupkhsw (vector unsigned int);
14778 vector long long vec_vupklsw (vector int);
14779 vector unsigned long long vec_vupklsw (vector int);
14780 @end smallexample
14782 If the cryptographic instructions are enabled (@option{-mcrypto} or
14783 @option{-mcpu=power8}), the following builtins are enabled.
14785 @smallexample
14786 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
14788 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
14789                                                     vector unsigned long long);
14791 vector unsigned long long __builtin_crypto_vcipherlast
14792                                      (vector unsigned long long,
14793                                       vector unsigned long long);
14795 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
14796                                                      vector unsigned long long);
14798 vector unsigned long long __builtin_crypto_vncipherlast
14799                                      (vector unsigned long long,
14800                                       vector unsigned long long);
14802 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
14803                                                 vector unsigned char,
14804                                                 vector unsigned char);
14806 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
14807                                                  vector unsigned short,
14808                                                  vector unsigned short);
14810 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
14811                                                vector unsigned int,
14812                                                vector unsigned int);
14814 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
14815                                                      vector unsigned long long,
14816                                                      vector unsigned long long);
14818 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
14819                                                vector unsigned char);
14821 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
14822                                                 vector unsigned short);
14824 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
14825                                               vector unsigned int);
14827 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
14828                                                     vector unsigned long long);
14830 vector unsigned long long __builtin_crypto_vshasigmad
14831                                (vector unsigned long long, int, int);
14833 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
14834                                                  int, int);
14835 @end smallexample
14837 The second argument to the @var{__builtin_crypto_vshasigmad} and
14838 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
14839 integer that is 0 or 1.  The third argument to these builtin functions
14840 must be a constant integer in the range of 0 to 15.
14842 @node RX Built-in Functions
14843 @subsection RX Built-in Functions
14844 GCC supports some of the RX instructions which cannot be expressed in
14845 the C programming language via the use of built-in functions.  The
14846 following functions are supported:
14848 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
14849 Generates the @code{brk} machine instruction.
14850 @end deftypefn
14852 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
14853 Generates the @code{clrpsw} machine instruction to clear the specified
14854 bit in the processor status word.
14855 @end deftypefn
14857 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
14858 Generates the @code{int} machine instruction to generate an interrupt
14859 with the specified value.
14860 @end deftypefn
14862 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
14863 Generates the @code{machi} machine instruction to add the result of
14864 multiplying the top 16 bits of the two arguments into the
14865 accumulator.
14866 @end deftypefn
14868 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
14869 Generates the @code{maclo} machine instruction to add the result of
14870 multiplying the bottom 16 bits of the two arguments into the
14871 accumulator.
14872 @end deftypefn
14874 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
14875 Generates the @code{mulhi} machine instruction to place the result of
14876 multiplying the top 16 bits of the two arguments into the
14877 accumulator.
14878 @end deftypefn
14880 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
14881 Generates the @code{mullo} machine instruction to place the result of
14882 multiplying the bottom 16 bits of the two arguments into the
14883 accumulator.
14884 @end deftypefn
14886 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
14887 Generates the @code{mvfachi} machine instruction to read the top
14888 32 bits of the accumulator.
14889 @end deftypefn
14891 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
14892 Generates the @code{mvfacmi} machine instruction to read the middle
14893 32 bits of the accumulator.
14894 @end deftypefn
14896 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
14897 Generates the @code{mvfc} machine instruction which reads the control
14898 register specified in its argument and returns its value.
14899 @end deftypefn
14901 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
14902 Generates the @code{mvtachi} machine instruction to set the top
14903 32 bits of the accumulator.
14904 @end deftypefn
14906 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
14907 Generates the @code{mvtaclo} machine instruction to set the bottom
14908 32 bits of the accumulator.
14909 @end deftypefn
14911 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
14912 Generates the @code{mvtc} machine instruction which sets control
14913 register number @code{reg} to @code{val}.
14914 @end deftypefn
14916 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
14917 Generates the @code{mvtipl} machine instruction set the interrupt
14918 priority level.
14919 @end deftypefn
14921 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
14922 Generates the @code{racw} machine instruction to round the accumulator
14923 according to the specified mode.
14924 @end deftypefn
14926 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
14927 Generates the @code{revw} machine instruction which swaps the bytes in
14928 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
14929 and also bits 16--23 occupy bits 24--31 and vice versa.
14930 @end deftypefn
14932 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
14933 Generates the @code{rmpa} machine instruction which initiates a
14934 repeated multiply and accumulate sequence.
14935 @end deftypefn
14937 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
14938 Generates the @code{round} machine instruction which returns the
14939 floating-point argument rounded according to the current rounding mode
14940 set in the floating-point status word register.
14941 @end deftypefn
14943 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
14944 Generates the @code{sat} machine instruction which returns the
14945 saturated value of the argument.
14946 @end deftypefn
14948 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
14949 Generates the @code{setpsw} machine instruction to set the specified
14950 bit in the processor status word.
14951 @end deftypefn
14953 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
14954 Generates the @code{wait} machine instruction.
14955 @end deftypefn
14957 @node S/390 System z Built-in Functions
14958 @subsection S/390 System z Built-in Functions
14959 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
14960 Generates the @code{tbegin} machine instruction starting a
14961 non-constraint hardware transaction.  If the parameter is non-NULL the
14962 memory area is used to store the transaction diagnostic buffer and
14963 will be passed as first operand to @code{tbegin}.  This buffer can be
14964 defined using the @code{struct __htm_tdb} C struct defined in
14965 @code{htmintrin.h} and must reside on a double-word boundary.  The
14966 second tbegin operand is set to @code{0xff0c}. This enables
14967 save/restore of all GPRs and disables aborts for FPR and AR
14968 manipulations inside the transaction body.  The condition code set by
14969 the tbegin instruction is returned as integer value.  The tbegin
14970 instruction by definition overwrites the content of all FPRs.  The
14971 compiler will generate code which saves and restores the FPRs.  For
14972 soft-float code it is recommended to used the @code{*_nofloat}
14973 variant.  In order to prevent a TDB from being written it is required
14974 to pass an constant zero value as parameter.  Passing the zero value
14975 through a variable is not sufficient.  Although modifications of
14976 access registers inside the transaction will not trigger an
14977 transaction abort it is not supported to actually modify them.  Access
14978 registers do not get saved when entering a transaction. They will have
14979 undefined state when reaching the abort code.
14980 @end deftypefn
14982 Macros for the possible return codes of tbegin are defined in the
14983 @code{htmintrin.h} header file:
14985 @table @code
14986 @item _HTM_TBEGIN_STARTED
14987 @code{tbegin} has been executed as part of normal processing.  The
14988 transaction body is supposed to be executed.
14989 @item _HTM_TBEGIN_INDETERMINATE
14990 The transaction was aborted due to an indeterminate condition which
14991 might be persistent.
14992 @item _HTM_TBEGIN_TRANSIENT
14993 The transaction aborted due to a transient failure.  The transaction
14994 should be re-executed in that case.
14995 @item _HTM_TBEGIN_PERSISTENT
14996 The transaction aborted due to a persistent failure.  Re-execution
14997 under same circumstances will not be productive.
14998 @end table
15000 @defmac _HTM_FIRST_USER_ABORT_CODE
15001 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15002 specifies the first abort code which can be used for
15003 @code{__builtin_tabort}.  Values below this threshold are reserved for
15004 machine use.
15005 @end defmac
15007 @deftp {Data type} {struct __htm_tdb}
15008 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15009 the structure of the transaction diagnostic block as specified in the
15010 Principles of Operation manual chapter 5-91.
15011 @end deftp
15013 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15014 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15015 Using this variant in code making use of FPRs will leave the FPRs in
15016 undefined state when entering the transaction abort handler code.
15017 @end deftypefn
15019 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15020 In addition to @code{__builtin_tbegin} a loop for transient failures
15021 is generated.  If tbegin returns a condition code of 2 the transaction
15022 will be retried as often as specified in the second argument.  The
15023 perform processor assist instruction is used to tell the CPU about the
15024 number of fails so far.
15025 @end deftypefn
15027 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15028 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15029 restores.  Using this variant in code making use of FPRs will leave
15030 the FPRs in undefined state when entering the transaction abort
15031 handler code.
15032 @end deftypefn
15034 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15035 Generates the @code{tbeginc} machine instruction starting a constraint
15036 hardware transaction.  The second operand is set to @code{0xff08}.
15037 @end deftypefn
15039 @deftypefn {Built-in Function} int __builtin_tend (void)
15040 Generates the @code{tend} machine instruction finishing a transaction
15041 and making the changes visible to other threads.  The condition code
15042 generated by tend is returned as integer value.
15043 @end deftypefn
15045 @deftypefn {Built-in Function} void __builtin_tabort (int)
15046 Generates the @code{tabort} machine instruction with the specified
15047 abort code.  Abort codes from 0 through 255 are reserved and will
15048 result in an error message.
15049 @end deftypefn
15051 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15052 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
15053 integer parameter is loaded into rX and a value of zero is loaded into
15054 rY.  The integer parameter specifies the number of times the
15055 transaction repeatedly aborted.
15056 @end deftypefn
15058 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15059 Generates the @code{etnd} machine instruction.  The current nesting
15060 depth is returned as integer value.  For a nesting depth of 0 the code
15061 is not executed as part of an transaction.
15062 @end deftypefn
15064 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15066 Generates the @code{ntstg} machine instruction.  The second argument
15067 is written to the first arguments location.  The store operation will
15068 not be rolled-back in case of an transaction abort.
15069 @end deftypefn
15071 @node SH Built-in Functions
15072 @subsection SH Built-in Functions
15073 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
15074 families of processors:
15076 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
15077 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
15078 used by system code that manages threads and execution contexts.  The compiler
15079 normally does not generate code that modifies the contents of @samp{GBR} and
15080 thus the value is preserved across function calls.  Changing the @samp{GBR}
15081 value in user code must be done with caution, since the compiler might use
15082 @samp{GBR} in order to access thread local variables.
15084 @end deftypefn
15086 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
15087 Returns the value that is currently set in the @samp{GBR} register.
15088 Memory loads and stores that use the thread pointer as a base address are
15089 turned into @samp{GBR} based displacement loads and stores, if possible.
15090 For example:
15091 @smallexample
15092 struct my_tcb
15094    int a, b, c, d, e;
15097 int get_tcb_value (void)
15099   // Generate @samp{mov.l @@(8,gbr),r0} instruction
15100   return ((my_tcb*)__builtin_thread_pointer ())->c;
15103 @end smallexample
15104 @end deftypefn
15106 @node SPARC VIS Built-in Functions
15107 @subsection SPARC VIS Built-in Functions
15109 GCC supports SIMD operations on the SPARC using both the generic vector
15110 extensions (@pxref{Vector Extensions}) as well as built-in functions for
15111 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
15112 switch, the VIS extension is exposed as the following built-in functions:
15114 @smallexample
15115 typedef int v1si __attribute__ ((vector_size (4)));
15116 typedef int v2si __attribute__ ((vector_size (8)));
15117 typedef short v4hi __attribute__ ((vector_size (8)));
15118 typedef short v2hi __attribute__ ((vector_size (4)));
15119 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
15120 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
15122 void __builtin_vis_write_gsr (int64_t);
15123 int64_t __builtin_vis_read_gsr (void);
15125 void * __builtin_vis_alignaddr (void *, long);
15126 void * __builtin_vis_alignaddrl (void *, long);
15127 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
15128 v2si __builtin_vis_faligndatav2si (v2si, v2si);
15129 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
15130 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
15132 v4hi __builtin_vis_fexpand (v4qi);
15134 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
15135 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
15136 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
15137 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
15138 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
15139 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
15140 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
15142 v4qi __builtin_vis_fpack16 (v4hi);
15143 v8qi __builtin_vis_fpack32 (v2si, v8qi);
15144 v2hi __builtin_vis_fpackfix (v2si);
15145 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
15147 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
15149 long __builtin_vis_edge8 (void *, void *);
15150 long __builtin_vis_edge8l (void *, void *);
15151 long __builtin_vis_edge16 (void *, void *);
15152 long __builtin_vis_edge16l (void *, void *);
15153 long __builtin_vis_edge32 (void *, void *);
15154 long __builtin_vis_edge32l (void *, void *);
15156 long __builtin_vis_fcmple16 (v4hi, v4hi);
15157 long __builtin_vis_fcmple32 (v2si, v2si);
15158 long __builtin_vis_fcmpne16 (v4hi, v4hi);
15159 long __builtin_vis_fcmpne32 (v2si, v2si);
15160 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
15161 long __builtin_vis_fcmpgt32 (v2si, v2si);
15162 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
15163 long __builtin_vis_fcmpeq32 (v2si, v2si);
15165 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
15166 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
15167 v2si __builtin_vis_fpadd32 (v2si, v2si);
15168 v1si __builtin_vis_fpadd32s (v1si, v1si);
15169 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
15170 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
15171 v2si __builtin_vis_fpsub32 (v2si, v2si);
15172 v1si __builtin_vis_fpsub32s (v1si, v1si);
15174 long __builtin_vis_array8 (long, long);
15175 long __builtin_vis_array16 (long, long);
15176 long __builtin_vis_array32 (long, long);
15177 @end smallexample
15179 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
15180 functions also become available:
15182 @smallexample
15183 long __builtin_vis_bmask (long, long);
15184 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
15185 v2si __builtin_vis_bshufflev2si (v2si, v2si);
15186 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
15187 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
15189 long __builtin_vis_edge8n (void *, void *);
15190 long __builtin_vis_edge8ln (void *, void *);
15191 long __builtin_vis_edge16n (void *, void *);
15192 long __builtin_vis_edge16ln (void *, void *);
15193 long __builtin_vis_edge32n (void *, void *);
15194 long __builtin_vis_edge32ln (void *, void *);
15195 @end smallexample
15197 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
15198 functions also become available:
15200 @smallexample
15201 void __builtin_vis_cmask8 (long);
15202 void __builtin_vis_cmask16 (long);
15203 void __builtin_vis_cmask32 (long);
15205 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
15207 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
15208 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
15209 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
15210 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
15211 v2si __builtin_vis_fsll16 (v2si, v2si);
15212 v2si __builtin_vis_fslas16 (v2si, v2si);
15213 v2si __builtin_vis_fsrl16 (v2si, v2si);
15214 v2si __builtin_vis_fsra16 (v2si, v2si);
15216 long __builtin_vis_pdistn (v8qi, v8qi);
15218 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
15220 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
15221 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
15223 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
15224 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
15225 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
15226 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
15227 v2si __builtin_vis_fpadds32 (v2si, v2si);
15228 v1si __builtin_vis_fpadds32s (v1si, v1si);
15229 v2si __builtin_vis_fpsubs32 (v2si, v2si);
15230 v1si __builtin_vis_fpsubs32s (v1si, v1si);
15232 long __builtin_vis_fucmple8 (v8qi, v8qi);
15233 long __builtin_vis_fucmpne8 (v8qi, v8qi);
15234 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
15235 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
15237 float __builtin_vis_fhadds (float, float);
15238 double __builtin_vis_fhaddd (double, double);
15239 float __builtin_vis_fhsubs (float, float);
15240 double __builtin_vis_fhsubd (double, double);
15241 float __builtin_vis_fnhadds (float, float);
15242 double __builtin_vis_fnhaddd (double, double);
15244 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
15245 int64_t __builtin_vis_xmulx (int64_t, int64_t);
15246 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
15247 @end smallexample
15249 @node SPU Built-in Functions
15250 @subsection SPU Built-in Functions
15252 GCC provides extensions for the SPU processor as described in the
15253 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
15254 found at @uref{http://cell.scei.co.jp/} or
15255 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
15256 implementation differs in several ways.
15258 @itemize @bullet
15260 @item
15261 The optional extension of specifying vector constants in parentheses is
15262 not supported.
15264 @item
15265 A vector initializer requires no cast if the vector constant is of the
15266 same type as the variable it is initializing.
15268 @item
15269 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15270 vector type is the default signedness of the base type.  The default
15271 varies depending on the operating system, so a portable program should
15272 always specify the signedness.
15274 @item
15275 By default, the keyword @code{__vector} is added. The macro
15276 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
15277 undefined.
15279 @item
15280 GCC allows using a @code{typedef} name as the type specifier for a
15281 vector type.
15283 @item
15284 For C, overloaded functions are implemented with macros so the following
15285 does not work:
15287 @smallexample
15288   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15289 @end smallexample
15291 @noindent
15292 Since @code{spu_add} is a macro, the vector constant in the example
15293 is treated as four separate arguments.  Wrap the entire argument in
15294 parentheses for this to work.
15296 @item
15297 The extended version of @code{__builtin_expect} is not supported.
15299 @end itemize
15301 @emph{Note:} Only the interface described in the aforementioned
15302 specification is supported. Internally, GCC uses built-in functions to
15303 implement the required functionality, but these are not supported and
15304 are subject to change without notice.
15306 @node TI C6X Built-in Functions
15307 @subsection TI C6X Built-in Functions
15309 GCC provides intrinsics to access certain instructions of the TI C6X
15310 processors.  These intrinsics, listed below, are available after
15311 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
15312 to C6X instructions.
15314 @smallexample
15316 int _sadd (int, int)
15317 int _ssub (int, int)
15318 int _sadd2 (int, int)
15319 int _ssub2 (int, int)
15320 long long _mpy2 (int, int)
15321 long long _smpy2 (int, int)
15322 int _add4 (int, int)
15323 int _sub4 (int, int)
15324 int _saddu4 (int, int)
15326 int _smpy (int, int)
15327 int _smpyh (int, int)
15328 int _smpyhl (int, int)
15329 int _smpylh (int, int)
15331 int _sshl (int, int)
15332 int _subc (int, int)
15334 int _avg2 (int, int)
15335 int _avgu4 (int, int)
15337 int _clrr (int, int)
15338 int _extr (int, int)
15339 int _extru (int, int)
15340 int _abs (int)
15341 int _abs2 (int)
15343 @end smallexample
15345 @node TILE-Gx Built-in Functions
15346 @subsection TILE-Gx Built-in Functions
15348 GCC provides intrinsics to access every instruction of the TILE-Gx
15349 processor.  The intrinsics are of the form:
15351 @smallexample
15353 unsigned long long __insn_@var{op} (...)
15355 @end smallexample
15357 Where @var{op} is the name of the instruction.  Refer to the ISA manual
15358 for the complete list of instructions.
15360 GCC also provides intrinsics to directly access the network registers.
15361 The intrinsics are:
15363 @smallexample
15365 unsigned long long __tile_idn0_receive (void)
15366 unsigned long long __tile_idn1_receive (void)
15367 unsigned long long __tile_udn0_receive (void)
15368 unsigned long long __tile_udn1_receive (void)
15369 unsigned long long __tile_udn2_receive (void)
15370 unsigned long long __tile_udn3_receive (void)
15371 void __tile_idn_send (unsigned long long)
15372 void __tile_udn_send (unsigned long long)
15374 @end smallexample
15376 The intrinsic @code{void __tile_network_barrier (void)} is used to
15377 guarantee that no network operations before it are reordered with
15378 those after it.
15380 @node TILEPro Built-in Functions
15381 @subsection TILEPro Built-in Functions
15383 GCC provides intrinsics to access every instruction of the TILEPro
15384 processor.  The intrinsics are of the form:
15386 @smallexample
15388 unsigned __insn_@var{op} (...)
15390 @end smallexample
15392 @noindent
15393 where @var{op} is the name of the instruction.  Refer to the ISA manual
15394 for the complete list of instructions.
15396 GCC also provides intrinsics to directly access the network registers.
15397 The intrinsics are:
15399 @smallexample
15401 unsigned __tile_idn0_receive (void)
15402 unsigned __tile_idn1_receive (void)
15403 unsigned __tile_sn_receive (void)
15404 unsigned __tile_udn0_receive (void)
15405 unsigned __tile_udn1_receive (void)
15406 unsigned __tile_udn2_receive (void)
15407 unsigned __tile_udn3_receive (void)
15408 void __tile_idn_send (unsigned)
15409 void __tile_sn_send (unsigned)
15410 void __tile_udn_send (unsigned)
15412 @end smallexample
15414 The intrinsic @code{void __tile_network_barrier (void)} is used to
15415 guarantee that no network operations before it are reordered with
15416 those after it.
15418 @node Target Format Checks
15419 @section Format Checks Specific to Particular Target Machines
15421 For some target machines, GCC supports additional options to the
15422 format attribute
15423 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
15425 @menu
15426 * Solaris Format Checks::
15427 * Darwin Format Checks::
15428 @end menu
15430 @node Solaris Format Checks
15431 @subsection Solaris Format Checks
15433 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
15434 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
15435 conversions, and the two-argument @code{%b} conversion for displaying
15436 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
15438 @node Darwin Format Checks
15439 @subsection Darwin Format Checks
15441 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
15442 attribute context.  Declarations made with such attribution are parsed for correct syntax
15443 and format argument types.  However, parsing of the format string itself is currently undefined
15444 and is not carried out by this version of the compiler.
15446 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
15447 also be used as format arguments.  Note that the relevant headers are only likely to be
15448 available on Darwin (OSX) installations.  On such installations, the XCode and system
15449 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
15450 associated functions.
15452 @node Pragmas
15453 @section Pragmas Accepted by GCC
15454 @cindex pragmas
15455 @cindex @code{#pragma}
15457 GCC supports several types of pragmas, primarily in order to compile
15458 code originally written for other compilers.  Note that in general
15459 we do not recommend the use of pragmas; @xref{Function Attributes},
15460 for further explanation.
15462 @menu
15463 * ARM Pragmas::
15464 * M32C Pragmas::
15465 * MeP Pragmas::
15466 * RS/6000 and PowerPC Pragmas::
15467 * Darwin Pragmas::
15468 * Solaris Pragmas::
15469 * Symbol-Renaming Pragmas::
15470 * Structure-Packing Pragmas::
15471 * Weak Pragmas::
15472 * Diagnostic Pragmas::
15473 * Visibility Pragmas::
15474 * Push/Pop Macro Pragmas::
15475 * Function Specific Option Pragmas::
15476 * Loop-Specific Pragmas::
15477 @end menu
15479 @node ARM Pragmas
15480 @subsection ARM Pragmas
15482 The ARM target defines pragmas for controlling the default addition of
15483 @code{long_call} and @code{short_call} attributes to functions.
15484 @xref{Function Attributes}, for information about the effects of these
15485 attributes.
15487 @table @code
15488 @item long_calls
15489 @cindex pragma, long_calls
15490 Set all subsequent functions to have the @code{long_call} attribute.
15492 @item no_long_calls
15493 @cindex pragma, no_long_calls
15494 Set all subsequent functions to have the @code{short_call} attribute.
15496 @item long_calls_off
15497 @cindex pragma, long_calls_off
15498 Do not affect the @code{long_call} or @code{short_call} attributes of
15499 subsequent functions.
15500 @end table
15502 @node M32C Pragmas
15503 @subsection M32C Pragmas
15505 @table @code
15506 @item GCC memregs @var{number}
15507 @cindex pragma, memregs
15508 Overrides the command-line option @code{-memregs=} for the current
15509 file.  Use with care!  This pragma must be before any function in the
15510 file, and mixing different memregs values in different objects may
15511 make them incompatible.  This pragma is useful when a
15512 performance-critical function uses a memreg for temporary values,
15513 as it may allow you to reduce the number of memregs used.
15515 @item ADDRESS @var{name} @var{address}
15516 @cindex pragma, address
15517 For any declared symbols matching @var{name}, this does three things
15518 to that symbol: it forces the symbol to be located at the given
15519 address (a number), it forces the symbol to be volatile, and it
15520 changes the symbol's scope to be static.  This pragma exists for
15521 compatibility with other compilers, but note that the common
15522 @code{1234H} numeric syntax is not supported (use @code{0x1234}
15523 instead).  Example:
15525 @smallexample
15526 #pragma ADDRESS port3 0x103
15527 char port3;
15528 @end smallexample
15530 @end table
15532 @node MeP Pragmas
15533 @subsection MeP Pragmas
15535 @table @code
15537 @item custom io_volatile (on|off)
15538 @cindex pragma, custom io_volatile
15539 Overrides the command-line option @code{-mio-volatile} for the current
15540 file.  Note that for compatibility with future GCC releases, this
15541 option should only be used once before any @code{io} variables in each
15542 file.
15544 @item GCC coprocessor available @var{registers}
15545 @cindex pragma, coprocessor available
15546 Specifies which coprocessor registers are available to the register
15547 allocator.  @var{registers} may be a single register, register range
15548 separated by ellipses, or comma-separated list of those.  Example:
15550 @smallexample
15551 #pragma GCC coprocessor available $c0...$c10, $c28
15552 @end smallexample
15554 @item GCC coprocessor call_saved @var{registers}
15555 @cindex pragma, coprocessor call_saved
15556 Specifies which coprocessor registers are to be saved and restored by
15557 any function using them.  @var{registers} may be a single register,
15558 register range separated by ellipses, or comma-separated list of
15559 those.  Example:
15561 @smallexample
15562 #pragma GCC coprocessor call_saved $c4...$c6, $c31
15563 @end smallexample
15565 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
15566 @cindex pragma, coprocessor subclass
15567 Creates and defines a register class.  These register classes can be
15568 used by inline @code{asm} constructs.  @var{registers} may be a single
15569 register, register range separated by ellipses, or comma-separated
15570 list of those.  Example:
15572 @smallexample
15573 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
15575 asm ("cpfoo %0" : "=B" (x));
15576 @end smallexample
15578 @item GCC disinterrupt @var{name} , @var{name} @dots{}
15579 @cindex pragma, disinterrupt
15580 For the named functions, the compiler adds code to disable interrupts
15581 for the duration of those functions.  If any functions so named 
15582 are not encountered in the source, a warning is emitted that the pragma is
15583 not used.  Examples:
15585 @smallexample
15586 #pragma disinterrupt foo
15587 #pragma disinterrupt bar, grill
15588 int foo () @{ @dots{} @}
15589 @end smallexample
15591 @item GCC call @var{name} , @var{name} @dots{}
15592 @cindex pragma, call
15593 For the named functions, the compiler always uses a register-indirect
15594 call model when calling the named functions.  Examples:
15596 @smallexample
15597 extern int foo ();
15598 #pragma call foo
15599 @end smallexample
15601 @end table
15603 @node RS/6000 and PowerPC Pragmas
15604 @subsection RS/6000 and PowerPC Pragmas
15606 The RS/6000 and PowerPC targets define one pragma for controlling
15607 whether or not the @code{longcall} attribute is added to function
15608 declarations by default.  This pragma overrides the @option{-mlongcall}
15609 option, but not the @code{longcall} and @code{shortcall} attributes.
15610 @xref{RS/6000 and PowerPC Options}, for more information about when long
15611 calls are and are not necessary.
15613 @table @code
15614 @item longcall (1)
15615 @cindex pragma, longcall
15616 Apply the @code{longcall} attribute to all subsequent function
15617 declarations.
15619 @item longcall (0)
15620 Do not apply the @code{longcall} attribute to subsequent function
15621 declarations.
15622 @end table
15624 @c Describe h8300 pragmas here.
15625 @c Describe sh pragmas here.
15626 @c Describe v850 pragmas here.
15628 @node Darwin Pragmas
15629 @subsection Darwin Pragmas
15631 The following pragmas are available for all architectures running the
15632 Darwin operating system.  These are useful for compatibility with other
15633 Mac OS compilers.
15635 @table @code
15636 @item mark @var{tokens}@dots{}
15637 @cindex pragma, mark
15638 This pragma is accepted, but has no effect.
15640 @item options align=@var{alignment}
15641 @cindex pragma, options align
15642 This pragma sets the alignment of fields in structures.  The values of
15643 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
15644 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
15645 properly; to restore the previous setting, use @code{reset} for the
15646 @var{alignment}.
15648 @item segment @var{tokens}@dots{}
15649 @cindex pragma, segment
15650 This pragma is accepted, but has no effect.
15652 @item unused (@var{var} [, @var{var}]@dots{})
15653 @cindex pragma, unused
15654 This pragma declares variables to be possibly unused.  GCC does not
15655 produce warnings for the listed variables.  The effect is similar to
15656 that of the @code{unused} attribute, except that this pragma may appear
15657 anywhere within the variables' scopes.
15658 @end table
15660 @node Solaris Pragmas
15661 @subsection Solaris Pragmas
15663 The Solaris target supports @code{#pragma redefine_extname}
15664 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
15665 @code{#pragma} directives for compatibility with the system compiler.
15667 @table @code
15668 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
15669 @cindex pragma, align
15671 Increase the minimum alignment of each @var{variable} to @var{alignment}.
15672 This is the same as GCC's @code{aligned} attribute @pxref{Variable
15673 Attributes}).  Macro expansion occurs on the arguments to this pragma
15674 when compiling C and Objective-C@.  It does not currently occur when
15675 compiling C++, but this is a bug which may be fixed in a future
15676 release.
15678 @item fini (@var{function} [, @var{function}]...)
15679 @cindex pragma, fini
15681 This pragma causes each listed @var{function} to be called after
15682 main, or during shared module unloading, by adding a call to the
15683 @code{.fini} section.
15685 @item init (@var{function} [, @var{function}]...)
15686 @cindex pragma, init
15688 This pragma causes each listed @var{function} to be called during
15689 initialization (before @code{main}) or during shared module loading, by
15690 adding a call to the @code{.init} section.
15692 @end table
15694 @node Symbol-Renaming Pragmas
15695 @subsection Symbol-Renaming Pragmas
15697 For compatibility with the Solaris system headers, GCC
15698 supports two @code{#pragma} directives that change the name used in
15699 assembly for a given declaration. To get this effect
15700 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
15701 Labels}).
15703 @table @code
15704 @item redefine_extname @var{oldname} @var{newname}
15705 @cindex pragma, redefine_extname
15707 This pragma gives the C function @var{oldname} the assembly symbol
15708 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
15709 is defined if this pragma is available (currently on all platforms).
15710 @end table
15712 This pragma and the asm labels extension interact in a complicated
15713 manner.  Here are some corner cases you may want to be aware of.
15715 @enumerate
15716 @item Both pragmas silently apply only to declarations with external
15717 linkage.  Asm labels do not have this restriction.
15719 @item In C++, both pragmas silently apply only to declarations with
15720 ``C'' linkage.  Again, asm labels do not have this restriction.
15722 @item If any of the three ways of changing the assembly name of a
15723 declaration is applied to a declaration whose assembly name has
15724 already been determined (either by a previous use of one of these
15725 features, or because the compiler needed the assembly name in order to
15726 generate code), and the new name is different, a warning issues and
15727 the name does not change.
15729 @item The @var{oldname} used by @code{#pragma redefine_extname} is
15730 always the C-language name.
15731 @end enumerate
15733 @node Structure-Packing Pragmas
15734 @subsection Structure-Packing Pragmas
15736 For compatibility with Microsoft Windows compilers, GCC supports a
15737 set of @code{#pragma} directives that change the maximum alignment of
15738 members of structures (other than zero-width bit-fields), unions, and
15739 classes subsequently defined. The @var{n} value below always is required
15740 to be a small power of two and specifies the new alignment in bytes.
15742 @enumerate
15743 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
15744 @item @code{#pragma pack()} sets the alignment to the one that was in
15745 effect when compilation started (see also command-line option
15746 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
15747 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
15748 setting on an internal stack and then optionally sets the new alignment.
15749 @item @code{#pragma pack(pop)} restores the alignment setting to the one
15750 saved at the top of the internal stack (and removes that stack entry).
15751 Note that @code{#pragma pack([@var{n}])} does not influence this internal
15752 stack; thus it is possible to have @code{#pragma pack(push)} followed by
15753 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
15754 @code{#pragma pack(pop)}.
15755 @end enumerate
15757 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
15758 @code{#pragma} which lays out a structure as the documented
15759 @code{__attribute__ ((ms_struct))}.
15760 @enumerate
15761 @item @code{#pragma ms_struct on} turns on the layout for structures
15762 declared.
15763 @item @code{#pragma ms_struct off} turns off the layout for structures
15764 declared.
15765 @item @code{#pragma ms_struct reset} goes back to the default layout.
15766 @end enumerate
15768 @node Weak Pragmas
15769 @subsection Weak Pragmas
15771 For compatibility with SVR4, GCC supports a set of @code{#pragma}
15772 directives for declaring symbols to be weak, and defining weak
15773 aliases.
15775 @table @code
15776 @item #pragma weak @var{symbol}
15777 @cindex pragma, weak
15778 This pragma declares @var{symbol} to be weak, as if the declaration
15779 had the attribute of the same name.  The pragma may appear before
15780 or after the declaration of @var{symbol}.  It is not an error for
15781 @var{symbol} to never be defined at all.
15783 @item #pragma weak @var{symbol1} = @var{symbol2}
15784 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
15785 It is an error if @var{symbol2} is not defined in the current
15786 translation unit.
15787 @end table
15789 @node Diagnostic Pragmas
15790 @subsection Diagnostic Pragmas
15792 GCC allows the user to selectively enable or disable certain types of
15793 diagnostics, and change the kind of the diagnostic.  For example, a
15794 project's policy might require that all sources compile with
15795 @option{-Werror} but certain files might have exceptions allowing
15796 specific types of warnings.  Or, a project might selectively enable
15797 diagnostics and treat them as errors depending on which preprocessor
15798 macros are defined.
15800 @table @code
15801 @item #pragma GCC diagnostic @var{kind} @var{option}
15802 @cindex pragma, diagnostic
15804 Modifies the disposition of a diagnostic.  Note that not all
15805 diagnostics are modifiable; at the moment only warnings (normally
15806 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
15807 Use @option{-fdiagnostics-show-option} to determine which diagnostics
15808 are controllable and which option controls them.
15810 @var{kind} is @samp{error} to treat this diagnostic as an error,
15811 @samp{warning} to treat it like a warning (even if @option{-Werror} is
15812 in effect), or @samp{ignored} if the diagnostic is to be ignored.
15813 @var{option} is a double quoted string that matches the command-line
15814 option.
15816 @smallexample
15817 #pragma GCC diagnostic warning "-Wformat"
15818 #pragma GCC diagnostic error "-Wformat"
15819 #pragma GCC diagnostic ignored "-Wformat"
15820 @end smallexample
15822 Note that these pragmas override any command-line options.  GCC keeps
15823 track of the location of each pragma, and issues diagnostics according
15824 to the state as of that point in the source file.  Thus, pragmas occurring
15825 after a line do not affect diagnostics caused by that line.
15827 @item #pragma GCC diagnostic push
15828 @itemx #pragma GCC diagnostic pop
15830 Causes GCC to remember the state of the diagnostics as of each
15831 @code{push}, and restore to that point at each @code{pop}.  If a
15832 @code{pop} has no matching @code{push}, the command-line options are
15833 restored.
15835 @smallexample
15836 #pragma GCC diagnostic error "-Wuninitialized"
15837   foo(a);                       /* error is given for this one */
15838 #pragma GCC diagnostic push
15839 #pragma GCC diagnostic ignored "-Wuninitialized"
15840   foo(b);                       /* no diagnostic for this one */
15841 #pragma GCC diagnostic pop
15842   foo(c);                       /* error is given for this one */
15843 #pragma GCC diagnostic pop
15844   foo(d);                       /* depends on command-line options */
15845 @end smallexample
15847 @end table
15849 GCC also offers a simple mechanism for printing messages during
15850 compilation.
15852 @table @code
15853 @item #pragma message @var{string}
15854 @cindex pragma, diagnostic
15856 Prints @var{string} as a compiler message on compilation.  The message
15857 is informational only, and is neither a compilation warning nor an error.
15859 @smallexample
15860 #pragma message "Compiling " __FILE__ "..."
15861 @end smallexample
15863 @var{string} may be parenthesized, and is printed with location
15864 information.  For example,
15866 @smallexample
15867 #define DO_PRAGMA(x) _Pragma (#x)
15868 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
15870 TODO(Remember to fix this)
15871 @end smallexample
15873 @noindent
15874 prints @samp{/tmp/file.c:4: note: #pragma message:
15875 TODO - Remember to fix this}.
15877 @end table
15879 @node Visibility Pragmas
15880 @subsection Visibility Pragmas
15882 @table @code
15883 @item #pragma GCC visibility push(@var{visibility})
15884 @itemx #pragma GCC visibility pop
15885 @cindex pragma, visibility
15887 This pragma allows the user to set the visibility for multiple
15888 declarations without having to give each a visibility attribute
15889 @xref{Function Attributes}, for more information about visibility and
15890 the attribute syntax.
15892 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
15893 declarations.  Class members and template specializations are not
15894 affected; if you want to override the visibility for a particular
15895 member or instantiation, you must use an attribute.
15897 @end table
15900 @node Push/Pop Macro Pragmas
15901 @subsection Push/Pop Macro Pragmas
15903 For compatibility with Microsoft Windows compilers, GCC supports
15904 @samp{#pragma push_macro(@var{"macro_name"})}
15905 and @samp{#pragma pop_macro(@var{"macro_name"})}.
15907 @table @code
15908 @item #pragma push_macro(@var{"macro_name"})
15909 @cindex pragma, push_macro
15910 This pragma saves the value of the macro named as @var{macro_name} to
15911 the top of the stack for this macro.
15913 @item #pragma pop_macro(@var{"macro_name"})
15914 @cindex pragma, pop_macro
15915 This pragma sets the value of the macro named as @var{macro_name} to
15916 the value on top of the stack for this macro. If the stack for
15917 @var{macro_name} is empty, the value of the macro remains unchanged.
15918 @end table
15920 For example:
15922 @smallexample
15923 #define X  1
15924 #pragma push_macro("X")
15925 #undef X
15926 #define X -1
15927 #pragma pop_macro("X")
15928 int x [X];
15929 @end smallexample
15931 @noindent
15932 In this example, the definition of X as 1 is saved by @code{#pragma
15933 push_macro} and restored by @code{#pragma pop_macro}.
15935 @node Function Specific Option Pragmas
15936 @subsection Function Specific Option Pragmas
15938 @table @code
15939 @item #pragma GCC target (@var{"string"}...)
15940 @cindex pragma GCC target
15942 This pragma allows you to set target specific options for functions
15943 defined later in the source file.  One or more strings can be
15944 specified.  Each function that is defined after this point is as
15945 if @code{attribute((target("STRING")))} was specified for that
15946 function.  The parenthesis around the options is optional.
15947 @xref{Function Attributes}, for more information about the
15948 @code{target} attribute and the attribute syntax.
15950 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
15951 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends.  At
15952 present, it is not implemented for other back ends.
15953 @end table
15955 @table @code
15956 @item #pragma GCC optimize (@var{"string"}...)
15957 @cindex pragma GCC optimize
15959 This pragma allows you to set global optimization options for functions
15960 defined later in the source file.  One or more strings can be
15961 specified.  Each function that is defined after this point is as
15962 if @code{attribute((optimize("STRING")))} was specified for that
15963 function.  The parenthesis around the options is optional.
15964 @xref{Function Attributes}, for more information about the
15965 @code{optimize} attribute and the attribute syntax.
15967 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
15968 versions earlier than 4.4.
15969 @end table
15971 @table @code
15972 @item #pragma GCC push_options
15973 @itemx #pragma GCC pop_options
15974 @cindex pragma GCC push_options
15975 @cindex pragma GCC pop_options
15977 These pragmas maintain a stack of the current target and optimization
15978 options.  It is intended for include files where you temporarily want
15979 to switch to using a different @samp{#pragma GCC target} or
15980 @samp{#pragma GCC optimize} and then to pop back to the previous
15981 options.
15983 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
15984 pragmas are not implemented in GCC versions earlier than 4.4.
15985 @end table
15987 @table @code
15988 @item #pragma GCC reset_options
15989 @cindex pragma GCC reset_options
15991 This pragma clears the current @code{#pragma GCC target} and
15992 @code{#pragma GCC optimize} to use the default switches as specified
15993 on the command line.
15995 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
15996 versions earlier than 4.4.
15997 @end table
15999 @node Loop-Specific Pragmas
16000 @subsection Loop-Specific Pragmas
16002 @table @code
16003 @item #pragma GCC ivdep
16004 @cindex pragma GCC ivdep
16005 @end table
16007 With this pragma, the programmer asserts that there are no loop-carried
16008 dependencies which would prevent that consecutive iterations of
16009 the following loop can be executed concurrently with SIMD
16010 (single instruction multiple data) instructions.
16012 For example, the compiler can only unconditionally vectorize the following
16013 loop with the pragma:
16015 @smallexample
16016 void foo (int n, int *a, int *b, int *c)
16018   int i, j;
16019 #pragma GCC ivdep
16020   for (i = 0; i < n; ++i)
16021     a[i] = b[i] + c[i];
16023 @end smallexample
16025 @noindent
16026 In this example, using the @code{restrict} qualifier had the same
16027 effect. In the following example, that would not be possible. Assume
16028 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
16029 that it can unconditionally vectorize the following loop:
16031 @smallexample
16032 void ignore_vec_dep (int *a, int k, int c, int m)
16034 #pragma GCC ivdep
16035   for (int i = 0; i < m; i++)
16036     a[i] = a[i + k] * c;
16038 @end smallexample
16041 @node Unnamed Fields
16042 @section Unnamed struct/union fields within structs/unions
16043 @cindex @code{struct}
16044 @cindex @code{union}
16046 As permitted by ISO C11 and for compatibility with other compilers,
16047 GCC allows you to define
16048 a structure or union that contains, as fields, structures and unions
16049 without names.  For example:
16051 @smallexample
16052 struct @{
16053   int a;
16054   union @{
16055     int b;
16056     float c;
16057   @};
16058   int d;
16059 @} foo;
16060 @end smallexample
16062 @noindent
16063 In this example, you are able to access members of the unnamed
16064 union with code like @samp{foo.b}.  Note that only unnamed structs and
16065 unions are allowed, you may not have, for example, an unnamed
16066 @code{int}.
16068 You must never create such structures that cause ambiguous field definitions.
16069 For example, in this structure:
16071 @smallexample
16072 struct @{
16073   int a;
16074   struct @{
16075     int a;
16076   @};
16077 @} foo;
16078 @end smallexample
16080 @noindent
16081 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
16082 The compiler gives errors for such constructs.
16084 @opindex fms-extensions
16085 Unless @option{-fms-extensions} is used, the unnamed field must be a
16086 structure or union definition without a tag (for example, @samp{struct
16087 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
16088 also be a definition with a tag such as @samp{struct foo @{ int a;
16089 @};}, a reference to a previously defined structure or union such as
16090 @samp{struct foo;}, or a reference to a @code{typedef} name for a
16091 previously defined structure or union type.
16093 @opindex fplan9-extensions
16094 The option @option{-fplan9-extensions} enables
16095 @option{-fms-extensions} as well as two other extensions.  First, a
16096 pointer to a structure is automatically converted to a pointer to an
16097 anonymous field for assignments and function calls.  For example:
16099 @smallexample
16100 struct s1 @{ int a; @};
16101 struct s2 @{ struct s1; @};
16102 extern void f1 (struct s1 *);
16103 void f2 (struct s2 *p) @{ f1 (p); @}
16104 @end smallexample
16106 @noindent
16107 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
16108 converted into a pointer to the anonymous field.
16110 Second, when the type of an anonymous field is a @code{typedef} for a
16111 @code{struct} or @code{union}, code may refer to the field using the
16112 name of the @code{typedef}.
16114 @smallexample
16115 typedef struct @{ int a; @} s1;
16116 struct s2 @{ s1; @};
16117 s1 f1 (struct s2 *p) @{ return p->s1; @}
16118 @end smallexample
16120 These usages are only permitted when they are not ambiguous.
16122 @node Thread-Local
16123 @section Thread-Local Storage
16124 @cindex Thread-Local Storage
16125 @cindex @acronym{TLS}
16126 @cindex @code{__thread}
16128 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
16129 are allocated such that there is one instance of the variable per extant
16130 thread.  The runtime model GCC uses to implement this originates
16131 in the IA-64 processor-specific ABI, but has since been migrated
16132 to other processors as well.  It requires significant support from
16133 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
16134 system libraries (@file{libc.so} and @file{libpthread.so}), so it
16135 is not available everywhere.
16137 At the user level, the extension is visible with a new storage
16138 class keyword: @code{__thread}.  For example:
16140 @smallexample
16141 __thread int i;
16142 extern __thread struct state s;
16143 static __thread char *p;
16144 @end smallexample
16146 The @code{__thread} specifier may be used alone, with the @code{extern}
16147 or @code{static} specifiers, but with no other storage class specifier.
16148 When used with @code{extern} or @code{static}, @code{__thread} must appear
16149 immediately after the other storage class specifier.
16151 The @code{__thread} specifier may be applied to any global, file-scoped
16152 static, function-scoped static, or static data member of a class.  It may
16153 not be applied to block-scoped automatic or non-static data member.
16155 When the address-of operator is applied to a thread-local variable, it is
16156 evaluated at run time and returns the address of the current thread's
16157 instance of that variable.  An address so obtained may be used by any
16158 thread.  When a thread terminates, any pointers to thread-local variables
16159 in that thread become invalid.
16161 No static initialization may refer to the address of a thread-local variable.
16163 In C++, if an initializer is present for a thread-local variable, it must
16164 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
16165 standard.
16167 See @uref{http://www.akkadia.org/drepper/tls.pdf,
16168 ELF Handling For Thread-Local Storage} for a detailed explanation of
16169 the four thread-local storage addressing models, and how the runtime
16170 is expected to function.
16172 @menu
16173 * C99 Thread-Local Edits::
16174 * C++98 Thread-Local Edits::
16175 @end menu
16177 @node C99 Thread-Local Edits
16178 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
16180 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
16181 that document the exact semantics of the language extension.
16183 @itemize @bullet
16184 @item
16185 @cite{5.1.2  Execution environments}
16187 Add new text after paragraph 1
16189 @quotation
16190 Within either execution environment, a @dfn{thread} is a flow of
16191 control within a program.  It is implementation defined whether
16192 or not there may be more than one thread associated with a program.
16193 It is implementation defined how threads beyond the first are
16194 created, the name and type of the function called at thread
16195 startup, and how threads may be terminated.  However, objects
16196 with thread storage duration shall be initialized before thread
16197 startup.
16198 @end quotation
16200 @item
16201 @cite{6.2.4  Storage durations of objects}
16203 Add new text before paragraph 3
16205 @quotation
16206 An object whose identifier is declared with the storage-class
16207 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
16208 Its lifetime is the entire execution of the thread, and its
16209 stored value is initialized only once, prior to thread startup.
16210 @end quotation
16212 @item
16213 @cite{6.4.1  Keywords}
16215 Add @code{__thread}.
16217 @item
16218 @cite{6.7.1  Storage-class specifiers}
16220 Add @code{__thread} to the list of storage class specifiers in
16221 paragraph 1.
16223 Change paragraph 2 to
16225 @quotation
16226 With the exception of @code{__thread}, at most one storage-class
16227 specifier may be given [@dots{}].  The @code{__thread} specifier may
16228 be used alone, or immediately following @code{extern} or
16229 @code{static}.
16230 @end quotation
16232 Add new text after paragraph 6
16234 @quotation
16235 The declaration of an identifier for a variable that has
16236 block scope that specifies @code{__thread} shall also
16237 specify either @code{extern} or @code{static}.
16239 The @code{__thread} specifier shall be used only with
16240 variables.
16241 @end quotation
16242 @end itemize
16244 @node C++98 Thread-Local Edits
16245 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
16247 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
16248 that document the exact semantics of the language extension.
16250 @itemize @bullet
16251 @item
16252 @b{[intro.execution]}
16254 New text after paragraph 4
16256 @quotation
16257 A @dfn{thread} is a flow of control within the abstract machine.
16258 It is implementation defined whether or not there may be more than
16259 one thread.
16260 @end quotation
16262 New text after paragraph 7
16264 @quotation
16265 It is unspecified whether additional action must be taken to
16266 ensure when and whether side effects are visible to other threads.
16267 @end quotation
16269 @item
16270 @b{[lex.key]}
16272 Add @code{__thread}.
16274 @item
16275 @b{[basic.start.main]}
16277 Add after paragraph 5
16279 @quotation
16280 The thread that begins execution at the @code{main} function is called
16281 the @dfn{main thread}.  It is implementation defined how functions
16282 beginning threads other than the main thread are designated or typed.
16283 A function so designated, as well as the @code{main} function, is called
16284 a @dfn{thread startup function}.  It is implementation defined what
16285 happens if a thread startup function returns.  It is implementation
16286 defined what happens to other threads when any thread calls @code{exit}.
16287 @end quotation
16289 @item
16290 @b{[basic.start.init]}
16292 Add after paragraph 4
16294 @quotation
16295 The storage for an object of thread storage duration shall be
16296 statically initialized before the first statement of the thread startup
16297 function.  An object of thread storage duration shall not require
16298 dynamic initialization.
16299 @end quotation
16301 @item
16302 @b{[basic.start.term]}
16304 Add after paragraph 3
16306 @quotation
16307 The type of an object with thread storage duration shall not have a
16308 non-trivial destructor, nor shall it be an array type whose elements
16309 (directly or indirectly) have non-trivial destructors.
16310 @end quotation
16312 @item
16313 @b{[basic.stc]}
16315 Add ``thread storage duration'' to the list in paragraph 1.
16317 Change paragraph 2
16319 @quotation
16320 Thread, static, and automatic storage durations are associated with
16321 objects introduced by declarations [@dots{}].
16322 @end quotation
16324 Add @code{__thread} to the list of specifiers in paragraph 3.
16326 @item
16327 @b{[basic.stc.thread]}
16329 New section before @b{[basic.stc.static]}
16331 @quotation
16332 The keyword @code{__thread} applied to a non-local object gives the
16333 object thread storage duration.
16335 A local variable or class data member declared both @code{static}
16336 and @code{__thread} gives the variable or member thread storage
16337 duration.
16338 @end quotation
16340 @item
16341 @b{[basic.stc.static]}
16343 Change paragraph 1
16345 @quotation
16346 All objects that have neither thread storage duration, dynamic
16347 storage duration nor are local [@dots{}].
16348 @end quotation
16350 @item
16351 @b{[dcl.stc]}
16353 Add @code{__thread} to the list in paragraph 1.
16355 Change paragraph 1
16357 @quotation
16358 With the exception of @code{__thread}, at most one
16359 @var{storage-class-specifier} shall appear in a given
16360 @var{decl-specifier-seq}.  The @code{__thread} specifier may
16361 be used alone, or immediately following the @code{extern} or
16362 @code{static} specifiers.  [@dots{}]
16363 @end quotation
16365 Add after paragraph 5
16367 @quotation
16368 The @code{__thread} specifier can be applied only to the names of objects
16369 and to anonymous unions.
16370 @end quotation
16372 @item
16373 @b{[class.mem]}
16375 Add after paragraph 6
16377 @quotation
16378 Non-@code{static} members shall not be @code{__thread}.
16379 @end quotation
16380 @end itemize
16382 @node Binary constants
16383 @section Binary constants using the @samp{0b} prefix
16384 @cindex Binary constants using the @samp{0b} prefix
16386 Integer constants can be written as binary constants, consisting of a
16387 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
16388 @samp{0B}.  This is particularly useful in environments that operate a
16389 lot on the bit level (like microcontrollers).
16391 The following statements are identical:
16393 @smallexample
16394 i =       42;
16395 i =     0x2a;
16396 i =      052;
16397 i = 0b101010;
16398 @end smallexample
16400 The type of these constants follows the same rules as for octal or
16401 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
16402 can be applied.
16404 @node C++ Extensions
16405 @chapter Extensions to the C++ Language
16406 @cindex extensions, C++ language
16407 @cindex C++ language extensions
16409 The GNU compiler provides these extensions to the C++ language (and you
16410 can also use most of the C language extensions in your C++ programs).  If you
16411 want to write code that checks whether these features are available, you can
16412 test for the GNU compiler the same way as for C programs: check for a
16413 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
16414 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
16415 Predefined Macros,cpp,The GNU C Preprocessor}).
16417 @menu
16418 * C++ Volatiles::       What constitutes an access to a volatile object.
16419 * Restricted Pointers:: C99 restricted pointers and references.
16420 * Vague Linkage::       Where G++ puts inlines, vtables and such.
16421 * C++ Interface::       You can use a single C++ header file for both
16422                         declarations and definitions.
16423 * Template Instantiation:: Methods for ensuring that exactly one copy of
16424                         each needed template instantiation is emitted.
16425 * Bound member functions:: You can extract a function pointer to the
16426                         method denoted by a @samp{->*} or @samp{.*} expression.
16427 * C++ Attributes::      Variable, function, and type attributes for C++ only.
16428 * Function Multiversioning::   Declaring multiple function versions.
16429 * Namespace Association:: Strong using-directives for namespace association.
16430 * Type Traits::         Compiler support for type traits
16431 * Java Exceptions::     Tweaking exception handling to work with Java.
16432 * Deprecated Features:: Things will disappear from G++.
16433 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
16434 @end menu
16436 @node C++ Volatiles
16437 @section When is a Volatile C++ Object Accessed?
16438 @cindex accessing volatiles
16439 @cindex volatile read
16440 @cindex volatile write
16441 @cindex volatile access
16443 The C++ standard differs from the C standard in its treatment of
16444 volatile objects.  It fails to specify what constitutes a volatile
16445 access, except to say that C++ should behave in a similar manner to C
16446 with respect to volatiles, where possible.  However, the different
16447 lvalueness of expressions between C and C++ complicate the behavior.
16448 G++ behaves the same as GCC for volatile access, @xref{C
16449 Extensions,,Volatiles}, for a description of GCC's behavior.
16451 The C and C++ language specifications differ when an object is
16452 accessed in a void context:
16454 @smallexample
16455 volatile int *src = @var{somevalue};
16456 *src;
16457 @end smallexample
16459 The C++ standard specifies that such expressions do not undergo lvalue
16460 to rvalue conversion, and that the type of the dereferenced object may
16461 be incomplete.  The C++ standard does not specify explicitly that it
16462 is lvalue to rvalue conversion that is responsible for causing an
16463 access.  There is reason to believe that it is, because otherwise
16464 certain simple expressions become undefined.  However, because it
16465 would surprise most programmers, G++ treats dereferencing a pointer to
16466 volatile object of complete type as GCC would do for an equivalent
16467 type in C@.  When the object has incomplete type, G++ issues a
16468 warning; if you wish to force an error, you must force a conversion to
16469 rvalue with, for instance, a static cast.
16471 When using a reference to volatile, G++ does not treat equivalent
16472 expressions as accesses to volatiles, but instead issues a warning that
16473 no volatile is accessed.  The rationale for this is that otherwise it
16474 becomes difficult to determine where volatile access occur, and not
16475 possible to ignore the return value from functions returning volatile
16476 references.  Again, if you wish to force a read, cast the reference to
16477 an rvalue.
16479 G++ implements the same behavior as GCC does when assigning to a
16480 volatile object---there is no reread of the assigned-to object, the
16481 assigned rvalue is reused.  Note that in C++ assignment expressions
16482 are lvalues, and if used as an lvalue, the volatile object is
16483 referred to.  For instance, @var{vref} refers to @var{vobj}, as
16484 expected, in the following example:
16486 @smallexample
16487 volatile int vobj;
16488 volatile int &vref = vobj = @var{something};
16489 @end smallexample
16491 @node Restricted Pointers
16492 @section Restricting Pointer Aliasing
16493 @cindex restricted pointers
16494 @cindex restricted references
16495 @cindex restricted this pointer
16497 As with the C front end, G++ understands the C99 feature of restricted pointers,
16498 specified with the @code{__restrict__}, or @code{__restrict} type
16499 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
16500 language flag, @code{restrict} is not a keyword in C++.
16502 In addition to allowing restricted pointers, you can specify restricted
16503 references, which indicate that the reference is not aliased in the local
16504 context.
16506 @smallexample
16507 void fn (int *__restrict__ rptr, int &__restrict__ rref)
16509   /* @r{@dots{}} */
16511 @end smallexample
16513 @noindent
16514 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
16515 @var{rref} refers to a (different) unaliased integer.
16517 You may also specify whether a member function's @var{this} pointer is
16518 unaliased by using @code{__restrict__} as a member function qualifier.
16520 @smallexample
16521 void T::fn () __restrict__
16523   /* @r{@dots{}} */
16525 @end smallexample
16527 @noindent
16528 Within the body of @code{T::fn}, @var{this} has the effective
16529 definition @code{T *__restrict__ const this}.  Notice that the
16530 interpretation of a @code{__restrict__} member function qualifier is
16531 different to that of @code{const} or @code{volatile} qualifier, in that it
16532 is applied to the pointer rather than the object.  This is consistent with
16533 other compilers that implement restricted pointers.
16535 As with all outermost parameter qualifiers, @code{__restrict__} is
16536 ignored in function definition matching.  This means you only need to
16537 specify @code{__restrict__} in a function definition, rather than
16538 in a function prototype as well.
16540 @node Vague Linkage
16541 @section Vague Linkage
16542 @cindex vague linkage
16544 There are several constructs in C++ that require space in the object
16545 file but are not clearly tied to a single translation unit.  We say that
16546 these constructs have ``vague linkage''.  Typically such constructs are
16547 emitted wherever they are needed, though sometimes we can be more
16548 clever.
16550 @table @asis
16551 @item Inline Functions
16552 Inline functions are typically defined in a header file which can be
16553 included in many different compilations.  Hopefully they can usually be
16554 inlined, but sometimes an out-of-line copy is necessary, if the address
16555 of the function is taken or if inlining fails.  In general, we emit an
16556 out-of-line copy in all translation units where one is needed.  As an
16557 exception, we only emit inline virtual functions with the vtable, since
16558 it always requires a copy.
16560 Local static variables and string constants used in an inline function
16561 are also considered to have vague linkage, since they must be shared
16562 between all inlined and out-of-line instances of the function.
16564 @item VTables
16565 @cindex vtable
16566 C++ virtual functions are implemented in most compilers using a lookup
16567 table, known as a vtable.  The vtable contains pointers to the virtual
16568 functions provided by a class, and each object of the class contains a
16569 pointer to its vtable (or vtables, in some multiple-inheritance
16570 situations).  If the class declares any non-inline, non-pure virtual
16571 functions, the first one is chosen as the ``key method'' for the class,
16572 and the vtable is only emitted in the translation unit where the key
16573 method is defined.
16575 @emph{Note:} If the chosen key method is later defined as inline, the
16576 vtable is still emitted in every translation unit that defines it.
16577 Make sure that any inline virtuals are declared inline in the class
16578 body, even if they are not defined there.
16580 @item @code{type_info} objects
16581 @cindex @code{type_info}
16582 @cindex RTTI
16583 C++ requires information about types to be written out in order to
16584 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
16585 For polymorphic classes (classes with virtual functions), the @samp{type_info}
16586 object is written out along with the vtable so that @samp{dynamic_cast}
16587 can determine the dynamic type of a class object at run time.  For all
16588 other types, we write out the @samp{type_info} object when it is used: when
16589 applying @samp{typeid} to an expression, throwing an object, or
16590 referring to a type in a catch clause or exception specification.
16592 @item Template Instantiations
16593 Most everything in this section also applies to template instantiations,
16594 but there are other options as well.
16595 @xref{Template Instantiation,,Where's the Template?}.
16597 @end table
16599 When used with GNU ld version 2.8 or later on an ELF system such as
16600 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
16601 these constructs will be discarded at link time.  This is known as
16602 COMDAT support.
16604 On targets that don't support COMDAT, but do support weak symbols, GCC
16605 uses them.  This way one copy overrides all the others, but
16606 the unused copies still take up space in the executable.
16608 For targets that do not support either COMDAT or weak symbols,
16609 most entities with vague linkage are emitted as local symbols to
16610 avoid duplicate definition errors from the linker.  This does not happen
16611 for local statics in inlines, however, as having multiple copies
16612 almost certainly breaks things.
16614 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
16615 another way to control placement of these constructs.
16617 @node C++ Interface
16618 @section #pragma interface and implementation
16620 @cindex interface and implementation headers, C++
16621 @cindex C++ interface and implementation headers
16622 @cindex pragmas, interface and implementation
16624 @code{#pragma interface} and @code{#pragma implementation} provide the
16625 user with a way of explicitly directing the compiler to emit entities
16626 with vague linkage (and debugging information) in a particular
16627 translation unit.
16629 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
16630 most cases, because of COMDAT support and the ``key method'' heuristic
16631 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
16632 program to grow due to unnecessary out-of-line copies of inline
16633 functions.  Currently (3.4) the only benefit of these
16634 @code{#pragma}s is reduced duplication of debugging information, and
16635 that should be addressed soon on DWARF 2 targets with the use of
16636 COMDAT groups.
16638 @table @code
16639 @item #pragma interface
16640 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
16641 @kindex #pragma interface
16642 Use this directive in @emph{header files} that define object classes, to save
16643 space in most of the object files that use those classes.  Normally,
16644 local copies of certain information (backup copies of inline member
16645 functions, debugging information, and the internal tables that implement
16646 virtual functions) must be kept in each object file that includes class
16647 definitions.  You can use this pragma to avoid such duplication.  When a
16648 header file containing @samp{#pragma interface} is included in a
16649 compilation, this auxiliary information is not generated (unless
16650 the main input source file itself uses @samp{#pragma implementation}).
16651 Instead, the object files contain references to be resolved at link
16652 time.
16654 The second form of this directive is useful for the case where you have
16655 multiple headers with the same name in different directories.  If you
16656 use this form, you must specify the same string to @samp{#pragma
16657 implementation}.
16659 @item #pragma implementation
16660 @itemx #pragma implementation "@var{objects}.h"
16661 @kindex #pragma implementation
16662 Use this pragma in a @emph{main input file}, when you want full output from
16663 included header files to be generated (and made globally visible).  The
16664 included header file, in turn, should use @samp{#pragma interface}.
16665 Backup copies of inline member functions, debugging information, and the
16666 internal tables used to implement virtual functions are all generated in
16667 implementation files.
16669 @cindex implied @code{#pragma implementation}
16670 @cindex @code{#pragma implementation}, implied
16671 @cindex naming convention, implementation headers
16672 If you use @samp{#pragma implementation} with no argument, it applies to
16673 an include file with the same basename@footnote{A file's @dfn{basename}
16674 is the name stripped of all leading path information and of trailing
16675 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
16676 file.  For example, in @file{allclass.cc}, giving just
16677 @samp{#pragma implementation}
16678 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
16680 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
16681 an implementation file whenever you would include it from
16682 @file{allclass.cc} even if you never specified @samp{#pragma
16683 implementation}.  This was deemed to be more trouble than it was worth,
16684 however, and disabled.
16686 Use the string argument if you want a single implementation file to
16687 include code from multiple header files.  (You must also use
16688 @samp{#include} to include the header file; @samp{#pragma
16689 implementation} only specifies how to use the file---it doesn't actually
16690 include it.)
16692 There is no way to split up the contents of a single header file into
16693 multiple implementation files.
16694 @end table
16696 @cindex inlining and C++ pragmas
16697 @cindex C++ pragmas, effect on inlining
16698 @cindex pragmas in C++, effect on inlining
16699 @samp{#pragma implementation} and @samp{#pragma interface} also have an
16700 effect on function inlining.
16702 If you define a class in a header file marked with @samp{#pragma
16703 interface}, the effect on an inline function defined in that class is
16704 similar to an explicit @code{extern} declaration---the compiler emits
16705 no code at all to define an independent version of the function.  Its
16706 definition is used only for inlining with its callers.
16708 @opindex fno-implement-inlines
16709 Conversely, when you include the same header file in a main source file
16710 that declares it as @samp{#pragma implementation}, the compiler emits
16711 code for the function itself; this defines a version of the function
16712 that can be found via pointers (or by callers compiled without
16713 inlining).  If all calls to the function can be inlined, you can avoid
16714 emitting the function by compiling with @option{-fno-implement-inlines}.
16715 If any calls are not inlined, you will get linker errors.
16717 @node Template Instantiation
16718 @section Where's the Template?
16719 @cindex template instantiation
16721 C++ templates are the first language feature to require more
16722 intelligence from the environment than one usually finds on a UNIX
16723 system.  Somehow the compiler and linker have to make sure that each
16724 template instance occurs exactly once in the executable if it is needed,
16725 and not at all otherwise.  There are two basic approaches to this
16726 problem, which are referred to as the Borland model and the Cfront model.
16728 @table @asis
16729 @item Borland model
16730 Borland C++ solved the template instantiation problem by adding the code
16731 equivalent of common blocks to their linker; the compiler emits template
16732 instances in each translation unit that uses them, and the linker
16733 collapses them together.  The advantage of this model is that the linker
16734 only has to consider the object files themselves; there is no external
16735 complexity to worry about.  This disadvantage is that compilation time
16736 is increased because the template code is being compiled repeatedly.
16737 Code written for this model tends to include definitions of all
16738 templates in the header file, since they must be seen to be
16739 instantiated.
16741 @item Cfront model
16742 The AT&T C++ translator, Cfront, solved the template instantiation
16743 problem by creating the notion of a template repository, an
16744 automatically maintained place where template instances are stored.  A
16745 more modern version of the repository works as follows: As individual
16746 object files are built, the compiler places any template definitions and
16747 instantiations encountered in the repository.  At link time, the link
16748 wrapper adds in the objects in the repository and compiles any needed
16749 instances that were not previously emitted.  The advantages of this
16750 model are more optimal compilation speed and the ability to use the
16751 system linker; to implement the Borland model a compiler vendor also
16752 needs to replace the linker.  The disadvantages are vastly increased
16753 complexity, and thus potential for error; for some code this can be
16754 just as transparent, but in practice it can been very difficult to build
16755 multiple programs in one directory and one program in multiple
16756 directories.  Code written for this model tends to separate definitions
16757 of non-inline member templates into a separate file, which should be
16758 compiled separately.
16759 @end table
16761 When used with GNU ld version 2.8 or later on an ELF system such as
16762 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
16763 Borland model.  On other systems, G++ implements neither automatic
16764 model.
16766 You have the following options for dealing with template instantiations:
16768 @enumerate
16769 @item
16770 @opindex frepo
16771 Compile your template-using code with @option{-frepo}.  The compiler
16772 generates files with the extension @samp{.rpo} listing all of the
16773 template instantiations used in the corresponding object files that
16774 could be instantiated there; the link wrapper, @samp{collect2},
16775 then updates the @samp{.rpo} files to tell the compiler where to place
16776 those instantiations and rebuild any affected object files.  The
16777 link-time overhead is negligible after the first pass, as the compiler
16778 continues to place the instantiations in the same files.
16780 This is your best option for application code written for the Borland
16781 model, as it just works.  Code written for the Cfront model 
16782 needs to be modified so that the template definitions are available at
16783 one or more points of instantiation; usually this is as simple as adding
16784 @code{#include <tmethods.cc>} to the end of each template header.
16786 For library code, if you want the library to provide all of the template
16787 instantiations it needs, just try to link all of its object files
16788 together; the link will fail, but cause the instantiations to be
16789 generated as a side effect.  Be warned, however, that this may cause
16790 conflicts if multiple libraries try to provide the same instantiations.
16791 For greater control, use explicit instantiation as described in the next
16792 option.
16794 @item
16795 @opindex fno-implicit-templates
16796 Compile your code with @option{-fno-implicit-templates} to disable the
16797 implicit generation of template instances, and explicitly instantiate
16798 all the ones you use.  This approach requires more knowledge of exactly
16799 which instances you need than do the others, but it's less
16800 mysterious and allows greater control.  You can scatter the explicit
16801 instantiations throughout your program, perhaps putting them in the
16802 translation units where the instances are used or the translation units
16803 that define the templates themselves; you can put all of the explicit
16804 instantiations you need into one big file; or you can create small files
16805 like
16807 @smallexample
16808 #include "Foo.h"
16809 #include "Foo.cc"
16811 template class Foo<int>;
16812 template ostream& operator <<
16813                 (ostream&, const Foo<int>&);
16814 @end smallexample
16816 @noindent
16817 for each of the instances you need, and create a template instantiation
16818 library from those.
16820 If you are using Cfront-model code, you can probably get away with not
16821 using @option{-fno-implicit-templates} when compiling files that don't
16822 @samp{#include} the member template definitions.
16824 If you use one big file to do the instantiations, you may want to
16825 compile it without @option{-fno-implicit-templates} so you get all of the
16826 instances required by your explicit instantiations (but not by any
16827 other files) without having to specify them as well.
16829 The ISO C++ 2011 standard allows forward declaration of explicit
16830 instantiations (with @code{extern}). G++ supports explicit instantiation
16831 declarations in C++98 mode and has extended the template instantiation
16832 syntax to support instantiation of the compiler support data for a
16833 template class (i.e.@: the vtable) without instantiating any of its
16834 members (with @code{inline}), and instantiation of only the static data
16835 members of a template class, without the support data or member
16836 functions (with (@code{static}):
16838 @smallexample
16839 extern template int max (int, int);
16840 inline template class Foo<int>;
16841 static template class Foo<int>;
16842 @end smallexample
16844 @item
16845 Do nothing.  Pretend G++ does implement automatic instantiation
16846 management.  Code written for the Borland model works fine, but
16847 each translation unit contains instances of each of the templates it
16848 uses.  In a large program, this can lead to an unacceptable amount of code
16849 duplication.
16850 @end enumerate
16852 @node Bound member functions
16853 @section Extracting the function pointer from a bound pointer to member function
16854 @cindex pmf
16855 @cindex pointer to member function
16856 @cindex bound pointer to member function
16858 In C++, pointer to member functions (PMFs) are implemented using a wide
16859 pointer of sorts to handle all the possible call mechanisms; the PMF
16860 needs to store information about how to adjust the @samp{this} pointer,
16861 and if the function pointed to is virtual, where to find the vtable, and
16862 where in the vtable to look for the member function.  If you are using
16863 PMFs in an inner loop, you should really reconsider that decision.  If
16864 that is not an option, you can extract the pointer to the function that
16865 would be called for a given object/PMF pair and call it directly inside
16866 the inner loop, to save a bit of time.
16868 Note that you still pay the penalty for the call through a
16869 function pointer; on most modern architectures, such a call defeats the
16870 branch prediction features of the CPU@.  This is also true of normal
16871 virtual function calls.
16873 The syntax for this extension is
16875 @smallexample
16876 extern A a;
16877 extern int (A::*fp)();
16878 typedef int (*fptr)(A *);
16880 fptr p = (fptr)(a.*fp);
16881 @end smallexample
16883 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
16884 no object is needed to obtain the address of the function.  They can be
16885 converted to function pointers directly:
16887 @smallexample
16888 fptr p1 = (fptr)(&A::foo);
16889 @end smallexample
16891 @opindex Wno-pmf-conversions
16892 You must specify @option{-Wno-pmf-conversions} to use this extension.
16894 @node C++ Attributes
16895 @section C++-Specific Variable, Function, and Type Attributes
16897 Some attributes only make sense for C++ programs.
16899 @table @code
16900 @item abi_tag ("@var{tag}", ...)
16901 @cindex @code{abi_tag} attribute
16902 The @code{abi_tag} attribute can be applied to a function or class
16903 declaration.  It modifies the mangled name of the function or class to
16904 incorporate the tag name, in order to distinguish the function or
16905 class from an earlier version with a different ABI; perhaps the class
16906 has changed size, or the function has a different return type that is
16907 not encoded in the mangled name.
16909 The argument can be a list of strings of arbitrary length.  The
16910 strings are sorted on output, so the order of the list is
16911 unimportant.
16913 A redeclaration of a function or class must not add new ABI tags,
16914 since doing so would change the mangled name.
16916 The @option{-Wabi-tag} flag enables a warning about a class which does
16917 not have all the ABI tags used by its subobjects and virtual functions; for users with code
16918 that needs to coexist with an earlier ABI, using this option can help
16919 to find all affected types that need to be tagged.
16921 @item init_priority (@var{priority})
16922 @cindex @code{init_priority} attribute
16925 In Standard C++, objects defined at namespace scope are guaranteed to be
16926 initialized in an order in strict accordance with that of their definitions
16927 @emph{in a given translation unit}.  No guarantee is made for initializations
16928 across translation units.  However, GNU C++ allows users to control the
16929 order of initialization of objects defined at namespace scope with the
16930 @code{init_priority} attribute by specifying a relative @var{priority},
16931 a constant integral expression currently bounded between 101 and 65535
16932 inclusive.  Lower numbers indicate a higher priority.
16934 In the following example, @code{A} would normally be created before
16935 @code{B}, but the @code{init_priority} attribute reverses that order:
16937 @smallexample
16938 Some_Class  A  __attribute__ ((init_priority (2000)));
16939 Some_Class  B  __attribute__ ((init_priority (543)));
16940 @end smallexample
16942 @noindent
16943 Note that the particular values of @var{priority} do not matter; only their
16944 relative ordering.
16946 @item java_interface
16947 @cindex @code{java_interface} attribute
16949 This type attribute informs C++ that the class is a Java interface.  It may
16950 only be applied to classes declared within an @code{extern "Java"} block.
16951 Calls to methods declared in this interface are dispatched using GCJ's
16952 interface table mechanism, instead of regular virtual table dispatch.
16954 @item warn_unused
16955 @cindex @code{warn_unused} attribute
16957 For C++ types with non-trivial constructors and/or destructors it is
16958 impossible for the compiler to determine whether a variable of this
16959 type is truly unused if it is not referenced. This type attribute
16960 informs the compiler that variables of this type should be warned
16961 about if they appear to be unused, just like variables of fundamental
16962 types.
16964 This attribute is appropriate for types which just represent a value,
16965 such as @code{std::string}; it is not appropriate for types which
16966 control a resource, such as @code{std::mutex}.
16968 This attribute is also accepted in C, but it is unnecessary because C
16969 does not have constructors or destructors.
16971 @end table
16973 See also @ref{Namespace Association}.
16975 @node Function Multiversioning
16976 @section Function Multiversioning
16977 @cindex function versions
16979 With the GNU C++ front end, for target i386, you may specify multiple
16980 versions of a function, where each function is specialized for a
16981 specific target feature.  At runtime, the appropriate version of the
16982 function is automatically executed depending on the characteristics of
16983 the execution platform.  Here is an example.
16985 @smallexample
16986 __attribute__ ((target ("default")))
16987 int foo ()
16989   // The default version of foo.
16990   return 0;
16993 __attribute__ ((target ("sse4.2")))
16994 int foo ()
16996   // foo version for SSE4.2
16997   return 1;
17000 __attribute__ ((target ("arch=atom")))
17001 int foo ()
17003   // foo version for the Intel ATOM processor
17004   return 2;
17007 __attribute__ ((target ("arch=amdfam10")))
17008 int foo ()
17010   // foo version for the AMD Family 0x10 processors.
17011   return 3;
17014 int main ()
17016   int (*p)() = &foo;
17017   assert ((*p) () == foo ());
17018   return 0;
17020 @end smallexample
17022 In the above example, four versions of function foo are created. The
17023 first version of foo with the target attribute "default" is the default
17024 version.  This version gets executed when no other target specific
17025 version qualifies for execution on a particular platform. A new version
17026 of foo is created by using the same function signature but with a
17027 different target string.  Function foo is called or a pointer to it is
17028 taken just like a regular function.  GCC takes care of doing the
17029 dispatching to call the right version at runtime.  Refer to the
17030 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
17031 Function Multiversioning} for more details.
17033 @node Namespace Association
17034 @section Namespace Association
17036 @strong{Caution:} The semantics of this extension are equivalent
17037 to C++ 2011 inline namespaces.  Users should use inline namespaces
17038 instead as this extension will be removed in future versions of G++.
17040 A using-directive with @code{__attribute ((strong))} is stronger
17041 than a normal using-directive in two ways:
17043 @itemize @bullet
17044 @item
17045 Templates from the used namespace can be specialized and explicitly
17046 instantiated as though they were members of the using namespace.
17048 @item
17049 The using namespace is considered an associated namespace of all
17050 templates in the used namespace for purposes of argument-dependent
17051 name lookup.
17052 @end itemize
17054 The used namespace must be nested within the using namespace so that
17055 normal unqualified lookup works properly.
17057 This is useful for composing a namespace transparently from
17058 implementation namespaces.  For example:
17060 @smallexample
17061 namespace std @{
17062   namespace debug @{
17063     template <class T> struct A @{ @};
17064   @}
17065   using namespace debug __attribute ((__strong__));
17066   template <> struct A<int> @{ @};   // @r{OK to specialize}
17068   template <class T> void f (A<T>);
17071 int main()
17073   f (std::A<float>());             // @r{lookup finds} std::f
17074   f (std::A<int>());
17076 @end smallexample
17078 @node Type Traits
17079 @section Type Traits
17081 The C++ front end implements syntactic extensions that allow
17082 compile-time determination of 
17083 various characteristics of a type (or of a
17084 pair of types).
17086 @table @code
17087 @item __has_nothrow_assign (type)
17088 If @code{type} is const qualified or is a reference type then the trait is
17089 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
17090 is true, else if @code{type} is a cv class or union type with copy assignment
17091 operators that are known not to throw an exception then the trait is true,
17092 else it is false.  Requires: @code{type} shall be a complete type,
17093 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17095 @item __has_nothrow_copy (type)
17096 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
17097 @code{type} is a cv class or union type with copy constructors that
17098 are known not to throw an exception then the trait is true, else it is false.
17099 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
17100 @code{void}, or an array of unknown bound.
17102 @item __has_nothrow_constructor (type)
17103 If @code{__has_trivial_constructor (type)} is true then the trait is
17104 true, else if @code{type} is a cv class or union type (or array
17105 thereof) with a default constructor that is known not to throw an
17106 exception then the trait is true, else it is false.  Requires:
17107 @code{type} shall be a complete type, (possibly cv-qualified)
17108 @code{void}, or an array of unknown bound.
17110 @item __has_trivial_assign (type)
17111 If @code{type} is const qualified or is a reference type then the trait is
17112 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
17113 true, else if @code{type} is a cv class or union type with a trivial
17114 copy assignment ([class.copy]) then the trait is true, else it is
17115 false.  Requires: @code{type} shall be a complete type, (possibly
17116 cv-qualified) @code{void}, or an array of unknown bound.
17118 @item __has_trivial_copy (type)
17119 If @code{__is_pod (type)} is true or @code{type} is a reference type
17120 then the trait is true, else if @code{type} is a cv class or union type
17121 with a trivial copy constructor ([class.copy]) then the trait
17122 is true, else it is false.  Requires: @code{type} shall be a complete
17123 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17125 @item __has_trivial_constructor (type)
17126 If @code{__is_pod (type)} is true then the trait is true, else if
17127 @code{type} is a cv class or union type (or array thereof) with a
17128 trivial default constructor ([class.ctor]) then the trait is true,
17129 else it is false.  Requires: @code{type} shall be a complete
17130 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17132 @item __has_trivial_destructor (type)
17133 If @code{__is_pod (type)} is true or @code{type} is a reference type then
17134 the trait is true, else if @code{type} is a cv class or union type (or
17135 array thereof) with a trivial destructor ([class.dtor]) then the trait
17136 is true, else it is false.  Requires: @code{type} shall be a complete
17137 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17139 @item __has_virtual_destructor (type)
17140 If @code{type} is a class type with a virtual destructor
17141 ([class.dtor]) then the trait is true, else it is false.  Requires:
17142 @code{type} shall be a complete type, (possibly cv-qualified)
17143 @code{void}, or an array of unknown bound.
17145 @item __is_abstract (type)
17146 If @code{type} is an abstract class ([class.abstract]) then the trait
17147 is true, else it is false.  Requires: @code{type} shall be a complete
17148 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17150 @item __is_base_of (base_type, derived_type)
17151 If @code{base_type} is a base class of @code{derived_type}
17152 ([class.derived]) then the trait is true, otherwise it is false.
17153 Top-level cv qualifications of @code{base_type} and
17154 @code{derived_type} are ignored.  For the purposes of this trait, a
17155 class type is considered is own base.  Requires: if @code{__is_class
17156 (base_type)} and @code{__is_class (derived_type)} are true and
17157 @code{base_type} and @code{derived_type} are not the same type
17158 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
17159 type.  Diagnostic is produced if this requirement is not met.
17161 @item __is_class (type)
17162 If @code{type} is a cv class type, and not a union type
17163 ([basic.compound]) the trait is true, else it is false.
17165 @item __is_empty (type)
17166 If @code{__is_class (type)} is false then the trait is false.
17167 Otherwise @code{type} is considered empty if and only if: @code{type}
17168 has no non-static data members, or all non-static data members, if
17169 any, are bit-fields of length 0, and @code{type} has no virtual
17170 members, and @code{type} has no virtual base classes, and @code{type}
17171 has no base classes @code{base_type} for which
17172 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
17173 be a complete type, (possibly cv-qualified) @code{void}, or an array
17174 of unknown bound.
17176 @item __is_enum (type)
17177 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
17178 true, else it is false.
17180 @item __is_literal_type (type)
17181 If @code{type} is a literal type ([basic.types]) the trait is
17182 true, else it is false.  Requires: @code{type} shall be a complete type,
17183 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17185 @item __is_pod (type)
17186 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
17187 else it is false.  Requires: @code{type} shall be a complete type,
17188 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17190 @item __is_polymorphic (type)
17191 If @code{type} is a polymorphic class ([class.virtual]) then the trait
17192 is true, else it is false.  Requires: @code{type} shall be a complete
17193 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17195 @item __is_standard_layout (type)
17196 If @code{type} is a standard-layout type ([basic.types]) the trait is
17197 true, else it is false.  Requires: @code{type} shall be a complete
17198 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17200 @item __is_trivial (type)
17201 If @code{type} is a trivial type ([basic.types]) the trait is
17202 true, else it is false.  Requires: @code{type} shall be a complete
17203 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17205 @item __is_union (type)
17206 If @code{type} is a cv union type ([basic.compound]) the trait is
17207 true, else it is false.
17209 @item __underlying_type (type)
17210 The underlying type of @code{type}.  Requires: @code{type} shall be
17211 an enumeration type ([dcl.enum]).
17213 @end table
17215 @node Java Exceptions
17216 @section Java Exceptions
17218 The Java language uses a slightly different exception handling model
17219 from C++.  Normally, GNU C++ automatically detects when you are
17220 writing C++ code that uses Java exceptions, and handle them
17221 appropriately.  However, if C++ code only needs to execute destructors
17222 when Java exceptions are thrown through it, GCC guesses incorrectly.
17223 Sample problematic code is:
17225 @smallexample
17226   struct S @{ ~S(); @};
17227   extern void bar();    // @r{is written in Java, and may throw exceptions}
17228   void foo()
17229   @{
17230     S s;
17231     bar();
17232   @}
17233 @end smallexample
17235 @noindent
17236 The usual effect of an incorrect guess is a link failure, complaining of
17237 a missing routine called @samp{__gxx_personality_v0}.
17239 You can inform the compiler that Java exceptions are to be used in a
17240 translation unit, irrespective of what it might think, by writing
17241 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
17242 @samp{#pragma} must appear before any functions that throw or catch
17243 exceptions, or run destructors when exceptions are thrown through them.
17245 You cannot mix Java and C++ exceptions in the same translation unit.  It
17246 is believed to be safe to throw a C++ exception from one file through
17247 another file compiled for the Java exception model, or vice versa, but
17248 there may be bugs in this area.
17250 @node Deprecated Features
17251 @section Deprecated Features
17253 In the past, the GNU C++ compiler was extended to experiment with new
17254 features, at a time when the C++ language was still evolving.  Now that
17255 the C++ standard is complete, some of those features are superseded by
17256 superior alternatives.  Using the old features might cause a warning in
17257 some cases that the feature will be dropped in the future.  In other
17258 cases, the feature might be gone already.
17260 While the list below is not exhaustive, it documents some of the options
17261 that are now deprecated:
17263 @table @code
17264 @item -fexternal-templates
17265 @itemx -falt-external-templates
17266 These are two of the many ways for G++ to implement template
17267 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
17268 defines how template definitions have to be organized across
17269 implementation units.  G++ has an implicit instantiation mechanism that
17270 should work just fine for standard-conforming code.
17272 @item -fstrict-prototype
17273 @itemx -fno-strict-prototype
17274 Previously it was possible to use an empty prototype parameter list to
17275 indicate an unspecified number of parameters (like C), rather than no
17276 parameters, as C++ demands.  This feature has been removed, except where
17277 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
17278 @end table
17280 G++ allows a virtual function returning @samp{void *} to be overridden
17281 by one returning a different pointer type.  This extension to the
17282 covariant return type rules is now deprecated and will be removed from a
17283 future version.
17285 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
17286 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
17287 and are now removed from G++.  Code using these operators should be
17288 modified to use @code{std::min} and @code{std::max} instead.
17290 The named return value extension has been deprecated, and is now
17291 removed from G++.
17293 The use of initializer lists with new expressions has been deprecated,
17294 and is now removed from G++.
17296 Floating and complex non-type template parameters have been deprecated,
17297 and are now removed from G++.
17299 The implicit typename extension has been deprecated and is now
17300 removed from G++.
17302 The use of default arguments in function pointers, function typedefs
17303 and other places where they are not permitted by the standard is
17304 deprecated and will be removed from a future version of G++.
17306 G++ allows floating-point literals to appear in integral constant expressions,
17307 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
17308 This extension is deprecated and will be removed from a future version.
17310 G++ allows static data members of const floating-point type to be declared
17311 with an initializer in a class definition. The standard only allows
17312 initializers for static members of const integral types and const
17313 enumeration types so this extension has been deprecated and will be removed
17314 from a future version.
17316 @node Backwards Compatibility
17317 @section Backwards Compatibility
17318 @cindex Backwards Compatibility
17319 @cindex ARM [Annotated C++ Reference Manual]
17321 Now that there is a definitive ISO standard C++, G++ has a specification
17322 to adhere to.  The C++ language evolved over time, and features that
17323 used to be acceptable in previous drafts of the standard, such as the ARM
17324 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
17325 compilation of C++ written to such drafts, G++ contains some backwards
17326 compatibilities.  @emph{All such backwards compatibility features are
17327 liable to disappear in future versions of G++.} They should be considered
17328 deprecated.   @xref{Deprecated Features}.
17330 @table @code
17331 @item For scope
17332 If a variable is declared at for scope, it used to remain in scope until
17333 the end of the scope that contained the for statement (rather than just
17334 within the for scope).  G++ retains this, but issues a warning, if such a
17335 variable is accessed outside the for scope.
17337 @item Implicit C language
17338 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
17339 scope to set the language.  On such systems, all header files are
17340 implicitly scoped inside a C language scope.  Also, an empty prototype
17341 @code{()} is treated as an unspecified number of arguments, rather
17342 than no arguments, as C++ demands.
17343 @end table
17345 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
17346 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign