Also turn off OPTION_MASK_ABI_X32 for -m16
[official-gcc.git] / gcc / doc / extend.texi
blob4eef90018206d9fbfeabb860e9326beb001c255c
1 @c Copyright (C) 1988-2014 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Label Attributes::    Specifying attributes on labels.
59 * Attribute Syntax::    Formal syntax for attributes.
60 * Function Prototypes:: Prototype declarations and old-style definitions.
61 * C++ Comments::        C++ comments are recognized.
62 * Dollar Signs::        Dollar sign is allowed in identifiers.
63 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
64 * Variable Attributes:: Specifying attributes of variables.
65 * Type Attributes::     Specifying attributes of types.
66 * Alignment::           Inquiring about the alignment of a type or variable.
67 * Inline::              Defining inline functions (as fast as macros).
68 * Volatiles::           What constitutes an access to a volatile object.
69 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
70 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
71 * Incomplete Enums::    @code{enum foo;}, with details to follow.
72 * Function Names::      Printable strings which are the name of the current
73                         function.
74 * Return Address::      Getting the return or frame address of a function.
75 * Vector Extensions::   Using vector instructions through built-in functions.
76 * Offsetof::            Special syntax for implementing @code{offsetof}.
77 * __sync Builtins::     Legacy built-in functions for atomic memory access.
78 * __atomic Builtins::   Atomic built-in functions with memory model.
79 * x86 specific memory model extensions for transactional memory:: x86 memory models.
80 * Object Size Checking:: Built-in functions for limited buffer overflow
81                         checking.
82 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
83 * Other Builtins::      Other built-in functions.
84 * Target Builtins::     Built-in functions specific to particular targets.
85 * Target Format Checks:: Format checks specific to particular targets.
86 * Pragmas::             Pragmas accepted by GCC.
87 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
88 * Thread-Local::        Per-thread variables.
89 * Binary constants::    Binary constants using the @samp{0b} prefix.
90 @end menu
92 @node Statement Exprs
93 @section Statements and Declarations in Expressions
94 @cindex statements inside expressions
95 @cindex declarations inside expressions
96 @cindex expressions containing statements
97 @cindex macros, statements in expressions
99 @c the above section title wrapped and causes an underfull hbox.. i
100 @c changed it from "within" to "in". --mew 4feb93
101 A compound statement enclosed in parentheses may appear as an expression
102 in GNU C@.  This allows you to use loops, switches, and local variables
103 within an expression.
105 Recall that a compound statement is a sequence of statements surrounded
106 by braces; in this construct, parentheses go around the braces.  For
107 example:
109 @smallexample
110 (@{ int y = foo (); int z;
111    if (y > 0) z = y;
112    else z = - y;
113    z; @})
114 @end smallexample
116 @noindent
117 is a valid (though slightly more complex than necessary) expression
118 for the absolute value of @code{foo ()}.
120 The last thing in the compound statement should be an expression
121 followed by a semicolon; the value of this subexpression serves as the
122 value of the entire construct.  (If you use some other kind of statement
123 last within the braces, the construct has type @code{void}, and thus
124 effectively no value.)
126 This feature is especially useful in making macro definitions ``safe'' (so
127 that they evaluate each operand exactly once).  For example, the
128 ``maximum'' function is commonly defined as a macro in standard C as
129 follows:
131 @smallexample
132 #define max(a,b) ((a) > (b) ? (a) : (b))
133 @end smallexample
135 @noindent
136 @cindex side effects, macro argument
137 But this definition computes either @var{a} or @var{b} twice, with bad
138 results if the operand has side effects.  In GNU C, if you know the
139 type of the operands (here taken as @code{int}), you can define
140 the macro safely as follows:
142 @smallexample
143 #define maxint(a,b) \
144   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
145 @end smallexample
147 Embedded statements are not allowed in constant expressions, such as
148 the value of an enumeration constant, the width of a bit-field, or
149 the initial value of a static variable.
151 If you don't know the type of the operand, you can still do this, but you
152 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
154 In G++, the result value of a statement expression undergoes array and
155 function pointer decay, and is returned by value to the enclosing
156 expression.  For instance, if @code{A} is a class, then
158 @smallexample
159         A a;
161         (@{a;@}).Foo ()
162 @end smallexample
164 @noindent
165 constructs a temporary @code{A} object to hold the result of the
166 statement expression, and that is used to invoke @code{Foo}.
167 Therefore the @code{this} pointer observed by @code{Foo} is not the
168 address of @code{a}.
170 In a statement expression, any temporaries created within a statement
171 are destroyed at that statement's end.  This makes statement
172 expressions inside macros slightly different from function calls.  In
173 the latter case temporaries introduced during argument evaluation are
174 destroyed at the end of the statement that includes the function
175 call.  In the statement expression case they are destroyed during
176 the statement expression.  For instance,
178 @smallexample
179 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
180 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
182 void foo ()
184   macro (X ());
185   function (X ());
187 @end smallexample
189 @noindent
190 has different places where temporaries are destroyed.  For the
191 @code{macro} case, the temporary @code{X} is destroyed just after
192 the initialization of @code{b}.  In the @code{function} case that
193 temporary is destroyed when the function returns.
195 These considerations mean that it is probably a bad idea to use
196 statement expressions of this form in header files that are designed to
197 work with C++.  (Note that some versions of the GNU C Library contained
198 header files using statement expressions that lead to precisely this
199 bug.)
201 Jumping into a statement expression with @code{goto} or using a
202 @code{switch} statement outside the statement expression with a
203 @code{case} or @code{default} label inside the statement expression is
204 not permitted.  Jumping into a statement expression with a computed
205 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
206 Jumping out of a statement expression is permitted, but if the
207 statement expression is part of a larger expression then it is
208 unspecified which other subexpressions of that expression have been
209 evaluated except where the language definition requires certain
210 subexpressions to be evaluated before or after the statement
211 expression.  In any case, as with a function call, the evaluation of a
212 statement expression is not interleaved with the evaluation of other
213 parts of the containing expression.  For example,
215 @smallexample
216   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
217 @end smallexample
219 @noindent
220 calls @code{foo} and @code{bar1} and does not call @code{baz} but
221 may or may not call @code{bar2}.  If @code{bar2} is called, it is
222 called after @code{foo} and before @code{bar1}.
224 @node Local Labels
225 @section Locally Declared Labels
226 @cindex local labels
227 @cindex macros, local labels
229 GCC allows you to declare @dfn{local labels} in any nested block
230 scope.  A local label is just like an ordinary label, but you can
231 only reference it (with a @code{goto} statement, or by taking its
232 address) within the block in which it is declared.
234 A local label declaration looks like this:
236 @smallexample
237 __label__ @var{label};
238 @end smallexample
240 @noindent
243 @smallexample
244 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
245 @end smallexample
247 Local label declarations must come at the beginning of the block,
248 before any ordinary declarations or statements.
250 The label declaration defines the label @emph{name}, but does not define
251 the label itself.  You must do this in the usual way, with
252 @code{@var{label}:}, within the statements of the statement expression.
254 The local label feature is useful for complex macros.  If a macro
255 contains nested loops, a @code{goto} can be useful for breaking out of
256 them.  However, an ordinary label whose scope is the whole function
257 cannot be used: if the macro can be expanded several times in one
258 function, the label is multiply defined in that function.  A
259 local label avoids this problem.  For example:
261 @smallexample
262 #define SEARCH(value, array, target)              \
263 do @{                                              \
264   __label__ found;                                \
265   typeof (target) _SEARCH_target = (target);      \
266   typeof (*(array)) *_SEARCH_array = (array);     \
267   int i, j;                                       \
268   int value;                                      \
269   for (i = 0; i < max; i++)                       \
270     for (j = 0; j < max; j++)                     \
271       if (_SEARCH_array[i][j] == _SEARCH_target)  \
272         @{ (value) = i; goto found; @}              \
273   (value) = -1;                                   \
274  found:;                                          \
275 @} while (0)
276 @end smallexample
278 This could also be written using a statement expression:
280 @smallexample
281 #define SEARCH(array, target)                     \
282 (@{                                                \
283   __label__ found;                                \
284   typeof (target) _SEARCH_target = (target);      \
285   typeof (*(array)) *_SEARCH_array = (array);     \
286   int i, j;                                       \
287   int value;                                      \
288   for (i = 0; i < max; i++)                       \
289     for (j = 0; j < max; j++)                     \
290       if (_SEARCH_array[i][j] == _SEARCH_target)  \
291         @{ value = i; goto found; @}                \
292   value = -1;                                     \
293  found:                                           \
294   value;                                          \
296 @end smallexample
298 Local label declarations also make the labels they declare visible to
299 nested functions, if there are any.  @xref{Nested Functions}, for details.
301 @node Labels as Values
302 @section Labels as Values
303 @cindex labels as values
304 @cindex computed gotos
305 @cindex goto with computed label
306 @cindex address of a label
308 You can get the address of a label defined in the current function
309 (or a containing function) with the unary operator @samp{&&}.  The
310 value has type @code{void *}.  This value is a constant and can be used
311 wherever a constant of that type is valid.  For example:
313 @smallexample
314 void *ptr;
315 /* @r{@dots{}} */
316 ptr = &&foo;
317 @end smallexample
319 To use these values, you need to be able to jump to one.  This is done
320 with the computed goto statement@footnote{The analogous feature in
321 Fortran is called an assigned goto, but that name seems inappropriate in
322 C, where one can do more than simply store label addresses in label
323 variables.}, @code{goto *@var{exp};}.  For example,
325 @smallexample
326 goto *ptr;
327 @end smallexample
329 @noindent
330 Any expression of type @code{void *} is allowed.
332 One way of using these constants is in initializing a static array that
333 serves as a jump table:
335 @smallexample
336 static void *array[] = @{ &&foo, &&bar, &&hack @};
337 @end smallexample
339 @noindent
340 Then you can select a label with indexing, like this:
342 @smallexample
343 goto *array[i];
344 @end smallexample
346 @noindent
347 Note that this does not check whether the subscript is in bounds---array
348 indexing in C never does that.
350 Such an array of label values serves a purpose much like that of the
351 @code{switch} statement.  The @code{switch} statement is cleaner, so
352 use that rather than an array unless the problem does not fit a
353 @code{switch} statement very well.
355 Another use of label values is in an interpreter for threaded code.
356 The labels within the interpreter function can be stored in the
357 threaded code for super-fast dispatching.
359 You may not use this mechanism to jump to code in a different function.
360 If you do that, totally unpredictable things happen.  The best way to
361 avoid this is to store the label address only in automatic variables and
362 never pass it as an argument.
364 An alternate way to write the above example is
366 @smallexample
367 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
368                              &&hack - &&foo @};
369 goto *(&&foo + array[i]);
370 @end smallexample
372 @noindent
373 This is more friendly to code living in shared libraries, as it reduces
374 the number of dynamic relocations that are needed, and by consequence,
375 allows the data to be read-only.
376 This alternative with label differences is not supported for the AVR target,
377 please use the first approach for AVR programs.
379 The @code{&&foo} expressions for the same label might have different
380 values if the containing function is inlined or cloned.  If a program
381 relies on them being always the same,
382 @code{__attribute__((__noinline__,__noclone__))} should be used to
383 prevent inlining and cloning.  If @code{&&foo} is used in a static
384 variable initializer, inlining and cloning is forbidden.
386 @node Nested Functions
387 @section Nested Functions
388 @cindex nested functions
389 @cindex downward funargs
390 @cindex thunks
392 A @dfn{nested function} is a function defined inside another function.
393 Nested functions are supported as an extension in GNU C, but are not
394 supported by GNU C++.
396 The nested function's name is local to the block where it is defined.
397 For example, here we define a nested function named @code{square}, and
398 call it twice:
400 @smallexample
401 @group
402 foo (double a, double b)
404   double square (double z) @{ return z * z; @}
406   return square (a) + square (b);
408 @end group
409 @end smallexample
411 The nested function can access all the variables of the containing
412 function that are visible at the point of its definition.  This is
413 called @dfn{lexical scoping}.  For example, here we show a nested
414 function which uses an inherited variable named @code{offset}:
416 @smallexample
417 @group
418 bar (int *array, int offset, int size)
420   int access (int *array, int index)
421     @{ return array[index + offset]; @}
422   int i;
423   /* @r{@dots{}} */
424   for (i = 0; i < size; i++)
425     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
427 @end group
428 @end smallexample
430 Nested function definitions are permitted within functions in the places
431 where variable definitions are allowed; that is, in any block, mixed
432 with the other declarations and statements in the block.
434 It is possible to call the nested function from outside the scope of its
435 name by storing its address or passing the address to another function:
437 @smallexample
438 hack (int *array, int size)
440   void store (int index, int value)
441     @{ array[index] = value; @}
443   intermediate (store, size);
445 @end smallexample
447 Here, the function @code{intermediate} receives the address of
448 @code{store} as an argument.  If @code{intermediate} calls @code{store},
449 the arguments given to @code{store} are used to store into @code{array}.
450 But this technique works only so long as the containing function
451 (@code{hack}, in this example) does not exit.
453 If you try to call the nested function through its address after the
454 containing function exits, all hell breaks loose.  If you try
455 to call it after a containing scope level exits, and if it refers
456 to some of the variables that are no longer in scope, you may be lucky,
457 but it's not wise to take the risk.  If, however, the nested function
458 does not refer to anything that has gone out of scope, you should be
459 safe.
461 GCC implements taking the address of a nested function using a technique
462 called @dfn{trampolines}.  This technique was described in
463 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
464 C++ Conference Proceedings, October 17-21, 1988).
466 A nested function can jump to a label inherited from a containing
467 function, provided the label is explicitly declared in the containing
468 function (@pxref{Local Labels}).  Such a jump returns instantly to the
469 containing function, exiting the nested function that did the
470 @code{goto} and any intermediate functions as well.  Here is an example:
472 @smallexample
473 @group
474 bar (int *array, int offset, int size)
476   __label__ failure;
477   int access (int *array, int index)
478     @{
479       if (index > size)
480         goto failure;
481       return array[index + offset];
482     @}
483   int i;
484   /* @r{@dots{}} */
485   for (i = 0; i < size; i++)
486     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
487   /* @r{@dots{}} */
488   return 0;
490  /* @r{Control comes here from @code{access}
491     if it detects an error.}  */
492  failure:
493   return -1;
495 @end group
496 @end smallexample
498 A nested function always has no linkage.  Declaring one with
499 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
500 before its definition, use @code{auto} (which is otherwise meaningless
501 for function declarations).
503 @smallexample
504 bar (int *array, int offset, int size)
506   __label__ failure;
507   auto int access (int *, int);
508   /* @r{@dots{}} */
509   int access (int *array, int index)
510     @{
511       if (index > size)
512         goto failure;
513       return array[index + offset];
514     @}
515   /* @r{@dots{}} */
517 @end smallexample
519 @node Constructing Calls
520 @section Constructing Function Calls
521 @cindex constructing calls
522 @cindex forwarding calls
524 Using the built-in functions described below, you can record
525 the arguments a function received, and call another function
526 with the same arguments, without knowing the number or types
527 of the arguments.
529 You can also record the return value of that function call,
530 and later return that value, without knowing what data type
531 the function tried to return (as long as your caller expects
532 that data type).
534 However, these built-in functions may interact badly with some
535 sophisticated features or other extensions of the language.  It
536 is, therefore, not recommended to use them outside very simple
537 functions acting as mere forwarders for their arguments.
539 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
540 This built-in function returns a pointer to data
541 describing how to perform a call with the same arguments as are passed
542 to the current function.
544 The function saves the arg pointer register, structure value address,
545 and all registers that might be used to pass arguments to a function
546 into a block of memory allocated on the stack.  Then it returns the
547 address of that block.
548 @end deftypefn
550 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
551 This built-in function invokes @var{function}
552 with a copy of the parameters described by @var{arguments}
553 and @var{size}.
555 The value of @var{arguments} should be the value returned by
556 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
557 of the stack argument data, in bytes.
559 This function returns a pointer to data describing
560 how to return whatever value is returned by @var{function}.  The data
561 is saved in a block of memory allocated on the stack.
563 It is not always simple to compute the proper value for @var{size}.  The
564 value is used by @code{__builtin_apply} to compute the amount of data
565 that should be pushed on the stack and copied from the incoming argument
566 area.
567 @end deftypefn
569 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
570 This built-in function returns the value described by @var{result} from
571 the containing function.  You should specify, for @var{result}, a value
572 returned by @code{__builtin_apply}.
573 @end deftypefn
575 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
576 This built-in function represents all anonymous arguments of an inline
577 function.  It can be used only in inline functions that are always
578 inlined, never compiled as a separate function, such as those using
579 @code{__attribute__ ((__always_inline__))} or
580 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
581 It must be only passed as last argument to some other function
582 with variable arguments.  This is useful for writing small wrapper
583 inlines for variable argument functions, when using preprocessor
584 macros is undesirable.  For example:
585 @smallexample
586 extern int myprintf (FILE *f, const char *format, ...);
587 extern inline __attribute__ ((__gnu_inline__)) int
588 myprintf (FILE *f, const char *format, ...)
590   int r = fprintf (f, "myprintf: ");
591   if (r < 0)
592     return r;
593   int s = fprintf (f, format, __builtin_va_arg_pack ());
594   if (s < 0)
595     return s;
596   return r + s;
598 @end smallexample
599 @end deftypefn
601 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
602 This built-in function returns the number of anonymous arguments of
603 an inline function.  It can be used only in inline functions that
604 are always inlined, never compiled as a separate function, such
605 as those using @code{__attribute__ ((__always_inline__))} or
606 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
607 For example following does link- or run-time checking of open
608 arguments for optimized code:
609 @smallexample
610 #ifdef __OPTIMIZE__
611 extern inline __attribute__((__gnu_inline__)) int
612 myopen (const char *path, int oflag, ...)
614   if (__builtin_va_arg_pack_len () > 1)
615     warn_open_too_many_arguments ();
617   if (__builtin_constant_p (oflag))
618     @{
619       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
620         @{
621           warn_open_missing_mode ();
622           return __open_2 (path, oflag);
623         @}
624       return open (path, oflag, __builtin_va_arg_pack ());
625     @}
627   if (__builtin_va_arg_pack_len () < 1)
628     return __open_2 (path, oflag);
630   return open (path, oflag, __builtin_va_arg_pack ());
632 #endif
633 @end smallexample
634 @end deftypefn
636 @node Typeof
637 @section Referring to a Type with @code{typeof}
638 @findex typeof
639 @findex sizeof
640 @cindex macros, types of arguments
642 Another way to refer to the type of an expression is with @code{typeof}.
643 The syntax of using of this keyword looks like @code{sizeof}, but the
644 construct acts semantically like a type name defined with @code{typedef}.
646 There are two ways of writing the argument to @code{typeof}: with an
647 expression or with a type.  Here is an example with an expression:
649 @smallexample
650 typeof (x[0](1))
651 @end smallexample
653 @noindent
654 This assumes that @code{x} is an array of pointers to functions;
655 the type described is that of the values of the functions.
657 Here is an example with a typename as the argument:
659 @smallexample
660 typeof (int *)
661 @end smallexample
663 @noindent
664 Here the type described is that of pointers to @code{int}.
666 If you are writing a header file that must work when included in ISO C
667 programs, write @code{__typeof__} instead of @code{typeof}.
668 @xref{Alternate Keywords}.
670 A @code{typeof} construct can be used anywhere a typedef name can be
671 used.  For example, you can use it in a declaration, in a cast, or inside
672 of @code{sizeof} or @code{typeof}.
674 The operand of @code{typeof} is evaluated for its side effects if and
675 only if it is an expression of variably modified type or the name of
676 such a type.
678 @code{typeof} is often useful in conjunction with
679 statement expressions (@pxref{Statement Exprs}).
680 Here is how the two together can
681 be used to define a safe ``maximum'' macro which operates on any
682 arithmetic type and evaluates each of its arguments exactly once:
684 @smallexample
685 #define max(a,b) \
686   (@{ typeof (a) _a = (a); \
687       typeof (b) _b = (b); \
688     _a > _b ? _a : _b; @})
689 @end smallexample
691 @cindex underscores in variables in macros
692 @cindex @samp{_} in variables in macros
693 @cindex local variables in macros
694 @cindex variables, local, in macros
695 @cindex macros, local variables in
697 The reason for using names that start with underscores for the local
698 variables is to avoid conflicts with variable names that occur within the
699 expressions that are substituted for @code{a} and @code{b}.  Eventually we
700 hope to design a new form of declaration syntax that allows you to declare
701 variables whose scopes start only after their initializers; this will be a
702 more reliable way to prevent such conflicts.
704 @noindent
705 Some more examples of the use of @code{typeof}:
707 @itemize @bullet
708 @item
709 This declares @code{y} with the type of what @code{x} points to.
711 @smallexample
712 typeof (*x) y;
713 @end smallexample
715 @item
716 This declares @code{y} as an array of such values.
718 @smallexample
719 typeof (*x) y[4];
720 @end smallexample
722 @item
723 This declares @code{y} as an array of pointers to characters:
725 @smallexample
726 typeof (typeof (char *)[4]) y;
727 @end smallexample
729 @noindent
730 It is equivalent to the following traditional C declaration:
732 @smallexample
733 char *y[4];
734 @end smallexample
736 To see the meaning of the declaration using @code{typeof}, and why it
737 might be a useful way to write, rewrite it with these macros:
739 @smallexample
740 #define pointer(T)  typeof(T *)
741 #define array(T, N) typeof(T [N])
742 @end smallexample
744 @noindent
745 Now the declaration can be rewritten this way:
747 @smallexample
748 array (pointer (char), 4) y;
749 @end smallexample
751 @noindent
752 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
753 pointers to @code{char}.
754 @end itemize
756 In GNU C, but not GNU C++, you may also declare the type of a variable
757 as @code{__auto_type}.  In that case, the declaration must declare
758 only one variable, whose declarator must just be an identifier, the
759 declaration must be initialized, and the type of the variable is
760 determined by the initializer; the name of the variable is not in
761 scope until after the initializer.  (In C++, you should use C++11
762 @code{auto} for this purpose.)  Using @code{__auto_type}, the
763 ``maximum'' macro above could be written as:
765 @smallexample
766 #define max(a,b) \
767   (@{ __auto_type _a = (a); \
768       __auto_type _b = (b); \
769     _a > _b ? _a : _b; @})
770 @end smallexample
772 Using @code{__auto_type} instead of @code{typeof} has two advantages:
774 @itemize @bullet
775 @item Each argument to the macro appears only once in the expansion of
776 the macro.  This prevents the size of the macro expansion growing
777 exponentially when calls to such macros are nested inside arguments of
778 such macros.
780 @item If the argument to the macro has variably modified type, it is
781 evaluated only once when using @code{__auto_type}, but twice if
782 @code{typeof} is used.
783 @end itemize
785 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
786 a more limited extension that permitted one to write
788 @smallexample
789 typedef @var{T} = @var{expr};
790 @end smallexample
792 @noindent
793 with the effect of declaring @var{T} to have the type of the expression
794 @var{expr}.  This extension does not work with GCC 3 (versions between
795 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
796 relies on it should be rewritten to use @code{typeof}:
798 @smallexample
799 typedef typeof(@var{expr}) @var{T};
800 @end smallexample
802 @noindent
803 This works with all versions of GCC@.
805 @node Conditionals
806 @section Conditionals with Omitted Operands
807 @cindex conditional expressions, extensions
808 @cindex omitted middle-operands
809 @cindex middle-operands, omitted
810 @cindex extensions, @code{?:}
811 @cindex @code{?:} extensions
813 The middle operand in a conditional expression may be omitted.  Then
814 if the first operand is nonzero, its value is the value of the conditional
815 expression.
817 Therefore, the expression
819 @smallexample
820 x ? : y
821 @end smallexample
823 @noindent
824 has the value of @code{x} if that is nonzero; otherwise, the value of
825 @code{y}.
827 This example is perfectly equivalent to
829 @smallexample
830 x ? x : y
831 @end smallexample
833 @cindex side effect in @code{?:}
834 @cindex @code{?:} side effect
835 @noindent
836 In this simple case, the ability to omit the middle operand is not
837 especially useful.  When it becomes useful is when the first operand does,
838 or may (if it is a macro argument), contain a side effect.  Then repeating
839 the operand in the middle would perform the side effect twice.  Omitting
840 the middle operand uses the value already computed without the undesirable
841 effects of recomputing it.
843 @node __int128
844 @section 128-bit integers
845 @cindex @code{__int128} data types
847 As an extension the integer scalar type @code{__int128} is supported for
848 targets which have an integer mode wide enough to hold 128 bits.
849 Simply write @code{__int128} for a signed 128-bit integer, or
850 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
851 support in GCC for expressing an integer constant of type @code{__int128}
852 for targets with @code{long long} integer less than 128 bits wide.
854 @node Long Long
855 @section Double-Word Integers
856 @cindex @code{long long} data types
857 @cindex double-word arithmetic
858 @cindex multiprecision arithmetic
859 @cindex @code{LL} integer suffix
860 @cindex @code{ULL} integer suffix
862 ISO C99 supports data types for integers that are at least 64 bits wide,
863 and as an extension GCC supports them in C90 mode and in C++.
864 Simply write @code{long long int} for a signed integer, or
865 @code{unsigned long long int} for an unsigned integer.  To make an
866 integer constant of type @code{long long int}, add the suffix @samp{LL}
867 to the integer.  To make an integer constant of type @code{unsigned long
868 long int}, add the suffix @samp{ULL} to the integer.
870 You can use these types in arithmetic like any other integer types.
871 Addition, subtraction, and bitwise boolean operations on these types
872 are open-coded on all types of machines.  Multiplication is open-coded
873 if the machine supports a fullword-to-doubleword widening multiply
874 instruction.  Division and shifts are open-coded only on machines that
875 provide special support.  The operations that are not open-coded use
876 special library routines that come with GCC@.
878 There may be pitfalls when you use @code{long long} types for function
879 arguments without function prototypes.  If a function
880 expects type @code{int} for its argument, and you pass a value of type
881 @code{long long int}, confusion results because the caller and the
882 subroutine disagree about the number of bytes for the argument.
883 Likewise, if the function expects @code{long long int} and you pass
884 @code{int}.  The best way to avoid such problems is to use prototypes.
886 @node Complex
887 @section Complex Numbers
888 @cindex complex numbers
889 @cindex @code{_Complex} keyword
890 @cindex @code{__complex__} keyword
892 ISO C99 supports complex floating data types, and as an extension GCC
893 supports them in C90 mode and in C++.  GCC also supports complex integer data
894 types which are not part of ISO C99.  You can declare complex types
895 using the keyword @code{_Complex}.  As an extension, the older GNU
896 keyword @code{__complex__} is also supported.
898 For example, @samp{_Complex double x;} declares @code{x} as a
899 variable whose real part and imaginary part are both of type
900 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
901 have real and imaginary parts of type @code{short int}; this is not
902 likely to be useful, but it shows that the set of complex types is
903 complete.
905 To write a constant with a complex data type, use the suffix @samp{i} or
906 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
907 has type @code{_Complex float} and @code{3i} has type
908 @code{_Complex int}.  Such a constant always has a pure imaginary
909 value, but you can form any complex value you like by adding one to a
910 real constant.  This is a GNU extension; if you have an ISO C99
911 conforming C library (such as the GNU C Library), and want to construct complex
912 constants of floating type, you should include @code{<complex.h>} and
913 use the macros @code{I} or @code{_Complex_I} instead.
915 @cindex @code{__real__} keyword
916 @cindex @code{__imag__} keyword
917 To extract the real part of a complex-valued expression @var{exp}, write
918 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
919 extract the imaginary part.  This is a GNU extension; for values of
920 floating type, you should use the ISO C99 functions @code{crealf},
921 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
922 @code{cimagl}, declared in @code{<complex.h>} and also provided as
923 built-in functions by GCC@.
925 @cindex complex conjugation
926 The operator @samp{~} performs complex conjugation when used on a value
927 with a complex type.  This is a GNU extension; for values of
928 floating type, you should use the ISO C99 functions @code{conjf},
929 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
930 provided as built-in functions by GCC@.
932 GCC can allocate complex automatic variables in a noncontiguous
933 fashion; it's even possible for the real part to be in a register while
934 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
935 debug info format can represent this, so use of DWARF 2 is recommended.
936 If you are using the stabs debug info format, GCC describes a noncontiguous
937 complex variable as if it were two separate variables of noncomplex type.
938 If the variable's actual name is @code{foo}, the two fictitious
939 variables are named @code{foo$real} and @code{foo$imag}.  You can
940 examine and set these two fictitious variables with your debugger.
942 @node Floating Types
943 @section Additional Floating Types
944 @cindex additional floating types
945 @cindex @code{__float80} data type
946 @cindex @code{__float128} data type
947 @cindex @code{w} floating point suffix
948 @cindex @code{q} floating point suffix
949 @cindex @code{W} floating point suffix
950 @cindex @code{Q} floating point suffix
952 As an extension, GNU C supports additional floating
953 types, @code{__float80} and @code{__float128} to support 80-bit
954 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
955 Support for additional types includes the arithmetic operators:
956 add, subtract, multiply, divide; unary arithmetic operators;
957 relational operators; equality operators; and conversions to and from
958 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
959 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
960 for @code{_float128}.  You can declare complex types using the
961 corresponding internal complex type, @code{XCmode} for @code{__float80}
962 type and @code{TCmode} for @code{__float128} type:
964 @smallexample
965 typedef _Complex float __attribute__((mode(TC))) _Complex128;
966 typedef _Complex float __attribute__((mode(XC))) _Complex80;
967 @end smallexample
969 Not all targets support additional floating-point types.  @code{__float80}
970 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
971 The @code{__float128} type is supported on hppa HP-UX targets.
973 @node Half-Precision
974 @section Half-Precision Floating Point
975 @cindex half-precision floating point
976 @cindex @code{__fp16} data type
978 On ARM targets, GCC supports half-precision (16-bit) floating point via
979 the @code{__fp16} type.  You must enable this type explicitly
980 with the @option{-mfp16-format} command-line option in order to use it.
982 ARM supports two incompatible representations for half-precision
983 floating-point values.  You must choose one of the representations and
984 use it consistently in your program.
986 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
987 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
988 There are 11 bits of significand precision, approximately 3
989 decimal digits.
991 Specifying @option{-mfp16-format=alternative} selects the ARM
992 alternative format.  This representation is similar to the IEEE
993 format, but does not support infinities or NaNs.  Instead, the range
994 of exponents is extended, so that this format can represent normalized
995 values in the range of @math{2^{-14}} to 131008.
997 The @code{__fp16} type is a storage format only.  For purposes
998 of arithmetic and other operations, @code{__fp16} values in C or C++
999 expressions are automatically promoted to @code{float}.  In addition,
1000 you cannot declare a function with a return value or parameters
1001 of type @code{__fp16}.
1003 Note that conversions from @code{double} to @code{__fp16}
1004 involve an intermediate conversion to @code{float}.  Because
1005 of rounding, this can sometimes produce a different result than a
1006 direct conversion.
1008 ARM provides hardware support for conversions between
1009 @code{__fp16} and @code{float} values
1010 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1011 code using these hardware instructions if you compile with
1012 options to select an FPU that provides them;
1013 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1014 in addition to the @option{-mfp16-format} option to select
1015 a half-precision format.
1017 Language-level support for the @code{__fp16} data type is
1018 independent of whether GCC generates code using hardware floating-point
1019 instructions.  In cases where hardware support is not specified, GCC
1020 implements conversions between @code{__fp16} and @code{float} values
1021 as library calls.
1023 @node Decimal Float
1024 @section Decimal Floating Types
1025 @cindex decimal floating types
1026 @cindex @code{_Decimal32} data type
1027 @cindex @code{_Decimal64} data type
1028 @cindex @code{_Decimal128} data type
1029 @cindex @code{df} integer suffix
1030 @cindex @code{dd} integer suffix
1031 @cindex @code{dl} integer suffix
1032 @cindex @code{DF} integer suffix
1033 @cindex @code{DD} integer suffix
1034 @cindex @code{DL} integer suffix
1036 As an extension, GNU C supports decimal floating types as
1037 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1038 floating types in GCC will evolve as the draft technical report changes.
1039 Calling conventions for any target might also change.  Not all targets
1040 support decimal floating types.
1042 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1043 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1044 @code{float}, @code{double}, and @code{long double} whose radix is not
1045 specified by the C standard but is usually two.
1047 Support for decimal floating types includes the arithmetic operators
1048 add, subtract, multiply, divide; unary arithmetic operators;
1049 relational operators; equality operators; and conversions to and from
1050 integer and other floating types.  Use a suffix @samp{df} or
1051 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1052 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1053 @code{_Decimal128}.
1055 GCC support of decimal float as specified by the draft technical report
1056 is incomplete:
1058 @itemize @bullet
1059 @item
1060 When the value of a decimal floating type cannot be represented in the
1061 integer type to which it is being converted, the result is undefined
1062 rather than the result value specified by the draft technical report.
1064 @item
1065 GCC does not provide the C library functionality associated with
1066 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1067 @file{wchar.h}, which must come from a separate C library implementation.
1068 Because of this the GNU C compiler does not define macro
1069 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1070 the technical report.
1071 @end itemize
1073 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1074 are supported by the DWARF 2 debug information format.
1076 @node Hex Floats
1077 @section Hex Floats
1078 @cindex hex floats
1080 ISO C99 supports floating-point numbers written not only in the usual
1081 decimal notation, such as @code{1.55e1}, but also numbers such as
1082 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1083 supports this in C90 mode (except in some cases when strictly
1084 conforming) and in C++.  In that format the
1085 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1086 mandatory.  The exponent is a decimal number that indicates the power of
1087 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1088 @tex
1089 $1 {15\over16}$,
1090 @end tex
1091 @ifnottex
1092 1 15/16,
1093 @end ifnottex
1094 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1095 is the same as @code{1.55e1}.
1097 Unlike for floating-point numbers in the decimal notation the exponent
1098 is always required in the hexadecimal notation.  Otherwise the compiler
1099 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1100 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1101 extension for floating-point constants of type @code{float}.
1103 @node Fixed-Point
1104 @section Fixed-Point Types
1105 @cindex fixed-point types
1106 @cindex @code{_Fract} data type
1107 @cindex @code{_Accum} data type
1108 @cindex @code{_Sat} data type
1109 @cindex @code{hr} fixed-suffix
1110 @cindex @code{r} fixed-suffix
1111 @cindex @code{lr} fixed-suffix
1112 @cindex @code{llr} fixed-suffix
1113 @cindex @code{uhr} fixed-suffix
1114 @cindex @code{ur} fixed-suffix
1115 @cindex @code{ulr} fixed-suffix
1116 @cindex @code{ullr} fixed-suffix
1117 @cindex @code{hk} fixed-suffix
1118 @cindex @code{k} fixed-suffix
1119 @cindex @code{lk} fixed-suffix
1120 @cindex @code{llk} fixed-suffix
1121 @cindex @code{uhk} fixed-suffix
1122 @cindex @code{uk} fixed-suffix
1123 @cindex @code{ulk} fixed-suffix
1124 @cindex @code{ullk} fixed-suffix
1125 @cindex @code{HR} fixed-suffix
1126 @cindex @code{R} fixed-suffix
1127 @cindex @code{LR} fixed-suffix
1128 @cindex @code{LLR} fixed-suffix
1129 @cindex @code{UHR} fixed-suffix
1130 @cindex @code{UR} fixed-suffix
1131 @cindex @code{ULR} fixed-suffix
1132 @cindex @code{ULLR} fixed-suffix
1133 @cindex @code{HK} fixed-suffix
1134 @cindex @code{K} fixed-suffix
1135 @cindex @code{LK} fixed-suffix
1136 @cindex @code{LLK} fixed-suffix
1137 @cindex @code{UHK} fixed-suffix
1138 @cindex @code{UK} fixed-suffix
1139 @cindex @code{ULK} fixed-suffix
1140 @cindex @code{ULLK} fixed-suffix
1142 As an extension, GNU C supports fixed-point types as
1143 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1144 types in GCC will evolve as the draft technical report changes.
1145 Calling conventions for any target might also change.  Not all targets
1146 support fixed-point types.
1148 The fixed-point types are
1149 @code{short _Fract},
1150 @code{_Fract},
1151 @code{long _Fract},
1152 @code{long long _Fract},
1153 @code{unsigned short _Fract},
1154 @code{unsigned _Fract},
1155 @code{unsigned long _Fract},
1156 @code{unsigned long long _Fract},
1157 @code{_Sat short _Fract},
1158 @code{_Sat _Fract},
1159 @code{_Sat long _Fract},
1160 @code{_Sat long long _Fract},
1161 @code{_Sat unsigned short _Fract},
1162 @code{_Sat unsigned _Fract},
1163 @code{_Sat unsigned long _Fract},
1164 @code{_Sat unsigned long long _Fract},
1165 @code{short _Accum},
1166 @code{_Accum},
1167 @code{long _Accum},
1168 @code{long long _Accum},
1169 @code{unsigned short _Accum},
1170 @code{unsigned _Accum},
1171 @code{unsigned long _Accum},
1172 @code{unsigned long long _Accum},
1173 @code{_Sat short _Accum},
1174 @code{_Sat _Accum},
1175 @code{_Sat long _Accum},
1176 @code{_Sat long long _Accum},
1177 @code{_Sat unsigned short _Accum},
1178 @code{_Sat unsigned _Accum},
1179 @code{_Sat unsigned long _Accum},
1180 @code{_Sat unsigned long long _Accum}.
1182 Fixed-point data values contain fractional and optional integral parts.
1183 The format of fixed-point data varies and depends on the target machine.
1185 Support for fixed-point types includes:
1186 @itemize @bullet
1187 @item
1188 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1189 @item
1190 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1191 @item
1192 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1193 @item
1194 binary shift operators (@code{<<}, @code{>>})
1195 @item
1196 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1197 @item
1198 equality operators (@code{==}, @code{!=})
1199 @item
1200 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1201 @code{<<=}, @code{>>=})
1202 @item
1203 conversions to and from integer, floating-point, or fixed-point types
1204 @end itemize
1206 Use a suffix in a fixed-point literal constant:
1207 @itemize
1208 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1209 @code{_Sat short _Fract}
1210 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1211 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1212 @code{_Sat long _Fract}
1213 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1214 @code{_Sat long long _Fract}
1215 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1216 @code{_Sat unsigned short _Fract}
1217 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1218 @code{_Sat unsigned _Fract}
1219 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1220 @code{_Sat unsigned long _Fract}
1221 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1222 and @code{_Sat unsigned long long _Fract}
1223 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1224 @code{_Sat short _Accum}
1225 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1226 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1227 @code{_Sat long _Accum}
1228 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1229 @code{_Sat long long _Accum}
1230 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1231 @code{_Sat unsigned short _Accum}
1232 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1233 @code{_Sat unsigned _Accum}
1234 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1235 @code{_Sat unsigned long _Accum}
1236 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1237 and @code{_Sat unsigned long long _Accum}
1238 @end itemize
1240 GCC support of fixed-point types as specified by the draft technical report
1241 is incomplete:
1243 @itemize @bullet
1244 @item
1245 Pragmas to control overflow and rounding behaviors are not implemented.
1246 @end itemize
1248 Fixed-point types are supported by the DWARF 2 debug information format.
1250 @node Named Address Spaces
1251 @section Named Address Spaces
1252 @cindex Named Address Spaces
1254 As an extension, GNU C supports named address spaces as
1255 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1256 address spaces in GCC will evolve as the draft technical report
1257 changes.  Calling conventions for any target might also change.  At
1258 present, only the AVR, SPU, M32C, and RL78 targets support address
1259 spaces other than the generic address space.
1261 Address space identifiers may be used exactly like any other C type
1262 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1263 document for more details.
1265 @anchor{AVR Named Address Spaces}
1266 @subsection AVR Named Address Spaces
1268 On the AVR target, there are several address spaces that can be used
1269 in order to put read-only data into the flash memory and access that
1270 data by means of the special instructions @code{LPM} or @code{ELPM}
1271 needed to read from flash.
1273 Per default, any data including read-only data is located in RAM
1274 (the generic address space) so that non-generic address spaces are
1275 needed to locate read-only data in flash memory
1276 @emph{and} to generate the right instructions to access this data
1277 without using (inline) assembler code.
1279 @table @code
1280 @item __flash
1281 @cindex @code{__flash} AVR Named Address Spaces
1282 The @code{__flash} qualifier locates data in the
1283 @code{.progmem.data} section. Data is read using the @code{LPM}
1284 instruction. Pointers to this address space are 16 bits wide.
1286 @item __flash1
1287 @itemx __flash2
1288 @itemx __flash3
1289 @itemx __flash4
1290 @itemx __flash5
1291 @cindex @code{__flash1} AVR Named Address Spaces
1292 @cindex @code{__flash2} AVR Named Address Spaces
1293 @cindex @code{__flash3} AVR Named Address Spaces
1294 @cindex @code{__flash4} AVR Named Address Spaces
1295 @cindex @code{__flash5} AVR Named Address Spaces
1296 These are 16-bit address spaces locating data in section
1297 @code{.progmem@var{N}.data} where @var{N} refers to
1298 address space @code{__flash@var{N}}.
1299 The compiler sets the @code{RAMPZ} segment register appropriately 
1300 before reading data by means of the @code{ELPM} instruction.
1302 @item __memx
1303 @cindex @code{__memx} AVR Named Address Spaces
1304 This is a 24-bit address space that linearizes flash and RAM:
1305 If the high bit of the address is set, data is read from
1306 RAM using the lower two bytes as RAM address.
1307 If the high bit of the address is clear, data is read from flash
1308 with @code{RAMPZ} set according to the high byte of the address.
1309 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1311 Objects in this address space are located in @code{.progmemx.data}.
1312 @end table
1314 @b{Example}
1316 @smallexample
1317 char my_read (const __flash char ** p)
1319     /* p is a pointer to RAM that points to a pointer to flash.
1320        The first indirection of p reads that flash pointer
1321        from RAM and the second indirection reads a char from this
1322        flash address.  */
1324     return **p;
1327 /* Locate array[] in flash memory */
1328 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1330 int i = 1;
1332 int main (void)
1334    /* Return 17 by reading from flash memory */
1335    return array[array[i]];
1337 @end smallexample
1339 @noindent
1340 For each named address space supported by avr-gcc there is an equally
1341 named but uppercase built-in macro defined. 
1342 The purpose is to facilitate testing if respective address space
1343 support is available or not:
1345 @smallexample
1346 #ifdef __FLASH
1347 const __flash int var = 1;
1349 int read_var (void)
1351     return var;
1353 #else
1354 #include <avr/pgmspace.h> /* From AVR-LibC */
1356 const int var PROGMEM = 1;
1358 int read_var (void)
1360     return (int) pgm_read_word (&var);
1362 #endif /* __FLASH */
1363 @end smallexample
1365 @noindent
1366 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1367 locates data in flash but
1368 accesses to these data read from generic address space, i.e.@:
1369 from RAM,
1370 so that you need special accessors like @code{pgm_read_byte}
1371 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1372 together with attribute @code{progmem}.
1374 @noindent
1375 @b{Limitations and caveats}
1377 @itemize
1378 @item
1379 Reading across the 64@tie{}KiB section boundary of
1380 the @code{__flash} or @code{__flash@var{N}} address spaces
1381 shows undefined behavior. The only address space that
1382 supports reading across the 64@tie{}KiB flash segment boundaries is
1383 @code{__memx}.
1385 @item
1386 If you use one of the @code{__flash@var{N}} address spaces
1387 you must arrange your linker script to locate the
1388 @code{.progmem@var{N}.data} sections according to your needs.
1390 @item
1391 Any data or pointers to the non-generic address spaces must
1392 be qualified as @code{const}, i.e.@: as read-only data.
1393 This still applies if the data in one of these address
1394 spaces like software version number or calibration lookup table are intended to
1395 be changed after load time by, say, a boot loader. In this case
1396 the right qualification is @code{const} @code{volatile} so that the compiler
1397 must not optimize away known values or insert them
1398 as immediates into operands of instructions.
1400 @item
1401 The following code initializes a variable @code{pfoo}
1402 located in static storage with a 24-bit address:
1403 @smallexample
1404 extern const __memx char foo;
1405 const __memx void *pfoo = &foo;
1406 @end smallexample
1408 @noindent
1409 Such code requires at least binutils 2.23, see
1410 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1412 @end itemize
1414 @subsection M32C Named Address Spaces
1415 @cindex @code{__far} M32C Named Address Spaces
1417 On the M32C target, with the R8C and M16C CPU variants, variables
1418 qualified with @code{__far} are accessed using 32-bit addresses in
1419 order to access memory beyond the first 64@tie{}Ki bytes.  If
1420 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1421 effect.
1423 @subsection RL78 Named Address Spaces
1424 @cindex @code{__far} RL78 Named Address Spaces
1426 On the RL78 target, variables qualified with @code{__far} are accessed
1427 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1428 addresses.  Non-far variables are assumed to appear in the topmost
1429 64@tie{}KiB of the address space.
1431 @subsection SPU Named Address Spaces
1432 @cindex @code{__ea} SPU Named Address Spaces
1434 On the SPU target variables may be declared as
1435 belonging to another address space by qualifying the type with the
1436 @code{__ea} address space identifier:
1438 @smallexample
1439 extern int __ea i;
1440 @end smallexample
1442 @noindent 
1443 The compiler generates special code to access the variable @code{i}.
1444 It may use runtime library
1445 support, or generate special machine instructions to access that address
1446 space.
1448 @node Zero Length
1449 @section Arrays of Length Zero
1450 @cindex arrays of length zero
1451 @cindex zero-length arrays
1452 @cindex length-zero arrays
1453 @cindex flexible array members
1455 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1456 last element of a structure that is really a header for a variable-length
1457 object:
1459 @smallexample
1460 struct line @{
1461   int length;
1462   char contents[0];
1465 struct line *thisline = (struct line *)
1466   malloc (sizeof (struct line) + this_length);
1467 thisline->length = this_length;
1468 @end smallexample
1470 In ISO C90, you would have to give @code{contents} a length of 1, which
1471 means either you waste space or complicate the argument to @code{malloc}.
1473 In ISO C99, you would use a @dfn{flexible array member}, which is
1474 slightly different in syntax and semantics:
1476 @itemize @bullet
1477 @item
1478 Flexible array members are written as @code{contents[]} without
1479 the @code{0}.
1481 @item
1482 Flexible array members have incomplete type, and so the @code{sizeof}
1483 operator may not be applied.  As a quirk of the original implementation
1484 of zero-length arrays, @code{sizeof} evaluates to zero.
1486 @item
1487 Flexible array members may only appear as the last member of a
1488 @code{struct} that is otherwise non-empty.
1490 @item
1491 A structure containing a flexible array member, or a union containing
1492 such a structure (possibly recursively), may not be a member of a
1493 structure or an element of an array.  (However, these uses are
1494 permitted by GCC as extensions.)
1495 @end itemize
1497 GCC versions before 3.0 allowed zero-length arrays to be statically
1498 initialized, as if they were flexible arrays.  In addition to those
1499 cases that were useful, it also allowed initializations in situations
1500 that would corrupt later data.  Non-empty initialization of zero-length
1501 arrays is now treated like any case where there are more initializer
1502 elements than the array holds, in that a suitable warning about ``excess
1503 elements in array'' is given, and the excess elements (all of them, in
1504 this case) are ignored.
1506 Instead GCC allows static initialization of flexible array members.
1507 This is equivalent to defining a new structure containing the original
1508 structure followed by an array of sufficient size to contain the data.
1509 E.g.@: in the following, @code{f1} is constructed as if it were declared
1510 like @code{f2}.
1512 @smallexample
1513 struct f1 @{
1514   int x; int y[];
1515 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1517 struct f2 @{
1518   struct f1 f1; int data[3];
1519 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1520 @end smallexample
1522 @noindent
1523 The convenience of this extension is that @code{f1} has the desired
1524 type, eliminating the need to consistently refer to @code{f2.f1}.
1526 This has symmetry with normal static arrays, in that an array of
1527 unknown size is also written with @code{[]}.
1529 Of course, this extension only makes sense if the extra data comes at
1530 the end of a top-level object, as otherwise we would be overwriting
1531 data at subsequent offsets.  To avoid undue complication and confusion
1532 with initialization of deeply nested arrays, we simply disallow any
1533 non-empty initialization except when the structure is the top-level
1534 object.  For example:
1536 @smallexample
1537 struct foo @{ int x; int y[]; @};
1538 struct bar @{ struct foo z; @};
1540 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1541 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1542 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1543 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1544 @end smallexample
1546 @node Empty Structures
1547 @section Structures With No Members
1548 @cindex empty structures
1549 @cindex zero-size structures
1551 GCC permits a C structure to have no members:
1553 @smallexample
1554 struct empty @{
1556 @end smallexample
1558 The structure has size zero.  In C++, empty structures are part
1559 of the language.  G++ treats empty structures as if they had a single
1560 member of type @code{char}.
1562 @node Variable Length
1563 @section Arrays of Variable Length
1564 @cindex variable-length arrays
1565 @cindex arrays of variable length
1566 @cindex VLAs
1568 Variable-length automatic arrays are allowed in ISO C99, and as an
1569 extension GCC accepts them in C90 mode and in C++.  These arrays are
1570 declared like any other automatic arrays, but with a length that is not
1571 a constant expression.  The storage is allocated at the point of
1572 declaration and deallocated when the block scope containing the declaration
1573 exits.  For
1574 example:
1576 @smallexample
1577 FILE *
1578 concat_fopen (char *s1, char *s2, char *mode)
1580   char str[strlen (s1) + strlen (s2) + 1];
1581   strcpy (str, s1);
1582   strcat (str, s2);
1583   return fopen (str, mode);
1585 @end smallexample
1587 @cindex scope of a variable length array
1588 @cindex variable-length array scope
1589 @cindex deallocating variable length arrays
1590 Jumping or breaking out of the scope of the array name deallocates the
1591 storage.  Jumping into the scope is not allowed; you get an error
1592 message for it.
1594 @cindex variable-length array in a structure
1595 As an extension, GCC accepts variable-length arrays as a member of
1596 a structure or a union.  For example:
1598 @smallexample
1599 void
1600 foo (int n)
1602   struct S @{ int x[n]; @};
1604 @end smallexample
1606 @cindex @code{alloca} vs variable-length arrays
1607 You can use the function @code{alloca} to get an effect much like
1608 variable-length arrays.  The function @code{alloca} is available in
1609 many other C implementations (but not in all).  On the other hand,
1610 variable-length arrays are more elegant.
1612 There are other differences between these two methods.  Space allocated
1613 with @code{alloca} exists until the containing @emph{function} returns.
1614 The space for a variable-length array is deallocated as soon as the array
1615 name's scope ends.  (If you use both variable-length arrays and
1616 @code{alloca} in the same function, deallocation of a variable-length array
1617 also deallocates anything more recently allocated with @code{alloca}.)
1619 You can also use variable-length arrays as arguments to functions:
1621 @smallexample
1622 struct entry
1623 tester (int len, char data[len][len])
1625   /* @r{@dots{}} */
1627 @end smallexample
1629 The length of an array is computed once when the storage is allocated
1630 and is remembered for the scope of the array in case you access it with
1631 @code{sizeof}.
1633 If you want to pass the array first and the length afterward, you can
1634 use a forward declaration in the parameter list---another GNU extension.
1636 @smallexample
1637 struct entry
1638 tester (int len; char data[len][len], int len)
1640   /* @r{@dots{}} */
1642 @end smallexample
1644 @cindex parameter forward declaration
1645 The @samp{int len} before the semicolon is a @dfn{parameter forward
1646 declaration}, and it serves the purpose of making the name @code{len}
1647 known when the declaration of @code{data} is parsed.
1649 You can write any number of such parameter forward declarations in the
1650 parameter list.  They can be separated by commas or semicolons, but the
1651 last one must end with a semicolon, which is followed by the ``real''
1652 parameter declarations.  Each forward declaration must match a ``real''
1653 declaration in parameter name and data type.  ISO C99 does not support
1654 parameter forward declarations.
1656 @node Variadic Macros
1657 @section Macros with a Variable Number of Arguments.
1658 @cindex variable number of arguments
1659 @cindex macro with variable arguments
1660 @cindex rest argument (in macro)
1661 @cindex variadic macros
1663 In the ISO C standard of 1999, a macro can be declared to accept a
1664 variable number of arguments much as a function can.  The syntax for
1665 defining the macro is similar to that of a function.  Here is an
1666 example:
1668 @smallexample
1669 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1670 @end smallexample
1672 @noindent
1673 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1674 such a macro, it represents the zero or more tokens until the closing
1675 parenthesis that ends the invocation, including any commas.  This set of
1676 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1677 wherever it appears.  See the CPP manual for more information.
1679 GCC has long supported variadic macros, and used a different syntax that
1680 allowed you to give a name to the variable arguments just like any other
1681 argument.  Here is an example:
1683 @smallexample
1684 #define debug(format, args...) fprintf (stderr, format, args)
1685 @end smallexample
1687 @noindent
1688 This is in all ways equivalent to the ISO C example above, but arguably
1689 more readable and descriptive.
1691 GNU CPP has two further variadic macro extensions, and permits them to
1692 be used with either of the above forms of macro definition.
1694 In standard C, you are not allowed to leave the variable argument out
1695 entirely; but you are allowed to pass an empty argument.  For example,
1696 this invocation is invalid in ISO C, because there is no comma after
1697 the string:
1699 @smallexample
1700 debug ("A message")
1701 @end smallexample
1703 GNU CPP permits you to completely omit the variable arguments in this
1704 way.  In the above examples, the compiler would complain, though since
1705 the expansion of the macro still has the extra comma after the format
1706 string.
1708 To help solve this problem, CPP behaves specially for variable arguments
1709 used with the token paste operator, @samp{##}.  If instead you write
1711 @smallexample
1712 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1713 @end smallexample
1715 @noindent
1716 and if the variable arguments are omitted or empty, the @samp{##}
1717 operator causes the preprocessor to remove the comma before it.  If you
1718 do provide some variable arguments in your macro invocation, GNU CPP
1719 does not complain about the paste operation and instead places the
1720 variable arguments after the comma.  Just like any other pasted macro
1721 argument, these arguments are not macro expanded.
1723 @node Escaped Newlines
1724 @section Slightly Looser Rules for Escaped Newlines
1725 @cindex escaped newlines
1726 @cindex newlines (escaped)
1728 Recently, the preprocessor has relaxed its treatment of escaped
1729 newlines.  Previously, the newline had to immediately follow a
1730 backslash.  The current implementation allows whitespace in the form
1731 of spaces, horizontal and vertical tabs, and form feeds between the
1732 backslash and the subsequent newline.  The preprocessor issues a
1733 warning, but treats it as a valid escaped newline and combines the two
1734 lines to form a single logical line.  This works within comments and
1735 tokens, as well as between tokens.  Comments are @emph{not} treated as
1736 whitespace for the purposes of this relaxation, since they have not
1737 yet been replaced with spaces.
1739 @node Subscripting
1740 @section Non-Lvalue Arrays May Have Subscripts
1741 @cindex subscripting
1742 @cindex arrays, non-lvalue
1744 @cindex subscripting and function values
1745 In ISO C99, arrays that are not lvalues still decay to pointers, and
1746 may be subscripted, although they may not be modified or used after
1747 the next sequence point and the unary @samp{&} operator may not be
1748 applied to them.  As an extension, GNU C allows such arrays to be
1749 subscripted in C90 mode, though otherwise they do not decay to
1750 pointers outside C99 mode.  For example,
1751 this is valid in GNU C though not valid in C90:
1753 @smallexample
1754 @group
1755 struct foo @{int a[4];@};
1757 struct foo f();
1759 bar (int index)
1761   return f().a[index];
1763 @end group
1764 @end smallexample
1766 @node Pointer Arith
1767 @section Arithmetic on @code{void}- and Function-Pointers
1768 @cindex void pointers, arithmetic
1769 @cindex void, size of pointer to
1770 @cindex function pointers, arithmetic
1771 @cindex function, size of pointer to
1773 In GNU C, addition and subtraction operations are supported on pointers to
1774 @code{void} and on pointers to functions.  This is done by treating the
1775 size of a @code{void} or of a function as 1.
1777 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1778 and on function types, and returns 1.
1780 @opindex Wpointer-arith
1781 The option @option{-Wpointer-arith} requests a warning if these extensions
1782 are used.
1784 @node Initializers
1785 @section Non-Constant Initializers
1786 @cindex initializers, non-constant
1787 @cindex non-constant initializers
1789 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1790 automatic variable are not required to be constant expressions in GNU C@.
1791 Here is an example of an initializer with run-time varying elements:
1793 @smallexample
1794 foo (float f, float g)
1796   float beat_freqs[2] = @{ f-g, f+g @};
1797   /* @r{@dots{}} */
1799 @end smallexample
1801 @node Compound Literals
1802 @section Compound Literals
1803 @cindex constructor expressions
1804 @cindex initializations in expressions
1805 @cindex structures, constructor expression
1806 @cindex expressions, constructor
1807 @cindex compound literals
1808 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1810 ISO C99 supports compound literals.  A compound literal looks like
1811 a cast containing an initializer.  Its value is an object of the
1812 type specified in the cast, containing the elements specified in
1813 the initializer; it is an lvalue.  As an extension, GCC supports
1814 compound literals in C90 mode and in C++, though the semantics are
1815 somewhat different in C++.
1817 Usually, the specified type is a structure.  Assume that
1818 @code{struct foo} and @code{structure} are declared as shown:
1820 @smallexample
1821 struct foo @{int a; char b[2];@} structure;
1822 @end smallexample
1824 @noindent
1825 Here is an example of constructing a @code{struct foo} with a compound literal:
1827 @smallexample
1828 structure = ((struct foo) @{x + y, 'a', 0@});
1829 @end smallexample
1831 @noindent
1832 This is equivalent to writing the following:
1834 @smallexample
1836   struct foo temp = @{x + y, 'a', 0@};
1837   structure = temp;
1839 @end smallexample
1841 You can also construct an array, though this is dangerous in C++, as
1842 explained below.  If all the elements of the compound literal are
1843 (made up of) simple constant expressions, suitable for use in
1844 initializers of objects of static storage duration, then the compound
1845 literal can be coerced to a pointer to its first element and used in
1846 such an initializer, as shown here:
1848 @smallexample
1849 char **foo = (char *[]) @{ "x", "y", "z" @};
1850 @end smallexample
1852 Compound literals for scalar types and union types are
1853 also allowed, but then the compound literal is equivalent
1854 to a cast.
1856 As a GNU extension, GCC allows initialization of objects with static storage
1857 duration by compound literals (which is not possible in ISO C99, because
1858 the initializer is not a constant).
1859 It is handled as if the object is initialized only with the bracket
1860 enclosed list if the types of the compound literal and the object match.
1861 The initializer list of the compound literal must be constant.
1862 If the object being initialized has array type of unknown size, the size is
1863 determined by compound literal size.
1865 @smallexample
1866 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1867 static int y[] = (int []) @{1, 2, 3@};
1868 static int z[] = (int [3]) @{1@};
1869 @end smallexample
1871 @noindent
1872 The above lines are equivalent to the following:
1873 @smallexample
1874 static struct foo x = @{1, 'a', 'b'@};
1875 static int y[] = @{1, 2, 3@};
1876 static int z[] = @{1, 0, 0@};
1877 @end smallexample
1879 In C, a compound literal designates an unnamed object with static or
1880 automatic storage duration.  In C++, a compound literal designates a
1881 temporary object, which only lives until the end of its
1882 full-expression.  As a result, well-defined C code that takes the
1883 address of a subobject of a compound literal can be undefined in C++.
1884 For instance, if the array compound literal example above appeared
1885 inside a function, any subsequent use of @samp{foo} in C++ has
1886 undefined behavior because the lifetime of the array ends after the
1887 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1888 the conversion of a temporary array to a pointer.
1890 As an optimization, the C++ compiler sometimes gives array compound
1891 literals longer lifetimes: when the array either appears outside a
1892 function or has const-qualified type.  If @samp{foo} and its
1893 initializer had elements of @samp{char *const} type rather than
1894 @samp{char *}, or if @samp{foo} were a global variable, the array
1895 would have static storage duration.  But it is probably safest just to
1896 avoid the use of array compound literals in code compiled as C++.
1898 @node Designated Inits
1899 @section Designated Initializers
1900 @cindex initializers with labeled elements
1901 @cindex labeled elements in initializers
1902 @cindex case labels in initializers
1903 @cindex designated initializers
1905 Standard C90 requires the elements of an initializer to appear in a fixed
1906 order, the same as the order of the elements in the array or structure
1907 being initialized.
1909 In ISO C99 you can give the elements in any order, specifying the array
1910 indices or structure field names they apply to, and GNU C allows this as
1911 an extension in C90 mode as well.  This extension is not
1912 implemented in GNU C++.
1914 To specify an array index, write
1915 @samp{[@var{index}] =} before the element value.  For example,
1917 @smallexample
1918 int a[6] = @{ [4] = 29, [2] = 15 @};
1919 @end smallexample
1921 @noindent
1922 is equivalent to
1924 @smallexample
1925 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1926 @end smallexample
1928 @noindent
1929 The index values must be constant expressions, even if the array being
1930 initialized is automatic.
1932 An alternative syntax for this that has been obsolete since GCC 2.5 but
1933 GCC still accepts is to write @samp{[@var{index}]} before the element
1934 value, with no @samp{=}.
1936 To initialize a range of elements to the same value, write
1937 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1938 extension.  For example,
1940 @smallexample
1941 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1942 @end smallexample
1944 @noindent
1945 If the value in it has side-effects, the side-effects happen only once,
1946 not for each initialized field by the range initializer.
1948 @noindent
1949 Note that the length of the array is the highest value specified
1950 plus one.
1952 In a structure initializer, specify the name of a field to initialize
1953 with @samp{.@var{fieldname} =} before the element value.  For example,
1954 given the following structure,
1956 @smallexample
1957 struct point @{ int x, y; @};
1958 @end smallexample
1960 @noindent
1961 the following initialization
1963 @smallexample
1964 struct point p = @{ .y = yvalue, .x = xvalue @};
1965 @end smallexample
1967 @noindent
1968 is equivalent to
1970 @smallexample
1971 struct point p = @{ xvalue, yvalue @};
1972 @end smallexample
1974 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1975 @samp{@var{fieldname}:}, as shown here:
1977 @smallexample
1978 struct point p = @{ y: yvalue, x: xvalue @};
1979 @end smallexample
1981 Omitted field members are implicitly initialized the same as objects
1982 that have static storage duration.
1984 @cindex designators
1985 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1986 @dfn{designator}.  You can also use a designator (or the obsolete colon
1987 syntax) when initializing a union, to specify which element of the union
1988 should be used.  For example,
1990 @smallexample
1991 union foo @{ int i; double d; @};
1993 union foo f = @{ .d = 4 @};
1994 @end smallexample
1996 @noindent
1997 converts 4 to a @code{double} to store it in the union using
1998 the second element.  By contrast, casting 4 to type @code{union foo}
1999 stores it into the union as the integer @code{i}, since it is
2000 an integer.  (@xref{Cast to Union}.)
2002 You can combine this technique of naming elements with ordinary C
2003 initialization of successive elements.  Each initializer element that
2004 does not have a designator applies to the next consecutive element of the
2005 array or structure.  For example,
2007 @smallexample
2008 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2009 @end smallexample
2011 @noindent
2012 is equivalent to
2014 @smallexample
2015 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2016 @end smallexample
2018 Labeling the elements of an array initializer is especially useful
2019 when the indices are characters or belong to an @code{enum} type.
2020 For example:
2022 @smallexample
2023 int whitespace[256]
2024   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2025       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2026 @end smallexample
2028 @cindex designator lists
2029 You can also write a series of @samp{.@var{fieldname}} and
2030 @samp{[@var{index}]} designators before an @samp{=} to specify a
2031 nested subobject to initialize; the list is taken relative to the
2032 subobject corresponding to the closest surrounding brace pair.  For
2033 example, with the @samp{struct point} declaration above:
2035 @smallexample
2036 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2037 @end smallexample
2039 @noindent
2040 If the same field is initialized multiple times, it has the value from
2041 the last initialization.  If any such overridden initialization has
2042 side-effect, it is unspecified whether the side-effect happens or not.
2043 Currently, GCC discards them and issues a warning.
2045 @node Case Ranges
2046 @section Case Ranges
2047 @cindex case ranges
2048 @cindex ranges in case statements
2050 You can specify a range of consecutive values in a single @code{case} label,
2051 like this:
2053 @smallexample
2054 case @var{low} ... @var{high}:
2055 @end smallexample
2057 @noindent
2058 This has the same effect as the proper number of individual @code{case}
2059 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2061 This feature is especially useful for ranges of ASCII character codes:
2063 @smallexample
2064 case 'A' ... 'Z':
2065 @end smallexample
2067 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2068 it may be parsed wrong when you use it with integer values.  For example,
2069 write this:
2071 @smallexample
2072 case 1 ... 5:
2073 @end smallexample
2075 @noindent
2076 rather than this:
2078 @smallexample
2079 case 1...5:
2080 @end smallexample
2082 @node Cast to Union
2083 @section Cast to a Union Type
2084 @cindex cast to a union
2085 @cindex union, casting to a
2087 A cast to union type is similar to other casts, except that the type
2088 specified is a union type.  You can specify the type either with
2089 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2090 a constructor, not a cast, and hence does not yield an lvalue like
2091 normal casts.  (@xref{Compound Literals}.)
2093 The types that may be cast to the union type are those of the members
2094 of the union.  Thus, given the following union and variables:
2096 @smallexample
2097 union foo @{ int i; double d; @};
2098 int x;
2099 double y;
2100 @end smallexample
2102 @noindent
2103 both @code{x} and @code{y} can be cast to type @code{union foo}.
2105 Using the cast as the right-hand side of an assignment to a variable of
2106 union type is equivalent to storing in a member of the union:
2108 @smallexample
2109 union foo u;
2110 /* @r{@dots{}} */
2111 u = (union foo) x  @equiv{}  u.i = x
2112 u = (union foo) y  @equiv{}  u.d = y
2113 @end smallexample
2115 You can also use the union cast as a function argument:
2117 @smallexample
2118 void hack (union foo);
2119 /* @r{@dots{}} */
2120 hack ((union foo) x);
2121 @end smallexample
2123 @node Mixed Declarations
2124 @section Mixed Declarations and Code
2125 @cindex mixed declarations and code
2126 @cindex declarations, mixed with code
2127 @cindex code, mixed with declarations
2129 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2130 within compound statements.  As an extension, GNU C also allows this in
2131 C90 mode.  For example, you could do:
2133 @smallexample
2134 int i;
2135 /* @r{@dots{}} */
2136 i++;
2137 int j = i + 2;
2138 @end smallexample
2140 Each identifier is visible from where it is declared until the end of
2141 the enclosing block.
2143 @node Function Attributes
2144 @section Declaring Attributes of Functions
2145 @cindex function attributes
2146 @cindex declaring attributes of functions
2147 @cindex functions that never return
2148 @cindex functions that return more than once
2149 @cindex functions that have no side effects
2150 @cindex functions in arbitrary sections
2151 @cindex functions that behave like malloc
2152 @cindex @code{volatile} applied to function
2153 @cindex @code{const} applied to function
2154 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2155 @cindex functions with non-null pointer arguments
2156 @cindex functions that are passed arguments in registers on the 386
2157 @cindex functions that pop the argument stack on the 386
2158 @cindex functions that do not pop the argument stack on the 386
2159 @cindex functions that have different compilation options on the 386
2160 @cindex functions that have different optimization options
2161 @cindex functions that are dynamically resolved
2163 In GNU C, you declare certain things about functions called in your program
2164 which help the compiler optimize function calls and check your code more
2165 carefully.
2167 The keyword @code{__attribute__} allows you to specify special
2168 attributes when making a declaration.  This keyword is followed by an
2169 attribute specification inside double parentheses.  The following
2170 attributes are currently defined for functions on all targets:
2171 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2172 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2173 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2174 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2175 @code{no_instrument_function}, @code{no_split_stack},
2176 @code{section}, @code{constructor},
2177 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2178 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2179 @code{warn_unused_result}, @code{nonnull},
2180 @code{returns_nonnull}, @code{gnu_inline},
2181 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2182 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2183 @code{no_sanitize_undefined},
2184 @code{error} and @code{warning}.
2185 Several other attributes are defined for functions on particular
2186 target systems.  Other attributes, including @code{section} are
2187 supported for variables declarations (@pxref{Variable Attributes}),
2188 labels (@pxref{Label Attributes})
2189 and for types (@pxref{Type Attributes}).
2191 GCC plugins may provide their own attributes.
2193 You may also specify attributes with @samp{__} preceding and following
2194 each keyword.  This allows you to use them in header files without
2195 being concerned about a possible macro of the same name.  For example,
2196 you may use @code{__noreturn__} instead of @code{noreturn}.
2198 @xref{Attribute Syntax}, for details of the exact syntax for using
2199 attributes.
2201 @table @code
2202 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2204 @item alias ("@var{target}")
2205 @cindex @code{alias} attribute
2206 The @code{alias} attribute causes the declaration to be emitted as an
2207 alias for another symbol, which must be specified.  For instance,
2209 @smallexample
2210 void __f () @{ /* @r{Do something.} */; @}
2211 void f () __attribute__ ((weak, alias ("__f")));
2212 @end smallexample
2214 @noindent
2215 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2216 mangled name for the target must be used.  It is an error if @samp{__f}
2217 is not defined in the same translation unit.
2219 Not all target machines support this attribute.
2221 @item aligned (@var{alignment})
2222 @cindex @code{aligned} attribute
2223 This attribute specifies a minimum alignment for the function,
2224 measured in bytes.
2226 You cannot use this attribute to decrease the alignment of a function,
2227 only to increase it.  However, when you explicitly specify a function
2228 alignment this overrides the effect of the
2229 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2230 function.
2232 Note that the effectiveness of @code{aligned} attributes may be
2233 limited by inherent limitations in your linker.  On many systems, the
2234 linker is only able to arrange for functions to be aligned up to a
2235 certain maximum alignment.  (For some linkers, the maximum supported
2236 alignment may be very very small.)  See your linker documentation for
2237 further information.
2239 The @code{aligned} attribute can also be used for variables and fields
2240 (@pxref{Variable Attributes}.)
2242 @item alloc_size
2243 @cindex @code{alloc_size} attribute
2244 The @code{alloc_size} attribute is used to tell the compiler that the
2245 function return value points to memory, where the size is given by
2246 one or two of the functions parameters.  GCC uses this
2247 information to improve the correctness of @code{__builtin_object_size}.
2249 The function parameter(s) denoting the allocated size are specified by
2250 one or two integer arguments supplied to the attribute.  The allocated size
2251 is either the value of the single function argument specified or the product
2252 of the two function arguments specified.  Argument numbering starts at
2253 one.
2255 For instance,
2257 @smallexample
2258 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2259 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2260 @end smallexample
2262 @noindent
2263 declares that @code{my_calloc} returns memory of the size given by
2264 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2265 of the size given by parameter 2.
2267 @item alloc_align
2268 @cindex @code{alloc_align} attribute
2269 The @code{alloc_align} attribute is used to tell the compiler that the
2270 function return value points to memory, where the returned pointer minimum
2271 alignment is given by one of the functions parameters.  GCC uses this
2272 information to improve pointer alignment analysis.
2274 The function parameter denoting the allocated alignment is specified by
2275 one integer argument, whose number is the argument of the attribute.
2276 Argument numbering starts at one.
2278 For instance,
2280 @smallexample
2281 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2282 @end smallexample
2284 @noindent
2285 declares that @code{my_memalign} returns memory with minimum alignment
2286 given by parameter 1.
2288 @item assume_aligned
2289 @cindex @code{assume_aligned} attribute
2290 The @code{assume_aligned} attribute is used to tell the compiler that the
2291 function return value points to memory, where the returned pointer minimum
2292 alignment is given by the first argument.
2293 If the attribute has two arguments, the second argument is misalignment offset.
2295 For instance
2297 @smallexample
2298 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2299 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2300 @end smallexample
2302 @noindent
2303 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2304 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2305 to 8.
2307 @item always_inline
2308 @cindex @code{always_inline} function attribute
2309 Generally, functions are not inlined unless optimization is specified.
2310 For functions declared inline, this attribute inlines the function
2311 independent of any restrictions that otherwise apply to inlining.
2312 Failure to inline such a function is diagnosed as an error.
2313 Note that if such a function is called indirectly the compiler may
2314 or may not inline it depending on optimization level and a failure
2315 to inline an indirect call may or may not be diagnosed.
2317 @item gnu_inline
2318 @cindex @code{gnu_inline} function attribute
2319 This attribute should be used with a function that is also declared
2320 with the @code{inline} keyword.  It directs GCC to treat the function
2321 as if it were defined in gnu90 mode even when compiling in C99 or
2322 gnu99 mode.
2324 If the function is declared @code{extern}, then this definition of the
2325 function is used only for inlining.  In no case is the function
2326 compiled as a standalone function, not even if you take its address
2327 explicitly.  Such an address becomes an external reference, as if you
2328 had only declared the function, and had not defined it.  This has
2329 almost the effect of a macro.  The way to use this is to put a
2330 function definition in a header file with this attribute, and put
2331 another copy of the function, without @code{extern}, in a library
2332 file.  The definition in the header file causes most calls to the
2333 function to be inlined.  If any uses of the function remain, they
2334 refer to the single copy in the library.  Note that the two
2335 definitions of the functions need not be precisely the same, although
2336 if they do not have the same effect your program may behave oddly.
2338 In C, if the function is neither @code{extern} nor @code{static}, then
2339 the function is compiled as a standalone function, as well as being
2340 inlined where possible.
2342 This is how GCC traditionally handled functions declared
2343 @code{inline}.  Since ISO C99 specifies a different semantics for
2344 @code{inline}, this function attribute is provided as a transition
2345 measure and as a useful feature in its own right.  This attribute is
2346 available in GCC 4.1.3 and later.  It is available if either of the
2347 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2348 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2349 Function is As Fast As a Macro}.
2351 In C++, this attribute does not depend on @code{extern} in any way,
2352 but it still requires the @code{inline} keyword to enable its special
2353 behavior.
2355 @item artificial
2356 @cindex @code{artificial} function attribute
2357 This attribute is useful for small inline wrappers that if possible
2358 should appear during debugging as a unit.  Depending on the debug
2359 info format it either means marking the function as artificial
2360 or using the caller location for all instructions within the inlined
2361 body.
2363 @item bank_switch
2364 @cindex interrupt handler functions
2365 When added to an interrupt handler with the M32C port, causes the
2366 prologue and epilogue to use bank switching to preserve the registers
2367 rather than saving them on the stack.
2369 @item flatten
2370 @cindex @code{flatten} function attribute
2371 Generally, inlining into a function is limited.  For a function marked with
2372 this attribute, every call inside this function is inlined, if possible.
2373 Whether the function itself is considered for inlining depends on its size and
2374 the current inlining parameters.
2376 @item error ("@var{message}")
2377 @cindex @code{error} function attribute
2378 If this attribute is used on a function declaration and a call to such a function
2379 is not eliminated through dead code elimination or other optimizations, an error
2380 that includes @var{message} is diagnosed.  This is useful
2381 for compile-time checking, especially together with @code{__builtin_constant_p}
2382 and inline functions where checking the inline function arguments is not
2383 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2384 While it is possible to leave the function undefined and thus invoke
2385 a link failure, when using this attribute the problem is diagnosed
2386 earlier and with exact location of the call even in presence of inline
2387 functions or when not emitting debugging information.
2389 @item warning ("@var{message}")
2390 @cindex @code{warning} function attribute
2391 If this attribute is used on a function declaration and a call to such a function
2392 is not eliminated through dead code elimination or other optimizations, a warning
2393 that includes @var{message} is diagnosed.  This is useful
2394 for compile-time checking, especially together with @code{__builtin_constant_p}
2395 and inline functions.  While it is possible to define the function with
2396 a message in @code{.gnu.warning*} section, when using this attribute the problem
2397 is diagnosed earlier and with exact location of the call even in presence
2398 of inline functions or when not emitting debugging information.
2400 @item cdecl
2401 @cindex functions that do pop the argument stack on the 386
2402 @opindex mrtd
2403 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2404 assume that the calling function pops off the stack space used to
2405 pass arguments.  This is
2406 useful to override the effects of the @option{-mrtd} switch.
2408 @item const
2409 @cindex @code{const} function attribute
2410 Many functions do not examine any values except their arguments, and
2411 have no effects except the return value.  Basically this is just slightly
2412 more strict class than the @code{pure} attribute below, since function is not
2413 allowed to read global memory.
2415 @cindex pointer arguments
2416 Note that a function that has pointer arguments and examines the data
2417 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2418 function that calls a non-@code{const} function usually must not be
2419 @code{const}.  It does not make sense for a @code{const} function to
2420 return @code{void}.
2422 The attribute @code{const} is not implemented in GCC versions earlier
2423 than 2.5.  An alternative way to declare that a function has no side
2424 effects, which works in the current version and in some older versions,
2425 is as follows:
2427 @smallexample
2428 typedef int intfn ();
2430 extern const intfn square;
2431 @end smallexample
2433 @noindent
2434 This approach does not work in GNU C++ from 2.6.0 on, since the language
2435 specifies that the @samp{const} must be attached to the return value.
2437 @item constructor
2438 @itemx destructor
2439 @itemx constructor (@var{priority})
2440 @itemx destructor (@var{priority})
2441 @cindex @code{constructor} function attribute
2442 @cindex @code{destructor} function attribute
2443 The @code{constructor} attribute causes the function to be called
2444 automatically before execution enters @code{main ()}.  Similarly, the
2445 @code{destructor} attribute causes the function to be called
2446 automatically after @code{main ()} completes or @code{exit ()} is
2447 called.  Functions with these attributes are useful for
2448 initializing data that is used implicitly during the execution of
2449 the program.
2451 You may provide an optional integer priority to control the order in
2452 which constructor and destructor functions are run.  A constructor
2453 with a smaller priority number runs before a constructor with a larger
2454 priority number; the opposite relationship holds for destructors.  So,
2455 if you have a constructor that allocates a resource and a destructor
2456 that deallocates the same resource, both functions typically have the
2457 same priority.  The priorities for constructor and destructor
2458 functions are the same as those specified for namespace-scope C++
2459 objects (@pxref{C++ Attributes}).
2461 These attributes are not currently implemented for Objective-C@.
2463 @item deprecated
2464 @itemx deprecated (@var{msg})
2465 @cindex @code{deprecated} attribute.
2466 The @code{deprecated} attribute results in a warning if the function
2467 is used anywhere in the source file.  This is useful when identifying
2468 functions that are expected to be removed in a future version of a
2469 program.  The warning also includes the location of the declaration
2470 of the deprecated function, to enable users to easily find further
2471 information about why the function is deprecated, or what they should
2472 do instead.  Note that the warnings only occurs for uses:
2474 @smallexample
2475 int old_fn () __attribute__ ((deprecated));
2476 int old_fn ();
2477 int (*fn_ptr)() = old_fn;
2478 @end smallexample
2480 @noindent
2481 results in a warning on line 3 but not line 2.  The optional @var{msg}
2482 argument, which must be a string, is printed in the warning if
2483 present.
2485 The @code{deprecated} attribute can also be used for variables and
2486 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2488 @item disinterrupt
2489 @cindex @code{disinterrupt} attribute
2490 On Epiphany and MeP targets, this attribute causes the compiler to emit
2491 instructions to disable interrupts for the duration of the given
2492 function.
2494 @item dllexport
2495 @cindex @code{__declspec(dllexport)}
2496 On Microsoft Windows targets and Symbian OS targets the
2497 @code{dllexport} attribute causes the compiler to provide a global
2498 pointer to a pointer in a DLL, so that it can be referenced with the
2499 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2500 name is formed by combining @code{_imp__} and the function or variable
2501 name.
2503 You can use @code{__declspec(dllexport)} as a synonym for
2504 @code{__attribute__ ((dllexport))} for compatibility with other
2505 compilers.
2507 On systems that support the @code{visibility} attribute, this
2508 attribute also implies ``default'' visibility.  It is an error to
2509 explicitly specify any other visibility.
2511 In previous versions of GCC, the @code{dllexport} attribute was ignored
2512 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2513 had been used.  The default behavior now is to emit all dllexported
2514 inline functions; however, this can cause object file-size bloat, in
2515 which case the old behavior can be restored by using
2516 @option{-fno-keep-inline-dllexport}.
2518 The attribute is also ignored for undefined symbols.
2520 When applied to C++ classes, the attribute marks defined non-inlined
2521 member functions and static data members as exports.  Static consts
2522 initialized in-class are not marked unless they are also defined
2523 out-of-class.
2525 For Microsoft Windows targets there are alternative methods for
2526 including the symbol in the DLL's export table such as using a
2527 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2528 the @option{--export-all} linker flag.
2530 @item dllimport
2531 @cindex @code{__declspec(dllimport)}
2532 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2533 attribute causes the compiler to reference a function or variable via
2534 a global pointer to a pointer that is set up by the DLL exporting the
2535 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2536 targets, the pointer name is formed by combining @code{_imp__} and the
2537 function or variable name.
2539 You can use @code{__declspec(dllimport)} as a synonym for
2540 @code{__attribute__ ((dllimport))} for compatibility with other
2541 compilers.
2543 On systems that support the @code{visibility} attribute, this
2544 attribute also implies ``default'' visibility.  It is an error to
2545 explicitly specify any other visibility.
2547 Currently, the attribute is ignored for inlined functions.  If the
2548 attribute is applied to a symbol @emph{definition}, an error is reported.
2549 If a symbol previously declared @code{dllimport} is later defined, the
2550 attribute is ignored in subsequent references, and a warning is emitted.
2551 The attribute is also overridden by a subsequent declaration as
2552 @code{dllexport}.
2554 When applied to C++ classes, the attribute marks non-inlined
2555 member functions and static data members as imports.  However, the
2556 attribute is ignored for virtual methods to allow creation of vtables
2557 using thunks.
2559 On the SH Symbian OS target the @code{dllimport} attribute also has
2560 another affect---it can cause the vtable and run-time type information
2561 for a class to be exported.  This happens when the class has a
2562 dllimported constructor or a non-inline, non-pure virtual function
2563 and, for either of those two conditions, the class also has an inline
2564 constructor or destructor and has a key function that is defined in
2565 the current translation unit.
2567 For Microsoft Windows targets the use of the @code{dllimport}
2568 attribute on functions is not necessary, but provides a small
2569 performance benefit by eliminating a thunk in the DLL@.  The use of the
2570 @code{dllimport} attribute on imported variables was required on older
2571 versions of the GNU linker, but can now be avoided by passing the
2572 @option{--enable-auto-import} switch to the GNU linker.  As with
2573 functions, using the attribute for a variable eliminates a thunk in
2574 the DLL@.
2576 One drawback to using this attribute is that a pointer to a
2577 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2578 address. However, a pointer to a @emph{function} with the
2579 @code{dllimport} attribute can be used as a constant initializer; in
2580 this case, the address of a stub function in the import lib is
2581 referenced.  On Microsoft Windows targets, the attribute can be disabled
2582 for functions by setting the @option{-mnop-fun-dllimport} flag.
2584 @item eightbit_data
2585 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2586 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2587 variable should be placed into the eight-bit data section.
2588 The compiler generates more efficient code for certain operations
2589 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2590 256 bytes of data.
2592 You must use GAS and GLD from GNU binutils version 2.7 or later for
2593 this attribute to work correctly.
2595 @item exception
2596 @cindex exception handler functions
2597 Use this attribute on the NDS32 target to indicate that the specified function
2598 is an exception handler.  The compiler will generate corresponding sections
2599 for use in an exception handler.
2601 @item exception_handler
2602 @cindex exception handler functions on the Blackfin processor
2603 Use this attribute on the Blackfin to indicate that the specified function
2604 is an exception handler.  The compiler generates function entry and
2605 exit sequences suitable for use in an exception handler when this
2606 attribute is present.
2608 @item externally_visible
2609 @cindex @code{externally_visible} attribute.
2610 This attribute, attached to a global variable or function, nullifies
2611 the effect of the @option{-fwhole-program} command-line option, so the
2612 object remains visible outside the current compilation unit.
2614 If @option{-fwhole-program} is used together with @option{-flto} and 
2615 @command{gold} is used as the linker plugin, 
2616 @code{externally_visible} attributes are automatically added to functions 
2617 (not variable yet due to a current @command{gold} issue) 
2618 that are accessed outside of LTO objects according to resolution file
2619 produced by @command{gold}.
2620 For other linkers that cannot generate resolution file,
2621 explicit @code{externally_visible} attributes are still necessary.
2623 @item far
2624 @cindex functions that handle memory bank switching
2625 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2626 use a calling convention that takes care of switching memory banks when
2627 entering and leaving a function.  This calling convention is also the
2628 default when using the @option{-mlong-calls} option.
2630 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2631 to call and return from a function.
2633 On 68HC11 the compiler generates a sequence of instructions
2634 to invoke a board-specific routine to switch the memory bank and call the
2635 real function.  The board-specific routine simulates a @code{call}.
2636 At the end of a function, it jumps to a board-specific routine
2637 instead of using @code{rts}.  The board-specific return routine simulates
2638 the @code{rtc}.
2640 On MeP targets this causes the compiler to use a calling convention
2641 that assumes the called function is too far away for the built-in
2642 addressing modes.
2644 @item fast_interrupt
2645 @cindex interrupt handler functions
2646 Use this attribute on the M32C and RX ports to indicate that the specified
2647 function is a fast interrupt handler.  This is just like the
2648 @code{interrupt} attribute, except that @code{freit} is used to return
2649 instead of @code{reit}.
2651 @item fastcall
2652 @cindex functions that pop the argument stack on the 386
2653 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2654 pass the first argument (if of integral type) in the register ECX and
2655 the second argument (if of integral type) in the register EDX@.  Subsequent
2656 and other typed arguments are passed on the stack.  The called function
2657 pops the arguments off the stack.  If the number of arguments is variable all
2658 arguments are pushed on the stack.
2660 @item thiscall
2661 @cindex functions that pop the argument stack on the 386
2662 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2663 pass the first argument (if of integral type) in the register ECX.
2664 Subsequent and other typed arguments are passed on the stack. The called
2665 function pops the arguments off the stack.
2666 If the number of arguments is variable all arguments are pushed on the
2667 stack.
2668 The @code{thiscall} attribute is intended for C++ non-static member functions.
2669 As a GCC extension, this calling convention can be used for C functions
2670 and for static member methods.
2672 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2673 @cindex @code{format} function attribute
2674 @opindex Wformat
2675 The @code{format} attribute specifies that a function takes @code{printf},
2676 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2677 should be type-checked against a format string.  For example, the
2678 declaration:
2680 @smallexample
2681 extern int
2682 my_printf (void *my_object, const char *my_format, ...)
2683       __attribute__ ((format (printf, 2, 3)));
2684 @end smallexample
2686 @noindent
2687 causes the compiler to check the arguments in calls to @code{my_printf}
2688 for consistency with the @code{printf} style format string argument
2689 @code{my_format}.
2691 The parameter @var{archetype} determines how the format string is
2692 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2693 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2694 @code{strfmon}.  (You can also use @code{__printf__},
2695 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2696 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2697 @code{ms_strftime} are also present.
2698 @var{archetype} values such as @code{printf} refer to the formats accepted
2699 by the system's C runtime library,
2700 while values prefixed with @samp{gnu_} always refer
2701 to the formats accepted by the GNU C Library.  On Microsoft Windows
2702 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2703 @file{msvcrt.dll} library.
2704 The parameter @var{string-index}
2705 specifies which argument is the format string argument (starting
2706 from 1), while @var{first-to-check} is the number of the first
2707 argument to check against the format string.  For functions
2708 where the arguments are not available to be checked (such as
2709 @code{vprintf}), specify the third parameter as zero.  In this case the
2710 compiler only checks the format string for consistency.  For
2711 @code{strftime} formats, the third parameter is required to be zero.
2712 Since non-static C++ methods have an implicit @code{this} argument, the
2713 arguments of such methods should be counted from two, not one, when
2714 giving values for @var{string-index} and @var{first-to-check}.
2716 In the example above, the format string (@code{my_format}) is the second
2717 argument of the function @code{my_print}, and the arguments to check
2718 start with the third argument, so the correct parameters for the format
2719 attribute are 2 and 3.
2721 @opindex ffreestanding
2722 @opindex fno-builtin
2723 The @code{format} attribute allows you to identify your own functions
2724 that take format strings as arguments, so that GCC can check the
2725 calls to these functions for errors.  The compiler always (unless
2726 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2727 for the standard library functions @code{printf}, @code{fprintf},
2728 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2729 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2730 warnings are requested (using @option{-Wformat}), so there is no need to
2731 modify the header file @file{stdio.h}.  In C99 mode, the functions
2732 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2733 @code{vsscanf} are also checked.  Except in strictly conforming C
2734 standard modes, the X/Open function @code{strfmon} is also checked as
2735 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2736 @xref{C Dialect Options,,Options Controlling C Dialect}.
2738 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2739 recognized in the same context.  Declarations including these format attributes
2740 are parsed for correct syntax, however the result of checking of such format
2741 strings is not yet defined, and is not carried out by this version of the
2742 compiler.
2744 The target may also provide additional types of format checks.
2745 @xref{Target Format Checks,,Format Checks Specific to Particular
2746 Target Machines}.
2748 @item format_arg (@var{string-index})
2749 @cindex @code{format_arg} function attribute
2750 @opindex Wformat-nonliteral
2751 The @code{format_arg} attribute specifies that a function takes a format
2752 string for a @code{printf}, @code{scanf}, @code{strftime} or
2753 @code{strfmon} style function and modifies it (for example, to translate
2754 it into another language), so the result can be passed to a
2755 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2756 function (with the remaining arguments to the format function the same
2757 as they would have been for the unmodified string).  For example, the
2758 declaration:
2760 @smallexample
2761 extern char *
2762 my_dgettext (char *my_domain, const char *my_format)
2763       __attribute__ ((format_arg (2)));
2764 @end smallexample
2766 @noindent
2767 causes the compiler to check the arguments in calls to a @code{printf},
2768 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2769 format string argument is a call to the @code{my_dgettext} function, for
2770 consistency with the format string argument @code{my_format}.  If the
2771 @code{format_arg} attribute had not been specified, all the compiler
2772 could tell in such calls to format functions would be that the format
2773 string argument is not constant; this would generate a warning when
2774 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2775 without the attribute.
2777 The parameter @var{string-index} specifies which argument is the format
2778 string argument (starting from one).  Since non-static C++ methods have
2779 an implicit @code{this} argument, the arguments of such methods should
2780 be counted from two.
2782 The @code{format_arg} attribute allows you to identify your own
2783 functions that modify format strings, so that GCC can check the
2784 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2785 type function whose operands are a call to one of your own function.
2786 The compiler always treats @code{gettext}, @code{dgettext}, and
2787 @code{dcgettext} in this manner except when strict ISO C support is
2788 requested by @option{-ansi} or an appropriate @option{-std} option, or
2789 @option{-ffreestanding} or @option{-fno-builtin}
2790 is used.  @xref{C Dialect Options,,Options
2791 Controlling C Dialect}.
2793 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2794 @code{NSString} reference for compatibility with the @code{format} attribute
2795 above.
2797 The target may also allow additional types in @code{format-arg} attributes.
2798 @xref{Target Format Checks,,Format Checks Specific to Particular
2799 Target Machines}.
2801 @item function_vector
2802 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2803 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2804 function should be called through the function vector.  Calling a
2805 function through the function vector reduces code size, however;
2806 the function vector has a limited size (maximum 128 entries on the H8/300
2807 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2809 On SH2A targets, this attribute declares a function to be called using the
2810 TBR relative addressing mode.  The argument to this attribute is the entry
2811 number of the same function in a vector table containing all the TBR
2812 relative addressable functions.  For correct operation the TBR must be setup
2813 accordingly to point to the start of the vector table before any functions with
2814 this attribute are invoked.  Usually a good place to do the initialization is
2815 the startup routine.  The TBR relative vector table can have at max 256 function
2816 entries.  The jumps to these functions are generated using a SH2A specific,
2817 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2818 from GNU binutils version 2.7 or later for this attribute to work correctly.
2820 Please refer the example of M16C target, to see the use of this
2821 attribute while declaring a function,
2823 In an application, for a function being called once, this attribute
2824 saves at least 8 bytes of code; and if other successive calls are being
2825 made to the same function, it saves 2 bytes of code per each of these
2826 calls.
2828 On M16C/M32C targets, the @code{function_vector} attribute declares a
2829 special page subroutine call function. Use of this attribute reduces
2830 the code size by 2 bytes for each call generated to the
2831 subroutine. The argument to the attribute is the vector number entry
2832 from the special page vector table which contains the 16 low-order
2833 bits of the subroutine's entry address. Each vector table has special
2834 page number (18 to 255) that is used in @code{jsrs} instructions.
2835 Jump addresses of the routines are generated by adding 0x0F0000 (in
2836 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2837 2-byte addresses set in the vector table. Therefore you need to ensure
2838 that all the special page vector routines should get mapped within the
2839 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2840 (for M32C).
2842 In the following example 2 bytes are saved for each call to
2843 function @code{foo}.
2845 @smallexample
2846 void foo (void) __attribute__((function_vector(0x18)));
2847 void foo (void)
2851 void bar (void)
2853     foo();
2855 @end smallexample
2857 If functions are defined in one file and are called in another file,
2858 then be sure to write this declaration in both files.
2860 This attribute is ignored for R8C target.
2862 @item ifunc ("@var{resolver}")
2863 @cindex @code{ifunc} attribute
2864 The @code{ifunc} attribute is used to mark a function as an indirect
2865 function using the STT_GNU_IFUNC symbol type extension to the ELF
2866 standard.  This allows the resolution of the symbol value to be
2867 determined dynamically at load time, and an optimized version of the
2868 routine can be selected for the particular processor or other system
2869 characteristics determined then.  To use this attribute, first define
2870 the implementation functions available, and a resolver function that
2871 returns a pointer to the selected implementation function.  The
2872 implementation functions' declarations must match the API of the
2873 function being implemented, the resolver's declaration is be a
2874 function returning pointer to void function returning void:
2876 @smallexample
2877 void *my_memcpy (void *dst, const void *src, size_t len)
2879   @dots{}
2882 static void (*resolve_memcpy (void)) (void)
2884   return my_memcpy; // we'll just always select this routine
2886 @end smallexample
2888 @noindent
2889 The exported header file declaring the function the user calls would
2890 contain:
2892 @smallexample
2893 extern void *memcpy (void *, const void *, size_t);
2894 @end smallexample
2896 @noindent
2897 allowing the user to call this as a regular function, unaware of the
2898 implementation.  Finally, the indirect function needs to be defined in
2899 the same translation unit as the resolver function:
2901 @smallexample
2902 void *memcpy (void *, const void *, size_t)
2903      __attribute__ ((ifunc ("resolve_memcpy")));
2904 @end smallexample
2906 Indirect functions cannot be weak, and require a recent binutils (at
2907 least version 2.20.1), and GNU C library (at least version 2.11.1).
2909 @item interrupt
2910 @cindex interrupt handler functions
2911 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2912 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2913 the specified function is an
2914 interrupt handler.  The compiler generates function entry and exit
2915 sequences suitable for use in an interrupt handler when this attribute
2916 is present.  With Epiphany targets it may also generate a special section with
2917 code to initialize the interrupt vector table.
2919 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2920 and SH processors can be specified via the @code{interrupt_handler} attribute.
2922 Note, on the ARC, you must specify the kind of interrupt to be handled
2923 in a parameter to the interrupt attribute like this:
2925 @smallexample
2926 void f () __attribute__ ((interrupt ("ilink1")));
2927 @end smallexample
2929 Permissible values for this parameter are: @w{@code{ilink1}} and
2930 @w{@code{ilink2}}.
2932 Note, on the AVR, the hardware globally disables interrupts when an
2933 interrupt is executed.  The first instruction of an interrupt handler
2934 declared with this attribute is a @code{SEI} instruction to
2935 re-enable interrupts.  See also the @code{signal} function attribute
2936 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2937 @code{interrupt} are specified for the same function, @code{signal}
2938 is silently ignored.
2940 Note, for the ARM, you can specify the kind of interrupt to be handled by
2941 adding an optional parameter to the interrupt attribute like this:
2943 @smallexample
2944 void f () __attribute__ ((interrupt ("IRQ")));
2945 @end smallexample
2947 @noindent
2948 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2949 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2951 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2952 may be called with a word-aligned stack pointer.
2954 Note, for the MSP430 you can provide an argument to the interrupt
2955 attribute which specifies a name or number.  If the argument is a
2956 number it indicates the slot in the interrupt vector table (0 - 31) to
2957 which this handler should be assigned.  If the argument is a name it
2958 is treated as a symbolic name for the vector slot.  These names should
2959 match up with appropriate entries in the linker script.  By default
2960 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2961 @code{reset} for vector 31 are recognised.
2963 You can also use the following function attributes to modify how
2964 normal functions interact with interrupt functions:
2966 @table @code
2967 @item critical
2968 @cindex @code{critical} attribute
2969 Critical functions disable interrupts upon entry and restore the
2970 previous interrupt state upon exit.  Critical functions cannot also
2971 have the @code{naked} or @code{reentrant} attributes.  They can have
2972 the @code{interrupt} attribute.
2974 @item reentrant
2975 @cindex @code{reentrant} attribute
2976 Reentrant functions disable interrupts upon entry and enable them
2977 upon exit.  Reentrant functions cannot also have the @code{naked}
2978 or @code{critical} attributes.  They can have the @code{interrupt}
2979 attribute.
2981 @item wakeup
2982 @cindex @code{wakeup} attribute
2983 This attribute only applies to interrupt functions.  It is silently
2984 ignored if applied to a non-interrupt function.  A wakeup interrupt
2985 function will rouse the processor from any low-power state that it
2986 might be in when the function exits.
2988 @end table
2990 On Epiphany targets one or more optional parameters can be added like this:
2992 @smallexample
2993 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2994 @end smallexample
2996 Permissible values for these parameters are: @w{@code{reset}},
2997 @w{@code{software_exception}}, @w{@code{page_miss}},
2998 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2999 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3000 Multiple parameters indicate that multiple entries in the interrupt
3001 vector table should be initialized for this function, i.e.@: for each
3002 parameter @w{@var{name}}, a jump to the function is emitted in
3003 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3004 entirely, in which case no interrupt vector table entry is provided.
3006 Note, on Epiphany targets, interrupts are enabled inside the function
3007 unless the @code{disinterrupt} attribute is also specified.
3009 On Epiphany targets, you can also use the following attribute to
3010 modify the behavior of an interrupt handler:
3011 @table @code
3012 @item forwarder_section
3013 @cindex @code{forwarder_section} attribute
3014 The interrupt handler may be in external memory which cannot be
3015 reached by a branch instruction, so generate a local memory trampoline
3016 to transfer control.  The single parameter identifies the section where
3017 the trampoline is placed.
3018 @end table
3020 The following examples are all valid uses of these attributes on
3021 Epiphany targets:
3022 @smallexample
3023 void __attribute__ ((interrupt)) universal_handler ();
3024 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3025 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3026 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3027   fast_timer_handler ();
3028 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3029   external_dma_handler ();
3030 @end smallexample
3032 On MIPS targets, you can use the following attributes to modify the behavior
3033 of an interrupt handler:
3034 @table @code
3035 @item use_shadow_register_set
3036 @cindex @code{use_shadow_register_set} attribute
3037 Assume that the handler uses a shadow register set, instead of
3038 the main general-purpose registers.
3040 @item keep_interrupts_masked
3041 @cindex @code{keep_interrupts_masked} attribute
3042 Keep interrupts masked for the whole function.  Without this attribute,
3043 GCC tries to reenable interrupts for as much of the function as it can.
3045 @item use_debug_exception_return
3046 @cindex @code{use_debug_exception_return} attribute
3047 Return using the @code{deret} instruction.  Interrupt handlers that don't
3048 have this attribute return using @code{eret} instead.
3049 @end table
3051 You can use any combination of these attributes, as shown below:
3052 @smallexample
3053 void __attribute__ ((interrupt)) v0 ();
3054 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3055 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3056 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3057 void __attribute__ ((interrupt, use_shadow_register_set,
3058                      keep_interrupts_masked)) v4 ();
3059 void __attribute__ ((interrupt, use_shadow_register_set,
3060                      use_debug_exception_return)) v5 ();
3061 void __attribute__ ((interrupt, keep_interrupts_masked,
3062                      use_debug_exception_return)) v6 ();
3063 void __attribute__ ((interrupt, use_shadow_register_set,
3064                      keep_interrupts_masked,
3065                      use_debug_exception_return)) v7 ();
3066 @end smallexample
3068 On NDS32 target, this attribute is to indicate that the specified function
3069 is an interrupt handler.  The compiler will generate corresponding sections
3070 for use in an interrupt handler.  You can use the following attributes
3071 to modify the behavior:
3072 @table @code
3073 @item nested
3074 @cindex @code{nested} attribute
3075 This interrupt service routine is interruptible.
3076 @item not_nested
3077 @cindex @code{not_nested} attribute
3078 This interrupt service routine is not interruptible.
3079 @item nested_ready
3080 @cindex @code{nested_ready} attribute
3081 This interrupt service routine is interruptible after @code{PSW.GIE}
3082 (global interrupt enable) is set.  This allows interrupt service routine to
3083 finish some short critical code before enabling interrupts.
3084 @item save_all
3085 @cindex @code{save_all} attribute
3086 The system will help save all registers into stack before entering
3087 interrupt handler.
3088 @item partial_save
3089 @cindex @code{partial_save} attribute
3090 The system will help save caller registers into stack before entering
3091 interrupt handler.
3092 @end table
3094 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3095 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3096 that must end with @code{RETB} instead of @code{RETI}).
3098 On RX targets, you may specify one or more vector numbers as arguments
3099 to the attribute, as well as naming an alternate table name.
3100 Parameters are handled sequentially, so one handler can be assigned to
3101 multiple entries in multiple tables.  One may also pass the magic
3102 string @code{"$default"} which causes the function to be used for any
3103 unfilled slots in the current table.
3105 This example shows a simple assignment of a function to one vector in
3106 the default table (note that preprocessor macros may be used for
3107 chip-specific symbolic vector names):
3108 @smallexample
3109 void __attribute__ ((interrupt (5))) txd1_handler ();
3110 @end smallexample
3112 This example assigns a function to two slots in the default table
3113 (using preprocessor macros defined elsewhere) and makes it the default
3114 for the @code{dct} table:
3115 @smallexample
3116 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3117         txd1_handler ();
3118 @end smallexample
3120 @item interrupt_handler
3121 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3122 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3123 indicate that the specified function is an interrupt handler.  The compiler
3124 generates function entry and exit sequences suitable for use in an
3125 interrupt handler when this attribute is present.
3127 @item interrupt_thread
3128 @cindex interrupt thread functions on fido
3129 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3130 that the specified function is an interrupt handler that is designed
3131 to run as a thread.  The compiler omits generate prologue/epilogue
3132 sequences and replaces the return instruction with a @code{sleep}
3133 instruction.  This attribute is available only on fido.
3135 @item isr
3136 @cindex interrupt service routines on ARM
3137 Use this attribute on ARM to write Interrupt Service Routines. This is an
3138 alias to the @code{interrupt} attribute above.
3140 @item kspisusp
3141 @cindex User stack pointer in interrupts on the Blackfin
3142 When used together with @code{interrupt_handler}, @code{exception_handler}
3143 or @code{nmi_handler}, code is generated to load the stack pointer
3144 from the USP register in the function prologue.
3146 @item l1_text
3147 @cindex @code{l1_text} function attribute
3148 This attribute specifies a function to be placed into L1 Instruction
3149 SRAM@. The function is put into a specific section named @code{.l1.text}.
3150 With @option{-mfdpic}, function calls with a such function as the callee
3151 or caller uses inlined PLT.
3153 @item l2
3154 @cindex @code{l2} function attribute
3155 On the Blackfin, this attribute specifies a function to be placed into L2
3156 SRAM. The function is put into a specific section named
3157 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3158 an inlined PLT.
3160 @item leaf
3161 @cindex @code{leaf} function attribute
3162 Calls to external functions with this attribute must return to the current
3163 compilation unit only by return or by exception handling.  In particular, leaf
3164 functions are not allowed to call callback function passed to it from the current
3165 compilation unit or directly call functions exported by the unit or longjmp
3166 into the unit.  Leaf function might still call functions from other compilation
3167 units and thus they are not necessarily leaf in the sense that they contain no
3168 function calls at all.
3170 The attribute is intended for library functions to improve dataflow analysis.
3171 The compiler takes the hint that any data not escaping the current compilation unit can
3172 not be used or modified by the leaf function.  For example, the @code{sin} function
3173 is a leaf function, but @code{qsort} is not.
3175 Note that leaf functions might invoke signals and signal handlers might be
3176 defined in the current compilation unit and use static variables.  The only
3177 compliant way to write such a signal handler is to declare such variables
3178 @code{volatile}.
3180 The attribute has no effect on functions defined within the current compilation
3181 unit.  This is to allow easy merging of multiple compilation units into one,
3182 for example, by using the link-time optimization.  For this reason the
3183 attribute is not allowed on types to annotate indirect calls.
3185 @item long_call/medium_call/short_call
3186 @cindex indirect calls on ARC
3187 @cindex indirect calls on ARM
3188 @cindex indirect calls on Epiphany
3189 These attributes specify how a particular function is called on
3190 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3191 These attributes override the
3192 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3193 and @option{-mmedium-calls} (@pxref{ARC Options})
3194 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3195 @code{long_call} attribute indicates that the function might be far
3196 away from the call site and require a different (more expensive)
3197 calling sequence.   The @code{short_call} attribute always places
3198 the offset to the function from the call site into the @samp{BL}
3199 instruction directly.
3201 For ARC, a function marked with the @code{long_call} attribute is
3202 always called using register-indirect jump-and-link instructions,
3203 thereby enabling the called function to be placed anywhere within the
3204 32-bit address space.  A function marked with the @code{medium_call}
3205 attribute will always be close enough to be called with an unconditional
3206 branch-and-link instruction, which has a 25-bit offset from
3207 the call site.  A function marked with the @code{short_call}
3208 attribute will always be close enough to be called with a conditional
3209 branch-and-link instruction, which has a 21-bit offset from
3210 the call site.
3212 @item longcall/shortcall
3213 @cindex functions called via pointer on the RS/6000 and PowerPC
3214 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3215 indicates that the function might be far away from the call site and
3216 require a different (more expensive) calling sequence.  The
3217 @code{shortcall} attribute indicates that the function is always close
3218 enough for the shorter calling sequence to be used.  These attributes
3219 override both the @option{-mlongcall} switch and, on the RS/6000 and
3220 PowerPC, the @code{#pragma longcall} setting.
3222 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3223 calls are necessary.
3225 @item long_call/near/far
3226 @cindex indirect calls on MIPS
3227 These attributes specify how a particular function is called on MIPS@.
3228 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3229 command-line switch.  The @code{long_call} and @code{far} attributes are
3230 synonyms, and cause the compiler to always call
3231 the function by first loading its address into a register, and then using
3232 the contents of that register.  The @code{near} attribute has the opposite
3233 effect; it specifies that non-PIC calls should be made using the more
3234 efficient @code{jal} instruction.
3236 @item malloc
3237 @cindex @code{malloc} attribute
3238 This tells the compiler that a function is @code{malloc}-like, i.e.,
3239 that the pointer @var{P} returned by the function cannot alias any
3240 other pointer valid when the function returns, and moreover no
3241 pointers to valid objects occur in any storage addressed by @var{P}.
3243 Using this attribute can improve optimization.  Functions like
3244 @code{malloc} and @code{calloc} have this property because they return
3245 a pointer to uninitialized or zeroed-out storage.  However, functions
3246 like @code{realloc} do not have this property, as they can return a
3247 pointer to storage containing pointers.
3249 @item mips16/nomips16
3250 @cindex @code{mips16} attribute
3251 @cindex @code{nomips16} attribute
3253 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3254 function attributes to locally select or turn off MIPS16 code generation.
3255 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3256 while MIPS16 code generation is disabled for functions with the
3257 @code{nomips16} attribute.  These attributes override the
3258 @option{-mips16} and @option{-mno-mips16} options on the command line
3259 (@pxref{MIPS Options}).
3261 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3262 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3263 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3264 may interact badly with some GCC extensions such as @code{__builtin_apply}
3265 (@pxref{Constructing Calls}).
3267 @item micromips/nomicromips
3268 @cindex @code{micromips} attribute
3269 @cindex @code{nomicromips} attribute
3271 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3272 function attributes to locally select or turn off microMIPS code generation.
3273 A function with the @code{micromips} attribute is emitted as microMIPS code,
3274 while microMIPS code generation is disabled for functions with the
3275 @code{nomicromips} attribute.  These attributes override the
3276 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3277 (@pxref{MIPS Options}).
3279 When compiling files containing mixed microMIPS and non-microMIPS code, the
3280 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3281 command line,
3282 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3283 may interact badly with some GCC extensions such as @code{__builtin_apply}
3284 (@pxref{Constructing Calls}).
3286 @item model (@var{model-name})
3287 @cindex function addressability on the M32R/D
3288 @cindex variable addressability on the IA-64
3290 On the M32R/D, use this attribute to set the addressability of an
3291 object, and of the code generated for a function.  The identifier
3292 @var{model-name} is one of @code{small}, @code{medium}, or
3293 @code{large}, representing each of the code models.
3295 Small model objects live in the lower 16MB of memory (so that their
3296 addresses can be loaded with the @code{ld24} instruction), and are
3297 callable with the @code{bl} instruction.
3299 Medium model objects may live anywhere in the 32-bit address space (the
3300 compiler generates @code{seth/add3} instructions to load their addresses),
3301 and are callable with the @code{bl} instruction.
3303 Large model objects may live anywhere in the 32-bit address space (the
3304 compiler generates @code{seth/add3} instructions to load their addresses),
3305 and may not be reachable with the @code{bl} instruction (the compiler
3306 generates the much slower @code{seth/add3/jl} instruction sequence).
3308 On IA-64, use this attribute to set the addressability of an object.
3309 At present, the only supported identifier for @var{model-name} is
3310 @code{small}, indicating addressability via ``small'' (22-bit)
3311 addresses (so that their addresses can be loaded with the @code{addl}
3312 instruction).  Caveat: such addressing is by definition not position
3313 independent and hence this attribute must not be used for objects
3314 defined by shared libraries.
3316 @item ms_abi/sysv_abi
3317 @cindex @code{ms_abi} attribute
3318 @cindex @code{sysv_abi} attribute
3320 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3321 to indicate which calling convention should be used for a function.  The
3322 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3323 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3324 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3325 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3327 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3328 requires the @option{-maccumulate-outgoing-args} option.
3330 @item callee_pop_aggregate_return (@var{number})
3331 @cindex @code{callee_pop_aggregate_return} attribute
3333 On 32-bit i?86-*-* targets, you can use this attribute to control how
3334 aggregates are returned in memory.  If the caller is responsible for
3335 popping the hidden pointer together with the rest of the arguments, specify
3336 @var{number} equal to zero.  If callee is responsible for popping the
3337 hidden pointer, specify @var{number} equal to one.  
3339 The default i386 ABI assumes that the callee pops the
3340 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3341 the compiler assumes that the
3342 caller pops the stack for hidden pointer.
3344 @item ms_hook_prologue
3345 @cindex @code{ms_hook_prologue} attribute
3347 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3348 this function attribute to make GCC generate the ``hot-patching'' function
3349 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3350 and newer.
3352 @item hotpatch [(@var{prologue-halfwords})]
3353 @cindex @code{hotpatch} attribute
3355 On S/390 System z targets, you can use this function attribute to
3356 make GCC generate a ``hot-patching'' function prologue.  The
3357 @code{hotpatch} has no effect on funtions that are explicitly
3358 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3359 command-line option is used at the same time, the @code{hotpatch}
3360 attribute takes precedence.  If an argument is given, the maximum
3361 allowed value is 1000000.
3363 @item naked
3364 @cindex function without a prologue/epilogue code
3365 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3366 RL78, RX and SPU ports.  It allows the compiler to construct the
3367 requisite function declaration, while allowing the body of the
3368 function to be assembly code. The specified function will not have
3369 prologue/epilogue sequences generated by the compiler. Only Basic
3370 @code{asm} statements can safely be included in naked functions
3371 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3372 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3373 depended upon to work reliably and are not supported.
3375 @item near
3376 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3377 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3378 use the normal calling convention based on @code{jsr} and @code{rts}.
3379 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3380 option.
3382 On MeP targets this attribute causes the compiler to assume the called
3383 function is close enough to use the normal calling convention,
3384 overriding the @option{-mtf} command-line option.
3386 @item nesting
3387 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3388 Use this attribute together with @code{interrupt_handler},
3389 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3390 entry code should enable nested interrupts or exceptions.
3392 @item nmi_handler
3393 @cindex NMI handler functions on the Blackfin processor
3394 Use this attribute on the Blackfin to indicate that the specified function
3395 is an NMI handler.  The compiler generates function entry and
3396 exit sequences suitable for use in an NMI handler when this
3397 attribute is present.
3399 @item nocompression
3400 @cindex @code{nocompression} attribute
3401 On MIPS targets, you can use the @code{nocompression} function attribute
3402 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3403 overrides the @option{-mips16} and @option{-mmicromips} options on the
3404 command line (@pxref{MIPS Options}).
3406 @item no_instrument_function
3407 @cindex @code{no_instrument_function} function attribute
3408 @opindex finstrument-functions
3409 If @option{-finstrument-functions} is given, profiling function calls are
3410 generated at entry and exit of most user-compiled functions.
3411 Functions with this attribute are not so instrumented.
3413 @item no_split_stack
3414 @cindex @code{no_split_stack} function attribute
3415 @opindex fsplit-stack
3416 If @option{-fsplit-stack} is given, functions have a small
3417 prologue which decides whether to split the stack.  Functions with the
3418 @code{no_split_stack} attribute do not have that prologue, and thus
3419 may run with only a small amount of stack space available.
3421 @item noinline
3422 @cindex @code{noinline} function attribute
3423 This function attribute prevents a function from being considered for
3424 inlining.
3425 @c Don't enumerate the optimizations by name here; we try to be
3426 @c future-compatible with this mechanism.
3427 If the function does not have side-effects, there are optimizations
3428 other than inlining that cause function calls to be optimized away,
3429 although the function call is live.  To keep such calls from being
3430 optimized away, put
3431 @smallexample
3432 asm ("");
3433 @end smallexample
3435 @noindent
3436 (@pxref{Extended Asm}) in the called function, to serve as a special
3437 side-effect.
3439 @item noclone
3440 @cindex @code{noclone} function attribute
3441 This function attribute prevents a function from being considered for
3442 cloning---a mechanism that produces specialized copies of functions
3443 and which is (currently) performed by interprocedural constant
3444 propagation.
3446 @item nonnull (@var{arg-index}, @dots{})
3447 @cindex @code{nonnull} function attribute
3448 The @code{nonnull} attribute specifies that some function parameters should
3449 be non-null pointers.  For instance, the declaration:
3451 @smallexample
3452 extern void *
3453 my_memcpy (void *dest, const void *src, size_t len)
3454         __attribute__((nonnull (1, 2)));
3455 @end smallexample
3457 @noindent
3458 causes the compiler to check that, in calls to @code{my_memcpy},
3459 arguments @var{dest} and @var{src} are non-null.  If the compiler
3460 determines that a null pointer is passed in an argument slot marked
3461 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3462 is issued.  The compiler may also choose to make optimizations based
3463 on the knowledge that certain function arguments will never be null.
3465 If no argument index list is given to the @code{nonnull} attribute,
3466 all pointer arguments are marked as non-null.  To illustrate, the
3467 following declaration is equivalent to the previous example:
3469 @smallexample
3470 extern void *
3471 my_memcpy (void *dest, const void *src, size_t len)
3472         __attribute__((nonnull));
3473 @end smallexample
3475 @item returns_nonnull
3476 @cindex @code{returns_nonnull} function attribute
3477 The @code{returns_nonnull} attribute specifies that the function
3478 return value should be a non-null pointer.  For instance, the declaration:
3480 @smallexample
3481 extern void *
3482 mymalloc (size_t len) __attribute__((returns_nonnull));
3483 @end smallexample
3485 @noindent
3486 lets the compiler optimize callers based on the knowledge
3487 that the return value will never be null.
3489 @item noreturn
3490 @cindex @code{noreturn} function attribute
3491 A few standard library functions, such as @code{abort} and @code{exit},
3492 cannot return.  GCC knows this automatically.  Some programs define
3493 their own functions that never return.  You can declare them
3494 @code{noreturn} to tell the compiler this fact.  For example,
3496 @smallexample
3497 @group
3498 void fatal () __attribute__ ((noreturn));
3500 void
3501 fatal (/* @r{@dots{}} */)
3503   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3504   exit (1);
3506 @end group
3507 @end smallexample
3509 The @code{noreturn} keyword tells the compiler to assume that
3510 @code{fatal} cannot return.  It can then optimize without regard to what
3511 would happen if @code{fatal} ever did return.  This makes slightly
3512 better code.  More importantly, it helps avoid spurious warnings of
3513 uninitialized variables.
3515 The @code{noreturn} keyword does not affect the exceptional path when that
3516 applies: a @code{noreturn}-marked function may still return to the caller
3517 by throwing an exception or calling @code{longjmp}.
3519 Do not assume that registers saved by the calling function are
3520 restored before calling the @code{noreturn} function.
3522 It does not make sense for a @code{noreturn} function to have a return
3523 type other than @code{void}.
3525 The attribute @code{noreturn} is not implemented in GCC versions
3526 earlier than 2.5.  An alternative way to declare that a function does
3527 not return, which works in the current version and in some older
3528 versions, is as follows:
3530 @smallexample
3531 typedef void voidfn ();
3533 volatile voidfn fatal;
3534 @end smallexample
3536 @noindent
3537 This approach does not work in GNU C++.
3539 @item nothrow
3540 @cindex @code{nothrow} function attribute
3541 The @code{nothrow} attribute is used to inform the compiler that a
3542 function cannot throw an exception.  For example, most functions in
3543 the standard C library can be guaranteed not to throw an exception
3544 with the notable exceptions of @code{qsort} and @code{bsearch} that
3545 take function pointer arguments.  The @code{nothrow} attribute is not
3546 implemented in GCC versions earlier than 3.3.
3548 @item nosave_low_regs
3549 @cindex @code{nosave_low_regs} attribute
3550 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3551 function should not save and restore registers R0..R7.  This can be used on SH3*
3552 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3553 interrupt handlers.
3555 @item optimize
3556 @cindex @code{optimize} function attribute
3557 The @code{optimize} attribute is used to specify that a function is to
3558 be compiled with different optimization options than specified on the
3559 command line.  Arguments can either be numbers or strings.  Numbers
3560 are assumed to be an optimization level.  Strings that begin with
3561 @code{O} are assumed to be an optimization option, while other options
3562 are assumed to be used with a @code{-f} prefix.  You can also use the
3563 @samp{#pragma GCC optimize} pragma to set the optimization options
3564 that affect more than one function.
3565 @xref{Function Specific Option Pragmas}, for details about the
3566 @samp{#pragma GCC optimize} pragma.
3568 This can be used for instance to have frequently-executed functions
3569 compiled with more aggressive optimization options that produce faster
3570 and larger code, while other functions can be compiled with less
3571 aggressive options.
3573 @item OS_main/OS_task
3574 @cindex @code{OS_main} AVR function attribute
3575 @cindex @code{OS_task} AVR function attribute
3576 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3577 do not save/restore any call-saved register in their prologue/epilogue.
3579 The @code{OS_main} attribute can be used when there @emph{is
3580 guarantee} that interrupts are disabled at the time when the function
3581 is entered.  This saves resources when the stack pointer has to be
3582 changed to set up a frame for local variables.
3584 The @code{OS_task} attribute can be used when there is @emph{no
3585 guarantee} that interrupts are disabled at that time when the function
3586 is entered like for, e@.g@. task functions in a multi-threading operating
3587 system. In that case, changing the stack pointer register is
3588 guarded by save/clear/restore of the global interrupt enable flag.
3590 The differences to the @code{naked} function attribute are:
3591 @itemize @bullet
3592 @item @code{naked} functions do not have a return instruction whereas 
3593 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3594 @code{RETI} return instruction.
3595 @item @code{naked} functions do not set up a frame for local variables
3596 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3597 as needed.
3598 @end itemize
3600 @item pcs
3601 @cindex @code{pcs} function attribute
3603 The @code{pcs} attribute can be used to control the calling convention
3604 used for a function on ARM.  The attribute takes an argument that specifies
3605 the calling convention to use.
3607 When compiling using the AAPCS ABI (or a variant of it) then valid
3608 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3609 order to use a variant other than @code{"aapcs"} then the compiler must
3610 be permitted to use the appropriate co-processor registers (i.e., the
3611 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3612 For example,
3614 @smallexample
3615 /* Argument passed in r0, and result returned in r0+r1.  */
3616 double f2d (float) __attribute__((pcs("aapcs")));
3617 @end smallexample
3619 Variadic functions always use the @code{"aapcs"} calling convention and
3620 the compiler rejects attempts to specify an alternative.
3622 @item pure
3623 @cindex @code{pure} function attribute
3624 Many functions have no effects except the return value and their
3625 return value depends only on the parameters and/or global variables.
3626 Such a function can be subject
3627 to common subexpression elimination and loop optimization just as an
3628 arithmetic operator would be.  These functions should be declared
3629 with the attribute @code{pure}.  For example,
3631 @smallexample
3632 int square (int) __attribute__ ((pure));
3633 @end smallexample
3635 @noindent
3636 says that the hypothetical function @code{square} is safe to call
3637 fewer times than the program says.
3639 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3640 Interesting non-pure functions are functions with infinite loops or those
3641 depending on volatile memory or other system resource, that may change between
3642 two consecutive calls (such as @code{feof} in a multithreading environment).
3644 The attribute @code{pure} is not implemented in GCC versions earlier
3645 than 2.96.
3647 @item hot
3648 @cindex @code{hot} function attribute
3649 The @code{hot} attribute on a function is used to inform the compiler that
3650 the function is a hot spot of the compiled program.  The function is
3651 optimized more aggressively and on many targets it is placed into a special
3652 subsection of the text section so all hot functions appear close together,
3653 improving locality.
3655 When profile feedback is available, via @option{-fprofile-use}, hot functions
3656 are automatically detected and this attribute is ignored.
3658 The @code{hot} attribute on functions is not implemented in GCC versions
3659 earlier than 4.3.
3661 @item cold
3662 @cindex @code{cold} function attribute
3663 The @code{cold} attribute on functions is used to inform the compiler that
3664 the function is unlikely to be executed.  The function is optimized for
3665 size rather than speed and on many targets it is placed into a special
3666 subsection of the text section so all cold functions appear close together,
3667 improving code locality of non-cold parts of program.  The paths leading
3668 to calls of cold functions within code are marked as unlikely by the branch
3669 prediction mechanism.  It is thus useful to mark functions used to handle
3670 unlikely conditions, such as @code{perror}, as cold to improve optimization
3671 of hot functions that do call marked functions in rare occasions.
3673 When profile feedback is available, via @option{-fprofile-use}, cold functions
3674 are automatically detected and this attribute is ignored.
3676 The @code{cold} attribute on functions is not implemented in GCC versions
3677 earlier than 4.3.
3679 @item no_sanitize_address
3680 @itemx no_address_safety_analysis
3681 @cindex @code{no_sanitize_address} function attribute
3682 The @code{no_sanitize_address} attribute on functions is used
3683 to inform the compiler that it should not instrument memory accesses
3684 in the function when compiling with the @option{-fsanitize=address} option.
3685 The @code{no_address_safety_analysis} is a deprecated alias of the
3686 @code{no_sanitize_address} attribute, new code should use
3687 @code{no_sanitize_address}.
3689 @item no_sanitize_undefined
3690 @cindex @code{no_sanitize_undefined} function attribute
3691 The @code{no_sanitize_undefined} attribute on functions is used
3692 to inform the compiler that it should not check for undefined behavior
3693 in the function when compiling with the @option{-fsanitize=undefined} option.
3695 @item regparm (@var{number})
3696 @cindex @code{regparm} attribute
3697 @cindex functions that are passed arguments in registers on the 386
3698 On the Intel 386, the @code{regparm} attribute causes the compiler to
3699 pass arguments number one to @var{number} if they are of integral type
3700 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3701 take a variable number of arguments continue to be passed all of their
3702 arguments on the stack.
3704 Beware that on some ELF systems this attribute is unsuitable for
3705 global functions in shared libraries with lazy binding (which is the
3706 default).  Lazy binding sends the first call via resolving code in
3707 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3708 per the standard calling conventions.  Solaris 8 is affected by this.
3709 Systems with the GNU C Library version 2.1 or higher
3710 and FreeBSD are believed to be
3711 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3712 disabled with the linker or the loader if desired, to avoid the
3713 problem.)
3715 @item reset
3716 @cindex reset handler functions
3717 Use this attribute on the NDS32 target to indicate that the specified function
3718 is a reset handler.  The compiler will generate corresponding sections
3719 for use in a reset handler.  You can use the following attributes
3720 to provide extra exception handling:
3721 @table @code
3722 @item nmi
3723 @cindex @code{nmi} attribute
3724 Provide a user-defined function to handle NMI exception.
3725 @item warm
3726 @cindex @code{warm} attribute
3727 Provide a user-defined function to handle warm reset exception.
3728 @end table
3730 @item sseregparm
3731 @cindex @code{sseregparm} attribute
3732 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3733 causes the compiler to pass up to 3 floating-point arguments in
3734 SSE registers instead of on the stack.  Functions that take a
3735 variable number of arguments continue to pass all of their
3736 floating-point arguments on the stack.
3738 @item force_align_arg_pointer
3739 @cindex @code{force_align_arg_pointer} attribute
3740 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3741 applied to individual function definitions, generating an alternate
3742 prologue and epilogue that realigns the run-time stack if necessary.
3743 This supports mixing legacy codes that run with a 4-byte aligned stack
3744 with modern codes that keep a 16-byte stack for SSE compatibility.
3746 @item renesas
3747 @cindex @code{renesas} attribute
3748 On SH targets this attribute specifies that the function or struct follows the
3749 Renesas ABI.
3751 @item resbank
3752 @cindex @code{resbank} attribute
3753 On the SH2A target, this attribute enables the high-speed register
3754 saving and restoration using a register bank for @code{interrupt_handler}
3755 routines.  Saving to the bank is performed automatically after the CPU
3756 accepts an interrupt that uses a register bank.
3758 The nineteen 32-bit registers comprising general register R0 to R14,
3759 control register GBR, and system registers MACH, MACL, and PR and the
3760 vector table address offset are saved into a register bank.  Register
3761 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3762 from the bank is executed by issuing a RESBANK instruction.
3764 @item returns_twice
3765 @cindex @code{returns_twice} attribute
3766 The @code{returns_twice} attribute tells the compiler that a function may
3767 return more than one time.  The compiler ensures that all registers
3768 are dead before calling such a function and emits a warning about
3769 the variables that may be clobbered after the second return from the
3770 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3771 The @code{longjmp}-like counterpart of such function, if any, might need
3772 to be marked with the @code{noreturn} attribute.
3774 @item saveall
3775 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3776 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3777 all registers except the stack pointer should be saved in the prologue
3778 regardless of whether they are used or not.
3780 @item save_volatiles
3781 @cindex save volatile registers on the MicroBlaze
3782 Use this attribute on the MicroBlaze to indicate that the function is
3783 an interrupt handler.  All volatile registers (in addition to non-volatile
3784 registers) are saved in the function prologue.  If the function is a leaf
3785 function, only volatiles used by the function are saved.  A normal function
3786 return is generated instead of a return from interrupt.
3788 @item break_handler
3789 @cindex break handler functions
3790 Use this attribute on the MicroBlaze ports to indicate that
3791 the specified function is an break handler.  The compiler generates function
3792 entry and exit sequences suitable for use in an break handler when this
3793 attribute is present. The return from @code{break_handler} is done through
3794 the @code{rtbd} instead of @code{rtsd}.
3796 @smallexample
3797 void f () __attribute__ ((break_handler));
3798 @end smallexample
3800 @item section ("@var{section-name}")
3801 @cindex @code{section} function attribute
3802 Normally, the compiler places the code it generates in the @code{text} section.
3803 Sometimes, however, you need additional sections, or you need certain
3804 particular functions to appear in special sections.  The @code{section}
3805 attribute specifies that a function lives in a particular section.
3806 For example, the declaration:
3808 @smallexample
3809 extern void foobar (void) __attribute__ ((section ("bar")));
3810 @end smallexample
3812 @noindent
3813 puts the function @code{foobar} in the @code{bar} section.
3815 Some file formats do not support arbitrary sections so the @code{section}
3816 attribute is not available on all platforms.
3817 If you need to map the entire contents of a module to a particular
3818 section, consider using the facilities of the linker instead.
3820 @item sentinel
3821 @cindex @code{sentinel} function attribute
3822 This function attribute ensures that a parameter in a function call is
3823 an explicit @code{NULL}.  The attribute is only valid on variadic
3824 functions.  By default, the sentinel is located at position zero, the
3825 last parameter of the function call.  If an optional integer position
3826 argument P is supplied to the attribute, the sentinel must be located at
3827 position P counting backwards from the end of the argument list.
3829 @smallexample
3830 __attribute__ ((sentinel))
3831 is equivalent to
3832 __attribute__ ((sentinel(0)))
3833 @end smallexample
3835 The attribute is automatically set with a position of 0 for the built-in
3836 functions @code{execl} and @code{execlp}.  The built-in function
3837 @code{execle} has the attribute set with a position of 1.
3839 A valid @code{NULL} in this context is defined as zero with any pointer
3840 type.  If your system defines the @code{NULL} macro with an integer type
3841 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3842 with a copy that redefines NULL appropriately.
3844 The warnings for missing or incorrect sentinels are enabled with
3845 @option{-Wformat}.
3847 @item short_call
3848 See @code{long_call/short_call}.
3850 @item shortcall
3851 See @code{longcall/shortcall}.
3853 @item signal
3854 @cindex interrupt handler functions on the AVR processors
3855 Use this attribute on the AVR to indicate that the specified
3856 function is an interrupt handler.  The compiler generates function
3857 entry and exit sequences suitable for use in an interrupt handler when this
3858 attribute is present.
3860 See also the @code{interrupt} function attribute. 
3862 The AVR hardware globally disables interrupts when an interrupt is executed.
3863 Interrupt handler functions defined with the @code{signal} attribute
3864 do not re-enable interrupts.  It is save to enable interrupts in a
3865 @code{signal} handler.  This ``save'' only applies to the code
3866 generated by the compiler and not to the IRQ layout of the
3867 application which is responsibility of the application.
3869 If both @code{signal} and @code{interrupt} are specified for the same
3870 function, @code{signal} is silently ignored.
3872 @item sp_switch
3873 @cindex @code{sp_switch} attribute
3874 Use this attribute on the SH to indicate an @code{interrupt_handler}
3875 function should switch to an alternate stack.  It expects a string
3876 argument that names a global variable holding the address of the
3877 alternate stack.
3879 @smallexample
3880 void *alt_stack;
3881 void f () __attribute__ ((interrupt_handler,
3882                           sp_switch ("alt_stack")));
3883 @end smallexample
3885 @item stdcall
3886 @cindex functions that pop the argument stack on the 386
3887 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3888 assume that the called function pops off the stack space used to
3889 pass arguments, unless it takes a variable number of arguments.
3891 @item syscall_linkage
3892 @cindex @code{syscall_linkage} attribute
3893 This attribute is used to modify the IA-64 calling convention by marking
3894 all input registers as live at all function exits.  This makes it possible
3895 to restart a system call after an interrupt without having to save/restore
3896 the input registers.  This also prevents kernel data from leaking into
3897 application code.
3899 @item target
3900 @cindex @code{target} function attribute
3901 The @code{target} attribute is used to specify that a function is to
3902 be compiled with different target options than specified on the
3903 command line.  This can be used for instance to have functions
3904 compiled with a different ISA (instruction set architecture) than the
3905 default.  You can also use the @samp{#pragma GCC target} pragma to set
3906 more than one function to be compiled with specific target options.
3907 @xref{Function Specific Option Pragmas}, for details about the
3908 @samp{#pragma GCC target} pragma.
3910 For instance on a 386, you could compile one function with
3911 @code{target("sse4.1,arch=core2")} and another with
3912 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3913 compiling the first function with @option{-msse4.1} and
3914 @option{-march=core2} options, and the second function with
3915 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3916 user to make sure that a function is only invoked on a machine that
3917 supports the particular ISA it is compiled for (for example by using
3918 @code{cpuid} on 386 to determine what feature bits and architecture
3919 family are used).
3921 @smallexample
3922 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3923 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3924 @end smallexample
3926 You can either use multiple
3927 strings to specify multiple options, or separate the options
3928 with a comma (@samp{,}).
3930 The @code{target} attribute is presently implemented for
3931 i386/x86_64, PowerPC, and Nios II targets only.
3932 The options supported are specific to each target.
3934 On the 386, the following options are allowed:
3936 @table @samp
3937 @item abm
3938 @itemx no-abm
3939 @cindex @code{target("abm")} attribute
3940 Enable/disable the generation of the advanced bit instructions.
3942 @item aes
3943 @itemx no-aes
3944 @cindex @code{target("aes")} attribute
3945 Enable/disable the generation of the AES instructions.
3947 @item default
3948 @cindex @code{target("default")} attribute
3949 @xref{Function Multiversioning}, where it is used to specify the
3950 default function version.
3952 @item mmx
3953 @itemx no-mmx
3954 @cindex @code{target("mmx")} attribute
3955 Enable/disable the generation of the MMX instructions.
3957 @item pclmul
3958 @itemx no-pclmul
3959 @cindex @code{target("pclmul")} attribute
3960 Enable/disable the generation of the PCLMUL instructions.
3962 @item popcnt
3963 @itemx no-popcnt
3964 @cindex @code{target("popcnt")} attribute
3965 Enable/disable the generation of the POPCNT instruction.
3967 @item sse
3968 @itemx no-sse
3969 @cindex @code{target("sse")} attribute
3970 Enable/disable the generation of the SSE instructions.
3972 @item sse2
3973 @itemx no-sse2
3974 @cindex @code{target("sse2")} attribute
3975 Enable/disable the generation of the SSE2 instructions.
3977 @item sse3
3978 @itemx no-sse3
3979 @cindex @code{target("sse3")} attribute
3980 Enable/disable the generation of the SSE3 instructions.
3982 @item sse4
3983 @itemx no-sse4
3984 @cindex @code{target("sse4")} attribute
3985 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3986 and SSE4.2).
3988 @item sse4.1
3989 @itemx no-sse4.1
3990 @cindex @code{target("sse4.1")} attribute
3991 Enable/disable the generation of the sse4.1 instructions.
3993 @item sse4.2
3994 @itemx no-sse4.2
3995 @cindex @code{target("sse4.2")} attribute
3996 Enable/disable the generation of the sse4.2 instructions.
3998 @item sse4a
3999 @itemx no-sse4a
4000 @cindex @code{target("sse4a")} attribute
4001 Enable/disable the generation of the SSE4A instructions.
4003 @item fma4
4004 @itemx no-fma4
4005 @cindex @code{target("fma4")} attribute
4006 Enable/disable the generation of the FMA4 instructions.
4008 @item xop
4009 @itemx no-xop
4010 @cindex @code{target("xop")} attribute
4011 Enable/disable the generation of the XOP instructions.
4013 @item lwp
4014 @itemx no-lwp
4015 @cindex @code{target("lwp")} attribute
4016 Enable/disable the generation of the LWP instructions.
4018 @item ssse3
4019 @itemx no-ssse3
4020 @cindex @code{target("ssse3")} attribute
4021 Enable/disable the generation of the SSSE3 instructions.
4023 @item cld
4024 @itemx no-cld
4025 @cindex @code{target("cld")} attribute
4026 Enable/disable the generation of the CLD before string moves.
4028 @item fancy-math-387
4029 @itemx no-fancy-math-387
4030 @cindex @code{target("fancy-math-387")} attribute
4031 Enable/disable the generation of the @code{sin}, @code{cos}, and
4032 @code{sqrt} instructions on the 387 floating-point unit.
4034 @item fused-madd
4035 @itemx no-fused-madd
4036 @cindex @code{target("fused-madd")} attribute
4037 Enable/disable the generation of the fused multiply/add instructions.
4039 @item ieee-fp
4040 @itemx no-ieee-fp
4041 @cindex @code{target("ieee-fp")} attribute
4042 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4044 @item inline-all-stringops
4045 @itemx no-inline-all-stringops
4046 @cindex @code{target("inline-all-stringops")} attribute
4047 Enable/disable inlining of string operations.
4049 @item inline-stringops-dynamically
4050 @itemx no-inline-stringops-dynamically
4051 @cindex @code{target("inline-stringops-dynamically")} attribute
4052 Enable/disable the generation of the inline code to do small string
4053 operations and calling the library routines for large operations.
4055 @item align-stringops
4056 @itemx no-align-stringops
4057 @cindex @code{target("align-stringops")} attribute
4058 Do/do not align destination of inlined string operations.
4060 @item recip
4061 @itemx no-recip
4062 @cindex @code{target("recip")} attribute
4063 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4064 instructions followed an additional Newton-Raphson step instead of
4065 doing a floating-point division.
4067 @item arch=@var{ARCH}
4068 @cindex @code{target("arch=@var{ARCH}")} attribute
4069 Specify the architecture to generate code for in compiling the function.
4071 @item tune=@var{TUNE}
4072 @cindex @code{target("tune=@var{TUNE}")} attribute
4073 Specify the architecture to tune for in compiling the function.
4075 @item fpmath=@var{FPMATH}
4076 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4077 Specify which floating-point unit to use.  The
4078 @code{target("fpmath=sse,387")} option must be specified as
4079 @code{target("fpmath=sse+387")} because the comma would separate
4080 different options.
4081 @end table
4083 On the PowerPC, the following options are allowed:
4085 @table @samp
4086 @item altivec
4087 @itemx no-altivec
4088 @cindex @code{target("altivec")} attribute
4089 Generate code that uses (does not use) AltiVec instructions.  In
4090 32-bit code, you cannot enable AltiVec instructions unless
4091 @option{-mabi=altivec} is used on the command line.
4093 @item cmpb
4094 @itemx no-cmpb
4095 @cindex @code{target("cmpb")} attribute
4096 Generate code that uses (does not use) the compare bytes instruction
4097 implemented on the POWER6 processor and other processors that support
4098 the PowerPC V2.05 architecture.
4100 @item dlmzb
4101 @itemx no-dlmzb
4102 @cindex @code{target("dlmzb")} attribute
4103 Generate code that uses (does not use) the string-search @samp{dlmzb}
4104 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4105 generated by default when targeting those processors.
4107 @item fprnd
4108 @itemx no-fprnd
4109 @cindex @code{target("fprnd")} attribute
4110 Generate code that uses (does not use) the FP round to integer
4111 instructions implemented on the POWER5+ processor and other processors
4112 that support the PowerPC V2.03 architecture.
4114 @item hard-dfp
4115 @itemx no-hard-dfp
4116 @cindex @code{target("hard-dfp")} attribute
4117 Generate code that uses (does not use) the decimal floating-point
4118 instructions implemented on some POWER processors.
4120 @item isel
4121 @itemx no-isel
4122 @cindex @code{target("isel")} attribute
4123 Generate code that uses (does not use) ISEL instruction.
4125 @item mfcrf
4126 @itemx no-mfcrf
4127 @cindex @code{target("mfcrf")} attribute
4128 Generate code that uses (does not use) the move from condition
4129 register field instruction implemented on the POWER4 processor and
4130 other processors that support the PowerPC V2.01 architecture.
4132 @item mfpgpr
4133 @itemx no-mfpgpr
4134 @cindex @code{target("mfpgpr")} attribute
4135 Generate code that uses (does not use) the FP move to/from general
4136 purpose register instructions implemented on the POWER6X processor and
4137 other processors that support the extended PowerPC V2.05 architecture.
4139 @item mulhw
4140 @itemx no-mulhw
4141 @cindex @code{target("mulhw")} attribute
4142 Generate code that uses (does not use) the half-word multiply and
4143 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4144 These instructions are generated by default when targeting those
4145 processors.
4147 @item multiple
4148 @itemx no-multiple
4149 @cindex @code{target("multiple")} attribute
4150 Generate code that uses (does not use) the load multiple word
4151 instructions and the store multiple word instructions.
4153 @item update
4154 @itemx no-update
4155 @cindex @code{target("update")} attribute
4156 Generate code that uses (does not use) the load or store instructions
4157 that update the base register to the address of the calculated memory
4158 location.
4160 @item popcntb
4161 @itemx no-popcntb
4162 @cindex @code{target("popcntb")} attribute
4163 Generate code that uses (does not use) the popcount and double-precision
4164 FP reciprocal estimate instruction implemented on the POWER5
4165 processor and other processors that support the PowerPC V2.02
4166 architecture.
4168 @item popcntd
4169 @itemx no-popcntd
4170 @cindex @code{target("popcntd")} attribute
4171 Generate code that uses (does not use) the popcount instruction
4172 implemented on the POWER7 processor and other processors that support
4173 the PowerPC V2.06 architecture.
4175 @item powerpc-gfxopt
4176 @itemx no-powerpc-gfxopt
4177 @cindex @code{target("powerpc-gfxopt")} attribute
4178 Generate code that uses (does not use) the optional PowerPC
4179 architecture instructions in the Graphics group, including
4180 floating-point select.
4182 @item powerpc-gpopt
4183 @itemx no-powerpc-gpopt
4184 @cindex @code{target("powerpc-gpopt")} attribute
4185 Generate code that uses (does not use) the optional PowerPC
4186 architecture instructions in the General Purpose group, including
4187 floating-point square root.
4189 @item recip-precision
4190 @itemx no-recip-precision
4191 @cindex @code{target("recip-precision")} attribute
4192 Assume (do not assume) that the reciprocal estimate instructions
4193 provide higher-precision estimates than is mandated by the powerpc
4194 ABI.
4196 @item string
4197 @itemx no-string
4198 @cindex @code{target("string")} attribute
4199 Generate code that uses (does not use) the load string instructions
4200 and the store string word instructions to save multiple registers and
4201 do small block moves.
4203 @item vsx
4204 @itemx no-vsx
4205 @cindex @code{target("vsx")} attribute
4206 Generate code that uses (does not use) vector/scalar (VSX)
4207 instructions, and also enable the use of built-in functions that allow
4208 more direct access to the VSX instruction set.  In 32-bit code, you
4209 cannot enable VSX or AltiVec instructions unless
4210 @option{-mabi=altivec} is used on the command line.
4212 @item friz
4213 @itemx no-friz
4214 @cindex @code{target("friz")} attribute
4215 Generate (do not generate) the @code{friz} instruction when the
4216 @option{-funsafe-math-optimizations} option is used to optimize
4217 rounding a floating-point value to 64-bit integer and back to floating
4218 point.  The @code{friz} instruction does not return the same value if
4219 the floating-point number is too large to fit in an integer.
4221 @item avoid-indexed-addresses
4222 @itemx no-avoid-indexed-addresses
4223 @cindex @code{target("avoid-indexed-addresses")} attribute
4224 Generate code that tries to avoid (not avoid) the use of indexed load
4225 or store instructions.
4227 @item paired
4228 @itemx no-paired
4229 @cindex @code{target("paired")} attribute
4230 Generate code that uses (does not use) the generation of PAIRED simd
4231 instructions.
4233 @item longcall
4234 @itemx no-longcall
4235 @cindex @code{target("longcall")} attribute
4236 Generate code that assumes (does not assume) that all calls are far
4237 away so that a longer more expensive calling sequence is required.
4239 @item cpu=@var{CPU}
4240 @cindex @code{target("cpu=@var{CPU}")} attribute
4241 Specify the architecture to generate code for when compiling the
4242 function.  If you select the @code{target("cpu=power7")} attribute when
4243 generating 32-bit code, VSX and AltiVec instructions are not generated
4244 unless you use the @option{-mabi=altivec} option on the command line.
4246 @item tune=@var{TUNE}
4247 @cindex @code{target("tune=@var{TUNE}")} attribute
4248 Specify the architecture to tune for when compiling the function.  If
4249 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4250 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4251 compilation tunes for the @var{CPU} architecture, and not the
4252 default tuning specified on the command line.
4253 @end table
4255 When compiling for Nios II, the following options are allowed:
4257 @table @samp
4258 @item custom-@var{insn}=@var{N}
4259 @itemx no-custom-@var{insn}
4260 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4261 @cindex @code{target("no-custom-@var{insn}")} attribute
4262 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4263 custom instruction with encoding @var{N} when generating code that uses 
4264 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4265 the custom instruction @var{insn}.
4266 These target attributes correspond to the
4267 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4268 command-line options, and support the same set of @var{insn} keywords.
4269 @xref{Nios II Options}, for more information.
4271 @item custom-fpu-cfg=@var{name}
4272 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4273 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4274 command-line option, to select a predefined set of custom instructions
4275 named @var{name}.
4276 @xref{Nios II Options}, for more information.
4277 @end table
4279 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4280 function that has different target options than the caller, unless the
4281 callee has a subset of the target options of the caller.  For example
4282 a function declared with @code{target("sse3")} can inline a function
4283 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4285 @item tiny_data
4286 @cindex tiny data section on the H8/300H and H8S
4287 Use this attribute on the H8/300H and H8S to indicate that the specified
4288 variable should be placed into the tiny data section.
4289 The compiler generates more efficient code for loads and stores
4290 on data in the tiny data section.  Note the tiny data area is limited to
4291 slightly under 32KB of data.
4293 @item trap_exit
4294 @cindex @code{trap_exit} attribute
4295 Use this attribute on the SH for an @code{interrupt_handler} to return using
4296 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4297 argument specifying the trap number to be used.
4299 @item trapa_handler
4300 @cindex @code{trapa_handler} attribute
4301 On SH targets this function attribute is similar to @code{interrupt_handler}
4302 but it does not save and restore all registers.
4304 @item unused
4305 @cindex @code{unused} attribute.
4306 This attribute, attached to a function, means that the function is meant
4307 to be possibly unused.  GCC does not produce a warning for this
4308 function.
4310 @item used
4311 @cindex @code{used} attribute.
4312 This attribute, attached to a function, means that code must be emitted
4313 for the function even if it appears that the function is not referenced.
4314 This is useful, for example, when the function is referenced only in
4315 inline assembly.
4317 When applied to a member function of a C++ class template, the
4318 attribute also means that the function is instantiated if the
4319 class itself is instantiated.
4321 @item vector
4322 @cindex @code{vector} attribute
4323 This RX attribute is similar to the @code{interrupt} attribute, including its
4324 parameters, but does not make the function an interrupt-handler type
4325 function (i.e. it retains the normal C function calling ABI).  See the
4326 @code{interrupt} attribute for a description of its arguments.
4328 @item version_id
4329 @cindex @code{version_id} attribute
4330 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4331 symbol to contain a version string, thus allowing for function level
4332 versioning.  HP-UX system header files may use function level versioning
4333 for some system calls.
4335 @smallexample
4336 extern int foo () __attribute__((version_id ("20040821")));
4337 @end smallexample
4339 @noindent
4340 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4342 @item visibility ("@var{visibility_type}")
4343 @cindex @code{visibility} attribute
4344 This attribute affects the linkage of the declaration to which it is attached.
4345 There are four supported @var{visibility_type} values: default,
4346 hidden, protected or internal visibility.
4348 @smallexample
4349 void __attribute__ ((visibility ("protected")))
4350 f () @{ /* @r{Do something.} */; @}
4351 int i __attribute__ ((visibility ("hidden")));
4352 @end smallexample
4354 The possible values of @var{visibility_type} correspond to the
4355 visibility settings in the ELF gABI.
4357 @table @dfn
4358 @c keep this list of visibilities in alphabetical order.
4360 @item default
4361 Default visibility is the normal case for the object file format.
4362 This value is available for the visibility attribute to override other
4363 options that may change the assumed visibility of entities.
4365 On ELF, default visibility means that the declaration is visible to other
4366 modules and, in shared libraries, means that the declared entity may be
4367 overridden.
4369 On Darwin, default visibility means that the declaration is visible to
4370 other modules.
4372 Default visibility corresponds to ``external linkage'' in the language.
4374 @item hidden
4375 Hidden visibility indicates that the entity declared has a new
4376 form of linkage, which we call ``hidden linkage''.  Two
4377 declarations of an object with hidden linkage refer to the same object
4378 if they are in the same shared object.
4380 @item internal
4381 Internal visibility is like hidden visibility, but with additional
4382 processor specific semantics.  Unless otherwise specified by the
4383 psABI, GCC defines internal visibility to mean that a function is
4384 @emph{never} called from another module.  Compare this with hidden
4385 functions which, while they cannot be referenced directly by other
4386 modules, can be referenced indirectly via function pointers.  By
4387 indicating that a function cannot be called from outside the module,
4388 GCC may for instance omit the load of a PIC register since it is known
4389 that the calling function loaded the correct value.
4391 @item protected
4392 Protected visibility is like default visibility except that it
4393 indicates that references within the defining module bind to the
4394 definition in that module.  That is, the declared entity cannot be
4395 overridden by another module.
4397 @end table
4399 All visibilities are supported on many, but not all, ELF targets
4400 (supported when the assembler supports the @samp{.visibility}
4401 pseudo-op).  Default visibility is supported everywhere.  Hidden
4402 visibility is supported on Darwin targets.
4404 The visibility attribute should be applied only to declarations that
4405 would otherwise have external linkage.  The attribute should be applied
4406 consistently, so that the same entity should not be declared with
4407 different settings of the attribute.
4409 In C++, the visibility attribute applies to types as well as functions
4410 and objects, because in C++ types have linkage.  A class must not have
4411 greater visibility than its non-static data member types and bases,
4412 and class members default to the visibility of their class.  Also, a
4413 declaration without explicit visibility is limited to the visibility
4414 of its type.
4416 In C++, you can mark member functions and static member variables of a
4417 class with the visibility attribute.  This is useful if you know a
4418 particular method or static member variable should only be used from
4419 one shared object; then you can mark it hidden while the rest of the
4420 class has default visibility.  Care must be taken to avoid breaking
4421 the One Definition Rule; for example, it is usually not useful to mark
4422 an inline method as hidden without marking the whole class as hidden.
4424 A C++ namespace declaration can also have the visibility attribute.
4426 @smallexample
4427 namespace nspace1 __attribute__ ((visibility ("protected")))
4428 @{ /* @r{Do something.} */; @}
4429 @end smallexample
4431 This attribute applies only to the particular namespace body, not to
4432 other definitions of the same namespace; it is equivalent to using
4433 @samp{#pragma GCC visibility} before and after the namespace
4434 definition (@pxref{Visibility Pragmas}).
4436 In C++, if a template argument has limited visibility, this
4437 restriction is implicitly propagated to the template instantiation.
4438 Otherwise, template instantiations and specializations default to the
4439 visibility of their template.
4441 If both the template and enclosing class have explicit visibility, the
4442 visibility from the template is used.
4444 @item vliw
4445 @cindex @code{vliw} attribute
4446 On MeP, the @code{vliw} attribute tells the compiler to emit
4447 instructions in VLIW mode instead of core mode.  Note that this
4448 attribute is not allowed unless a VLIW coprocessor has been configured
4449 and enabled through command-line options.
4451 @item warn_unused_result
4452 @cindex @code{warn_unused_result} attribute
4453 The @code{warn_unused_result} attribute causes a warning to be emitted
4454 if a caller of the function with this attribute does not use its
4455 return value.  This is useful for functions where not checking
4456 the result is either a security problem or always a bug, such as
4457 @code{realloc}.
4459 @smallexample
4460 int fn () __attribute__ ((warn_unused_result));
4461 int foo ()
4463   if (fn () < 0) return -1;
4464   fn ();
4465   return 0;
4467 @end smallexample
4469 @noindent
4470 results in warning on line 5.
4472 @item weak
4473 @cindex @code{weak} attribute
4474 The @code{weak} attribute causes the declaration to be emitted as a weak
4475 symbol rather than a global.  This is primarily useful in defining
4476 library functions that can be overridden in user code, though it can
4477 also be used with non-function declarations.  Weak symbols are supported
4478 for ELF targets, and also for a.out targets when using the GNU assembler
4479 and linker.
4481 @item weakref
4482 @itemx weakref ("@var{target}")
4483 @cindex @code{weakref} attribute
4484 The @code{weakref} attribute marks a declaration as a weak reference.
4485 Without arguments, it should be accompanied by an @code{alias} attribute
4486 naming the target symbol.  Optionally, the @var{target} may be given as
4487 an argument to @code{weakref} itself.  In either case, @code{weakref}
4488 implicitly marks the declaration as @code{weak}.  Without a
4489 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4490 @code{weakref} is equivalent to @code{weak}.
4492 @smallexample
4493 static int x() __attribute__ ((weakref ("y")));
4494 /* is equivalent to... */
4495 static int x() __attribute__ ((weak, weakref, alias ("y")));
4496 /* and to... */
4497 static int x() __attribute__ ((weakref));
4498 static int x() __attribute__ ((alias ("y")));
4499 @end smallexample
4501 A weak reference is an alias that does not by itself require a
4502 definition to be given for the target symbol.  If the target symbol is
4503 only referenced through weak references, then it becomes a @code{weak}
4504 undefined symbol.  If it is directly referenced, however, then such
4505 strong references prevail, and a definition is required for the
4506 symbol, not necessarily in the same translation unit.
4508 The effect is equivalent to moving all references to the alias to a
4509 separate translation unit, renaming the alias to the aliased symbol,
4510 declaring it as weak, compiling the two separate translation units and
4511 performing a reloadable link on them.
4513 At present, a declaration to which @code{weakref} is attached can
4514 only be @code{static}.
4516 @end table
4518 You can specify multiple attributes in a declaration by separating them
4519 by commas within the double parentheses or by immediately following an
4520 attribute declaration with another attribute declaration.
4522 @cindex @code{#pragma}, reason for not using
4523 @cindex pragma, reason for not using
4524 Some people object to the @code{__attribute__} feature, suggesting that
4525 ISO C's @code{#pragma} should be used instead.  At the time
4526 @code{__attribute__} was designed, there were two reasons for not doing
4527 this.
4529 @enumerate
4530 @item
4531 It is impossible to generate @code{#pragma} commands from a macro.
4533 @item
4534 There is no telling what the same @code{#pragma} might mean in another
4535 compiler.
4536 @end enumerate
4538 These two reasons applied to almost any application that might have been
4539 proposed for @code{#pragma}.  It was basically a mistake to use
4540 @code{#pragma} for @emph{anything}.
4542 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4543 to be generated from macros.  In addition, a @code{#pragma GCC}
4544 namespace is now in use for GCC-specific pragmas.  However, it has been
4545 found convenient to use @code{__attribute__} to achieve a natural
4546 attachment of attributes to their corresponding declarations, whereas
4547 @code{#pragma GCC} is of use for constructs that do not naturally form
4548 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4550 @node Label Attributes
4551 @section Label Attributes
4552 @cindex Label Attributes
4554 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4555 details of the exact syntax for using attributes.  Other attributes are 
4556 available for functions (@pxref{Function Attributes}), variables 
4557 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4559 This example uses the @code{cold} label attribute to indicate the 
4560 @code{ErrorHandling} branch is unlikely to be taken and that the
4561 @code{ErrorHandling} label is unused:
4563 @smallexample
4565    asm goto ("some asm" : : : : NoError);
4567 /* This branch (the fallthru from the asm) is less commonly used */
4568 ErrorHandling: 
4569    __attribute__((cold, unused)); /* Semi-colon is required here */
4570    printf("error\n");
4571    return 0;
4573 NoError:
4574    printf("no error\n");
4575    return 1;
4576 @end smallexample
4578 @table @code
4579 @item unused
4580 @cindex @code{unused} label attribute
4581 This feature is intended for program-generated code that may contain 
4582 unused labels, but which is compiled with @option{-Wall}.  It is
4583 not normally appropriate to use in it human-written code, though it
4584 could be useful in cases where the code that jumps to the label is
4585 contained within an @code{#ifdef} conditional.
4587 @item hot
4588 @cindex @code{hot} label attribute
4589 The @code{hot} attribute on a label is used to inform the compiler that
4590 the path following the label is more likely than paths that are not so
4591 annotated.  This attribute is used in cases where @code{__builtin_expect}
4592 cannot be used, for instance with computed goto or @code{asm goto}.
4594 The @code{hot} attribute on labels is not implemented in GCC versions
4595 earlier than 4.8.
4597 @item cold
4598 @cindex @code{cold} label attribute
4599 The @code{cold} attribute on labels is used to inform the compiler that
4600 the path following the label is unlikely to be executed.  This attribute
4601 is used in cases where @code{__builtin_expect} cannot be used, for instance
4602 with computed goto or @code{asm goto}.
4604 The @code{cold} attribute on labels is not implemented in GCC versions
4605 earlier than 4.8.
4607 @end table
4609 @node Attribute Syntax
4610 @section Attribute Syntax
4611 @cindex attribute syntax
4613 This section describes the syntax with which @code{__attribute__} may be
4614 used, and the constructs to which attribute specifiers bind, for the C
4615 language.  Some details may vary for C++ and Objective-C@.  Because of
4616 infelicities in the grammar for attributes, some forms described here
4617 may not be successfully parsed in all cases.
4619 There are some problems with the semantics of attributes in C++.  For
4620 example, there are no manglings for attributes, although they may affect
4621 code generation, so problems may arise when attributed types are used in
4622 conjunction with templates or overloading.  Similarly, @code{typeid}
4623 does not distinguish between types with different attributes.  Support
4624 for attributes in C++ may be restricted in future to attributes on
4625 declarations only, but not on nested declarators.
4627 @xref{Function Attributes}, for details of the semantics of attributes
4628 applying to functions.  @xref{Variable Attributes}, for details of the
4629 semantics of attributes applying to variables.  @xref{Type Attributes},
4630 for details of the semantics of attributes applying to structure, union
4631 and enumerated types.
4632 @xref{Label Attributes}, for details of the semantics of attributes 
4633 applying to labels.
4635 An @dfn{attribute specifier} is of the form
4636 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4637 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4638 each attribute is one of the following:
4640 @itemize @bullet
4641 @item
4642 Empty.  Empty attributes are ignored.
4644 @item
4645 A word (which may be an identifier such as @code{unused}, or a reserved
4646 word such as @code{const}).
4648 @item
4649 A word, followed by, in parentheses, parameters for the attribute.
4650 These parameters take one of the following forms:
4652 @itemize @bullet
4653 @item
4654 An identifier.  For example, @code{mode} attributes use this form.
4656 @item
4657 An identifier followed by a comma and a non-empty comma-separated list
4658 of expressions.  For example, @code{format} attributes use this form.
4660 @item
4661 A possibly empty comma-separated list of expressions.  For example,
4662 @code{format_arg} attributes use this form with the list being a single
4663 integer constant expression, and @code{alias} attributes use this form
4664 with the list being a single string constant.
4665 @end itemize
4666 @end itemize
4668 An @dfn{attribute specifier list} is a sequence of one or more attribute
4669 specifiers, not separated by any other tokens.
4671 @subsubheading Label Attributes
4673 In GNU C, an attribute specifier list may appear after the colon following a
4674 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4675 attributes on labels if the attribute specifier is immediately
4676 followed by a semicolon (i.e., the label applies to an empty
4677 statement).  If the semicolon is missing, C++ label attributes are
4678 ambiguous, as it is permissible for a declaration, which could begin
4679 with an attribute list, to be labelled in C++.  Declarations cannot be
4680 labelled in C90 or C99, so the ambiguity does not arise there.
4682 @subsubheading Type Attributes
4684 An attribute specifier list may appear as part of a @code{struct},
4685 @code{union} or @code{enum} specifier.  It may go either immediately
4686 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4687 the closing brace.  The former syntax is preferred.
4688 Where attribute specifiers follow the closing brace, they are considered
4689 to relate to the structure, union or enumerated type defined, not to any
4690 enclosing declaration the type specifier appears in, and the type
4691 defined is not complete until after the attribute specifiers.
4692 @c Otherwise, there would be the following problems: a shift/reduce
4693 @c conflict between attributes binding the struct/union/enum and
4694 @c binding to the list of specifiers/qualifiers; and "aligned"
4695 @c attributes could use sizeof for the structure, but the size could be
4696 @c changed later by "packed" attributes.
4699 @subsubheading All other attributes
4701 Otherwise, an attribute specifier appears as part of a declaration,
4702 counting declarations of unnamed parameters and type names, and relates
4703 to that declaration (which may be nested in another declaration, for
4704 example in the case of a parameter declaration), or to a particular declarator
4705 within a declaration.  Where an
4706 attribute specifier is applied to a parameter declared as a function or
4707 an array, it should apply to the function or array rather than the
4708 pointer to which the parameter is implicitly converted, but this is not
4709 yet correctly implemented.
4711 Any list of specifiers and qualifiers at the start of a declaration may
4712 contain attribute specifiers, whether or not such a list may in that
4713 context contain storage class specifiers.  (Some attributes, however,
4714 are essentially in the nature of storage class specifiers, and only make
4715 sense where storage class specifiers may be used; for example,
4716 @code{section}.)  There is one necessary limitation to this syntax: the
4717 first old-style parameter declaration in a function definition cannot
4718 begin with an attribute specifier, because such an attribute applies to
4719 the function instead by syntax described below (which, however, is not
4720 yet implemented in this case).  In some other cases, attribute
4721 specifiers are permitted by this grammar but not yet supported by the
4722 compiler.  All attribute specifiers in this place relate to the
4723 declaration as a whole.  In the obsolescent usage where a type of
4724 @code{int} is implied by the absence of type specifiers, such a list of
4725 specifiers and qualifiers may be an attribute specifier list with no
4726 other specifiers or qualifiers.
4728 At present, the first parameter in a function prototype must have some
4729 type specifier that is not an attribute specifier; this resolves an
4730 ambiguity in the interpretation of @code{void f(int
4731 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4732 the parentheses of a function declarator contain only attributes then
4733 those attributes are ignored, rather than yielding an error or warning
4734 or implying a single parameter of type int, but this is subject to
4735 change.
4737 An attribute specifier list may appear immediately before a declarator
4738 (other than the first) in a comma-separated list of declarators in a
4739 declaration of more than one identifier using a single list of
4740 specifiers and qualifiers.  Such attribute specifiers apply
4741 only to the identifier before whose declarator they appear.  For
4742 example, in
4744 @smallexample
4745 __attribute__((noreturn)) void d0 (void),
4746     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4747      d2 (void)
4748 @end smallexample
4750 @noindent
4751 the @code{noreturn} attribute applies to all the functions
4752 declared; the @code{format} attribute only applies to @code{d1}.
4754 An attribute specifier list may appear immediately before the comma,
4755 @code{=} or semicolon terminating the declaration of an identifier other
4756 than a function definition.  Such attribute specifiers apply
4757 to the declared object or function.  Where an
4758 assembler name for an object or function is specified (@pxref{Asm
4759 Labels}), the attribute must follow the @code{asm}
4760 specification.
4762 An attribute specifier list may, in future, be permitted to appear after
4763 the declarator in a function definition (before any old-style parameter
4764 declarations or the function body).
4766 Attribute specifiers may be mixed with type qualifiers appearing inside
4767 the @code{[]} of a parameter array declarator, in the C99 construct by
4768 which such qualifiers are applied to the pointer to which the array is
4769 implicitly converted.  Such attribute specifiers apply to the pointer,
4770 not to the array, but at present this is not implemented and they are
4771 ignored.
4773 An attribute specifier list may appear at the start of a nested
4774 declarator.  At present, there are some limitations in this usage: the
4775 attributes correctly apply to the declarator, but for most individual
4776 attributes the semantics this implies are not implemented.
4777 When attribute specifiers follow the @code{*} of a pointer
4778 declarator, they may be mixed with any type qualifiers present.
4779 The following describes the formal semantics of this syntax.  It makes the
4780 most sense if you are familiar with the formal specification of
4781 declarators in the ISO C standard.
4783 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4784 D1}, where @code{T} contains declaration specifiers that specify a type
4785 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4786 contains an identifier @var{ident}.  The type specified for @var{ident}
4787 for derived declarators whose type does not include an attribute
4788 specifier is as in the ISO C standard.
4790 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4791 and the declaration @code{T D} specifies the type
4792 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4793 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4794 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4796 If @code{D1} has the form @code{*
4797 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4798 declaration @code{T D} specifies the type
4799 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4800 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4801 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4802 @var{ident}.
4804 For example,
4806 @smallexample
4807 void (__attribute__((noreturn)) ****f) (void);
4808 @end smallexample
4810 @noindent
4811 specifies the type ``pointer to pointer to pointer to pointer to
4812 non-returning function returning @code{void}''.  As another example,
4814 @smallexample
4815 char *__attribute__((aligned(8))) *f;
4816 @end smallexample
4818 @noindent
4819 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4820 Note again that this does not work with most attributes; for example,
4821 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4822 is not yet supported.
4824 For compatibility with existing code written for compiler versions that
4825 did not implement attributes on nested declarators, some laxity is
4826 allowed in the placing of attributes.  If an attribute that only applies
4827 to types is applied to a declaration, it is treated as applying to
4828 the type of that declaration.  If an attribute that only applies to
4829 declarations is applied to the type of a declaration, it is treated
4830 as applying to that declaration; and, for compatibility with code
4831 placing the attributes immediately before the identifier declared, such
4832 an attribute applied to a function return type is treated as
4833 applying to the function type, and such an attribute applied to an array
4834 element type is treated as applying to the array type.  If an
4835 attribute that only applies to function types is applied to a
4836 pointer-to-function type, it is treated as applying to the pointer
4837 target type; if such an attribute is applied to a function return type
4838 that is not a pointer-to-function type, it is treated as applying
4839 to the function type.
4841 @node Function Prototypes
4842 @section Prototypes and Old-Style Function Definitions
4843 @cindex function prototype declarations
4844 @cindex old-style function definitions
4845 @cindex promotion of formal parameters
4847 GNU C extends ISO C to allow a function prototype to override a later
4848 old-style non-prototype definition.  Consider the following example:
4850 @smallexample
4851 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4852 #ifdef __STDC__
4853 #define P(x) x
4854 #else
4855 #define P(x) ()
4856 #endif
4858 /* @r{Prototype function declaration.}  */
4859 int isroot P((uid_t));
4861 /* @r{Old-style function definition.}  */
4863 isroot (x)   /* @r{??? lossage here ???} */
4864      uid_t x;
4866   return x == 0;
4868 @end smallexample
4870 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4871 not allow this example, because subword arguments in old-style
4872 non-prototype definitions are promoted.  Therefore in this example the
4873 function definition's argument is really an @code{int}, which does not
4874 match the prototype argument type of @code{short}.
4876 This restriction of ISO C makes it hard to write code that is portable
4877 to traditional C compilers, because the programmer does not know
4878 whether the @code{uid_t} type is @code{short}, @code{int}, or
4879 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4880 to override a later old-style definition.  More precisely, in GNU C, a
4881 function prototype argument type overrides the argument type specified
4882 by a later old-style definition if the former type is the same as the
4883 latter type before promotion.  Thus in GNU C the above example is
4884 equivalent to the following:
4886 @smallexample
4887 int isroot (uid_t);
4890 isroot (uid_t x)
4892   return x == 0;
4894 @end smallexample
4896 @noindent
4897 GNU C++ does not support old-style function definitions, so this
4898 extension is irrelevant.
4900 @node C++ Comments
4901 @section C++ Style Comments
4902 @cindex @code{//}
4903 @cindex C++ comments
4904 @cindex comments, C++ style
4906 In GNU C, you may use C++ style comments, which start with @samp{//} and
4907 continue until the end of the line.  Many other C implementations allow
4908 such comments, and they are included in the 1999 C standard.  However,
4909 C++ style comments are not recognized if you specify an @option{-std}
4910 option specifying a version of ISO C before C99, or @option{-ansi}
4911 (equivalent to @option{-std=c90}).
4913 @node Dollar Signs
4914 @section Dollar Signs in Identifier Names
4915 @cindex $
4916 @cindex dollar signs in identifier names
4917 @cindex identifier names, dollar signs in
4919 In GNU C, you may normally use dollar signs in identifier names.
4920 This is because many traditional C implementations allow such identifiers.
4921 However, dollar signs in identifiers are not supported on a few target
4922 machines, typically because the target assembler does not allow them.
4924 @node Character Escapes
4925 @section The Character @key{ESC} in Constants
4927 You can use the sequence @samp{\e} in a string or character constant to
4928 stand for the ASCII character @key{ESC}.
4930 @node Variable Attributes
4931 @section Specifying Attributes of Variables
4932 @cindex attribute of variables
4933 @cindex variable attributes
4935 The keyword @code{__attribute__} allows you to specify special
4936 attributes of variables or structure fields.  This keyword is followed
4937 by an attribute specification inside double parentheses.  Some
4938 attributes are currently defined generically for variables.
4939 Other attributes are defined for variables on particular target
4940 systems.  Other attributes are available for functions
4941 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4942 types (@pxref{Type Attributes}).
4943 Other front ends might define more attributes
4944 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4946 You may also specify attributes with @samp{__} preceding and following
4947 each keyword.  This allows you to use them in header files without
4948 being concerned about a possible macro of the same name.  For example,
4949 you may use @code{__aligned__} instead of @code{aligned}.
4951 @xref{Attribute Syntax}, for details of the exact syntax for using
4952 attributes.
4954 @table @code
4955 @cindex @code{aligned} attribute
4956 @item aligned (@var{alignment})
4957 This attribute specifies a minimum alignment for the variable or
4958 structure field, measured in bytes.  For example, the declaration:
4960 @smallexample
4961 int x __attribute__ ((aligned (16))) = 0;
4962 @end smallexample
4964 @noindent
4965 causes the compiler to allocate the global variable @code{x} on a
4966 16-byte boundary.  On a 68040, this could be used in conjunction with
4967 an @code{asm} expression to access the @code{move16} instruction which
4968 requires 16-byte aligned operands.
4970 You can also specify the alignment of structure fields.  For example, to
4971 create a double-word aligned @code{int} pair, you could write:
4973 @smallexample
4974 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4975 @end smallexample
4977 @noindent
4978 This is an alternative to creating a union with a @code{double} member,
4979 which forces the union to be double-word aligned.
4981 As in the preceding examples, you can explicitly specify the alignment
4982 (in bytes) that you wish the compiler to use for a given variable or
4983 structure field.  Alternatively, you can leave out the alignment factor
4984 and just ask the compiler to align a variable or field to the
4985 default alignment for the target architecture you are compiling for.
4986 The default alignment is sufficient for all scalar types, but may not be
4987 enough for all vector types on a target that supports vector operations.
4988 The default alignment is fixed for a particular target ABI.
4990 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4991 which is the largest alignment ever used for any data type on the
4992 target machine you are compiling for.  For example, you could write:
4994 @smallexample
4995 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4996 @end smallexample
4998 The compiler automatically sets the alignment for the declared
4999 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5000 often make copy operations more efficient, because the compiler can
5001 use whatever instructions copy the biggest chunks of memory when
5002 performing copies to or from the variables or fields that you have
5003 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5004 may change depending on command-line options.
5006 When used on a struct, or struct member, the @code{aligned} attribute can
5007 only increase the alignment; in order to decrease it, the @code{packed}
5008 attribute must be specified as well.  When used as part of a typedef, the
5009 @code{aligned} attribute can both increase and decrease alignment, and
5010 specifying the @code{packed} attribute generates a warning.
5012 Note that the effectiveness of @code{aligned} attributes may be limited
5013 by inherent limitations in your linker.  On many systems, the linker is
5014 only able to arrange for variables to be aligned up to a certain maximum
5015 alignment.  (For some linkers, the maximum supported alignment may
5016 be very very small.)  If your linker is only able to align variables
5017 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5018 in an @code{__attribute__} still only provides you with 8-byte
5019 alignment.  See your linker documentation for further information.
5021 The @code{aligned} attribute can also be used for functions
5022 (@pxref{Function Attributes}.)
5024 @item cleanup (@var{cleanup_function})
5025 @cindex @code{cleanup} attribute
5026 The @code{cleanup} attribute runs a function when the variable goes
5027 out of scope.  This attribute can only be applied to auto function
5028 scope variables; it may not be applied to parameters or variables
5029 with static storage duration.  The function must take one parameter,
5030 a pointer to a type compatible with the variable.  The return value
5031 of the function (if any) is ignored.
5033 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5034 is run during the stack unwinding that happens during the
5035 processing of the exception.  Note that the @code{cleanup} attribute
5036 does not allow the exception to be caught, only to perform an action.
5037 It is undefined what happens if @var{cleanup_function} does not
5038 return normally.
5040 @item common
5041 @itemx nocommon
5042 @cindex @code{common} attribute
5043 @cindex @code{nocommon} attribute
5044 @opindex fcommon
5045 @opindex fno-common
5046 The @code{common} attribute requests GCC to place a variable in
5047 ``common'' storage.  The @code{nocommon} attribute requests the
5048 opposite---to allocate space for it directly.
5050 These attributes override the default chosen by the
5051 @option{-fno-common} and @option{-fcommon} flags respectively.
5053 @item deprecated
5054 @itemx deprecated (@var{msg})
5055 @cindex @code{deprecated} attribute
5056 The @code{deprecated} attribute results in a warning if the variable
5057 is used anywhere in the source file.  This is useful when identifying
5058 variables that are expected to be removed in a future version of a
5059 program.  The warning also includes the location of the declaration
5060 of the deprecated variable, to enable users to easily find further
5061 information about why the variable is deprecated, or what they should
5062 do instead.  Note that the warning only occurs for uses:
5064 @smallexample
5065 extern int old_var __attribute__ ((deprecated));
5066 extern int old_var;
5067 int new_fn () @{ return old_var; @}
5068 @end smallexample
5070 @noindent
5071 results in a warning on line 3 but not line 2.  The optional @var{msg}
5072 argument, which must be a string, is printed in the warning if
5073 present.
5075 The @code{deprecated} attribute can also be used for functions and
5076 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5078 @item mode (@var{mode})
5079 @cindex @code{mode} attribute
5080 This attribute specifies the data type for the declaration---whichever
5081 type corresponds to the mode @var{mode}.  This in effect lets you
5082 request an integer or floating-point type according to its width.
5084 You may also specify a mode of @code{byte} or @code{__byte__} to
5085 indicate the mode corresponding to a one-byte integer, @code{word} or
5086 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5087 or @code{__pointer__} for the mode used to represent pointers.
5089 @item packed
5090 @cindex @code{packed} attribute
5091 The @code{packed} attribute specifies that a variable or structure field
5092 should have the smallest possible alignment---one byte for a variable,
5093 and one bit for a field, unless you specify a larger value with the
5094 @code{aligned} attribute.
5096 Here is a structure in which the field @code{x} is packed, so that it
5097 immediately follows @code{a}:
5099 @smallexample
5100 struct foo
5102   char a;
5103   int x[2] __attribute__ ((packed));
5105 @end smallexample
5107 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5108 @code{packed} attribute on bit-fields of type @code{char}.  This has
5109 been fixed in GCC 4.4 but the change can lead to differences in the
5110 structure layout.  See the documentation of
5111 @option{-Wpacked-bitfield-compat} for more information.
5113 @item section ("@var{section-name}")
5114 @cindex @code{section} variable attribute
5115 Normally, the compiler places the objects it generates in sections like
5116 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5117 or you need certain particular variables to appear in special sections,
5118 for example to map to special hardware.  The @code{section}
5119 attribute specifies that a variable (or function) lives in a particular
5120 section.  For example, this small program uses several specific section names:
5122 @smallexample
5123 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5124 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5125 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5126 int init_data __attribute__ ((section ("INITDATA")));
5128 main()
5130   /* @r{Initialize stack pointer} */
5131   init_sp (stack + sizeof (stack));
5133   /* @r{Initialize initialized data} */
5134   memcpy (&init_data, &data, &edata - &data);
5136   /* @r{Turn on the serial ports} */
5137   init_duart (&a);
5138   init_duart (&b);
5140 @end smallexample
5142 @noindent
5143 Use the @code{section} attribute with
5144 @emph{global} variables and not @emph{local} variables,
5145 as shown in the example.
5147 You may use the @code{section} attribute with initialized or
5148 uninitialized global variables but the linker requires
5149 each object be defined once, with the exception that uninitialized
5150 variables tentatively go in the @code{common} (or @code{bss}) section
5151 and can be multiply ``defined''.  Using the @code{section} attribute
5152 changes what section the variable goes into and may cause the
5153 linker to issue an error if an uninitialized variable has multiple
5154 definitions.  You can force a variable to be initialized with the
5155 @option{-fno-common} flag or the @code{nocommon} attribute.
5157 Some file formats do not support arbitrary sections so the @code{section}
5158 attribute is not available on all platforms.
5159 If you need to map the entire contents of a module to a particular
5160 section, consider using the facilities of the linker instead.
5162 @item shared
5163 @cindex @code{shared} variable attribute
5164 On Microsoft Windows, in addition to putting variable definitions in a named
5165 section, the section can also be shared among all running copies of an
5166 executable or DLL@.  For example, this small program defines shared data
5167 by putting it in a named section @code{shared} and marking the section
5168 shareable:
5170 @smallexample
5171 int foo __attribute__((section ("shared"), shared)) = 0;
5174 main()
5176   /* @r{Read and write foo.  All running
5177      copies see the same value.}  */
5178   return 0;
5180 @end smallexample
5182 @noindent
5183 You may only use the @code{shared} attribute along with @code{section}
5184 attribute with a fully-initialized global definition because of the way
5185 linkers work.  See @code{section} attribute for more information.
5187 The @code{shared} attribute is only available on Microsoft Windows@.
5189 @item tls_model ("@var{tls_model}")
5190 @cindex @code{tls_model} attribute
5191 The @code{tls_model} attribute sets thread-local storage model
5192 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5193 overriding @option{-ftls-model=} command-line switch on a per-variable
5194 basis.
5195 The @var{tls_model} argument should be one of @code{global-dynamic},
5196 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5198 Not all targets support this attribute.
5200 @item unused
5201 This attribute, attached to a variable, means that the variable is meant
5202 to be possibly unused.  GCC does not produce a warning for this
5203 variable.
5205 @item used
5206 This attribute, attached to a variable with the static storage, means that
5207 the variable must be emitted even if it appears that the variable is not
5208 referenced.
5210 When applied to a static data member of a C++ class template, the
5211 attribute also means that the member is instantiated if the
5212 class itself is instantiated.
5214 @item vector_size (@var{bytes})
5215 This attribute specifies the vector size for the variable, measured in
5216 bytes.  For example, the declaration:
5218 @smallexample
5219 int foo __attribute__ ((vector_size (16)));
5220 @end smallexample
5222 @noindent
5223 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5224 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5225 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5227 This attribute is only applicable to integral and float scalars,
5228 although arrays, pointers, and function return values are allowed in
5229 conjunction with this construct.
5231 Aggregates with this attribute are invalid, even if they are of the same
5232 size as a corresponding scalar.  For example, the declaration:
5234 @smallexample
5235 struct S @{ int a; @};
5236 struct S  __attribute__ ((vector_size (16))) foo;
5237 @end smallexample
5239 @noindent
5240 is invalid even if the size of the structure is the same as the size of
5241 the @code{int}.
5243 @item selectany
5244 The @code{selectany} attribute causes an initialized global variable to
5245 have link-once semantics.  When multiple definitions of the variable are
5246 encountered by the linker, the first is selected and the remainder are
5247 discarded.  Following usage by the Microsoft compiler, the linker is told
5248 @emph{not} to warn about size or content differences of the multiple
5249 definitions.
5251 Although the primary usage of this attribute is for POD types, the
5252 attribute can also be applied to global C++ objects that are initialized
5253 by a constructor.  In this case, the static initialization and destruction
5254 code for the object is emitted in each translation defining the object,
5255 but the calls to the constructor and destructor are protected by a
5256 link-once guard variable.
5258 The @code{selectany} attribute is only available on Microsoft Windows
5259 targets.  You can use @code{__declspec (selectany)} as a synonym for
5260 @code{__attribute__ ((selectany))} for compatibility with other
5261 compilers.
5263 @item weak
5264 The @code{weak} attribute is described in @ref{Function Attributes}.
5266 @item dllimport
5267 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5269 @item dllexport
5270 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5272 @end table
5274 @anchor{AVR Variable Attributes}
5275 @subsection AVR Variable Attributes
5277 @table @code
5278 @item progmem
5279 @cindex @code{progmem} AVR variable attribute
5280 The @code{progmem} attribute is used on the AVR to place read-only
5281 data in the non-volatile program memory (flash). The @code{progmem}
5282 attribute accomplishes this by putting respective variables into a
5283 section whose name starts with @code{.progmem}.
5285 This attribute works similar to the @code{section} attribute
5286 but adds additional checking. Notice that just like the
5287 @code{section} attribute, @code{progmem} affects the location
5288 of the data but not how this data is accessed.
5290 In order to read data located with the @code{progmem} attribute
5291 (inline) assembler must be used.
5292 @smallexample
5293 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5294 #include <avr/pgmspace.h> 
5296 /* Locate var in flash memory */
5297 const int var[2] PROGMEM = @{ 1, 2 @};
5299 int read_var (int i)
5301     /* Access var[] by accessor macro from avr/pgmspace.h */
5302     return (int) pgm_read_word (& var[i]);
5304 @end smallexample
5306 AVR is a Harvard architecture processor and data and read-only data
5307 normally resides in the data memory (RAM).
5309 See also the @ref{AVR Named Address Spaces} section for
5310 an alternate way to locate and access data in flash memory.
5311 @end table
5313 @subsection Blackfin Variable Attributes
5315 Three attributes are currently defined for the Blackfin.
5317 @table @code
5318 @item l1_data
5319 @itemx l1_data_A
5320 @itemx l1_data_B
5321 @cindex @code{l1_data} variable attribute
5322 @cindex @code{l1_data_A} variable attribute
5323 @cindex @code{l1_data_B} variable attribute
5324 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5325 Variables with @code{l1_data} attribute are put into the specific section
5326 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5327 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5328 attribute are put into the specific section named @code{.l1.data.B}.
5330 @item l2
5331 @cindex @code{l2} variable attribute
5332 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5333 Variables with @code{l2} attribute are put into the specific section
5334 named @code{.l2.data}.
5335 @end table
5337 @subsection M32R/D Variable Attributes
5339 One attribute is currently defined for the M32R/D@.
5341 @table @code
5342 @item model (@var{model-name})
5343 @cindex variable addressability on the M32R/D
5344 Use this attribute on the M32R/D to set the addressability of an object.
5345 The identifier @var{model-name} is one of @code{small}, @code{medium},
5346 or @code{large}, representing each of the code models.
5348 Small model objects live in the lower 16MB of memory (so that their
5349 addresses can be loaded with the @code{ld24} instruction).
5351 Medium and large model objects may live anywhere in the 32-bit address space
5352 (the compiler generates @code{seth/add3} instructions to load their
5353 addresses).
5354 @end table
5356 @anchor{MeP Variable Attributes}
5357 @subsection MeP Variable Attributes
5359 The MeP target has a number of addressing modes and busses.  The
5360 @code{near} space spans the standard memory space's first 16 megabytes
5361 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5362 The @code{based} space is a 128-byte region in the memory space that
5363 is addressed relative to the @code{$tp} register.  The @code{tiny}
5364 space is a 65536-byte region relative to the @code{$gp} register.  In
5365 addition to these memory regions, the MeP target has a separate 16-bit
5366 control bus which is specified with @code{cb} attributes.
5368 @table @code
5370 @item based
5371 Any variable with the @code{based} attribute is assigned to the
5372 @code{.based} section, and is accessed with relative to the
5373 @code{$tp} register.
5375 @item tiny
5376 Likewise, the @code{tiny} attribute assigned variables to the
5377 @code{.tiny} section, relative to the @code{$gp} register.
5379 @item near
5380 Variables with the @code{near} attribute are assumed to have addresses
5381 that fit in a 24-bit addressing mode.  This is the default for large
5382 variables (@code{-mtiny=4} is the default) but this attribute can
5383 override @code{-mtiny=} for small variables, or override @code{-ml}.
5385 @item far
5386 Variables with the @code{far} attribute are addressed using a full
5387 32-bit address.  Since this covers the entire memory space, this
5388 allows modules to make no assumptions about where variables might be
5389 stored.
5391 @item io
5392 @itemx io (@var{addr})
5393 Variables with the @code{io} attribute are used to address
5394 memory-mapped peripherals.  If an address is specified, the variable
5395 is assigned that address, else it is not assigned an address (it is
5396 assumed some other module assigns an address).  Example:
5398 @smallexample
5399 int timer_count __attribute__((io(0x123)));
5400 @end smallexample
5402 @item cb
5403 @itemx cb (@var{addr})
5404 Variables with the @code{cb} attribute are used to access the control
5405 bus, using special instructions.  @code{addr} indicates the control bus
5406 address.  Example:
5408 @smallexample
5409 int cpu_clock __attribute__((cb(0x123)));
5410 @end smallexample
5412 @end table
5414 @anchor{i386 Variable Attributes}
5415 @subsection i386 Variable Attributes
5417 Two attributes are currently defined for i386 configurations:
5418 @code{ms_struct} and @code{gcc_struct}
5420 @table @code
5421 @item ms_struct
5422 @itemx gcc_struct
5423 @cindex @code{ms_struct} attribute
5424 @cindex @code{gcc_struct} attribute
5426 If @code{packed} is used on a structure, or if bit-fields are used,
5427 it may be that the Microsoft ABI lays out the structure differently
5428 than the way GCC normally does.  Particularly when moving packed
5429 data between functions compiled with GCC and the native Microsoft compiler
5430 (either via function call or as data in a file), it may be necessary to access
5431 either format.
5433 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5434 compilers to match the native Microsoft compiler.
5436 The Microsoft structure layout algorithm is fairly simple with the exception
5437 of the bit-field packing.  
5438 The padding and alignment of members of structures and whether a bit-field 
5439 can straddle a storage-unit boundary are determine by these rules:
5441 @enumerate
5442 @item Structure members are stored sequentially in the order in which they are
5443 declared: the first member has the lowest memory address and the last member
5444 the highest.
5446 @item Every data object has an alignment requirement.  The alignment requirement
5447 for all data except structures, unions, and arrays is either the size of the
5448 object or the current packing size (specified with either the
5449 @code{aligned} attribute or the @code{pack} pragma),
5450 whichever is less.  For structures, unions, and arrays,
5451 the alignment requirement is the largest alignment requirement of its members.
5452 Every object is allocated an offset so that:
5454 @smallexample
5455 offset % alignment_requirement == 0
5456 @end smallexample
5458 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5459 unit if the integral types are the same size and if the next bit-field fits
5460 into the current allocation unit without crossing the boundary imposed by the
5461 common alignment requirements of the bit-fields.
5462 @end enumerate
5464 MSVC interprets zero-length bit-fields in the following ways:
5466 @enumerate
5467 @item If a zero-length bit-field is inserted between two bit-fields that
5468 are normally coalesced, the bit-fields are not coalesced.
5470 For example:
5472 @smallexample
5473 struct
5474  @{
5475    unsigned long bf_1 : 12;
5476    unsigned long : 0;
5477    unsigned long bf_2 : 12;
5478  @} t1;
5479 @end smallexample
5481 @noindent
5482 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5483 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5485 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5486 alignment of the zero-length bit-field is greater than the member that follows it,
5487 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5489 For example:
5491 @smallexample
5492 struct
5493  @{
5494    char foo : 4;
5495    short : 0;
5496    char bar;
5497  @} t2;
5499 struct
5500  @{
5501    char foo : 4;
5502    short : 0;
5503    double bar;
5504  @} t3;
5505 @end smallexample
5507 @noindent
5508 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5509 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5510 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5511 of the structure.
5513 Taking this into account, it is important to note the following:
5515 @enumerate
5516 @item If a zero-length bit-field follows a normal bit-field, the type of the
5517 zero-length bit-field may affect the alignment of the structure as whole. For
5518 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5519 normal bit-field, and is of type short.
5521 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5522 still affect the alignment of the structure:
5524 @smallexample
5525 struct
5526  @{
5527    char foo : 6;
5528    long : 0;
5529  @} t4;
5530 @end smallexample
5532 @noindent
5533 Here, @code{t4} takes up 4 bytes.
5534 @end enumerate
5536 @item Zero-length bit-fields following non-bit-field members are ignored:
5538 @smallexample
5539 struct
5540  @{
5541    char foo;
5542    long : 0;
5543    char bar;
5544  @} t5;
5545 @end smallexample
5547 @noindent
5548 Here, @code{t5} takes up 2 bytes.
5549 @end enumerate
5550 @end table
5552 @subsection PowerPC Variable Attributes
5554 Three attributes currently are defined for PowerPC configurations:
5555 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5557 For full documentation of the struct attributes please see the
5558 documentation in @ref{i386 Variable Attributes}.
5560 For documentation of @code{altivec} attribute please see the
5561 documentation in @ref{PowerPC Type Attributes}.
5563 @subsection SPU Variable Attributes
5565 The SPU supports the @code{spu_vector} attribute for variables.  For
5566 documentation of this attribute please see the documentation in
5567 @ref{SPU Type Attributes}.
5569 @subsection Xstormy16 Variable Attributes
5571 One attribute is currently defined for xstormy16 configurations:
5572 @code{below100}.
5574 @table @code
5575 @item below100
5576 @cindex @code{below100} attribute
5578 If a variable has the @code{below100} attribute (@code{BELOW100} is
5579 allowed also), GCC places the variable in the first 0x100 bytes of
5580 memory and use special opcodes to access it.  Such variables are
5581 placed in either the @code{.bss_below100} section or the
5582 @code{.data_below100} section.
5584 @end table
5586 @node Type Attributes
5587 @section Specifying Attributes of Types
5588 @cindex attribute of types
5589 @cindex type attributes
5591 The keyword @code{__attribute__} allows you to specify special
5592 attributes of @code{struct} and @code{union} types when you define
5593 such types.  This keyword is followed by an attribute specification
5594 inside double parentheses.  Seven attributes are currently defined for
5595 types: @code{aligned}, @code{packed}, @code{transparent_union},
5596 @code{unused}, @code{deprecated}, @code{visibility}, and
5597 @code{may_alias}.  Other attributes are defined for functions
5598 (@pxref{Function Attributes}), labels (@pxref{Label 
5599 Attributes}) and for variables (@pxref{Variable Attributes}).
5601 You may also specify any one of these attributes with @samp{__}
5602 preceding and following its keyword.  This allows you to use these
5603 attributes in header files without being concerned about a possible
5604 macro of the same name.  For example, you may use @code{__aligned__}
5605 instead of @code{aligned}.
5607 You may specify type attributes in an enum, struct or union type
5608 declaration or definition, or for other types in a @code{typedef}
5609 declaration.
5611 For an enum, struct or union type, you may specify attributes either
5612 between the enum, struct or union tag and the name of the type, or
5613 just past the closing curly brace of the @emph{definition}.  The
5614 former syntax is preferred.
5616 @xref{Attribute Syntax}, for details of the exact syntax for using
5617 attributes.
5619 @table @code
5620 @cindex @code{aligned} attribute
5621 @item aligned (@var{alignment})
5622 This attribute specifies a minimum alignment (in bytes) for variables
5623 of the specified type.  For example, the declarations:
5625 @smallexample
5626 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5627 typedef int more_aligned_int __attribute__ ((aligned (8)));
5628 @end smallexample
5630 @noindent
5631 force the compiler to ensure (as far as it can) that each variable whose
5632 type is @code{struct S} or @code{more_aligned_int} is allocated and
5633 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5634 variables of type @code{struct S} aligned to 8-byte boundaries allows
5635 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5636 store) instructions when copying one variable of type @code{struct S} to
5637 another, thus improving run-time efficiency.
5639 Note that the alignment of any given @code{struct} or @code{union} type
5640 is required by the ISO C standard to be at least a perfect multiple of
5641 the lowest common multiple of the alignments of all of the members of
5642 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5643 effectively adjust the alignment of a @code{struct} or @code{union}
5644 type by attaching an @code{aligned} attribute to any one of the members
5645 of such a type, but the notation illustrated in the example above is a
5646 more obvious, intuitive, and readable way to request the compiler to
5647 adjust the alignment of an entire @code{struct} or @code{union} type.
5649 As in the preceding example, you can explicitly specify the alignment
5650 (in bytes) that you wish the compiler to use for a given @code{struct}
5651 or @code{union} type.  Alternatively, you can leave out the alignment factor
5652 and just ask the compiler to align a type to the maximum
5653 useful alignment for the target machine you are compiling for.  For
5654 example, you could write:
5656 @smallexample
5657 struct S @{ short f[3]; @} __attribute__ ((aligned));
5658 @end smallexample
5660 Whenever you leave out the alignment factor in an @code{aligned}
5661 attribute specification, the compiler automatically sets the alignment
5662 for the type to the largest alignment that is ever used for any data
5663 type on the target machine you are compiling for.  Doing this can often
5664 make copy operations more efficient, because the compiler can use
5665 whatever instructions copy the biggest chunks of memory when performing
5666 copies to or from the variables that have types that you have aligned
5667 this way.
5669 In the example above, if the size of each @code{short} is 2 bytes, then
5670 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5671 power of two that is greater than or equal to that is 8, so the
5672 compiler sets the alignment for the entire @code{struct S} type to 8
5673 bytes.
5675 Note that although you can ask the compiler to select a time-efficient
5676 alignment for a given type and then declare only individual stand-alone
5677 objects of that type, the compiler's ability to select a time-efficient
5678 alignment is primarily useful only when you plan to create arrays of
5679 variables having the relevant (efficiently aligned) type.  If you
5680 declare or use arrays of variables of an efficiently-aligned type, then
5681 it is likely that your program also does pointer arithmetic (or
5682 subscripting, which amounts to the same thing) on pointers to the
5683 relevant type, and the code that the compiler generates for these
5684 pointer arithmetic operations is often more efficient for
5685 efficiently-aligned types than for other types.
5687 The @code{aligned} attribute can only increase the alignment; but you
5688 can decrease it by specifying @code{packed} as well.  See below.
5690 Note that the effectiveness of @code{aligned} attributes may be limited
5691 by inherent limitations in your linker.  On many systems, the linker is
5692 only able to arrange for variables to be aligned up to a certain maximum
5693 alignment.  (For some linkers, the maximum supported alignment may
5694 be very very small.)  If your linker is only able to align variables
5695 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5696 in an @code{__attribute__} still only provides you with 8-byte
5697 alignment.  See your linker documentation for further information.
5699 @item packed
5700 This attribute, attached to @code{struct} or @code{union} type
5701 definition, specifies that each member (other than zero-width bit-fields)
5702 of the structure or union is placed to minimize the memory required.  When
5703 attached to an @code{enum} definition, it indicates that the smallest
5704 integral type should be used.
5706 @opindex fshort-enums
5707 Specifying this attribute for @code{struct} and @code{union} types is
5708 equivalent to specifying the @code{packed} attribute on each of the
5709 structure or union members.  Specifying the @option{-fshort-enums}
5710 flag on the line is equivalent to specifying the @code{packed}
5711 attribute on all @code{enum} definitions.
5713 In the following example @code{struct my_packed_struct}'s members are
5714 packed closely together, but the internal layout of its @code{s} member
5715 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5716 be packed too.
5718 @smallexample
5719 struct my_unpacked_struct
5720  @{
5721     char c;
5722     int i;
5723  @};
5725 struct __attribute__ ((__packed__)) my_packed_struct
5726   @{
5727      char c;
5728      int  i;
5729      struct my_unpacked_struct s;
5730   @};
5731 @end smallexample
5733 You may only specify this attribute on the definition of an @code{enum},
5734 @code{struct} or @code{union}, not on a @code{typedef} that does not
5735 also define the enumerated type, structure or union.
5737 @item transparent_union
5738 @cindex @code{transparent_union} attribute
5740 This attribute, attached to a @code{union} type definition, indicates
5741 that any function parameter having that union type causes calls to that
5742 function to be treated in a special way.
5744 First, the argument corresponding to a transparent union type can be of
5745 any type in the union; no cast is required.  Also, if the union contains
5746 a pointer type, the corresponding argument can be a null pointer
5747 constant or a void pointer expression; and if the union contains a void
5748 pointer type, the corresponding argument can be any pointer expression.
5749 If the union member type is a pointer, qualifiers like @code{const} on
5750 the referenced type must be respected, just as with normal pointer
5751 conversions.
5753 Second, the argument is passed to the function using the calling
5754 conventions of the first member of the transparent union, not the calling
5755 conventions of the union itself.  All members of the union must have the
5756 same machine representation; this is necessary for this argument passing
5757 to work properly.
5759 Transparent unions are designed for library functions that have multiple
5760 interfaces for compatibility reasons.  For example, suppose the
5761 @code{wait} function must accept either a value of type @code{int *} to
5762 comply with POSIX, or a value of type @code{union wait *} to comply with
5763 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5764 @code{wait} would accept both kinds of arguments, but it would also
5765 accept any other pointer type and this would make argument type checking
5766 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5767 as follows:
5769 @smallexample
5770 typedef union __attribute__ ((__transparent_union__))
5771   @{
5772     int *__ip;
5773     union wait *__up;
5774   @} wait_status_ptr_t;
5776 pid_t wait (wait_status_ptr_t);
5777 @end smallexample
5779 @noindent
5780 This interface allows either @code{int *} or @code{union wait *}
5781 arguments to be passed, using the @code{int *} calling convention.
5782 The program can call @code{wait} with arguments of either type:
5784 @smallexample
5785 int w1 () @{ int w; return wait (&w); @}
5786 int w2 () @{ union wait w; return wait (&w); @}
5787 @end smallexample
5789 @noindent
5790 With this interface, @code{wait}'s implementation might look like this:
5792 @smallexample
5793 pid_t wait (wait_status_ptr_t p)
5795   return waitpid (-1, p.__ip, 0);
5797 @end smallexample
5799 @item unused
5800 When attached to a type (including a @code{union} or a @code{struct}),
5801 this attribute means that variables of that type are meant to appear
5802 possibly unused.  GCC does not produce a warning for any variables of
5803 that type, even if the variable appears to do nothing.  This is often
5804 the case with lock or thread classes, which are usually defined and then
5805 not referenced, but contain constructors and destructors that have
5806 nontrivial bookkeeping functions.
5808 @item deprecated
5809 @itemx deprecated (@var{msg})
5810 The @code{deprecated} attribute results in a warning if the type
5811 is used anywhere in the source file.  This is useful when identifying
5812 types that are expected to be removed in a future version of a program.
5813 If possible, the warning also includes the location of the declaration
5814 of the deprecated type, to enable users to easily find further
5815 information about why the type is deprecated, or what they should do
5816 instead.  Note that the warnings only occur for uses and then only
5817 if the type is being applied to an identifier that itself is not being
5818 declared as deprecated.
5820 @smallexample
5821 typedef int T1 __attribute__ ((deprecated));
5822 T1 x;
5823 typedef T1 T2;
5824 T2 y;
5825 typedef T1 T3 __attribute__ ((deprecated));
5826 T3 z __attribute__ ((deprecated));
5827 @end smallexample
5829 @noindent
5830 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5831 warning is issued for line 4 because T2 is not explicitly
5832 deprecated.  Line 5 has no warning because T3 is explicitly
5833 deprecated.  Similarly for line 6.  The optional @var{msg}
5834 argument, which must be a string, is printed in the warning if
5835 present.
5837 The @code{deprecated} attribute can also be used for functions and
5838 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5840 @item may_alias
5841 Accesses through pointers to types with this attribute are not subject
5842 to type-based alias analysis, but are instead assumed to be able to alias
5843 any other type of objects.
5844 In the context of section 6.5 paragraph 7 of the C99 standard,
5845 an lvalue expression
5846 dereferencing such a pointer is treated like having a character type.
5847 See @option{-fstrict-aliasing} for more information on aliasing issues.
5848 This extension exists to support some vector APIs, in which pointers to
5849 one vector type are permitted to alias pointers to a different vector type.
5851 Note that an object of a type with this attribute does not have any
5852 special semantics.
5854 Example of use:
5856 @smallexample
5857 typedef short __attribute__((__may_alias__)) short_a;
5860 main (void)
5862   int a = 0x12345678;
5863   short_a *b = (short_a *) &a;
5865   b[1] = 0;
5867   if (a == 0x12345678)
5868     abort();
5870   exit(0);
5872 @end smallexample
5874 @noindent
5875 If you replaced @code{short_a} with @code{short} in the variable
5876 declaration, the above program would abort when compiled with
5877 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5878 above in recent GCC versions.
5880 @item visibility
5881 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5882 applied to class, struct, union and enum types.  Unlike other type
5883 attributes, the attribute must appear between the initial keyword and
5884 the name of the type; it cannot appear after the body of the type.
5886 Note that the type visibility is applied to vague linkage entities
5887 associated with the class (vtable, typeinfo node, etc.).  In
5888 particular, if a class is thrown as an exception in one shared object
5889 and caught in another, the class must have default visibility.
5890 Otherwise the two shared objects are unable to use the same
5891 typeinfo node and exception handling will break.
5893 @item designated_init
5894 This attribute may only be applied to structure types.  It indicates
5895 that any initialization of an object of this type must use designated
5896 initializers rather than positional initializers.  The intent of this
5897 attribute is to allow the programmer to indicate that a structure's
5898 layout may change, and that therefore relying on positional
5899 initialization will result in future breakage.
5901 GCC emits warnings based on this attribute by default; use
5902 @option{-Wno-designated-init} to suppress them.
5904 @end table
5906 To specify multiple attributes, separate them by commas within the
5907 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5908 packed))}.
5910 @subsection ARM Type Attributes
5912 On those ARM targets that support @code{dllimport} (such as Symbian
5913 OS), you can use the @code{notshared} attribute to indicate that the
5914 virtual table and other similar data for a class should not be
5915 exported from a DLL@.  For example:
5917 @smallexample
5918 class __declspec(notshared) C @{
5919 public:
5920   __declspec(dllimport) C();
5921   virtual void f();
5924 __declspec(dllexport)
5925 C::C() @{@}
5926 @end smallexample
5928 @noindent
5929 In this code, @code{C::C} is exported from the current DLL, but the
5930 virtual table for @code{C} is not exported.  (You can use
5931 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5932 most Symbian OS code uses @code{__declspec}.)
5934 @anchor{MeP Type Attributes}
5935 @subsection MeP Type Attributes
5937 Many of the MeP variable attributes may be applied to types as well.
5938 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5939 @code{far} attributes may be applied to either.  The @code{io} and
5940 @code{cb} attributes may not be applied to types.
5942 @anchor{i386 Type Attributes}
5943 @subsection i386 Type Attributes
5945 Two attributes are currently defined for i386 configurations:
5946 @code{ms_struct} and @code{gcc_struct}.
5948 @table @code
5950 @item ms_struct
5951 @itemx gcc_struct
5952 @cindex @code{ms_struct}
5953 @cindex @code{gcc_struct}
5955 If @code{packed} is used on a structure, or if bit-fields are used
5956 it may be that the Microsoft ABI packs them differently
5957 than GCC normally packs them.  Particularly when moving packed
5958 data between functions compiled with GCC and the native Microsoft compiler
5959 (either via function call or as data in a file), it may be necessary to access
5960 either format.
5962 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5963 compilers to match the native Microsoft compiler.
5964 @end table
5966 @anchor{PowerPC Type Attributes}
5967 @subsection PowerPC Type Attributes
5969 Three attributes currently are defined for PowerPC configurations:
5970 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5972 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5973 attributes please see the documentation in @ref{i386 Type Attributes}.
5975 The @code{altivec} attribute allows one to declare AltiVec vector data
5976 types supported by the AltiVec Programming Interface Manual.  The
5977 attribute requires an argument to specify one of three vector types:
5978 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5979 and @code{bool__} (always followed by unsigned).
5981 @smallexample
5982 __attribute__((altivec(vector__)))
5983 __attribute__((altivec(pixel__))) unsigned short
5984 __attribute__((altivec(bool__))) unsigned
5985 @end smallexample
5987 These attributes mainly are intended to support the @code{__vector},
5988 @code{__pixel}, and @code{__bool} AltiVec keywords.
5990 @anchor{SPU Type Attributes}
5991 @subsection SPU Type Attributes
5993 The SPU supports the @code{spu_vector} attribute for types.  This attribute
5994 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5995 Language Extensions Specification.  It is intended to support the
5996 @code{__vector} keyword.
5998 @node Alignment
5999 @section Inquiring on Alignment of Types or Variables
6000 @cindex alignment
6001 @cindex type alignment
6002 @cindex variable alignment
6004 The keyword @code{__alignof__} allows you to inquire about how an object
6005 is aligned, or the minimum alignment usually required by a type.  Its
6006 syntax is just like @code{sizeof}.
6008 For example, if the target machine requires a @code{double} value to be
6009 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6010 This is true on many RISC machines.  On more traditional machine
6011 designs, @code{__alignof__ (double)} is 4 or even 2.
6013 Some machines never actually require alignment; they allow reference to any
6014 data type even at an odd address.  For these machines, @code{__alignof__}
6015 reports the smallest alignment that GCC gives the data type, usually as
6016 mandated by the target ABI.
6018 If the operand of @code{__alignof__} is an lvalue rather than a type,
6019 its value is the required alignment for its type, taking into account
6020 any minimum alignment specified with GCC's @code{__attribute__}
6021 extension (@pxref{Variable Attributes}).  For example, after this
6022 declaration:
6024 @smallexample
6025 struct foo @{ int x; char y; @} foo1;
6026 @end smallexample
6028 @noindent
6029 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6030 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6032 It is an error to ask for the alignment of an incomplete type.
6035 @node Inline
6036 @section An Inline Function is As Fast As a Macro
6037 @cindex inline functions
6038 @cindex integrating function code
6039 @cindex open coding
6040 @cindex macros, inline alternative
6042 By declaring a function inline, you can direct GCC to make
6043 calls to that function faster.  One way GCC can achieve this is to
6044 integrate that function's code into the code for its callers.  This
6045 makes execution faster by eliminating the function-call overhead; in
6046 addition, if any of the actual argument values are constant, their
6047 known values may permit simplifications at compile time so that not
6048 all of the inline function's code needs to be included.  The effect on
6049 code size is less predictable; object code may be larger or smaller
6050 with function inlining, depending on the particular case.  You can
6051 also direct GCC to try to integrate all ``simple enough'' functions
6052 into their callers with the option @option{-finline-functions}.
6054 GCC implements three different semantics of declaring a function
6055 inline.  One is available with @option{-std=gnu89} or
6056 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6057 on all inline declarations, another when
6058 @option{-std=c99}, @option{-std=c11},
6059 @option{-std=gnu99} or @option{-std=gnu11}
6060 (without @option{-fgnu89-inline}), and the third
6061 is used when compiling C++.
6063 To declare a function inline, use the @code{inline} keyword in its
6064 declaration, like this:
6066 @smallexample
6067 static inline int
6068 inc (int *a)
6070   return (*a)++;
6072 @end smallexample
6074 If you are writing a header file to be included in ISO C90 programs, write
6075 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6077 The three types of inlining behave similarly in two important cases:
6078 when the @code{inline} keyword is used on a @code{static} function,
6079 like the example above, and when a function is first declared without
6080 using the @code{inline} keyword and then is defined with
6081 @code{inline}, like this:
6083 @smallexample
6084 extern int inc (int *a);
6085 inline int
6086 inc (int *a)
6088   return (*a)++;
6090 @end smallexample
6092 In both of these common cases, the program behaves the same as if you
6093 had not used the @code{inline} keyword, except for its speed.
6095 @cindex inline functions, omission of
6096 @opindex fkeep-inline-functions
6097 When a function is both inline and @code{static}, if all calls to the
6098 function are integrated into the caller, and the function's address is
6099 never used, then the function's own assembler code is never referenced.
6100 In this case, GCC does not actually output assembler code for the
6101 function, unless you specify the option @option{-fkeep-inline-functions}.
6102 Some calls cannot be integrated for various reasons (in particular,
6103 calls that precede the function's definition cannot be integrated, and
6104 neither can recursive calls within the definition).  If there is a
6105 nonintegrated call, then the function is compiled to assembler code as
6106 usual.  The function must also be compiled as usual if the program
6107 refers to its address, because that can't be inlined.
6109 @opindex Winline
6110 Note that certain usages in a function definition can make it unsuitable
6111 for inline substitution.  Among these usages are: variadic functions, use of
6112 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6113 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6114 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6115 warns when a function marked @code{inline} could not be substituted,
6116 and gives the reason for the failure.
6118 @cindex automatic @code{inline} for C++ member fns
6119 @cindex @code{inline} automatic for C++ member fns
6120 @cindex member fns, automatically @code{inline}
6121 @cindex C++ member fns, automatically @code{inline}
6122 @opindex fno-default-inline
6123 As required by ISO C++, GCC considers member functions defined within
6124 the body of a class to be marked inline even if they are
6125 not explicitly declared with the @code{inline} keyword.  You can
6126 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6127 Options,,Options Controlling C++ Dialect}.
6129 GCC does not inline any functions when not optimizing unless you specify
6130 the @samp{always_inline} attribute for the function, like this:
6132 @smallexample
6133 /* @r{Prototype.}  */
6134 inline void foo (const char) __attribute__((always_inline));
6135 @end smallexample
6137 The remainder of this section is specific to GNU C90 inlining.
6139 @cindex non-static inline function
6140 When an inline function is not @code{static}, then the compiler must assume
6141 that there may be calls from other source files; since a global symbol can
6142 be defined only once in any program, the function must not be defined in
6143 the other source files, so the calls therein cannot be integrated.
6144 Therefore, a non-@code{static} inline function is always compiled on its
6145 own in the usual fashion.
6147 If you specify both @code{inline} and @code{extern} in the function
6148 definition, then the definition is used only for inlining.  In no case
6149 is the function compiled on its own, not even if you refer to its
6150 address explicitly.  Such an address becomes an external reference, as
6151 if you had only declared the function, and had not defined it.
6153 This combination of @code{inline} and @code{extern} has almost the
6154 effect of a macro.  The way to use it is to put a function definition in
6155 a header file with these keywords, and put another copy of the
6156 definition (lacking @code{inline} and @code{extern}) in a library file.
6157 The definition in the header file causes most calls to the function
6158 to be inlined.  If any uses of the function remain, they refer to
6159 the single copy in the library.
6161 @node Volatiles
6162 @section When is a Volatile Object Accessed?
6163 @cindex accessing volatiles
6164 @cindex volatile read
6165 @cindex volatile write
6166 @cindex volatile access
6168 C has the concept of volatile objects.  These are normally accessed by
6169 pointers and used for accessing hardware or inter-thread
6170 communication.  The standard encourages compilers to refrain from
6171 optimizations concerning accesses to volatile objects, but leaves it
6172 implementation defined as to what constitutes a volatile access.  The
6173 minimum requirement is that at a sequence point all previous accesses
6174 to volatile objects have stabilized and no subsequent accesses have
6175 occurred.  Thus an implementation is free to reorder and combine
6176 volatile accesses that occur between sequence points, but cannot do
6177 so for accesses across a sequence point.  The use of volatile does
6178 not allow you to violate the restriction on updating objects multiple
6179 times between two sequence points.
6181 Accesses to non-volatile objects are not ordered with respect to
6182 volatile accesses.  You cannot use a volatile object as a memory
6183 barrier to order a sequence of writes to non-volatile memory.  For
6184 instance:
6186 @smallexample
6187 int *ptr = @var{something};
6188 volatile int vobj;
6189 *ptr = @var{something};
6190 vobj = 1;
6191 @end smallexample
6193 @noindent
6194 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6195 that the write to @var{*ptr} occurs by the time the update
6196 of @var{vobj} happens.  If you need this guarantee, you must use
6197 a stronger memory barrier such as:
6199 @smallexample
6200 int *ptr = @var{something};
6201 volatile int vobj;
6202 *ptr = @var{something};
6203 asm volatile ("" : : : "memory");
6204 vobj = 1;
6205 @end smallexample
6207 A scalar volatile object is read when it is accessed in a void context:
6209 @smallexample
6210 volatile int *src = @var{somevalue};
6211 *src;
6212 @end smallexample
6214 Such expressions are rvalues, and GCC implements this as a
6215 read of the volatile object being pointed to.
6217 Assignments are also expressions and have an rvalue.  However when
6218 assigning to a scalar volatile, the volatile object is not reread,
6219 regardless of whether the assignment expression's rvalue is used or
6220 not.  If the assignment's rvalue is used, the value is that assigned
6221 to the volatile object.  For instance, there is no read of @var{vobj}
6222 in all the following cases:
6224 @smallexample
6225 int obj;
6226 volatile int vobj;
6227 vobj = @var{something};
6228 obj = vobj = @var{something};
6229 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6230 obj = (@var{something}, vobj = @var{anotherthing});
6231 @end smallexample
6233 If you need to read the volatile object after an assignment has
6234 occurred, you must use a separate expression with an intervening
6235 sequence point.
6237 As bit-fields are not individually addressable, volatile bit-fields may
6238 be implicitly read when written to, or when adjacent bit-fields are
6239 accessed.  Bit-field operations may be optimized such that adjacent
6240 bit-fields are only partially accessed, if they straddle a storage unit
6241 boundary.  For these reasons it is unwise to use volatile bit-fields to
6242 access hardware.
6244 @node Using Assembly Language with C
6245 @section How to Use Inline Assembly Language in C Code
6247 GCC provides various extensions that allow you to embed assembler within 
6248 C code.
6250 @menu
6251 * Basic Asm::          Inline assembler with no operands.
6252 * Extended Asm::       Inline assembler with operands.
6253 * Constraints::        Constraints for @code{asm} operands
6254 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6255 * Explicit Reg Vars::  Defining variables residing in specified registers.
6256 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6257 @end menu
6259 @node Basic Asm
6260 @subsection Basic Asm --- Assembler Instructions with No Operands
6261 @cindex basic @code{asm}
6263 The @code{asm} keyword allows you to embed assembler instructions within 
6264 C code.
6266 @example
6267 asm [ volatile ] ( AssemblerInstructions )
6268 @end example
6270 To create headers compatible with ISO C, write @code{__asm__} instead of 
6271 @code{asm} (@pxref{Alternate Keywords}).
6273 By definition, a Basic @code{asm} statement is one with no operands. 
6274 @code{asm} statements that contain one or more colons (used to delineate 
6275 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6276 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6278 @subsubheading Qualifiers
6279 @emph{volatile}
6281 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6282 implicitly volatile.
6284 @subsubheading Parameters
6285 @emph{AssemblerInstructions}
6287 This is a literal string that specifies the assembler code. The string can 
6288 contain any instructions recognized by the assembler, including directives. 
6289 GCC does not parse the assembler instructions themselves and 
6290 does not know what they mean or even whether they are valid assembler input. 
6291 The compiler copies it verbatim to the assembly language output file, without 
6292 processing dialects or any of the "%" operators that are available with
6293 Extended @code{asm}. This results in minor differences between Basic 
6294 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6295 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6296 @code{asm}.
6298 You may place multiple assembler instructions together in a single @code{asm} 
6299 string, separated by the characters normally used in assembly code for the 
6300 system. A combination that works in most places is a newline to break the 
6301 line, plus a tab character (written as "\n\t").
6302 Some assemblers allow semicolons as a line separator. However, 
6303 note that some assembler dialects use semicolons to start a comment. 
6305 Do not expect a sequence of @code{asm} statements to remain perfectly 
6306 consecutive after compilation. If certain instructions need to remain 
6307 consecutive in the output, put them in a single multi-instruction asm 
6308 statement. Note that GCC's optimizers can move @code{asm} statements 
6309 relative to other code, including across jumps.
6311 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6312 GCC does not know about these jumps, and therefore cannot take 
6313 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6314 labels are only supported in Extended @code{asm}.
6316 @subsubheading Remarks
6317 Using Extended @code{asm} will typically produce smaller, safer, and more 
6318 efficient code, and in most cases it is a better solution. When writing 
6319 inline assembly language outside of C functions, however, you must use Basic 
6320 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6321 Functions declared with the @code{naked} attribute also require Basic 
6322 @code{asm} (@pxref{Function Attributes}).
6324 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6325 assembly code when optimizing. This can lead to unexpected duplicate 
6326 symbol errors during compilation if your assembly code defines symbols or 
6327 labels.
6329 Safely accessing C data and calling functions from Basic @code{asm} is more 
6330 complex than it may appear. To access C data, it is better to use Extended 
6331 @code{asm}.
6333 Since GCC does not parse the AssemblerInstructions, it has no 
6334 visibility of any symbols it references. This may result in GCC discarding 
6335 those symbols as unreferenced.
6337 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6338 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6339 as though they used a "memory" clobber (@pxref{Clobbers}).
6341 All Basic @code{asm} blocks use the assembler dialect specified by the 
6342 @option{-masm} command-line option. Basic @code{asm} provides no
6343 mechanism to provide different assembler strings for different dialects.
6345 Here is an example of Basic @code{asm} for i386:
6347 @example
6348 /* Note that this code will not compile with -masm=intel */
6349 #define DebugBreak() asm("int $3")
6350 @end example
6352 @node Extended Asm
6353 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6354 @cindex @code{asm} keyword
6355 @cindex extended @code{asm}
6356 @cindex assembler instructions
6358 The @code{asm} keyword allows you to embed assembler instructions within C 
6359 code. With Extended @code{asm} you can read and write C variables from 
6360 assembler and perform jumps from assembler code to C labels.
6362 @example
6363 @ifhtml
6364 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6366 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6367 @end ifhtml
6368 @ifnothtml
6369 asm [volatile] ( AssemblerTemplate 
6370                  : [OutputOperands] 
6371                  [ : [InputOperands] 
6372                  [ : [Clobbers] ] ])
6374 asm [volatile] goto ( AssemblerTemplate 
6375                       : 
6376                       : [InputOperands] 
6377                       : [Clobbers] 
6378                       : GotoLabels)
6379 @end ifnothtml
6380 @end example
6382 To create headers compatible with ISO C, write @code{__asm__} instead of 
6383 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6384 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6386 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6387 operands. To separate the classes of operands, you use colons. Basic 
6388 @code{asm} statements contain no colons. (So, for example, 
6389 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6390 Extended @code{asm}. @pxref{Basic Asm}.)
6392 @subsubheading Qualifiers
6393 @emph{volatile}
6395 The typical use of Extended @code{asm} statements is to manipulate input 
6396 values to produce output values. However, your @code{asm} statements may 
6397 also produce side effects. If so, you may need to use the @code{volatile} 
6398 qualifier to disable certain optimizations. @xref{Volatile}.
6400 @emph{goto}
6402 This qualifier informs the compiler that the @code{asm} statement may 
6403 perform a jump to one of the labels listed in the GotoLabels section. 
6404 @xref{GotoLabels}.
6406 @subsubheading Parameters
6407 @emph{AssemblerTemplate}
6409 This is a literal string that contains the assembler code. It is a 
6410 combination of fixed text and tokens that refer to the input, output, 
6411 and goto parameters. @xref{AssemblerTemplate}.
6413 @emph{OutputOperands}
6415 A comma-separated list of the C variables modified by the instructions in the 
6416 AssemblerTemplate. @xref{OutputOperands}.
6418 @emph{InputOperands}
6420 A comma-separated list of C expressions read by the instructions in the 
6421 AssemblerTemplate. @xref{InputOperands}.
6423 @emph{Clobbers}
6425 A comma-separated list of registers or other values changed by the 
6426 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6428 @emph{GotoLabels}
6430 When you are using the @code{goto} form of @code{asm}, this section contains 
6431 the list of all C labels to which the AssemblerTemplate may jump. 
6432 @xref{GotoLabels}.
6434 @subsubheading Remarks
6435 The @code{asm} statement allows you to include assembly instructions directly 
6436 within C code. This may help you to maximize performance in time-sensitive 
6437 code or to access assembly instructions that are not readily available to C 
6438 programs.
6440 Note that Extended @code{asm} statements must be inside a function. Only 
6441 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6442 Functions declared with the @code{naked} attribute also require Basic 
6443 @code{asm} (@pxref{Function Attributes}).
6445 While the uses of @code{asm} are many and varied, it may help to think of an 
6446 @code{asm} statement as a series of low-level instructions that convert input 
6447 parameters to output parameters. So a simple (if not particularly useful) 
6448 example for i386 using @code{asm} might look like this:
6450 @example
6451 int src = 1;
6452 int dst;   
6454 asm ("mov %1, %0\n\t"
6455     "add $1, %0"
6456     : "=r" (dst) 
6457     : "r" (src));
6459 printf("%d\n", dst);
6460 @end example
6462 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6464 @anchor{Volatile}
6465 @subsubsection Volatile
6466 @cindex volatile @code{asm}
6467 @cindex @code{asm} volatile
6469 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6470 there is no need for the output variables. Also, the optimizers may move 
6471 code out of loops if they believe that the code will always return the same 
6472 result (i.e. none of its input values change between calls). Using the 
6473 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6474 that have no output operands are implicitly volatile.
6476 Examples:
6478 This i386 code demonstrates a case that does not use (or require) the 
6479 @code{volatile} qualifier. If it is performing assertion checking, this code 
6480 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6481 unreferenced by any code. As a result, the optimizers can discard the 
6482 @code{asm} statement, which in turn removes the need for the entire 
6483 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6484 isn't needed you allow the optimizers to produce the most efficient code 
6485 possible.
6487 @example
6488 void DoCheck(uint32_t dwSomeValue)
6490    uint32_t dwRes;
6492    // Assumes dwSomeValue is not zero.
6493    asm ("bsfl %1,%0"
6494      : "=r" (dwRes)
6495      : "r" (dwSomeValue)
6496      : "cc");
6498    assert(dwRes > 3);
6500 @end example
6502 The next example shows a case where the optimizers can recognize that the input 
6503 (@var{dwSomeValue}) never changes during the execution of the function and can 
6504 therefore move the @code{asm} outside the loop to produce more efficient code. 
6505 Again, using @code{volatile} disables this type of optimization.
6507 @example
6508 void do_print(uint32_t dwSomeValue)
6510    uint32_t dwRes;
6512    for (uint32_t x=0; x < 5; x++)
6513    @{
6514       // Assumes dwSomeValue is not zero.
6515       asm ("bsfl %1,%0"
6516         : "=r" (dwRes)
6517         : "r" (dwSomeValue)
6518         : "cc");
6520       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6521    @}
6523 @end example
6525 The following example demonstrates a case where you need to use the 
6526 @code{volatile} qualifier. It uses the i386 RDTSC instruction, which reads 
6527 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6528 the optimizers might assume that the @code{asm} block will always return the 
6529 same value and therefore optimize away the second call.
6531 @example
6532 uint64_t msr;
6534 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6535         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6536         "or %%rdx, %0"        // 'Or' in the lower bits.
6537         : "=a" (msr)
6538         : 
6539         : "rdx");
6541 printf("msr: %llx\n", msr);
6543 // Do other work...
6545 // Reprint the timestamp
6546 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6547         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6548         "or %%rdx, %0"        // 'Or' in the lower bits.
6549         : "=a" (msr)
6550         : 
6551         : "rdx");
6553 printf("msr: %llx\n", msr);
6554 @end example
6556 GCC's optimizers will not treat this code like the non-volatile code in the 
6557 earlier examples. They do not move it out of loops or omit it on the 
6558 assumption that the result from a previous call is still valid.
6560 Note that the compiler can move even volatile @code{asm} instructions relative 
6561 to other code, including across jump instructions. For example, on many 
6562 targets there is a system register that controls the rounding mode of 
6563 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6564 following PowerPC example, will not work reliably.
6566 @example
6567 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6568 sum = x + y;
6569 @end example
6571 The compiler may move the addition back before the volatile @code{asm}. To 
6572 make it work as expected, add an artificial dependency to the @code{asm} by 
6573 referencing a variable in the subsequent code, for example: 
6575 @example
6576 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6577 sum = x + y;
6578 @end example
6580 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6581 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6582 errors during compilation if your asm code defines symbols or labels. Using %= 
6583 (@pxref{AssemblerTemplate}) may help resolve this problem.
6585 @anchor{AssemblerTemplate}
6586 @subsubsection Assembler Template
6587 @cindex @code{asm} assembler template
6589 An assembler template is a literal string containing assembler instructions. 
6590 The compiler will replace any references to inputs, outputs, and goto labels 
6591 in the template, and then output the resulting string to the assembler. The 
6592 string can contain any instructions recognized by the assembler, including 
6593 directives. GCC does not parse the assembler instructions 
6594 themselves and does not know what they mean or even whether they are valid 
6595 assembler input. However, it does count the statements 
6596 (@pxref{Size of an asm}).
6598 You may place multiple assembler instructions together in a single @code{asm} 
6599 string, separated by the characters normally used in assembly code for the 
6600 system. A combination that works in most places is a newline to break the 
6601 line, plus a tab character to move to the instruction field (written as 
6602 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6603 that some assembler dialects use semicolons to start a comment. 
6605 Do not expect a sequence of @code{asm} statements to remain perfectly 
6606 consecutive after compilation, even when you are using the @code{volatile} 
6607 qualifier. If certain instructions need to remain consecutive in the output, 
6608 put them in a single multi-instruction asm statement.
6610 Accessing data from C programs without using input/output operands (such as 
6611 by using global symbols directly from the assembler template) may not work as 
6612 expected. Similarly, calling functions directly from an assembler template 
6613 requires a detailed understanding of the target assembler and ABI.
6615 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6616 symbols it references. This may result in GCC discarding those symbols as 
6617 unreferenced unless they are also listed as input, output, or goto operands.
6619 GCC can support multiple assembler dialects (for example, GCC for i386 
6620 supports "att" and "intel" dialects) for inline assembler. In builds that 
6621 support this capability, the @option{-masm} option controls which dialect 
6622 GCC uses as its default. The hardware-specific documentation for the 
6623 @option{-masm} option contains the list of supported dialects, as well as the 
6624 default dialect if the option is not specified. This information may be 
6625 important to understand, since assembler code that works correctly when 
6626 compiled using one dialect will likely fail if compiled using another.
6628 @subsubheading Using braces in @code{asm} templates
6630 If your code needs to support multiple assembler dialects (for example, if 
6631 you are writing public headers that need to support a variety of compilation 
6632 options), use constructs of this form:
6634 @example
6635 @{ dialect0 | dialect1 | dialect2... @}
6636 @end example
6638 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6639 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6640 braces than the number of dialects the compiler supports, the construct 
6641 outputs nothing.
6643 For example, if an i386 compiler supports two dialects (att, intel), an 
6644 assembler template such as this:
6646 @example
6647 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6648 @end example
6650 would produce the output:
6652 @example
6653 For att: "btl %[Offset],%[Base] ; jc %l2"
6654 For intel: "bt %[Base],%[Offset]; jc %l2"
6655 @end example
6657 Using that same compiler, this code:
6659 @example
6660 "xchg@{l@}\t@{%%@}ebx, %1"
6661 @end example
6663 would produce 
6665 @example
6666 For att: "xchgl\t%%ebx, %1"
6667 For intel: "xchg\tebx, %1"
6668 @end example
6670 There is no support for nesting dialect alternatives. Also, there is no 
6671 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6672 @code{asm} template other than as a dialect indicator.
6674 @subsubheading Other format strings
6676 In addition to the tokens described by the input, output, and goto operands, 
6677 there are a few special cases:
6679 @itemize
6680 @item
6681 "%%" outputs a single "%" into the assembler code.
6683 @item
6684 "%=" outputs a number that is unique to each instance of the @code{asm} 
6685 statement in the entire compilation. This option is useful when creating local 
6686 labels and referring to them multiple times in a single template that 
6687 generates multiple assembler instructions. 
6689 @end itemize
6691 @anchor{OutputOperands}
6692 @subsubsection Output Operands
6693 @cindex @code{asm} output operands
6695 An @code{asm} statement has zero or more output operands indicating the names
6696 of C variables modified by the assembler code.
6698 In this i386 example, @var{old} (referred to in the template string as 
6699 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6700 (@code{%2}) is an input:
6702 @example
6703 bool old;
6705 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6706          "sbb %0,%0"      // Use the CF to calculate old.
6707    : "=r" (old), "+rm" (*Base)
6708    : "Ir" (Offset)
6709    : "cc");
6711 return old;
6712 @end example
6714 Operands use this format:
6716 @example
6717 [ [asmSymbolicName] ] "constraint" (cvariablename)
6718 @end example
6720 @emph{asmSymbolicName}
6723 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6724 in the list of operands in the assembler template. For example if there are 
6725 three output operands, use @code{%0} in the template to refer to the first, 
6726 @code{%1} for the second, and @code{%2} for the third. When using an 
6727 asmSymbolicName, reference it by enclosing the name in square brackets 
6728 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6729 that contains the definition. Any valid C variable name is acceptable, 
6730 including names already defined in the surrounding code. No two operands 
6731 within the same @code{asm} statement can use the same symbolic name.
6733 @emph{constraint}
6735 Output constraints must begin with either @code{"="} (a variable overwriting an 
6736 existing value) or @code{"+"} (when reading and writing). When using 
6737 @code{"="}, do not assume the location will contain the existing value (except 
6738 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6740 After the prefix, there must be one or more additional constraints 
6741 (@pxref{Constraints}) that describe where the value resides. Common 
6742 constraints include @code{"r"} for register and @code{"m"} for memory. 
6743 When you list more than one possible location (for example @code{"=rm"}), the 
6744 compiler chooses the most efficient one based on the current context. If you 
6745 list as many alternates as the @code{asm} statement allows, you will permit 
6746 the optimizers to produce the best possible code. If you must use a specific
6747 register, but your Machine Constraints do not provide sufficient 
6748 control to select the specific register you want, Local Reg Vars may provide 
6749 a solution (@pxref{Local Reg Vars}).
6751 @emph{cvariablename}
6753 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6754 any (non-constant) variable within scope.
6756 Remarks:
6758 The total number of input + output + goto operands has a limit of 30. Commas 
6759 separate the operands. When the compiler selects the registers to use to 
6760 represent the output operands, it will not use any of the clobbered registers 
6761 (@pxref{Clobbers}).
6763 Output operand expressions must be lvalues. The compiler cannot check whether 
6764 the operands have data types that are reasonable for the instruction being 
6765 executed. For output expressions that are not directly addressable (for 
6766 example a bit-field), the constraint must allow a register. In that case, GCC 
6767 uses the register as the output of the @code{asm}, and then stores that 
6768 register into the output. 
6770 Unless an output operand has the '@code{&}' constraint modifier 
6771 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6772 input operand, on the assumption that the assembler code will consume its 
6773 inputs before producing outputs. This assumption may be false if the assembler 
6774 code actually consists of more than one instruction. In this case, use 
6775 '@code{&}' on each output operand that must not overlap an input.
6777 The same problem can occur if one output parameter (@var{a}) allows a register 
6778 constraint and another output parameter (@var{b}) allows a memory constraint.
6779 The code generated by GCC to access the memory address in @var{b} can contain
6780 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6781 registers to be inputs to the asm. As above, GCC assumes that such input
6782 registers are consumed before any outputs are written. This assumption may 
6783 result in incorrect behavior if the asm writes to @var{a} before using 
6784 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6785 ensures that modifying @var{a} will not affect what address is referenced by 
6786 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6787 will be undefined if @var{a} is modified before using @var{b}.
6789 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6790 instead of simply @code{%2}). Typically these qualifiers are hardware 
6791 dependent. The list of supported modifiers for i386 is found at 
6792 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6794 If the C code that follows the @code{asm} makes no use of any of the output 
6795 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6796 optimizers from discarding the @code{asm} statement as unneeded 
6797 (see @ref{Volatile}).
6799 Examples:
6801 This code makes no use of the optional asmSymbolicName. Therefore it 
6802 references the first output operand as @code{%0} (were there a second, it 
6803 would be @code{%1}, etc). The number of the first input operand is one greater 
6804 than that of the last output operand. In this i386 example, that makes 
6805 @var{Mask} @code{%1}:
6807 @example
6808 uint32_t Mask = 1234;
6809 uint32_t Index;
6811   asm ("bsfl %1, %0"
6812      : "=r" (Index)
6813      : "r" (Mask)
6814      : "cc");
6815 @end example
6817 That code overwrites the variable Index ("="), placing the value in a register 
6818 ("r"). The generic "r" constraint instead of a constraint for a specific 
6819 register allows the compiler to pick the register to use, which can result 
6820 in more efficient code. This may not be possible if an assembler instruction 
6821 requires a specific register.
6823 The following i386 example uses the asmSymbolicName operand. It produces the 
6824 same result as the code above, but some may consider it more readable or more 
6825 maintainable since reordering index numbers is not necessary when adding or 
6826 removing operands. The names aIndex and aMask are only used to emphasize which 
6827 names get used where. It is acceptable to reuse the names Index and Mask.
6829 @example
6830 uint32_t Mask = 1234;
6831 uint32_t Index;
6833   asm ("bsfl %[aMask], %[aIndex]"
6834      : [aIndex] "=r" (Index)
6835      : [aMask] "r" (Mask)
6836      : "cc");
6837 @end example
6839 Here are some more examples of output operands.
6841 @example
6842 uint32_t c = 1;
6843 uint32_t d;
6844 uint32_t *e = &c;
6846 asm ("mov %[e], %[d]"
6847    : [d] "=rm" (d)
6848    : [e] "rm" (*e));
6849 @end example
6851 Here, @var{d} may either be in a register or in memory. Since the compiler 
6852 might already have the current value of the uint32_t pointed to by @var{e} 
6853 in a register, you can enable it to choose the best location
6854 for @var{d} by specifying both constraints.
6856 @anchor{InputOperands}
6857 @subsubsection Input Operands
6858 @cindex @code{asm} input operands
6859 @cindex @code{asm} expressions
6861 Input operands make inputs from C variables and expressions available to the 
6862 assembly code.
6864 Specify input operands by using the format:
6866 @example
6867 [ [asmSymbolicName] ] "constraint" (cexpression)
6868 @end example
6870 @emph{asmSymbolicName}
6872 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6873 in the list of operands, including outputs, in the assembler template. For 
6874 example, if there are two output parameters and three inputs, @code{%2} refers 
6875 to the first input, @code{%3} to the second, and @code{%4} to the third.
6876 When using an asmSymbolicName, reference it by enclosing the name in square 
6877 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
6878 statement that contains the definition. Any valid C variable name is 
6879 acceptable, including names already defined in the surrounding code. No two 
6880 operands within the same @code{asm} statement can use the same symbolic name.
6882 @emph{constraint}
6884 Input constraints must be a string containing one or more constraints 
6885 (@pxref{Constraints}). When you give more than one possible constraint 
6886 (for example, @code{"irm"}), the compiler will choose the most efficient 
6887 method based on the current context. Input constraints may not begin with 
6888 either "=" or "+". If you must use a specific register, but your Machine
6889 Constraints do not provide sufficient control to select the specific 
6890 register you want, Local Reg Vars may provide a solution 
6891 (@pxref{Local Reg Vars}).
6893 Input constraints can also be digits (for example, @code{"0"}). This indicates 
6894 that the specified input will be in the same place as the output constraint 
6895 at the (zero-based) index in the output constraint list. When using 
6896 asmSymbolicNames for the output operands, you may use these names (enclosed 
6897 in brackets []) instead of digits.
6899 @emph{cexpression}
6901 This is the C variable or expression being passed to the @code{asm} statement 
6902 as input.
6904 When the compiler selects the registers to use to represent the input 
6905 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
6907 If there are no output operands but there are input operands, place two 
6908 consecutive colons where the output operands would go:
6910 @example
6911 __asm__ ("some instructions"
6912    : /* No outputs. */
6913    : "r" (Offset / 8);
6914 @end example
6916 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
6917 (except for inputs tied to outputs). The compiler assumes that on exit from 
6918 the @code{asm} statement these operands will contain the same values as they 
6919 had before executing the assembler. It is @emph{not} possible to use Clobbers 
6920 to inform the compiler that the values in these inputs are changing. One 
6921 common work-around is to tie the changing input variable to an output variable 
6922 that never gets used. Note, however, that if the code that follows the 
6923 @code{asm} statement makes no use of any of the output operands, the GCC 
6924 optimizers may discard the @code{asm} statement as unneeded 
6925 (see @ref{Volatile}).
6927 Remarks:
6929 The total number of input + output + goto operands has a limit of 30.
6931 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6932 instead of simply @code{%2}). Typically these qualifiers are hardware 
6933 dependent. The list of supported modifiers for i386 is found at 
6934 @ref{i386Operandmodifiers,i386 Operand modifiers}.
6936 Examples:
6938 In this example using the fictitious @code{combine} instruction, the 
6939 constraint @code{"0"} for input operand 1 says that it must occupy the same 
6940 location as output operand 0. Only input operands may use numbers in 
6941 constraints, and they must each refer to an output operand. Only a number (or 
6942 the symbolic assembler name) in the constraint can guarantee that one operand 
6943 is in the same place as another. The mere fact that @var{foo} is the value of 
6944 both operands is not enough to guarantee that they are in the same place in 
6945 the generated assembler code.
6947 @example
6948 asm ("combine %2, %0" 
6949    : "=r" (foo) 
6950    : "0" (foo), "g" (bar));
6951 @end example
6953 Here is an example using symbolic names.
6955 @example
6956 asm ("cmoveq %1, %2, %[result]" 
6957    : [result] "=r"(result) 
6958    : "r" (test), "r" (new), "[result]" (old));
6959 @end example
6961 @anchor{Clobbers}
6962 @subsubsection Clobbers
6963 @cindex @code{asm} clobbers
6965 While the compiler is aware of changes to entries listed in the output 
6966 operands, the assembler code may modify more than just the outputs. For 
6967 example, calculations may require additional registers, or the processor may 
6968 overwrite a register as a side effect of a particular assembler instruction. 
6969 In order to inform the compiler of these changes, list them in the clobber 
6970 list. Clobber list items are either register names or the special clobbers 
6971 (listed below). Each clobber list item is enclosed in double quotes and 
6972 separated by commas.
6974 Clobber descriptions may not in any way overlap with an input or output 
6975 operand. For example, you may not have an operand describing a register class 
6976 with one member when listing that register in the clobber list. Variables 
6977 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
6978 as @code{asm} input or output operands, must have no part mentioned in the 
6979 clobber description. In particular, there is no way to specify that input 
6980 operands get modified without also specifying them as output operands.
6982 When the compiler selects which registers to use to represent input and output 
6983 operands, it will not use any of the clobbered registers. As a result, 
6984 clobbered registers are available for any use in the assembler code.
6986 Here is a realistic example for the VAX showing the use of clobbered 
6987 registers: 
6989 @example
6990 asm volatile ("movc3 %0, %1, %2"
6991                    : /* No outputs. */
6992                    : "g" (from), "g" (to), "g" (count)
6993                    : "r0", "r1", "r2", "r3", "r4", "r5");
6994 @end example
6996 Also, there are two special clobber arguments:
6998 @enumerate
6999 @item
7000 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7001 register. On some machines, GCC represents the condition codes as a specific 
7002 hardware register; "cc" serves to name this register. On other machines, 
7003 condition code handling is different, and specifying "cc" has no effect. But 
7004 it is valid no matter what the machine.
7006 @item
7007 The "memory" clobber tells the compiler that the assembly code performs memory 
7008 reads or writes to items other than those listed in the input and output 
7009 operands (for example accessing the memory pointed to by one of the input 
7010 parameters). To ensure memory contains correct values, GCC may need to flush 
7011 specific register values to memory before executing the @code{asm}. Further, 
7012 the compiler will not assume that any values read from memory before an 
7013 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7014 needed. This effectively forms a read/write memory barrier for the compiler.
7016 Note that this clobber does not prevent the @emph{processor} from doing 
7017 speculative reads past the @code{asm} statement. To prevent that, you need 
7018 processor-specific fence instructions.
7020 Flushing registers to memory has performance implications and may be an issue 
7021 for time-sensitive code. One trick to avoid this is available if the size of 
7022 the memory being accessed is known at compile time. For example, if accessing 
7023 ten bytes of a string, use a memory input like: 
7025 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7027 @end enumerate
7029 @anchor{GotoLabels}
7030 @subsubsection Goto Labels
7031 @cindex @code{asm} goto labels
7033 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7034 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7035 list of all C labels to which the assembler code may jump. GCC assumes that 
7036 @code{asm} execution falls through to the next statement (if this is not the 
7037 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7038 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7039 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7040 Attributes}). The total number of input + output + goto operands has 
7041 a limit of 30.
7043 An @code{asm goto} statement can not have outputs (which means that the 
7044 statement is implicitly volatile). This is due to an internal restriction of 
7045 the compiler: control transfer instructions cannot have outputs. If the 
7046 assembler code does modify anything, use the "memory" clobber to force the 
7047 optimizers to flush all register values to memory, and reload them if 
7048 necessary, after the @code{asm} statement.
7050 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7051 by its (zero-based) position in GotoLabels plus the number of input 
7052 arguments.  For example, if the @code{asm} has three inputs and references two 
7053 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7055 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7056 GCC's optimizers do not know about these jumps; therefore they cannot take 
7057 account of them when deciding how to optimize.
7059 Example code for i386 might look like:
7061 @example
7062 asm goto (
7063     "btl %1, %0\n\t"
7064     "jc %l2"
7065     : /* No outputs. */
7066     : "r" (p1), "r" (p2) 
7067     : "cc" 
7068     : carry);
7070 return 0;
7072 carry:
7073 return 1;
7074 @end example
7076 The following example shows an @code{asm goto} that uses the memory clobber.
7078 @example
7079 int frob(int x)
7081   int y;
7082   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7083             : /* No outputs. */
7084             : "r"(x), "r"(&y)
7085             : "r5", "memory" 
7086             : error);
7087   return y;
7088 error:
7089   return -1;
7091 @end example
7093 @anchor{i386Operandmodifiers}
7094 @subsubsection i386 Operand modifiers
7096 Input, output, and goto operands for extended @code{asm} statements can use 
7097 modifiers to affect the code output to the assembler. For example, the 
7098 following code uses the "h" and "b" modifiers for i386:
7100 @example
7101 uint16_t  num;
7102 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7103 @end example
7105 These modifiers generate this assembler code:
7107 @example
7108 xchg %ah, %al
7109 @end example
7111 The rest of this discussion uses the following code for illustrative purposes.
7113 @example
7114 int main()
7116    int iInt = 1;
7118 top:
7120    asm volatile goto ("some assembler instructions here"
7121    : /* No outputs. */
7122    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7123    : /* No clobbers. */
7124    : top);
7126 @end example
7128 With no modifiers, this is what the output from the operands would be for the 
7129 att and intel dialects of assembler:
7131 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7132 @headitem Operand @tab masm=att @tab masm=intel
7133 @item @code{%0}
7134 @tab @code{%eax}
7135 @tab @code{eax}
7136 @item @code{%1}
7137 @tab @code{$2}
7138 @tab @code{2}
7139 @item @code{%2}
7140 @tab @code{$.L2}
7141 @tab @code{OFFSET FLAT:.L2}
7142 @end multitable
7144 The table below shows the list of supported modifiers and their effects.
7146 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7147 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7148 @item @code{z}
7149 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7150 @tab @code{%z0}
7151 @tab @code{l}
7152 @tab 
7153 @item @code{b}
7154 @tab Print the QImode name of the register.
7155 @tab @code{%b0}
7156 @tab @code{%al}
7157 @tab @code{al}
7158 @item @code{h}
7159 @tab Print the QImode name for a ``high'' register.
7160 @tab @code{%h0}
7161 @tab @code{%ah}
7162 @tab @code{ah}
7163 @item @code{w}
7164 @tab Print the HImode name of the register.
7165 @tab @code{%w0}
7166 @tab @code{%ax}
7167 @tab @code{ax}
7168 @item @code{k}
7169 @tab Print the SImode name of the register.
7170 @tab @code{%k0}
7171 @tab @code{%eax}
7172 @tab @code{eax}
7173 @item @code{q}
7174 @tab Print the DImode name of the register.
7175 @tab @code{%q0}
7176 @tab @code{%rax}
7177 @tab @code{rax}
7178 @item @code{l}
7179 @tab Print the label name with no punctuation.
7180 @tab @code{%l2}
7181 @tab @code{.L2}
7182 @tab @code{.L2}
7183 @item @code{c}
7184 @tab Require a constant operand and print the constant expression with no punctuation.
7185 @tab @code{%c1}
7186 @tab @code{2}
7187 @tab @code{2}
7188 @end multitable
7190 @anchor{i386floatingpointasmoperands}
7191 @subsubsection i386 floating-point asm operands
7193 On i386 targets, there are several rules on the usage of stack-like registers
7194 in the operands of an @code{asm}.  These rules apply only to the operands
7195 that are stack-like registers:
7197 @enumerate
7198 @item
7199 Given a set of input registers that die in an @code{asm}, it is
7200 necessary to know which are implicitly popped by the @code{asm}, and
7201 which must be explicitly popped by GCC@.
7203 An input register that is implicitly popped by the @code{asm} must be
7204 explicitly clobbered, unless it is constrained to match an
7205 output operand.
7207 @item
7208 For any input register that is implicitly popped by an @code{asm}, it is
7209 necessary to know how to adjust the stack to compensate for the pop.
7210 If any non-popped input is closer to the top of the reg-stack than
7211 the implicitly popped register, it would not be possible to know what the
7212 stack looked like---it's not clear how the rest of the stack ``slides
7213 up''.
7215 All implicitly popped input registers must be closer to the top of
7216 the reg-stack than any input that is not implicitly popped.
7218 It is possible that if an input dies in an @code{asm}, the compiler might
7219 use the input register for an output reload.  Consider this example:
7221 @smallexample
7222 asm ("foo" : "=t" (a) : "f" (b));
7223 @end smallexample
7225 @noindent
7226 This code says that input @code{b} is not popped by the @code{asm}, and that
7227 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7228 deeper after the @code{asm} than it was before.  But, it is possible that
7229 reload may think that it can use the same register for both the input and
7230 the output.
7232 To prevent this from happening,
7233 if any input operand uses the @code{f} constraint, all output register
7234 constraints must use the @code{&} early-clobber modifier.
7236 The example above would be correctly written as:
7238 @smallexample
7239 asm ("foo" : "=&t" (a) : "f" (b));
7240 @end smallexample
7242 @item
7243 Some operands need to be in particular places on the stack.  All
7244 output operands fall in this category---GCC has no other way to
7245 know which registers the outputs appear in unless you indicate
7246 this in the constraints.
7248 Output operands must specifically indicate which register an output
7249 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7250 constraints must select a class with a single register.
7252 @item
7253 Output operands may not be ``inserted'' between existing stack registers.
7254 Since no 387 opcode uses a read/write operand, all output operands
7255 are dead before the @code{asm}, and are pushed by the @code{asm}.
7256 It makes no sense to push anywhere but the top of the reg-stack.
7258 Output operands must start at the top of the reg-stack: output
7259 operands may not ``skip'' a register.
7261 @item
7262 Some @code{asm} statements may need extra stack space for internal
7263 calculations.  This can be guaranteed by clobbering stack registers
7264 unrelated to the inputs and outputs.
7266 @end enumerate
7268 Here are a couple of reasonable @code{asm}s to want to write.  This
7269 @code{asm}
7270 takes one input, which is internally popped, and produces two outputs.
7272 @smallexample
7273 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7274 @end smallexample
7276 @noindent
7277 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7278 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7279 for the compiler to know that @code{fyl2xp1} pops both inputs.
7281 @smallexample
7282 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7283 @end smallexample
7285 @lowersections
7286 @include md.texi
7287 @raisesections
7289 @node Asm Labels
7290 @subsection Controlling Names Used in Assembler Code
7291 @cindex assembler names for identifiers
7292 @cindex names used in assembler code
7293 @cindex identifiers, names in assembler code
7295 You can specify the name to be used in the assembler code for a C
7296 function or variable by writing the @code{asm} (or @code{__asm__})
7297 keyword after the declarator as follows:
7299 @smallexample
7300 int foo asm ("myfoo") = 2;
7301 @end smallexample
7303 @noindent
7304 This specifies that the name to be used for the variable @code{foo} in
7305 the assembler code should be @samp{myfoo} rather than the usual
7306 @samp{_foo}.
7308 On systems where an underscore is normally prepended to the name of a C
7309 function or variable, this feature allows you to define names for the
7310 linker that do not start with an underscore.
7312 It does not make sense to use this feature with a non-static local
7313 variable since such variables do not have assembler names.  If you are
7314 trying to put the variable in a particular register, see @ref{Explicit
7315 Reg Vars}.  GCC presently accepts such code with a warning, but will
7316 probably be changed to issue an error, rather than a warning, in the
7317 future.
7319 You cannot use @code{asm} in this way in a function @emph{definition}; but
7320 you can get the same effect by writing a declaration for the function
7321 before its definition and putting @code{asm} there, like this:
7323 @smallexample
7324 extern func () asm ("FUNC");
7326 func (x, y)
7327      int x, y;
7328 /* @r{@dots{}} */
7329 @end smallexample
7331 It is up to you to make sure that the assembler names you choose do not
7332 conflict with any other assembler symbols.  Also, you must not use a
7333 register name; that would produce completely invalid assembler code.  GCC
7334 does not as yet have the ability to store static variables in registers.
7335 Perhaps that will be added.
7337 @node Explicit Reg Vars
7338 @subsection Variables in Specified Registers
7339 @cindex explicit register variables
7340 @cindex variables in specified registers
7341 @cindex specified registers
7342 @cindex registers, global allocation
7344 GNU C allows you to put a few global variables into specified hardware
7345 registers.  You can also specify the register in which an ordinary
7346 register variable should be allocated.
7348 @itemize @bullet
7349 @item
7350 Global register variables reserve registers throughout the program.
7351 This may be useful in programs such as programming language
7352 interpreters that have a couple of global variables that are accessed
7353 very often.
7355 @item
7356 Local register variables in specific registers do not reserve the
7357 registers, except at the point where they are used as input or output
7358 operands in an @code{asm} statement and the @code{asm} statement itself is
7359 not deleted.  The compiler's data flow analysis is capable of determining
7360 where the specified registers contain live values, and where they are
7361 available for other uses.  Stores into local register variables may be deleted
7362 when they appear to be dead according to dataflow analysis.  References
7363 to local register variables may be deleted or moved or simplified.
7365 These local variables are sometimes convenient for use with the extended
7366 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7367 output of the assembler instruction directly into a particular register.
7368 (This works provided the register you specify fits the constraints
7369 specified for that operand in the @code{asm}.)
7370 @end itemize
7372 @menu
7373 * Global Reg Vars::
7374 * Local Reg Vars::
7375 @end menu
7377 @node Global Reg Vars
7378 @subsubsection Defining Global Register Variables
7379 @cindex global register variables
7380 @cindex registers, global variables in
7382 You can define a global register variable in GNU C like this:
7384 @smallexample
7385 register int *foo asm ("a5");
7386 @end smallexample
7388 @noindent
7389 Here @code{a5} is the name of the register that should be used.  Choose a
7390 register that is normally saved and restored by function calls on your
7391 machine, so that library routines will not clobber it.
7393 Naturally the register name is cpu-dependent, so you need to
7394 conditionalize your program according to cpu type.  The register
7395 @code{a5} is a good choice on a 68000 for a variable of pointer
7396 type.  On machines with register windows, be sure to choose a ``global''
7397 register that is not affected magically by the function call mechanism.
7399 In addition, different operating systems on the same CPU may differ in how they
7400 name the registers; then you need additional conditionals.  For
7401 example, some 68000 operating systems call this register @code{%a5}.
7403 Eventually there may be a way of asking the compiler to choose a register
7404 automatically, but first we need to figure out how it should choose and
7405 how to enable you to guide the choice.  No solution is evident.
7407 Defining a global register variable in a certain register reserves that
7408 register entirely for this use, at least within the current compilation.
7409 The register is not allocated for any other purpose in the functions
7410 in the current compilation, and is not saved and restored by
7411 these functions.  Stores into this register are never deleted even if they
7412 appear to be dead, but references may be deleted or moved or
7413 simplified.
7415 It is not safe to access the global register variables from signal
7416 handlers, or from more than one thread of control, because the system
7417 library routines may temporarily use the register for other things (unless
7418 you recompile them specially for the task at hand).
7420 @cindex @code{qsort}, and global register variables
7421 It is not safe for one function that uses a global register variable to
7422 call another such function @code{foo} by way of a third function
7423 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7424 different source file in which the variable isn't declared).  This is
7425 because @code{lose} might save the register and put some other value there.
7426 For example, you can't expect a global register variable to be available in
7427 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7428 might have put something else in that register.  (If you are prepared to
7429 recompile @code{qsort} with the same global register variable, you can
7430 solve this problem.)
7432 If you want to recompile @code{qsort} or other source files that do not
7433 actually use your global register variable, so that they do not use that
7434 register for any other purpose, then it suffices to specify the compiler
7435 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7436 register declaration to their source code.
7438 A function that can alter the value of a global register variable cannot
7439 safely be called from a function compiled without this variable, because it
7440 could clobber the value the caller expects to find there on return.
7441 Therefore, the function that is the entry point into the part of the
7442 program that uses the global register variable must explicitly save and
7443 restore the value that belongs to its caller.
7445 @cindex register variable after @code{longjmp}
7446 @cindex global register after @code{longjmp}
7447 @cindex value after @code{longjmp}
7448 @findex longjmp
7449 @findex setjmp
7450 On most machines, @code{longjmp} restores to each global register
7451 variable the value it had at the time of the @code{setjmp}.  On some
7452 machines, however, @code{longjmp} does not change the value of global
7453 register variables.  To be portable, the function that called @code{setjmp}
7454 should make other arrangements to save the values of the global register
7455 variables, and to restore them in a @code{longjmp}.  This way, the same
7456 thing happens regardless of what @code{longjmp} does.
7458 All global register variable declarations must precede all function
7459 definitions.  If such a declaration could appear after function
7460 definitions, the declaration would be too late to prevent the register from
7461 being used for other purposes in the preceding functions.
7463 Global register variables may not have initial values, because an
7464 executable file has no means to supply initial contents for a register.
7466 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7467 registers, but certain library functions, such as @code{getwd}, as well
7468 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7469 g2 are local temporaries.
7471 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7472 Of course, it does not do to use more than a few of those.
7474 @node Local Reg Vars
7475 @subsubsection Specifying Registers for Local Variables
7476 @cindex local variables, specifying registers
7477 @cindex specifying registers for local variables
7478 @cindex registers for local variables
7480 You can define a local register variable with a specified register
7481 like this:
7483 @smallexample
7484 register int *foo asm ("a5");
7485 @end smallexample
7487 @noindent
7488 Here @code{a5} is the name of the register that should be used.  Note
7489 that this is the same syntax used for defining global register
7490 variables, but for a local variable it appears within a function.
7492 Naturally the register name is cpu-dependent, but this is not a
7493 problem, since specific registers are most often useful with explicit
7494 assembler instructions (@pxref{Extended Asm}).  Both of these things
7495 generally require that you conditionalize your program according to
7496 cpu type.
7498 In addition, operating systems on one type of cpu may differ in how they
7499 name the registers; then you need additional conditionals.  For
7500 example, some 68000 operating systems call this register @code{%a5}.
7502 Defining such a register variable does not reserve the register; it
7503 remains available for other uses in places where flow control determines
7504 the variable's value is not live.
7506 This option does not guarantee that GCC generates code that has
7507 this variable in the register you specify at all times.  You may not
7508 code an explicit reference to this register in the @emph{assembler
7509 instruction template} part of an @code{asm} statement and assume it
7510 always refers to this variable.  However, using the variable as an
7511 @code{asm} @emph{operand} guarantees that the specified register is used
7512 for the operand.
7514 Stores into local register variables may be deleted when they appear to be dead
7515 according to dataflow analysis.  References to local register variables may
7516 be deleted or moved or simplified.
7518 As with global register variables, it is recommended that you choose a
7519 register that is normally saved and restored by function calls on
7520 your machine, so that library routines will not clobber it.  
7522 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7523 specific register, but there's no matching constraint letter for that 
7524 register. To force the operand into that register, create a local variable 
7525 and specify the register in the variable's declaration. Then use the local 
7526 variable for the asm operand and specify any constraint letter that matches 
7527 the register:
7529 @smallexample
7530 register int *p1 asm ("r0") = @dots{};
7531 register int *p2 asm ("r1") = @dots{};
7532 register int *result asm ("r0");
7533 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7534 @end smallexample
7536 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7537 call-clobbered by subsequent code, including function calls and library calls 
7538 for arithmetic operators on other variables (for example the initialization 
7539 of p2). In this case, use temporary variables for expressions between the 
7540 register assignments:
7542 @smallexample
7543 int t1 = @dots{};
7544 register int *p1 asm ("r0") = @dots{};
7545 register int *p2 asm ("r1") = t1;
7546 register int *result asm ("r0");
7547 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7548 @end smallexample
7550 @node Size of an asm
7551 @subsection Size of an @code{asm}
7553 Some targets require that GCC track the size of each instruction used
7554 in order to generate correct code.  Because the final length of the
7555 code produced by an @code{asm} statement is only known by the
7556 assembler, GCC must make an estimate as to how big it will be.  It
7557 does this by counting the number of instructions in the pattern of the
7558 @code{asm} and multiplying that by the length of the longest
7559 instruction supported by that processor.  (When working out the number
7560 of instructions, it assumes that any occurrence of a newline or of
7561 whatever statement separator character is supported by the assembler --
7562 typically @samp{;} --- indicates the end of an instruction.)
7564 Normally, GCC's estimate is adequate to ensure that correct
7565 code is generated, but it is possible to confuse the compiler if you use
7566 pseudo instructions or assembler macros that expand into multiple real
7567 instructions, or if you use assembler directives that expand to more
7568 space in the object file than is needed for a single instruction.
7569 If this happens then the assembler may produce a diagnostic saying that
7570 a label is unreachable.
7572 @node Alternate Keywords
7573 @section Alternate Keywords
7574 @cindex alternate keywords
7575 @cindex keywords, alternate
7577 @option{-ansi} and the various @option{-std} options disable certain
7578 keywords.  This causes trouble when you want to use GNU C extensions, or
7579 a general-purpose header file that should be usable by all programs,
7580 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7581 @code{inline} are not available in programs compiled with
7582 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7583 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7584 ISO C99 keyword
7585 @code{restrict} is only available when @option{-std=gnu99} (which will
7586 eventually be the default) or @option{-std=c99} (or the equivalent
7587 @option{-std=iso9899:1999}), or an option for a later standard
7588 version, is used.
7590 The way to solve these problems is to put @samp{__} at the beginning and
7591 end of each problematical keyword.  For example, use @code{__asm__}
7592 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7594 Other C compilers won't accept these alternative keywords; if you want to
7595 compile with another compiler, you can define the alternate keywords as
7596 macros to replace them with the customary keywords.  It looks like this:
7598 @smallexample
7599 #ifndef __GNUC__
7600 #define __asm__ asm
7601 #endif
7602 @end smallexample
7604 @findex __extension__
7605 @opindex pedantic
7606 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7607 You can
7608 prevent such warnings within one expression by writing
7609 @code{__extension__} before the expression.  @code{__extension__} has no
7610 effect aside from this.
7612 @node Incomplete Enums
7613 @section Incomplete @code{enum} Types
7615 You can define an @code{enum} tag without specifying its possible values.
7616 This results in an incomplete type, much like what you get if you write
7617 @code{struct foo} without describing the elements.  A later declaration
7618 that does specify the possible values completes the type.
7620 You can't allocate variables or storage using the type while it is
7621 incomplete.  However, you can work with pointers to that type.
7623 This extension may not be very useful, but it makes the handling of
7624 @code{enum} more consistent with the way @code{struct} and @code{union}
7625 are handled.
7627 This extension is not supported by GNU C++.
7629 @node Function Names
7630 @section Function Names as Strings
7631 @cindex @code{__func__} identifier
7632 @cindex @code{__FUNCTION__} identifier
7633 @cindex @code{__PRETTY_FUNCTION__} identifier
7635 GCC provides three magic variables that hold the name of the current
7636 function, as a string.  The first of these is @code{__func__}, which
7637 is part of the C99 standard:
7639 The identifier @code{__func__} is implicitly declared by the translator
7640 as if, immediately following the opening brace of each function
7641 definition, the declaration
7643 @smallexample
7644 static const char __func__[] = "function-name";
7645 @end smallexample
7647 @noindent
7648 appeared, where function-name is the name of the lexically-enclosing
7649 function.  This name is the unadorned name of the function.
7651 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7652 versions of GCC recognize only this name.  However, it is not
7653 standardized.  For maximum portability, we recommend you use
7654 @code{__func__}, but provide a fallback definition with the
7655 preprocessor:
7657 @smallexample
7658 #if __STDC_VERSION__ < 199901L
7659 # if __GNUC__ >= 2
7660 #  define __func__ __FUNCTION__
7661 # else
7662 #  define __func__ "<unknown>"
7663 # endif
7664 #endif
7665 @end smallexample
7667 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7668 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7669 the type signature of the function as well as its bare name.  For
7670 example, this program:
7672 @smallexample
7673 extern "C" @{
7674 extern int printf (char *, ...);
7677 class a @{
7678  public:
7679   void sub (int i)
7680     @{
7681       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7682       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7683     @}
7687 main (void)
7689   a ax;
7690   ax.sub (0);
7691   return 0;
7693 @end smallexample
7695 @noindent
7696 gives this output:
7698 @smallexample
7699 __FUNCTION__ = sub
7700 __PRETTY_FUNCTION__ = void a::sub(int)
7701 @end smallexample
7703 These identifiers are not preprocessor macros.  In GCC 3.3 and
7704 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7705 were treated as string literals; they could be used to initialize
7706 @code{char} arrays, and they could be concatenated with other string
7707 literals.  GCC 3.4 and later treat them as variables, like
7708 @code{__func__}.  In C++, @code{__FUNCTION__} and
7709 @code{__PRETTY_FUNCTION__} have always been variables.
7711 @node Return Address
7712 @section Getting the Return or Frame Address of a Function
7714 These functions may be used to get information about the callers of a
7715 function.
7717 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7718 This function returns the return address of the current function, or of
7719 one of its callers.  The @var{level} argument is number of frames to
7720 scan up the call stack.  A value of @code{0} yields the return address
7721 of the current function, a value of @code{1} yields the return address
7722 of the caller of the current function, and so forth.  When inlining
7723 the expected behavior is that the function returns the address of
7724 the function that is returned to.  To work around this behavior use
7725 the @code{noinline} function attribute.
7727 The @var{level} argument must be a constant integer.
7729 On some machines it may be impossible to determine the return address of
7730 any function other than the current one; in such cases, or when the top
7731 of the stack has been reached, this function returns @code{0} or a
7732 random value.  In addition, @code{__builtin_frame_address} may be used
7733 to determine if the top of the stack has been reached.
7735 Additional post-processing of the returned value may be needed, see
7736 @code{__builtin_extract_return_addr}.
7738 This function should only be used with a nonzero argument for debugging
7739 purposes.
7740 @end deftypefn
7742 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7743 The address as returned by @code{__builtin_return_address} may have to be fed
7744 through this function to get the actual encoded address.  For example, on the
7745 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7746 platforms an offset has to be added for the true next instruction to be
7747 executed.
7749 If no fixup is needed, this function simply passes through @var{addr}.
7750 @end deftypefn
7752 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7753 This function does the reverse of @code{__builtin_extract_return_addr}.
7754 @end deftypefn
7756 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7757 This function is similar to @code{__builtin_return_address}, but it
7758 returns the address of the function frame rather than the return address
7759 of the function.  Calling @code{__builtin_frame_address} with a value of
7760 @code{0} yields the frame address of the current function, a value of
7761 @code{1} yields the frame address of the caller of the current function,
7762 and so forth.
7764 The frame is the area on the stack that holds local variables and saved
7765 registers.  The frame address is normally the address of the first word
7766 pushed on to the stack by the function.  However, the exact definition
7767 depends upon the processor and the calling convention.  If the processor
7768 has a dedicated frame pointer register, and the function has a frame,
7769 then @code{__builtin_frame_address} returns the value of the frame
7770 pointer register.
7772 On some machines it may be impossible to determine the frame address of
7773 any function other than the current one; in such cases, or when the top
7774 of the stack has been reached, this function returns @code{0} if
7775 the first frame pointer is properly initialized by the startup code.
7777 This function should only be used with a nonzero argument for debugging
7778 purposes.
7779 @end deftypefn
7781 @node Vector Extensions
7782 @section Using Vector Instructions through Built-in Functions
7784 On some targets, the instruction set contains SIMD vector instructions which
7785 operate on multiple values contained in one large register at the same time.
7786 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7787 this way.
7789 The first step in using these extensions is to provide the necessary data
7790 types.  This should be done using an appropriate @code{typedef}:
7792 @smallexample
7793 typedef int v4si __attribute__ ((vector_size (16)));
7794 @end smallexample
7796 @noindent
7797 The @code{int} type specifies the base type, while the attribute specifies
7798 the vector size for the variable, measured in bytes.  For example, the
7799 declaration above causes the compiler to set the mode for the @code{v4si}
7800 type to be 16 bytes wide and divided into @code{int} sized units.  For
7801 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7802 corresponding mode of @code{foo} is @acronym{V4SI}.
7804 The @code{vector_size} attribute is only applicable to integral and
7805 float scalars, although arrays, pointers, and function return values
7806 are allowed in conjunction with this construct. Only sizes that are
7807 a power of two are currently allowed.
7809 All the basic integer types can be used as base types, both as signed
7810 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7811 @code{long long}.  In addition, @code{float} and @code{double} can be
7812 used to build floating-point vector types.
7814 Specifying a combination that is not valid for the current architecture
7815 causes GCC to synthesize the instructions using a narrower mode.
7816 For example, if you specify a variable of type @code{V4SI} and your
7817 architecture does not allow for this specific SIMD type, GCC
7818 produces code that uses 4 @code{SIs}.
7820 The types defined in this manner can be used with a subset of normal C
7821 operations.  Currently, GCC allows using the following operators
7822 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7824 The operations behave like C++ @code{valarrays}.  Addition is defined as
7825 the addition of the corresponding elements of the operands.  For
7826 example, in the code below, each of the 4 elements in @var{a} is
7827 added to the corresponding 4 elements in @var{b} and the resulting
7828 vector is stored in @var{c}.
7830 @smallexample
7831 typedef int v4si __attribute__ ((vector_size (16)));
7833 v4si a, b, c;
7835 c = a + b;
7836 @end smallexample
7838 Subtraction, multiplication, division, and the logical operations
7839 operate in a similar manner.  Likewise, the result of using the unary
7840 minus or complement operators on a vector type is a vector whose
7841 elements are the negative or complemented values of the corresponding
7842 elements in the operand.
7844 It is possible to use shifting operators @code{<<}, @code{>>} on
7845 integer-type vectors. The operation is defined as following: @code{@{a0,
7846 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7847 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7848 elements. 
7850 For convenience, it is allowed to use a binary vector operation
7851 where one operand is a scalar. In that case the compiler transforms
7852 the scalar operand into a vector where each element is the scalar from
7853 the operation. The transformation happens only if the scalar could be
7854 safely converted to the vector-element type.
7855 Consider the following code.
7857 @smallexample
7858 typedef int v4si __attribute__ ((vector_size (16)));
7860 v4si a, b, c;
7861 long l;
7863 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7864 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7866 a = l + a;    /* Error, cannot convert long to int. */
7867 @end smallexample
7869 Vectors can be subscripted as if the vector were an array with
7870 the same number of elements and base type.  Out of bound accesses
7871 invoke undefined behavior at run time.  Warnings for out of bound
7872 accesses for vector subscription can be enabled with
7873 @option{-Warray-bounds}.
7875 Vector comparison is supported with standard comparison
7876 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7877 vector expressions of integer-type or real-type. Comparison between
7878 integer-type vectors and real-type vectors are not supported.  The
7879 result of the comparison is a vector of the same width and number of
7880 elements as the comparison operands with a signed integral element
7881 type.
7883 Vectors are compared element-wise producing 0 when comparison is false
7884 and -1 (constant of the appropriate type where all bits are set)
7885 otherwise. Consider the following example.
7887 @smallexample
7888 typedef int v4si __attribute__ ((vector_size (16)));
7890 v4si a = @{1,2,3,4@};
7891 v4si b = @{3,2,1,4@};
7892 v4si c;
7894 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7895 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7896 @end smallexample
7898 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
7899 @code{b} and @code{c} are vectors of the same type and @code{a} is an
7900 integer vector with the same number of elements of the same size as @code{b}
7901 and @code{c}, computes all three arguments and creates a vector
7902 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
7903 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
7904 As in the case of binary operations, this syntax is also accepted when
7905 one of @code{b} or @code{c} is a scalar that is then transformed into a
7906 vector. If both @code{b} and @code{c} are scalars and the type of
7907 @code{true?b:c} has the same size as the element type of @code{a}, then
7908 @code{b} and @code{c} are converted to a vector type whose elements have
7909 this type and with the same number of elements as @code{a}.
7911 Vector shuffling is available using functions
7912 @code{__builtin_shuffle (vec, mask)} and
7913 @code{__builtin_shuffle (vec0, vec1, mask)}.
7914 Both functions construct a permutation of elements from one or two
7915 vectors and return a vector of the same type as the input vector(s).
7916 The @var{mask} is an integral vector with the same width (@var{W})
7917 and element count (@var{N}) as the output vector.
7919 The elements of the input vectors are numbered in memory ordering of
7920 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
7921 elements of @var{mask} are considered modulo @var{N} in the single-operand
7922 case and modulo @math{2*@var{N}} in the two-operand case.
7924 Consider the following example,
7926 @smallexample
7927 typedef int v4si __attribute__ ((vector_size (16)));
7929 v4si a = @{1,2,3,4@};
7930 v4si b = @{5,6,7,8@};
7931 v4si mask1 = @{0,1,1,3@};
7932 v4si mask2 = @{0,4,2,5@};
7933 v4si res;
7935 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
7936 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
7937 @end smallexample
7939 Note that @code{__builtin_shuffle} is intentionally semantically
7940 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7942 You can declare variables and use them in function calls and returns, as
7943 well as in assignments and some casts.  You can specify a vector type as
7944 a return type for a function.  Vector types can also be used as function
7945 arguments.  It is possible to cast from one vector type to another,
7946 provided they are of the same size (in fact, you can also cast vectors
7947 to and from other datatypes of the same size).
7949 You cannot operate between vectors of different lengths or different
7950 signedness without a cast.
7952 @node Offsetof
7953 @section Offsetof
7954 @findex __builtin_offsetof
7956 GCC implements for both C and C++ a syntactic extension to implement
7957 the @code{offsetof} macro.
7959 @smallexample
7960 primary:
7961         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7963 offsetof_member_designator:
7964           @code{identifier}
7965         | offsetof_member_designator "." @code{identifier}
7966         | offsetof_member_designator "[" @code{expr} "]"
7967 @end smallexample
7969 This extension is sufficient such that
7971 @smallexample
7972 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
7973 @end smallexample
7975 @noindent
7976 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
7977 may be dependent.  In either case, @var{member} may consist of a single
7978 identifier, or a sequence of member accesses and array references.
7980 @node __sync Builtins
7981 @section Legacy __sync Built-in Functions for Atomic Memory Access
7983 The following built-in functions
7984 are intended to be compatible with those described
7985 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7986 section 7.4.  As such, they depart from the normal GCC practice of using
7987 the @samp{__builtin_} prefix, and further that they are overloaded such that
7988 they work on multiple types.
7990 The definition given in the Intel documentation allows only for the use of
7991 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7992 counterparts.  GCC allows any integral scalar or pointer type that is
7993 1, 2, 4 or 8 bytes in length.
7995 Not all operations are supported by all target processors.  If a particular
7996 operation cannot be implemented on the target processor, a warning is
7997 generated and a call an external function is generated.  The external
7998 function carries the same name as the built-in version,
7999 with an additional suffix
8000 @samp{_@var{n}} where @var{n} is the size of the data type.
8002 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8003 @c useful for implementing the operation under the control of an external
8004 @c mutex.
8006 In most cases, these built-in functions are considered a @dfn{full barrier}.
8007 That is,
8008 no memory operand is moved across the operation, either forward or
8009 backward.  Further, instructions are issued as necessary to prevent the
8010 processor from speculating loads across the operation and from queuing stores
8011 after the operation.
8013 All of the routines are described in the Intel documentation to take
8014 ``an optional list of variables protected by the memory barrier''.  It's
8015 not clear what is meant by that; it could mean that @emph{only} the
8016 following variables are protected, or it could mean that these variables
8017 should in addition be protected.  At present GCC ignores this list and
8018 protects all variables that are globally accessible.  If in the future
8019 we make some use of this list, an empty list will continue to mean all
8020 globally accessible variables.
8022 @table @code
8023 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8024 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8025 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8026 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8027 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8028 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8029 @findex __sync_fetch_and_add
8030 @findex __sync_fetch_and_sub
8031 @findex __sync_fetch_and_or
8032 @findex __sync_fetch_and_and
8033 @findex __sync_fetch_and_xor
8034 @findex __sync_fetch_and_nand
8035 These built-in functions perform the operation suggested by the name, and
8036 returns the value that had previously been in memory.  That is,
8038 @smallexample
8039 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8040 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8041 @end smallexample
8043 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8044 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8046 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8047 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8048 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8049 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8050 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8051 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8052 @findex __sync_add_and_fetch
8053 @findex __sync_sub_and_fetch
8054 @findex __sync_or_and_fetch
8055 @findex __sync_and_and_fetch
8056 @findex __sync_xor_and_fetch
8057 @findex __sync_nand_and_fetch
8058 These built-in functions perform the operation suggested by the name, and
8059 return the new value.  That is,
8061 @smallexample
8062 @{ *ptr @var{op}= value; return *ptr; @}
8063 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8064 @end smallexample
8066 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8067 as @code{*ptr = ~(*ptr & value)} instead of
8068 @code{*ptr = ~*ptr & value}.
8070 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8071 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8072 @findex __sync_bool_compare_and_swap
8073 @findex __sync_val_compare_and_swap
8074 These built-in functions perform an atomic compare and swap.
8075 That is, if the current
8076 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8077 @code{*@var{ptr}}.
8079 The ``bool'' version returns true if the comparison is successful and
8080 @var{newval} is written.  The ``val'' version returns the contents
8081 of @code{*@var{ptr}} before the operation.
8083 @item __sync_synchronize (...)
8084 @findex __sync_synchronize
8085 This built-in function issues a full memory barrier.
8087 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8088 @findex __sync_lock_test_and_set
8089 This built-in function, as described by Intel, is not a traditional test-and-set
8090 operation, but rather an atomic exchange operation.  It writes @var{value}
8091 into @code{*@var{ptr}}, and returns the previous contents of
8092 @code{*@var{ptr}}.
8094 Many targets have only minimal support for such locks, and do not support
8095 a full exchange operation.  In this case, a target may support reduced
8096 functionality here by which the @emph{only} valid value to store is the
8097 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8098 is implementation defined.
8100 This built-in function is not a full barrier,
8101 but rather an @dfn{acquire barrier}.
8102 This means that references after the operation cannot move to (or be
8103 speculated to) before the operation, but previous memory stores may not
8104 be globally visible yet, and previous memory loads may not yet be
8105 satisfied.
8107 @item void __sync_lock_release (@var{type} *ptr, ...)
8108 @findex __sync_lock_release
8109 This built-in function releases the lock acquired by
8110 @code{__sync_lock_test_and_set}.
8111 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8113 This built-in function is not a full barrier,
8114 but rather a @dfn{release barrier}.
8115 This means that all previous memory stores are globally visible, and all
8116 previous memory loads have been satisfied, but following memory reads
8117 are not prevented from being speculated to before the barrier.
8118 @end table
8120 @node __atomic Builtins
8121 @section Built-in functions for memory model aware atomic operations
8123 The following built-in functions approximately match the requirements for
8124 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8125 functions, but all also have a memory model parameter.  These are all
8126 identified by being prefixed with @samp{__atomic}, and most are overloaded
8127 such that they work with multiple types.
8129 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8130 bytes in length. 16-byte integral types are also allowed if
8131 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8133 Target architectures are encouraged to provide their own patterns for
8134 each of these built-in functions.  If no target is provided, the original 
8135 non-memory model set of @samp{__sync} atomic built-in functions are
8136 utilized, along with any required synchronization fences surrounding it in
8137 order to achieve the proper behavior.  Execution in this case is subject
8138 to the same restrictions as those built-in functions.
8140 If there is no pattern or mechanism to provide a lock free instruction
8141 sequence, a call is made to an external routine with the same parameters
8142 to be resolved at run time.
8144 The four non-arithmetic functions (load, store, exchange, and 
8145 compare_exchange) all have a generic version as well.  This generic
8146 version works on any data type.  If the data type size maps to one
8147 of the integral sizes that may have lock free support, the generic
8148 version utilizes the lock free built-in function.  Otherwise an
8149 external call is left to be resolved at run time.  This external call is
8150 the same format with the addition of a @samp{size_t} parameter inserted
8151 as the first parameter indicating the size of the object being pointed to.
8152 All objects must be the same size.
8154 There are 6 different memory models that can be specified.  These map
8155 to the same names in the C++11 standard.  Refer there or to the
8156 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8157 atomic synchronization} for more detailed definitions.  These memory
8158 models integrate both barriers to code motion as well as synchronization
8159 requirements with other threads. These are listed in approximately
8160 ascending order of strength. It is also possible to use target specific
8161 flags for memory model flags, like Hardware Lock Elision.
8163 @table  @code
8164 @item __ATOMIC_RELAXED
8165 No barriers or synchronization.
8166 @item __ATOMIC_CONSUME
8167 Data dependency only for both barrier and synchronization with another
8168 thread.
8169 @item __ATOMIC_ACQUIRE
8170 Barrier to hoisting of code and synchronizes with release (or stronger)
8171 semantic stores from another thread.
8172 @item __ATOMIC_RELEASE
8173 Barrier to sinking of code and synchronizes with acquire (or stronger)
8174 semantic loads from another thread.
8175 @item __ATOMIC_ACQ_REL
8176 Full barrier in both directions and synchronizes with acquire loads and
8177 release stores in another thread.
8178 @item __ATOMIC_SEQ_CST
8179 Full barrier in both directions and synchronizes with acquire loads and
8180 release stores in all threads.
8181 @end table
8183 When implementing patterns for these built-in functions, the memory model
8184 parameter can be ignored as long as the pattern implements the most
8185 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8186 execute correctly with this memory model but they may not execute as
8187 efficiently as they could with a more appropriate implementation of the
8188 relaxed requirements.
8190 Note that the C++11 standard allows for the memory model parameter to be
8191 determined at run time rather than at compile time.  These built-in
8192 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8193 than invoke a runtime library call or inline a switch statement.  This is
8194 standard compliant, safe, and the simplest approach for now.
8196 The memory model parameter is a signed int, but only the lower 8 bits are
8197 reserved for the memory model.  The remainder of the signed int is reserved
8198 for future use and should be 0.  Use of the predefined atomic values
8199 ensures proper usage.
8201 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8202 This built-in function implements an atomic load operation.  It returns the
8203 contents of @code{*@var{ptr}}.
8205 The valid memory model variants are
8206 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8207 and @code{__ATOMIC_CONSUME}.
8209 @end deftypefn
8211 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8212 This is the generic version of an atomic load.  It returns the
8213 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8215 @end deftypefn
8217 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8218 This built-in function implements an atomic store operation.  It writes 
8219 @code{@var{val}} into @code{*@var{ptr}}.  
8221 The valid memory model variants are
8222 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8224 @end deftypefn
8226 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8227 This is the generic version of an atomic store.  It stores the value
8228 of @code{*@var{val}} into @code{*@var{ptr}}.
8230 @end deftypefn
8232 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8233 This built-in function implements an atomic exchange operation.  It writes
8234 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8235 @code{*@var{ptr}}.
8237 The valid memory model variants are
8238 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8239 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8241 @end deftypefn
8243 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8244 This is the generic version of an atomic exchange.  It stores the
8245 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8246 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8248 @end deftypefn
8250 @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)
8251 This built-in function implements an atomic compare and exchange operation.
8252 This compares the contents of @code{*@var{ptr}} with the contents of
8253 @code{*@var{expected}} and if equal, writes @var{desired} into
8254 @code{*@var{ptr}}.  If they are not equal, the current contents of
8255 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8256 for weak compare_exchange, and false for the strong variation.  Many targets 
8257 only offer the strong variation and ignore the parameter.  When in doubt, use
8258 the strong variation.
8260 True is returned if @var{desired} is written into
8261 @code{*@var{ptr}} and the execution is considered to conform to the
8262 memory model specified by @var{success_memmodel}.  There are no
8263 restrictions on what memory model can be used here.
8265 False is returned otherwise, and the execution is considered to conform
8266 to @var{failure_memmodel}. This memory model cannot be
8267 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8268 stronger model than that specified by @var{success_memmodel}.
8270 @end deftypefn
8272 @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)
8273 This built-in function implements the generic version of
8274 @code{__atomic_compare_exchange}.  The function is virtually identical to
8275 @code{__atomic_compare_exchange_n}, except the desired value is also a
8276 pointer.
8278 @end deftypefn
8280 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8281 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8282 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8283 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8284 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8285 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8286 These built-in functions perform the operation suggested by the name, and
8287 return the result of the operation. That is,
8289 @smallexample
8290 @{ *ptr @var{op}= val; return *ptr; @}
8291 @end smallexample
8293 All memory models are valid.
8295 @end deftypefn
8297 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8298 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8299 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8300 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8301 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8302 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8303 These built-in functions perform the operation suggested by the name, and
8304 return the value that had previously been in @code{*@var{ptr}}.  That is,
8306 @smallexample
8307 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8308 @end smallexample
8310 All memory models are valid.
8312 @end deftypefn
8314 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8316 This built-in function performs an atomic test-and-set operation on
8317 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8318 defined nonzero ``set'' value and the return value is @code{true} if and only
8319 if the previous contents were ``set''.
8320 It should be only used for operands of type @code{bool} or @code{char}. For 
8321 other types only part of the value may be set.
8323 All memory models are valid.
8325 @end deftypefn
8327 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8329 This built-in function performs an atomic clear operation on
8330 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8331 It should be only used for operands of type @code{bool} or @code{char} and 
8332 in conjunction with @code{__atomic_test_and_set}.
8333 For other types it may only clear partially. If the type is not @code{bool}
8334 prefer using @code{__atomic_store}.
8336 The valid memory model variants are
8337 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8338 @code{__ATOMIC_RELEASE}.
8340 @end deftypefn
8342 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8344 This built-in function acts as a synchronization fence between threads
8345 based on the specified memory model.
8347 All memory orders are valid.
8349 @end deftypefn
8351 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8353 This built-in function acts as a synchronization fence between a thread
8354 and signal handlers based in the same thread.
8356 All memory orders are valid.
8358 @end deftypefn
8360 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8362 This built-in function returns true if objects of @var{size} bytes always
8363 generate lock free atomic instructions for the target architecture.  
8364 @var{size} must resolve to a compile-time constant and the result also
8365 resolves to a compile-time constant.
8367 @var{ptr} is an optional pointer to the object that may be used to determine
8368 alignment.  A value of 0 indicates typical alignment should be used.  The 
8369 compiler may also ignore this parameter.
8371 @smallexample
8372 if (_atomic_always_lock_free (sizeof (long long), 0))
8373 @end smallexample
8375 @end deftypefn
8377 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8379 This built-in function returns true if objects of @var{size} bytes always
8380 generate lock free atomic instructions for the target architecture.  If
8381 it is not known to be lock free a call is made to a runtime routine named
8382 @code{__atomic_is_lock_free}.
8384 @var{ptr} is an optional pointer to the object that may be used to determine
8385 alignment.  A value of 0 indicates typical alignment should be used.  The 
8386 compiler may also ignore this parameter.
8387 @end deftypefn
8389 @node x86 specific memory model extensions for transactional memory
8390 @section x86 specific memory model extensions for transactional memory
8392 The i386 architecture supports additional memory ordering flags
8393 to mark lock critical sections for hardware lock elision. 
8394 These must be specified in addition to an existing memory model to 
8395 atomic intrinsics.
8397 @table @code
8398 @item __ATOMIC_HLE_ACQUIRE
8399 Start lock elision on a lock variable.
8400 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8401 @item __ATOMIC_HLE_RELEASE
8402 End lock elision on a lock variable.
8403 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8404 @end table
8406 When a lock acquire fails it is required for good performance to abort
8407 the transaction quickly. This can be done with a @code{_mm_pause}
8409 @smallexample
8410 #include <immintrin.h> // For _mm_pause
8412 int lockvar;
8414 /* Acquire lock with lock elision */
8415 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8416     _mm_pause(); /* Abort failed transaction */
8418 /* Free lock with lock elision */
8419 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8420 @end smallexample
8422 @node Object Size Checking
8423 @section Object Size Checking Built-in Functions
8424 @findex __builtin_object_size
8425 @findex __builtin___memcpy_chk
8426 @findex __builtin___mempcpy_chk
8427 @findex __builtin___memmove_chk
8428 @findex __builtin___memset_chk
8429 @findex __builtin___strcpy_chk
8430 @findex __builtin___stpcpy_chk
8431 @findex __builtin___strncpy_chk
8432 @findex __builtin___strcat_chk
8433 @findex __builtin___strncat_chk
8434 @findex __builtin___sprintf_chk
8435 @findex __builtin___snprintf_chk
8436 @findex __builtin___vsprintf_chk
8437 @findex __builtin___vsnprintf_chk
8438 @findex __builtin___printf_chk
8439 @findex __builtin___vprintf_chk
8440 @findex __builtin___fprintf_chk
8441 @findex __builtin___vfprintf_chk
8443 GCC implements a limited buffer overflow protection mechanism
8444 that can prevent some buffer overflow attacks.
8446 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8447 is a built-in construct that returns a constant number of bytes from
8448 @var{ptr} to the end of the object @var{ptr} pointer points to
8449 (if known at compile time).  @code{__builtin_object_size} never evaluates
8450 its arguments for side-effects.  If there are any side-effects in them, it
8451 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8452 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8453 point to and all of them are known at compile time, the returned number
8454 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8455 0 and minimum if nonzero.  If it is not possible to determine which objects
8456 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8457 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8458 for @var{type} 2 or 3.
8460 @var{type} is an integer constant from 0 to 3.  If the least significant
8461 bit is clear, objects are whole variables, if it is set, a closest
8462 surrounding subobject is considered the object a pointer points to.
8463 The second bit determines if maximum or minimum of remaining bytes
8464 is computed.
8466 @smallexample
8467 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8468 char *p = &var.buf1[1], *q = &var.b;
8470 /* Here the object p points to is var.  */
8471 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8472 /* The subobject p points to is var.buf1.  */
8473 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8474 /* The object q points to is var.  */
8475 assert (__builtin_object_size (q, 0)
8476         == (char *) (&var + 1) - (char *) &var.b);
8477 /* The subobject q points to is var.b.  */
8478 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8479 @end smallexample
8480 @end deftypefn
8482 There are built-in functions added for many common string operation
8483 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8484 built-in is provided.  This built-in has an additional last argument,
8485 which is the number of bytes remaining in object the @var{dest}
8486 argument points to or @code{(size_t) -1} if the size is not known.
8488 The built-in functions are optimized into the normal string functions
8489 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8490 it is known at compile time that the destination object will not
8491 be overflown.  If the compiler can determine at compile time the
8492 object will be always overflown, it issues a warning.
8494 The intended use can be e.g.@:
8496 @smallexample
8497 #undef memcpy
8498 #define bos0(dest) __builtin_object_size (dest, 0)
8499 #define memcpy(dest, src, n) \
8500   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8502 char *volatile p;
8503 char buf[10];
8504 /* It is unknown what object p points to, so this is optimized
8505    into plain memcpy - no checking is possible.  */
8506 memcpy (p, "abcde", n);
8507 /* Destination is known and length too.  It is known at compile
8508    time there will be no overflow.  */
8509 memcpy (&buf[5], "abcde", 5);
8510 /* Destination is known, but the length is not known at compile time.
8511    This will result in __memcpy_chk call that can check for overflow
8512    at run time.  */
8513 memcpy (&buf[5], "abcde", n);
8514 /* Destination is known and it is known at compile time there will
8515    be overflow.  There will be a warning and __memcpy_chk call that
8516    will abort the program at run time.  */
8517 memcpy (&buf[6], "abcde", 5);
8518 @end smallexample
8520 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8521 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8522 @code{strcat} and @code{strncat}.
8524 There are also checking built-in functions for formatted output functions.
8525 @smallexample
8526 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8527 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8528                               const char *fmt, ...);
8529 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8530                               va_list ap);
8531 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8532                                const char *fmt, va_list ap);
8533 @end smallexample
8535 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8536 etc.@: functions and can contain implementation specific flags on what
8537 additional security measures the checking function might take, such as
8538 handling @code{%n} differently.
8540 The @var{os} argument is the object size @var{s} points to, like in the
8541 other built-in functions.  There is a small difference in the behavior
8542 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8543 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8544 the checking function is called with @var{os} argument set to
8545 @code{(size_t) -1}.
8547 In addition to this, there are checking built-in functions
8548 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8549 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8550 These have just one additional argument, @var{flag}, right before
8551 format string @var{fmt}.  If the compiler is able to optimize them to
8552 @code{fputc} etc.@: functions, it does, otherwise the checking function
8553 is called and the @var{flag} argument passed to it.
8555 @node Cilk Plus Builtins
8556 @section Cilk Plus C/C++ language extension Built-in Functions.
8558 GCC provides support for the following built-in reduction funtions if Cilk Plus
8559 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8561 @itemize @bullet
8562 @item __sec_implicit_index
8563 @item __sec_reduce
8564 @item __sec_reduce_add
8565 @item __sec_reduce_all_nonzero
8566 @item __sec_reduce_all_zero
8567 @item __sec_reduce_any_nonzero
8568 @item __sec_reduce_any_zero
8569 @item __sec_reduce_max
8570 @item __sec_reduce_min
8571 @item __sec_reduce_max_ind
8572 @item __sec_reduce_min_ind
8573 @item __sec_reduce_mul
8574 @item __sec_reduce_mutating
8575 @end itemize
8577 Further details and examples about these built-in functions are described 
8578 in the Cilk Plus language manual which can be found at 
8579 @uref{http://www.cilkplus.org}.
8581 @node Other Builtins
8582 @section Other Built-in Functions Provided by GCC
8583 @cindex built-in functions
8584 @findex __builtin_fpclassify
8585 @findex __builtin_isfinite
8586 @findex __builtin_isnormal
8587 @findex __builtin_isgreater
8588 @findex __builtin_isgreaterequal
8589 @findex __builtin_isinf_sign
8590 @findex __builtin_isless
8591 @findex __builtin_islessequal
8592 @findex __builtin_islessgreater
8593 @findex __builtin_isunordered
8594 @findex __builtin_powi
8595 @findex __builtin_powif
8596 @findex __builtin_powil
8597 @findex _Exit
8598 @findex _exit
8599 @findex abort
8600 @findex abs
8601 @findex acos
8602 @findex acosf
8603 @findex acosh
8604 @findex acoshf
8605 @findex acoshl
8606 @findex acosl
8607 @findex alloca
8608 @findex asin
8609 @findex asinf
8610 @findex asinh
8611 @findex asinhf
8612 @findex asinhl
8613 @findex asinl
8614 @findex atan
8615 @findex atan2
8616 @findex atan2f
8617 @findex atan2l
8618 @findex atanf
8619 @findex atanh
8620 @findex atanhf
8621 @findex atanhl
8622 @findex atanl
8623 @findex bcmp
8624 @findex bzero
8625 @findex cabs
8626 @findex cabsf
8627 @findex cabsl
8628 @findex cacos
8629 @findex cacosf
8630 @findex cacosh
8631 @findex cacoshf
8632 @findex cacoshl
8633 @findex cacosl
8634 @findex calloc
8635 @findex carg
8636 @findex cargf
8637 @findex cargl
8638 @findex casin
8639 @findex casinf
8640 @findex casinh
8641 @findex casinhf
8642 @findex casinhl
8643 @findex casinl
8644 @findex catan
8645 @findex catanf
8646 @findex catanh
8647 @findex catanhf
8648 @findex catanhl
8649 @findex catanl
8650 @findex cbrt
8651 @findex cbrtf
8652 @findex cbrtl
8653 @findex ccos
8654 @findex ccosf
8655 @findex ccosh
8656 @findex ccoshf
8657 @findex ccoshl
8658 @findex ccosl
8659 @findex ceil
8660 @findex ceilf
8661 @findex ceill
8662 @findex cexp
8663 @findex cexpf
8664 @findex cexpl
8665 @findex cimag
8666 @findex cimagf
8667 @findex cimagl
8668 @findex clog
8669 @findex clogf
8670 @findex clogl
8671 @findex conj
8672 @findex conjf
8673 @findex conjl
8674 @findex copysign
8675 @findex copysignf
8676 @findex copysignl
8677 @findex cos
8678 @findex cosf
8679 @findex cosh
8680 @findex coshf
8681 @findex coshl
8682 @findex cosl
8683 @findex cpow
8684 @findex cpowf
8685 @findex cpowl
8686 @findex cproj
8687 @findex cprojf
8688 @findex cprojl
8689 @findex creal
8690 @findex crealf
8691 @findex creall
8692 @findex csin
8693 @findex csinf
8694 @findex csinh
8695 @findex csinhf
8696 @findex csinhl
8697 @findex csinl
8698 @findex csqrt
8699 @findex csqrtf
8700 @findex csqrtl
8701 @findex ctan
8702 @findex ctanf
8703 @findex ctanh
8704 @findex ctanhf
8705 @findex ctanhl
8706 @findex ctanl
8707 @findex dcgettext
8708 @findex dgettext
8709 @findex drem
8710 @findex dremf
8711 @findex dreml
8712 @findex erf
8713 @findex erfc
8714 @findex erfcf
8715 @findex erfcl
8716 @findex erff
8717 @findex erfl
8718 @findex exit
8719 @findex exp
8720 @findex exp10
8721 @findex exp10f
8722 @findex exp10l
8723 @findex exp2
8724 @findex exp2f
8725 @findex exp2l
8726 @findex expf
8727 @findex expl
8728 @findex expm1
8729 @findex expm1f
8730 @findex expm1l
8731 @findex fabs
8732 @findex fabsf
8733 @findex fabsl
8734 @findex fdim
8735 @findex fdimf
8736 @findex fdiml
8737 @findex ffs
8738 @findex floor
8739 @findex floorf
8740 @findex floorl
8741 @findex fma
8742 @findex fmaf
8743 @findex fmal
8744 @findex fmax
8745 @findex fmaxf
8746 @findex fmaxl
8747 @findex fmin
8748 @findex fminf
8749 @findex fminl
8750 @findex fmod
8751 @findex fmodf
8752 @findex fmodl
8753 @findex fprintf
8754 @findex fprintf_unlocked
8755 @findex fputs
8756 @findex fputs_unlocked
8757 @findex frexp
8758 @findex frexpf
8759 @findex frexpl
8760 @findex fscanf
8761 @findex gamma
8762 @findex gammaf
8763 @findex gammal
8764 @findex gamma_r
8765 @findex gammaf_r
8766 @findex gammal_r
8767 @findex gettext
8768 @findex hypot
8769 @findex hypotf
8770 @findex hypotl
8771 @findex ilogb
8772 @findex ilogbf
8773 @findex ilogbl
8774 @findex imaxabs
8775 @findex index
8776 @findex isalnum
8777 @findex isalpha
8778 @findex isascii
8779 @findex isblank
8780 @findex iscntrl
8781 @findex isdigit
8782 @findex isgraph
8783 @findex islower
8784 @findex isprint
8785 @findex ispunct
8786 @findex isspace
8787 @findex isupper
8788 @findex iswalnum
8789 @findex iswalpha
8790 @findex iswblank
8791 @findex iswcntrl
8792 @findex iswdigit
8793 @findex iswgraph
8794 @findex iswlower
8795 @findex iswprint
8796 @findex iswpunct
8797 @findex iswspace
8798 @findex iswupper
8799 @findex iswxdigit
8800 @findex isxdigit
8801 @findex j0
8802 @findex j0f
8803 @findex j0l
8804 @findex j1
8805 @findex j1f
8806 @findex j1l
8807 @findex jn
8808 @findex jnf
8809 @findex jnl
8810 @findex labs
8811 @findex ldexp
8812 @findex ldexpf
8813 @findex ldexpl
8814 @findex lgamma
8815 @findex lgammaf
8816 @findex lgammal
8817 @findex lgamma_r
8818 @findex lgammaf_r
8819 @findex lgammal_r
8820 @findex llabs
8821 @findex llrint
8822 @findex llrintf
8823 @findex llrintl
8824 @findex llround
8825 @findex llroundf
8826 @findex llroundl
8827 @findex log
8828 @findex log10
8829 @findex log10f
8830 @findex log10l
8831 @findex log1p
8832 @findex log1pf
8833 @findex log1pl
8834 @findex log2
8835 @findex log2f
8836 @findex log2l
8837 @findex logb
8838 @findex logbf
8839 @findex logbl
8840 @findex logf
8841 @findex logl
8842 @findex lrint
8843 @findex lrintf
8844 @findex lrintl
8845 @findex lround
8846 @findex lroundf
8847 @findex lroundl
8848 @findex malloc
8849 @findex memchr
8850 @findex memcmp
8851 @findex memcpy
8852 @findex mempcpy
8853 @findex memset
8854 @findex modf
8855 @findex modff
8856 @findex modfl
8857 @findex nearbyint
8858 @findex nearbyintf
8859 @findex nearbyintl
8860 @findex nextafter
8861 @findex nextafterf
8862 @findex nextafterl
8863 @findex nexttoward
8864 @findex nexttowardf
8865 @findex nexttowardl
8866 @findex pow
8867 @findex pow10
8868 @findex pow10f
8869 @findex pow10l
8870 @findex powf
8871 @findex powl
8872 @findex printf
8873 @findex printf_unlocked
8874 @findex putchar
8875 @findex puts
8876 @findex remainder
8877 @findex remainderf
8878 @findex remainderl
8879 @findex remquo
8880 @findex remquof
8881 @findex remquol
8882 @findex rindex
8883 @findex rint
8884 @findex rintf
8885 @findex rintl
8886 @findex round
8887 @findex roundf
8888 @findex roundl
8889 @findex scalb
8890 @findex scalbf
8891 @findex scalbl
8892 @findex scalbln
8893 @findex scalblnf
8894 @findex scalblnf
8895 @findex scalbn
8896 @findex scalbnf
8897 @findex scanfnl
8898 @findex signbit
8899 @findex signbitf
8900 @findex signbitl
8901 @findex signbitd32
8902 @findex signbitd64
8903 @findex signbitd128
8904 @findex significand
8905 @findex significandf
8906 @findex significandl
8907 @findex sin
8908 @findex sincos
8909 @findex sincosf
8910 @findex sincosl
8911 @findex sinf
8912 @findex sinh
8913 @findex sinhf
8914 @findex sinhl
8915 @findex sinl
8916 @findex snprintf
8917 @findex sprintf
8918 @findex sqrt
8919 @findex sqrtf
8920 @findex sqrtl
8921 @findex sscanf
8922 @findex stpcpy
8923 @findex stpncpy
8924 @findex strcasecmp
8925 @findex strcat
8926 @findex strchr
8927 @findex strcmp
8928 @findex strcpy
8929 @findex strcspn
8930 @findex strdup
8931 @findex strfmon
8932 @findex strftime
8933 @findex strlen
8934 @findex strncasecmp
8935 @findex strncat
8936 @findex strncmp
8937 @findex strncpy
8938 @findex strndup
8939 @findex strpbrk
8940 @findex strrchr
8941 @findex strspn
8942 @findex strstr
8943 @findex tan
8944 @findex tanf
8945 @findex tanh
8946 @findex tanhf
8947 @findex tanhl
8948 @findex tanl
8949 @findex tgamma
8950 @findex tgammaf
8951 @findex tgammal
8952 @findex toascii
8953 @findex tolower
8954 @findex toupper
8955 @findex towlower
8956 @findex towupper
8957 @findex trunc
8958 @findex truncf
8959 @findex truncl
8960 @findex vfprintf
8961 @findex vfscanf
8962 @findex vprintf
8963 @findex vscanf
8964 @findex vsnprintf
8965 @findex vsprintf
8966 @findex vsscanf
8967 @findex y0
8968 @findex y0f
8969 @findex y0l
8970 @findex y1
8971 @findex y1f
8972 @findex y1l
8973 @findex yn
8974 @findex ynf
8975 @findex ynl
8977 GCC provides a large number of built-in functions other than the ones
8978 mentioned above.  Some of these are for internal use in the processing
8979 of exceptions or variable-length argument lists and are not
8980 documented here because they may change from time to time; we do not
8981 recommend general use of these functions.
8983 The remaining functions are provided for optimization purposes.
8985 @opindex fno-builtin
8986 GCC includes built-in versions of many of the functions in the standard
8987 C library.  The versions prefixed with @code{__builtin_} are always
8988 treated as having the same meaning as the C library function even if you
8989 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
8990 Many of these functions are only optimized in certain cases; if they are
8991 not optimized in a particular case, a call to the library function is
8992 emitted.
8994 @opindex ansi
8995 @opindex std
8996 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8997 @option{-std=c99} or @option{-std=c11}), the functions
8998 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8999 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9000 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9001 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9002 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9003 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9004 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9005 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9006 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9007 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9008 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9009 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9010 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9011 @code{significandl}, @code{significand}, @code{sincosf},
9012 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9013 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9014 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9015 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9016 @code{yn}
9017 may be handled as built-in functions.
9018 All these functions have corresponding versions
9019 prefixed with @code{__builtin_}, which may be used even in strict C90
9020 mode.
9022 The ISO C99 functions
9023 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9024 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9025 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9026 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9027 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9028 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9029 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9030 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9031 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9032 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9033 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9034 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9035 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9036 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9037 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9038 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9039 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9040 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9041 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9042 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9043 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9044 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9045 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9046 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9047 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9048 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9049 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9050 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9051 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9052 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9053 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9054 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9055 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9056 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9057 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9058 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9059 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9060 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9061 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9062 are handled as built-in functions
9063 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9065 There are also built-in versions of the ISO C99 functions
9066 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9067 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9068 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9069 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9070 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9071 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9072 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9073 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9074 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9075 that are recognized in any mode since ISO C90 reserves these names for
9076 the purpose to which ISO C99 puts them.  All these functions have
9077 corresponding versions prefixed with @code{__builtin_}.
9079 The ISO C94 functions
9080 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9081 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9082 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9083 @code{towupper}
9084 are handled as built-in functions
9085 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9087 The ISO C90 functions
9088 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9089 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9090 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9091 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9092 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9093 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9094 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9095 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9096 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9097 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9098 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9099 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9100 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9101 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9102 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9103 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9104 are all recognized as built-in functions unless
9105 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9106 is specified for an individual function).  All of these functions have
9107 corresponding versions prefixed with @code{__builtin_}.
9109 GCC provides built-in versions of the ISO C99 floating-point comparison
9110 macros that avoid raising exceptions for unordered operands.  They have
9111 the same names as the standard macros ( @code{isgreater},
9112 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9113 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9114 prefixed.  We intend for a library implementor to be able to simply
9115 @code{#define} each standard macro to its built-in equivalent.
9116 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9117 @code{isinf_sign} and @code{isnormal} built-ins used with
9118 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9119 built-in functions appear both with and without the @code{__builtin_} prefix.
9121 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9123 You can use the built-in function @code{__builtin_types_compatible_p} to
9124 determine whether two types are the same.
9126 This built-in function returns 1 if the unqualified versions of the
9127 types @var{type1} and @var{type2} (which are types, not expressions) are
9128 compatible, 0 otherwise.  The result of this built-in function can be
9129 used in integer constant expressions.
9131 This built-in function ignores top level qualifiers (e.g., @code{const},
9132 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9133 int}.
9135 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9136 hand, @code{int} and @code{char *} are not compatible, even if the size
9137 of their types, on the particular architecture are the same.  Also, the
9138 amount of pointer indirection is taken into account when determining
9139 similarity.  Consequently, @code{short *} is not similar to
9140 @code{short **}.  Furthermore, two types that are typedefed are
9141 considered compatible if their underlying types are compatible.
9143 An @code{enum} type is not considered to be compatible with another
9144 @code{enum} type even if both are compatible with the same integer
9145 type; this is what the C standard specifies.
9146 For example, @code{enum @{foo, bar@}} is not similar to
9147 @code{enum @{hot, dog@}}.
9149 You typically use this function in code whose execution varies
9150 depending on the arguments' types.  For example:
9152 @smallexample
9153 #define foo(x)                                                  \
9154   (@{                                                           \
9155     typeof (x) tmp = (x);                                       \
9156     if (__builtin_types_compatible_p (typeof (x), long double)) \
9157       tmp = foo_long_double (tmp);                              \
9158     else if (__builtin_types_compatible_p (typeof (x), double)) \
9159       tmp = foo_double (tmp);                                   \
9160     else if (__builtin_types_compatible_p (typeof (x), float))  \
9161       tmp = foo_float (tmp);                                    \
9162     else                                                        \
9163       abort ();                                                 \
9164     tmp;                                                        \
9165   @})
9166 @end smallexample
9168 @emph{Note:} This construct is only available for C@.
9170 @end deftypefn
9172 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9174 You can use the built-in function @code{__builtin_choose_expr} to
9175 evaluate code depending on the value of a constant expression.  This
9176 built-in function returns @var{exp1} if @var{const_exp}, which is an
9177 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9179 This built-in function is analogous to the @samp{? :} operator in C,
9180 except that the expression returned has its type unaltered by promotion
9181 rules.  Also, the built-in function does not evaluate the expression
9182 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9183 @var{exp2} is not evaluated even if it has side-effects.
9185 This built-in function can return an lvalue if the chosen argument is an
9186 lvalue.
9188 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9189 type.  Similarly, if @var{exp2} is returned, its return type is the same
9190 as @var{exp2}.
9192 Example:
9194 @smallexample
9195 #define foo(x)                                                    \
9196   __builtin_choose_expr (                                         \
9197     __builtin_types_compatible_p (typeof (x), double),            \
9198     foo_double (x),                                               \
9199     __builtin_choose_expr (                                       \
9200       __builtin_types_compatible_p (typeof (x), float),           \
9201       foo_float (x),                                              \
9202       /* @r{The void expression results in a compile-time error}  \
9203          @r{when assigning the result to something.}  */          \
9204       (void)0))
9205 @end smallexample
9207 @emph{Note:} This construct is only available for C@.  Furthermore, the
9208 unused expression (@var{exp1} or @var{exp2} depending on the value of
9209 @var{const_exp}) may still generate syntax errors.  This may change in
9210 future revisions.
9212 @end deftypefn
9214 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9216 The built-in function @code{__builtin_complex} is provided for use in
9217 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9218 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9219 real binary floating-point type, and the result has the corresponding
9220 complex type with real and imaginary parts @var{real} and @var{imag}.
9221 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9222 infinities, NaNs and negative zeros are involved.
9224 @end deftypefn
9226 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9227 You can use the built-in function @code{__builtin_constant_p} to
9228 determine if a value is known to be constant at compile time and hence
9229 that GCC can perform constant-folding on expressions involving that
9230 value.  The argument of the function is the value to test.  The function
9231 returns the integer 1 if the argument is known to be a compile-time
9232 constant and 0 if it is not known to be a compile-time constant.  A
9233 return of 0 does not indicate that the value is @emph{not} a constant,
9234 but merely that GCC cannot prove it is a constant with the specified
9235 value of the @option{-O} option.
9237 You typically use this function in an embedded application where
9238 memory is a critical resource.  If you have some complex calculation,
9239 you may want it to be folded if it involves constants, but need to call
9240 a function if it does not.  For example:
9242 @smallexample
9243 #define Scale_Value(X)      \
9244   (__builtin_constant_p (X) \
9245   ? ((X) * SCALE + OFFSET) : Scale (X))
9246 @end smallexample
9248 You may use this built-in function in either a macro or an inline
9249 function.  However, if you use it in an inlined function and pass an
9250 argument of the function as the argument to the built-in, GCC 
9251 never returns 1 when you call the inline function with a string constant
9252 or compound literal (@pxref{Compound Literals}) and does not return 1
9253 when you pass a constant numeric value to the inline function unless you
9254 specify the @option{-O} option.
9256 You may also use @code{__builtin_constant_p} in initializers for static
9257 data.  For instance, you can write
9259 @smallexample
9260 static const int table[] = @{
9261    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9262    /* @r{@dots{}} */
9264 @end smallexample
9266 @noindent
9267 This is an acceptable initializer even if @var{EXPRESSION} is not a
9268 constant expression, including the case where
9269 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9270 folded to a constant but @var{EXPRESSION} contains operands that are
9271 not otherwise permitted in a static initializer (for example,
9272 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9273 built-in in this case, because it has no opportunity to perform
9274 optimization.
9276 Previous versions of GCC did not accept this built-in in data
9277 initializers.  The earliest version where it is completely safe is
9278 3.0.1.
9279 @end deftypefn
9281 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9282 @opindex fprofile-arcs
9283 You may use @code{__builtin_expect} to provide the compiler with
9284 branch prediction information.  In general, you should prefer to
9285 use actual profile feedback for this (@option{-fprofile-arcs}), as
9286 programmers are notoriously bad at predicting how their programs
9287 actually perform.  However, there are applications in which this
9288 data is hard to collect.
9290 The return value is the value of @var{exp}, which should be an integral
9291 expression.  The semantics of the built-in are that it is expected that
9292 @var{exp} == @var{c}.  For example:
9294 @smallexample
9295 if (__builtin_expect (x, 0))
9296   foo ();
9297 @end smallexample
9299 @noindent
9300 indicates that we do not expect to call @code{foo}, since
9301 we expect @code{x} to be zero.  Since you are limited to integral
9302 expressions for @var{exp}, you should use constructions such as
9304 @smallexample
9305 if (__builtin_expect (ptr != NULL, 1))
9306   foo (*ptr);
9307 @end smallexample
9309 @noindent
9310 when testing pointer or floating-point values.
9311 @end deftypefn
9313 @deftypefn {Built-in Function} void __builtin_trap (void)
9314 This function causes the program to exit abnormally.  GCC implements
9315 this function by using a target-dependent mechanism (such as
9316 intentionally executing an illegal instruction) or by calling
9317 @code{abort}.  The mechanism used may vary from release to release so
9318 you should not rely on any particular implementation.
9319 @end deftypefn
9321 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9322 If control flow reaches the point of the @code{__builtin_unreachable},
9323 the program is undefined.  It is useful in situations where the
9324 compiler cannot deduce the unreachability of the code.
9326 One such case is immediately following an @code{asm} statement that
9327 either never terminates, or one that transfers control elsewhere
9328 and never returns.  In this example, without the
9329 @code{__builtin_unreachable}, GCC issues a warning that control
9330 reaches the end of a non-void function.  It also generates code
9331 to return after the @code{asm}.
9333 @smallexample
9334 int f (int c, int v)
9336   if (c)
9337     @{
9338       return v;
9339     @}
9340   else
9341     @{
9342       asm("jmp error_handler");
9343       __builtin_unreachable ();
9344     @}
9346 @end smallexample
9348 @noindent
9349 Because the @code{asm} statement unconditionally transfers control out
9350 of the function, control never reaches the end of the function
9351 body.  The @code{__builtin_unreachable} is in fact unreachable and
9352 communicates this fact to the compiler.
9354 Another use for @code{__builtin_unreachable} is following a call a
9355 function that never returns but that is not declared
9356 @code{__attribute__((noreturn))}, as in this example:
9358 @smallexample
9359 void function_that_never_returns (void);
9361 int g (int c)
9363   if (c)
9364     @{
9365       return 1;
9366     @}
9367   else
9368     @{
9369       function_that_never_returns ();
9370       __builtin_unreachable ();
9371     @}
9373 @end smallexample
9375 @end deftypefn
9377 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9378 This function returns its first argument, and allows the compiler
9379 to assume that the returned pointer is at least @var{align} bytes
9380 aligned.  This built-in can have either two or three arguments,
9381 if it has three, the third argument should have integer type, and
9382 if it is nonzero means misalignment offset.  For example:
9384 @smallexample
9385 void *x = __builtin_assume_aligned (arg, 16);
9386 @end smallexample
9388 @noindent
9389 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9390 16-byte aligned, while:
9392 @smallexample
9393 void *x = __builtin_assume_aligned (arg, 32, 8);
9394 @end smallexample
9396 @noindent
9397 means that the compiler can assume for @code{x}, set to @code{arg}, that
9398 @code{(char *) x - 8} is 32-byte aligned.
9399 @end deftypefn
9401 @deftypefn {Built-in Function} int __builtin_LINE ()
9402 This function is the equivalent to the preprocessor @code{__LINE__}
9403 macro and returns the line number of the invocation of the built-in.
9404 In a C++ default argument for a function @var{F}, it gets the line number of
9405 the call to @var{F}.
9406 @end deftypefn
9408 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9409 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9410 macro and returns the function name the invocation of the built-in is in.
9411 @end deftypefn
9413 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9414 This function is the equivalent to the preprocessor @code{__FILE__}
9415 macro and returns the file name the invocation of the built-in is in.
9416 In a C++ default argument for a function @var{F}, it gets the file name of
9417 the call to @var{F}.
9418 @end deftypefn
9420 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9421 This function is used to flush the processor's instruction cache for
9422 the region of memory between @var{begin} inclusive and @var{end}
9423 exclusive.  Some targets require that the instruction cache be
9424 flushed, after modifying memory containing code, in order to obtain
9425 deterministic behavior.
9427 If the target does not require instruction cache flushes,
9428 @code{__builtin___clear_cache} has no effect.  Otherwise either
9429 instructions are emitted in-line to clear the instruction cache or a
9430 call to the @code{__clear_cache} function in libgcc is made.
9431 @end deftypefn
9433 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9434 This function is used to minimize cache-miss latency by moving data into
9435 a cache before it is accessed.
9436 You can insert calls to @code{__builtin_prefetch} into code for which
9437 you know addresses of data in memory that is likely to be accessed soon.
9438 If the target supports them, data prefetch instructions are generated.
9439 If the prefetch is done early enough before the access then the data will
9440 be in the cache by the time it is accessed.
9442 The value of @var{addr} is the address of the memory to prefetch.
9443 There are two optional arguments, @var{rw} and @var{locality}.
9444 The value of @var{rw} is a compile-time constant one or zero; one
9445 means that the prefetch is preparing for a write to the memory address
9446 and zero, the default, means that the prefetch is preparing for a read.
9447 The value @var{locality} must be a compile-time constant integer between
9448 zero and three.  A value of zero means that the data has no temporal
9449 locality, so it need not be left in the cache after the access.  A value
9450 of three means that the data has a high degree of temporal locality and
9451 should be left in all levels of cache possible.  Values of one and two
9452 mean, respectively, a low or moderate degree of temporal locality.  The
9453 default is three.
9455 @smallexample
9456 for (i = 0; i < n; i++)
9457   @{
9458     a[i] = a[i] + b[i];
9459     __builtin_prefetch (&a[i+j], 1, 1);
9460     __builtin_prefetch (&b[i+j], 0, 1);
9461     /* @r{@dots{}} */
9462   @}
9463 @end smallexample
9465 Data prefetch does not generate faults if @var{addr} is invalid, but
9466 the address expression itself must be valid.  For example, a prefetch
9467 of @code{p->next} does not fault if @code{p->next} is not a valid
9468 address, but evaluation faults if @code{p} is not a valid address.
9470 If the target does not support data prefetch, the address expression
9471 is evaluated if it includes side effects but no other code is generated
9472 and GCC does not issue a warning.
9473 @end deftypefn
9475 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9476 Returns a positive infinity, if supported by the floating-point format,
9477 else @code{DBL_MAX}.  This function is suitable for implementing the
9478 ISO C macro @code{HUGE_VAL}.
9479 @end deftypefn
9481 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9482 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9483 @end deftypefn
9485 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9486 Similar to @code{__builtin_huge_val}, except the return
9487 type is @code{long double}.
9488 @end deftypefn
9490 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9491 This built-in implements the C99 fpclassify functionality.  The first
9492 five int arguments should be the target library's notion of the
9493 possible FP classes and are used for return values.  They must be
9494 constant values and they must appear in this order: @code{FP_NAN},
9495 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9496 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9497 to classify.  GCC treats the last argument as type-generic, which
9498 means it does not do default promotion from float to double.
9499 @end deftypefn
9501 @deftypefn {Built-in Function} double __builtin_inf (void)
9502 Similar to @code{__builtin_huge_val}, except a warning is generated
9503 if the target floating-point format does not support infinities.
9504 @end deftypefn
9506 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9507 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9508 @end deftypefn
9510 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9511 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9512 @end deftypefn
9514 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9515 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9516 @end deftypefn
9518 @deftypefn {Built-in Function} float __builtin_inff (void)
9519 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9520 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9521 @end deftypefn
9523 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9524 Similar to @code{__builtin_inf}, except the return
9525 type is @code{long double}.
9526 @end deftypefn
9528 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9529 Similar to @code{isinf}, except the return value is -1 for
9530 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9531 Note while the parameter list is an
9532 ellipsis, this function only accepts exactly one floating-point
9533 argument.  GCC treats this parameter as type-generic, which means it
9534 does not do default promotion from float to double.
9535 @end deftypefn
9537 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9538 This is an implementation of the ISO C99 function @code{nan}.
9540 Since ISO C99 defines this function in terms of @code{strtod}, which we
9541 do not implement, a description of the parsing is in order.  The string
9542 is parsed as by @code{strtol}; that is, the base is recognized by
9543 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9544 in the significand such that the least significant bit of the number
9545 is at the least significant bit of the significand.  The number is
9546 truncated to fit the significand field provided.  The significand is
9547 forced to be a quiet NaN@.
9549 This function, if given a string literal all of which would have been
9550 consumed by @code{strtol}, is evaluated early enough that it is considered a
9551 compile-time constant.
9552 @end deftypefn
9554 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9555 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9556 @end deftypefn
9558 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9559 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9560 @end deftypefn
9562 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9563 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9564 @end deftypefn
9566 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9567 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9568 @end deftypefn
9570 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9571 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9572 @end deftypefn
9574 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9575 Similar to @code{__builtin_nan}, except the significand is forced
9576 to be a signaling NaN@.  The @code{nans} function is proposed by
9577 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9578 @end deftypefn
9580 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9581 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9582 @end deftypefn
9584 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9585 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9586 @end deftypefn
9588 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9589 Returns one plus the index of the least significant 1-bit of @var{x}, or
9590 if @var{x} is zero, returns zero.
9591 @end deftypefn
9593 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9594 Returns the number of leading 0-bits in @var{x}, starting at the most
9595 significant bit position.  If @var{x} is 0, the result is undefined.
9596 @end deftypefn
9598 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9599 Returns the number of trailing 0-bits in @var{x}, starting at the least
9600 significant bit position.  If @var{x} is 0, the result is undefined.
9601 @end deftypefn
9603 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9604 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9605 number of bits following the most significant bit that are identical
9606 to it.  There are no special cases for 0 or other values. 
9607 @end deftypefn
9609 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9610 Returns the number of 1-bits in @var{x}.
9611 @end deftypefn
9613 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
9614 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
9615 modulo 2.
9616 @end deftypefn
9618 @deftypefn {Built-in Function} int __builtin_ffsl (long)
9619 Similar to @code{__builtin_ffs}, except the argument type is
9620 @code{long}.
9621 @end deftypefn
9623 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
9624 Similar to @code{__builtin_clz}, except the argument type is
9625 @code{unsigned long}.
9626 @end deftypefn
9628 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
9629 Similar to @code{__builtin_ctz}, except the argument type is
9630 @code{unsigned long}.
9631 @end deftypefn
9633 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
9634 Similar to @code{__builtin_clrsb}, except the argument type is
9635 @code{long}.
9636 @end deftypefn
9638 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
9639 Similar to @code{__builtin_popcount}, except the argument type is
9640 @code{unsigned long}.
9641 @end deftypefn
9643 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
9644 Similar to @code{__builtin_parity}, except the argument type is
9645 @code{unsigned long}.
9646 @end deftypefn
9648 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
9649 Similar to @code{__builtin_ffs}, except the argument type is
9650 @code{long long}.
9651 @end deftypefn
9653 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
9654 Similar to @code{__builtin_clz}, except the argument type is
9655 @code{unsigned long long}.
9656 @end deftypefn
9658 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
9659 Similar to @code{__builtin_ctz}, except the argument type is
9660 @code{unsigned long long}.
9661 @end deftypefn
9663 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
9664 Similar to @code{__builtin_clrsb}, except the argument type is
9665 @code{long long}.
9666 @end deftypefn
9668 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
9669 Similar to @code{__builtin_popcount}, except the argument type is
9670 @code{unsigned long long}.
9671 @end deftypefn
9673 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
9674 Similar to @code{__builtin_parity}, except the argument type is
9675 @code{unsigned long long}.
9676 @end deftypefn
9678 @deftypefn {Built-in Function} double __builtin_powi (double, int)
9679 Returns the first argument raised to the power of the second.  Unlike the
9680 @code{pow} function no guarantees about precision and rounding are made.
9681 @end deftypefn
9683 @deftypefn {Built-in Function} float __builtin_powif (float, int)
9684 Similar to @code{__builtin_powi}, except the argument and return types
9685 are @code{float}.
9686 @end deftypefn
9688 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
9689 Similar to @code{__builtin_powi}, except the argument and return types
9690 are @code{long double}.
9691 @end deftypefn
9693 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
9694 Returns @var{x} with the order of the bytes reversed; for example,
9695 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
9696 exactly 8 bits.
9697 @end deftypefn
9699 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
9700 Similar to @code{__builtin_bswap16}, except the argument and return types
9701 are 32 bit.
9702 @end deftypefn
9704 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9705 Similar to @code{__builtin_bswap32}, except the argument and return types
9706 are 64 bit.
9707 @end deftypefn
9709 @node Target Builtins
9710 @section Built-in Functions Specific to Particular Target Machines
9712 On some target machines, GCC supports many built-in functions specific
9713 to those machines.  Generally these generate calls to specific machine
9714 instructions, but allow the compiler to schedule those calls.
9716 @menu
9717 * AArch64 Built-in Functions::
9718 * AArch64 intrinsics::
9719 * Alpha Built-in Functions::
9720 * Altera Nios II Built-in Functions::
9721 * ARC Built-in Functions::
9722 * ARC SIMD Built-in Functions::
9723 * ARM iWMMXt Built-in Functions::
9724 * ARM NEON Intrinsics::
9725 * ARM ACLE Intrinsics::
9726 * ARM Floating Point Status and Control Intrinsics::
9727 * AVR Built-in Functions::
9728 * Blackfin Built-in Functions::
9729 * FR-V Built-in Functions::
9730 * X86 Built-in Functions::
9731 * X86 transactional memory intrinsics::
9732 * MIPS DSP Built-in Functions::
9733 * MIPS Paired-Single Support::
9734 * MIPS Loongson Built-in Functions::
9735 * Other MIPS Built-in Functions::
9736 * MSP430 Built-in Functions::
9737 * NDS32 Built-in Functions::
9738 * picoChip Built-in Functions::
9739 * PowerPC Built-in Functions::
9740 * PowerPC AltiVec/VSX Built-in Functions::
9741 * PowerPC Hardware Transactional Memory Built-in Functions::
9742 * RX Built-in Functions::
9743 * S/390 System z Built-in Functions::
9744 * SH Built-in Functions::
9745 * SPARC VIS Built-in Functions::
9746 * SPU Built-in Functions::
9747 * TI C6X Built-in Functions::
9748 * TILE-Gx Built-in Functions::
9749 * TILEPro Built-in Functions::
9750 @end menu
9752 @node AArch64 Built-in Functions
9753 @subsection AArch64 Built-in Functions
9755 These built-in functions are available for the AArch64 family of
9756 processors.
9757 @smallexample
9758 unsigned int __builtin_aarch64_get_fpcr ()
9759 void __builtin_aarch64_set_fpcr (unsigned int)
9760 unsigned int __builtin_aarch64_get_fpsr ()
9761 void __builtin_aarch64_set_fpsr (unsigned int)
9762 @end smallexample
9764 @node AArch64 intrinsics
9765 @subsection ACLE Intrinsics for AArch64
9767 @include aarch64-acle-intrinsics.texi
9769 @node Alpha Built-in Functions
9770 @subsection Alpha Built-in Functions
9772 These built-in functions are available for the Alpha family of
9773 processors, depending on the command-line switches used.
9775 The following built-in functions are always available.  They
9776 all generate the machine instruction that is part of the name.
9778 @smallexample
9779 long __builtin_alpha_implver (void)
9780 long __builtin_alpha_rpcc (void)
9781 long __builtin_alpha_amask (long)
9782 long __builtin_alpha_cmpbge (long, long)
9783 long __builtin_alpha_extbl (long, long)
9784 long __builtin_alpha_extwl (long, long)
9785 long __builtin_alpha_extll (long, long)
9786 long __builtin_alpha_extql (long, long)
9787 long __builtin_alpha_extwh (long, long)
9788 long __builtin_alpha_extlh (long, long)
9789 long __builtin_alpha_extqh (long, long)
9790 long __builtin_alpha_insbl (long, long)
9791 long __builtin_alpha_inswl (long, long)
9792 long __builtin_alpha_insll (long, long)
9793 long __builtin_alpha_insql (long, long)
9794 long __builtin_alpha_inswh (long, long)
9795 long __builtin_alpha_inslh (long, long)
9796 long __builtin_alpha_insqh (long, long)
9797 long __builtin_alpha_mskbl (long, long)
9798 long __builtin_alpha_mskwl (long, long)
9799 long __builtin_alpha_mskll (long, long)
9800 long __builtin_alpha_mskql (long, long)
9801 long __builtin_alpha_mskwh (long, long)
9802 long __builtin_alpha_msklh (long, long)
9803 long __builtin_alpha_mskqh (long, long)
9804 long __builtin_alpha_umulh (long, long)
9805 long __builtin_alpha_zap (long, long)
9806 long __builtin_alpha_zapnot (long, long)
9807 @end smallexample
9809 The following built-in functions are always with @option{-mmax}
9810 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9811 later.  They all generate the machine instruction that is part
9812 of the name.
9814 @smallexample
9815 long __builtin_alpha_pklb (long)
9816 long __builtin_alpha_pkwb (long)
9817 long __builtin_alpha_unpkbl (long)
9818 long __builtin_alpha_unpkbw (long)
9819 long __builtin_alpha_minub8 (long, long)
9820 long __builtin_alpha_minsb8 (long, long)
9821 long __builtin_alpha_minuw4 (long, long)
9822 long __builtin_alpha_minsw4 (long, long)
9823 long __builtin_alpha_maxub8 (long, long)
9824 long __builtin_alpha_maxsb8 (long, long)
9825 long __builtin_alpha_maxuw4 (long, long)
9826 long __builtin_alpha_maxsw4 (long, long)
9827 long __builtin_alpha_perr (long, long)
9828 @end smallexample
9830 The following built-in functions are always with @option{-mcix}
9831 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9832 later.  They all generate the machine instruction that is part
9833 of the name.
9835 @smallexample
9836 long __builtin_alpha_cttz (long)
9837 long __builtin_alpha_ctlz (long)
9838 long __builtin_alpha_ctpop (long)
9839 @end smallexample
9841 The following built-in functions are available on systems that use the OSF/1
9842 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
9843 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9844 @code{rdval} and @code{wrval}.
9846 @smallexample
9847 void *__builtin_thread_pointer (void)
9848 void __builtin_set_thread_pointer (void *)
9849 @end smallexample
9851 @node Altera Nios II Built-in Functions
9852 @subsection Altera Nios II Built-in Functions
9854 These built-in functions are available for the Altera Nios II
9855 family of processors.
9857 The following built-in functions are always available.  They
9858 all generate the machine instruction that is part of the name.
9860 @example
9861 int __builtin_ldbio (volatile const void *)
9862 int __builtin_ldbuio (volatile const void *)
9863 int __builtin_ldhio (volatile const void *)
9864 int __builtin_ldhuio (volatile const void *)
9865 int __builtin_ldwio (volatile const void *)
9866 void __builtin_stbio (volatile void *, int)
9867 void __builtin_sthio (volatile void *, int)
9868 void __builtin_stwio (volatile void *, int)
9869 void __builtin_sync (void)
9870 int __builtin_rdctl (int) 
9871 void __builtin_wrctl (int, int)
9872 @end example
9874 The following built-in functions are always available.  They
9875 all generate a Nios II Custom Instruction. The name of the
9876 function represents the types that the function takes and
9877 returns. The letter before the @code{n} is the return type
9878 or void if absent. The @code{n} represents the first parameter
9879 to all the custom instructions, the custom instruction number.
9880 The two letters after the @code{n} represent the up to two
9881 parameters to the function.
9883 The letters represent the following data types:
9884 @table @code
9885 @item <no letter>
9886 @code{void} for return type and no parameter for parameter types.
9888 @item i
9889 @code{int} for return type and parameter type
9891 @item f
9892 @code{float} for return type and parameter type
9894 @item p
9895 @code{void *} for return type and parameter type
9897 @end table
9899 And the function names are:
9900 @example
9901 void __builtin_custom_n (void)
9902 void __builtin_custom_ni (int)
9903 void __builtin_custom_nf (float)
9904 void __builtin_custom_np (void *)
9905 void __builtin_custom_nii (int, int)
9906 void __builtin_custom_nif (int, float)
9907 void __builtin_custom_nip (int, void *)
9908 void __builtin_custom_nfi (float, int)
9909 void __builtin_custom_nff (float, float)
9910 void __builtin_custom_nfp (float, void *)
9911 void __builtin_custom_npi (void *, int)
9912 void __builtin_custom_npf (void *, float)
9913 void __builtin_custom_npp (void *, void *)
9914 int __builtin_custom_in (void)
9915 int __builtin_custom_ini (int)
9916 int __builtin_custom_inf (float)
9917 int __builtin_custom_inp (void *)
9918 int __builtin_custom_inii (int, int)
9919 int __builtin_custom_inif (int, float)
9920 int __builtin_custom_inip (int, void *)
9921 int __builtin_custom_infi (float, int)
9922 int __builtin_custom_inff (float, float)
9923 int __builtin_custom_infp (float, void *)
9924 int __builtin_custom_inpi (void *, int)
9925 int __builtin_custom_inpf (void *, float)
9926 int __builtin_custom_inpp (void *, void *)
9927 float __builtin_custom_fn (void)
9928 float __builtin_custom_fni (int)
9929 float __builtin_custom_fnf (float)
9930 float __builtin_custom_fnp (void *)
9931 float __builtin_custom_fnii (int, int)
9932 float __builtin_custom_fnif (int, float)
9933 float __builtin_custom_fnip (int, void *)
9934 float __builtin_custom_fnfi (float, int)
9935 float __builtin_custom_fnff (float, float)
9936 float __builtin_custom_fnfp (float, void *)
9937 float __builtin_custom_fnpi (void *, int)
9938 float __builtin_custom_fnpf (void *, float)
9939 float __builtin_custom_fnpp (void *, void *)
9940 void * __builtin_custom_pn (void)
9941 void * __builtin_custom_pni (int)
9942 void * __builtin_custom_pnf (float)
9943 void * __builtin_custom_pnp (void *)
9944 void * __builtin_custom_pnii (int, int)
9945 void * __builtin_custom_pnif (int, float)
9946 void * __builtin_custom_pnip (int, void *)
9947 void * __builtin_custom_pnfi (float, int)
9948 void * __builtin_custom_pnff (float, float)
9949 void * __builtin_custom_pnfp (float, void *)
9950 void * __builtin_custom_pnpi (void *, int)
9951 void * __builtin_custom_pnpf (void *, float)
9952 void * __builtin_custom_pnpp (void *, void *)
9953 @end example
9955 @node ARC Built-in Functions
9956 @subsection ARC Built-in Functions
9958 The following built-in functions are provided for ARC targets.  The
9959 built-ins generate the corresponding assembly instructions.  In the
9960 examples given below, the generated code often requires an operand or
9961 result to be in a register.  Where necessary further code will be
9962 generated to ensure this is true, but for brevity this is not
9963 described in each case.
9965 @emph{Note:} Using a built-in to generate an instruction not supported
9966 by a target may cause problems. At present the compiler is not
9967 guaranteed to detect such misuse, and as a result an internal compiler
9968 error may be generated.
9970 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9971 Return 1 if @var{val} is known to have the byte alignment given
9972 by @var{alignval}, otherwise return 0.
9973 Note that this is different from
9974 @smallexample
9975 __alignof__(*(char *)@var{val}) >= alignval
9976 @end smallexample
9977 because __alignof__ sees only the type of the dereference, whereas
9978 __builtin_arc_align uses alignment information from the pointer
9979 as well as from the pointed-to type.
9980 The information available will depend on optimization level.
9981 @end deftypefn
9983 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9984 Generates
9985 @example
9987 @end example
9988 @end deftypefn
9990 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9991 The operand is the number of a register to be read.  Generates:
9992 @example
9993 mov  @var{dest}, r@var{regno}
9994 @end example
9995 where the value in @var{dest} will be the result returned from the
9996 built-in.
9997 @end deftypefn
9999 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10000 The first operand is the number of a register to be written, the
10001 second operand is a compile time constant to write into that
10002 register.  Generates:
10003 @example
10004 mov  r@var{regno}, @var{val}
10005 @end example
10006 @end deftypefn
10008 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10009 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10010 Generates:
10011 @example
10012 divaw  @var{dest}, @var{a}, @var{b}
10013 @end example
10014 where the value in @var{dest} will be the result returned from the
10015 built-in.
10016 @end deftypefn
10018 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10019 Generates
10020 @example
10021 flag  @var{a}
10022 @end example
10023 @end deftypefn
10025 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10026 The operand, @var{auxv}, is the address of an auxiliary register and
10027 must be a compile time constant.  Generates:
10028 @example
10029 lr  @var{dest}, [@var{auxr}]
10030 @end example
10031 Where the value in @var{dest} will be the result returned from the
10032 built-in.
10033 @end deftypefn
10035 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10036 Only available with @option{-mmul64}.  Generates:
10037 @example
10038 mul64  @var{a}, @var{b}
10039 @end example
10040 @end deftypefn
10042 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10043 Only available with @option{-mmul64}.  Generates:
10044 @example
10045 mulu64  @var{a}, @var{b}
10046 @end example
10047 @end deftypefn
10049 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10050 Generates:
10051 @example
10053 @end example
10054 @end deftypefn
10056 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10057 Only valid if the @samp{norm} instruction is available through the
10058 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10059 Generates:
10060 @example
10061 norm  @var{dest}, @var{src}
10062 @end example
10063 Where the value in @var{dest} will be the result returned from the
10064 built-in.
10065 @end deftypefn
10067 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10068 Only valid if the @samp{normw} instruction is available through the
10069 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10070 Generates:
10071 @example
10072 normw  @var{dest}, @var{src}
10073 @end example
10074 Where the value in @var{dest} will be the result returned from the
10075 built-in.
10076 @end deftypefn
10078 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10079 Generates:
10080 @example
10081 rtie
10082 @end example
10083 @end deftypefn
10085 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10086 Generates:
10087 @example
10088 sleep  @var{a}
10089 @end example
10090 @end deftypefn
10092 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10093 The first argument, @var{auxv}, is the address of an auxiliary
10094 register, the second argument, @var{val}, is a compile time constant
10095 to be written to the register.  Generates:
10096 @example
10097 sr  @var{auxr}, [@var{val}]
10098 @end example
10099 @end deftypefn
10101 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10102 Only valid with @option{-mswap}.  Generates:
10103 @example
10104 swap  @var{dest}, @var{src}
10105 @end example
10106 Where the value in @var{dest} will be the result returned from the
10107 built-in.
10108 @end deftypefn
10110 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10111 Generates:
10112 @example
10114 @end example
10115 @end deftypefn
10117 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10118 Only available with @option{-mcpu=ARC700}.  Generates:
10119 @example
10120 sync
10121 @end example
10122 @end deftypefn
10124 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10125 Only available with @option{-mcpu=ARC700}.  Generates:
10126 @example
10127 trap_s  @var{c}
10128 @end example
10129 @end deftypefn
10131 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10132 Only available with @option{-mcpu=ARC700}.  Generates:
10133 @example
10134 unimp_s
10135 @end example
10136 @end deftypefn
10138 The instructions generated by the following builtins are not
10139 considered as candidates for scheduling.  They are not moved around by
10140 the compiler during scheduling, and thus can be expected to appear
10141 where they are put in the C code:
10142 @example
10143 __builtin_arc_brk()
10144 __builtin_arc_core_read()
10145 __builtin_arc_core_write()
10146 __builtin_arc_flag()
10147 __builtin_arc_lr()
10148 __builtin_arc_sleep()
10149 __builtin_arc_sr()
10150 __builtin_arc_swi()
10151 @end example
10153 @node ARC SIMD Built-in Functions
10154 @subsection ARC SIMD Built-in Functions
10156 SIMD builtins provided by the compiler can be used to generate the
10157 vector instructions.  This section describes the available builtins
10158 and their usage in programs.  With the @option{-msimd} option, the
10159 compiler provides 128-bit vector types, which can be specified using
10160 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10161 can be included to use the following predefined types:
10162 @example
10163 typedef int __v4si   __attribute__((vector_size(16)));
10164 typedef short __v8hi __attribute__((vector_size(16)));
10165 @end example
10167 These types can be used to define 128-bit variables.  The built-in
10168 functions listed in the following section can be used on these
10169 variables to generate the vector operations.
10171 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10172 @file{arc-simd.h} also provides equivalent macros called
10173 @code{_@var{someinsn}} that can be used for programming ease and
10174 improved readability.  The following macros for DMA control are also
10175 provided:
10176 @example
10177 #define _setup_dma_in_channel_reg _vdiwr
10178 #define _setup_dma_out_channel_reg _vdowr
10179 @end example
10181 The following is a complete list of all the SIMD built-ins provided
10182 for ARC, grouped by calling signature.
10184 The following take two @code{__v8hi} arguments and return a
10185 @code{__v8hi} result:
10186 @example
10187 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10188 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10189 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10190 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10191 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10192 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10193 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10194 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10195 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10196 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10197 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10198 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10199 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10200 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10201 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10202 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10203 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10204 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10205 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10206 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10207 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10208 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10209 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10210 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10211 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10212 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10213 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10214 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10215 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10216 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10217 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10218 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10219 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10220 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10221 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10222 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10223 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10224 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10225 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10226 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10227 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10228 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10229 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10230 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10231 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10232 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10233 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10234 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10235 @end example
10237 The following take one @code{__v8hi} and one @code{int} argument and return a
10238 @code{__v8hi} result:
10240 @example
10241 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10242 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10243 __v8hi __builtin_arc_vbminw (__v8hi, int)
10244 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10245 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10246 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10247 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10248 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10249 @end example
10251 The following take one @code{__v8hi} argument and one @code{int} argument which
10252 must be a 3-bit compile time constant indicating a register number
10253 I0-I7.  They return a @code{__v8hi} result.
10254 @example
10255 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10256 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10257 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10258 @end example
10260 The following take one @code{__v8hi} argument and one @code{int}
10261 argument which must be a 6-bit compile time constant.  They return a
10262 @code{__v8hi} result.
10263 @example
10264 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10265 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10266 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10267 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10268 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10269 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10270 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10271 @end example
10273 The following take one @code{__v8hi} argument and one @code{int} argument which
10274 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10275 result.
10276 @example
10277 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10278 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10279 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10280 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10281 @end example
10283 The following take two @code{int} arguments, the second of which which
10284 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10285 result:
10286 @example
10287 __v8hi __builtin_arc_vmovaw (int, const int)
10288 __v8hi __builtin_arc_vmovw (int, const int)
10289 __v8hi __builtin_arc_vmovzw (int, const int)
10290 @end example
10292 The following take a single @code{__v8hi} argument and return a
10293 @code{__v8hi} result:
10294 @example
10295 __v8hi __builtin_arc_vabsaw (__v8hi)
10296 __v8hi __builtin_arc_vabsw (__v8hi)
10297 __v8hi __builtin_arc_vaddsuw (__v8hi)
10298 __v8hi __builtin_arc_vexch1 (__v8hi)
10299 __v8hi __builtin_arc_vexch2 (__v8hi)
10300 __v8hi __builtin_arc_vexch4 (__v8hi)
10301 __v8hi __builtin_arc_vsignw (__v8hi)
10302 __v8hi __builtin_arc_vupbaw (__v8hi)
10303 __v8hi __builtin_arc_vupbw (__v8hi)
10304 __v8hi __builtin_arc_vupsbaw (__v8hi)
10305 __v8hi __builtin_arc_vupsbw (__v8hi)
10306 @end example
10308 The followign take two @code{int} arguments and return no result:
10309 @example
10310 void __builtin_arc_vdirun (int, int)
10311 void __builtin_arc_vdorun (int, int)
10312 @end example
10314 The following take two @code{int} arguments and return no result.  The
10315 first argument must a 3-bit compile time constant indicating one of
10316 the DR0-DR7 DMA setup channels:
10317 @example
10318 void __builtin_arc_vdiwr (const int, int)
10319 void __builtin_arc_vdowr (const int, int)
10320 @end example
10322 The following take an @code{int} argument and return no result:
10323 @example
10324 void __builtin_arc_vendrec (int)
10325 void __builtin_arc_vrec (int)
10326 void __builtin_arc_vrecrun (int)
10327 void __builtin_arc_vrun (int)
10328 @end example
10330 The following take a @code{__v8hi} argument and two @code{int}
10331 arguments and return a @code{__v8hi} result.  The second argument must
10332 be a 3-bit compile time constants, indicating one the registers I0-I7,
10333 and the third argument must be an 8-bit compile time constant.
10335 @emph{Note:} Although the equivalent hardware instructions do not take
10336 an SIMD register as an operand, these builtins overwrite the relevant
10337 bits of the @code{__v8hi} register provided as the first argument with
10338 the value loaded from the @code{[Ib, u8]} location in the SDM.
10340 @example
10341 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10342 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10343 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10344 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10345 @end example
10347 The following take two @code{int} arguments and return a @code{__v8hi}
10348 result.  The first argument must be a 3-bit compile time constants,
10349 indicating one the registers I0-I7, and the second argument must be an
10350 8-bit compile time constant.
10352 @example
10353 __v8hi __builtin_arc_vld128 (const int, const int)
10354 __v8hi __builtin_arc_vld64w (const int, const int)
10355 @end example
10357 The following take a @code{__v8hi} argument and two @code{int}
10358 arguments and return no result.  The second argument must be a 3-bit
10359 compile time constants, indicating one the registers I0-I7, and the
10360 third argument must be an 8-bit compile time constant.
10362 @example
10363 void __builtin_arc_vst128 (__v8hi, const int, const int)
10364 void __builtin_arc_vst64 (__v8hi, const int, const int)
10365 @end example
10367 The following take a @code{__v8hi} argument and three @code{int}
10368 arguments and return no result.  The second argument must be a 3-bit
10369 compile-time constant, identifying the 16-bit sub-register to be
10370 stored, the third argument must be a 3-bit compile time constants,
10371 indicating one the registers I0-I7, and the fourth argument must be an
10372 8-bit compile time constant.
10374 @example
10375 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10376 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10377 @end example
10379 @node ARM iWMMXt Built-in Functions
10380 @subsection ARM iWMMXt Built-in Functions
10382 These built-in functions are available for the ARM family of
10383 processors when the @option{-mcpu=iwmmxt} switch is used:
10385 @smallexample
10386 typedef int v2si __attribute__ ((vector_size (8)));
10387 typedef short v4hi __attribute__ ((vector_size (8)));
10388 typedef char v8qi __attribute__ ((vector_size (8)));
10390 int __builtin_arm_getwcgr0 (void)
10391 void __builtin_arm_setwcgr0 (int)
10392 int __builtin_arm_getwcgr1 (void)
10393 void __builtin_arm_setwcgr1 (int)
10394 int __builtin_arm_getwcgr2 (void)
10395 void __builtin_arm_setwcgr2 (int)
10396 int __builtin_arm_getwcgr3 (void)
10397 void __builtin_arm_setwcgr3 (int)
10398 int __builtin_arm_textrmsb (v8qi, int)
10399 int __builtin_arm_textrmsh (v4hi, int)
10400 int __builtin_arm_textrmsw (v2si, int)
10401 int __builtin_arm_textrmub (v8qi, int)
10402 int __builtin_arm_textrmuh (v4hi, int)
10403 int __builtin_arm_textrmuw (v2si, int)
10404 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10405 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10406 v2si __builtin_arm_tinsrw (v2si, int, int)
10407 long long __builtin_arm_tmia (long long, int, int)
10408 long long __builtin_arm_tmiabb (long long, int, int)
10409 long long __builtin_arm_tmiabt (long long, int, int)
10410 long long __builtin_arm_tmiaph (long long, int, int)
10411 long long __builtin_arm_tmiatb (long long, int, int)
10412 long long __builtin_arm_tmiatt (long long, int, int)
10413 int __builtin_arm_tmovmskb (v8qi)
10414 int __builtin_arm_tmovmskh (v4hi)
10415 int __builtin_arm_tmovmskw (v2si)
10416 long long __builtin_arm_waccb (v8qi)
10417 long long __builtin_arm_wacch (v4hi)
10418 long long __builtin_arm_waccw (v2si)
10419 v8qi __builtin_arm_waddb (v8qi, v8qi)
10420 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10421 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10422 v4hi __builtin_arm_waddh (v4hi, v4hi)
10423 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10424 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10425 v2si __builtin_arm_waddw (v2si, v2si)
10426 v2si __builtin_arm_waddwss (v2si, v2si)
10427 v2si __builtin_arm_waddwus (v2si, v2si)
10428 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10429 long long __builtin_arm_wand(long long, long long)
10430 long long __builtin_arm_wandn (long long, long long)
10431 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10432 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10433 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10434 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10435 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10436 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10437 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10438 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10439 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10440 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10441 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10442 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10443 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10444 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10445 long long __builtin_arm_wmacsz (v4hi, v4hi)
10446 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10447 long long __builtin_arm_wmacuz (v4hi, v4hi)
10448 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10449 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10450 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10451 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10452 v2si __builtin_arm_wmaxsw (v2si, v2si)
10453 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10454 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10455 v2si __builtin_arm_wmaxuw (v2si, v2si)
10456 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10457 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10458 v2si __builtin_arm_wminsw (v2si, v2si)
10459 v8qi __builtin_arm_wminub (v8qi, v8qi)
10460 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10461 v2si __builtin_arm_wminuw (v2si, v2si)
10462 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10463 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10464 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10465 long long __builtin_arm_wor (long long, long long)
10466 v2si __builtin_arm_wpackdss (long long, long long)
10467 v2si __builtin_arm_wpackdus (long long, long long)
10468 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10469 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10470 v4hi __builtin_arm_wpackwss (v2si, v2si)
10471 v4hi __builtin_arm_wpackwus (v2si, v2si)
10472 long long __builtin_arm_wrord (long long, long long)
10473 long long __builtin_arm_wrordi (long long, int)
10474 v4hi __builtin_arm_wrorh (v4hi, long long)
10475 v4hi __builtin_arm_wrorhi (v4hi, int)
10476 v2si __builtin_arm_wrorw (v2si, long long)
10477 v2si __builtin_arm_wrorwi (v2si, int)
10478 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10479 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10480 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10481 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10482 v4hi __builtin_arm_wshufh (v4hi, int)
10483 long long __builtin_arm_wslld (long long, long long)
10484 long long __builtin_arm_wslldi (long long, int)
10485 v4hi __builtin_arm_wsllh (v4hi, long long)
10486 v4hi __builtin_arm_wsllhi (v4hi, int)
10487 v2si __builtin_arm_wsllw (v2si, long long)
10488 v2si __builtin_arm_wsllwi (v2si, int)
10489 long long __builtin_arm_wsrad (long long, long long)
10490 long long __builtin_arm_wsradi (long long, int)
10491 v4hi __builtin_arm_wsrah (v4hi, long long)
10492 v4hi __builtin_arm_wsrahi (v4hi, int)
10493 v2si __builtin_arm_wsraw (v2si, long long)
10494 v2si __builtin_arm_wsrawi (v2si, int)
10495 long long __builtin_arm_wsrld (long long, long long)
10496 long long __builtin_arm_wsrldi (long long, int)
10497 v4hi __builtin_arm_wsrlh (v4hi, long long)
10498 v4hi __builtin_arm_wsrlhi (v4hi, int)
10499 v2si __builtin_arm_wsrlw (v2si, long long)
10500 v2si __builtin_arm_wsrlwi (v2si, int)
10501 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10502 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10503 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10504 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10505 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10506 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10507 v2si __builtin_arm_wsubw (v2si, v2si)
10508 v2si __builtin_arm_wsubwss (v2si, v2si)
10509 v2si __builtin_arm_wsubwus (v2si, v2si)
10510 v4hi __builtin_arm_wunpckehsb (v8qi)
10511 v2si __builtin_arm_wunpckehsh (v4hi)
10512 long long __builtin_arm_wunpckehsw (v2si)
10513 v4hi __builtin_arm_wunpckehub (v8qi)
10514 v2si __builtin_arm_wunpckehuh (v4hi)
10515 long long __builtin_arm_wunpckehuw (v2si)
10516 v4hi __builtin_arm_wunpckelsb (v8qi)
10517 v2si __builtin_arm_wunpckelsh (v4hi)
10518 long long __builtin_arm_wunpckelsw (v2si)
10519 v4hi __builtin_arm_wunpckelub (v8qi)
10520 v2si __builtin_arm_wunpckeluh (v4hi)
10521 long long __builtin_arm_wunpckeluw (v2si)
10522 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10523 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10524 v2si __builtin_arm_wunpckihw (v2si, v2si)
10525 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10526 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10527 v2si __builtin_arm_wunpckilw (v2si, v2si)
10528 long long __builtin_arm_wxor (long long, long long)
10529 long long __builtin_arm_wzero ()
10530 @end smallexample
10532 @node ARM NEON Intrinsics
10533 @subsection ARM NEON Intrinsics
10535 These built-in intrinsics for the ARM Advanced SIMD extension are available
10536 when the @option{-mfpu=neon} switch is used:
10538 @include arm-neon-intrinsics.texi
10540 @node ARM ACLE Intrinsics
10541 @subsection ARM ACLE Intrinsics
10543 @include arm-acle-intrinsics.texi
10545 @node ARM Floating Point Status and Control Intrinsics
10546 @subsection ARM Floating Point Status and Control Intrinsics
10548 These built-in functions are available for the ARM family of
10549 processors with floating-point unit.
10551 @smallexample
10552 unsigned int __builtin_arm_get_fpscr ()
10553 void __builtin_arm_set_fpscr (unsigned int)
10554 @end smallexample
10556 @node AVR Built-in Functions
10557 @subsection AVR Built-in Functions
10559 For each built-in function for AVR, there is an equally named,
10560 uppercase built-in macro defined. That way users can easily query if
10561 or if not a specific built-in is implemented or not. For example, if
10562 @code{__builtin_avr_nop} is available the macro
10563 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10565 The following built-in functions map to the respective machine
10566 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10567 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10568 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10569 as library call if no hardware multiplier is available.
10571 @smallexample
10572 void __builtin_avr_nop (void)
10573 void __builtin_avr_sei (void)
10574 void __builtin_avr_cli (void)
10575 void __builtin_avr_sleep (void)
10576 void __builtin_avr_wdr (void)
10577 unsigned char __builtin_avr_swap (unsigned char)
10578 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10579 int __builtin_avr_fmuls (char, char)
10580 int __builtin_avr_fmulsu (char, unsigned char)
10581 @end smallexample
10583 In order to delay execution for a specific number of cycles, GCC
10584 implements
10585 @smallexample
10586 void __builtin_avr_delay_cycles (unsigned long ticks)
10587 @end smallexample
10589 @noindent
10590 @code{ticks} is the number of ticks to delay execution. Note that this
10591 built-in does not take into account the effect of interrupts that
10592 might increase delay time. @code{ticks} must be a compile-time
10593 integer constant; delays with a variable number of cycles are not supported.
10595 @smallexample
10596 char __builtin_avr_flash_segment (const __memx void*)
10597 @end smallexample
10599 @noindent
10600 This built-in takes a byte address to the 24-bit
10601 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10602 the number of the flash segment (the 64 KiB chunk) where the address
10603 points to.  Counting starts at @code{0}.
10604 If the address does not point to flash memory, return @code{-1}.
10606 @smallexample
10607 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
10608 @end smallexample
10610 @noindent
10611 Insert bits from @var{bits} into @var{val} and return the resulting
10612 value. The nibbles of @var{map} determine how the insertion is
10613 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
10614 @enumerate
10615 @item If @var{X} is @code{0xf},
10616 then the @var{n}-th bit of @var{val} is returned unaltered.
10618 @item If X is in the range 0@dots{}7,
10619 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
10621 @item If X is in the range 8@dots{}@code{0xe},
10622 then the @var{n}-th result bit is undefined.
10623 @end enumerate
10625 @noindent
10626 One typical use case for this built-in is adjusting input and
10627 output values to non-contiguous port layouts. Some examples:
10629 @smallexample
10630 // same as val, bits is unused
10631 __builtin_avr_insert_bits (0xffffffff, bits, val)
10632 @end smallexample
10634 @smallexample
10635 // same as bits, val is unused
10636 __builtin_avr_insert_bits (0x76543210, bits, val)
10637 @end smallexample
10639 @smallexample
10640 // same as rotating bits by 4
10641 __builtin_avr_insert_bits (0x32107654, bits, 0)
10642 @end smallexample
10644 @smallexample
10645 // high nibble of result is the high nibble of val
10646 // low nibble of result is the low nibble of bits
10647 __builtin_avr_insert_bits (0xffff3210, bits, val)
10648 @end smallexample
10650 @smallexample
10651 // reverse the bit order of bits
10652 __builtin_avr_insert_bits (0x01234567, bits, 0)
10653 @end smallexample
10655 @node Blackfin Built-in Functions
10656 @subsection Blackfin Built-in Functions
10658 Currently, there are two Blackfin-specific built-in functions.  These are
10659 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
10660 using inline assembly; by using these built-in functions the compiler can
10661 automatically add workarounds for hardware errata involving these
10662 instructions.  These functions are named as follows:
10664 @smallexample
10665 void __builtin_bfin_csync (void)
10666 void __builtin_bfin_ssync (void)
10667 @end smallexample
10669 @node FR-V Built-in Functions
10670 @subsection FR-V Built-in Functions
10672 GCC provides many FR-V-specific built-in functions.  In general,
10673 these functions are intended to be compatible with those described
10674 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
10675 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
10676 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
10677 pointer rather than by value.
10679 Most of the functions are named after specific FR-V instructions.
10680 Such functions are said to be ``directly mapped'' and are summarized
10681 here in tabular form.
10683 @menu
10684 * Argument Types::
10685 * Directly-mapped Integer Functions::
10686 * Directly-mapped Media Functions::
10687 * Raw read/write Functions::
10688 * Other Built-in Functions::
10689 @end menu
10691 @node Argument Types
10692 @subsubsection Argument Types
10694 The arguments to the built-in functions can be divided into three groups:
10695 register numbers, compile-time constants and run-time values.  In order
10696 to make this classification clear at a glance, the arguments and return
10697 values are given the following pseudo types:
10699 @multitable @columnfractions .20 .30 .15 .35
10700 @item Pseudo type @tab Real C type @tab Constant? @tab Description
10701 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
10702 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
10703 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
10704 @item @code{uw2} @tab @code{unsigned long long} @tab No
10705 @tab an unsigned doubleword
10706 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
10707 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
10708 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
10709 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
10710 @end multitable
10712 These pseudo types are not defined by GCC, they are simply a notational
10713 convenience used in this manual.
10715 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
10716 and @code{sw2} are evaluated at run time.  They correspond to
10717 register operands in the underlying FR-V instructions.
10719 @code{const} arguments represent immediate operands in the underlying
10720 FR-V instructions.  They must be compile-time constants.
10722 @code{acc} arguments are evaluated at compile time and specify the number
10723 of an accumulator register.  For example, an @code{acc} argument of 2
10724 selects the ACC2 register.
10726 @code{iacc} arguments are similar to @code{acc} arguments but specify the
10727 number of an IACC register.  See @pxref{Other Built-in Functions}
10728 for more details.
10730 @node Directly-mapped Integer Functions
10731 @subsubsection Directly-mapped Integer Functions
10733 The functions listed below map directly to FR-V I-type instructions.
10735 @multitable @columnfractions .45 .32 .23
10736 @item Function prototype @tab Example usage @tab Assembly output
10737 @item @code{sw1 __ADDSS (sw1, sw1)}
10738 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
10739 @tab @code{ADDSS @var{a},@var{b},@var{c}}
10740 @item @code{sw1 __SCAN (sw1, sw1)}
10741 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
10742 @tab @code{SCAN @var{a},@var{b},@var{c}}
10743 @item @code{sw1 __SCUTSS (sw1)}
10744 @tab @code{@var{b} = __SCUTSS (@var{a})}
10745 @tab @code{SCUTSS @var{a},@var{b}}
10746 @item @code{sw1 __SLASS (sw1, sw1)}
10747 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
10748 @tab @code{SLASS @var{a},@var{b},@var{c}}
10749 @item @code{void __SMASS (sw1, sw1)}
10750 @tab @code{__SMASS (@var{a}, @var{b})}
10751 @tab @code{SMASS @var{a},@var{b}}
10752 @item @code{void __SMSSS (sw1, sw1)}
10753 @tab @code{__SMSSS (@var{a}, @var{b})}
10754 @tab @code{SMSSS @var{a},@var{b}}
10755 @item @code{void __SMU (sw1, sw1)}
10756 @tab @code{__SMU (@var{a}, @var{b})}
10757 @tab @code{SMU @var{a},@var{b}}
10758 @item @code{sw2 __SMUL (sw1, sw1)}
10759 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
10760 @tab @code{SMUL @var{a},@var{b},@var{c}}
10761 @item @code{sw1 __SUBSS (sw1, sw1)}
10762 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
10763 @tab @code{SUBSS @var{a},@var{b},@var{c}}
10764 @item @code{uw2 __UMUL (uw1, uw1)}
10765 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
10766 @tab @code{UMUL @var{a},@var{b},@var{c}}
10767 @end multitable
10769 @node Directly-mapped Media Functions
10770 @subsubsection Directly-mapped Media Functions
10772 The functions listed below map directly to FR-V M-type instructions.
10774 @multitable @columnfractions .45 .32 .23
10775 @item Function prototype @tab Example usage @tab Assembly output
10776 @item @code{uw1 __MABSHS (sw1)}
10777 @tab @code{@var{b} = __MABSHS (@var{a})}
10778 @tab @code{MABSHS @var{a},@var{b}}
10779 @item @code{void __MADDACCS (acc, acc)}
10780 @tab @code{__MADDACCS (@var{b}, @var{a})}
10781 @tab @code{MADDACCS @var{a},@var{b}}
10782 @item @code{sw1 __MADDHSS (sw1, sw1)}
10783 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
10784 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
10785 @item @code{uw1 __MADDHUS (uw1, uw1)}
10786 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
10787 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
10788 @item @code{uw1 __MAND (uw1, uw1)}
10789 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
10790 @tab @code{MAND @var{a},@var{b},@var{c}}
10791 @item @code{void __MASACCS (acc, acc)}
10792 @tab @code{__MASACCS (@var{b}, @var{a})}
10793 @tab @code{MASACCS @var{a},@var{b}}
10794 @item @code{uw1 __MAVEH (uw1, uw1)}
10795 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
10796 @tab @code{MAVEH @var{a},@var{b},@var{c}}
10797 @item @code{uw2 __MBTOH (uw1)}
10798 @tab @code{@var{b} = __MBTOH (@var{a})}
10799 @tab @code{MBTOH @var{a},@var{b}}
10800 @item @code{void __MBTOHE (uw1 *, uw1)}
10801 @tab @code{__MBTOHE (&@var{b}, @var{a})}
10802 @tab @code{MBTOHE @var{a},@var{b}}
10803 @item @code{void __MCLRACC (acc)}
10804 @tab @code{__MCLRACC (@var{a})}
10805 @tab @code{MCLRACC @var{a}}
10806 @item @code{void __MCLRACCA (void)}
10807 @tab @code{__MCLRACCA ()}
10808 @tab @code{MCLRACCA}
10809 @item @code{uw1 __Mcop1 (uw1, uw1)}
10810 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
10811 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
10812 @item @code{uw1 __Mcop2 (uw1, uw1)}
10813 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
10814 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
10815 @item @code{uw1 __MCPLHI (uw2, const)}
10816 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
10817 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
10818 @item @code{uw1 __MCPLI (uw2, const)}
10819 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
10820 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
10821 @item @code{void __MCPXIS (acc, sw1, sw1)}
10822 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
10823 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
10824 @item @code{void __MCPXIU (acc, uw1, uw1)}
10825 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
10826 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
10827 @item @code{void __MCPXRS (acc, sw1, sw1)}
10828 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
10829 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
10830 @item @code{void __MCPXRU (acc, uw1, uw1)}
10831 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
10832 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
10833 @item @code{uw1 __MCUT (acc, uw1)}
10834 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
10835 @tab @code{MCUT @var{a},@var{b},@var{c}}
10836 @item @code{uw1 __MCUTSS (acc, sw1)}
10837 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
10838 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
10839 @item @code{void __MDADDACCS (acc, acc)}
10840 @tab @code{__MDADDACCS (@var{b}, @var{a})}
10841 @tab @code{MDADDACCS @var{a},@var{b}}
10842 @item @code{void __MDASACCS (acc, acc)}
10843 @tab @code{__MDASACCS (@var{b}, @var{a})}
10844 @tab @code{MDASACCS @var{a},@var{b}}
10845 @item @code{uw2 __MDCUTSSI (acc, const)}
10846 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10847 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10848 @item @code{uw2 __MDPACKH (uw2, uw2)}
10849 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10850 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10851 @item @code{uw2 __MDROTLI (uw2, const)}
10852 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10853 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10854 @item @code{void __MDSUBACCS (acc, acc)}
10855 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10856 @tab @code{MDSUBACCS @var{a},@var{b}}
10857 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10858 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10859 @tab @code{MDUNPACKH @var{a},@var{b}}
10860 @item @code{uw2 __MEXPDHD (uw1, const)}
10861 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10862 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10863 @item @code{uw1 __MEXPDHW (uw1, const)}
10864 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10865 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10866 @item @code{uw1 __MHDSETH (uw1, const)}
10867 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10868 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10869 @item @code{sw1 __MHDSETS (const)}
10870 @tab @code{@var{b} = __MHDSETS (@var{a})}
10871 @tab @code{MHDSETS #@var{a},@var{b}}
10872 @item @code{uw1 __MHSETHIH (uw1, const)}
10873 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10874 @tab @code{MHSETHIH #@var{a},@var{b}}
10875 @item @code{sw1 __MHSETHIS (sw1, const)}
10876 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10877 @tab @code{MHSETHIS #@var{a},@var{b}}
10878 @item @code{uw1 __MHSETLOH (uw1, const)}
10879 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10880 @tab @code{MHSETLOH #@var{a},@var{b}}
10881 @item @code{sw1 __MHSETLOS (sw1, const)}
10882 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10883 @tab @code{MHSETLOS #@var{a},@var{b}}
10884 @item @code{uw1 __MHTOB (uw2)}
10885 @tab @code{@var{b} = __MHTOB (@var{a})}
10886 @tab @code{MHTOB @var{a},@var{b}}
10887 @item @code{void __MMACHS (acc, sw1, sw1)}
10888 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10889 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10890 @item @code{void __MMACHU (acc, uw1, uw1)}
10891 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10892 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10893 @item @code{void __MMRDHS (acc, sw1, sw1)}
10894 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10895 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10896 @item @code{void __MMRDHU (acc, uw1, uw1)}
10897 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10898 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10899 @item @code{void __MMULHS (acc, sw1, sw1)}
10900 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10901 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10902 @item @code{void __MMULHU (acc, uw1, uw1)}
10903 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10904 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10905 @item @code{void __MMULXHS (acc, sw1, sw1)}
10906 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10907 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10908 @item @code{void __MMULXHU (acc, uw1, uw1)}
10909 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10910 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10911 @item @code{uw1 __MNOT (uw1)}
10912 @tab @code{@var{b} = __MNOT (@var{a})}
10913 @tab @code{MNOT @var{a},@var{b}}
10914 @item @code{uw1 __MOR (uw1, uw1)}
10915 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10916 @tab @code{MOR @var{a},@var{b},@var{c}}
10917 @item @code{uw1 __MPACKH (uh, uh)}
10918 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10919 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10920 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10921 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10922 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10923 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10924 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10925 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10926 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10927 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10928 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10929 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10930 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10931 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10932 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10933 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10934 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10935 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10936 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10937 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10938 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10939 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10940 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10941 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10942 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10943 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10944 @item @code{void __MQMACHS (acc, sw2, sw2)}
10945 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10946 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10947 @item @code{void __MQMACHU (acc, uw2, uw2)}
10948 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10949 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10950 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10951 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10952 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10953 @item @code{void __MQMULHS (acc, sw2, sw2)}
10954 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10955 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10956 @item @code{void __MQMULHU (acc, uw2, uw2)}
10957 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10958 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10959 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10960 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10961 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10962 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10963 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10964 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10965 @item @code{sw2 __MQSATHS (sw2, sw2)}
10966 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10967 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10968 @item @code{uw2 __MQSLLHI (uw2, int)}
10969 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10970 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10971 @item @code{sw2 __MQSRAHI (sw2, int)}
10972 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10973 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10974 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10975 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10976 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10977 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10978 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10979 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10980 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10981 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10982 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10983 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10984 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10985 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10986 @item @code{uw1 __MRDACC (acc)}
10987 @tab @code{@var{b} = __MRDACC (@var{a})}
10988 @tab @code{MRDACC @var{a},@var{b}}
10989 @item @code{uw1 __MRDACCG (acc)}
10990 @tab @code{@var{b} = __MRDACCG (@var{a})}
10991 @tab @code{MRDACCG @var{a},@var{b}}
10992 @item @code{uw1 __MROTLI (uw1, const)}
10993 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10994 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10995 @item @code{uw1 __MROTRI (uw1, const)}
10996 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10997 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10998 @item @code{sw1 __MSATHS (sw1, sw1)}
10999 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11000 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11001 @item @code{uw1 __MSATHU (uw1, uw1)}
11002 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11003 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11004 @item @code{uw1 __MSLLHI (uw1, const)}
11005 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11006 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11007 @item @code{sw1 __MSRAHI (sw1, const)}
11008 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11009 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11010 @item @code{uw1 __MSRLHI (uw1, const)}
11011 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11012 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11013 @item @code{void __MSUBACCS (acc, acc)}
11014 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11015 @tab @code{MSUBACCS @var{a},@var{b}}
11016 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11017 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11018 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11019 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11020 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11021 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11022 @item @code{void __MTRAP (void)}
11023 @tab @code{__MTRAP ()}
11024 @tab @code{MTRAP}
11025 @item @code{uw2 __MUNPACKH (uw1)}
11026 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11027 @tab @code{MUNPACKH @var{a},@var{b}}
11028 @item @code{uw1 __MWCUT (uw2, uw1)}
11029 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11030 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11031 @item @code{void __MWTACC (acc, uw1)}
11032 @tab @code{__MWTACC (@var{b}, @var{a})}
11033 @tab @code{MWTACC @var{a},@var{b}}
11034 @item @code{void __MWTACCG (acc, uw1)}
11035 @tab @code{__MWTACCG (@var{b}, @var{a})}
11036 @tab @code{MWTACCG @var{a},@var{b}}
11037 @item @code{uw1 __MXOR (uw1, uw1)}
11038 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11039 @tab @code{MXOR @var{a},@var{b},@var{c}}
11040 @end multitable
11042 @node Raw read/write Functions
11043 @subsubsection Raw read/write Functions
11045 This sections describes built-in functions related to read and write
11046 instructions to access memory.  These functions generate
11047 @code{membar} instructions to flush the I/O load and stores where
11048 appropriate, as described in Fujitsu's manual described above.
11050 @table @code
11052 @item unsigned char __builtin_read8 (void *@var{data})
11053 @item unsigned short __builtin_read16 (void *@var{data})
11054 @item unsigned long __builtin_read32 (void *@var{data})
11055 @item unsigned long long __builtin_read64 (void *@var{data})
11057 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11058 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11059 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11060 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11061 @end table
11063 @node Other Built-in Functions
11064 @subsubsection Other Built-in Functions
11066 This section describes built-in functions that are not named after
11067 a specific FR-V instruction.
11069 @table @code
11070 @item sw2 __IACCreadll (iacc @var{reg})
11071 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11072 for future expansion and must be 0.
11074 @item sw1 __IACCreadl (iacc @var{reg})
11075 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11076 Other values of @var{reg} are rejected as invalid.
11078 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11079 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11080 is reserved for future expansion and must be 0.
11082 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11083 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11084 is 1.  Other values of @var{reg} are rejected as invalid.
11086 @item void __data_prefetch0 (const void *@var{x})
11087 Use the @code{dcpl} instruction to load the contents of address @var{x}
11088 into the data cache.
11090 @item void __data_prefetch (const void *@var{x})
11091 Use the @code{nldub} instruction to load the contents of address @var{x}
11092 into the data cache.  The instruction is issued in slot I1@.
11093 @end table
11095 @node X86 Built-in Functions
11096 @subsection X86 Built-in Functions
11098 These built-in functions are available for the i386 and x86-64 family
11099 of computers, depending on the command-line switches used.
11101 If you specify command-line switches such as @option{-msse},
11102 the compiler could use the extended instruction sets even if the built-ins
11103 are not used explicitly in the program.  For this reason, applications
11104 that perform run-time CPU detection must compile separate files for each
11105 supported architecture, using the appropriate flags.  In particular,
11106 the file containing the CPU detection code should be compiled without
11107 these options.
11109 The following machine modes are available for use with MMX built-in functions
11110 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
11111 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
11112 vector of eight 8-bit integers.  Some of the built-in functions operate on
11113 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
11115 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
11116 of two 32-bit floating-point values.
11118 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
11119 floating-point values.  Some instructions use a vector of four 32-bit
11120 integers, these use @code{V4SI}.  Finally, some instructions operate on an
11121 entire vector register, interpreting it as a 128-bit integer, these use mode
11122 @code{TI}.
11124 In 64-bit mode, the x86-64 family of processors uses additional built-in
11125 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
11126 floating point and @code{TC} 128-bit complex floating-point values.
11128 The following floating-point built-in functions are available in 64-bit
11129 mode.  All of them implement the function that is part of the name.
11131 @smallexample
11132 __float128 __builtin_fabsq (__float128)
11133 __float128 __builtin_copysignq (__float128, __float128)
11134 @end smallexample
11136 The following built-in function is always available.
11138 @table @code
11139 @item void __builtin_ia32_pause (void)
11140 Generates the @code{pause} machine instruction with a compiler memory
11141 barrier.
11142 @end table
11144 The following floating-point built-in functions are made available in the
11145 64-bit mode.
11147 @table @code
11148 @item __float128 __builtin_infq (void)
11149 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
11150 @findex __builtin_infq
11152 @item __float128 __builtin_huge_valq (void)
11153 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
11154 @findex __builtin_huge_valq
11155 @end table
11157 The following built-in functions are always available and can be used to
11158 check the target platform type.
11160 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
11161 This function runs the CPU detection code to check the type of CPU and the
11162 features supported.  This built-in function needs to be invoked along with the built-in functions
11163 to check CPU type and features, @code{__builtin_cpu_is} and
11164 @code{__builtin_cpu_supports}, only when used in a function that is
11165 executed before any constructors are called.  The CPU detection code is
11166 automatically executed in a very high priority constructor.
11168 For example, this function has to be used in @code{ifunc} resolvers that
11169 check for CPU type using the built-in functions @code{__builtin_cpu_is}
11170 and @code{__builtin_cpu_supports}, or in constructors on targets that
11171 don't support constructor priority.
11172 @smallexample
11174 static void (*resolve_memcpy (void)) (void)
11176   // ifunc resolvers fire before constructors, explicitly call the init
11177   // function.
11178   __builtin_cpu_init ();
11179   if (__builtin_cpu_supports ("ssse3"))
11180     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
11181   else
11182     return default_memcpy;
11185 void *memcpy (void *, const void *, size_t)
11186      __attribute__ ((ifunc ("resolve_memcpy")));
11187 @end smallexample
11189 @end deftypefn
11191 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
11192 This function returns a positive integer if the run-time CPU
11193 is of type @var{cpuname}
11194 and returns @code{0} otherwise. The following CPU names can be detected:
11196 @table @samp
11197 @item intel
11198 Intel CPU.
11200 @item atom
11201 Intel Atom CPU.
11203 @item core2
11204 Intel Core 2 CPU.
11206 @item corei7
11207 Intel Core i7 CPU.
11209 @item nehalem
11210 Intel Core i7 Nehalem CPU.
11212 @item westmere
11213 Intel Core i7 Westmere CPU.
11215 @item sandybridge
11216 Intel Core i7 Sandy Bridge CPU.
11218 @item amd
11219 AMD CPU.
11221 @item amdfam10h
11222 AMD Family 10h CPU.
11224 @item barcelona
11225 AMD Family 10h Barcelona CPU.
11227 @item shanghai
11228 AMD Family 10h Shanghai CPU.
11230 @item istanbul
11231 AMD Family 10h Istanbul CPU.
11233 @item btver1
11234 AMD Family 14h CPU.
11236 @item amdfam15h
11237 AMD Family 15h CPU.
11239 @item bdver1
11240 AMD Family 15h Bulldozer version 1.
11242 @item bdver2
11243 AMD Family 15h Bulldozer version 2.
11245 @item bdver3
11246 AMD Family 15h Bulldozer version 3.
11248 @item bdver4
11249 AMD Family 15h Bulldozer version 4.
11251 @item btver2
11252 AMD Family 16h CPU.
11253 @end table
11255 Here is an example:
11256 @smallexample
11257 if (__builtin_cpu_is ("corei7"))
11258   @{
11259      do_corei7 (); // Core i7 specific implementation.
11260   @}
11261 else
11262   @{
11263      do_generic (); // Generic implementation.
11264   @}
11265 @end smallexample
11266 @end deftypefn
11268 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
11269 This function returns a positive integer if the run-time CPU
11270 supports @var{feature}
11271 and returns @code{0} otherwise. The following features can be detected:
11273 @table @samp
11274 @item cmov
11275 CMOV instruction.
11276 @item mmx
11277 MMX instructions.
11278 @item popcnt
11279 POPCNT instruction.
11280 @item sse
11281 SSE instructions.
11282 @item sse2
11283 SSE2 instructions.
11284 @item sse3
11285 SSE3 instructions.
11286 @item ssse3
11287 SSSE3 instructions.
11288 @item sse4.1
11289 SSE4.1 instructions.
11290 @item sse4.2
11291 SSE4.2 instructions.
11292 @item avx
11293 AVX instructions.
11294 @item avx2
11295 AVX2 instructions.
11296 @end table
11298 Here is an example:
11299 @smallexample
11300 if (__builtin_cpu_supports ("popcnt"))
11301   @{
11302      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
11303   @}
11304 else
11305   @{
11306      count = generic_countbits (n); //generic implementation.
11307   @}
11308 @end smallexample
11309 @end deftypefn
11312 The following built-in functions are made available by @option{-mmmx}.
11313 All of them generate the machine instruction that is part of the name.
11315 @smallexample
11316 v8qi __builtin_ia32_paddb (v8qi, v8qi)
11317 v4hi __builtin_ia32_paddw (v4hi, v4hi)
11318 v2si __builtin_ia32_paddd (v2si, v2si)
11319 v8qi __builtin_ia32_psubb (v8qi, v8qi)
11320 v4hi __builtin_ia32_psubw (v4hi, v4hi)
11321 v2si __builtin_ia32_psubd (v2si, v2si)
11322 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
11323 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
11324 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
11325 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
11326 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
11327 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
11328 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
11329 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
11330 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
11331 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
11332 di __builtin_ia32_pand (di, di)
11333 di __builtin_ia32_pandn (di,di)
11334 di __builtin_ia32_por (di, di)
11335 di __builtin_ia32_pxor (di, di)
11336 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
11337 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
11338 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
11339 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
11340 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
11341 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
11342 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
11343 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
11344 v2si __builtin_ia32_punpckhdq (v2si, v2si)
11345 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
11346 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
11347 v2si __builtin_ia32_punpckldq (v2si, v2si)
11348 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
11349 v4hi __builtin_ia32_packssdw (v2si, v2si)
11350 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
11352 v4hi __builtin_ia32_psllw (v4hi, v4hi)
11353 v2si __builtin_ia32_pslld (v2si, v2si)
11354 v1di __builtin_ia32_psllq (v1di, v1di)
11355 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
11356 v2si __builtin_ia32_psrld (v2si, v2si)
11357 v1di __builtin_ia32_psrlq (v1di, v1di)
11358 v4hi __builtin_ia32_psraw (v4hi, v4hi)
11359 v2si __builtin_ia32_psrad (v2si, v2si)
11360 v4hi __builtin_ia32_psllwi (v4hi, int)
11361 v2si __builtin_ia32_pslldi (v2si, int)
11362 v1di __builtin_ia32_psllqi (v1di, int)
11363 v4hi __builtin_ia32_psrlwi (v4hi, int)
11364 v2si __builtin_ia32_psrldi (v2si, int)
11365 v1di __builtin_ia32_psrlqi (v1di, int)
11366 v4hi __builtin_ia32_psrawi (v4hi, int)
11367 v2si __builtin_ia32_psradi (v2si, int)
11369 @end smallexample
11371 The following built-in functions are made available either with
11372 @option{-msse}, or with a combination of @option{-m3dnow} and
11373 @option{-march=athlon}.  All of them generate the machine
11374 instruction that is part of the name.
11376 @smallexample
11377 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
11378 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
11379 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
11380 v1di __builtin_ia32_psadbw (v8qi, v8qi)
11381 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
11382 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
11383 v8qi __builtin_ia32_pminub (v8qi, v8qi)
11384 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
11385 int __builtin_ia32_pmovmskb (v8qi)
11386 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
11387 void __builtin_ia32_movntq (di *, di)
11388 void __builtin_ia32_sfence (void)
11389 @end smallexample
11391 The following built-in functions are available when @option{-msse} is used.
11392 All of them generate the machine instruction that is part of the name.
11394 @smallexample
11395 int __builtin_ia32_comieq (v4sf, v4sf)
11396 int __builtin_ia32_comineq (v4sf, v4sf)
11397 int __builtin_ia32_comilt (v4sf, v4sf)
11398 int __builtin_ia32_comile (v4sf, v4sf)
11399 int __builtin_ia32_comigt (v4sf, v4sf)
11400 int __builtin_ia32_comige (v4sf, v4sf)
11401 int __builtin_ia32_ucomieq (v4sf, v4sf)
11402 int __builtin_ia32_ucomineq (v4sf, v4sf)
11403 int __builtin_ia32_ucomilt (v4sf, v4sf)
11404 int __builtin_ia32_ucomile (v4sf, v4sf)
11405 int __builtin_ia32_ucomigt (v4sf, v4sf)
11406 int __builtin_ia32_ucomige (v4sf, v4sf)
11407 v4sf __builtin_ia32_addps (v4sf, v4sf)
11408 v4sf __builtin_ia32_subps (v4sf, v4sf)
11409 v4sf __builtin_ia32_mulps (v4sf, v4sf)
11410 v4sf __builtin_ia32_divps (v4sf, v4sf)
11411 v4sf __builtin_ia32_addss (v4sf, v4sf)
11412 v4sf __builtin_ia32_subss (v4sf, v4sf)
11413 v4sf __builtin_ia32_mulss (v4sf, v4sf)
11414 v4sf __builtin_ia32_divss (v4sf, v4sf)
11415 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
11416 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
11417 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
11418 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
11419 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
11420 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
11421 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
11422 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
11423 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
11424 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
11425 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
11426 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
11427 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
11428 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
11429 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
11430 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
11431 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
11432 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
11433 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
11434 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
11435 v4sf __builtin_ia32_maxps (v4sf, v4sf)
11436 v4sf __builtin_ia32_maxss (v4sf, v4sf)
11437 v4sf __builtin_ia32_minps (v4sf, v4sf)
11438 v4sf __builtin_ia32_minss (v4sf, v4sf)
11439 v4sf __builtin_ia32_andps (v4sf, v4sf)
11440 v4sf __builtin_ia32_andnps (v4sf, v4sf)
11441 v4sf __builtin_ia32_orps (v4sf, v4sf)
11442 v4sf __builtin_ia32_xorps (v4sf, v4sf)
11443 v4sf __builtin_ia32_movss (v4sf, v4sf)
11444 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
11445 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
11446 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
11447 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
11448 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
11449 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
11450 v2si __builtin_ia32_cvtps2pi (v4sf)
11451 int __builtin_ia32_cvtss2si (v4sf)
11452 v2si __builtin_ia32_cvttps2pi (v4sf)
11453 int __builtin_ia32_cvttss2si (v4sf)
11454 v4sf __builtin_ia32_rcpps (v4sf)
11455 v4sf __builtin_ia32_rsqrtps (v4sf)
11456 v4sf __builtin_ia32_sqrtps (v4sf)
11457 v4sf __builtin_ia32_rcpss (v4sf)
11458 v4sf __builtin_ia32_rsqrtss (v4sf)
11459 v4sf __builtin_ia32_sqrtss (v4sf)
11460 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
11461 void __builtin_ia32_movntps (float *, v4sf)
11462 int __builtin_ia32_movmskps (v4sf)
11463 @end smallexample
11465 The following built-in functions are available when @option{-msse} is used.
11467 @table @code
11468 @item v4sf __builtin_ia32_loadups (float *)
11469 Generates the @code{movups} machine instruction as a load from memory.
11470 @item void __builtin_ia32_storeups (float *, v4sf)
11471 Generates the @code{movups} machine instruction as a store to memory.
11472 @item v4sf __builtin_ia32_loadss (float *)
11473 Generates the @code{movss} machine instruction as a load from memory.
11474 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
11475 Generates the @code{movhps} machine instruction as a load from memory.
11476 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
11477 Generates the @code{movlps} machine instruction as a load from memory
11478 @item void __builtin_ia32_storehps (v2sf *, v4sf)
11479 Generates the @code{movhps} machine instruction as a store to memory.
11480 @item void __builtin_ia32_storelps (v2sf *, v4sf)
11481 Generates the @code{movlps} machine instruction as a store to memory.
11482 @end table
11484 The following built-in functions are available when @option{-msse2} is used.
11485 All of them generate the machine instruction that is part of the name.
11487 @smallexample
11488 int __builtin_ia32_comisdeq (v2df, v2df)
11489 int __builtin_ia32_comisdlt (v2df, v2df)
11490 int __builtin_ia32_comisdle (v2df, v2df)
11491 int __builtin_ia32_comisdgt (v2df, v2df)
11492 int __builtin_ia32_comisdge (v2df, v2df)
11493 int __builtin_ia32_comisdneq (v2df, v2df)
11494 int __builtin_ia32_ucomisdeq (v2df, v2df)
11495 int __builtin_ia32_ucomisdlt (v2df, v2df)
11496 int __builtin_ia32_ucomisdle (v2df, v2df)
11497 int __builtin_ia32_ucomisdgt (v2df, v2df)
11498 int __builtin_ia32_ucomisdge (v2df, v2df)
11499 int __builtin_ia32_ucomisdneq (v2df, v2df)
11500 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
11501 v2df __builtin_ia32_cmpltpd (v2df, v2df)
11502 v2df __builtin_ia32_cmplepd (v2df, v2df)
11503 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
11504 v2df __builtin_ia32_cmpgepd (v2df, v2df)
11505 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
11506 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
11507 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
11508 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
11509 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
11510 v2df __builtin_ia32_cmpngepd (v2df, v2df)
11511 v2df __builtin_ia32_cmpordpd (v2df, v2df)
11512 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
11513 v2df __builtin_ia32_cmpltsd (v2df, v2df)
11514 v2df __builtin_ia32_cmplesd (v2df, v2df)
11515 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
11516 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
11517 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
11518 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
11519 v2df __builtin_ia32_cmpordsd (v2df, v2df)
11520 v2di __builtin_ia32_paddq (v2di, v2di)
11521 v2di __builtin_ia32_psubq (v2di, v2di)
11522 v2df __builtin_ia32_addpd (v2df, v2df)
11523 v2df __builtin_ia32_subpd (v2df, v2df)
11524 v2df __builtin_ia32_mulpd (v2df, v2df)
11525 v2df __builtin_ia32_divpd (v2df, v2df)
11526 v2df __builtin_ia32_addsd (v2df, v2df)
11527 v2df __builtin_ia32_subsd (v2df, v2df)
11528 v2df __builtin_ia32_mulsd (v2df, v2df)
11529 v2df __builtin_ia32_divsd (v2df, v2df)
11530 v2df __builtin_ia32_minpd (v2df, v2df)
11531 v2df __builtin_ia32_maxpd (v2df, v2df)
11532 v2df __builtin_ia32_minsd (v2df, v2df)
11533 v2df __builtin_ia32_maxsd (v2df, v2df)
11534 v2df __builtin_ia32_andpd (v2df, v2df)
11535 v2df __builtin_ia32_andnpd (v2df, v2df)
11536 v2df __builtin_ia32_orpd (v2df, v2df)
11537 v2df __builtin_ia32_xorpd (v2df, v2df)
11538 v2df __builtin_ia32_movsd (v2df, v2df)
11539 v2df __builtin_ia32_unpckhpd (v2df, v2df)
11540 v2df __builtin_ia32_unpcklpd (v2df, v2df)
11541 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
11542 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
11543 v4si __builtin_ia32_paddd128 (v4si, v4si)
11544 v2di __builtin_ia32_paddq128 (v2di, v2di)
11545 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
11546 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
11547 v4si __builtin_ia32_psubd128 (v4si, v4si)
11548 v2di __builtin_ia32_psubq128 (v2di, v2di)
11549 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
11550 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
11551 v2di __builtin_ia32_pand128 (v2di, v2di)
11552 v2di __builtin_ia32_pandn128 (v2di, v2di)
11553 v2di __builtin_ia32_por128 (v2di, v2di)
11554 v2di __builtin_ia32_pxor128 (v2di, v2di)
11555 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
11556 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
11557 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
11558 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
11559 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
11560 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
11561 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
11562 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
11563 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
11564 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
11565 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
11566 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
11567 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
11568 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
11569 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
11570 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
11571 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
11572 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
11573 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
11574 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
11575 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
11576 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
11577 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
11578 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
11579 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
11580 v2df __builtin_ia32_loadupd (double *)
11581 void __builtin_ia32_storeupd (double *, v2df)
11582 v2df __builtin_ia32_loadhpd (v2df, double const *)
11583 v2df __builtin_ia32_loadlpd (v2df, double const *)
11584 int __builtin_ia32_movmskpd (v2df)
11585 int __builtin_ia32_pmovmskb128 (v16qi)
11586 void __builtin_ia32_movnti (int *, int)
11587 void __builtin_ia32_movnti64 (long long int *, long long int)
11588 void __builtin_ia32_movntpd (double *, v2df)
11589 void __builtin_ia32_movntdq (v2df *, v2df)
11590 v4si __builtin_ia32_pshufd (v4si, int)
11591 v8hi __builtin_ia32_pshuflw (v8hi, int)
11592 v8hi __builtin_ia32_pshufhw (v8hi, int)
11593 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
11594 v2df __builtin_ia32_sqrtpd (v2df)
11595 v2df __builtin_ia32_sqrtsd (v2df)
11596 v2df __builtin_ia32_shufpd (v2df, v2df, int)
11597 v2df __builtin_ia32_cvtdq2pd (v4si)
11598 v4sf __builtin_ia32_cvtdq2ps (v4si)
11599 v4si __builtin_ia32_cvtpd2dq (v2df)
11600 v2si __builtin_ia32_cvtpd2pi (v2df)
11601 v4sf __builtin_ia32_cvtpd2ps (v2df)
11602 v4si __builtin_ia32_cvttpd2dq (v2df)
11603 v2si __builtin_ia32_cvttpd2pi (v2df)
11604 v2df __builtin_ia32_cvtpi2pd (v2si)
11605 int __builtin_ia32_cvtsd2si (v2df)
11606 int __builtin_ia32_cvttsd2si (v2df)
11607 long long __builtin_ia32_cvtsd2si64 (v2df)
11608 long long __builtin_ia32_cvttsd2si64 (v2df)
11609 v4si __builtin_ia32_cvtps2dq (v4sf)
11610 v2df __builtin_ia32_cvtps2pd (v4sf)
11611 v4si __builtin_ia32_cvttps2dq (v4sf)
11612 v2df __builtin_ia32_cvtsi2sd (v2df, int)
11613 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
11614 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
11615 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
11616 void __builtin_ia32_clflush (const void *)
11617 void __builtin_ia32_lfence (void)
11618 void __builtin_ia32_mfence (void)
11619 v16qi __builtin_ia32_loaddqu (const char *)
11620 void __builtin_ia32_storedqu (char *, v16qi)
11621 v1di __builtin_ia32_pmuludq (v2si, v2si)
11622 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
11623 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
11624 v4si __builtin_ia32_pslld128 (v4si, v4si)
11625 v2di __builtin_ia32_psllq128 (v2di, v2di)
11626 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
11627 v4si __builtin_ia32_psrld128 (v4si, v4si)
11628 v2di __builtin_ia32_psrlq128 (v2di, v2di)
11629 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
11630 v4si __builtin_ia32_psrad128 (v4si, v4si)
11631 v2di __builtin_ia32_pslldqi128 (v2di, int)
11632 v8hi __builtin_ia32_psllwi128 (v8hi, int)
11633 v4si __builtin_ia32_pslldi128 (v4si, int)
11634 v2di __builtin_ia32_psllqi128 (v2di, int)
11635 v2di __builtin_ia32_psrldqi128 (v2di, int)
11636 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
11637 v4si __builtin_ia32_psrldi128 (v4si, int)
11638 v2di __builtin_ia32_psrlqi128 (v2di, int)
11639 v8hi __builtin_ia32_psrawi128 (v8hi, int)
11640 v4si __builtin_ia32_psradi128 (v4si, int)
11641 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
11642 v2di __builtin_ia32_movq128 (v2di)
11643 @end smallexample
11645 The following built-in functions are available when @option{-msse3} is used.
11646 All of them generate the machine instruction that is part of the name.
11648 @smallexample
11649 v2df __builtin_ia32_addsubpd (v2df, v2df)
11650 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
11651 v2df __builtin_ia32_haddpd (v2df, v2df)
11652 v4sf __builtin_ia32_haddps (v4sf, v4sf)
11653 v2df __builtin_ia32_hsubpd (v2df, v2df)
11654 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
11655 v16qi __builtin_ia32_lddqu (char const *)
11656 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
11657 v4sf __builtin_ia32_movshdup (v4sf)
11658 v4sf __builtin_ia32_movsldup (v4sf)
11659 void __builtin_ia32_mwait (unsigned int, unsigned int)
11660 @end smallexample
11662 The following built-in functions are available when @option{-mssse3} is used.
11663 All of them generate the machine instruction that is part of the name.
11665 @smallexample
11666 v2si __builtin_ia32_phaddd (v2si, v2si)
11667 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
11668 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
11669 v2si __builtin_ia32_phsubd (v2si, v2si)
11670 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
11671 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
11672 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
11673 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
11674 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
11675 v8qi __builtin_ia32_psignb (v8qi, v8qi)
11676 v2si __builtin_ia32_psignd (v2si, v2si)
11677 v4hi __builtin_ia32_psignw (v4hi, v4hi)
11678 v1di __builtin_ia32_palignr (v1di, v1di, int)
11679 v8qi __builtin_ia32_pabsb (v8qi)
11680 v2si __builtin_ia32_pabsd (v2si)
11681 v4hi __builtin_ia32_pabsw (v4hi)
11682 @end smallexample
11684 The following built-in functions are available when @option{-mssse3} is used.
11685 All of them generate the machine instruction that is part of the name.
11687 @smallexample
11688 v4si __builtin_ia32_phaddd128 (v4si, v4si)
11689 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
11690 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
11691 v4si __builtin_ia32_phsubd128 (v4si, v4si)
11692 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
11693 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
11694 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
11695 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
11696 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
11697 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
11698 v4si __builtin_ia32_psignd128 (v4si, v4si)
11699 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
11700 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
11701 v16qi __builtin_ia32_pabsb128 (v16qi)
11702 v4si __builtin_ia32_pabsd128 (v4si)
11703 v8hi __builtin_ia32_pabsw128 (v8hi)
11704 @end smallexample
11706 The following built-in functions are available when @option{-msse4.1} is
11707 used.  All of them generate the machine instruction that is part of the
11708 name.
11710 @smallexample
11711 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
11712 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
11713 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
11714 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
11715 v2df __builtin_ia32_dppd (v2df, v2df, const int)
11716 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
11717 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
11718 v2di __builtin_ia32_movntdqa (v2di *);
11719 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
11720 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
11721 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
11722 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
11723 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
11724 v8hi __builtin_ia32_phminposuw128 (v8hi)
11725 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
11726 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
11727 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
11728 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
11729 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
11730 v4si __builtin_ia32_pminsd128 (v4si, v4si)
11731 v4si __builtin_ia32_pminud128 (v4si, v4si)
11732 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
11733 v4si __builtin_ia32_pmovsxbd128 (v16qi)
11734 v2di __builtin_ia32_pmovsxbq128 (v16qi)
11735 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
11736 v2di __builtin_ia32_pmovsxdq128 (v4si)
11737 v4si __builtin_ia32_pmovsxwd128 (v8hi)
11738 v2di __builtin_ia32_pmovsxwq128 (v8hi)
11739 v4si __builtin_ia32_pmovzxbd128 (v16qi)
11740 v2di __builtin_ia32_pmovzxbq128 (v16qi)
11741 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
11742 v2di __builtin_ia32_pmovzxdq128 (v4si)
11743 v4si __builtin_ia32_pmovzxwd128 (v8hi)
11744 v2di __builtin_ia32_pmovzxwq128 (v8hi)
11745 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
11746 v4si __builtin_ia32_pmulld128 (v4si, v4si)
11747 int __builtin_ia32_ptestc128 (v2di, v2di)
11748 int __builtin_ia32_ptestnzc128 (v2di, v2di)
11749 int __builtin_ia32_ptestz128 (v2di, v2di)
11750 v2df __builtin_ia32_roundpd (v2df, const int)
11751 v4sf __builtin_ia32_roundps (v4sf, const int)
11752 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
11753 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
11754 @end smallexample
11756 The following built-in functions are available when @option{-msse4.1} is
11757 used.
11759 @table @code
11760 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
11761 Generates the @code{insertps} machine instruction.
11762 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
11763 Generates the @code{pextrb} machine instruction.
11764 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
11765 Generates the @code{pinsrb} machine instruction.
11766 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
11767 Generates the @code{pinsrd} machine instruction.
11768 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
11769 Generates the @code{pinsrq} machine instruction in 64bit mode.
11770 @end table
11772 The following built-in functions are changed to generate new SSE4.1
11773 instructions when @option{-msse4.1} is used.
11775 @table @code
11776 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
11777 Generates the @code{extractps} machine instruction.
11778 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
11779 Generates the @code{pextrd} machine instruction.
11780 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
11781 Generates the @code{pextrq} machine instruction in 64bit mode.
11782 @end table
11784 The following built-in functions are available when @option{-msse4.2} is
11785 used.  All of them generate the machine instruction that is part of the
11786 name.
11788 @smallexample
11789 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
11790 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
11791 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
11792 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
11793 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
11794 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
11795 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
11796 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
11797 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
11798 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
11799 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
11800 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
11801 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
11802 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
11803 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
11804 @end smallexample
11806 The following built-in functions are available when @option{-msse4.2} is
11807 used.
11809 @table @code
11810 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
11811 Generates the @code{crc32b} machine instruction.
11812 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
11813 Generates the @code{crc32w} machine instruction.
11814 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
11815 Generates the @code{crc32l} machine instruction.
11816 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
11817 Generates the @code{crc32q} machine instruction.
11818 @end table
11820 The following built-in functions are changed to generate new SSE4.2
11821 instructions when @option{-msse4.2} is used.
11823 @table @code
11824 @item int __builtin_popcount (unsigned int)
11825 Generates the @code{popcntl} machine instruction.
11826 @item int __builtin_popcountl (unsigned long)
11827 Generates the @code{popcntl} or @code{popcntq} machine instruction,
11828 depending on the size of @code{unsigned long}.
11829 @item int __builtin_popcountll (unsigned long long)
11830 Generates the @code{popcntq} machine instruction.
11831 @end table
11833 The following built-in functions are available when @option{-mavx} is
11834 used. All of them generate the machine instruction that is part of the
11835 name.
11837 @smallexample
11838 v4df __builtin_ia32_addpd256 (v4df,v4df)
11839 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
11840 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
11841 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
11842 v4df __builtin_ia32_andnpd256 (v4df,v4df)
11843 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
11844 v4df __builtin_ia32_andpd256 (v4df,v4df)
11845 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11846 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11847 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11848 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11849 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11850 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11851 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11852 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11853 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11854 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11855 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11856 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11857 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11858 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11859 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11860 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11861 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11862 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11863 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11864 v4df __builtin_ia32_divpd256 (v4df,v4df)
11865 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11866 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11867 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11868 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11869 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11870 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11871 v32qi __builtin_ia32_lddqu256 (pcchar)
11872 v32qi __builtin_ia32_loaddqu256 (pcchar)
11873 v4df __builtin_ia32_loadupd256 (pcdouble)
11874 v8sf __builtin_ia32_loadups256 (pcfloat)
11875 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11876 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11877 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11878 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11879 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11880 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11881 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11882 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11883 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11884 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11885 v4df __builtin_ia32_minpd256 (v4df,v4df)
11886 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11887 v4df __builtin_ia32_movddup256 (v4df)
11888 int __builtin_ia32_movmskpd256 (v4df)
11889 int __builtin_ia32_movmskps256 (v8sf)
11890 v8sf __builtin_ia32_movshdup256 (v8sf)
11891 v8sf __builtin_ia32_movsldup256 (v8sf)
11892 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11893 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11894 v4df __builtin_ia32_orpd256 (v4df,v4df)
11895 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11896 v2df __builtin_ia32_pd_pd256 (v4df)
11897 v4df __builtin_ia32_pd256_pd (v2df)
11898 v4sf __builtin_ia32_ps_ps256 (v8sf)
11899 v8sf __builtin_ia32_ps256_ps (v4sf)
11900 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11901 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11902 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11903 v8sf __builtin_ia32_rcpps256 (v8sf)
11904 v4df __builtin_ia32_roundpd256 (v4df,int)
11905 v8sf __builtin_ia32_roundps256 (v8sf,int)
11906 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11907 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11908 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11909 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11910 v4si __builtin_ia32_si_si256 (v8si)
11911 v8si __builtin_ia32_si256_si (v4si)
11912 v4df __builtin_ia32_sqrtpd256 (v4df)
11913 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11914 v8sf __builtin_ia32_sqrtps256 (v8sf)
11915 void __builtin_ia32_storedqu256 (pchar,v32qi)
11916 void __builtin_ia32_storeupd256 (pdouble,v4df)
11917 void __builtin_ia32_storeups256 (pfloat,v8sf)
11918 v4df __builtin_ia32_subpd256 (v4df,v4df)
11919 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11920 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11921 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11922 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11923 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11924 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11925 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11926 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11927 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11928 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11929 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11930 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11931 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11932 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11933 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11934 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11935 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11936 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11937 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11938 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11939 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11940 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11941 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11942 v2df __builtin_ia32_vpermilpd (v2df,int)
11943 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11944 v4sf __builtin_ia32_vpermilps (v4sf,int)
11945 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11946 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11947 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11948 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11949 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11950 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11951 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11952 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11953 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11954 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11955 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11956 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11957 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11958 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11959 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11960 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11961 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11962 void __builtin_ia32_vzeroall (void)
11963 void __builtin_ia32_vzeroupper (void)
11964 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11965 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11966 @end smallexample
11968 The following built-in functions are available when @option{-mavx2} is
11969 used. All of them generate the machine instruction that is part of the
11970 name.
11972 @smallexample
11973 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
11974 v32qi __builtin_ia32_pabsb256 (v32qi)
11975 v16hi __builtin_ia32_pabsw256 (v16hi)
11976 v8si __builtin_ia32_pabsd256 (v8si)
11977 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11978 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11979 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11980 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11981 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11982 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11983 v8si __builtin_ia32_paddd256 (v8si,v8si)
11984 v4di __builtin_ia32_paddq256 (v4di,v4di)
11985 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11986 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11987 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11988 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11989 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11990 v4di __builtin_ia32_andsi256 (v4di,v4di)
11991 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11992 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11993 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11994 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11995 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11996 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11997 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11998 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11999 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
12000 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
12001 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
12002 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
12003 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
12004 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
12005 v8si __builtin_ia32_phaddd256 (v8si,v8si)
12006 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
12007 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
12008 v8si __builtin_ia32_phsubd256 (v8si,v8si)
12009 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
12010 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
12011 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
12012 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
12013 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
12014 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
12015 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
12016 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
12017 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
12018 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
12019 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
12020 v8si __builtin_ia32_pminsd256 (v8si,v8si)
12021 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
12022 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
12023 v8si __builtin_ia32_pminud256 (v8si,v8si)
12024 int __builtin_ia32_pmovmskb256 (v32qi)
12025 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
12026 v8si __builtin_ia32_pmovsxbd256 (v16qi)
12027 v4di __builtin_ia32_pmovsxbq256 (v16qi)
12028 v8si __builtin_ia32_pmovsxwd256 (v8hi)
12029 v4di __builtin_ia32_pmovsxwq256 (v8hi)
12030 v4di __builtin_ia32_pmovsxdq256 (v4si)
12031 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
12032 v8si __builtin_ia32_pmovzxbd256 (v16qi)
12033 v4di __builtin_ia32_pmovzxbq256 (v16qi)
12034 v8si __builtin_ia32_pmovzxwd256 (v8hi)
12035 v4di __builtin_ia32_pmovzxwq256 (v8hi)
12036 v4di __builtin_ia32_pmovzxdq256 (v4si)
12037 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
12038 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
12039 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
12040 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
12041 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
12042 v8si __builtin_ia32_pmulld256 (v8si,v8si)
12043 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
12044 v4di __builtin_ia32_por256 (v4di,v4di)
12045 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
12046 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
12047 v8si __builtin_ia32_pshufd256 (v8si,int)
12048 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
12049 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
12050 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
12051 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
12052 v8si __builtin_ia32_psignd256 (v8si,v8si)
12053 v4di __builtin_ia32_pslldqi256 (v4di,int)
12054 v16hi __builtin_ia32_psllwi256 (16hi,int)
12055 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
12056 v8si __builtin_ia32_pslldi256 (v8si,int)
12057 v8si __builtin_ia32_pslld256(v8si,v4si)
12058 v4di __builtin_ia32_psllqi256 (v4di,int)
12059 v4di __builtin_ia32_psllq256(v4di,v2di)
12060 v16hi __builtin_ia32_psrawi256 (v16hi,int)
12061 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
12062 v8si __builtin_ia32_psradi256 (v8si,int)
12063 v8si __builtin_ia32_psrad256 (v8si,v4si)
12064 v4di __builtin_ia32_psrldqi256 (v4di, int)
12065 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
12066 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
12067 v8si __builtin_ia32_psrldi256 (v8si,int)
12068 v8si __builtin_ia32_psrld256 (v8si,v4si)
12069 v4di __builtin_ia32_psrlqi256 (v4di,int)
12070 v4di __builtin_ia32_psrlq256(v4di,v2di)
12071 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
12072 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
12073 v8si __builtin_ia32_psubd256 (v8si,v8si)
12074 v4di __builtin_ia32_psubq256 (v4di,v4di)
12075 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
12076 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
12077 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
12078 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
12079 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
12080 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
12081 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
12082 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
12083 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
12084 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
12085 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
12086 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
12087 v4di __builtin_ia32_pxor256 (v4di,v4di)
12088 v4di __builtin_ia32_movntdqa256 (pv4di)
12089 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
12090 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
12091 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
12092 v4di __builtin_ia32_vbroadcastsi256 (v2di)
12093 v4si __builtin_ia32_pblendd128 (v4si,v4si)
12094 v8si __builtin_ia32_pblendd256 (v8si,v8si)
12095 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
12096 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
12097 v8si __builtin_ia32_pbroadcastd256 (v4si)
12098 v4di __builtin_ia32_pbroadcastq256 (v2di)
12099 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
12100 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
12101 v4si __builtin_ia32_pbroadcastd128 (v4si)
12102 v2di __builtin_ia32_pbroadcastq128 (v2di)
12103 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
12104 v4df __builtin_ia32_permdf256 (v4df,int)
12105 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
12106 v4di __builtin_ia32_permdi256 (v4di,int)
12107 v4di __builtin_ia32_permti256 (v4di,v4di,int)
12108 v4di __builtin_ia32_extract128i256 (v4di,int)
12109 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
12110 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
12111 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
12112 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
12113 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
12114 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
12115 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
12116 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
12117 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
12118 v8si __builtin_ia32_psllv8si (v8si,v8si)
12119 v4si __builtin_ia32_psllv4si (v4si,v4si)
12120 v4di __builtin_ia32_psllv4di (v4di,v4di)
12121 v2di __builtin_ia32_psllv2di (v2di,v2di)
12122 v8si __builtin_ia32_psrav8si (v8si,v8si)
12123 v4si __builtin_ia32_psrav4si (v4si,v4si)
12124 v8si __builtin_ia32_psrlv8si (v8si,v8si)
12125 v4si __builtin_ia32_psrlv4si (v4si,v4si)
12126 v4di __builtin_ia32_psrlv4di (v4di,v4di)
12127 v2di __builtin_ia32_psrlv2di (v2di,v2di)
12128 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
12129 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
12130 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
12131 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
12132 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
12133 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
12134 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
12135 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
12136 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
12137 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
12138 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
12139 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
12140 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
12141 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
12142 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
12143 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
12144 @end smallexample
12146 The following built-in functions are available when @option{-maes} is
12147 used.  All of them generate the machine instruction that is part of the
12148 name.
12150 @smallexample
12151 v2di __builtin_ia32_aesenc128 (v2di, v2di)
12152 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
12153 v2di __builtin_ia32_aesdec128 (v2di, v2di)
12154 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
12155 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
12156 v2di __builtin_ia32_aesimc128 (v2di)
12157 @end smallexample
12159 The following built-in function is available when @option{-mpclmul} is
12160 used.
12162 @table @code
12163 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
12164 Generates the @code{pclmulqdq} machine instruction.
12165 @end table
12167 The following built-in function is available when @option{-mfsgsbase} is
12168 used.  All of them generate the machine instruction that is part of the
12169 name.
12171 @smallexample
12172 unsigned int __builtin_ia32_rdfsbase32 (void)
12173 unsigned long long __builtin_ia32_rdfsbase64 (void)
12174 unsigned int __builtin_ia32_rdgsbase32 (void)
12175 unsigned long long __builtin_ia32_rdgsbase64 (void)
12176 void _writefsbase_u32 (unsigned int)
12177 void _writefsbase_u64 (unsigned long long)
12178 void _writegsbase_u32 (unsigned int)
12179 void _writegsbase_u64 (unsigned long long)
12180 @end smallexample
12182 The following built-in function is available when @option{-mrdrnd} is
12183 used.  All of them generate the machine instruction that is part of the
12184 name.
12186 @smallexample
12187 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
12188 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
12189 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
12190 @end smallexample
12192 The following built-in functions are available when @option{-msse4a} is used.
12193 All of them generate the machine instruction that is part of the name.
12195 @smallexample
12196 void __builtin_ia32_movntsd (double *, v2df)
12197 void __builtin_ia32_movntss (float *, v4sf)
12198 v2di __builtin_ia32_extrq  (v2di, v16qi)
12199 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
12200 v2di __builtin_ia32_insertq (v2di, v2di)
12201 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
12202 @end smallexample
12204 The following built-in functions are available when @option{-mxop} is used.
12205 @smallexample
12206 v2df __builtin_ia32_vfrczpd (v2df)
12207 v4sf __builtin_ia32_vfrczps (v4sf)
12208 v2df __builtin_ia32_vfrczsd (v2df)
12209 v4sf __builtin_ia32_vfrczss (v4sf)
12210 v4df __builtin_ia32_vfrczpd256 (v4df)
12211 v8sf __builtin_ia32_vfrczps256 (v8sf)
12212 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
12213 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
12214 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
12215 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
12216 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
12217 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
12218 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
12219 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
12220 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
12221 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
12222 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
12223 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
12224 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
12225 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
12226 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12227 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
12228 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
12229 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
12230 v4si __builtin_ia32_vpcomequd (v4si, v4si)
12231 v2di __builtin_ia32_vpcomequq (v2di, v2di)
12232 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
12233 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
12234 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
12235 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
12236 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
12237 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
12238 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
12239 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
12240 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
12241 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
12242 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
12243 v4si __builtin_ia32_vpcomged (v4si, v4si)
12244 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
12245 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
12246 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
12247 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
12248 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
12249 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
12250 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
12251 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
12252 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
12253 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
12254 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
12255 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
12256 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
12257 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
12258 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
12259 v4si __builtin_ia32_vpcomled (v4si, v4si)
12260 v2di __builtin_ia32_vpcomleq (v2di, v2di)
12261 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
12262 v4si __builtin_ia32_vpcomleud (v4si, v4si)
12263 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
12264 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
12265 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
12266 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
12267 v4si __builtin_ia32_vpcomltd (v4si, v4si)
12268 v2di __builtin_ia32_vpcomltq (v2di, v2di)
12269 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
12270 v4si __builtin_ia32_vpcomltud (v4si, v4si)
12271 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
12272 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
12273 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
12274 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
12275 v4si __builtin_ia32_vpcomned (v4si, v4si)
12276 v2di __builtin_ia32_vpcomneq (v2di, v2di)
12277 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
12278 v4si __builtin_ia32_vpcomneud (v4si, v4si)
12279 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
12280 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
12281 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
12282 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
12283 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
12284 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
12285 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
12286 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
12287 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
12288 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
12289 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
12290 v4si __builtin_ia32_vphaddbd (v16qi)
12291 v2di __builtin_ia32_vphaddbq (v16qi)
12292 v8hi __builtin_ia32_vphaddbw (v16qi)
12293 v2di __builtin_ia32_vphadddq (v4si)
12294 v4si __builtin_ia32_vphaddubd (v16qi)
12295 v2di __builtin_ia32_vphaddubq (v16qi)
12296 v8hi __builtin_ia32_vphaddubw (v16qi)
12297 v2di __builtin_ia32_vphaddudq (v4si)
12298 v4si __builtin_ia32_vphadduwd (v8hi)
12299 v2di __builtin_ia32_vphadduwq (v8hi)
12300 v4si __builtin_ia32_vphaddwd (v8hi)
12301 v2di __builtin_ia32_vphaddwq (v8hi)
12302 v8hi __builtin_ia32_vphsubbw (v16qi)
12303 v2di __builtin_ia32_vphsubdq (v4si)
12304 v4si __builtin_ia32_vphsubwd (v8hi)
12305 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
12306 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
12307 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
12308 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
12309 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
12310 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
12311 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
12312 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
12313 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
12314 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
12315 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
12316 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
12317 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
12318 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
12319 v4si __builtin_ia32_vprotd (v4si, v4si)
12320 v2di __builtin_ia32_vprotq (v2di, v2di)
12321 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
12322 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
12323 v4si __builtin_ia32_vpshad (v4si, v4si)
12324 v2di __builtin_ia32_vpshaq (v2di, v2di)
12325 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
12326 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
12327 v4si __builtin_ia32_vpshld (v4si, v4si)
12328 v2di __builtin_ia32_vpshlq (v2di, v2di)
12329 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
12330 @end smallexample
12332 The following built-in functions are available when @option{-mfma4} is used.
12333 All of them generate the machine instruction that is part of the name.
12335 @smallexample
12336 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
12337 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
12338 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
12339 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
12340 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
12341 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
12342 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
12343 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
12344 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
12345 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
12346 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
12347 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
12348 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
12349 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
12350 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
12351 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
12352 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
12353 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
12354 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
12355 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
12356 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
12357 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
12358 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
12359 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
12360 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
12361 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
12362 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
12363 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
12364 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
12365 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
12366 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
12367 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
12369 @end smallexample
12371 The following built-in functions are available when @option{-mlwp} is used.
12373 @smallexample
12374 void __builtin_ia32_llwpcb16 (void *);
12375 void __builtin_ia32_llwpcb32 (void *);
12376 void __builtin_ia32_llwpcb64 (void *);
12377 void * __builtin_ia32_llwpcb16 (void);
12378 void * __builtin_ia32_llwpcb32 (void);
12379 void * __builtin_ia32_llwpcb64 (void);
12380 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
12381 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
12382 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
12383 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
12384 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
12385 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
12386 @end smallexample
12388 The following built-in functions are available when @option{-mbmi} is used.
12389 All of them generate the machine instruction that is part of the name.
12390 @smallexample
12391 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
12392 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
12393 @end smallexample
12395 The following built-in functions are available when @option{-mbmi2} is used.
12396 All of them generate the machine instruction that is part of the name.
12397 @smallexample
12398 unsigned int _bzhi_u32 (unsigned int, unsigned int)
12399 unsigned int _pdep_u32 (unsigned int, unsigned int)
12400 unsigned int _pext_u32 (unsigned int, unsigned int)
12401 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
12402 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
12403 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
12404 @end smallexample
12406 The following built-in functions are available when @option{-mlzcnt} is used.
12407 All of them generate the machine instruction that is part of the name.
12408 @smallexample
12409 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
12410 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
12411 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
12412 @end smallexample
12414 The following built-in functions are available when @option{-mfxsr} is used.
12415 All of them generate the machine instruction that is part of the name.
12416 @smallexample
12417 void __builtin_ia32_fxsave (void *)
12418 void __builtin_ia32_fxrstor (void *)
12419 void __builtin_ia32_fxsave64 (void *)
12420 void __builtin_ia32_fxrstor64 (void *)
12421 @end smallexample
12423 The following built-in functions are available when @option{-mxsave} is used.
12424 All of them generate the machine instruction that is part of the name.
12425 @smallexample
12426 void __builtin_ia32_xsave (void *, long long)
12427 void __builtin_ia32_xrstor (void *, long long)
12428 void __builtin_ia32_xsave64 (void *, long long)
12429 void __builtin_ia32_xrstor64 (void *, long long)
12430 @end smallexample
12432 The following built-in functions are available when @option{-mxsaveopt} is used.
12433 All of them generate the machine instruction that is part of the name.
12434 @smallexample
12435 void __builtin_ia32_xsaveopt (void *, long long)
12436 void __builtin_ia32_xsaveopt64 (void *, long long)
12437 @end smallexample
12439 The following built-in functions are available when @option{-mtbm} is used.
12440 Both of them generate the immediate form of the bextr machine instruction.
12441 @smallexample
12442 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
12443 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
12444 @end smallexample
12447 The following built-in functions are available when @option{-m3dnow} is used.
12448 All of them generate the machine instruction that is part of the name.
12450 @smallexample
12451 void __builtin_ia32_femms (void)
12452 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
12453 v2si __builtin_ia32_pf2id (v2sf)
12454 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
12455 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
12456 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
12457 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
12458 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
12459 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
12460 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
12461 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
12462 v2sf __builtin_ia32_pfrcp (v2sf)
12463 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
12464 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
12465 v2sf __builtin_ia32_pfrsqrt (v2sf)
12466 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
12467 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
12468 v2sf __builtin_ia32_pi2fd (v2si)
12469 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
12470 @end smallexample
12472 The following built-in functions are available when both @option{-m3dnow}
12473 and @option{-march=athlon} are used.  All of them generate the machine
12474 instruction that is part of the name.
12476 @smallexample
12477 v2si __builtin_ia32_pf2iw (v2sf)
12478 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
12479 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
12480 v2sf __builtin_ia32_pi2fw (v2si)
12481 v2sf __builtin_ia32_pswapdsf (v2sf)
12482 v2si __builtin_ia32_pswapdsi (v2si)
12483 @end smallexample
12485 The following built-in functions are available when @option{-mrtm} is used
12486 They are used for restricted transactional memory. These are the internal
12487 low level functions. Normally the functions in 
12488 @ref{X86 transactional memory intrinsics} should be used instead.
12490 @smallexample
12491 int __builtin_ia32_xbegin ()
12492 void __builtin_ia32_xend ()
12493 void __builtin_ia32_xabort (status)
12494 int __builtin_ia32_xtest ()
12495 @end smallexample
12497 @node X86 transactional memory intrinsics
12498 @subsection X86 transaction memory intrinsics
12500 Hardware transactional memory intrinsics for i386. These allow to use
12501 memory transactions with RTM (Restricted Transactional Memory).
12502 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
12503 This support is enabled with the @option{-mrtm} option.
12505 A memory transaction commits all changes to memory in an atomic way,
12506 as visible to other threads. If the transaction fails it is rolled back
12507 and all side effects discarded.
12509 Generally there is no guarantee that a memory transaction ever succeeds
12510 and suitable fallback code always needs to be supplied.
12512 @deftypefn {RTM Function} {unsigned} _xbegin ()
12513 Start a RTM (Restricted Transactional Memory) transaction. 
12514 Returns _XBEGIN_STARTED when the transaction
12515 started successfully (note this is not 0, so the constant has to be 
12516 explicitely tested). When the transaction aborts all side effects
12517 are undone and an abort code is returned. There is no guarantee
12518 any transaction ever succeeds, so there always needs to be a valid
12519 tested fallback path.
12520 @end deftypefn
12522 @smallexample
12523 #include <immintrin.h>
12525 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
12526     ... transaction code...
12527     _xend ();
12528 @} else @{
12529     ... non transactional fallback path...
12531 @end smallexample
12533 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
12535 @table @code
12536 @item _XABORT_EXPLICIT
12537 Transaction explicitely aborted with @code{_xabort}. The parameter passed
12538 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
12539 @item _XABORT_RETRY
12540 Transaction retry is possible.
12541 @item _XABORT_CONFLICT
12542 Transaction abort due to a memory conflict with another thread
12543 @item _XABORT_CAPACITY
12544 Transaction abort due to the transaction using too much memory
12545 @item _XABORT_DEBUG
12546 Transaction abort due to a debug trap
12547 @item _XABORT_NESTED
12548 Transaction abort in a inner nested transaction
12549 @end table
12551 @deftypefn {RTM Function} {void} _xend ()
12552 Commit the current transaction. When no transaction is active this will
12553 fault. All memory side effects of the transactions will become visible
12554 to other threads in an atomic matter.
12555 @end deftypefn
12557 @deftypefn {RTM Function} {int} _xtest ()
12558 Return a value not zero when a transaction is currently active, otherwise 0.
12559 @end deftypefn
12561 @deftypefn {RTM Function} {void} _xabort (status)
12562 Abort the current transaction. When no transaction is active this is a no-op.
12563 status must be a 8bit constant, that is included in the status code returned
12564 by @code{_xbegin}
12565 @end deftypefn
12567 @node MIPS DSP Built-in Functions
12568 @subsection MIPS DSP Built-in Functions
12570 The MIPS DSP Application-Specific Extension (ASE) includes new
12571 instructions that are designed to improve the performance of DSP and
12572 media applications.  It provides instructions that operate on packed
12573 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12575 GCC supports MIPS DSP operations using both the generic
12576 vector extensions (@pxref{Vector Extensions}) and a collection of
12577 MIPS-specific built-in functions.  Both kinds of support are
12578 enabled by the @option{-mdsp} command-line option.
12580 Revision 2 of the ASE was introduced in the second half of 2006.
12581 This revision adds extra instructions to the original ASE, but is
12582 otherwise backwards-compatible with it.  You can select revision 2
12583 using the command-line option @option{-mdspr2}; this option implies
12584 @option{-mdsp}.
12586 The SCOUNT and POS bits of the DSP control register are global.  The
12587 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12588 POS bits.  During optimization, the compiler does not delete these
12589 instructions and it does not delete calls to functions containing
12590 these instructions.
12592 At present, GCC only provides support for operations on 32-bit
12593 vectors.  The vector type associated with 8-bit integer data is
12594 usually called @code{v4i8}, the vector type associated with Q7
12595 is usually called @code{v4q7}, the vector type associated with 16-bit
12596 integer data is usually called @code{v2i16}, and the vector type
12597 associated with Q15 is usually called @code{v2q15}.  They can be
12598 defined in C as follows:
12600 @smallexample
12601 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12602 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12603 typedef short v2i16 __attribute__ ((vector_size(4)));
12604 typedef short v2q15 __attribute__ ((vector_size(4)));
12605 @end smallexample
12607 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12608 initialized in the same way as aggregates.  For example:
12610 @smallexample
12611 v4i8 a = @{1, 2, 3, 4@};
12612 v4i8 b;
12613 b = (v4i8) @{5, 6, 7, 8@};
12615 v2q15 c = @{0x0fcb, 0x3a75@};
12616 v2q15 d;
12617 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12618 @end smallexample
12620 @emph{Note:} The CPU's endianness determines the order in which values
12621 are packed.  On little-endian targets, the first value is the least
12622 significant and the last value is the most significant.  The opposite
12623 order applies to big-endian targets.  For example, the code above
12624 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12625 and @code{4} on big-endian targets.
12627 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12628 representation.  As shown in this example, the integer representation
12629 of a Q7 value can be obtained by multiplying the fractional value by
12630 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
12631 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
12632 @code{0x1.0p31}.
12634 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12635 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
12636 and @code{c} and @code{d} are @code{v2q15} values.
12638 @multitable @columnfractions .50 .50
12639 @item C code @tab MIPS instruction
12640 @item @code{a + b} @tab @code{addu.qb}
12641 @item @code{c + d} @tab @code{addq.ph}
12642 @item @code{a - b} @tab @code{subu.qb}
12643 @item @code{c - d} @tab @code{subq.ph}
12644 @end multitable
12646 The table below lists the @code{v2i16} operation for which
12647 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
12648 @code{v2i16} values.
12650 @multitable @columnfractions .50 .50
12651 @item C code @tab MIPS instruction
12652 @item @code{e * f} @tab @code{mul.ph}
12653 @end multitable
12655 It is easier to describe the DSP built-in functions if we first define
12656 the following types:
12658 @smallexample
12659 typedef int q31;
12660 typedef int i32;
12661 typedef unsigned int ui32;
12662 typedef long long a64;
12663 @end smallexample
12665 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12666 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12667 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
12668 @code{long long}, but we use @code{a64} to indicate values that are
12669 placed in one of the four DSP accumulators (@code{$ac0},
12670 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12672 Also, some built-in functions prefer or require immediate numbers as
12673 parameters, because the corresponding DSP instructions accept both immediate
12674 numbers and register operands, or accept immediate numbers only.  The
12675 immediate parameters are listed as follows.
12677 @smallexample
12678 imm0_3: 0 to 3.
12679 imm0_7: 0 to 7.
12680 imm0_15: 0 to 15.
12681 imm0_31: 0 to 31.
12682 imm0_63: 0 to 63.
12683 imm0_255: 0 to 255.
12684 imm_n32_31: -32 to 31.
12685 imm_n512_511: -512 to 511.
12686 @end smallexample
12688 The following built-in functions map directly to a particular MIPS DSP
12689 instruction.  Please refer to the architecture specification
12690 for details on what each instruction does.
12692 @smallexample
12693 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12694 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12695 q31 __builtin_mips_addq_s_w (q31, q31)
12696 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12697 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12698 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12699 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12700 q31 __builtin_mips_subq_s_w (q31, q31)
12701 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12702 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12703 i32 __builtin_mips_addsc (i32, i32)
12704 i32 __builtin_mips_addwc (i32, i32)
12705 i32 __builtin_mips_modsub (i32, i32)
12706 i32 __builtin_mips_raddu_w_qb (v4i8)
12707 v2q15 __builtin_mips_absq_s_ph (v2q15)
12708 q31 __builtin_mips_absq_s_w (q31)
12709 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12710 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12711 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12712 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12713 q31 __builtin_mips_preceq_w_phl (v2q15)
12714 q31 __builtin_mips_preceq_w_phr (v2q15)
12715 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12716 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12717 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12718 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12719 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12720 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12721 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12722 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12723 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12724 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12725 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12726 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12727 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12728 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12729 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12730 q31 __builtin_mips_shll_s_w (q31, i32)
12731 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12732 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12733 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12734 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12735 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12736 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12737 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12738 q31 __builtin_mips_shra_r_w (q31, i32)
12739 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12740 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12741 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12742 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12743 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12744 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12745 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12746 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12747 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12748 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12749 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12750 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12751 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12752 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12753 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12754 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12755 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12756 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12757 i32 __builtin_mips_bitrev (i32)
12758 i32 __builtin_mips_insv (i32, i32)
12759 v4i8 __builtin_mips_repl_qb (imm0_255)
12760 v4i8 __builtin_mips_repl_qb (i32)
12761 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12762 v2q15 __builtin_mips_repl_ph (i32)
12763 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12764 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12765 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12766 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12767 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12768 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12769 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12770 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12771 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12772 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12773 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12774 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12775 i32 __builtin_mips_extr_w (a64, imm0_31)
12776 i32 __builtin_mips_extr_w (a64, i32)
12777 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12778 i32 __builtin_mips_extr_s_h (a64, i32)
12779 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12780 i32 __builtin_mips_extr_rs_w (a64, i32)
12781 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12782 i32 __builtin_mips_extr_r_w (a64, i32)
12783 i32 __builtin_mips_extp (a64, imm0_31)
12784 i32 __builtin_mips_extp (a64, i32)
12785 i32 __builtin_mips_extpdp (a64, imm0_31)
12786 i32 __builtin_mips_extpdp (a64, i32)
12787 a64 __builtin_mips_shilo (a64, imm_n32_31)
12788 a64 __builtin_mips_shilo (a64, i32)
12789 a64 __builtin_mips_mthlip (a64, i32)
12790 void __builtin_mips_wrdsp (i32, imm0_63)
12791 i32 __builtin_mips_rddsp (imm0_63)
12792 i32 __builtin_mips_lbux (void *, i32)
12793 i32 __builtin_mips_lhx (void *, i32)
12794 i32 __builtin_mips_lwx (void *, i32)
12795 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12796 i32 __builtin_mips_bposge32 (void)
12797 a64 __builtin_mips_madd (a64, i32, i32);
12798 a64 __builtin_mips_maddu (a64, ui32, ui32);
12799 a64 __builtin_mips_msub (a64, i32, i32);
12800 a64 __builtin_mips_msubu (a64, ui32, ui32);
12801 a64 __builtin_mips_mult (i32, i32);
12802 a64 __builtin_mips_multu (ui32, ui32);
12803 @end smallexample
12805 The following built-in functions map directly to a particular MIPS DSP REV 2
12806 instruction.  Please refer to the architecture specification
12807 for details on what each instruction does.
12809 @smallexample
12810 v4q7 __builtin_mips_absq_s_qb (v4q7);
12811 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12812 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12813 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12814 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12815 i32 __builtin_mips_append (i32, i32, imm0_31);
12816 i32 __builtin_mips_balign (i32, i32, imm0_3);
12817 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12818 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12819 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12820 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12821 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12822 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12823 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12824 q31 __builtin_mips_mulq_rs_w (q31, q31);
12825 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12826 q31 __builtin_mips_mulq_s_w (q31, q31);
12827 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12828 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12829 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12830 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12831 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12832 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12833 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12834 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12835 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12836 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12837 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12838 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12839 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12840 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12841 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12842 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12843 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12844 q31 __builtin_mips_addqh_w (q31, q31);
12845 q31 __builtin_mips_addqh_r_w (q31, q31);
12846 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12847 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12848 q31 __builtin_mips_subqh_w (q31, q31);
12849 q31 __builtin_mips_subqh_r_w (q31, q31);
12850 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12851 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12852 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12853 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12854 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12855 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12856 @end smallexample
12859 @node MIPS Paired-Single Support
12860 @subsection MIPS Paired-Single Support
12862 The MIPS64 architecture includes a number of instructions that
12863 operate on pairs of single-precision floating-point values.
12864 Each pair is packed into a 64-bit floating-point register,
12865 with one element being designated the ``upper half'' and
12866 the other being designated the ``lower half''.
12868 GCC supports paired-single operations using both the generic
12869 vector extensions (@pxref{Vector Extensions}) and a collection of
12870 MIPS-specific built-in functions.  Both kinds of support are
12871 enabled by the @option{-mpaired-single} command-line option.
12873 The vector type associated with paired-single values is usually
12874 called @code{v2sf}.  It can be defined in C as follows:
12876 @smallexample
12877 typedef float v2sf __attribute__ ((vector_size (8)));
12878 @end smallexample
12880 @code{v2sf} values are initialized in the same way as aggregates.
12881 For example:
12883 @smallexample
12884 v2sf a = @{1.5, 9.1@};
12885 v2sf b;
12886 float e, f;
12887 b = (v2sf) @{e, f@};
12888 @end smallexample
12890 @emph{Note:} The CPU's endianness determines which value is stored in
12891 the upper half of a register and which value is stored in the lower half.
12892 On little-endian targets, the first value is the lower one and the second
12893 value is the upper one.  The opposite order applies to big-endian targets.
12894 For example, the code above sets the lower half of @code{a} to
12895 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12897 @node MIPS Loongson Built-in Functions
12898 @subsection MIPS Loongson Built-in Functions
12900 GCC provides intrinsics to access the SIMD instructions provided by the
12901 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12902 available after inclusion of the @code{loongson.h} header file,
12903 operate on the following 64-bit vector types:
12905 @itemize
12906 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12907 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12908 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12909 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12910 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12911 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12912 @end itemize
12914 The intrinsics provided are listed below; each is named after the
12915 machine instruction to which it corresponds, with suffixes added as
12916 appropriate to distinguish intrinsics that expand to the same machine
12917 instruction yet have different argument types.  Refer to the architecture
12918 documentation for a description of the functionality of each
12919 instruction.
12921 @smallexample
12922 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12923 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12924 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12925 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12926 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12927 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12928 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12929 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12930 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12931 uint64_t paddd_u (uint64_t s, uint64_t t);
12932 int64_t paddd_s (int64_t s, int64_t t);
12933 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12934 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12935 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12936 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12937 uint64_t pandn_ud (uint64_t s, uint64_t t);
12938 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12939 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12940 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12941 int64_t pandn_sd (int64_t s, int64_t t);
12942 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12943 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12944 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12945 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12946 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12947 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12948 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12949 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12950 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12951 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12952 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12953 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12954 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12955 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12956 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12957 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12958 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12959 uint16x4_t pextrh_u (uint16x4_t s, int field);
12960 int16x4_t pextrh_s (int16x4_t s, int field);
12961 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12962 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12963 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12964 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12965 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12966 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12967 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12968 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12969 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12970 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12971 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12972 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12973 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12974 uint8x8_t pmovmskb_u (uint8x8_t s);
12975 int8x8_t pmovmskb_s (int8x8_t s);
12976 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12977 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12978 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12979 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12980 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12981 uint16x4_t biadd (uint8x8_t s);
12982 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12983 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12984 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12985 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12986 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12987 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12988 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12989 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12990 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12991 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12992 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12993 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12994 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12995 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12996 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12997 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12998 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12999 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13000 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13001 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13002 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13003 uint64_t psubd_u (uint64_t s, uint64_t t);
13004 int64_t psubd_s (int64_t s, int64_t t);
13005 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13006 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13007 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13008 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13009 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13010 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13011 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13012 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13013 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13014 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13015 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13016 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13017 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13018 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13019 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13020 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13021 @end smallexample
13023 @menu
13024 * Paired-Single Arithmetic::
13025 * Paired-Single Built-in Functions::
13026 * MIPS-3D Built-in Functions::
13027 @end menu
13029 @node Paired-Single Arithmetic
13030 @subsubsection Paired-Single Arithmetic
13032 The table below lists the @code{v2sf} operations for which hardware
13033 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13034 values and @code{x} is an integral value.
13036 @multitable @columnfractions .50 .50
13037 @item C code @tab MIPS instruction
13038 @item @code{a + b} @tab @code{add.ps}
13039 @item @code{a - b} @tab @code{sub.ps}
13040 @item @code{-a} @tab @code{neg.ps}
13041 @item @code{a * b} @tab @code{mul.ps}
13042 @item @code{a * b + c} @tab @code{madd.ps}
13043 @item @code{a * b - c} @tab @code{msub.ps}
13044 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13045 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13046 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13047 @end multitable
13049 Note that the multiply-accumulate instructions can be disabled
13050 using the command-line option @code{-mno-fused-madd}.
13052 @node Paired-Single Built-in Functions
13053 @subsubsection Paired-Single Built-in Functions
13055 The following paired-single functions map directly to a particular
13056 MIPS instruction.  Please refer to the architecture specification
13057 for details on what each instruction does.
13059 @table @code
13060 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13061 Pair lower lower (@code{pll.ps}).
13063 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13064 Pair upper lower (@code{pul.ps}).
13066 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13067 Pair lower upper (@code{plu.ps}).
13069 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13070 Pair upper upper (@code{puu.ps}).
13072 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13073 Convert pair to paired single (@code{cvt.ps.s}).
13075 @item float __builtin_mips_cvt_s_pl (v2sf)
13076 Convert pair lower to single (@code{cvt.s.pl}).
13078 @item float __builtin_mips_cvt_s_pu (v2sf)
13079 Convert pair upper to single (@code{cvt.s.pu}).
13081 @item v2sf __builtin_mips_abs_ps (v2sf)
13082 Absolute value (@code{abs.ps}).
13084 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13085 Align variable (@code{alnv.ps}).
13087 @emph{Note:} The value of the third parameter must be 0 or 4
13088 modulo 8, otherwise the result is unpredictable.  Please read the
13089 instruction description for details.
13090 @end table
13092 The following multi-instruction functions are also available.
13093 In each case, @var{cond} can be any of the 16 floating-point conditions:
13094 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13095 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13096 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13098 @table @code
13099 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13100 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13101 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13102 @code{movt.ps}/@code{movf.ps}).
13104 The @code{movt} functions return the value @var{x} computed by:
13106 @smallexample
13107 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13108 mov.ps @var{x},@var{c}
13109 movt.ps @var{x},@var{d},@var{cc}
13110 @end smallexample
13112 The @code{movf} functions are similar but use @code{movf.ps} instead
13113 of @code{movt.ps}.
13115 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13116 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13117 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13118 @code{bc1t}/@code{bc1f}).
13120 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13121 and return either the upper or lower half of the result.  For example:
13123 @smallexample
13124 v2sf a, b;
13125 if (__builtin_mips_upper_c_eq_ps (a, b))
13126   upper_halves_are_equal ();
13127 else
13128   upper_halves_are_unequal ();
13130 if (__builtin_mips_lower_c_eq_ps (a, b))
13131   lower_halves_are_equal ();
13132 else
13133   lower_halves_are_unequal ();
13134 @end smallexample
13135 @end table
13137 @node MIPS-3D Built-in Functions
13138 @subsubsection MIPS-3D Built-in Functions
13140 The MIPS-3D Application-Specific Extension (ASE) includes additional
13141 paired-single instructions that are designed to improve the performance
13142 of 3D graphics operations.  Support for these instructions is controlled
13143 by the @option{-mips3d} command-line option.
13145 The functions listed below map directly to a particular MIPS-3D
13146 instruction.  Please refer to the architecture specification for
13147 more details on what each instruction does.
13149 @table @code
13150 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13151 Reduction add (@code{addr.ps}).
13153 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13154 Reduction multiply (@code{mulr.ps}).
13156 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13157 Convert paired single to paired word (@code{cvt.pw.ps}).
13159 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13160 Convert paired word to paired single (@code{cvt.ps.pw}).
13162 @item float __builtin_mips_recip1_s (float)
13163 @itemx double __builtin_mips_recip1_d (double)
13164 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13165 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13167 @item float __builtin_mips_recip2_s (float, float)
13168 @itemx double __builtin_mips_recip2_d (double, double)
13169 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13170 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13172 @item float __builtin_mips_rsqrt1_s (float)
13173 @itemx double __builtin_mips_rsqrt1_d (double)
13174 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13175 Reduced-precision reciprocal square root (sequence step 1)
13176 (@code{rsqrt1.@var{fmt}}).
13178 @item float __builtin_mips_rsqrt2_s (float, float)
13179 @itemx double __builtin_mips_rsqrt2_d (double, double)
13180 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13181 Reduced-precision reciprocal square root (sequence step 2)
13182 (@code{rsqrt2.@var{fmt}}).
13183 @end table
13185 The following multi-instruction functions are also available.
13186 In each case, @var{cond} can be any of the 16 floating-point conditions:
13187 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13188 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13189 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13191 @table @code
13192 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13193 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13194 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13195 @code{bc1t}/@code{bc1f}).
13197 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13198 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13199 For example:
13201 @smallexample
13202 float a, b;
13203 if (__builtin_mips_cabs_eq_s (a, b))
13204   true ();
13205 else
13206   false ();
13207 @end smallexample
13209 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13210 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13211 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13212 @code{bc1t}/@code{bc1f}).
13214 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13215 and return either the upper or lower half of the result.  For example:
13217 @smallexample
13218 v2sf a, b;
13219 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13220   upper_halves_are_equal ();
13221 else
13222   upper_halves_are_unequal ();
13224 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13225   lower_halves_are_equal ();
13226 else
13227   lower_halves_are_unequal ();
13228 @end smallexample
13230 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13231 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13232 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13233 @code{movt.ps}/@code{movf.ps}).
13235 The @code{movt} functions return the value @var{x} computed by:
13237 @smallexample
13238 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13239 mov.ps @var{x},@var{c}
13240 movt.ps @var{x},@var{d},@var{cc}
13241 @end smallexample
13243 The @code{movf} functions are similar but use @code{movf.ps} instead
13244 of @code{movt.ps}.
13246 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13247 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13248 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13249 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13250 Comparison of two paired-single values
13251 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13252 @code{bc1any2t}/@code{bc1any2f}).
13254 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13255 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13256 result is true and the @code{all} forms return true if both results are true.
13257 For example:
13259 @smallexample
13260 v2sf a, b;
13261 if (__builtin_mips_any_c_eq_ps (a, b))
13262   one_is_true ();
13263 else
13264   both_are_false ();
13266 if (__builtin_mips_all_c_eq_ps (a, b))
13267   both_are_true ();
13268 else
13269   one_is_false ();
13270 @end smallexample
13272 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13273 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13274 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13275 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13276 Comparison of four paired-single values
13277 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13278 @code{bc1any4t}/@code{bc1any4f}).
13280 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13281 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13282 The @code{any} forms return true if any of the four results are true
13283 and the @code{all} forms return true if all four results are true.
13284 For example:
13286 @smallexample
13287 v2sf a, b, c, d;
13288 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13289   some_are_true ();
13290 else
13291   all_are_false ();
13293 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13294   all_are_true ();
13295 else
13296   some_are_false ();
13297 @end smallexample
13298 @end table
13300 @node Other MIPS Built-in Functions
13301 @subsection Other MIPS Built-in Functions
13303 GCC provides other MIPS-specific built-in functions:
13305 @table @code
13306 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13307 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13308 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13309 when this function is available.
13311 @item unsigned int __builtin_mips_get_fcsr (void)
13312 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13313 Get and set the contents of the floating-point control and status register
13314 (FPU control register 31).  These functions are only available in hard-float
13315 code but can be called in both MIPS16 and non-MIPS16 contexts.
13317 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13318 register except the condition codes, which GCC assumes are preserved.
13319 @end table
13321 @node MSP430 Built-in Functions
13322 @subsection MSP430 Built-in Functions
13324 GCC provides a couple of special builtin functions to aid in the
13325 writing of interrupt handlers in C.
13327 @table @code
13328 @item __bic_SR_register_on_exit (int @var{mask})
13329 This clears the indicated bits in the saved copy of the status register
13330 currently residing on the stack.  This only works inside interrupt
13331 handlers and the changes to the status register will only take affect
13332 once the handler returns.
13334 @item __bis_SR_register_on_exit (int @var{mask})
13335 This sets the indicated bits in the saved copy of the status register
13336 currently residing on the stack.  This only works inside interrupt
13337 handlers and the changes to the status register will only take affect
13338 once the handler returns.
13340 @item __delay_cycles (long long @var{cycles})
13341 This inserts an instruction sequence that takes exactly @var{cycles}
13342 cycles (between 0 and about 17E9) to complete.  The inserted sequence
13343 may use jumps, loops, or no-ops, and does not interfere with any other
13344 instructions.  Note that @var{cycles} must be a compile-time constant
13345 integer - that is, you must pass a number, not a variable that may be
13346 optimized to a constant later.  The number of cycles delayed by this
13347 builtin is exact.
13348 @end table
13350 @node NDS32 Built-in Functions
13351 @subsection NDS32 Built-in Functions
13353 These built-in functions are available for the NDS32 target:
13355 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13356 Insert an ISYNC instruction into the instruction stream where
13357 @var{addr} is an instruction address for serialization.
13358 @end deftypefn
13360 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13361 Insert an ISB instruction into the instruction stream.
13362 @end deftypefn
13364 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13365 Return the content of a system register which is mapped by @var{sr}.
13366 @end deftypefn
13368 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13369 Return the content of a user space register which is mapped by @var{usr}.
13370 @end deftypefn
13372 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13373 Move the @var{value} to a system register which is mapped by @var{sr}.
13374 @end deftypefn
13376 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13377 Move the @var{value} to a user space register which is mapped by @var{usr}.
13378 @end deftypefn
13380 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13381 Enable global interrupt.
13382 @end deftypefn
13384 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13385 Disable global interrupt.
13386 @end deftypefn
13388 @node picoChip Built-in Functions
13389 @subsection picoChip Built-in Functions
13391 GCC provides an interface to selected machine instructions from the
13392 picoChip instruction set.
13394 @table @code
13395 @item int __builtin_sbc (int @var{value})
13396 Sign bit count.  Return the number of consecutive bits in @var{value}
13397 that have the same value as the sign bit.  The result is the number of
13398 leading sign bits minus one, giving the number of redundant sign bits in
13399 @var{value}.
13401 @item int __builtin_byteswap (int @var{value})
13402 Byte swap.  Return the result of swapping the upper and lower bytes of
13403 @var{value}.
13405 @item int __builtin_brev (int @var{value})
13406 Bit reversal.  Return the result of reversing the bits in
13407 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13408 and so on.
13410 @item int __builtin_adds (int @var{x}, int @var{y})
13411 Saturating addition.  Return the result of adding @var{x} and @var{y},
13412 storing the value 32767 if the result overflows.
13414 @item int __builtin_subs (int @var{x}, int @var{y})
13415 Saturating subtraction.  Return the result of subtracting @var{y} from
13416 @var{x}, storing the value @minus{}32768 if the result overflows.
13418 @item void __builtin_halt (void)
13419 Halt.  The processor stops execution.  This built-in is useful for
13420 implementing assertions.
13422 @end table
13424 @node PowerPC Built-in Functions
13425 @subsection PowerPC Built-in Functions
13427 These built-in functions are available for the PowerPC family of
13428 processors:
13429 @smallexample
13430 float __builtin_recipdivf (float, float);
13431 float __builtin_rsqrtf (float);
13432 double __builtin_recipdiv (double, double);
13433 double __builtin_rsqrt (double);
13434 uint64_t __builtin_ppc_get_timebase ();
13435 unsigned long __builtin_ppc_mftb ();
13436 double __builtin_unpack_longdouble (long double, int);
13437 long double __builtin_pack_longdouble (double, double);
13438 @end smallexample
13440 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13441 @code{__builtin_rsqrtf} functions generate multiple instructions to
13442 implement the reciprocal sqrt functionality using reciprocal sqrt
13443 estimate instructions.
13445 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13446 functions generate multiple instructions to implement division using
13447 the reciprocal estimate instructions.
13449 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13450 functions generate instructions to read the Time Base Register.  The
13451 @code{__builtin_ppc_get_timebase} function may generate multiple
13452 instructions and always returns the 64 bits of the Time Base Register.
13453 The @code{__builtin_ppc_mftb} function always generates one instruction and
13454 returns the Time Base Register value as an unsigned long, throwing away
13455 the most significant word on 32-bit environments.
13457 The following built-in functions are available for the PowerPC family
13458 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13459 or @option{-mpopcntd}):
13460 @smallexample
13461 long __builtin_bpermd (long, long);
13462 int __builtin_divwe (int, int);
13463 int __builtin_divweo (int, int);
13464 unsigned int __builtin_divweu (unsigned int, unsigned int);
13465 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13466 long __builtin_divde (long, long);
13467 long __builtin_divdeo (long, long);
13468 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13469 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13470 unsigned int cdtbcd (unsigned int);
13471 unsigned int cbcdtd (unsigned int);
13472 unsigned int addg6s (unsigned int, unsigned int);
13473 @end smallexample
13475 The @code{__builtin_divde}, @code{__builtin_divdeo},
13476 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
13477 64-bit environment support ISA 2.06 or later.
13479 The following built-in functions are available for the PowerPC family
13480 of processors when hardware decimal floating point
13481 (@option{-mhard-dfp}) is available:
13482 @smallexample
13483 _Decimal64 __builtin_dxex (_Decimal64);
13484 _Decimal128 __builtin_dxexq (_Decimal128);
13485 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13486 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13487 _Decimal64 __builtin_denbcd (int, _Decimal64);
13488 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13489 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13490 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13491 _Decimal64 __builtin_dscli (_Decimal64, int);
13492 _Decimal128 __builitn_dscliq (_Decimal128, int);
13493 _Decimal64 __builtin_dscri (_Decimal64, int);
13494 _Decimal128 __builitn_dscriq (_Decimal128, int);
13495 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13496 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13497 @end smallexample
13499 The following built-in functions are available for the PowerPC family
13500 of processors when the Vector Scalar (vsx) instruction set is
13501 available:
13502 @smallexample
13503 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13504 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13505                                                 unsigned long long);
13506 @end smallexample
13508 @node PowerPC AltiVec/VSX Built-in Functions
13509 @subsection PowerPC AltiVec Built-in Functions
13511 GCC provides an interface for the PowerPC family of processors to access
13512 the AltiVec operations described in Motorola's AltiVec Programming
13513 Interface Manual.  The interface is made available by including
13514 @code{<altivec.h>} and using @option{-maltivec} and
13515 @option{-mabi=altivec}.  The interface supports the following vector
13516 types.
13518 @smallexample
13519 vector unsigned char
13520 vector signed char
13521 vector bool char
13523 vector unsigned short
13524 vector signed short
13525 vector bool short
13526 vector pixel
13528 vector unsigned int
13529 vector signed int
13530 vector bool int
13531 vector float
13532 @end smallexample
13534 If @option{-mvsx} is used the following additional vector types are
13535 implemented.
13537 @smallexample
13538 vector unsigned long
13539 vector signed long
13540 vector double
13541 @end smallexample
13543 The long types are only implemented for 64-bit code generation, and
13544 the long type is only used in the floating point/integer conversion
13545 instructions.
13547 GCC's implementation of the high-level language interface available from
13548 C and C++ code differs from Motorola's documentation in several ways.
13550 @itemize @bullet
13552 @item
13553 A vector constant is a list of constant expressions within curly braces.
13555 @item
13556 A vector initializer requires no cast if the vector constant is of the
13557 same type as the variable it is initializing.
13559 @item
13560 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13561 vector type is the default signedness of the base type.  The default
13562 varies depending on the operating system, so a portable program should
13563 always specify the signedness.
13565 @item
13566 Compiling with @option{-maltivec} adds keywords @code{__vector},
13567 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13568 @code{bool}.  When compiling ISO C, the context-sensitive substitution
13569 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13570 disabled.  To use them, you must include @code{<altivec.h>} instead.
13572 @item
13573 GCC allows using a @code{typedef} name as the type specifier for a
13574 vector type.
13576 @item
13577 For C, overloaded functions are implemented with macros so the following
13578 does not work:
13580 @smallexample
13581   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13582 @end smallexample
13584 @noindent
13585 Since @code{vec_add} is a macro, the vector constant in the example
13586 is treated as four separate arguments.  Wrap the entire argument in
13587 parentheses for this to work.
13588 @end itemize
13590 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13591 Internally, GCC uses built-in functions to achieve the functionality in
13592 the aforementioned header file, but they are not supported and are
13593 subject to change without notice.
13595 The following interfaces are supported for the generic and specific
13596 AltiVec operations and the AltiVec predicates.  In cases where there
13597 is a direct mapping between generic and specific operations, only the
13598 generic names are shown here, although the specific operations can also
13599 be used.
13601 Arguments that are documented as @code{const int} require literal
13602 integral values within the range required for that operation.
13604 @smallexample
13605 vector signed char vec_abs (vector signed char);
13606 vector signed short vec_abs (vector signed short);
13607 vector signed int vec_abs (vector signed int);
13608 vector float vec_abs (vector float);
13610 vector signed char vec_abss (vector signed char);
13611 vector signed short vec_abss (vector signed short);
13612 vector signed int vec_abss (vector signed int);
13614 vector signed char vec_add (vector bool char, vector signed char);
13615 vector signed char vec_add (vector signed char, vector bool char);
13616 vector signed char vec_add (vector signed char, vector signed char);
13617 vector unsigned char vec_add (vector bool char, vector unsigned char);
13618 vector unsigned char vec_add (vector unsigned char, vector bool char);
13619 vector unsigned char vec_add (vector unsigned char,
13620                               vector unsigned char);
13621 vector signed short vec_add (vector bool short, vector signed short);
13622 vector signed short vec_add (vector signed short, vector bool short);
13623 vector signed short vec_add (vector signed short, vector signed short);
13624 vector unsigned short vec_add (vector bool short,
13625                                vector unsigned short);
13626 vector unsigned short vec_add (vector unsigned short,
13627                                vector bool short);
13628 vector unsigned short vec_add (vector unsigned short,
13629                                vector unsigned short);
13630 vector signed int vec_add (vector bool int, vector signed int);
13631 vector signed int vec_add (vector signed int, vector bool int);
13632 vector signed int vec_add (vector signed int, vector signed int);
13633 vector unsigned int vec_add (vector bool int, vector unsigned int);
13634 vector unsigned int vec_add (vector unsigned int, vector bool int);
13635 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13636 vector float vec_add (vector float, vector float);
13638 vector float vec_vaddfp (vector float, vector float);
13640 vector signed int vec_vadduwm (vector bool int, vector signed int);
13641 vector signed int vec_vadduwm (vector signed int, vector bool int);
13642 vector signed int vec_vadduwm (vector signed int, vector signed int);
13643 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13644 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13645 vector unsigned int vec_vadduwm (vector unsigned int,
13646                                  vector unsigned int);
13648 vector signed short vec_vadduhm (vector bool short,
13649                                  vector signed short);
13650 vector signed short vec_vadduhm (vector signed short,
13651                                  vector bool short);
13652 vector signed short vec_vadduhm (vector signed short,
13653                                  vector signed short);
13654 vector unsigned short vec_vadduhm (vector bool short,
13655                                    vector unsigned short);
13656 vector unsigned short vec_vadduhm (vector unsigned short,
13657                                    vector bool short);
13658 vector unsigned short vec_vadduhm (vector unsigned short,
13659                                    vector unsigned short);
13661 vector signed char vec_vaddubm (vector bool char, vector signed char);
13662 vector signed char vec_vaddubm (vector signed char, vector bool char);
13663 vector signed char vec_vaddubm (vector signed char, vector signed char);
13664 vector unsigned char vec_vaddubm (vector bool char,
13665                                   vector unsigned char);
13666 vector unsigned char vec_vaddubm (vector unsigned char,
13667                                   vector bool char);
13668 vector unsigned char vec_vaddubm (vector unsigned char,
13669                                   vector unsigned char);
13671 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13673 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13674 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13675 vector unsigned char vec_adds (vector unsigned char,
13676                                vector unsigned char);
13677 vector signed char vec_adds (vector bool char, vector signed char);
13678 vector signed char vec_adds (vector signed char, vector bool char);
13679 vector signed char vec_adds (vector signed char, vector signed char);
13680 vector unsigned short vec_adds (vector bool short,
13681                                 vector unsigned short);
13682 vector unsigned short vec_adds (vector unsigned short,
13683                                 vector bool short);
13684 vector unsigned short vec_adds (vector unsigned short,
13685                                 vector unsigned short);
13686 vector signed short vec_adds (vector bool short, vector signed short);
13687 vector signed short vec_adds (vector signed short, vector bool short);
13688 vector signed short vec_adds (vector signed short, vector signed short);
13689 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13690 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13691 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13692 vector signed int vec_adds (vector bool int, vector signed int);
13693 vector signed int vec_adds (vector signed int, vector bool int);
13694 vector signed int vec_adds (vector signed int, vector signed int);
13696 vector signed int vec_vaddsws (vector bool int, vector signed int);
13697 vector signed int vec_vaddsws (vector signed int, vector bool int);
13698 vector signed int vec_vaddsws (vector signed int, vector signed int);
13700 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13701 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13702 vector unsigned int vec_vadduws (vector unsigned int,
13703                                  vector unsigned int);
13705 vector signed short vec_vaddshs (vector bool short,
13706                                  vector signed short);
13707 vector signed short vec_vaddshs (vector signed short,
13708                                  vector bool short);
13709 vector signed short vec_vaddshs (vector signed short,
13710                                  vector signed short);
13712 vector unsigned short vec_vadduhs (vector bool short,
13713                                    vector unsigned short);
13714 vector unsigned short vec_vadduhs (vector unsigned short,
13715                                    vector bool short);
13716 vector unsigned short vec_vadduhs (vector unsigned short,
13717                                    vector unsigned short);
13719 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13720 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13721 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13723 vector unsigned char vec_vaddubs (vector bool char,
13724                                   vector unsigned char);
13725 vector unsigned char vec_vaddubs (vector unsigned char,
13726                                   vector bool char);
13727 vector unsigned char vec_vaddubs (vector unsigned char,
13728                                   vector unsigned char);
13730 vector float vec_and (vector float, vector float);
13731 vector float vec_and (vector float, vector bool int);
13732 vector float vec_and (vector bool int, vector float);
13733 vector bool int vec_and (vector bool int, vector bool int);
13734 vector signed int vec_and (vector bool int, vector signed int);
13735 vector signed int vec_and (vector signed int, vector bool int);
13736 vector signed int vec_and (vector signed int, vector signed int);
13737 vector unsigned int vec_and (vector bool int, vector unsigned int);
13738 vector unsigned int vec_and (vector unsigned int, vector bool int);
13739 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13740 vector bool short vec_and (vector bool short, vector bool short);
13741 vector signed short vec_and (vector bool short, vector signed short);
13742 vector signed short vec_and (vector signed short, vector bool short);
13743 vector signed short vec_and (vector signed short, vector signed short);
13744 vector unsigned short vec_and (vector bool short,
13745                                vector unsigned short);
13746 vector unsigned short vec_and (vector unsigned short,
13747                                vector bool short);
13748 vector unsigned short vec_and (vector unsigned short,
13749                                vector unsigned short);
13750 vector signed char vec_and (vector bool char, vector signed char);
13751 vector bool char vec_and (vector bool char, vector bool char);
13752 vector signed char vec_and (vector signed char, vector bool char);
13753 vector signed char vec_and (vector signed char, vector signed char);
13754 vector unsigned char vec_and (vector bool char, vector unsigned char);
13755 vector unsigned char vec_and (vector unsigned char, vector bool char);
13756 vector unsigned char vec_and (vector unsigned char,
13757                               vector unsigned char);
13759 vector float vec_andc (vector float, vector float);
13760 vector float vec_andc (vector float, vector bool int);
13761 vector float vec_andc (vector bool int, vector float);
13762 vector bool int vec_andc (vector bool int, vector bool int);
13763 vector signed int vec_andc (vector bool int, vector signed int);
13764 vector signed int vec_andc (vector signed int, vector bool int);
13765 vector signed int vec_andc (vector signed int, vector signed int);
13766 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13767 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13768 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13769 vector bool short vec_andc (vector bool short, vector bool short);
13770 vector signed short vec_andc (vector bool short, vector signed short);
13771 vector signed short vec_andc (vector signed short, vector bool short);
13772 vector signed short vec_andc (vector signed short, vector signed short);
13773 vector unsigned short vec_andc (vector bool short,
13774                                 vector unsigned short);
13775 vector unsigned short vec_andc (vector unsigned short,
13776                                 vector bool short);
13777 vector unsigned short vec_andc (vector unsigned short,
13778                                 vector unsigned short);
13779 vector signed char vec_andc (vector bool char, vector signed char);
13780 vector bool char vec_andc (vector bool char, vector bool char);
13781 vector signed char vec_andc (vector signed char, vector bool char);
13782 vector signed char vec_andc (vector signed char, vector signed char);
13783 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13784 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13785 vector unsigned char vec_andc (vector unsigned char,
13786                                vector unsigned char);
13788 vector unsigned char vec_avg (vector unsigned char,
13789                               vector unsigned char);
13790 vector signed char vec_avg (vector signed char, vector signed char);
13791 vector unsigned short vec_avg (vector unsigned short,
13792                                vector unsigned short);
13793 vector signed short vec_avg (vector signed short, vector signed short);
13794 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13795 vector signed int vec_avg (vector signed int, vector signed int);
13797 vector signed int vec_vavgsw (vector signed int, vector signed int);
13799 vector unsigned int vec_vavguw (vector unsigned int,
13800                                 vector unsigned int);
13802 vector signed short vec_vavgsh (vector signed short,
13803                                 vector signed short);
13805 vector unsigned short vec_vavguh (vector unsigned short,
13806                                   vector unsigned short);
13808 vector signed char vec_vavgsb (vector signed char, vector signed char);
13810 vector unsigned char vec_vavgub (vector unsigned char,
13811                                  vector unsigned char);
13813 vector float vec_copysign (vector float);
13815 vector float vec_ceil (vector float);
13817 vector signed int vec_cmpb (vector float, vector float);
13819 vector bool char vec_cmpeq (vector signed char, vector signed char);
13820 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13821 vector bool short vec_cmpeq (vector signed short, vector signed short);
13822 vector bool short vec_cmpeq (vector unsigned short,
13823                              vector unsigned short);
13824 vector bool int vec_cmpeq (vector signed int, vector signed int);
13825 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13826 vector bool int vec_cmpeq (vector float, vector float);
13828 vector bool int vec_vcmpeqfp (vector float, vector float);
13830 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13831 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13833 vector bool short vec_vcmpequh (vector signed short,
13834                                 vector signed short);
13835 vector bool short vec_vcmpequh (vector unsigned short,
13836                                 vector unsigned short);
13838 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13839 vector bool char vec_vcmpequb (vector unsigned char,
13840                                vector unsigned char);
13842 vector bool int vec_cmpge (vector float, vector float);
13844 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13845 vector bool char vec_cmpgt (vector signed char, vector signed char);
13846 vector bool short vec_cmpgt (vector unsigned short,
13847                              vector unsigned short);
13848 vector bool short vec_cmpgt (vector signed short, vector signed short);
13849 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13850 vector bool int vec_cmpgt (vector signed int, vector signed int);
13851 vector bool int vec_cmpgt (vector float, vector float);
13853 vector bool int vec_vcmpgtfp (vector float, vector float);
13855 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13857 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13859 vector bool short vec_vcmpgtsh (vector signed short,
13860                                 vector signed short);
13862 vector bool short vec_vcmpgtuh (vector unsigned short,
13863                                 vector unsigned short);
13865 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13867 vector bool char vec_vcmpgtub (vector unsigned char,
13868                                vector unsigned char);
13870 vector bool int vec_cmple (vector float, vector float);
13872 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13873 vector bool char vec_cmplt (vector signed char, vector signed char);
13874 vector bool short vec_cmplt (vector unsigned short,
13875                              vector unsigned short);
13876 vector bool short vec_cmplt (vector signed short, vector signed short);
13877 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13878 vector bool int vec_cmplt (vector signed int, vector signed int);
13879 vector bool int vec_cmplt (vector float, vector float);
13881 vector float vec_cpsgn (vector float, vector float);
13883 vector float vec_ctf (vector unsigned int, const int);
13884 vector float vec_ctf (vector signed int, const int);
13885 vector double vec_ctf (vector unsigned long, const int);
13886 vector double vec_ctf (vector signed long, const int);
13888 vector float vec_vcfsx (vector signed int, const int);
13890 vector float vec_vcfux (vector unsigned int, const int);
13892 vector signed int vec_cts (vector float, const int);
13893 vector signed long vec_cts (vector double, const int);
13895 vector unsigned int vec_ctu (vector float, const int);
13896 vector unsigned long vec_ctu (vector double, const int);
13898 void vec_dss (const int);
13900 void vec_dssall (void);
13902 void vec_dst (const vector unsigned char *, int, const int);
13903 void vec_dst (const vector signed char *, int, const int);
13904 void vec_dst (const vector bool char *, int, const int);
13905 void vec_dst (const vector unsigned short *, int, const int);
13906 void vec_dst (const vector signed short *, int, const int);
13907 void vec_dst (const vector bool short *, int, const int);
13908 void vec_dst (const vector pixel *, int, const int);
13909 void vec_dst (const vector unsigned int *, int, const int);
13910 void vec_dst (const vector signed int *, int, const int);
13911 void vec_dst (const vector bool int *, int, const int);
13912 void vec_dst (const vector float *, int, const int);
13913 void vec_dst (const unsigned char *, int, const int);
13914 void vec_dst (const signed char *, int, const int);
13915 void vec_dst (const unsigned short *, int, const int);
13916 void vec_dst (const short *, int, const int);
13917 void vec_dst (const unsigned int *, int, const int);
13918 void vec_dst (const int *, int, const int);
13919 void vec_dst (const unsigned long *, int, const int);
13920 void vec_dst (const long *, int, const int);
13921 void vec_dst (const float *, int, const int);
13923 void vec_dstst (const vector unsigned char *, int, const int);
13924 void vec_dstst (const vector signed char *, int, const int);
13925 void vec_dstst (const vector bool char *, int, const int);
13926 void vec_dstst (const vector unsigned short *, int, const int);
13927 void vec_dstst (const vector signed short *, int, const int);
13928 void vec_dstst (const vector bool short *, int, const int);
13929 void vec_dstst (const vector pixel *, int, const int);
13930 void vec_dstst (const vector unsigned int *, int, const int);
13931 void vec_dstst (const vector signed int *, int, const int);
13932 void vec_dstst (const vector bool int *, int, const int);
13933 void vec_dstst (const vector float *, int, const int);
13934 void vec_dstst (const unsigned char *, int, const int);
13935 void vec_dstst (const signed char *, int, const int);
13936 void vec_dstst (const unsigned short *, int, const int);
13937 void vec_dstst (const short *, int, const int);
13938 void vec_dstst (const unsigned int *, int, const int);
13939 void vec_dstst (const int *, int, const int);
13940 void vec_dstst (const unsigned long *, int, const int);
13941 void vec_dstst (const long *, int, const int);
13942 void vec_dstst (const float *, int, const int);
13944 void vec_dststt (const vector unsigned char *, int, const int);
13945 void vec_dststt (const vector signed char *, int, const int);
13946 void vec_dststt (const vector bool char *, int, const int);
13947 void vec_dststt (const vector unsigned short *, int, const int);
13948 void vec_dststt (const vector signed short *, int, const int);
13949 void vec_dststt (const vector bool short *, int, const int);
13950 void vec_dststt (const vector pixel *, int, const int);
13951 void vec_dststt (const vector unsigned int *, int, const int);
13952 void vec_dststt (const vector signed int *, int, const int);
13953 void vec_dststt (const vector bool int *, int, const int);
13954 void vec_dststt (const vector float *, int, const int);
13955 void vec_dststt (const unsigned char *, int, const int);
13956 void vec_dststt (const signed char *, int, const int);
13957 void vec_dststt (const unsigned short *, int, const int);
13958 void vec_dststt (const short *, int, const int);
13959 void vec_dststt (const unsigned int *, int, const int);
13960 void vec_dststt (const int *, int, const int);
13961 void vec_dststt (const unsigned long *, int, const int);
13962 void vec_dststt (const long *, int, const int);
13963 void vec_dststt (const float *, int, const int);
13965 void vec_dstt (const vector unsigned char *, int, const int);
13966 void vec_dstt (const vector signed char *, int, const int);
13967 void vec_dstt (const vector bool char *, int, const int);
13968 void vec_dstt (const vector unsigned short *, int, const int);
13969 void vec_dstt (const vector signed short *, int, const int);
13970 void vec_dstt (const vector bool short *, int, const int);
13971 void vec_dstt (const vector pixel *, int, const int);
13972 void vec_dstt (const vector unsigned int *, int, const int);
13973 void vec_dstt (const vector signed int *, int, const int);
13974 void vec_dstt (const vector bool int *, int, const int);
13975 void vec_dstt (const vector float *, int, const int);
13976 void vec_dstt (const unsigned char *, int, const int);
13977 void vec_dstt (const signed char *, int, const int);
13978 void vec_dstt (const unsigned short *, int, const int);
13979 void vec_dstt (const short *, int, const int);
13980 void vec_dstt (const unsigned int *, int, const int);
13981 void vec_dstt (const int *, int, const int);
13982 void vec_dstt (const unsigned long *, int, const int);
13983 void vec_dstt (const long *, int, const int);
13984 void vec_dstt (const float *, int, const int);
13986 vector float vec_expte (vector float);
13988 vector float vec_floor (vector float);
13990 vector float vec_ld (int, const vector float *);
13991 vector float vec_ld (int, const float *);
13992 vector bool int vec_ld (int, const vector bool int *);
13993 vector signed int vec_ld (int, const vector signed int *);
13994 vector signed int vec_ld (int, const int *);
13995 vector signed int vec_ld (int, const long *);
13996 vector unsigned int vec_ld (int, const vector unsigned int *);
13997 vector unsigned int vec_ld (int, const unsigned int *);
13998 vector unsigned int vec_ld (int, const unsigned long *);
13999 vector bool short vec_ld (int, const vector bool short *);
14000 vector pixel vec_ld (int, const vector pixel *);
14001 vector signed short vec_ld (int, const vector signed short *);
14002 vector signed short vec_ld (int, const short *);
14003 vector unsigned short vec_ld (int, const vector unsigned short *);
14004 vector unsigned short vec_ld (int, const unsigned short *);
14005 vector bool char vec_ld (int, const vector bool char *);
14006 vector signed char vec_ld (int, const vector signed char *);
14007 vector signed char vec_ld (int, const signed char *);
14008 vector unsigned char vec_ld (int, const vector unsigned char *);
14009 vector unsigned char vec_ld (int, const unsigned char *);
14011 vector signed char vec_lde (int, const signed char *);
14012 vector unsigned char vec_lde (int, const unsigned char *);
14013 vector signed short vec_lde (int, const short *);
14014 vector unsigned short vec_lde (int, const unsigned short *);
14015 vector float vec_lde (int, const float *);
14016 vector signed int vec_lde (int, const int *);
14017 vector unsigned int vec_lde (int, const unsigned int *);
14018 vector signed int vec_lde (int, const long *);
14019 vector unsigned int vec_lde (int, const unsigned long *);
14021 vector float vec_lvewx (int, float *);
14022 vector signed int vec_lvewx (int, int *);
14023 vector unsigned int vec_lvewx (int, unsigned int *);
14024 vector signed int vec_lvewx (int, long *);
14025 vector unsigned int vec_lvewx (int, unsigned long *);
14027 vector signed short vec_lvehx (int, short *);
14028 vector unsigned short vec_lvehx (int, unsigned short *);
14030 vector signed char vec_lvebx (int, char *);
14031 vector unsigned char vec_lvebx (int, unsigned char *);
14033 vector float vec_ldl (int, const vector float *);
14034 vector float vec_ldl (int, const float *);
14035 vector bool int vec_ldl (int, const vector bool int *);
14036 vector signed int vec_ldl (int, const vector signed int *);
14037 vector signed int vec_ldl (int, const int *);
14038 vector signed int vec_ldl (int, const long *);
14039 vector unsigned int vec_ldl (int, const vector unsigned int *);
14040 vector unsigned int vec_ldl (int, const unsigned int *);
14041 vector unsigned int vec_ldl (int, const unsigned long *);
14042 vector bool short vec_ldl (int, const vector bool short *);
14043 vector pixel vec_ldl (int, const vector pixel *);
14044 vector signed short vec_ldl (int, const vector signed short *);
14045 vector signed short vec_ldl (int, const short *);
14046 vector unsigned short vec_ldl (int, const vector unsigned short *);
14047 vector unsigned short vec_ldl (int, const unsigned short *);
14048 vector bool char vec_ldl (int, const vector bool char *);
14049 vector signed char vec_ldl (int, const vector signed char *);
14050 vector signed char vec_ldl (int, const signed char *);
14051 vector unsigned char vec_ldl (int, const vector unsigned char *);
14052 vector unsigned char vec_ldl (int, const unsigned char *);
14054 vector float vec_loge (vector float);
14056 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14057 vector unsigned char vec_lvsl (int, const volatile signed char *);
14058 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14059 vector unsigned char vec_lvsl (int, const volatile short *);
14060 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14061 vector unsigned char vec_lvsl (int, const volatile int *);
14062 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14063 vector unsigned char vec_lvsl (int, const volatile long *);
14064 vector unsigned char vec_lvsl (int, const volatile float *);
14066 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14067 vector unsigned char vec_lvsr (int, const volatile signed char *);
14068 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14069 vector unsigned char vec_lvsr (int, const volatile short *);
14070 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14071 vector unsigned char vec_lvsr (int, const volatile int *);
14072 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14073 vector unsigned char vec_lvsr (int, const volatile long *);
14074 vector unsigned char vec_lvsr (int, const volatile float *);
14076 vector float vec_madd (vector float, vector float, vector float);
14078 vector signed short vec_madds (vector signed short,
14079                                vector signed short,
14080                                vector signed short);
14082 vector unsigned char vec_max (vector bool char, vector unsigned char);
14083 vector unsigned char vec_max (vector unsigned char, vector bool char);
14084 vector unsigned char vec_max (vector unsigned char,
14085                               vector unsigned char);
14086 vector signed char vec_max (vector bool char, vector signed char);
14087 vector signed char vec_max (vector signed char, vector bool char);
14088 vector signed char vec_max (vector signed char, vector signed char);
14089 vector unsigned short vec_max (vector bool short,
14090                                vector unsigned short);
14091 vector unsigned short vec_max (vector unsigned short,
14092                                vector bool short);
14093 vector unsigned short vec_max (vector unsigned short,
14094                                vector unsigned short);
14095 vector signed short vec_max (vector bool short, vector signed short);
14096 vector signed short vec_max (vector signed short, vector bool short);
14097 vector signed short vec_max (vector signed short, vector signed short);
14098 vector unsigned int vec_max (vector bool int, vector unsigned int);
14099 vector unsigned int vec_max (vector unsigned int, vector bool int);
14100 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14101 vector signed int vec_max (vector bool int, vector signed int);
14102 vector signed int vec_max (vector signed int, vector bool int);
14103 vector signed int vec_max (vector signed int, vector signed int);
14104 vector float vec_max (vector float, vector float);
14106 vector float vec_vmaxfp (vector float, vector float);
14108 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14109 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14110 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14112 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14113 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14114 vector unsigned int vec_vmaxuw (vector unsigned int,
14115                                 vector unsigned int);
14117 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14118 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14119 vector signed short vec_vmaxsh (vector signed short,
14120                                 vector signed short);
14122 vector unsigned short vec_vmaxuh (vector bool short,
14123                                   vector unsigned short);
14124 vector unsigned short vec_vmaxuh (vector unsigned short,
14125                                   vector bool short);
14126 vector unsigned short vec_vmaxuh (vector unsigned short,
14127                                   vector unsigned short);
14129 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14130 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14131 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14133 vector unsigned char vec_vmaxub (vector bool char,
14134                                  vector unsigned char);
14135 vector unsigned char vec_vmaxub (vector unsigned char,
14136                                  vector bool char);
14137 vector unsigned char vec_vmaxub (vector unsigned char,
14138                                  vector unsigned char);
14140 vector bool char vec_mergeh (vector bool char, vector bool char);
14141 vector signed char vec_mergeh (vector signed char, vector signed char);
14142 vector unsigned char vec_mergeh (vector unsigned char,
14143                                  vector unsigned char);
14144 vector bool short vec_mergeh (vector bool short, vector bool short);
14145 vector pixel vec_mergeh (vector pixel, vector pixel);
14146 vector signed short vec_mergeh (vector signed short,
14147                                 vector signed short);
14148 vector unsigned short vec_mergeh (vector unsigned short,
14149                                   vector unsigned short);
14150 vector float vec_mergeh (vector float, vector float);
14151 vector bool int vec_mergeh (vector bool int, vector bool int);
14152 vector signed int vec_mergeh (vector signed int, vector signed int);
14153 vector unsigned int vec_mergeh (vector unsigned int,
14154                                 vector unsigned int);
14156 vector float vec_vmrghw (vector float, vector float);
14157 vector bool int vec_vmrghw (vector bool int, vector bool int);
14158 vector signed int vec_vmrghw (vector signed int, vector signed int);
14159 vector unsigned int vec_vmrghw (vector unsigned int,
14160                                 vector unsigned int);
14162 vector bool short vec_vmrghh (vector bool short, vector bool short);
14163 vector signed short vec_vmrghh (vector signed short,
14164                                 vector signed short);
14165 vector unsigned short vec_vmrghh (vector unsigned short,
14166                                   vector unsigned short);
14167 vector pixel vec_vmrghh (vector pixel, vector pixel);
14169 vector bool char vec_vmrghb (vector bool char, vector bool char);
14170 vector signed char vec_vmrghb (vector signed char, vector signed char);
14171 vector unsigned char vec_vmrghb (vector unsigned char,
14172                                  vector unsigned char);
14174 vector bool char vec_mergel (vector bool char, vector bool char);
14175 vector signed char vec_mergel (vector signed char, vector signed char);
14176 vector unsigned char vec_mergel (vector unsigned char,
14177                                  vector unsigned char);
14178 vector bool short vec_mergel (vector bool short, vector bool short);
14179 vector pixel vec_mergel (vector pixel, vector pixel);
14180 vector signed short vec_mergel (vector signed short,
14181                                 vector signed short);
14182 vector unsigned short vec_mergel (vector unsigned short,
14183                                   vector unsigned short);
14184 vector float vec_mergel (vector float, vector float);
14185 vector bool int vec_mergel (vector bool int, vector bool int);
14186 vector signed int vec_mergel (vector signed int, vector signed int);
14187 vector unsigned int vec_mergel (vector unsigned int,
14188                                 vector unsigned int);
14190 vector float vec_vmrglw (vector float, vector float);
14191 vector signed int vec_vmrglw (vector signed int, vector signed int);
14192 vector unsigned int vec_vmrglw (vector unsigned int,
14193                                 vector unsigned int);
14194 vector bool int vec_vmrglw (vector bool int, vector bool int);
14196 vector bool short vec_vmrglh (vector bool short, vector bool short);
14197 vector signed short vec_vmrglh (vector signed short,
14198                                 vector signed short);
14199 vector unsigned short vec_vmrglh (vector unsigned short,
14200                                   vector unsigned short);
14201 vector pixel vec_vmrglh (vector pixel, vector pixel);
14203 vector bool char vec_vmrglb (vector bool char, vector bool char);
14204 vector signed char vec_vmrglb (vector signed char, vector signed char);
14205 vector unsigned char vec_vmrglb (vector unsigned char,
14206                                  vector unsigned char);
14208 vector unsigned short vec_mfvscr (void);
14210 vector unsigned char vec_min (vector bool char, vector unsigned char);
14211 vector unsigned char vec_min (vector unsigned char, vector bool char);
14212 vector unsigned char vec_min (vector unsigned char,
14213                               vector unsigned char);
14214 vector signed char vec_min (vector bool char, vector signed char);
14215 vector signed char vec_min (vector signed char, vector bool char);
14216 vector signed char vec_min (vector signed char, vector signed char);
14217 vector unsigned short vec_min (vector bool short,
14218                                vector unsigned short);
14219 vector unsigned short vec_min (vector unsigned short,
14220                                vector bool short);
14221 vector unsigned short vec_min (vector unsigned short,
14222                                vector unsigned short);
14223 vector signed short vec_min (vector bool short, vector signed short);
14224 vector signed short vec_min (vector signed short, vector bool short);
14225 vector signed short vec_min (vector signed short, vector signed short);
14226 vector unsigned int vec_min (vector bool int, vector unsigned int);
14227 vector unsigned int vec_min (vector unsigned int, vector bool int);
14228 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14229 vector signed int vec_min (vector bool int, vector signed int);
14230 vector signed int vec_min (vector signed int, vector bool int);
14231 vector signed int vec_min (vector signed int, vector signed int);
14232 vector float vec_min (vector float, vector float);
14234 vector float vec_vminfp (vector float, vector float);
14236 vector signed int vec_vminsw (vector bool int, vector signed int);
14237 vector signed int vec_vminsw (vector signed int, vector bool int);
14238 vector signed int vec_vminsw (vector signed int, vector signed int);
14240 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14241 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14242 vector unsigned int vec_vminuw (vector unsigned int,
14243                                 vector unsigned int);
14245 vector signed short vec_vminsh (vector bool short, vector signed short);
14246 vector signed short vec_vminsh (vector signed short, vector bool short);
14247 vector signed short vec_vminsh (vector signed short,
14248                                 vector signed short);
14250 vector unsigned short vec_vminuh (vector bool short,
14251                                   vector unsigned short);
14252 vector unsigned short vec_vminuh (vector unsigned short,
14253                                   vector bool short);
14254 vector unsigned short vec_vminuh (vector unsigned short,
14255                                   vector unsigned short);
14257 vector signed char vec_vminsb (vector bool char, vector signed char);
14258 vector signed char vec_vminsb (vector signed char, vector bool char);
14259 vector signed char vec_vminsb (vector signed char, vector signed char);
14261 vector unsigned char vec_vminub (vector bool char,
14262                                  vector unsigned char);
14263 vector unsigned char vec_vminub (vector unsigned char,
14264                                  vector bool char);
14265 vector unsigned char vec_vminub (vector unsigned char,
14266                                  vector unsigned char);
14268 vector signed short vec_mladd (vector signed short,
14269                                vector signed short,
14270                                vector signed short);
14271 vector signed short vec_mladd (vector signed short,
14272                                vector unsigned short,
14273                                vector unsigned short);
14274 vector signed short vec_mladd (vector unsigned short,
14275                                vector signed short,
14276                                vector signed short);
14277 vector unsigned short vec_mladd (vector unsigned short,
14278                                  vector unsigned short,
14279                                  vector unsigned short);
14281 vector signed short vec_mradds (vector signed short,
14282                                 vector signed short,
14283                                 vector signed short);
14285 vector unsigned int vec_msum (vector unsigned char,
14286                               vector unsigned char,
14287                               vector unsigned int);
14288 vector signed int vec_msum (vector signed char,
14289                             vector unsigned char,
14290                             vector signed int);
14291 vector unsigned int vec_msum (vector unsigned short,
14292                               vector unsigned short,
14293                               vector unsigned int);
14294 vector signed int vec_msum (vector signed short,
14295                             vector signed short,
14296                             vector signed int);
14298 vector signed int vec_vmsumshm (vector signed short,
14299                                 vector signed short,
14300                                 vector signed int);
14302 vector unsigned int vec_vmsumuhm (vector unsigned short,
14303                                   vector unsigned short,
14304                                   vector unsigned int);
14306 vector signed int vec_vmsummbm (vector signed char,
14307                                 vector unsigned char,
14308                                 vector signed int);
14310 vector unsigned int vec_vmsumubm (vector unsigned char,
14311                                   vector unsigned char,
14312                                   vector unsigned int);
14314 vector unsigned int vec_msums (vector unsigned short,
14315                                vector unsigned short,
14316                                vector unsigned int);
14317 vector signed int vec_msums (vector signed short,
14318                              vector signed short,
14319                              vector signed int);
14321 vector signed int vec_vmsumshs (vector signed short,
14322                                 vector signed short,
14323                                 vector signed int);
14325 vector unsigned int vec_vmsumuhs (vector unsigned short,
14326                                   vector unsigned short,
14327                                   vector unsigned int);
14329 void vec_mtvscr (vector signed int);
14330 void vec_mtvscr (vector unsigned int);
14331 void vec_mtvscr (vector bool int);
14332 void vec_mtvscr (vector signed short);
14333 void vec_mtvscr (vector unsigned short);
14334 void vec_mtvscr (vector bool short);
14335 void vec_mtvscr (vector pixel);
14336 void vec_mtvscr (vector signed char);
14337 void vec_mtvscr (vector unsigned char);
14338 void vec_mtvscr (vector bool char);
14340 vector unsigned short vec_mule (vector unsigned char,
14341                                 vector unsigned char);
14342 vector signed short vec_mule (vector signed char,
14343                               vector signed char);
14344 vector unsigned int vec_mule (vector unsigned short,
14345                               vector unsigned short);
14346 vector signed int vec_mule (vector signed short, vector signed short);
14348 vector signed int vec_vmulesh (vector signed short,
14349                                vector signed short);
14351 vector unsigned int vec_vmuleuh (vector unsigned short,
14352                                  vector unsigned short);
14354 vector signed short vec_vmulesb (vector signed char,
14355                                  vector signed char);
14357 vector unsigned short vec_vmuleub (vector unsigned char,
14358                                   vector unsigned char);
14360 vector unsigned short vec_mulo (vector unsigned char,
14361                                 vector unsigned char);
14362 vector signed short vec_mulo (vector signed char, vector signed char);
14363 vector unsigned int vec_mulo (vector unsigned short,
14364                               vector unsigned short);
14365 vector signed int vec_mulo (vector signed short, vector signed short);
14367 vector signed int vec_vmulosh (vector signed short,
14368                                vector signed short);
14370 vector unsigned int vec_vmulouh (vector unsigned short,
14371                                  vector unsigned short);
14373 vector signed short vec_vmulosb (vector signed char,
14374                                  vector signed char);
14376 vector unsigned short vec_vmuloub (vector unsigned char,
14377                                    vector unsigned char);
14379 vector float vec_nmsub (vector float, vector float, vector float);
14381 vector float vec_nor (vector float, vector float);
14382 vector signed int vec_nor (vector signed int, vector signed int);
14383 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14384 vector bool int vec_nor (vector bool int, vector bool int);
14385 vector signed short vec_nor (vector signed short, vector signed short);
14386 vector unsigned short vec_nor (vector unsigned short,
14387                                vector unsigned short);
14388 vector bool short vec_nor (vector bool short, vector bool short);
14389 vector signed char vec_nor (vector signed char, vector signed char);
14390 vector unsigned char vec_nor (vector unsigned char,
14391                               vector unsigned char);
14392 vector bool char vec_nor (vector bool char, vector bool char);
14394 vector float vec_or (vector float, vector float);
14395 vector float vec_or (vector float, vector bool int);
14396 vector float vec_or (vector bool int, vector float);
14397 vector bool int vec_or (vector bool int, vector bool int);
14398 vector signed int vec_or (vector bool int, vector signed int);
14399 vector signed int vec_or (vector signed int, vector bool int);
14400 vector signed int vec_or (vector signed int, vector signed int);
14401 vector unsigned int vec_or (vector bool int, vector unsigned int);
14402 vector unsigned int vec_or (vector unsigned int, vector bool int);
14403 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14404 vector bool short vec_or (vector bool short, vector bool short);
14405 vector signed short vec_or (vector bool short, vector signed short);
14406 vector signed short vec_or (vector signed short, vector bool short);
14407 vector signed short vec_or (vector signed short, vector signed short);
14408 vector unsigned short vec_or (vector bool short, vector unsigned short);
14409 vector unsigned short vec_or (vector unsigned short, vector bool short);
14410 vector unsigned short vec_or (vector unsigned short,
14411                               vector unsigned short);
14412 vector signed char vec_or (vector bool char, vector signed char);
14413 vector bool char vec_or (vector bool char, vector bool char);
14414 vector signed char vec_or (vector signed char, vector bool char);
14415 vector signed char vec_or (vector signed char, vector signed char);
14416 vector unsigned char vec_or (vector bool char, vector unsigned char);
14417 vector unsigned char vec_or (vector unsigned char, vector bool char);
14418 vector unsigned char vec_or (vector unsigned char,
14419                              vector unsigned char);
14421 vector signed char vec_pack (vector signed short, vector signed short);
14422 vector unsigned char vec_pack (vector unsigned short,
14423                                vector unsigned short);
14424 vector bool char vec_pack (vector bool short, vector bool short);
14425 vector signed short vec_pack (vector signed int, vector signed int);
14426 vector unsigned short vec_pack (vector unsigned int,
14427                                 vector unsigned int);
14428 vector bool short vec_pack (vector bool int, vector bool int);
14430 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14431 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14432 vector unsigned short vec_vpkuwum (vector unsigned int,
14433                                    vector unsigned int);
14435 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14436 vector signed char vec_vpkuhum (vector signed short,
14437                                 vector signed short);
14438 vector unsigned char vec_vpkuhum (vector unsigned short,
14439                                   vector unsigned short);
14441 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14443 vector unsigned char vec_packs (vector unsigned short,
14444                                 vector unsigned short);
14445 vector signed char vec_packs (vector signed short, vector signed short);
14446 vector unsigned short vec_packs (vector unsigned int,
14447                                  vector unsigned int);
14448 vector signed short vec_packs (vector signed int, vector signed int);
14450 vector signed short vec_vpkswss (vector signed int, vector signed int);
14452 vector unsigned short vec_vpkuwus (vector unsigned int,
14453                                    vector unsigned int);
14455 vector signed char vec_vpkshss (vector signed short,
14456                                 vector signed short);
14458 vector unsigned char vec_vpkuhus (vector unsigned short,
14459                                   vector unsigned short);
14461 vector unsigned char vec_packsu (vector unsigned short,
14462                                  vector unsigned short);
14463 vector unsigned char vec_packsu (vector signed short,
14464                                  vector signed short);
14465 vector unsigned short vec_packsu (vector unsigned int,
14466                                   vector unsigned int);
14467 vector unsigned short vec_packsu (vector signed int, vector signed int);
14469 vector unsigned short vec_vpkswus (vector signed int,
14470                                    vector signed int);
14472 vector unsigned char vec_vpkshus (vector signed short,
14473                                   vector signed short);
14475 vector float vec_perm (vector float,
14476                        vector float,
14477                        vector unsigned char);
14478 vector signed int vec_perm (vector signed int,
14479                             vector signed int,
14480                             vector unsigned char);
14481 vector unsigned int vec_perm (vector unsigned int,
14482                               vector unsigned int,
14483                               vector unsigned char);
14484 vector bool int vec_perm (vector bool int,
14485                           vector bool int,
14486                           vector unsigned char);
14487 vector signed short vec_perm (vector signed short,
14488                               vector signed short,
14489                               vector unsigned char);
14490 vector unsigned short vec_perm (vector unsigned short,
14491                                 vector unsigned short,
14492                                 vector unsigned char);
14493 vector bool short vec_perm (vector bool short,
14494                             vector bool short,
14495                             vector unsigned char);
14496 vector pixel vec_perm (vector pixel,
14497                        vector pixel,
14498                        vector unsigned char);
14499 vector signed char vec_perm (vector signed char,
14500                              vector signed char,
14501                              vector unsigned char);
14502 vector unsigned char vec_perm (vector unsigned char,
14503                                vector unsigned char,
14504                                vector unsigned char);
14505 vector bool char vec_perm (vector bool char,
14506                            vector bool char,
14507                            vector unsigned char);
14509 vector float vec_re (vector float);
14511 vector signed char vec_rl (vector signed char,
14512                            vector unsigned char);
14513 vector unsigned char vec_rl (vector unsigned char,
14514                              vector unsigned char);
14515 vector signed short vec_rl (vector signed short, vector unsigned short);
14516 vector unsigned short vec_rl (vector unsigned short,
14517                               vector unsigned short);
14518 vector signed int vec_rl (vector signed int, vector unsigned int);
14519 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14521 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14522 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14524 vector signed short vec_vrlh (vector signed short,
14525                               vector unsigned short);
14526 vector unsigned short vec_vrlh (vector unsigned short,
14527                                 vector unsigned short);
14529 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14530 vector unsigned char vec_vrlb (vector unsigned char,
14531                                vector unsigned char);
14533 vector float vec_round (vector float);
14535 vector float vec_recip (vector float, vector float);
14537 vector float vec_rsqrt (vector float);
14539 vector float vec_rsqrte (vector float);
14541 vector float vec_sel (vector float, vector float, vector bool int);
14542 vector float vec_sel (vector float, vector float, vector unsigned int);
14543 vector signed int vec_sel (vector signed int,
14544                            vector signed int,
14545                            vector bool int);
14546 vector signed int vec_sel (vector signed int,
14547                            vector signed int,
14548                            vector unsigned int);
14549 vector unsigned int vec_sel (vector unsigned int,
14550                              vector unsigned int,
14551                              vector bool int);
14552 vector unsigned int vec_sel (vector unsigned int,
14553                              vector unsigned int,
14554                              vector unsigned int);
14555 vector bool int vec_sel (vector bool int,
14556                          vector bool int,
14557                          vector bool int);
14558 vector bool int vec_sel (vector bool int,
14559                          vector bool int,
14560                          vector unsigned int);
14561 vector signed short vec_sel (vector signed short,
14562                              vector signed short,
14563                              vector bool short);
14564 vector signed short vec_sel (vector signed short,
14565                              vector signed short,
14566                              vector unsigned short);
14567 vector unsigned short vec_sel (vector unsigned short,
14568                                vector unsigned short,
14569                                vector bool short);
14570 vector unsigned short vec_sel (vector unsigned short,
14571                                vector unsigned short,
14572                                vector unsigned short);
14573 vector bool short vec_sel (vector bool short,
14574                            vector bool short,
14575                            vector bool short);
14576 vector bool short vec_sel (vector bool short,
14577                            vector bool short,
14578                            vector unsigned short);
14579 vector signed char vec_sel (vector signed char,
14580                             vector signed char,
14581                             vector bool char);
14582 vector signed char vec_sel (vector signed char,
14583                             vector signed char,
14584                             vector unsigned char);
14585 vector unsigned char vec_sel (vector unsigned char,
14586                               vector unsigned char,
14587                               vector bool char);
14588 vector unsigned char vec_sel (vector unsigned char,
14589                               vector unsigned char,
14590                               vector unsigned char);
14591 vector bool char vec_sel (vector bool char,
14592                           vector bool char,
14593                           vector bool char);
14594 vector bool char vec_sel (vector bool char,
14595                           vector bool char,
14596                           vector unsigned char);
14598 vector signed char vec_sl (vector signed char,
14599                            vector unsigned char);
14600 vector unsigned char vec_sl (vector unsigned char,
14601                              vector unsigned char);
14602 vector signed short vec_sl (vector signed short, vector unsigned short);
14603 vector unsigned short vec_sl (vector unsigned short,
14604                               vector unsigned short);
14605 vector signed int vec_sl (vector signed int, vector unsigned int);
14606 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14608 vector signed int vec_vslw (vector signed int, vector unsigned int);
14609 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14611 vector signed short vec_vslh (vector signed short,
14612                               vector unsigned short);
14613 vector unsigned short vec_vslh (vector unsigned short,
14614                                 vector unsigned short);
14616 vector signed char vec_vslb (vector signed char, vector unsigned char);
14617 vector unsigned char vec_vslb (vector unsigned char,
14618                                vector unsigned char);
14620 vector float vec_sld (vector float, vector float, const int);
14621 vector signed int vec_sld (vector signed int,
14622                            vector signed int,
14623                            const int);
14624 vector unsigned int vec_sld (vector unsigned int,
14625                              vector unsigned int,
14626                              const int);
14627 vector bool int vec_sld (vector bool int,
14628                          vector bool int,
14629                          const int);
14630 vector signed short vec_sld (vector signed short,
14631                              vector signed short,
14632                              const int);
14633 vector unsigned short vec_sld (vector unsigned short,
14634                                vector unsigned short,
14635                                const int);
14636 vector bool short vec_sld (vector bool short,
14637                            vector bool short,
14638                            const int);
14639 vector pixel vec_sld (vector pixel,
14640                       vector pixel,
14641                       const int);
14642 vector signed char vec_sld (vector signed char,
14643                             vector signed char,
14644                             const int);
14645 vector unsigned char vec_sld (vector unsigned char,
14646                               vector unsigned char,
14647                               const int);
14648 vector bool char vec_sld (vector bool char,
14649                           vector bool char,
14650                           const int);
14652 vector signed int vec_sll (vector signed int,
14653                            vector unsigned int);
14654 vector signed int vec_sll (vector signed int,
14655                            vector unsigned short);
14656 vector signed int vec_sll (vector signed int,
14657                            vector unsigned char);
14658 vector unsigned int vec_sll (vector unsigned int,
14659                              vector unsigned int);
14660 vector unsigned int vec_sll (vector unsigned int,
14661                              vector unsigned short);
14662 vector unsigned int vec_sll (vector unsigned int,
14663                              vector unsigned char);
14664 vector bool int vec_sll (vector bool int,
14665                          vector unsigned int);
14666 vector bool int vec_sll (vector bool int,
14667                          vector unsigned short);
14668 vector bool int vec_sll (vector bool int,
14669                          vector unsigned char);
14670 vector signed short vec_sll (vector signed short,
14671                              vector unsigned int);
14672 vector signed short vec_sll (vector signed short,
14673                              vector unsigned short);
14674 vector signed short vec_sll (vector signed short,
14675                              vector unsigned char);
14676 vector unsigned short vec_sll (vector unsigned short,
14677                                vector unsigned int);
14678 vector unsigned short vec_sll (vector unsigned short,
14679                                vector unsigned short);
14680 vector unsigned short vec_sll (vector unsigned short,
14681                                vector unsigned char);
14682 vector bool short vec_sll (vector bool short, vector unsigned int);
14683 vector bool short vec_sll (vector bool short, vector unsigned short);
14684 vector bool short vec_sll (vector bool short, vector unsigned char);
14685 vector pixel vec_sll (vector pixel, vector unsigned int);
14686 vector pixel vec_sll (vector pixel, vector unsigned short);
14687 vector pixel vec_sll (vector pixel, vector unsigned char);
14688 vector signed char vec_sll (vector signed char, vector unsigned int);
14689 vector signed char vec_sll (vector signed char, vector unsigned short);
14690 vector signed char vec_sll (vector signed char, vector unsigned char);
14691 vector unsigned char vec_sll (vector unsigned char,
14692                               vector unsigned int);
14693 vector unsigned char vec_sll (vector unsigned char,
14694                               vector unsigned short);
14695 vector unsigned char vec_sll (vector unsigned char,
14696                               vector unsigned char);
14697 vector bool char vec_sll (vector bool char, vector unsigned int);
14698 vector bool char vec_sll (vector bool char, vector unsigned short);
14699 vector bool char vec_sll (vector bool char, vector unsigned char);
14701 vector float vec_slo (vector float, vector signed char);
14702 vector float vec_slo (vector float, vector unsigned char);
14703 vector signed int vec_slo (vector signed int, vector signed char);
14704 vector signed int vec_slo (vector signed int, vector unsigned char);
14705 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14706 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14707 vector signed short vec_slo (vector signed short, vector signed char);
14708 vector signed short vec_slo (vector signed short, vector unsigned char);
14709 vector unsigned short vec_slo (vector unsigned short,
14710                                vector signed char);
14711 vector unsigned short vec_slo (vector unsigned short,
14712                                vector unsigned char);
14713 vector pixel vec_slo (vector pixel, vector signed char);
14714 vector pixel vec_slo (vector pixel, vector unsigned char);
14715 vector signed char vec_slo (vector signed char, vector signed char);
14716 vector signed char vec_slo (vector signed char, vector unsigned char);
14717 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14718 vector unsigned char vec_slo (vector unsigned char,
14719                               vector unsigned char);
14721 vector signed char vec_splat (vector signed char, const int);
14722 vector unsigned char vec_splat (vector unsigned char, const int);
14723 vector bool char vec_splat (vector bool char, const int);
14724 vector signed short vec_splat (vector signed short, const int);
14725 vector unsigned short vec_splat (vector unsigned short, const int);
14726 vector bool short vec_splat (vector bool short, const int);
14727 vector pixel vec_splat (vector pixel, const int);
14728 vector float vec_splat (vector float, const int);
14729 vector signed int vec_splat (vector signed int, const int);
14730 vector unsigned int vec_splat (vector unsigned int, const int);
14731 vector bool int vec_splat (vector bool int, const int);
14732 vector signed long vec_splat (vector signed long, const int);
14733 vector unsigned long vec_splat (vector unsigned long, const int);
14735 vector signed char vec_splats (signed char);
14736 vector unsigned char vec_splats (unsigned char);
14737 vector signed short vec_splats (signed short);
14738 vector unsigned short vec_splats (unsigned short);
14739 vector signed int vec_splats (signed int);
14740 vector unsigned int vec_splats (unsigned int);
14741 vector float vec_splats (float);
14743 vector float vec_vspltw (vector float, const int);
14744 vector signed int vec_vspltw (vector signed int, const int);
14745 vector unsigned int vec_vspltw (vector unsigned int, const int);
14746 vector bool int vec_vspltw (vector bool int, const int);
14748 vector bool short vec_vsplth (vector bool short, const int);
14749 vector signed short vec_vsplth (vector signed short, const int);
14750 vector unsigned short vec_vsplth (vector unsigned short, const int);
14751 vector pixel vec_vsplth (vector pixel, const int);
14753 vector signed char vec_vspltb (vector signed char, const int);
14754 vector unsigned char vec_vspltb (vector unsigned char, const int);
14755 vector bool char vec_vspltb (vector bool char, const int);
14757 vector signed char vec_splat_s8 (const int);
14759 vector signed short vec_splat_s16 (const int);
14761 vector signed int vec_splat_s32 (const int);
14763 vector unsigned char vec_splat_u8 (const int);
14765 vector unsigned short vec_splat_u16 (const int);
14767 vector unsigned int vec_splat_u32 (const int);
14769 vector signed char vec_sr (vector signed char, vector unsigned char);
14770 vector unsigned char vec_sr (vector unsigned char,
14771                              vector unsigned char);
14772 vector signed short vec_sr (vector signed short,
14773                             vector unsigned short);
14774 vector unsigned short vec_sr (vector unsigned short,
14775                               vector unsigned short);
14776 vector signed int vec_sr (vector signed int, vector unsigned int);
14777 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14779 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14780 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14782 vector signed short vec_vsrh (vector signed short,
14783                               vector unsigned short);
14784 vector unsigned short vec_vsrh (vector unsigned short,
14785                                 vector unsigned short);
14787 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14788 vector unsigned char vec_vsrb (vector unsigned char,
14789                                vector unsigned char);
14791 vector signed char vec_sra (vector signed char, vector unsigned char);
14792 vector unsigned char vec_sra (vector unsigned char,
14793                               vector unsigned char);
14794 vector signed short vec_sra (vector signed short,
14795                              vector unsigned short);
14796 vector unsigned short vec_sra (vector unsigned short,
14797                                vector unsigned short);
14798 vector signed int vec_sra (vector signed int, vector unsigned int);
14799 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14801 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14802 vector unsigned int vec_vsraw (vector unsigned int,
14803                                vector unsigned int);
14805 vector signed short vec_vsrah (vector signed short,
14806                                vector unsigned short);
14807 vector unsigned short vec_vsrah (vector unsigned short,
14808                                  vector unsigned short);
14810 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14811 vector unsigned char vec_vsrab (vector unsigned char,
14812                                 vector unsigned char);
14814 vector signed int vec_srl (vector signed int, vector unsigned int);
14815 vector signed int vec_srl (vector signed int, vector unsigned short);
14816 vector signed int vec_srl (vector signed int, vector unsigned char);
14817 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14818 vector unsigned int vec_srl (vector unsigned int,
14819                              vector unsigned short);
14820 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14821 vector bool int vec_srl (vector bool int, vector unsigned int);
14822 vector bool int vec_srl (vector bool int, vector unsigned short);
14823 vector bool int vec_srl (vector bool int, vector unsigned char);
14824 vector signed short vec_srl (vector signed short, vector unsigned int);
14825 vector signed short vec_srl (vector signed short,
14826                              vector unsigned short);
14827 vector signed short vec_srl (vector signed short, vector unsigned char);
14828 vector unsigned short vec_srl (vector unsigned short,
14829                                vector unsigned int);
14830 vector unsigned short vec_srl (vector unsigned short,
14831                                vector unsigned short);
14832 vector unsigned short vec_srl (vector unsigned short,
14833                                vector unsigned char);
14834 vector bool short vec_srl (vector bool short, vector unsigned int);
14835 vector bool short vec_srl (vector bool short, vector unsigned short);
14836 vector bool short vec_srl (vector bool short, vector unsigned char);
14837 vector pixel vec_srl (vector pixel, vector unsigned int);
14838 vector pixel vec_srl (vector pixel, vector unsigned short);
14839 vector pixel vec_srl (vector pixel, vector unsigned char);
14840 vector signed char vec_srl (vector signed char, vector unsigned int);
14841 vector signed char vec_srl (vector signed char, vector unsigned short);
14842 vector signed char vec_srl (vector signed char, vector unsigned char);
14843 vector unsigned char vec_srl (vector unsigned char,
14844                               vector unsigned int);
14845 vector unsigned char vec_srl (vector unsigned char,
14846                               vector unsigned short);
14847 vector unsigned char vec_srl (vector unsigned char,
14848                               vector unsigned char);
14849 vector bool char vec_srl (vector bool char, vector unsigned int);
14850 vector bool char vec_srl (vector bool char, vector unsigned short);
14851 vector bool char vec_srl (vector bool char, vector unsigned char);
14853 vector float vec_sro (vector float, vector signed char);
14854 vector float vec_sro (vector float, vector unsigned char);
14855 vector signed int vec_sro (vector signed int, vector signed char);
14856 vector signed int vec_sro (vector signed int, vector unsigned char);
14857 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14858 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14859 vector signed short vec_sro (vector signed short, vector signed char);
14860 vector signed short vec_sro (vector signed short, vector unsigned char);
14861 vector unsigned short vec_sro (vector unsigned short,
14862                                vector signed char);
14863 vector unsigned short vec_sro (vector unsigned short,
14864                                vector unsigned char);
14865 vector pixel vec_sro (vector pixel, vector signed char);
14866 vector pixel vec_sro (vector pixel, vector unsigned char);
14867 vector signed char vec_sro (vector signed char, vector signed char);
14868 vector signed char vec_sro (vector signed char, vector unsigned char);
14869 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14870 vector unsigned char vec_sro (vector unsigned char,
14871                               vector unsigned char);
14873 void vec_st (vector float, int, vector float *);
14874 void vec_st (vector float, int, float *);
14875 void vec_st (vector signed int, int, vector signed int *);
14876 void vec_st (vector signed int, int, int *);
14877 void vec_st (vector unsigned int, int, vector unsigned int *);
14878 void vec_st (vector unsigned int, int, unsigned int *);
14879 void vec_st (vector bool int, int, vector bool int *);
14880 void vec_st (vector bool int, int, unsigned int *);
14881 void vec_st (vector bool int, int, int *);
14882 void vec_st (vector signed short, int, vector signed short *);
14883 void vec_st (vector signed short, int, short *);
14884 void vec_st (vector unsigned short, int, vector unsigned short *);
14885 void vec_st (vector unsigned short, int, unsigned short *);
14886 void vec_st (vector bool short, int, vector bool short *);
14887 void vec_st (vector bool short, int, unsigned short *);
14888 void vec_st (vector pixel, int, vector pixel *);
14889 void vec_st (vector pixel, int, unsigned short *);
14890 void vec_st (vector pixel, int, short *);
14891 void vec_st (vector bool short, int, short *);
14892 void vec_st (vector signed char, int, vector signed char *);
14893 void vec_st (vector signed char, int, signed char *);
14894 void vec_st (vector unsigned char, int, vector unsigned char *);
14895 void vec_st (vector unsigned char, int, unsigned char *);
14896 void vec_st (vector bool char, int, vector bool char *);
14897 void vec_st (vector bool char, int, unsigned char *);
14898 void vec_st (vector bool char, int, signed char *);
14900 void vec_ste (vector signed char, int, signed char *);
14901 void vec_ste (vector unsigned char, int, unsigned char *);
14902 void vec_ste (vector bool char, int, signed char *);
14903 void vec_ste (vector bool char, int, unsigned char *);
14904 void vec_ste (vector signed short, int, short *);
14905 void vec_ste (vector unsigned short, int, unsigned short *);
14906 void vec_ste (vector bool short, int, short *);
14907 void vec_ste (vector bool short, int, unsigned short *);
14908 void vec_ste (vector pixel, int, short *);
14909 void vec_ste (vector pixel, int, unsigned short *);
14910 void vec_ste (vector float, int, float *);
14911 void vec_ste (vector signed int, int, int *);
14912 void vec_ste (vector unsigned int, int, unsigned int *);
14913 void vec_ste (vector bool int, int, int *);
14914 void vec_ste (vector bool int, int, unsigned int *);
14916 void vec_stvewx (vector float, int, float *);
14917 void vec_stvewx (vector signed int, int, int *);
14918 void vec_stvewx (vector unsigned int, int, unsigned int *);
14919 void vec_stvewx (vector bool int, int, int *);
14920 void vec_stvewx (vector bool int, int, unsigned int *);
14922 void vec_stvehx (vector signed short, int, short *);
14923 void vec_stvehx (vector unsigned short, int, unsigned short *);
14924 void vec_stvehx (vector bool short, int, short *);
14925 void vec_stvehx (vector bool short, int, unsigned short *);
14926 void vec_stvehx (vector pixel, int, short *);
14927 void vec_stvehx (vector pixel, int, unsigned short *);
14929 void vec_stvebx (vector signed char, int, signed char *);
14930 void vec_stvebx (vector unsigned char, int, unsigned char *);
14931 void vec_stvebx (vector bool char, int, signed char *);
14932 void vec_stvebx (vector bool char, int, unsigned char *);
14934 void vec_stl (vector float, int, vector float *);
14935 void vec_stl (vector float, int, float *);
14936 void vec_stl (vector signed int, int, vector signed int *);
14937 void vec_stl (vector signed int, int, int *);
14938 void vec_stl (vector unsigned int, int, vector unsigned int *);
14939 void vec_stl (vector unsigned int, int, unsigned int *);
14940 void vec_stl (vector bool int, int, vector bool int *);
14941 void vec_stl (vector bool int, int, unsigned int *);
14942 void vec_stl (vector bool int, int, int *);
14943 void vec_stl (vector signed short, int, vector signed short *);
14944 void vec_stl (vector signed short, int, short *);
14945 void vec_stl (vector unsigned short, int, vector unsigned short *);
14946 void vec_stl (vector unsigned short, int, unsigned short *);
14947 void vec_stl (vector bool short, int, vector bool short *);
14948 void vec_stl (vector bool short, int, unsigned short *);
14949 void vec_stl (vector bool short, int, short *);
14950 void vec_stl (vector pixel, int, vector pixel *);
14951 void vec_stl (vector pixel, int, unsigned short *);
14952 void vec_stl (vector pixel, int, short *);
14953 void vec_stl (vector signed char, int, vector signed char *);
14954 void vec_stl (vector signed char, int, signed char *);
14955 void vec_stl (vector unsigned char, int, vector unsigned char *);
14956 void vec_stl (vector unsigned char, int, unsigned char *);
14957 void vec_stl (vector bool char, int, vector bool char *);
14958 void vec_stl (vector bool char, int, unsigned char *);
14959 void vec_stl (vector bool char, int, signed char *);
14961 vector signed char vec_sub (vector bool char, vector signed char);
14962 vector signed char vec_sub (vector signed char, vector bool char);
14963 vector signed char vec_sub (vector signed char, vector signed char);
14964 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14965 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14966 vector unsigned char vec_sub (vector unsigned char,
14967                               vector unsigned char);
14968 vector signed short vec_sub (vector bool short, vector signed short);
14969 vector signed short vec_sub (vector signed short, vector bool short);
14970 vector signed short vec_sub (vector signed short, vector signed short);
14971 vector unsigned short vec_sub (vector bool short,
14972                                vector unsigned short);
14973 vector unsigned short vec_sub (vector unsigned short,
14974                                vector bool short);
14975 vector unsigned short vec_sub (vector unsigned short,
14976                                vector unsigned short);
14977 vector signed int vec_sub (vector bool int, vector signed int);
14978 vector signed int vec_sub (vector signed int, vector bool int);
14979 vector signed int vec_sub (vector signed int, vector signed int);
14980 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14981 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14982 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14983 vector float vec_sub (vector float, vector float);
14985 vector float vec_vsubfp (vector float, vector float);
14987 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14988 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14989 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14990 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14991 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14992 vector unsigned int vec_vsubuwm (vector unsigned int,
14993                                  vector unsigned int);
14995 vector signed short vec_vsubuhm (vector bool short,
14996                                  vector signed short);
14997 vector signed short vec_vsubuhm (vector signed short,
14998                                  vector bool short);
14999 vector signed short vec_vsubuhm (vector signed short,
15000                                  vector signed short);
15001 vector unsigned short vec_vsubuhm (vector bool short,
15002                                    vector unsigned short);
15003 vector unsigned short vec_vsubuhm (vector unsigned short,
15004                                    vector bool short);
15005 vector unsigned short vec_vsubuhm (vector unsigned short,
15006                                    vector unsigned short);
15008 vector signed char vec_vsububm (vector bool char, vector signed char);
15009 vector signed char vec_vsububm (vector signed char, vector bool char);
15010 vector signed char vec_vsububm (vector signed char, vector signed char);
15011 vector unsigned char vec_vsububm (vector bool char,
15012                                   vector unsigned char);
15013 vector unsigned char vec_vsububm (vector unsigned char,
15014                                   vector bool char);
15015 vector unsigned char vec_vsububm (vector unsigned char,
15016                                   vector unsigned char);
15018 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15020 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15021 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15022 vector unsigned char vec_subs (vector unsigned char,
15023                                vector unsigned char);
15024 vector signed char vec_subs (vector bool char, vector signed char);
15025 vector signed char vec_subs (vector signed char, vector bool char);
15026 vector signed char vec_subs (vector signed char, vector signed char);
15027 vector unsigned short vec_subs (vector bool short,
15028                                 vector unsigned short);
15029 vector unsigned short vec_subs (vector unsigned short,
15030                                 vector bool short);
15031 vector unsigned short vec_subs (vector unsigned short,
15032                                 vector unsigned short);
15033 vector signed short vec_subs (vector bool short, vector signed short);
15034 vector signed short vec_subs (vector signed short, vector bool short);
15035 vector signed short vec_subs (vector signed short, vector signed short);
15036 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15037 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15038 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15039 vector signed int vec_subs (vector bool int, vector signed int);
15040 vector signed int vec_subs (vector signed int, vector bool int);
15041 vector signed int vec_subs (vector signed int, vector signed int);
15043 vector signed int vec_vsubsws (vector bool int, vector signed int);
15044 vector signed int vec_vsubsws (vector signed int, vector bool int);
15045 vector signed int vec_vsubsws (vector signed int, vector signed int);
15047 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15048 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15049 vector unsigned int vec_vsubuws (vector unsigned int,
15050                                  vector unsigned int);
15052 vector signed short vec_vsubshs (vector bool short,
15053                                  vector signed short);
15054 vector signed short vec_vsubshs (vector signed short,
15055                                  vector bool short);
15056 vector signed short vec_vsubshs (vector signed short,
15057                                  vector signed short);
15059 vector unsigned short vec_vsubuhs (vector bool short,
15060                                    vector unsigned short);
15061 vector unsigned short vec_vsubuhs (vector unsigned short,
15062                                    vector bool short);
15063 vector unsigned short vec_vsubuhs (vector unsigned short,
15064                                    vector unsigned short);
15066 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15067 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15068 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15070 vector unsigned char vec_vsububs (vector bool char,
15071                                   vector unsigned char);
15072 vector unsigned char vec_vsububs (vector unsigned char,
15073                                   vector bool char);
15074 vector unsigned char vec_vsububs (vector unsigned char,
15075                                   vector unsigned char);
15077 vector unsigned int vec_sum4s (vector unsigned char,
15078                                vector unsigned int);
15079 vector signed int vec_sum4s (vector signed char, vector signed int);
15080 vector signed int vec_sum4s (vector signed short, vector signed int);
15082 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15084 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15086 vector unsigned int vec_vsum4ubs (vector unsigned char,
15087                                   vector unsigned int);
15089 vector signed int vec_sum2s (vector signed int, vector signed int);
15091 vector signed int vec_sums (vector signed int, vector signed int);
15093 vector float vec_trunc (vector float);
15095 vector signed short vec_unpackh (vector signed char);
15096 vector bool short vec_unpackh (vector bool char);
15097 vector signed int vec_unpackh (vector signed short);
15098 vector bool int vec_unpackh (vector bool short);
15099 vector unsigned int vec_unpackh (vector pixel);
15101 vector bool int vec_vupkhsh (vector bool short);
15102 vector signed int vec_vupkhsh (vector signed short);
15104 vector unsigned int vec_vupkhpx (vector pixel);
15106 vector bool short vec_vupkhsb (vector bool char);
15107 vector signed short vec_vupkhsb (vector signed char);
15109 vector signed short vec_unpackl (vector signed char);
15110 vector bool short vec_unpackl (vector bool char);
15111 vector unsigned int vec_unpackl (vector pixel);
15112 vector signed int vec_unpackl (vector signed short);
15113 vector bool int vec_unpackl (vector bool short);
15115 vector unsigned int vec_vupklpx (vector pixel);
15117 vector bool int vec_vupklsh (vector bool short);
15118 vector signed int vec_vupklsh (vector signed short);
15120 vector bool short vec_vupklsb (vector bool char);
15121 vector signed short vec_vupklsb (vector signed char);
15123 vector float vec_xor (vector float, vector float);
15124 vector float vec_xor (vector float, vector bool int);
15125 vector float vec_xor (vector bool int, vector float);
15126 vector bool int vec_xor (vector bool int, vector bool int);
15127 vector signed int vec_xor (vector bool int, vector signed int);
15128 vector signed int vec_xor (vector signed int, vector bool int);
15129 vector signed int vec_xor (vector signed int, vector signed int);
15130 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15131 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15132 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15133 vector bool short vec_xor (vector bool short, vector bool short);
15134 vector signed short vec_xor (vector bool short, vector signed short);
15135 vector signed short vec_xor (vector signed short, vector bool short);
15136 vector signed short vec_xor (vector signed short, vector signed short);
15137 vector unsigned short vec_xor (vector bool short,
15138                                vector unsigned short);
15139 vector unsigned short vec_xor (vector unsigned short,
15140                                vector bool short);
15141 vector unsigned short vec_xor (vector unsigned short,
15142                                vector unsigned short);
15143 vector signed char vec_xor (vector bool char, vector signed char);
15144 vector bool char vec_xor (vector bool char, vector bool char);
15145 vector signed char vec_xor (vector signed char, vector bool char);
15146 vector signed char vec_xor (vector signed char, vector signed char);
15147 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15148 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15149 vector unsigned char vec_xor (vector unsigned char,
15150                               vector unsigned char);
15152 int vec_all_eq (vector signed char, vector bool char);
15153 int vec_all_eq (vector signed char, vector signed char);
15154 int vec_all_eq (vector unsigned char, vector bool char);
15155 int vec_all_eq (vector unsigned char, vector unsigned char);
15156 int vec_all_eq (vector bool char, vector bool char);
15157 int vec_all_eq (vector bool char, vector unsigned char);
15158 int vec_all_eq (vector bool char, vector signed char);
15159 int vec_all_eq (vector signed short, vector bool short);
15160 int vec_all_eq (vector signed short, vector signed short);
15161 int vec_all_eq (vector unsigned short, vector bool short);
15162 int vec_all_eq (vector unsigned short, vector unsigned short);
15163 int vec_all_eq (vector bool short, vector bool short);
15164 int vec_all_eq (vector bool short, vector unsigned short);
15165 int vec_all_eq (vector bool short, vector signed short);
15166 int vec_all_eq (vector pixel, vector pixel);
15167 int vec_all_eq (vector signed int, vector bool int);
15168 int vec_all_eq (vector signed int, vector signed int);
15169 int vec_all_eq (vector unsigned int, vector bool int);
15170 int vec_all_eq (vector unsigned int, vector unsigned int);
15171 int vec_all_eq (vector bool int, vector bool int);
15172 int vec_all_eq (vector bool int, vector unsigned int);
15173 int vec_all_eq (vector bool int, vector signed int);
15174 int vec_all_eq (vector float, vector float);
15176 int vec_all_ge (vector bool char, vector unsigned char);
15177 int vec_all_ge (vector unsigned char, vector bool char);
15178 int vec_all_ge (vector unsigned char, vector unsigned char);
15179 int vec_all_ge (vector bool char, vector signed char);
15180 int vec_all_ge (vector signed char, vector bool char);
15181 int vec_all_ge (vector signed char, vector signed char);
15182 int vec_all_ge (vector bool short, vector unsigned short);
15183 int vec_all_ge (vector unsigned short, vector bool short);
15184 int vec_all_ge (vector unsigned short, vector unsigned short);
15185 int vec_all_ge (vector signed short, vector signed short);
15186 int vec_all_ge (vector bool short, vector signed short);
15187 int vec_all_ge (vector signed short, vector bool short);
15188 int vec_all_ge (vector bool int, vector unsigned int);
15189 int vec_all_ge (vector unsigned int, vector bool int);
15190 int vec_all_ge (vector unsigned int, vector unsigned int);
15191 int vec_all_ge (vector bool int, vector signed int);
15192 int vec_all_ge (vector signed int, vector bool int);
15193 int vec_all_ge (vector signed int, vector signed int);
15194 int vec_all_ge (vector float, vector float);
15196 int vec_all_gt (vector bool char, vector unsigned char);
15197 int vec_all_gt (vector unsigned char, vector bool char);
15198 int vec_all_gt (vector unsigned char, vector unsigned char);
15199 int vec_all_gt (vector bool char, vector signed char);
15200 int vec_all_gt (vector signed char, vector bool char);
15201 int vec_all_gt (vector signed char, vector signed char);
15202 int vec_all_gt (vector bool short, vector unsigned short);
15203 int vec_all_gt (vector unsigned short, vector bool short);
15204 int vec_all_gt (vector unsigned short, vector unsigned short);
15205 int vec_all_gt (vector bool short, vector signed short);
15206 int vec_all_gt (vector signed short, vector bool short);
15207 int vec_all_gt (vector signed short, vector signed short);
15208 int vec_all_gt (vector bool int, vector unsigned int);
15209 int vec_all_gt (vector unsigned int, vector bool int);
15210 int vec_all_gt (vector unsigned int, vector unsigned int);
15211 int vec_all_gt (vector bool int, vector signed int);
15212 int vec_all_gt (vector signed int, vector bool int);
15213 int vec_all_gt (vector signed int, vector signed int);
15214 int vec_all_gt (vector float, vector float);
15216 int vec_all_in (vector float, vector float);
15218 int vec_all_le (vector bool char, vector unsigned char);
15219 int vec_all_le (vector unsigned char, vector bool char);
15220 int vec_all_le (vector unsigned char, vector unsigned char);
15221 int vec_all_le (vector bool char, vector signed char);
15222 int vec_all_le (vector signed char, vector bool char);
15223 int vec_all_le (vector signed char, vector signed char);
15224 int vec_all_le (vector bool short, vector unsigned short);
15225 int vec_all_le (vector unsigned short, vector bool short);
15226 int vec_all_le (vector unsigned short, vector unsigned short);
15227 int vec_all_le (vector bool short, vector signed short);
15228 int vec_all_le (vector signed short, vector bool short);
15229 int vec_all_le (vector signed short, vector signed short);
15230 int vec_all_le (vector bool int, vector unsigned int);
15231 int vec_all_le (vector unsigned int, vector bool int);
15232 int vec_all_le (vector unsigned int, vector unsigned int);
15233 int vec_all_le (vector bool int, vector signed int);
15234 int vec_all_le (vector signed int, vector bool int);
15235 int vec_all_le (vector signed int, vector signed int);
15236 int vec_all_le (vector float, vector float);
15238 int vec_all_lt (vector bool char, vector unsigned char);
15239 int vec_all_lt (vector unsigned char, vector bool char);
15240 int vec_all_lt (vector unsigned char, vector unsigned char);
15241 int vec_all_lt (vector bool char, vector signed char);
15242 int vec_all_lt (vector signed char, vector bool char);
15243 int vec_all_lt (vector signed char, vector signed char);
15244 int vec_all_lt (vector bool short, vector unsigned short);
15245 int vec_all_lt (vector unsigned short, vector bool short);
15246 int vec_all_lt (vector unsigned short, vector unsigned short);
15247 int vec_all_lt (vector bool short, vector signed short);
15248 int vec_all_lt (vector signed short, vector bool short);
15249 int vec_all_lt (vector signed short, vector signed short);
15250 int vec_all_lt (vector bool int, vector unsigned int);
15251 int vec_all_lt (vector unsigned int, vector bool int);
15252 int vec_all_lt (vector unsigned int, vector unsigned int);
15253 int vec_all_lt (vector bool int, vector signed int);
15254 int vec_all_lt (vector signed int, vector bool int);
15255 int vec_all_lt (vector signed int, vector signed int);
15256 int vec_all_lt (vector float, vector float);
15258 int vec_all_nan (vector float);
15260 int vec_all_ne (vector signed char, vector bool char);
15261 int vec_all_ne (vector signed char, vector signed char);
15262 int vec_all_ne (vector unsigned char, vector bool char);
15263 int vec_all_ne (vector unsigned char, vector unsigned char);
15264 int vec_all_ne (vector bool char, vector bool char);
15265 int vec_all_ne (vector bool char, vector unsigned char);
15266 int vec_all_ne (vector bool char, vector signed char);
15267 int vec_all_ne (vector signed short, vector bool short);
15268 int vec_all_ne (vector signed short, vector signed short);
15269 int vec_all_ne (vector unsigned short, vector bool short);
15270 int vec_all_ne (vector unsigned short, vector unsigned short);
15271 int vec_all_ne (vector bool short, vector bool short);
15272 int vec_all_ne (vector bool short, vector unsigned short);
15273 int vec_all_ne (vector bool short, vector signed short);
15274 int vec_all_ne (vector pixel, vector pixel);
15275 int vec_all_ne (vector signed int, vector bool int);
15276 int vec_all_ne (vector signed int, vector signed int);
15277 int vec_all_ne (vector unsigned int, vector bool int);
15278 int vec_all_ne (vector unsigned int, vector unsigned int);
15279 int vec_all_ne (vector bool int, vector bool int);
15280 int vec_all_ne (vector bool int, vector unsigned int);
15281 int vec_all_ne (vector bool int, vector signed int);
15282 int vec_all_ne (vector float, vector float);
15284 int vec_all_nge (vector float, vector float);
15286 int vec_all_ngt (vector float, vector float);
15288 int vec_all_nle (vector float, vector float);
15290 int vec_all_nlt (vector float, vector float);
15292 int vec_all_numeric (vector float);
15294 int vec_any_eq (vector signed char, vector bool char);
15295 int vec_any_eq (vector signed char, vector signed char);
15296 int vec_any_eq (vector unsigned char, vector bool char);
15297 int vec_any_eq (vector unsigned char, vector unsigned char);
15298 int vec_any_eq (vector bool char, vector bool char);
15299 int vec_any_eq (vector bool char, vector unsigned char);
15300 int vec_any_eq (vector bool char, vector signed char);
15301 int vec_any_eq (vector signed short, vector bool short);
15302 int vec_any_eq (vector signed short, vector signed short);
15303 int vec_any_eq (vector unsigned short, vector bool short);
15304 int vec_any_eq (vector unsigned short, vector unsigned short);
15305 int vec_any_eq (vector bool short, vector bool short);
15306 int vec_any_eq (vector bool short, vector unsigned short);
15307 int vec_any_eq (vector bool short, vector signed short);
15308 int vec_any_eq (vector pixel, vector pixel);
15309 int vec_any_eq (vector signed int, vector bool int);
15310 int vec_any_eq (vector signed int, vector signed int);
15311 int vec_any_eq (vector unsigned int, vector bool int);
15312 int vec_any_eq (vector unsigned int, vector unsigned int);
15313 int vec_any_eq (vector bool int, vector bool int);
15314 int vec_any_eq (vector bool int, vector unsigned int);
15315 int vec_any_eq (vector bool int, vector signed int);
15316 int vec_any_eq (vector float, vector float);
15318 int vec_any_ge (vector signed char, vector bool char);
15319 int vec_any_ge (vector unsigned char, vector bool char);
15320 int vec_any_ge (vector unsigned char, vector unsigned char);
15321 int vec_any_ge (vector signed char, vector signed char);
15322 int vec_any_ge (vector bool char, vector unsigned char);
15323 int vec_any_ge (vector bool char, vector signed char);
15324 int vec_any_ge (vector unsigned short, vector bool short);
15325 int vec_any_ge (vector unsigned short, vector unsigned short);
15326 int vec_any_ge (vector signed short, vector signed short);
15327 int vec_any_ge (vector signed short, vector bool short);
15328 int vec_any_ge (vector bool short, vector unsigned short);
15329 int vec_any_ge (vector bool short, vector signed short);
15330 int vec_any_ge (vector signed int, vector bool int);
15331 int vec_any_ge (vector unsigned int, vector bool int);
15332 int vec_any_ge (vector unsigned int, vector unsigned int);
15333 int vec_any_ge (vector signed int, vector signed int);
15334 int vec_any_ge (vector bool int, vector unsigned int);
15335 int vec_any_ge (vector bool int, vector signed int);
15336 int vec_any_ge (vector float, vector float);
15338 int vec_any_gt (vector bool char, vector unsigned char);
15339 int vec_any_gt (vector unsigned char, vector bool char);
15340 int vec_any_gt (vector unsigned char, vector unsigned char);
15341 int vec_any_gt (vector bool char, vector signed char);
15342 int vec_any_gt (vector signed char, vector bool char);
15343 int vec_any_gt (vector signed char, vector signed char);
15344 int vec_any_gt (vector bool short, vector unsigned short);
15345 int vec_any_gt (vector unsigned short, vector bool short);
15346 int vec_any_gt (vector unsigned short, vector unsigned short);
15347 int vec_any_gt (vector bool short, vector signed short);
15348 int vec_any_gt (vector signed short, vector bool short);
15349 int vec_any_gt (vector signed short, vector signed short);
15350 int vec_any_gt (vector bool int, vector unsigned int);
15351 int vec_any_gt (vector unsigned int, vector bool int);
15352 int vec_any_gt (vector unsigned int, vector unsigned int);
15353 int vec_any_gt (vector bool int, vector signed int);
15354 int vec_any_gt (vector signed int, vector bool int);
15355 int vec_any_gt (vector signed int, vector signed int);
15356 int vec_any_gt (vector float, vector float);
15358 int vec_any_le (vector bool char, vector unsigned char);
15359 int vec_any_le (vector unsigned char, vector bool char);
15360 int vec_any_le (vector unsigned char, vector unsigned char);
15361 int vec_any_le (vector bool char, vector signed char);
15362 int vec_any_le (vector signed char, vector bool char);
15363 int vec_any_le (vector signed char, vector signed char);
15364 int vec_any_le (vector bool short, vector unsigned short);
15365 int vec_any_le (vector unsigned short, vector bool short);
15366 int vec_any_le (vector unsigned short, vector unsigned short);
15367 int vec_any_le (vector bool short, vector signed short);
15368 int vec_any_le (vector signed short, vector bool short);
15369 int vec_any_le (vector signed short, vector signed short);
15370 int vec_any_le (vector bool int, vector unsigned int);
15371 int vec_any_le (vector unsigned int, vector bool int);
15372 int vec_any_le (vector unsigned int, vector unsigned int);
15373 int vec_any_le (vector bool int, vector signed int);
15374 int vec_any_le (vector signed int, vector bool int);
15375 int vec_any_le (vector signed int, vector signed int);
15376 int vec_any_le (vector float, vector float);
15378 int vec_any_lt (vector bool char, vector unsigned char);
15379 int vec_any_lt (vector unsigned char, vector bool char);
15380 int vec_any_lt (vector unsigned char, vector unsigned char);
15381 int vec_any_lt (vector bool char, vector signed char);
15382 int vec_any_lt (vector signed char, vector bool char);
15383 int vec_any_lt (vector signed char, vector signed char);
15384 int vec_any_lt (vector bool short, vector unsigned short);
15385 int vec_any_lt (vector unsigned short, vector bool short);
15386 int vec_any_lt (vector unsigned short, vector unsigned short);
15387 int vec_any_lt (vector bool short, vector signed short);
15388 int vec_any_lt (vector signed short, vector bool short);
15389 int vec_any_lt (vector signed short, vector signed short);
15390 int vec_any_lt (vector bool int, vector unsigned int);
15391 int vec_any_lt (vector unsigned int, vector bool int);
15392 int vec_any_lt (vector unsigned int, vector unsigned int);
15393 int vec_any_lt (vector bool int, vector signed int);
15394 int vec_any_lt (vector signed int, vector bool int);
15395 int vec_any_lt (vector signed int, vector signed int);
15396 int vec_any_lt (vector float, vector float);
15398 int vec_any_nan (vector float);
15400 int vec_any_ne (vector signed char, vector bool char);
15401 int vec_any_ne (vector signed char, vector signed char);
15402 int vec_any_ne (vector unsigned char, vector bool char);
15403 int vec_any_ne (vector unsigned char, vector unsigned char);
15404 int vec_any_ne (vector bool char, vector bool char);
15405 int vec_any_ne (vector bool char, vector unsigned char);
15406 int vec_any_ne (vector bool char, vector signed char);
15407 int vec_any_ne (vector signed short, vector bool short);
15408 int vec_any_ne (vector signed short, vector signed short);
15409 int vec_any_ne (vector unsigned short, vector bool short);
15410 int vec_any_ne (vector unsigned short, vector unsigned short);
15411 int vec_any_ne (vector bool short, vector bool short);
15412 int vec_any_ne (vector bool short, vector unsigned short);
15413 int vec_any_ne (vector bool short, vector signed short);
15414 int vec_any_ne (vector pixel, vector pixel);
15415 int vec_any_ne (vector signed int, vector bool int);
15416 int vec_any_ne (vector signed int, vector signed int);
15417 int vec_any_ne (vector unsigned int, vector bool int);
15418 int vec_any_ne (vector unsigned int, vector unsigned int);
15419 int vec_any_ne (vector bool int, vector bool int);
15420 int vec_any_ne (vector bool int, vector unsigned int);
15421 int vec_any_ne (vector bool int, vector signed int);
15422 int vec_any_ne (vector float, vector float);
15424 int vec_any_nge (vector float, vector float);
15426 int vec_any_ngt (vector float, vector float);
15428 int vec_any_nle (vector float, vector float);
15430 int vec_any_nlt (vector float, vector float);
15432 int vec_any_numeric (vector float);
15434 int vec_any_out (vector float, vector float);
15435 @end smallexample
15437 If the vector/scalar (VSX) instruction set is available, the following
15438 additional functions are available:
15440 @smallexample
15441 vector double vec_abs (vector double);
15442 vector double vec_add (vector double, vector double);
15443 vector double vec_and (vector double, vector double);
15444 vector double vec_and (vector double, vector bool long);
15445 vector double vec_and (vector bool long, vector double);
15446 vector long vec_and (vector long, vector long);
15447 vector long vec_and (vector long, vector bool long);
15448 vector long vec_and (vector bool long, vector long);
15449 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15450 vector unsigned long vec_and (vector unsigned long, vector bool long);
15451 vector unsigned long vec_and (vector bool long, vector unsigned long);
15452 vector double vec_andc (vector double, vector double);
15453 vector double vec_andc (vector double, vector bool long);
15454 vector double vec_andc (vector bool long, vector double);
15455 vector long vec_andc (vector long, vector long);
15456 vector long vec_andc (vector long, vector bool long);
15457 vector long vec_andc (vector bool long, vector long);
15458 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15459 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15460 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15461 vector double vec_ceil (vector double);
15462 vector bool long vec_cmpeq (vector double, vector double);
15463 vector bool long vec_cmpge (vector double, vector double);
15464 vector bool long vec_cmpgt (vector double, vector double);
15465 vector bool long vec_cmple (vector double, vector double);
15466 vector bool long vec_cmplt (vector double, vector double);
15467 vector double vec_cpsgn (vector double, vector double);
15468 vector float vec_div (vector float, vector float);
15469 vector double vec_div (vector double, vector double);
15470 vector long vec_div (vector long, vector long);
15471 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15472 vector double vec_floor (vector double);
15473 vector double vec_ld (int, const vector double *);
15474 vector double vec_ld (int, const double *);
15475 vector double vec_ldl (int, const vector double *);
15476 vector double vec_ldl (int, const double *);
15477 vector unsigned char vec_lvsl (int, const volatile double *);
15478 vector unsigned char vec_lvsr (int, const volatile double *);
15479 vector double vec_madd (vector double, vector double, vector double);
15480 vector double vec_max (vector double, vector double);
15481 vector signed long vec_mergeh (vector signed long, vector signed long);
15482 vector signed long vec_mergeh (vector signed long, vector bool long);
15483 vector signed long vec_mergeh (vector bool long, vector signed long);
15484 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15485 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15486 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15487 vector signed long vec_mergel (vector signed long, vector signed long);
15488 vector signed long vec_mergel (vector signed long, vector bool long);
15489 vector signed long vec_mergel (vector bool long, vector signed long);
15490 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15491 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15492 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15493 vector double vec_min (vector double, vector double);
15494 vector float vec_msub (vector float, vector float, vector float);
15495 vector double vec_msub (vector double, vector double, vector double);
15496 vector float vec_mul (vector float, vector float);
15497 vector double vec_mul (vector double, vector double);
15498 vector long vec_mul (vector long, vector long);
15499 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15500 vector float vec_nearbyint (vector float);
15501 vector double vec_nearbyint (vector double);
15502 vector float vec_nmadd (vector float, vector float, vector float);
15503 vector double vec_nmadd (vector double, vector double, vector double);
15504 vector double vec_nmsub (vector double, vector double, vector double);
15505 vector double vec_nor (vector double, vector double);
15506 vector long vec_nor (vector long, vector long);
15507 vector long vec_nor (vector long, vector bool long);
15508 vector long vec_nor (vector bool long, vector long);
15509 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15510 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15511 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15512 vector double vec_or (vector double, vector double);
15513 vector double vec_or (vector double, vector bool long);
15514 vector double vec_or (vector bool long, vector double);
15515 vector long vec_or (vector long, vector long);
15516 vector long vec_or (vector long, vector bool long);
15517 vector long vec_or (vector bool long, vector long);
15518 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15519 vector unsigned long vec_or (vector unsigned long, vector bool long);
15520 vector unsigned long vec_or (vector bool long, vector unsigned long);
15521 vector double vec_perm (vector double, vector double, vector unsigned char);
15522 vector long vec_perm (vector long, vector long, vector unsigned char);
15523 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15524                                vector unsigned char);
15525 vector double vec_rint (vector double);
15526 vector double vec_recip (vector double, vector double);
15527 vector double vec_rsqrt (vector double);
15528 vector double vec_rsqrte (vector double);
15529 vector double vec_sel (vector double, vector double, vector bool long);
15530 vector double vec_sel (vector double, vector double, vector unsigned long);
15531 vector long vec_sel (vector long, vector long, vector long);
15532 vector long vec_sel (vector long, vector long, vector unsigned long);
15533 vector long vec_sel (vector long, vector long, vector bool long);
15534 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15535                               vector long);
15536 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15537                               vector unsigned long);
15538 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15539                               vector bool long);
15540 vector double vec_splats (double);
15541 vector signed long vec_splats (signed long);
15542 vector unsigned long vec_splats (unsigned long);
15543 vector float vec_sqrt (vector float);
15544 vector double vec_sqrt (vector double);
15545 void vec_st (vector double, int, vector double *);
15546 void vec_st (vector double, int, double *);
15547 vector double vec_sub (vector double, vector double);
15548 vector double vec_trunc (vector double);
15549 vector double vec_xor (vector double, vector double);
15550 vector double vec_xor (vector double, vector bool long);
15551 vector double vec_xor (vector bool long, vector double);
15552 vector long vec_xor (vector long, vector long);
15553 vector long vec_xor (vector long, vector bool long);
15554 vector long vec_xor (vector bool long, vector long);
15555 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15556 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15557 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15558 int vec_all_eq (vector double, vector double);
15559 int vec_all_ge (vector double, vector double);
15560 int vec_all_gt (vector double, vector double);
15561 int vec_all_le (vector double, vector double);
15562 int vec_all_lt (vector double, vector double);
15563 int vec_all_nan (vector double);
15564 int vec_all_ne (vector double, vector double);
15565 int vec_all_nge (vector double, vector double);
15566 int vec_all_ngt (vector double, vector double);
15567 int vec_all_nle (vector double, vector double);
15568 int vec_all_nlt (vector double, vector double);
15569 int vec_all_numeric (vector double);
15570 int vec_any_eq (vector double, vector double);
15571 int vec_any_ge (vector double, vector double);
15572 int vec_any_gt (vector double, vector double);
15573 int vec_any_le (vector double, vector double);
15574 int vec_any_lt (vector double, vector double);
15575 int vec_any_nan (vector double);
15576 int vec_any_ne (vector double, vector double);
15577 int vec_any_nge (vector double, vector double);
15578 int vec_any_ngt (vector double, vector double);
15579 int vec_any_nle (vector double, vector double);
15580 int vec_any_nlt (vector double, vector double);
15581 int vec_any_numeric (vector double);
15583 vector double vec_vsx_ld (int, const vector double *);
15584 vector double vec_vsx_ld (int, const double *);
15585 vector float vec_vsx_ld (int, const vector float *);
15586 vector float vec_vsx_ld (int, const float *);
15587 vector bool int vec_vsx_ld (int, const vector bool int *);
15588 vector signed int vec_vsx_ld (int, const vector signed int *);
15589 vector signed int vec_vsx_ld (int, const int *);
15590 vector signed int vec_vsx_ld (int, const long *);
15591 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15592 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15593 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15594 vector bool short vec_vsx_ld (int, const vector bool short *);
15595 vector pixel vec_vsx_ld (int, const vector pixel *);
15596 vector signed short vec_vsx_ld (int, const vector signed short *);
15597 vector signed short vec_vsx_ld (int, const short *);
15598 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15599 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15600 vector bool char vec_vsx_ld (int, const vector bool char *);
15601 vector signed char vec_vsx_ld (int, const vector signed char *);
15602 vector signed char vec_vsx_ld (int, const signed char *);
15603 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15604 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15606 void vec_vsx_st (vector double, int, vector double *);
15607 void vec_vsx_st (vector double, int, double *);
15608 void vec_vsx_st (vector float, int, vector float *);
15609 void vec_vsx_st (vector float, int, float *);
15610 void vec_vsx_st (vector signed int, int, vector signed int *);
15611 void vec_vsx_st (vector signed int, int, int *);
15612 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15613 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15614 void vec_vsx_st (vector bool int, int, vector bool int *);
15615 void vec_vsx_st (vector bool int, int, unsigned int *);
15616 void vec_vsx_st (vector bool int, int, int *);
15617 void vec_vsx_st (vector signed short, int, vector signed short *);
15618 void vec_vsx_st (vector signed short, int, short *);
15619 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15620 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15621 void vec_vsx_st (vector bool short, int, vector bool short *);
15622 void vec_vsx_st (vector bool short, int, unsigned short *);
15623 void vec_vsx_st (vector pixel, int, vector pixel *);
15624 void vec_vsx_st (vector pixel, int, unsigned short *);
15625 void vec_vsx_st (vector pixel, int, short *);
15626 void vec_vsx_st (vector bool short, int, short *);
15627 void vec_vsx_st (vector signed char, int, vector signed char *);
15628 void vec_vsx_st (vector signed char, int, signed char *);
15629 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15630 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15631 void vec_vsx_st (vector bool char, int, vector bool char *);
15632 void vec_vsx_st (vector bool char, int, unsigned char *);
15633 void vec_vsx_st (vector bool char, int, signed char *);
15635 vector double vec_xxpermdi (vector double, vector double, int);
15636 vector float vec_xxpermdi (vector float, vector float, int);
15637 vector long long vec_xxpermdi (vector long long, vector long long, int);
15638 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15639                                         vector unsigned long long, int);
15640 vector int vec_xxpermdi (vector int, vector int, int);
15641 vector unsigned int vec_xxpermdi (vector unsigned int,
15642                                   vector unsigned int, int);
15643 vector short vec_xxpermdi (vector short, vector short, int);
15644 vector unsigned short vec_xxpermdi (vector unsigned short,
15645                                     vector unsigned short, int);
15646 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15647 vector unsigned char vec_xxpermdi (vector unsigned char,
15648                                    vector unsigned char, int);
15650 vector double vec_xxsldi (vector double, vector double, int);
15651 vector float vec_xxsldi (vector float, vector float, int);
15652 vector long long vec_xxsldi (vector long long, vector long long, int);
15653 vector unsigned long long vec_xxsldi (vector unsigned long long,
15654                                       vector unsigned long long, int);
15655 vector int vec_xxsldi (vector int, vector int, int);
15656 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15657 vector short vec_xxsldi (vector short, vector short, int);
15658 vector unsigned short vec_xxsldi (vector unsigned short,
15659                                   vector unsigned short, int);
15660 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15661 vector unsigned char vec_xxsldi (vector unsigned char,
15662                                  vector unsigned char, int);
15663 @end smallexample
15665 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15666 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15667 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
15668 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15669 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15671 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15672 instruction set is available, the following additional functions are
15673 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
15674 can use @var{vector long} instead of @var{vector long long},
15675 @var{vector bool long} instead of @var{vector bool long long}, and
15676 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15678 @smallexample
15679 vector long long vec_abs (vector long long);
15681 vector long long vec_add (vector long long, vector long long);
15682 vector unsigned long long vec_add (vector unsigned long long,
15683                                    vector unsigned long long);
15685 int vec_all_eq (vector long long, vector long long);
15686 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15687 int vec_all_ge (vector long long, vector long long);
15688 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15689 int vec_all_gt (vector long long, vector long long);
15690 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15691 int vec_all_le (vector long long, vector long long);
15692 int vec_all_le (vector unsigned long long, vector unsigned long long);
15693 int vec_all_lt (vector long long, vector long long);
15694 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15695 int vec_all_ne (vector long long, vector long long);
15696 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15698 int vec_any_eq (vector long long, vector long long);
15699 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15700 int vec_any_ge (vector long long, vector long long);
15701 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15702 int vec_any_gt (vector long long, vector long long);
15703 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15704 int vec_any_le (vector long long, vector long long);
15705 int vec_any_le (vector unsigned long long, vector unsigned long long);
15706 int vec_any_lt (vector long long, vector long long);
15707 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15708 int vec_any_ne (vector long long, vector long long);
15709 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15711 vector long long vec_eqv (vector long long, vector long long);
15712 vector long long vec_eqv (vector bool long long, vector long long);
15713 vector long long vec_eqv (vector long long, vector bool long long);
15714 vector unsigned long long vec_eqv (vector unsigned long long,
15715                                    vector unsigned long long);
15716 vector unsigned long long vec_eqv (vector bool long long,
15717                                    vector unsigned long long);
15718 vector unsigned long long vec_eqv (vector unsigned long long,
15719                                    vector bool long long);
15720 vector int vec_eqv (vector int, vector int);
15721 vector int vec_eqv (vector bool int, vector int);
15722 vector int vec_eqv (vector int, vector bool int);
15723 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15724 vector unsigned int vec_eqv (vector bool unsigned int,
15725                              vector unsigned int);
15726 vector unsigned int vec_eqv (vector unsigned int,
15727                              vector bool unsigned int);
15728 vector short vec_eqv (vector short, vector short);
15729 vector short vec_eqv (vector bool short, vector short);
15730 vector short vec_eqv (vector short, vector bool short);
15731 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15732 vector unsigned short vec_eqv (vector bool unsigned short,
15733                                vector unsigned short);
15734 vector unsigned short vec_eqv (vector unsigned short,
15735                                vector bool unsigned short);
15736 vector signed char vec_eqv (vector signed char, vector signed char);
15737 vector signed char vec_eqv (vector bool signed char, vector signed char);
15738 vector signed char vec_eqv (vector signed char, vector bool signed char);
15739 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15740 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15741 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15743 vector long long vec_max (vector long long, vector long long);
15744 vector unsigned long long vec_max (vector unsigned long long,
15745                                    vector unsigned long long);
15747 vector signed int vec_mergee (vector signed int, vector signed int);
15748 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15749 vector bool int vec_mergee (vector bool int, vector bool int);
15751 vector signed int vec_mergeo (vector signed int, vector signed int);
15752 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15753 vector bool int vec_mergeo (vector bool int, vector bool int);
15755 vector long long vec_min (vector long long, vector long long);
15756 vector unsigned long long vec_min (vector unsigned long long,
15757                                    vector unsigned long long);
15759 vector long long vec_nand (vector long long, vector long long);
15760 vector long long vec_nand (vector bool long long, vector long long);
15761 vector long long vec_nand (vector long long, vector bool long long);
15762 vector unsigned long long vec_nand (vector unsigned long long,
15763                                     vector unsigned long long);
15764 vector unsigned long long vec_nand (vector bool long long,
15765                                    vector unsigned long long);
15766 vector unsigned long long vec_nand (vector unsigned long long,
15767                                     vector bool long long);
15768 vector int vec_nand (vector int, vector int);
15769 vector int vec_nand (vector bool int, vector int);
15770 vector int vec_nand (vector int, vector bool int);
15771 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15772 vector unsigned int vec_nand (vector bool unsigned int,
15773                               vector unsigned int);
15774 vector unsigned int vec_nand (vector unsigned int,
15775                               vector bool unsigned int);
15776 vector short vec_nand (vector short, vector short);
15777 vector short vec_nand (vector bool short, vector short);
15778 vector short vec_nand (vector short, vector bool short);
15779 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15780 vector unsigned short vec_nand (vector bool unsigned short,
15781                                 vector unsigned short);
15782 vector unsigned short vec_nand (vector unsigned short,
15783                                 vector bool unsigned short);
15784 vector signed char vec_nand (vector signed char, vector signed char);
15785 vector signed char vec_nand (vector bool signed char, vector signed char);
15786 vector signed char vec_nand (vector signed char, vector bool signed char);
15787 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15788 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15789 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15791 vector long long vec_orc (vector long long, vector long long);
15792 vector long long vec_orc (vector bool long long, vector long long);
15793 vector long long vec_orc (vector long long, vector bool long long);
15794 vector unsigned long long vec_orc (vector unsigned long long,
15795                                    vector unsigned long long);
15796 vector unsigned long long vec_orc (vector bool long long,
15797                                    vector unsigned long long);
15798 vector unsigned long long vec_orc (vector unsigned long long,
15799                                    vector bool long long);
15800 vector int vec_orc (vector int, vector int);
15801 vector int vec_orc (vector bool int, vector int);
15802 vector int vec_orc (vector int, vector bool int);
15803 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15804 vector unsigned int vec_orc (vector bool unsigned int,
15805                              vector unsigned int);
15806 vector unsigned int vec_orc (vector unsigned int,
15807                              vector bool unsigned int);
15808 vector short vec_orc (vector short, vector short);
15809 vector short vec_orc (vector bool short, vector short);
15810 vector short vec_orc (vector short, vector bool short);
15811 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15812 vector unsigned short vec_orc (vector bool unsigned short,
15813                                vector unsigned short);
15814 vector unsigned short vec_orc (vector unsigned short,
15815                                vector bool unsigned short);
15816 vector signed char vec_orc (vector signed char, vector signed char);
15817 vector signed char vec_orc (vector bool signed char, vector signed char);
15818 vector signed char vec_orc (vector signed char, vector bool signed char);
15819 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15820 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15821 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15823 vector int vec_pack (vector long long, vector long long);
15824 vector unsigned int vec_pack (vector unsigned long long,
15825                               vector unsigned long long);
15826 vector bool int vec_pack (vector bool long long, vector bool long long);
15828 vector int vec_packs (vector long long, vector long long);
15829 vector unsigned int vec_packs (vector unsigned long long,
15830                                vector unsigned long long);
15832 vector unsigned int vec_packsu (vector long long, vector long long);
15833 vector unsigned int vec_packsu (vector unsigned long long,
15834                                 vector unsigned long long);
15836 vector long long vec_rl (vector long long,
15837                          vector unsigned long long);
15838 vector long long vec_rl (vector unsigned long long,
15839                          vector unsigned long long);
15841 vector long long vec_sl (vector long long, vector unsigned long long);
15842 vector long long vec_sl (vector unsigned long long,
15843                          vector unsigned long long);
15845 vector long long vec_sr (vector long long, vector unsigned long long);
15846 vector unsigned long long char vec_sr (vector unsigned long long,
15847                                        vector unsigned long long);
15849 vector long long vec_sra (vector long long, vector unsigned long long);
15850 vector unsigned long long vec_sra (vector unsigned long long,
15851                                    vector unsigned long long);
15853 vector long long vec_sub (vector long long, vector long long);
15854 vector unsigned long long vec_sub (vector unsigned long long,
15855                                    vector unsigned long long);
15857 vector long long vec_unpackh (vector int);
15858 vector unsigned long long vec_unpackh (vector unsigned int);
15860 vector long long vec_unpackl (vector int);
15861 vector unsigned long long vec_unpackl (vector unsigned int);
15863 vector long long vec_vaddudm (vector long long, vector long long);
15864 vector long long vec_vaddudm (vector bool long long, vector long long);
15865 vector long long vec_vaddudm (vector long long, vector bool long long);
15866 vector unsigned long long vec_vaddudm (vector unsigned long long,
15867                                        vector unsigned long long);
15868 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15869                                        vector unsigned long long);
15870 vector unsigned long long vec_vaddudm (vector unsigned long long,
15871                                        vector bool unsigned long long);
15873 vector long long vec_vbpermq (vector signed char, vector signed char);
15874 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15876 vector long long vec_cntlz (vector long long);
15877 vector unsigned long long vec_cntlz (vector unsigned long long);
15878 vector int vec_cntlz (vector int);
15879 vector unsigned int vec_cntlz (vector int);
15880 vector short vec_cntlz (vector short);
15881 vector unsigned short vec_cntlz (vector unsigned short);
15882 vector signed char vec_cntlz (vector signed char);
15883 vector unsigned char vec_cntlz (vector unsigned char);
15885 vector long long vec_vclz (vector long long);
15886 vector unsigned long long vec_vclz (vector unsigned long long);
15887 vector int vec_vclz (vector int);
15888 vector unsigned int vec_vclz (vector int);
15889 vector short vec_vclz (vector short);
15890 vector unsigned short vec_vclz (vector unsigned short);
15891 vector signed char vec_vclz (vector signed char);
15892 vector unsigned char vec_vclz (vector unsigned char);
15894 vector signed char vec_vclzb (vector signed char);
15895 vector unsigned char vec_vclzb (vector unsigned char);
15897 vector long long vec_vclzd (vector long long);
15898 vector unsigned long long vec_vclzd (vector unsigned long long);
15900 vector short vec_vclzh (vector short);
15901 vector unsigned short vec_vclzh (vector unsigned short);
15903 vector int vec_vclzw (vector int);
15904 vector unsigned int vec_vclzw (vector int);
15906 vector signed char vec_vgbbd (vector signed char);
15907 vector unsigned char vec_vgbbd (vector unsigned char);
15909 vector long long vec_vmaxsd (vector long long, vector long long);
15911 vector unsigned long long vec_vmaxud (vector unsigned long long,
15912                                       unsigned vector long long);
15914 vector long long vec_vminsd (vector long long, vector long long);
15916 vector unsigned long long vec_vminud (vector long long,
15917                                       vector long long);
15919 vector int vec_vpksdss (vector long long, vector long long);
15920 vector unsigned int vec_vpksdss (vector long long, vector long long);
15922 vector unsigned int vec_vpkudus (vector unsigned long long,
15923                                  vector unsigned long long);
15925 vector int vec_vpkudum (vector long long, vector long long);
15926 vector unsigned int vec_vpkudum (vector unsigned long long,
15927                                  vector unsigned long long);
15928 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15930 vector long long vec_vpopcnt (vector long long);
15931 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15932 vector int vec_vpopcnt (vector int);
15933 vector unsigned int vec_vpopcnt (vector int);
15934 vector short vec_vpopcnt (vector short);
15935 vector unsigned short vec_vpopcnt (vector unsigned short);
15936 vector signed char vec_vpopcnt (vector signed char);
15937 vector unsigned char vec_vpopcnt (vector unsigned char);
15939 vector signed char vec_vpopcntb (vector signed char);
15940 vector unsigned char vec_vpopcntb (vector unsigned char);
15942 vector long long vec_vpopcntd (vector long long);
15943 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15945 vector short vec_vpopcnth (vector short);
15946 vector unsigned short vec_vpopcnth (vector unsigned short);
15948 vector int vec_vpopcntw (vector int);
15949 vector unsigned int vec_vpopcntw (vector int);
15951 vector long long vec_vrld (vector long long, vector unsigned long long);
15952 vector unsigned long long vec_vrld (vector unsigned long long,
15953                                     vector unsigned long long);
15955 vector long long vec_vsld (vector long long, vector unsigned long long);
15956 vector long long vec_vsld (vector unsigned long long,
15957                            vector unsigned long long);
15959 vector long long vec_vsrad (vector long long, vector unsigned long long);
15960 vector unsigned long long vec_vsrad (vector unsigned long long,
15961                                      vector unsigned long long);
15963 vector long long vec_vsrd (vector long long, vector unsigned long long);
15964 vector unsigned long long char vec_vsrd (vector unsigned long long,
15965                                          vector unsigned long long);
15967 vector long long vec_vsubudm (vector long long, vector long long);
15968 vector long long vec_vsubudm (vector bool long long, vector long long);
15969 vector long long vec_vsubudm (vector long long, vector bool long long);
15970 vector unsigned long long vec_vsubudm (vector unsigned long long,
15971                                        vector unsigned long long);
15972 vector unsigned long long vec_vsubudm (vector bool long long,
15973                                        vector unsigned long long);
15974 vector unsigned long long vec_vsubudm (vector unsigned long long,
15975                                        vector bool long long);
15977 vector long long vec_vupkhsw (vector int);
15978 vector unsigned long long vec_vupkhsw (vector unsigned int);
15980 vector long long vec_vupklsw (vector int);
15981 vector unsigned long long vec_vupklsw (vector int);
15982 @end smallexample
15984 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15985 instruction set is available, the following additional functions are
15986 available for 64-bit targets.  New vector types
15987 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15988 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15989 builtins.
15991 The normal vector extract, and set operations work on
15992 @var{vector __int128_t} and @var{vector __uint128_t} types,
15993 but the index value must be 0.
15995 @smallexample
15996 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15997 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15999 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16000 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16002 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16003                                 vector __int128_t);
16004 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
16005                                  vector __uint128_t);
16007 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16008                                 vector __int128_t);
16009 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
16010                                  vector __uint128_t);
16012 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16013                                 vector __int128_t);
16014 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
16015                                  vector __uint128_t);
16017 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16018                                 vector __int128_t);
16019 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16020                                  vector __uint128_t);
16022 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16023 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16025 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16026 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16028 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16029 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16030 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16031 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16032 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16033 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16034 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16035 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16036 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16037 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16038 @end smallexample
16040 If the cryptographic instructions are enabled (@option{-mcrypto} or
16041 @option{-mcpu=power8}), the following builtins are enabled.
16043 @smallexample
16044 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16046 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16047                                                     vector unsigned long long);
16049 vector unsigned long long __builtin_crypto_vcipherlast
16050                                      (vector unsigned long long,
16051                                       vector unsigned long long);
16053 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16054                                                      vector unsigned long long);
16056 vector unsigned long long __builtin_crypto_vncipherlast
16057                                      (vector unsigned long long,
16058                                       vector unsigned long long);
16060 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16061                                                 vector unsigned char,
16062                                                 vector unsigned char);
16064 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16065                                                  vector unsigned short,
16066                                                  vector unsigned short);
16068 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16069                                                vector unsigned int,
16070                                                vector unsigned int);
16072 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16073                                                      vector unsigned long long,
16074                                                      vector unsigned long long);
16076 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16077                                                vector unsigned char);
16079 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16080                                                 vector unsigned short);
16082 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16083                                               vector unsigned int);
16085 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16086                                                     vector unsigned long long);
16088 vector unsigned long long __builtin_crypto_vshasigmad
16089                                (vector unsigned long long, int, int);
16091 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16092                                                  int, int);
16093 @end smallexample
16095 The second argument to the @var{__builtin_crypto_vshasigmad} and
16096 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16097 integer that is 0 or 1.  The third argument to these builtin functions
16098 must be a constant integer in the range of 0 to 15.
16100 @node PowerPC Hardware Transactional Memory Built-in Functions
16101 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16102 GCC provides two interfaces for accessing the Hardware Transactional
16103 Memory (HTM) instructions available on some of the PowerPC family
16104 of prcoessors (eg, POWER8).  The two interfaces come in a low level
16105 interface, consisting of built-in functions specific to PowerPC and a
16106 higher level interface consisting of inline functions that are common
16107 between PowerPC and S/390.
16109 @subsubsection PowerPC HTM Low Level Built-in Functions
16111 The following low level built-in functions are available with
16112 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16113 They all generate the machine instruction that is part of the name.
16115 The HTM built-ins return true or false depending on their success and
16116 their arguments match exactly the type and order of the associated
16117 hardware instruction's operands.  Refer to the ISA manual for a
16118 description of each instruction's operands.
16120 @smallexample
16121 unsigned int __builtin_tbegin (unsigned int)
16122 unsigned int __builtin_tend (unsigned int)
16124 unsigned int __builtin_tabort (unsigned int)
16125 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16126 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16127 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16128 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16130 unsigned int __builtin_tcheck (unsigned int)
16131 unsigned int __builtin_treclaim (unsigned int)
16132 unsigned int __builtin_trechkpt (void)
16133 unsigned int __builtin_tsr (unsigned int)
16134 @end smallexample
16136 In addition to the above HTM built-ins, we have added built-ins for
16137 some common extended mnemonics of the HTM instructions:
16139 @smallexample
16140 unsigned int __builtin_tendall (void)
16141 unsigned int __builtin_tresume (void)
16142 unsigned int __builtin_tsuspend (void)
16143 @end smallexample
16145 The following set of built-in functions are available to gain access
16146 to the HTM specific special purpose registers.
16148 @smallexample
16149 unsigned long __builtin_get_texasr (void)
16150 unsigned long __builtin_get_texasru (void)
16151 unsigned long __builtin_get_tfhar (void)
16152 unsigned long __builtin_get_tfiar (void)
16154 void __builtin_set_texasr (unsigned long);
16155 void __builtin_set_texasru (unsigned long);
16156 void __builtin_set_tfhar (unsigned long);
16157 void __builtin_set_tfiar (unsigned long);
16158 @end smallexample
16160 Example usage of these low level built-in functions may look like:
16162 @smallexample
16163 #include <htmintrin.h>
16165 int num_retries = 10;
16167 while (1)
16168   @{
16169     if (__builtin_tbegin (0))
16170       @{
16171         /* Transaction State Initiated.  */
16172         if (is_locked (lock))
16173           __builtin_tabort (0);
16174         ... transaction code...
16175         __builtin_tend (0);
16176         break;
16177       @}
16178     else
16179       @{
16180         /* Transaction State Failed.  Use locks if the transaction
16181            failure is "persistent" or we've tried too many times.  */
16182         if (num_retries-- <= 0
16183             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16184           @{
16185             acquire_lock (lock);
16186             ... non transactional fallback path...
16187             release_lock (lock);
16188             break;
16189           @}
16190       @}
16191   @}
16192 @end smallexample
16194 One final built-in function has been added that returns the value of
16195 the 2-bit Transaction State field of the Machine Status Register (MSR)
16196 as stored in @code{CR0}.
16198 @smallexample
16199 unsigned long __builtin_ttest (void)
16200 @end smallexample
16202 This built-in can be used to determine the current transaction state
16203 using the following code example:
16205 @smallexample
16206 #include <htmintrin.h>
16208 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16210 if (tx_state == _HTM_TRANSACTIONAL)
16211   @{
16212     /* Code to use in transactional state.  */
16213   @}
16214 else if (tx_state == _HTM_NONTRANSACTIONAL)
16215   @{
16216     /* Code to use in non-transactional state.  */
16217   @}
16218 else if (tx_state == _HTM_SUSPENDED)
16219   @{
16220     /* Code to use in transaction suspended state.  */
16221   @}
16222 @end smallexample
16224 @subsubsection PowerPC HTM High Level Inline Functions
16226 The following high level HTM interface is made available by including
16227 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16228 where CPU is `power8' or later.  This interface is common between PowerPC
16229 and S/390, allowing users to write one HTM source implementation that
16230 can be compiled and executed on either system.
16232 @smallexample
16233 long __TM_simple_begin (void)
16234 long __TM_begin (void* const TM_buff)
16235 long __TM_end (void)
16236 void __TM_abort (void)
16237 void __TM_named_abort (unsigned char const code)
16238 void __TM_resume (void)
16239 void __TM_suspend (void)
16241 long __TM_is_user_abort (void* const TM_buff)
16242 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16243 long __TM_is_illegal (void* const TM_buff)
16244 long __TM_is_footprint_exceeded (void* const TM_buff)
16245 long __TM_nesting_depth (void* const TM_buff)
16246 long __TM_is_nested_too_deep(void* const TM_buff)
16247 long __TM_is_conflict(void* const TM_buff)
16248 long __TM_is_failure_persistent(void* const TM_buff)
16249 long __TM_failure_address(void* const TM_buff)
16250 long long __TM_failure_code(void* const TM_buff)
16251 @end smallexample
16253 Using these common set of HTM inline functions, we can create
16254 a more portable version of the HTM example in the previous
16255 section that will work on either PowerPC or S/390:
16257 @smallexample
16258 #include <htmxlintrin.h>
16260 int num_retries = 10;
16261 TM_buff_type TM_buff;
16263 while (1)
16264   @{
16265     if (__TM_begin (TM_buff))
16266       @{
16267         /* Transaction State Initiated.  */
16268         if (is_locked (lock))
16269           __TM_abort ();
16270         ... transaction code...
16271         __TM_end ();
16272         break;
16273       @}
16274     else
16275       @{
16276         /* Transaction State Failed.  Use locks if the transaction
16277            failure is "persistent" or we've tried too many times.  */
16278         if (num_retries-- <= 0
16279             || __TM_is_failure_persistent (TM_buff))
16280           @{
16281             acquire_lock (lock);
16282             ... non transactional fallback path...
16283             release_lock (lock);
16284             break;
16285           @}
16286       @}
16287   @}
16288 @end smallexample
16290 @node RX Built-in Functions
16291 @subsection RX Built-in Functions
16292 GCC supports some of the RX instructions which cannot be expressed in
16293 the C programming language via the use of built-in functions.  The
16294 following functions are supported:
16296 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
16297 Generates the @code{brk} machine instruction.
16298 @end deftypefn
16300 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
16301 Generates the @code{clrpsw} machine instruction to clear the specified
16302 bit in the processor status word.
16303 @end deftypefn
16305 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
16306 Generates the @code{int} machine instruction to generate an interrupt
16307 with the specified value.
16308 @end deftypefn
16310 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
16311 Generates the @code{machi} machine instruction to add the result of
16312 multiplying the top 16 bits of the two arguments into the
16313 accumulator.
16314 @end deftypefn
16316 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
16317 Generates the @code{maclo} machine instruction to add the result of
16318 multiplying the bottom 16 bits of the two arguments into the
16319 accumulator.
16320 @end deftypefn
16322 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
16323 Generates the @code{mulhi} machine instruction to place the result of
16324 multiplying the top 16 bits of the two arguments into the
16325 accumulator.
16326 @end deftypefn
16328 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
16329 Generates the @code{mullo} machine instruction to place the result of
16330 multiplying the bottom 16 bits of the two arguments into the
16331 accumulator.
16332 @end deftypefn
16334 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
16335 Generates the @code{mvfachi} machine instruction to read the top
16336 32 bits of the accumulator.
16337 @end deftypefn
16339 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
16340 Generates the @code{mvfacmi} machine instruction to read the middle
16341 32 bits of the accumulator.
16342 @end deftypefn
16344 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
16345 Generates the @code{mvfc} machine instruction which reads the control
16346 register specified in its argument and returns its value.
16347 @end deftypefn
16349 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
16350 Generates the @code{mvtachi} machine instruction to set the top
16351 32 bits of the accumulator.
16352 @end deftypefn
16354 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
16355 Generates the @code{mvtaclo} machine instruction to set the bottom
16356 32 bits of the accumulator.
16357 @end deftypefn
16359 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
16360 Generates the @code{mvtc} machine instruction which sets control
16361 register number @code{reg} to @code{val}.
16362 @end deftypefn
16364 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
16365 Generates the @code{mvtipl} machine instruction set the interrupt
16366 priority level.
16367 @end deftypefn
16369 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
16370 Generates the @code{racw} machine instruction to round the accumulator
16371 according to the specified mode.
16372 @end deftypefn
16374 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
16375 Generates the @code{revw} machine instruction which swaps the bytes in
16376 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16377 and also bits 16--23 occupy bits 24--31 and vice versa.
16378 @end deftypefn
16380 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
16381 Generates the @code{rmpa} machine instruction which initiates a
16382 repeated multiply and accumulate sequence.
16383 @end deftypefn
16385 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
16386 Generates the @code{round} machine instruction which returns the
16387 floating-point argument rounded according to the current rounding mode
16388 set in the floating-point status word register.
16389 @end deftypefn
16391 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
16392 Generates the @code{sat} machine instruction which returns the
16393 saturated value of the argument.
16394 @end deftypefn
16396 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
16397 Generates the @code{setpsw} machine instruction to set the specified
16398 bit in the processor status word.
16399 @end deftypefn
16401 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
16402 Generates the @code{wait} machine instruction.
16403 @end deftypefn
16405 @node S/390 System z Built-in Functions
16406 @subsection S/390 System z Built-in Functions
16407 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16408 Generates the @code{tbegin} machine instruction starting a
16409 non-constraint hardware transaction.  If the parameter is non-NULL the
16410 memory area is used to store the transaction diagnostic buffer and
16411 will be passed as first operand to @code{tbegin}.  This buffer can be
16412 defined using the @code{struct __htm_tdb} C struct defined in
16413 @code{htmintrin.h} and must reside on a double-word boundary.  The
16414 second tbegin operand is set to @code{0xff0c}. This enables
16415 save/restore of all GPRs and disables aborts for FPR and AR
16416 manipulations inside the transaction body.  The condition code set by
16417 the tbegin instruction is returned as integer value.  The tbegin
16418 instruction by definition overwrites the content of all FPRs.  The
16419 compiler will generate code which saves and restores the FPRs.  For
16420 soft-float code it is recommended to used the @code{*_nofloat}
16421 variant.  In order to prevent a TDB from being written it is required
16422 to pass an constant zero value as parameter.  Passing the zero value
16423 through a variable is not sufficient.  Although modifications of
16424 access registers inside the transaction will not trigger an
16425 transaction abort it is not supported to actually modify them.  Access
16426 registers do not get saved when entering a transaction. They will have
16427 undefined state when reaching the abort code.
16428 @end deftypefn
16430 Macros for the possible return codes of tbegin are defined in the
16431 @code{htmintrin.h} header file:
16433 @table @code
16434 @item _HTM_TBEGIN_STARTED
16435 @code{tbegin} has been executed as part of normal processing.  The
16436 transaction body is supposed to be executed.
16437 @item _HTM_TBEGIN_INDETERMINATE
16438 The transaction was aborted due to an indeterminate condition which
16439 might be persistent.
16440 @item _HTM_TBEGIN_TRANSIENT
16441 The transaction aborted due to a transient failure.  The transaction
16442 should be re-executed in that case.
16443 @item _HTM_TBEGIN_PERSISTENT
16444 The transaction aborted due to a persistent failure.  Re-execution
16445 under same circumstances will not be productive.
16446 @end table
16448 @defmac _HTM_FIRST_USER_ABORT_CODE
16449 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16450 specifies the first abort code which can be used for
16451 @code{__builtin_tabort}.  Values below this threshold are reserved for
16452 machine use.
16453 @end defmac
16455 @deftp {Data type} {struct __htm_tdb}
16456 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16457 the structure of the transaction diagnostic block as specified in the
16458 Principles of Operation manual chapter 5-91.
16459 @end deftp
16461 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16462 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16463 Using this variant in code making use of FPRs will leave the FPRs in
16464 undefined state when entering the transaction abort handler code.
16465 @end deftypefn
16467 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16468 In addition to @code{__builtin_tbegin} a loop for transient failures
16469 is generated.  If tbegin returns a condition code of 2 the transaction
16470 will be retried as often as specified in the second argument.  The
16471 perform processor assist instruction is used to tell the CPU about the
16472 number of fails so far.
16473 @end deftypefn
16475 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16476 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16477 restores.  Using this variant in code making use of FPRs will leave
16478 the FPRs in undefined state when entering the transaction abort
16479 handler code.
16480 @end deftypefn
16482 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16483 Generates the @code{tbeginc} machine instruction starting a constraint
16484 hardware transaction.  The second operand is set to @code{0xff08}.
16485 @end deftypefn
16487 @deftypefn {Built-in Function} int __builtin_tend (void)
16488 Generates the @code{tend} machine instruction finishing a transaction
16489 and making the changes visible to other threads.  The condition code
16490 generated by tend is returned as integer value.
16491 @end deftypefn
16493 @deftypefn {Built-in Function} void __builtin_tabort (int)
16494 Generates the @code{tabort} machine instruction with the specified
16495 abort code.  Abort codes from 0 through 255 are reserved and will
16496 result in an error message.
16497 @end deftypefn
16499 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16500 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
16501 integer parameter is loaded into rX and a value of zero is loaded into
16502 rY.  The integer parameter specifies the number of times the
16503 transaction repeatedly aborted.
16504 @end deftypefn
16506 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16507 Generates the @code{etnd} machine instruction.  The current nesting
16508 depth is returned as integer value.  For a nesting depth of 0 the code
16509 is not executed as part of an transaction.
16510 @end deftypefn
16512 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16514 Generates the @code{ntstg} machine instruction.  The second argument
16515 is written to the first arguments location.  The store operation will
16516 not be rolled-back in case of an transaction abort.
16517 @end deftypefn
16519 @node SH Built-in Functions
16520 @subsection SH Built-in Functions
16521 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16522 families of processors:
16524 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16525 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
16526 used by system code that manages threads and execution contexts.  The compiler
16527 normally does not generate code that modifies the contents of @samp{GBR} and
16528 thus the value is preserved across function calls.  Changing the @samp{GBR}
16529 value in user code must be done with caution, since the compiler might use
16530 @samp{GBR} in order to access thread local variables.
16532 @end deftypefn
16534 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16535 Returns the value that is currently set in the @samp{GBR} register.
16536 Memory loads and stores that use the thread pointer as a base address are
16537 turned into @samp{GBR} based displacement loads and stores, if possible.
16538 For example:
16539 @smallexample
16540 struct my_tcb
16542    int a, b, c, d, e;
16545 int get_tcb_value (void)
16547   // Generate @samp{mov.l @@(8,gbr),r0} instruction
16548   return ((my_tcb*)__builtin_thread_pointer ())->c;
16551 @end smallexample
16552 @end deftypefn
16554 @node SPARC VIS Built-in Functions
16555 @subsection SPARC VIS Built-in Functions
16557 GCC supports SIMD operations on the SPARC using both the generic vector
16558 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16559 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
16560 switch, the VIS extension is exposed as the following built-in functions:
16562 @smallexample
16563 typedef int v1si __attribute__ ((vector_size (4)));
16564 typedef int v2si __attribute__ ((vector_size (8)));
16565 typedef short v4hi __attribute__ ((vector_size (8)));
16566 typedef short v2hi __attribute__ ((vector_size (4)));
16567 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16568 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16570 void __builtin_vis_write_gsr (int64_t);
16571 int64_t __builtin_vis_read_gsr (void);
16573 void * __builtin_vis_alignaddr (void *, long);
16574 void * __builtin_vis_alignaddrl (void *, long);
16575 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16576 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16577 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16578 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16580 v4hi __builtin_vis_fexpand (v4qi);
16582 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16583 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16584 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16585 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16586 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16587 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16588 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16590 v4qi __builtin_vis_fpack16 (v4hi);
16591 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16592 v2hi __builtin_vis_fpackfix (v2si);
16593 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16595 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16597 long __builtin_vis_edge8 (void *, void *);
16598 long __builtin_vis_edge8l (void *, void *);
16599 long __builtin_vis_edge16 (void *, void *);
16600 long __builtin_vis_edge16l (void *, void *);
16601 long __builtin_vis_edge32 (void *, void *);
16602 long __builtin_vis_edge32l (void *, void *);
16604 long __builtin_vis_fcmple16 (v4hi, v4hi);
16605 long __builtin_vis_fcmple32 (v2si, v2si);
16606 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16607 long __builtin_vis_fcmpne32 (v2si, v2si);
16608 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16609 long __builtin_vis_fcmpgt32 (v2si, v2si);
16610 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16611 long __builtin_vis_fcmpeq32 (v2si, v2si);
16613 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16614 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16615 v2si __builtin_vis_fpadd32 (v2si, v2si);
16616 v1si __builtin_vis_fpadd32s (v1si, v1si);
16617 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16618 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16619 v2si __builtin_vis_fpsub32 (v2si, v2si);
16620 v1si __builtin_vis_fpsub32s (v1si, v1si);
16622 long __builtin_vis_array8 (long, long);
16623 long __builtin_vis_array16 (long, long);
16624 long __builtin_vis_array32 (long, long);
16625 @end smallexample
16627 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16628 functions also become available:
16630 @smallexample
16631 long __builtin_vis_bmask (long, long);
16632 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16633 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16634 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16635 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16637 long __builtin_vis_edge8n (void *, void *);
16638 long __builtin_vis_edge8ln (void *, void *);
16639 long __builtin_vis_edge16n (void *, void *);
16640 long __builtin_vis_edge16ln (void *, void *);
16641 long __builtin_vis_edge32n (void *, void *);
16642 long __builtin_vis_edge32ln (void *, void *);
16643 @end smallexample
16645 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16646 functions also become available:
16648 @smallexample
16649 void __builtin_vis_cmask8 (long);
16650 void __builtin_vis_cmask16 (long);
16651 void __builtin_vis_cmask32 (long);
16653 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16655 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16656 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16657 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16658 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16659 v2si __builtin_vis_fsll16 (v2si, v2si);
16660 v2si __builtin_vis_fslas16 (v2si, v2si);
16661 v2si __builtin_vis_fsrl16 (v2si, v2si);
16662 v2si __builtin_vis_fsra16 (v2si, v2si);
16664 long __builtin_vis_pdistn (v8qi, v8qi);
16666 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16668 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16669 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16671 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16672 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16673 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16674 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16675 v2si __builtin_vis_fpadds32 (v2si, v2si);
16676 v1si __builtin_vis_fpadds32s (v1si, v1si);
16677 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16678 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16680 long __builtin_vis_fucmple8 (v8qi, v8qi);
16681 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16682 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16683 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16685 float __builtin_vis_fhadds (float, float);
16686 double __builtin_vis_fhaddd (double, double);
16687 float __builtin_vis_fhsubs (float, float);
16688 double __builtin_vis_fhsubd (double, double);
16689 float __builtin_vis_fnhadds (float, float);
16690 double __builtin_vis_fnhaddd (double, double);
16692 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16693 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16694 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16695 @end smallexample
16697 @node SPU Built-in Functions
16698 @subsection SPU Built-in Functions
16700 GCC provides extensions for the SPU processor as described in the
16701 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16702 found at @uref{http://cell.scei.co.jp/} or
16703 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
16704 implementation differs in several ways.
16706 @itemize @bullet
16708 @item
16709 The optional extension of specifying vector constants in parentheses is
16710 not supported.
16712 @item
16713 A vector initializer requires no cast if the vector constant is of the
16714 same type as the variable it is initializing.
16716 @item
16717 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16718 vector type is the default signedness of the base type.  The default
16719 varies depending on the operating system, so a portable program should
16720 always specify the signedness.
16722 @item
16723 By default, the keyword @code{__vector} is added. The macro
16724 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16725 undefined.
16727 @item
16728 GCC allows using a @code{typedef} name as the type specifier for a
16729 vector type.
16731 @item
16732 For C, overloaded functions are implemented with macros so the following
16733 does not work:
16735 @smallexample
16736   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16737 @end smallexample
16739 @noindent
16740 Since @code{spu_add} is a macro, the vector constant in the example
16741 is treated as four separate arguments.  Wrap the entire argument in
16742 parentheses for this to work.
16744 @item
16745 The extended version of @code{__builtin_expect} is not supported.
16747 @end itemize
16749 @emph{Note:} Only the interface described in the aforementioned
16750 specification is supported. Internally, GCC uses built-in functions to
16751 implement the required functionality, but these are not supported and
16752 are subject to change without notice.
16754 @node TI C6X Built-in Functions
16755 @subsection TI C6X Built-in Functions
16757 GCC provides intrinsics to access certain instructions of the TI C6X
16758 processors.  These intrinsics, listed below, are available after
16759 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
16760 to C6X instructions.
16762 @smallexample
16764 int _sadd (int, int)
16765 int _ssub (int, int)
16766 int _sadd2 (int, int)
16767 int _ssub2 (int, int)
16768 long long _mpy2 (int, int)
16769 long long _smpy2 (int, int)
16770 int _add4 (int, int)
16771 int _sub4 (int, int)
16772 int _saddu4 (int, int)
16774 int _smpy (int, int)
16775 int _smpyh (int, int)
16776 int _smpyhl (int, int)
16777 int _smpylh (int, int)
16779 int _sshl (int, int)
16780 int _subc (int, int)
16782 int _avg2 (int, int)
16783 int _avgu4 (int, int)
16785 int _clrr (int, int)
16786 int _extr (int, int)
16787 int _extru (int, int)
16788 int _abs (int)
16789 int _abs2 (int)
16791 @end smallexample
16793 @node TILE-Gx Built-in Functions
16794 @subsection TILE-Gx Built-in Functions
16796 GCC provides intrinsics to access every instruction of the TILE-Gx
16797 processor.  The intrinsics are of the form:
16799 @smallexample
16801 unsigned long long __insn_@var{op} (...)
16803 @end smallexample
16805 Where @var{op} is the name of the instruction.  Refer to the ISA manual
16806 for the complete list of instructions.
16808 GCC also provides intrinsics to directly access the network registers.
16809 The intrinsics are:
16811 @smallexample
16813 unsigned long long __tile_idn0_receive (void)
16814 unsigned long long __tile_idn1_receive (void)
16815 unsigned long long __tile_udn0_receive (void)
16816 unsigned long long __tile_udn1_receive (void)
16817 unsigned long long __tile_udn2_receive (void)
16818 unsigned long long __tile_udn3_receive (void)
16819 void __tile_idn_send (unsigned long long)
16820 void __tile_udn_send (unsigned long long)
16822 @end smallexample
16824 The intrinsic @code{void __tile_network_barrier (void)} is used to
16825 guarantee that no network operations before it are reordered with
16826 those after it.
16828 @node TILEPro Built-in Functions
16829 @subsection TILEPro Built-in Functions
16831 GCC provides intrinsics to access every instruction of the TILEPro
16832 processor.  The intrinsics are of the form:
16834 @smallexample
16836 unsigned __insn_@var{op} (...)
16838 @end smallexample
16840 @noindent
16841 where @var{op} is the name of the instruction.  Refer to the ISA manual
16842 for the complete list of instructions.
16844 GCC also provides intrinsics to directly access the network registers.
16845 The intrinsics are:
16847 @smallexample
16849 unsigned __tile_idn0_receive (void)
16850 unsigned __tile_idn1_receive (void)
16851 unsigned __tile_sn_receive (void)
16852 unsigned __tile_udn0_receive (void)
16853 unsigned __tile_udn1_receive (void)
16854 unsigned __tile_udn2_receive (void)
16855 unsigned __tile_udn3_receive (void)
16856 void __tile_idn_send (unsigned)
16857 void __tile_sn_send (unsigned)
16858 void __tile_udn_send (unsigned)
16860 @end smallexample
16862 The intrinsic @code{void __tile_network_barrier (void)} is used to
16863 guarantee that no network operations before it are reordered with
16864 those after it.
16866 @node Target Format Checks
16867 @section Format Checks Specific to Particular Target Machines
16869 For some target machines, GCC supports additional options to the
16870 format attribute
16871 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
16873 @menu
16874 * Solaris Format Checks::
16875 * Darwin Format Checks::
16876 @end menu
16878 @node Solaris Format Checks
16879 @subsection Solaris Format Checks
16881 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
16882 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
16883 conversions, and the two-argument @code{%b} conversion for displaying
16884 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
16886 @node Darwin Format Checks
16887 @subsection Darwin Format Checks
16889 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
16890 attribute context.  Declarations made with such attribution are parsed for correct syntax
16891 and format argument types.  However, parsing of the format string itself is currently undefined
16892 and is not carried out by this version of the compiler.
16894 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
16895 also be used as format arguments.  Note that the relevant headers are only likely to be
16896 available on Darwin (OSX) installations.  On such installations, the XCode and system
16897 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
16898 associated functions.
16900 @node Pragmas
16901 @section Pragmas Accepted by GCC
16902 @cindex pragmas
16903 @cindex @code{#pragma}
16905 GCC supports several types of pragmas, primarily in order to compile
16906 code originally written for other compilers.  Note that in general
16907 we do not recommend the use of pragmas; @xref{Function Attributes},
16908 for further explanation.
16910 @menu
16911 * ARM Pragmas::
16912 * M32C Pragmas::
16913 * MeP Pragmas::
16914 * RS/6000 and PowerPC Pragmas::
16915 * Darwin Pragmas::
16916 * Solaris Pragmas::
16917 * Symbol-Renaming Pragmas::
16918 * Structure-Packing Pragmas::
16919 * Weak Pragmas::
16920 * Diagnostic Pragmas::
16921 * Visibility Pragmas::
16922 * Push/Pop Macro Pragmas::
16923 * Function Specific Option Pragmas::
16924 * Loop-Specific Pragmas::
16925 @end menu
16927 @node ARM Pragmas
16928 @subsection ARM Pragmas
16930 The ARM target defines pragmas for controlling the default addition of
16931 @code{long_call} and @code{short_call} attributes to functions.
16932 @xref{Function Attributes}, for information about the effects of these
16933 attributes.
16935 @table @code
16936 @item long_calls
16937 @cindex pragma, long_calls
16938 Set all subsequent functions to have the @code{long_call} attribute.
16940 @item no_long_calls
16941 @cindex pragma, no_long_calls
16942 Set all subsequent functions to have the @code{short_call} attribute.
16944 @item long_calls_off
16945 @cindex pragma, long_calls_off
16946 Do not affect the @code{long_call} or @code{short_call} attributes of
16947 subsequent functions.
16948 @end table
16950 @node M32C Pragmas
16951 @subsection M32C Pragmas
16953 @table @code
16954 @item GCC memregs @var{number}
16955 @cindex pragma, memregs
16956 Overrides the command-line option @code{-memregs=} for the current
16957 file.  Use with care!  This pragma must be before any function in the
16958 file, and mixing different memregs values in different objects may
16959 make them incompatible.  This pragma is useful when a
16960 performance-critical function uses a memreg for temporary values,
16961 as it may allow you to reduce the number of memregs used.
16963 @item ADDRESS @var{name} @var{address}
16964 @cindex pragma, address
16965 For any declared symbols matching @var{name}, this does three things
16966 to that symbol: it forces the symbol to be located at the given
16967 address (a number), it forces the symbol to be volatile, and it
16968 changes the symbol's scope to be static.  This pragma exists for
16969 compatibility with other compilers, but note that the common
16970 @code{1234H} numeric syntax is not supported (use @code{0x1234}
16971 instead).  Example:
16973 @smallexample
16974 #pragma ADDRESS port3 0x103
16975 char port3;
16976 @end smallexample
16978 @end table
16980 @node MeP Pragmas
16981 @subsection MeP Pragmas
16983 @table @code
16985 @item custom io_volatile (on|off)
16986 @cindex pragma, custom io_volatile
16987 Overrides the command-line option @code{-mio-volatile} for the current
16988 file.  Note that for compatibility with future GCC releases, this
16989 option should only be used once before any @code{io} variables in each
16990 file.
16992 @item GCC coprocessor available @var{registers}
16993 @cindex pragma, coprocessor available
16994 Specifies which coprocessor registers are available to the register
16995 allocator.  @var{registers} may be a single register, register range
16996 separated by ellipses, or comma-separated list of those.  Example:
16998 @smallexample
16999 #pragma GCC coprocessor available $c0...$c10, $c28
17000 @end smallexample
17002 @item GCC coprocessor call_saved @var{registers}
17003 @cindex pragma, coprocessor call_saved
17004 Specifies which coprocessor registers are to be saved and restored by
17005 any function using them.  @var{registers} may be a single register,
17006 register range separated by ellipses, or comma-separated list of
17007 those.  Example:
17009 @smallexample
17010 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17011 @end smallexample
17013 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17014 @cindex pragma, coprocessor subclass
17015 Creates and defines a register class.  These register classes can be
17016 used by inline @code{asm} constructs.  @var{registers} may be a single
17017 register, register range separated by ellipses, or comma-separated
17018 list of those.  Example:
17020 @smallexample
17021 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17023 asm ("cpfoo %0" : "=B" (x));
17024 @end smallexample
17026 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17027 @cindex pragma, disinterrupt
17028 For the named functions, the compiler adds code to disable interrupts
17029 for the duration of those functions.  If any functions so named 
17030 are not encountered in the source, a warning is emitted that the pragma is
17031 not used.  Examples:
17033 @smallexample
17034 #pragma disinterrupt foo
17035 #pragma disinterrupt bar, grill
17036 int foo () @{ @dots{} @}
17037 @end smallexample
17039 @item GCC call @var{name} , @var{name} @dots{}
17040 @cindex pragma, call
17041 For the named functions, the compiler always uses a register-indirect
17042 call model when calling the named functions.  Examples:
17044 @smallexample
17045 extern int foo ();
17046 #pragma call foo
17047 @end smallexample
17049 @end table
17051 @node RS/6000 and PowerPC Pragmas
17052 @subsection RS/6000 and PowerPC Pragmas
17054 The RS/6000 and PowerPC targets define one pragma for controlling
17055 whether or not the @code{longcall} attribute is added to function
17056 declarations by default.  This pragma overrides the @option{-mlongcall}
17057 option, but not the @code{longcall} and @code{shortcall} attributes.
17058 @xref{RS/6000 and PowerPC Options}, for more information about when long
17059 calls are and are not necessary.
17061 @table @code
17062 @item longcall (1)
17063 @cindex pragma, longcall
17064 Apply the @code{longcall} attribute to all subsequent function
17065 declarations.
17067 @item longcall (0)
17068 Do not apply the @code{longcall} attribute to subsequent function
17069 declarations.
17070 @end table
17072 @c Describe h8300 pragmas here.
17073 @c Describe sh pragmas here.
17074 @c Describe v850 pragmas here.
17076 @node Darwin Pragmas
17077 @subsection Darwin Pragmas
17079 The following pragmas are available for all architectures running the
17080 Darwin operating system.  These are useful for compatibility with other
17081 Mac OS compilers.
17083 @table @code
17084 @item mark @var{tokens}@dots{}
17085 @cindex pragma, mark
17086 This pragma is accepted, but has no effect.
17088 @item options align=@var{alignment}
17089 @cindex pragma, options align
17090 This pragma sets the alignment of fields in structures.  The values of
17091 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17092 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17093 properly; to restore the previous setting, use @code{reset} for the
17094 @var{alignment}.
17096 @item segment @var{tokens}@dots{}
17097 @cindex pragma, segment
17098 This pragma is accepted, but has no effect.
17100 @item unused (@var{var} [, @var{var}]@dots{})
17101 @cindex pragma, unused
17102 This pragma declares variables to be possibly unused.  GCC does not
17103 produce warnings for the listed variables.  The effect is similar to
17104 that of the @code{unused} attribute, except that this pragma may appear
17105 anywhere within the variables' scopes.
17106 @end table
17108 @node Solaris Pragmas
17109 @subsection Solaris Pragmas
17111 The Solaris target supports @code{#pragma redefine_extname}
17112 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17113 @code{#pragma} directives for compatibility with the system compiler.
17115 @table @code
17116 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17117 @cindex pragma, align
17119 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17120 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17121 Attributes}).  Macro expansion occurs on the arguments to this pragma
17122 when compiling C and Objective-C@.  It does not currently occur when
17123 compiling C++, but this is a bug which may be fixed in a future
17124 release.
17126 @item fini (@var{function} [, @var{function}]...)
17127 @cindex pragma, fini
17129 This pragma causes each listed @var{function} to be called after
17130 main, or during shared module unloading, by adding a call to the
17131 @code{.fini} section.
17133 @item init (@var{function} [, @var{function}]...)
17134 @cindex pragma, init
17136 This pragma causes each listed @var{function} to be called during
17137 initialization (before @code{main}) or during shared module loading, by
17138 adding a call to the @code{.init} section.
17140 @end table
17142 @node Symbol-Renaming Pragmas
17143 @subsection Symbol-Renaming Pragmas
17145 GCC supports a @code{#pragma} directive that changes the name used in
17146 assembly for a given declaration. This effect can also be achieved
17147 using the asm labels extension (@pxref{Asm Labels}).
17149 @table @code
17150 @item redefine_extname @var{oldname} @var{newname}
17151 @cindex pragma, redefine_extname
17153 This pragma gives the C function @var{oldname} the assembly symbol
17154 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17155 is defined if this pragma is available (currently on all platforms).
17156 @end table
17158 This pragma and the asm labels extension interact in a complicated
17159 manner.  Here are some corner cases you may want to be aware of:
17161 @enumerate
17162 @item This pragma silently applies only to declarations with external
17163 linkage.  Asm labels do not have this restriction.
17165 @item In C++, this pragma silently applies only to declarations with
17166 ``C'' linkage.  Again, asm labels do not have this restriction.
17168 @item If either of the ways of changing the assembly name of a
17169 declaration are applied to a declaration whose assembly name has
17170 already been determined (either by a previous use of one of these
17171 features, or because the compiler needed the assembly name in order to
17172 generate code), and the new name is different, a warning issues and
17173 the name does not change.
17175 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17176 always the C-language name.
17177 @end enumerate
17179 @node Structure-Packing Pragmas
17180 @subsection Structure-Packing Pragmas
17182 For compatibility with Microsoft Windows compilers, GCC supports a
17183 set of @code{#pragma} directives that change the maximum alignment of
17184 members of structures (other than zero-width bit-fields), unions, and
17185 classes subsequently defined. The @var{n} value below always is required
17186 to be a small power of two and specifies the new alignment in bytes.
17188 @enumerate
17189 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17190 @item @code{#pragma pack()} sets the alignment to the one that was in
17191 effect when compilation started (see also command-line option
17192 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17193 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17194 setting on an internal stack and then optionally sets the new alignment.
17195 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17196 saved at the top of the internal stack (and removes that stack entry).
17197 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17198 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17199 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17200 @code{#pragma pack(pop)}.
17201 @end enumerate
17203 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
17204 @code{#pragma} which lays out a structure as the documented
17205 @code{__attribute__ ((ms_struct))}.
17206 @enumerate
17207 @item @code{#pragma ms_struct on} turns on the layout for structures
17208 declared.
17209 @item @code{#pragma ms_struct off} turns off the layout for structures
17210 declared.
17211 @item @code{#pragma ms_struct reset} goes back to the default layout.
17212 @end enumerate
17214 @node Weak Pragmas
17215 @subsection Weak Pragmas
17217 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17218 directives for declaring symbols to be weak, and defining weak
17219 aliases.
17221 @table @code
17222 @item #pragma weak @var{symbol}
17223 @cindex pragma, weak
17224 This pragma declares @var{symbol} to be weak, as if the declaration
17225 had the attribute of the same name.  The pragma may appear before
17226 or after the declaration of @var{symbol}.  It is not an error for
17227 @var{symbol} to never be defined at all.
17229 @item #pragma weak @var{symbol1} = @var{symbol2}
17230 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17231 It is an error if @var{symbol2} is not defined in the current
17232 translation unit.
17233 @end table
17235 @node Diagnostic Pragmas
17236 @subsection Diagnostic Pragmas
17238 GCC allows the user to selectively enable or disable certain types of
17239 diagnostics, and change the kind of the diagnostic.  For example, a
17240 project's policy might require that all sources compile with
17241 @option{-Werror} but certain files might have exceptions allowing
17242 specific types of warnings.  Or, a project might selectively enable
17243 diagnostics and treat them as errors depending on which preprocessor
17244 macros are defined.
17246 @table @code
17247 @item #pragma GCC diagnostic @var{kind} @var{option}
17248 @cindex pragma, diagnostic
17250 Modifies the disposition of a diagnostic.  Note that not all
17251 diagnostics are modifiable; at the moment only warnings (normally
17252 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17253 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17254 are controllable and which option controls them.
17256 @var{kind} is @samp{error} to treat this diagnostic as an error,
17257 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17258 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17259 @var{option} is a double quoted string that matches the command-line
17260 option.
17262 @smallexample
17263 #pragma GCC diagnostic warning "-Wformat"
17264 #pragma GCC diagnostic error "-Wformat"
17265 #pragma GCC diagnostic ignored "-Wformat"
17266 @end smallexample
17268 Note that these pragmas override any command-line options.  GCC keeps
17269 track of the location of each pragma, and issues diagnostics according
17270 to the state as of that point in the source file.  Thus, pragmas occurring
17271 after a line do not affect diagnostics caused by that line.
17273 @item #pragma GCC diagnostic push
17274 @itemx #pragma GCC diagnostic pop
17276 Causes GCC to remember the state of the diagnostics as of each
17277 @code{push}, and restore to that point at each @code{pop}.  If a
17278 @code{pop} has no matching @code{push}, the command-line options are
17279 restored.
17281 @smallexample
17282 #pragma GCC diagnostic error "-Wuninitialized"
17283   foo(a);                       /* error is given for this one */
17284 #pragma GCC diagnostic push
17285 #pragma GCC diagnostic ignored "-Wuninitialized"
17286   foo(b);                       /* no diagnostic for this one */
17287 #pragma GCC diagnostic pop
17288   foo(c);                       /* error is given for this one */
17289 #pragma GCC diagnostic pop
17290   foo(d);                       /* depends on command-line options */
17291 @end smallexample
17293 @end table
17295 GCC also offers a simple mechanism for printing messages during
17296 compilation.
17298 @table @code
17299 @item #pragma message @var{string}
17300 @cindex pragma, diagnostic
17302 Prints @var{string} as a compiler message on compilation.  The message
17303 is informational only, and is neither a compilation warning nor an error.
17305 @smallexample
17306 #pragma message "Compiling " __FILE__ "..."
17307 @end smallexample
17309 @var{string} may be parenthesized, and is printed with location
17310 information.  For example,
17312 @smallexample
17313 #define DO_PRAGMA(x) _Pragma (#x)
17314 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17316 TODO(Remember to fix this)
17317 @end smallexample
17319 @noindent
17320 prints @samp{/tmp/file.c:4: note: #pragma message:
17321 TODO - Remember to fix this}.
17323 @end table
17325 @node Visibility Pragmas
17326 @subsection Visibility Pragmas
17328 @table @code
17329 @item #pragma GCC visibility push(@var{visibility})
17330 @itemx #pragma GCC visibility pop
17331 @cindex pragma, visibility
17333 This pragma allows the user to set the visibility for multiple
17334 declarations without having to give each a visibility attribute
17335 (@pxref{Function Attributes}).
17337 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17338 declarations.  Class members and template specializations are not
17339 affected; if you want to override the visibility for a particular
17340 member or instantiation, you must use an attribute.
17342 @end table
17345 @node Push/Pop Macro Pragmas
17346 @subsection Push/Pop Macro Pragmas
17348 For compatibility with Microsoft Windows compilers, GCC supports
17349 @samp{#pragma push_macro(@var{"macro_name"})}
17350 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17352 @table @code
17353 @item #pragma push_macro(@var{"macro_name"})
17354 @cindex pragma, push_macro
17355 This pragma saves the value of the macro named as @var{macro_name} to
17356 the top of the stack for this macro.
17358 @item #pragma pop_macro(@var{"macro_name"})
17359 @cindex pragma, pop_macro
17360 This pragma sets the value of the macro named as @var{macro_name} to
17361 the value on top of the stack for this macro. If the stack for
17362 @var{macro_name} is empty, the value of the macro remains unchanged.
17363 @end table
17365 For example:
17367 @smallexample
17368 #define X  1
17369 #pragma push_macro("X")
17370 #undef X
17371 #define X -1
17372 #pragma pop_macro("X")
17373 int x [X];
17374 @end smallexample
17376 @noindent
17377 In this example, the definition of X as 1 is saved by @code{#pragma
17378 push_macro} and restored by @code{#pragma pop_macro}.
17380 @node Function Specific Option Pragmas
17381 @subsection Function Specific Option Pragmas
17383 @table @code
17384 @item #pragma GCC target (@var{"string"}...)
17385 @cindex pragma GCC target
17387 This pragma allows you to set target specific options for functions
17388 defined later in the source file.  One or more strings can be
17389 specified.  Each function that is defined after this point is as
17390 if @code{attribute((target("STRING")))} was specified for that
17391 function.  The parenthesis around the options is optional.
17392 @xref{Function Attributes}, for more information about the
17393 @code{target} attribute and the attribute syntax.
17395 The @code{#pragma GCC target} pragma is presently implemented for
17396 i386/x86_64, PowerPC, and Nios II targets only.
17397 @end table
17399 @table @code
17400 @item #pragma GCC optimize (@var{"string"}...)
17401 @cindex pragma GCC optimize
17403 This pragma allows you to set global optimization options for functions
17404 defined later in the source file.  One or more strings can be
17405 specified.  Each function that is defined after this point is as
17406 if @code{attribute((optimize("STRING")))} was specified for that
17407 function.  The parenthesis around the options is optional.
17408 @xref{Function Attributes}, for more information about the
17409 @code{optimize} attribute and the attribute syntax.
17411 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17412 versions earlier than 4.4.
17413 @end table
17415 @table @code
17416 @item #pragma GCC push_options
17417 @itemx #pragma GCC pop_options
17418 @cindex pragma GCC push_options
17419 @cindex pragma GCC pop_options
17421 These pragmas maintain a stack of the current target and optimization
17422 options.  It is intended for include files where you temporarily want
17423 to switch to using a different @samp{#pragma GCC target} or
17424 @samp{#pragma GCC optimize} and then to pop back to the previous
17425 options.
17427 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17428 pragmas are not implemented in GCC versions earlier than 4.4.
17429 @end table
17431 @table @code
17432 @item #pragma GCC reset_options
17433 @cindex pragma GCC reset_options
17435 This pragma clears the current @code{#pragma GCC target} and
17436 @code{#pragma GCC optimize} to use the default switches as specified
17437 on the command line.
17439 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17440 versions earlier than 4.4.
17441 @end table
17443 @node Loop-Specific Pragmas
17444 @subsection Loop-Specific Pragmas
17446 @table @code
17447 @item #pragma GCC ivdep
17448 @cindex pragma GCC ivdep
17449 @end table
17451 With this pragma, the programmer asserts that there are no loop-carried
17452 dependencies which would prevent that consecutive iterations of
17453 the following loop can be executed concurrently with SIMD
17454 (single instruction multiple data) instructions.
17456 For example, the compiler can only unconditionally vectorize the following
17457 loop with the pragma:
17459 @smallexample
17460 void foo (int n, int *a, int *b, int *c)
17462   int i, j;
17463 #pragma GCC ivdep
17464   for (i = 0; i < n; ++i)
17465     a[i] = b[i] + c[i];
17467 @end smallexample
17469 @noindent
17470 In this example, using the @code{restrict} qualifier had the same
17471 effect. In the following example, that would not be possible. Assume
17472 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17473 that it can unconditionally vectorize the following loop:
17475 @smallexample
17476 void ignore_vec_dep (int *a, int k, int c, int m)
17478 #pragma GCC ivdep
17479   for (int i = 0; i < m; i++)
17480     a[i] = a[i + k] * c;
17482 @end smallexample
17485 @node Unnamed Fields
17486 @section Unnamed struct/union fields within structs/unions
17487 @cindex @code{struct}
17488 @cindex @code{union}
17490 As permitted by ISO C11 and for compatibility with other compilers,
17491 GCC allows you to define
17492 a structure or union that contains, as fields, structures and unions
17493 without names.  For example:
17495 @smallexample
17496 struct @{
17497   int a;
17498   union @{
17499     int b;
17500     float c;
17501   @};
17502   int d;
17503 @} foo;
17504 @end smallexample
17506 @noindent
17507 In this example, you are able to access members of the unnamed
17508 union with code like @samp{foo.b}.  Note that only unnamed structs and
17509 unions are allowed, you may not have, for example, an unnamed
17510 @code{int}.
17512 You must never create such structures that cause ambiguous field definitions.
17513 For example, in this structure:
17515 @smallexample
17516 struct @{
17517   int a;
17518   struct @{
17519     int a;
17520   @};
17521 @} foo;
17522 @end smallexample
17524 @noindent
17525 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17526 The compiler gives errors for such constructs.
17528 @opindex fms-extensions
17529 Unless @option{-fms-extensions} is used, the unnamed field must be a
17530 structure or union definition without a tag (for example, @samp{struct
17531 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17532 also be a definition with a tag such as @samp{struct foo @{ int a;
17533 @};}, a reference to a previously defined structure or union such as
17534 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17535 previously defined structure or union type.
17537 @opindex fplan9-extensions
17538 The option @option{-fplan9-extensions} enables
17539 @option{-fms-extensions} as well as two other extensions.  First, a
17540 pointer to a structure is automatically converted to a pointer to an
17541 anonymous field for assignments and function calls.  For example:
17543 @smallexample
17544 struct s1 @{ int a; @};
17545 struct s2 @{ struct s1; @};
17546 extern void f1 (struct s1 *);
17547 void f2 (struct s2 *p) @{ f1 (p); @}
17548 @end smallexample
17550 @noindent
17551 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17552 converted into a pointer to the anonymous field.
17554 Second, when the type of an anonymous field is a @code{typedef} for a
17555 @code{struct} or @code{union}, code may refer to the field using the
17556 name of the @code{typedef}.
17558 @smallexample
17559 typedef struct @{ int a; @} s1;
17560 struct s2 @{ s1; @};
17561 s1 f1 (struct s2 *p) @{ return p->s1; @}
17562 @end smallexample
17564 These usages are only permitted when they are not ambiguous.
17566 @node Thread-Local
17567 @section Thread-Local Storage
17568 @cindex Thread-Local Storage
17569 @cindex @acronym{TLS}
17570 @cindex @code{__thread}
17572 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17573 are allocated such that there is one instance of the variable per extant
17574 thread.  The runtime model GCC uses to implement this originates
17575 in the IA-64 processor-specific ABI, but has since been migrated
17576 to other processors as well.  It requires significant support from
17577 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17578 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17579 is not available everywhere.
17581 At the user level, the extension is visible with a new storage
17582 class keyword: @code{__thread}.  For example:
17584 @smallexample
17585 __thread int i;
17586 extern __thread struct state s;
17587 static __thread char *p;
17588 @end smallexample
17590 The @code{__thread} specifier may be used alone, with the @code{extern}
17591 or @code{static} specifiers, but with no other storage class specifier.
17592 When used with @code{extern} or @code{static}, @code{__thread} must appear
17593 immediately after the other storage class specifier.
17595 The @code{__thread} specifier may be applied to any global, file-scoped
17596 static, function-scoped static, or static data member of a class.  It may
17597 not be applied to block-scoped automatic or non-static data member.
17599 When the address-of operator is applied to a thread-local variable, it is
17600 evaluated at run time and returns the address of the current thread's
17601 instance of that variable.  An address so obtained may be used by any
17602 thread.  When a thread terminates, any pointers to thread-local variables
17603 in that thread become invalid.
17605 No static initialization may refer to the address of a thread-local variable.
17607 In C++, if an initializer is present for a thread-local variable, it must
17608 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
17609 standard.
17611 See @uref{http://www.akkadia.org/drepper/tls.pdf,
17612 ELF Handling For Thread-Local Storage} for a detailed explanation of
17613 the four thread-local storage addressing models, and how the runtime
17614 is expected to function.
17616 @menu
17617 * C99 Thread-Local Edits::
17618 * C++98 Thread-Local Edits::
17619 @end menu
17621 @node C99 Thread-Local Edits
17622 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
17624 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
17625 that document the exact semantics of the language extension.
17627 @itemize @bullet
17628 @item
17629 @cite{5.1.2  Execution environments}
17631 Add new text after paragraph 1
17633 @quotation
17634 Within either execution environment, a @dfn{thread} is a flow of
17635 control within a program.  It is implementation defined whether
17636 or not there may be more than one thread associated with a program.
17637 It is implementation defined how threads beyond the first are
17638 created, the name and type of the function called at thread
17639 startup, and how threads may be terminated.  However, objects
17640 with thread storage duration shall be initialized before thread
17641 startup.
17642 @end quotation
17644 @item
17645 @cite{6.2.4  Storage durations of objects}
17647 Add new text before paragraph 3
17649 @quotation
17650 An object whose identifier is declared with the storage-class
17651 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
17652 Its lifetime is the entire execution of the thread, and its
17653 stored value is initialized only once, prior to thread startup.
17654 @end quotation
17656 @item
17657 @cite{6.4.1  Keywords}
17659 Add @code{__thread}.
17661 @item
17662 @cite{6.7.1  Storage-class specifiers}
17664 Add @code{__thread} to the list of storage class specifiers in
17665 paragraph 1.
17667 Change paragraph 2 to
17669 @quotation
17670 With the exception of @code{__thread}, at most one storage-class
17671 specifier may be given [@dots{}].  The @code{__thread} specifier may
17672 be used alone, or immediately following @code{extern} or
17673 @code{static}.
17674 @end quotation
17676 Add new text after paragraph 6
17678 @quotation
17679 The declaration of an identifier for a variable that has
17680 block scope that specifies @code{__thread} shall also
17681 specify either @code{extern} or @code{static}.
17683 The @code{__thread} specifier shall be used only with
17684 variables.
17685 @end quotation
17686 @end itemize
17688 @node C++98 Thread-Local Edits
17689 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
17691 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
17692 that document the exact semantics of the language extension.
17694 @itemize @bullet
17695 @item
17696 @b{[intro.execution]}
17698 New text after paragraph 4
17700 @quotation
17701 A @dfn{thread} is a flow of control within the abstract machine.
17702 It is implementation defined whether or not there may be more than
17703 one thread.
17704 @end quotation
17706 New text after paragraph 7
17708 @quotation
17709 It is unspecified whether additional action must be taken to
17710 ensure when and whether side effects are visible to other threads.
17711 @end quotation
17713 @item
17714 @b{[lex.key]}
17716 Add @code{__thread}.
17718 @item
17719 @b{[basic.start.main]}
17721 Add after paragraph 5
17723 @quotation
17724 The thread that begins execution at the @code{main} function is called
17725 the @dfn{main thread}.  It is implementation defined how functions
17726 beginning threads other than the main thread are designated or typed.
17727 A function so designated, as well as the @code{main} function, is called
17728 a @dfn{thread startup function}.  It is implementation defined what
17729 happens if a thread startup function returns.  It is implementation
17730 defined what happens to other threads when any thread calls @code{exit}.
17731 @end quotation
17733 @item
17734 @b{[basic.start.init]}
17736 Add after paragraph 4
17738 @quotation
17739 The storage for an object of thread storage duration shall be
17740 statically initialized before the first statement of the thread startup
17741 function.  An object of thread storage duration shall not require
17742 dynamic initialization.
17743 @end quotation
17745 @item
17746 @b{[basic.start.term]}
17748 Add after paragraph 3
17750 @quotation
17751 The type of an object with thread storage duration shall not have a
17752 non-trivial destructor, nor shall it be an array type whose elements
17753 (directly or indirectly) have non-trivial destructors.
17754 @end quotation
17756 @item
17757 @b{[basic.stc]}
17759 Add ``thread storage duration'' to the list in paragraph 1.
17761 Change paragraph 2
17763 @quotation
17764 Thread, static, and automatic storage durations are associated with
17765 objects introduced by declarations [@dots{}].
17766 @end quotation
17768 Add @code{__thread} to the list of specifiers in paragraph 3.
17770 @item
17771 @b{[basic.stc.thread]}
17773 New section before @b{[basic.stc.static]}
17775 @quotation
17776 The keyword @code{__thread} applied to a non-local object gives the
17777 object thread storage duration.
17779 A local variable or class data member declared both @code{static}
17780 and @code{__thread} gives the variable or member thread storage
17781 duration.
17782 @end quotation
17784 @item
17785 @b{[basic.stc.static]}
17787 Change paragraph 1
17789 @quotation
17790 All objects that have neither thread storage duration, dynamic
17791 storage duration nor are local [@dots{}].
17792 @end quotation
17794 @item
17795 @b{[dcl.stc]}
17797 Add @code{__thread} to the list in paragraph 1.
17799 Change paragraph 1
17801 @quotation
17802 With the exception of @code{__thread}, at most one
17803 @var{storage-class-specifier} shall appear in a given
17804 @var{decl-specifier-seq}.  The @code{__thread} specifier may
17805 be used alone, or immediately following the @code{extern} or
17806 @code{static} specifiers.  [@dots{}]
17807 @end quotation
17809 Add after paragraph 5
17811 @quotation
17812 The @code{__thread} specifier can be applied only to the names of objects
17813 and to anonymous unions.
17814 @end quotation
17816 @item
17817 @b{[class.mem]}
17819 Add after paragraph 6
17821 @quotation
17822 Non-@code{static} members shall not be @code{__thread}.
17823 @end quotation
17824 @end itemize
17826 @node Binary constants
17827 @section Binary constants using the @samp{0b} prefix
17828 @cindex Binary constants using the @samp{0b} prefix
17830 Integer constants can be written as binary constants, consisting of a
17831 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
17832 @samp{0B}.  This is particularly useful in environments that operate a
17833 lot on the bit level (like microcontrollers).
17835 The following statements are identical:
17837 @smallexample
17838 i =       42;
17839 i =     0x2a;
17840 i =      052;
17841 i = 0b101010;
17842 @end smallexample
17844 The type of these constants follows the same rules as for octal or
17845 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
17846 can be applied.
17848 @node C++ Extensions
17849 @chapter Extensions to the C++ Language
17850 @cindex extensions, C++ language
17851 @cindex C++ language extensions
17853 The GNU compiler provides these extensions to the C++ language (and you
17854 can also use most of the C language extensions in your C++ programs).  If you
17855 want to write code that checks whether these features are available, you can
17856 test for the GNU compiler the same way as for C programs: check for a
17857 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
17858 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
17859 Predefined Macros,cpp,The GNU C Preprocessor}).
17861 @menu
17862 * C++ Volatiles::       What constitutes an access to a volatile object.
17863 * Restricted Pointers:: C99 restricted pointers and references.
17864 * Vague Linkage::       Where G++ puts inlines, vtables and such.
17865 * C++ Interface::       You can use a single C++ header file for both
17866                         declarations and definitions.
17867 * Template Instantiation:: Methods for ensuring that exactly one copy of
17868                         each needed template instantiation is emitted.
17869 * Bound member functions:: You can extract a function pointer to the
17870                         method denoted by a @samp{->*} or @samp{.*} expression.
17871 * C++ Attributes::      Variable, function, and type attributes for C++ only.
17872 * Function Multiversioning::   Declaring multiple function versions.
17873 * Namespace Association:: Strong using-directives for namespace association.
17874 * Type Traits::         Compiler support for type traits
17875 * Java Exceptions::     Tweaking exception handling to work with Java.
17876 * Deprecated Features:: Things will disappear from G++.
17877 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
17878 @end menu
17880 @node C++ Volatiles
17881 @section When is a Volatile C++ Object Accessed?
17882 @cindex accessing volatiles
17883 @cindex volatile read
17884 @cindex volatile write
17885 @cindex volatile access
17887 The C++ standard differs from the C standard in its treatment of
17888 volatile objects.  It fails to specify what constitutes a volatile
17889 access, except to say that C++ should behave in a similar manner to C
17890 with respect to volatiles, where possible.  However, the different
17891 lvalueness of expressions between C and C++ complicate the behavior.
17892 G++ behaves the same as GCC for volatile access, @xref{C
17893 Extensions,,Volatiles}, for a description of GCC's behavior.
17895 The C and C++ language specifications differ when an object is
17896 accessed in a void context:
17898 @smallexample
17899 volatile int *src = @var{somevalue};
17900 *src;
17901 @end smallexample
17903 The C++ standard specifies that such expressions do not undergo lvalue
17904 to rvalue conversion, and that the type of the dereferenced object may
17905 be incomplete.  The C++ standard does not specify explicitly that it
17906 is lvalue to rvalue conversion that is responsible for causing an
17907 access.  There is reason to believe that it is, because otherwise
17908 certain simple expressions become undefined.  However, because it
17909 would surprise most programmers, G++ treats dereferencing a pointer to
17910 volatile object of complete type as GCC would do for an equivalent
17911 type in C@.  When the object has incomplete type, G++ issues a
17912 warning; if you wish to force an error, you must force a conversion to
17913 rvalue with, for instance, a static cast.
17915 When using a reference to volatile, G++ does not treat equivalent
17916 expressions as accesses to volatiles, but instead issues a warning that
17917 no volatile is accessed.  The rationale for this is that otherwise it
17918 becomes difficult to determine where volatile access occur, and not
17919 possible to ignore the return value from functions returning volatile
17920 references.  Again, if you wish to force a read, cast the reference to
17921 an rvalue.
17923 G++ implements the same behavior as GCC does when assigning to a
17924 volatile object---there is no reread of the assigned-to object, the
17925 assigned rvalue is reused.  Note that in C++ assignment expressions
17926 are lvalues, and if used as an lvalue, the volatile object is
17927 referred to.  For instance, @var{vref} refers to @var{vobj}, as
17928 expected, in the following example:
17930 @smallexample
17931 volatile int vobj;
17932 volatile int &vref = vobj = @var{something};
17933 @end smallexample
17935 @node Restricted Pointers
17936 @section Restricting Pointer Aliasing
17937 @cindex restricted pointers
17938 @cindex restricted references
17939 @cindex restricted this pointer
17941 As with the C front end, G++ understands the C99 feature of restricted pointers,
17942 specified with the @code{__restrict__}, or @code{__restrict} type
17943 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
17944 language flag, @code{restrict} is not a keyword in C++.
17946 In addition to allowing restricted pointers, you can specify restricted
17947 references, which indicate that the reference is not aliased in the local
17948 context.
17950 @smallexample
17951 void fn (int *__restrict__ rptr, int &__restrict__ rref)
17953   /* @r{@dots{}} */
17955 @end smallexample
17957 @noindent
17958 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
17959 @var{rref} refers to a (different) unaliased integer.
17961 You may also specify whether a member function's @var{this} pointer is
17962 unaliased by using @code{__restrict__} as a member function qualifier.
17964 @smallexample
17965 void T::fn () __restrict__
17967   /* @r{@dots{}} */
17969 @end smallexample
17971 @noindent
17972 Within the body of @code{T::fn}, @var{this} has the effective
17973 definition @code{T *__restrict__ const this}.  Notice that the
17974 interpretation of a @code{__restrict__} member function qualifier is
17975 different to that of @code{const} or @code{volatile} qualifier, in that it
17976 is applied to the pointer rather than the object.  This is consistent with
17977 other compilers that implement restricted pointers.
17979 As with all outermost parameter qualifiers, @code{__restrict__} is
17980 ignored in function definition matching.  This means you only need to
17981 specify @code{__restrict__} in a function definition, rather than
17982 in a function prototype as well.
17984 @node Vague Linkage
17985 @section Vague Linkage
17986 @cindex vague linkage
17988 There are several constructs in C++ that require space in the object
17989 file but are not clearly tied to a single translation unit.  We say that
17990 these constructs have ``vague linkage''.  Typically such constructs are
17991 emitted wherever they are needed, though sometimes we can be more
17992 clever.
17994 @table @asis
17995 @item Inline Functions
17996 Inline functions are typically defined in a header file which can be
17997 included in many different compilations.  Hopefully they can usually be
17998 inlined, but sometimes an out-of-line copy is necessary, if the address
17999 of the function is taken or if inlining fails.  In general, we emit an
18000 out-of-line copy in all translation units where one is needed.  As an
18001 exception, we only emit inline virtual functions with the vtable, since
18002 it always requires a copy.
18004 Local static variables and string constants used in an inline function
18005 are also considered to have vague linkage, since they must be shared
18006 between all inlined and out-of-line instances of the function.
18008 @item VTables
18009 @cindex vtable
18010 C++ virtual functions are implemented in most compilers using a lookup
18011 table, known as a vtable.  The vtable contains pointers to the virtual
18012 functions provided by a class, and each object of the class contains a
18013 pointer to its vtable (or vtables, in some multiple-inheritance
18014 situations).  If the class declares any non-inline, non-pure virtual
18015 functions, the first one is chosen as the ``key method'' for the class,
18016 and the vtable is only emitted in the translation unit where the key
18017 method is defined.
18019 @emph{Note:} If the chosen key method is later defined as inline, the
18020 vtable is still emitted in every translation unit that defines it.
18021 Make sure that any inline virtuals are declared inline in the class
18022 body, even if they are not defined there.
18024 @item @code{type_info} objects
18025 @cindex @code{type_info}
18026 @cindex RTTI
18027 C++ requires information about types to be written out in order to
18028 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18029 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18030 object is written out along with the vtable so that @samp{dynamic_cast}
18031 can determine the dynamic type of a class object at run time.  For all
18032 other types, we write out the @samp{type_info} object when it is used: when
18033 applying @samp{typeid} to an expression, throwing an object, or
18034 referring to a type in a catch clause or exception specification.
18036 @item Template Instantiations
18037 Most everything in this section also applies to template instantiations,
18038 but there are other options as well.
18039 @xref{Template Instantiation,,Where's the Template?}.
18041 @end table
18043 When used with GNU ld version 2.8 or later on an ELF system such as
18044 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18045 these constructs will be discarded at link time.  This is known as
18046 COMDAT support.
18048 On targets that don't support COMDAT, but do support weak symbols, GCC
18049 uses them.  This way one copy overrides all the others, but
18050 the unused copies still take up space in the executable.
18052 For targets that do not support either COMDAT or weak symbols,
18053 most entities with vague linkage are emitted as local symbols to
18054 avoid duplicate definition errors from the linker.  This does not happen
18055 for local statics in inlines, however, as having multiple copies
18056 almost certainly breaks things.
18058 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18059 another way to control placement of these constructs.
18061 @node C++ Interface
18062 @section #pragma interface and implementation
18064 @cindex interface and implementation headers, C++
18065 @cindex C++ interface and implementation headers
18066 @cindex pragmas, interface and implementation
18068 @code{#pragma interface} and @code{#pragma implementation} provide the
18069 user with a way of explicitly directing the compiler to emit entities
18070 with vague linkage (and debugging information) in a particular
18071 translation unit.
18073 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18074 most cases, because of COMDAT support and the ``key method'' heuristic
18075 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18076 program to grow due to unnecessary out-of-line copies of inline
18077 functions.  Currently (3.4) the only benefit of these
18078 @code{#pragma}s is reduced duplication of debugging information, and
18079 that should be addressed soon on DWARF 2 targets with the use of
18080 COMDAT groups.
18082 @table @code
18083 @item #pragma interface
18084 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18085 @kindex #pragma interface
18086 Use this directive in @emph{header files} that define object classes, to save
18087 space in most of the object files that use those classes.  Normally,
18088 local copies of certain information (backup copies of inline member
18089 functions, debugging information, and the internal tables that implement
18090 virtual functions) must be kept in each object file that includes class
18091 definitions.  You can use this pragma to avoid such duplication.  When a
18092 header file containing @samp{#pragma interface} is included in a
18093 compilation, this auxiliary information is not generated (unless
18094 the main input source file itself uses @samp{#pragma implementation}).
18095 Instead, the object files contain references to be resolved at link
18096 time.
18098 The second form of this directive is useful for the case where you have
18099 multiple headers with the same name in different directories.  If you
18100 use this form, you must specify the same string to @samp{#pragma
18101 implementation}.
18103 @item #pragma implementation
18104 @itemx #pragma implementation "@var{objects}.h"
18105 @kindex #pragma implementation
18106 Use this pragma in a @emph{main input file}, when you want full output from
18107 included header files to be generated (and made globally visible).  The
18108 included header file, in turn, should use @samp{#pragma interface}.
18109 Backup copies of inline member functions, debugging information, and the
18110 internal tables used to implement virtual functions are all generated in
18111 implementation files.
18113 @cindex implied @code{#pragma implementation}
18114 @cindex @code{#pragma implementation}, implied
18115 @cindex naming convention, implementation headers
18116 If you use @samp{#pragma implementation} with no argument, it applies to
18117 an include file with the same basename@footnote{A file's @dfn{basename}
18118 is the name stripped of all leading path information and of trailing
18119 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18120 file.  For example, in @file{allclass.cc}, giving just
18121 @samp{#pragma implementation}
18122 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18124 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18125 an implementation file whenever you would include it from
18126 @file{allclass.cc} even if you never specified @samp{#pragma
18127 implementation}.  This was deemed to be more trouble than it was worth,
18128 however, and disabled.
18130 Use the string argument if you want a single implementation file to
18131 include code from multiple header files.  (You must also use
18132 @samp{#include} to include the header file; @samp{#pragma
18133 implementation} only specifies how to use the file---it doesn't actually
18134 include it.)
18136 There is no way to split up the contents of a single header file into
18137 multiple implementation files.
18138 @end table
18140 @cindex inlining and C++ pragmas
18141 @cindex C++ pragmas, effect on inlining
18142 @cindex pragmas in C++, effect on inlining
18143 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18144 effect on function inlining.
18146 If you define a class in a header file marked with @samp{#pragma
18147 interface}, the effect on an inline function defined in that class is
18148 similar to an explicit @code{extern} declaration---the compiler emits
18149 no code at all to define an independent version of the function.  Its
18150 definition is used only for inlining with its callers.
18152 @opindex fno-implement-inlines
18153 Conversely, when you include the same header file in a main source file
18154 that declares it as @samp{#pragma implementation}, the compiler emits
18155 code for the function itself; this defines a version of the function
18156 that can be found via pointers (or by callers compiled without
18157 inlining).  If all calls to the function can be inlined, you can avoid
18158 emitting the function by compiling with @option{-fno-implement-inlines}.
18159 If any calls are not inlined, you will get linker errors.
18161 @node Template Instantiation
18162 @section Where's the Template?
18163 @cindex template instantiation
18165 C++ templates are the first language feature to require more
18166 intelligence from the environment than one usually finds on a UNIX
18167 system.  Somehow the compiler and linker have to make sure that each
18168 template instance occurs exactly once in the executable if it is needed,
18169 and not at all otherwise.  There are two basic approaches to this
18170 problem, which are referred to as the Borland model and the Cfront model.
18172 @table @asis
18173 @item Borland model
18174 Borland C++ solved the template instantiation problem by adding the code
18175 equivalent of common blocks to their linker; the compiler emits template
18176 instances in each translation unit that uses them, and the linker
18177 collapses them together.  The advantage of this model is that the linker
18178 only has to consider the object files themselves; there is no external
18179 complexity to worry about.  This disadvantage is that compilation time
18180 is increased because the template code is being compiled repeatedly.
18181 Code written for this model tends to include definitions of all
18182 templates in the header file, since they must be seen to be
18183 instantiated.
18185 @item Cfront model
18186 The AT&T C++ translator, Cfront, solved the template instantiation
18187 problem by creating the notion of a template repository, an
18188 automatically maintained place where template instances are stored.  A
18189 more modern version of the repository works as follows: As individual
18190 object files are built, the compiler places any template definitions and
18191 instantiations encountered in the repository.  At link time, the link
18192 wrapper adds in the objects in the repository and compiles any needed
18193 instances that were not previously emitted.  The advantages of this
18194 model are more optimal compilation speed and the ability to use the
18195 system linker; to implement the Borland model a compiler vendor also
18196 needs to replace the linker.  The disadvantages are vastly increased
18197 complexity, and thus potential for error; for some code this can be
18198 just as transparent, but in practice it can been very difficult to build
18199 multiple programs in one directory and one program in multiple
18200 directories.  Code written for this model tends to separate definitions
18201 of non-inline member templates into a separate file, which should be
18202 compiled separately.
18203 @end table
18205 When used with GNU ld version 2.8 or later on an ELF system such as
18206 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18207 Borland model.  On other systems, G++ implements neither automatic
18208 model.
18210 You have the following options for dealing with template instantiations:
18212 @enumerate
18213 @item
18214 @opindex frepo
18215 Compile your template-using code with @option{-frepo}.  The compiler
18216 generates files with the extension @samp{.rpo} listing all of the
18217 template instantiations used in the corresponding object files that
18218 could be instantiated there; the link wrapper, @samp{collect2},
18219 then updates the @samp{.rpo} files to tell the compiler where to place
18220 those instantiations and rebuild any affected object files.  The
18221 link-time overhead is negligible after the first pass, as the compiler
18222 continues to place the instantiations in the same files.
18224 This is your best option for application code written for the Borland
18225 model, as it just works.  Code written for the Cfront model 
18226 needs to be modified so that the template definitions are available at
18227 one or more points of instantiation; usually this is as simple as adding
18228 @code{#include <tmethods.cc>} to the end of each template header.
18230 For library code, if you want the library to provide all of the template
18231 instantiations it needs, just try to link all of its object files
18232 together; the link will fail, but cause the instantiations to be
18233 generated as a side effect.  Be warned, however, that this may cause
18234 conflicts if multiple libraries try to provide the same instantiations.
18235 For greater control, use explicit instantiation as described in the next
18236 option.
18238 @item
18239 @opindex fno-implicit-templates
18240 Compile your code with @option{-fno-implicit-templates} to disable the
18241 implicit generation of template instances, and explicitly instantiate
18242 all the ones you use.  This approach requires more knowledge of exactly
18243 which instances you need than do the others, but it's less
18244 mysterious and allows greater control.  You can scatter the explicit
18245 instantiations throughout your program, perhaps putting them in the
18246 translation units where the instances are used or the translation units
18247 that define the templates themselves; you can put all of the explicit
18248 instantiations you need into one big file; or you can create small files
18249 like
18251 @smallexample
18252 #include "Foo.h"
18253 #include "Foo.cc"
18255 template class Foo<int>;
18256 template ostream& operator <<
18257                 (ostream&, const Foo<int>&);
18258 @end smallexample
18260 @noindent
18261 for each of the instances you need, and create a template instantiation
18262 library from those.
18264 If you are using Cfront-model code, you can probably get away with not
18265 using @option{-fno-implicit-templates} when compiling files that don't
18266 @samp{#include} the member template definitions.
18268 If you use one big file to do the instantiations, you may want to
18269 compile it without @option{-fno-implicit-templates} so you get all of the
18270 instances required by your explicit instantiations (but not by any
18271 other files) without having to specify them as well.
18273 The ISO C++ 2011 standard allows forward declaration of explicit
18274 instantiations (with @code{extern}). G++ supports explicit instantiation
18275 declarations in C++98 mode and has extended the template instantiation
18276 syntax to support instantiation of the compiler support data for a
18277 template class (i.e.@: the vtable) without instantiating any of its
18278 members (with @code{inline}), and instantiation of only the static data
18279 members of a template class, without the support data or member
18280 functions (with @code{static}):
18282 @smallexample
18283 extern template int max (int, int);
18284 inline template class Foo<int>;
18285 static template class Foo<int>;
18286 @end smallexample
18288 @item
18289 Do nothing.  Pretend G++ does implement automatic instantiation
18290 management.  Code written for the Borland model works fine, but
18291 each translation unit contains instances of each of the templates it
18292 uses.  In a large program, this can lead to an unacceptable amount of code
18293 duplication.
18294 @end enumerate
18296 @node Bound member functions
18297 @section Extracting the function pointer from a bound pointer to member function
18298 @cindex pmf
18299 @cindex pointer to member function
18300 @cindex bound pointer to member function
18302 In C++, pointer to member functions (PMFs) are implemented using a wide
18303 pointer of sorts to handle all the possible call mechanisms; the PMF
18304 needs to store information about how to adjust the @samp{this} pointer,
18305 and if the function pointed to is virtual, where to find the vtable, and
18306 where in the vtable to look for the member function.  If you are using
18307 PMFs in an inner loop, you should really reconsider that decision.  If
18308 that is not an option, you can extract the pointer to the function that
18309 would be called for a given object/PMF pair and call it directly inside
18310 the inner loop, to save a bit of time.
18312 Note that you still pay the penalty for the call through a
18313 function pointer; on most modern architectures, such a call defeats the
18314 branch prediction features of the CPU@.  This is also true of normal
18315 virtual function calls.
18317 The syntax for this extension is
18319 @smallexample
18320 extern A a;
18321 extern int (A::*fp)();
18322 typedef int (*fptr)(A *);
18324 fptr p = (fptr)(a.*fp);
18325 @end smallexample
18327 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18328 no object is needed to obtain the address of the function.  They can be
18329 converted to function pointers directly:
18331 @smallexample
18332 fptr p1 = (fptr)(&A::foo);
18333 @end smallexample
18335 @opindex Wno-pmf-conversions
18336 You must specify @option{-Wno-pmf-conversions} to use this extension.
18338 @node C++ Attributes
18339 @section C++-Specific Variable, Function, and Type Attributes
18341 Some attributes only make sense for C++ programs.
18343 @table @code
18344 @item abi_tag ("@var{tag}", ...)
18345 @cindex @code{abi_tag} attribute
18346 The @code{abi_tag} attribute can be applied to a function or class
18347 declaration.  It modifies the mangled name of the function or class to
18348 incorporate the tag name, in order to distinguish the function or
18349 class from an earlier version with a different ABI; perhaps the class
18350 has changed size, or the function has a different return type that is
18351 not encoded in the mangled name.
18353 The argument can be a list of strings of arbitrary length.  The
18354 strings are sorted on output, so the order of the list is
18355 unimportant.
18357 A redeclaration of a function or class must not add new ABI tags,
18358 since doing so would change the mangled name.
18360 The ABI tags apply to a name, so all instantiations and
18361 specializations of a template have the same tags.  The attribute will
18362 be ignored if applied to an explicit specialization or instantiation.
18364 The @option{-Wabi-tag} flag enables a warning about a class which does
18365 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18366 that needs to coexist with an earlier ABI, using this option can help
18367 to find all affected types that need to be tagged.
18369 @item init_priority (@var{priority})
18370 @cindex @code{init_priority} attribute
18373 In Standard C++, objects defined at namespace scope are guaranteed to be
18374 initialized in an order in strict accordance with that of their definitions
18375 @emph{in a given translation unit}.  No guarantee is made for initializations
18376 across translation units.  However, GNU C++ allows users to control the
18377 order of initialization of objects defined at namespace scope with the
18378 @code{init_priority} attribute by specifying a relative @var{priority},
18379 a constant integral expression currently bounded between 101 and 65535
18380 inclusive.  Lower numbers indicate a higher priority.
18382 In the following example, @code{A} would normally be created before
18383 @code{B}, but the @code{init_priority} attribute reverses that order:
18385 @smallexample
18386 Some_Class  A  __attribute__ ((init_priority (2000)));
18387 Some_Class  B  __attribute__ ((init_priority (543)));
18388 @end smallexample
18390 @noindent
18391 Note that the particular values of @var{priority} do not matter; only their
18392 relative ordering.
18394 @item java_interface
18395 @cindex @code{java_interface} attribute
18397 This type attribute informs C++ that the class is a Java interface.  It may
18398 only be applied to classes declared within an @code{extern "Java"} block.
18399 Calls to methods declared in this interface are dispatched using GCJ's
18400 interface table mechanism, instead of regular virtual table dispatch.
18402 @item warn_unused
18403 @cindex @code{warn_unused} attribute
18405 For C++ types with non-trivial constructors and/or destructors it is
18406 impossible for the compiler to determine whether a variable of this
18407 type is truly unused if it is not referenced. This type attribute
18408 informs the compiler that variables of this type should be warned
18409 about if they appear to be unused, just like variables of fundamental
18410 types.
18412 This attribute is appropriate for types which just represent a value,
18413 such as @code{std::string}; it is not appropriate for types which
18414 control a resource, such as @code{std::mutex}.
18416 This attribute is also accepted in C, but it is unnecessary because C
18417 does not have constructors or destructors.
18419 @end table
18421 See also @ref{Namespace Association}.
18423 @node Function Multiversioning
18424 @section Function Multiversioning
18425 @cindex function versions
18427 With the GNU C++ front end, for target i386, you may specify multiple
18428 versions of a function, where each function is specialized for a
18429 specific target feature.  At runtime, the appropriate version of the
18430 function is automatically executed depending on the characteristics of
18431 the execution platform.  Here is an example.
18433 @smallexample
18434 __attribute__ ((target ("default")))
18435 int foo ()
18437   // The default version of foo.
18438   return 0;
18441 __attribute__ ((target ("sse4.2")))
18442 int foo ()
18444   // foo version for SSE4.2
18445   return 1;
18448 __attribute__ ((target ("arch=atom")))
18449 int foo ()
18451   // foo version for the Intel ATOM processor
18452   return 2;
18455 __attribute__ ((target ("arch=amdfam10")))
18456 int foo ()
18458   // foo version for the AMD Family 0x10 processors.
18459   return 3;
18462 int main ()
18464   int (*p)() = &foo;
18465   assert ((*p) () == foo ());
18466   return 0;
18468 @end smallexample
18470 In the above example, four versions of function foo are created. The
18471 first version of foo with the target attribute "default" is the default
18472 version.  This version gets executed when no other target specific
18473 version qualifies for execution on a particular platform. A new version
18474 of foo is created by using the same function signature but with a
18475 different target string.  Function foo is called or a pointer to it is
18476 taken just like a regular function.  GCC takes care of doing the
18477 dispatching to call the right version at runtime.  Refer to the
18478 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18479 Function Multiversioning} for more details.
18481 @node Namespace Association
18482 @section Namespace Association
18484 @strong{Caution:} The semantics of this extension are equivalent
18485 to C++ 2011 inline namespaces.  Users should use inline namespaces
18486 instead as this extension will be removed in future versions of G++.
18488 A using-directive with @code{__attribute ((strong))} is stronger
18489 than a normal using-directive in two ways:
18491 @itemize @bullet
18492 @item
18493 Templates from the used namespace can be specialized and explicitly
18494 instantiated as though they were members of the using namespace.
18496 @item
18497 The using namespace is considered an associated namespace of all
18498 templates in the used namespace for purposes of argument-dependent
18499 name lookup.
18500 @end itemize
18502 The used namespace must be nested within the using namespace so that
18503 normal unqualified lookup works properly.
18505 This is useful for composing a namespace transparently from
18506 implementation namespaces.  For example:
18508 @smallexample
18509 namespace std @{
18510   namespace debug @{
18511     template <class T> struct A @{ @};
18512   @}
18513   using namespace debug __attribute ((__strong__));
18514   template <> struct A<int> @{ @};   // @r{OK to specialize}
18516   template <class T> void f (A<T>);
18519 int main()
18521   f (std::A<float>());             // @r{lookup finds} std::f
18522   f (std::A<int>());
18524 @end smallexample
18526 @node Type Traits
18527 @section Type Traits
18529 The C++ front end implements syntactic extensions that allow
18530 compile-time determination of 
18531 various characteristics of a type (or of a
18532 pair of types).
18534 @table @code
18535 @item __has_nothrow_assign (type)
18536 If @code{type} is const qualified or is a reference type then the trait is
18537 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18538 is true, else if @code{type} is a cv class or union type with copy assignment
18539 operators that are known not to throw an exception then the trait is true,
18540 else it is false.  Requires: @code{type} shall be a complete type,
18541 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18543 @item __has_nothrow_copy (type)
18544 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18545 @code{type} is a cv class or union type with copy constructors that
18546 are known not to throw an exception then the trait is true, else it is false.
18547 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18548 @code{void}, or an array of unknown bound.
18550 @item __has_nothrow_constructor (type)
18551 If @code{__has_trivial_constructor (type)} is true then the trait is
18552 true, else if @code{type} is a cv class or union type (or array
18553 thereof) with a default constructor that is known not to throw an
18554 exception then the trait is true, else it is false.  Requires:
18555 @code{type} shall be a complete type, (possibly cv-qualified)
18556 @code{void}, or an array of unknown bound.
18558 @item __has_trivial_assign (type)
18559 If @code{type} is const qualified or is a reference type then the trait is
18560 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18561 true, else if @code{type} is a cv class or union type with a trivial
18562 copy assignment ([class.copy]) then the trait is true, else it is
18563 false.  Requires: @code{type} shall be a complete type, (possibly
18564 cv-qualified) @code{void}, or an array of unknown bound.
18566 @item __has_trivial_copy (type)
18567 If @code{__is_pod (type)} is true or @code{type} is a reference type
18568 then the trait is true, else if @code{type} is a cv class or union type
18569 with a trivial copy constructor ([class.copy]) then the trait
18570 is true, else it is false.  Requires: @code{type} shall be a complete
18571 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18573 @item __has_trivial_constructor (type)
18574 If @code{__is_pod (type)} is true then the trait is true, else if
18575 @code{type} is a cv class or union type (or array thereof) with a
18576 trivial default constructor ([class.ctor]) then the trait is true,
18577 else it is false.  Requires: @code{type} shall be a complete
18578 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18580 @item __has_trivial_destructor (type)
18581 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18582 the trait is true, else if @code{type} is a cv class or union type (or
18583 array thereof) with a trivial destructor ([class.dtor]) then the trait
18584 is true, else it is false.  Requires: @code{type} shall be a complete
18585 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18587 @item __has_virtual_destructor (type)
18588 If @code{type} is a class type with a virtual destructor
18589 ([class.dtor]) then the trait is true, else it is false.  Requires:
18590 @code{type} shall be a complete type, (possibly cv-qualified)
18591 @code{void}, or an array of unknown bound.
18593 @item __is_abstract (type)
18594 If @code{type} is an abstract class ([class.abstract]) then the trait
18595 is true, else it is false.  Requires: @code{type} shall be a complete
18596 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18598 @item __is_base_of (base_type, derived_type)
18599 If @code{base_type} is a base class of @code{derived_type}
18600 ([class.derived]) then the trait is true, otherwise it is false.
18601 Top-level cv qualifications of @code{base_type} and
18602 @code{derived_type} are ignored.  For the purposes of this trait, a
18603 class type is considered is own base.  Requires: if @code{__is_class
18604 (base_type)} and @code{__is_class (derived_type)} are true and
18605 @code{base_type} and @code{derived_type} are not the same type
18606 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
18607 type.  Diagnostic is produced if this requirement is not met.
18609 @item __is_class (type)
18610 If @code{type} is a cv class type, and not a union type
18611 ([basic.compound]) the trait is true, else it is false.
18613 @item __is_empty (type)
18614 If @code{__is_class (type)} is false then the trait is false.
18615 Otherwise @code{type} is considered empty if and only if: @code{type}
18616 has no non-static data members, or all non-static data members, if
18617 any, are bit-fields of length 0, and @code{type} has no virtual
18618 members, and @code{type} has no virtual base classes, and @code{type}
18619 has no base classes @code{base_type} for which
18620 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
18621 be a complete type, (possibly cv-qualified) @code{void}, or an array
18622 of unknown bound.
18624 @item __is_enum (type)
18625 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
18626 true, else it is false.
18628 @item __is_literal_type (type)
18629 If @code{type} is a literal type ([basic.types]) the trait is
18630 true, else it is false.  Requires: @code{type} shall be a complete type,
18631 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18633 @item __is_pod (type)
18634 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
18635 else it is false.  Requires: @code{type} shall be a complete type,
18636 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18638 @item __is_polymorphic (type)
18639 If @code{type} is a polymorphic class ([class.virtual]) then the trait
18640 is true, else it is false.  Requires: @code{type} shall be a complete
18641 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18643 @item __is_standard_layout (type)
18644 If @code{type} is a standard-layout type ([basic.types]) the trait is
18645 true, else it is false.  Requires: @code{type} shall be a complete
18646 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18648 @item __is_trivial (type)
18649 If @code{type} is a trivial type ([basic.types]) the trait is
18650 true, else it is false.  Requires: @code{type} shall be a complete
18651 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18653 @item __is_union (type)
18654 If @code{type} is a cv union type ([basic.compound]) the trait is
18655 true, else it is false.
18657 @item __underlying_type (type)
18658 The underlying type of @code{type}.  Requires: @code{type} shall be
18659 an enumeration type ([dcl.enum]).
18661 @end table
18663 @node Java Exceptions
18664 @section Java Exceptions
18666 The Java language uses a slightly different exception handling model
18667 from C++.  Normally, GNU C++ automatically detects when you are
18668 writing C++ code that uses Java exceptions, and handle them
18669 appropriately.  However, if C++ code only needs to execute destructors
18670 when Java exceptions are thrown through it, GCC guesses incorrectly.
18671 Sample problematic code is:
18673 @smallexample
18674   struct S @{ ~S(); @};
18675   extern void bar();    // @r{is written in Java, and may throw exceptions}
18676   void foo()
18677   @{
18678     S s;
18679     bar();
18680   @}
18681 @end smallexample
18683 @noindent
18684 The usual effect of an incorrect guess is a link failure, complaining of
18685 a missing routine called @samp{__gxx_personality_v0}.
18687 You can inform the compiler that Java exceptions are to be used in a
18688 translation unit, irrespective of what it might think, by writing
18689 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
18690 @samp{#pragma} must appear before any functions that throw or catch
18691 exceptions, or run destructors when exceptions are thrown through them.
18693 You cannot mix Java and C++ exceptions in the same translation unit.  It
18694 is believed to be safe to throw a C++ exception from one file through
18695 another file compiled for the Java exception model, or vice versa, but
18696 there may be bugs in this area.
18698 @node Deprecated Features
18699 @section Deprecated Features
18701 In the past, the GNU C++ compiler was extended to experiment with new
18702 features, at a time when the C++ language was still evolving.  Now that
18703 the C++ standard is complete, some of those features are superseded by
18704 superior alternatives.  Using the old features might cause a warning in
18705 some cases that the feature will be dropped in the future.  In other
18706 cases, the feature might be gone already.
18708 While the list below is not exhaustive, it documents some of the options
18709 that are now deprecated:
18711 @table @code
18712 @item -fexternal-templates
18713 @itemx -falt-external-templates
18714 These are two of the many ways for G++ to implement template
18715 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
18716 defines how template definitions have to be organized across
18717 implementation units.  G++ has an implicit instantiation mechanism that
18718 should work just fine for standard-conforming code.
18720 @item -fstrict-prototype
18721 @itemx -fno-strict-prototype
18722 Previously it was possible to use an empty prototype parameter list to
18723 indicate an unspecified number of parameters (like C), rather than no
18724 parameters, as C++ demands.  This feature has been removed, except where
18725 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
18726 @end table
18728 G++ allows a virtual function returning @samp{void *} to be overridden
18729 by one returning a different pointer type.  This extension to the
18730 covariant return type rules is now deprecated and will be removed from a
18731 future version.
18733 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
18734 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
18735 and are now removed from G++.  Code using these operators should be
18736 modified to use @code{std::min} and @code{std::max} instead.
18738 The named return value extension has been deprecated, and is now
18739 removed from G++.
18741 The use of initializer lists with new expressions has been deprecated,
18742 and is now removed from G++.
18744 Floating and complex non-type template parameters have been deprecated,
18745 and are now removed from G++.
18747 The implicit typename extension has been deprecated and is now
18748 removed from G++.
18750 The use of default arguments in function pointers, function typedefs
18751 and other places where they are not permitted by the standard is
18752 deprecated and will be removed from a future version of G++.
18754 G++ allows floating-point literals to appear in integral constant expressions,
18755 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
18756 This extension is deprecated and will be removed from a future version.
18758 G++ allows static data members of const floating-point type to be declared
18759 with an initializer in a class definition. The standard only allows
18760 initializers for static members of const integral types and const
18761 enumeration types so this extension has been deprecated and will be removed
18762 from a future version.
18764 @node Backwards Compatibility
18765 @section Backwards Compatibility
18766 @cindex Backwards Compatibility
18767 @cindex ARM [Annotated C++ Reference Manual]
18769 Now that there is a definitive ISO standard C++, G++ has a specification
18770 to adhere to.  The C++ language evolved over time, and features that
18771 used to be acceptable in previous drafts of the standard, such as the ARM
18772 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
18773 compilation of C++ written to such drafts, G++ contains some backwards
18774 compatibilities.  @emph{All such backwards compatibility features are
18775 liable to disappear in future versions of G++.} They should be considered
18776 deprecated.   @xref{Deprecated Features}.
18778 @table @code
18779 @item For scope
18780 If a variable is declared at for scope, it used to remain in scope until
18781 the end of the scope that contained the for statement (rather than just
18782 within the for scope).  G++ retains this, but issues a warning, if such a
18783 variable is accessed outside the for scope.
18785 @item Implicit C language
18786 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
18787 scope to set the language.  On such systems, all header files are
18788 implicitly scoped inside a C language scope.  Also, an empty prototype
18789 @code{()} is treated as an unspecified number of arguments, rather
18790 than no arguments, as C++ demands.
18791 @end table
18793 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
18794 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign