* doc/extend.texi (Cilk Plus Builtins): cilkplus.org now uses
[official-gcc.git] / gcc / doc / extend.texi
blobe82bb1bb310d4f0972389b9a2a194e16688d5a5f
1 @c Copyright (C) 1988-2016 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Inquiring about the alignment of a type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
89 * Other Builtins::      Other built-in functions.
90 * Target Builtins::     Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas::             Pragmas accepted by GCC.
93 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
94 * Thread-Local::        Per-thread variables.
95 * Binary constants::    Binary constants using the @samp{0b} prefix.
96 @end menu
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@.  This allows you to use loops, switches, and local variables
109 within an expression.
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces.  For
113 example:
115 @smallexample
116 (@{ int y = foo (); int z;
117    if (y > 0) z = y;
118    else z = - y;
119    z; @})
120 @end smallexample
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct.  (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once).  For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects.  In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
148 @smallexample
149 #define maxint(a,b) \
150   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression.  For instance, if @code{A} is a class, then
164 @smallexample
165         A a;
167         (@{a;@}).Foo ()
168 @end smallexample
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end.  This makes statement
178 expressions inside macros slightly different from function calls.  In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call.  In the statement expression case they are destroyed during
182 the statement expression.  For instance,
184 @smallexample
185 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
188 void foo ()
190   macro (X ());
191   function (X ());
193 @end smallexample
195 @noindent
196 has different places where temporaries are destroyed.  For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}.  In the @code{function} case that
199 temporary is destroyed when the function returns.
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++.  (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted.  Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression.  In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression.  For example,
221 @smallexample
222   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
223 @end smallexample
225 @noindent
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}.  If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
230 @node Local Labels
231 @section Locally Declared Labels
232 @cindex local labels
233 @cindex macros, local labels
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope.  A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
240 A local label declaration looks like this:
242 @smallexample
243 __label__ @var{label};
244 @end smallexample
246 @noindent
249 @smallexample
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 @end smallexample
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself.  You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
260 The local label feature is useful for complex macros.  If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them.  However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function.  A
265 local label avoids this problem.  For example:
267 @smallexample
268 #define SEARCH(value, array, target)              \
269 do @{                                              \
270   __label__ found;                                \
271   typeof (target) _SEARCH_target = (target);      \
272   typeof (*(array)) *_SEARCH_array = (array);     \
273   int i, j;                                       \
274   int value;                                      \
275   for (i = 0; i < max; i++)                       \
276     for (j = 0; j < max; j++)                     \
277       if (_SEARCH_array[i][j] == _SEARCH_target)  \
278         @{ (value) = i; goto found; @}              \
279   (value) = -1;                                   \
280  found:;                                          \
281 @} while (0)
282 @end smallexample
284 This could also be written using a statement expression:
286 @smallexample
287 #define SEARCH(array, target)                     \
288 (@{                                                \
289   __label__ found;                                \
290   typeof (target) _SEARCH_target = (target);      \
291   typeof (*(array)) *_SEARCH_array = (array);     \
292   int i, j;                                       \
293   int value;                                      \
294   for (i = 0; i < max; i++)                       \
295     for (j = 0; j < max; j++)                     \
296       if (_SEARCH_array[i][j] == _SEARCH_target)  \
297         @{ value = i; goto found; @}                \
298   value = -1;                                     \
299  found:                                           \
300   value;                                          \
302 @end smallexample
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any.  @xref{Nested Functions}, for details.
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}.  The
316 value has type @code{void *}.  This value is a constant and can be used
317 wherever a constant of that type is valid.  For example:
319 @smallexample
320 void *ptr;
321 /* @r{@dots{}} */
322 ptr = &&foo;
323 @end smallexample
325 To use these values, you need to be able to jump to one.  This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}.  For example,
331 @smallexample
332 goto *ptr;
333 @end smallexample
335 @noindent
336 Any expression of type @code{void *} is allowed.
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
341 @smallexample
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
343 @end smallexample
345 @noindent
346 Then you can select a label with indexing, like this:
348 @smallexample
349 goto *array[i];
350 @end smallexample
352 @noindent
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement.  The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen.  The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
370 An alternate way to write the above example is
372 @smallexample
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374                              &&hack - &&foo @};
375 goto *(&&foo + array[i]);
376 @end smallexample
378 @noindent
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned.  If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning.  If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
396 @cindex thunks
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
404 call it twice:
406 @smallexample
407 @group
408 foo (double a, double b)
410   double square (double z) @{ return z * z; @}
412   return square (a) + square (b);
414 @end group
415 @end smallexample
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition.  This is
419 called @dfn{lexical scoping}.  For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
422 @smallexample
423 @group
424 bar (int *array, int offset, int size)
426   int access (int *array, int index)
427     @{ return array[index + offset]; @}
428   int i;
429   /* @r{@dots{}} */
430   for (i = 0; i < size; i++)
431     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
433 @end group
434 @end smallexample
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
443 @smallexample
444 hack (int *array, int size)
446   void store (int index, int value)
447     @{ array[index] = value; @}
449   intermediate (store, size);
451 @end smallexample
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument.  If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose.  If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk.  If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
465 safe.
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}.  This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}).  Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well.  Here is an example:
478 @smallexample
479 @group
480 bar (int *array, int offset, int size)
482   __label__ failure;
483   int access (int *array, int index)
484     @{
485       if (index > size)
486         goto failure;
487       return array[index + offset];
488     @}
489   int i;
490   /* @r{@dots{}} */
491   for (i = 0; i < size; i++)
492     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
493   /* @r{@dots{}} */
494   return 0;
496  /* @r{Control comes here from @code{access}
497     if it detects an error.}  */
498  failure:
499   return -1;
501 @end group
502 @end smallexample
504 A nested function always has no linkage.  Declaring one with
505 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
509 @smallexample
510 bar (int *array, int offset, int size)
512   __label__ failure;
513   auto int access (int *, int);
514   /* @r{@dots{}} */
515   int access (int *array, int index)
516     @{
517       if (index > size)
518         goto failure;
519       return array[index + offset];
520     @}
521   /* @r{@dots{}} */
523 @end smallexample
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
533 of the arguments.
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
538 that data type).
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language.  It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack.  Then it returns the
553 address of that block.
554 @end deftypefn
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
559 and @var{size}.
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}.  The data
567 is saved in a block of memory allocated on the stack.
569 It is not always simple to compute the proper value for @var{size}.  The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
572 area.
573 @end deftypefn
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function.  You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
579 @end deftypefn
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function.  It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments.  This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable.  For example:
591 @smallexample
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
596   int r = fprintf (f, "myprintf: ");
597   if (r < 0)
598     return r;
599   int s = fprintf (f, format, __builtin_va_arg_pack ());
600   if (s < 0)
601     return s;
602   return r + s;
604 @end smallexample
605 @end deftypefn
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function.  It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
615 @smallexample
616 #ifdef __OPTIMIZE__
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
620   if (__builtin_va_arg_pack_len () > 1)
621     warn_open_too_many_arguments ();
623   if (__builtin_constant_p (oflag))
624     @{
625       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626         @{
627           warn_open_missing_mode ();
628           return __open_2 (path, oflag);
629         @}
630       return open (path, oflag, __builtin_va_arg_pack ());
631     @}
633   if (__builtin_va_arg_pack_len () < 1)
634     return __open_2 (path, oflag);
636   return open (path, oflag, __builtin_va_arg_pack ());
638 #endif
639 @end smallexample
640 @end deftypefn
642 @node Typeof
643 @section Referring to a Type with @code{typeof}
644 @findex typeof
645 @findex sizeof
646 @cindex macros, types of arguments
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type.  Here is an example with an expression:
655 @smallexample
656 typeof (x[0](1))
657 @end smallexample
659 @noindent
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
663 Here is an example with a typename as the argument:
665 @smallexample
666 typeof (int *)
667 @end smallexample
669 @noindent
670 Here the type described is that of pointers to @code{int}.
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used.  For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
682 such a type.
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
690 @smallexample
691 #define max(a,b) \
692   (@{ typeof (a) _a = (a); \
693       typeof (b) _b = (b); \
694     _a > _b ? _a : _b; @})
695 @end smallexample
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}.  Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
710 @noindent
711 Some more examples of the use of @code{typeof}:
713 @itemize @bullet
714 @item
715 This declares @code{y} with the type of what @code{x} points to.
717 @smallexample
718 typeof (*x) y;
719 @end smallexample
721 @item
722 This declares @code{y} as an array of such values.
724 @smallexample
725 typeof (*x) y[4];
726 @end smallexample
728 @item
729 This declares @code{y} as an array of pointers to characters:
731 @smallexample
732 typeof (typeof (char *)[4]) y;
733 @end smallexample
735 @noindent
736 It is equivalent to the following traditional C declaration:
738 @smallexample
739 char *y[4];
740 @end smallexample
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
745 @smallexample
746 #define pointer(T)  typeof(T *)
747 #define array(T, N) typeof(T [N])
748 @end smallexample
750 @noindent
751 Now the declaration can be rewritten this way:
753 @smallexample
754 array (pointer (char), 4) y;
755 @end smallexample
757 @noindent
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
760 @end itemize
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}.  In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer.  (In C++, you should use C++11
768 @code{auto} for this purpose.)  Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
771 @smallexample
772 #define max(a,b) \
773   (@{ __auto_type _a = (a); \
774       __auto_type _b = (b); \
775     _a > _b ? _a : _b; @})
776 @end smallexample
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
780 @itemize @bullet
781 @item Each argument to the macro appears only once in the expansion of
782 the macro.  This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
784 such macros.
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
789 @end itemize
791 @node Conditionals
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
799 The middle operand in a conditional expression may be omitted.  Then
800 if the first operand is nonzero, its value is the value of the conditional
801 expression.
803 Therefore, the expression
805 @smallexample
806 x ? : y
807 @end smallexample
809 @noindent
810 has the value of @code{x} if that is nonzero; otherwise, the value of
811 @code{y}.
813 This example is perfectly equivalent to
815 @smallexample
816 x ? x : y
817 @end smallexample
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
821 @noindent
822 In this simple case, the ability to omit the middle operand is not
823 especially useful.  When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect.  Then repeating
825 the operand in the middle would perform the side effect twice.  Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
829 @node __int128
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
840 @node Long Long
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer.  To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer.  To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines.  Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction.  Division and shifts are open-coded only on machines that
861 provide special support.  The operations that are not open-coded use
862 special library routines that come with GCC@.
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes.  If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}.  The best way to avoid such problems is to use prototypes.
872 @node Complex
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++.  GCC also supports complex integer data
880 types which are not part of ISO C99.  You can declare complex types
881 using the keyword @code{_Complex}.  As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
889 complete.
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}.  Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant.  This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
905 extract the imaginary part.  This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type.  This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa).  Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}.  You can
926 examine and set these two fictitious variables with your debugger.
928 @node Floating Types
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture.  These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
947 names can be used together with @code{_Complex} to declare complex
948 types.
950 As an extension, GNU C and GNU C++ support additional floating
951 types, @code{__float80} and @code{__float128} to support 80-bit
952 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types; these are
953 aliases for the type names @code{_Float64x} and @code{_Float128}.
954 Support for additional types includes the arithmetic operators:
955 add, subtract, multiply, divide; unary arithmetic operators;
956 relational operators; equality operators; and conversions to and from
957 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
958 in a literal constant of type @code{__float80} or type
959 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
961 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
962 types using the corresponding internal complex type, @code{XCmode} for
963 @code{__float80} type and @code{TCmode} for @code{__float128} type:
965 @smallexample
966 typedef _Complex float __attribute__((mode(TC))) _Complex128;
967 typedef _Complex float __attribute__((mode(XC))) _Complex80;
968 @end smallexample
970 In order to use @code{_Float128}, @code{__float128} and
971 @code{__ibm128} on PowerPC Linux
972 systems, you must use the @option{-mfloat128}. It is expected in
973 future versions of GCC that @code{_Float128} and @code{__float128}
974 will be enabled
975 automatically.  In addition, there are currently problems in using the
976 complex @code{__float128} type.  When these problems are fixed, you
977 would use the following syntax to declare @code{_Complex128} to be a
978 complex @code{__float128} type:
980 On the PowerPC Linux VSX targets, you can declare complex types using
981 the corresponding internal complex type, @code{KCmode} for
982 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
984 @smallexample
985 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
986 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
987 @end smallexample
989 Not all targets support additional floating-point types.
990 @code{__float80} and @code{__float128} types are supported on x86 and
991 IA-64 targets.  The @code{__float128} type is supported on hppa HP-UX.
992 The @code{__float128} type is supported on PowerPC 64-bit Linux
993 systems by default if the vector scalar instruction set (VSX) is
994 enabled.  The @code{_Float128} type is supported on all systems where
995 @code{__float128} is supported or where @code{long double} has the
996 IEEE binary128 format.  The @code{_Float64x} type is supported on all
997 systems where @code{__float128} is supported.  The @code{_Float32}
998 type is supported on all systems supporting IEEE binary32; the
999 @code{_Float64} and @code{Float32x} types are supported on all systems
1000 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
1001 systems by default, and on ARM systems when the IEEE format for 16-bit
1002 floating-point types is selected with @option{-mfp16-format=ieee}.
1003 GCC does not currently support @code{_Float128x} on any systems.
1005 On the PowerPC, @code{__ibm128} provides access to the IBM extended
1006 double format, and it is intended to be used by the library functions
1007 that handle conversions if/when long double is changed to be IEEE
1008 128-bit floating point.
1010 @node Half-Precision
1011 @section Half-Precision Floating Point
1012 @cindex half-precision floating point
1013 @cindex @code{__fp16} data type
1015 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1016 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1017 On ARM systems, you must enable this type explicitly with the
1018 @option{-mfp16-format} command-line option in order to use it.
1020 ARM targets support two incompatible representations for half-precision
1021 floating-point values.  You must choose one of the representations and
1022 use it consistently in your program.
1024 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1025 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1026 There are 11 bits of significand precision, approximately 3
1027 decimal digits.
1029 Specifying @option{-mfp16-format=alternative} selects the ARM
1030 alternative format.  This representation is similar to the IEEE
1031 format, but does not support infinities or NaNs.  Instead, the range
1032 of exponents is extended, so that this format can represent normalized
1033 values in the range of @math{2^{-14}} to 131008.
1035 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1036 not require use of the @option{-mfp16-format} command-line option.
1038 The @code{__fp16} type may only be used as an argument to intrinsics defined
1039 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1040 arithmetic and other operations, @code{__fp16} values in C or C++
1041 expressions are automatically promoted to @code{float}.
1043 The ARM target provides hardware support for conversions between
1044 @code{__fp16} and @code{float} values
1045 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8 provides
1046 hardware support for conversions between @code{__fp16} and @code{double}
1047 values.  GCC generates code using these hardware instructions if you
1048 compile with options to select an FPU that provides them;
1049 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1050 in addition to the @option{-mfp16-format} option to select
1051 a half-precision format.
1053 Language-level support for the @code{__fp16} data type is
1054 independent of whether GCC generates code using hardware floating-point
1055 instructions.  In cases where hardware support is not specified, GCC
1056 implements conversions between @code{__fp16} and other types as library
1057 calls.
1059 It is recommended that portable code use the @code{_Float16} type defined
1060 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1062 @node Decimal Float
1063 @section Decimal Floating Types
1064 @cindex decimal floating types
1065 @cindex @code{_Decimal32} data type
1066 @cindex @code{_Decimal64} data type
1067 @cindex @code{_Decimal128} data type
1068 @cindex @code{df} integer suffix
1069 @cindex @code{dd} integer suffix
1070 @cindex @code{dl} integer suffix
1071 @cindex @code{DF} integer suffix
1072 @cindex @code{DD} integer suffix
1073 @cindex @code{DL} integer suffix
1075 As an extension, GNU C supports decimal floating types as
1076 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1077 floating types in GCC will evolve as the draft technical report changes.
1078 Calling conventions for any target might also change.  Not all targets
1079 support decimal floating types.
1081 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1082 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1083 @code{float}, @code{double}, and @code{long double} whose radix is not
1084 specified by the C standard but is usually two.
1086 Support for decimal floating types includes the arithmetic operators
1087 add, subtract, multiply, divide; unary arithmetic operators;
1088 relational operators; equality operators; and conversions to and from
1089 integer and other floating types.  Use a suffix @samp{df} or
1090 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1091 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1092 @code{_Decimal128}.
1094 GCC support of decimal float as specified by the draft technical report
1095 is incomplete:
1097 @itemize @bullet
1098 @item
1099 When the value of a decimal floating type cannot be represented in the
1100 integer type to which it is being converted, the result is undefined
1101 rather than the result value specified by the draft technical report.
1103 @item
1104 GCC does not provide the C library functionality associated with
1105 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1106 @file{wchar.h}, which must come from a separate C library implementation.
1107 Because of this the GNU C compiler does not define macro
1108 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1109 the technical report.
1110 @end itemize
1112 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1113 are supported by the DWARF debug information format.
1115 @node Hex Floats
1116 @section Hex Floats
1117 @cindex hex floats
1119 ISO C99 supports floating-point numbers written not only in the usual
1120 decimal notation, such as @code{1.55e1}, but also numbers such as
1121 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1122 supports this in C90 mode (except in some cases when strictly
1123 conforming) and in C++.  In that format the
1124 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1125 mandatory.  The exponent is a decimal number that indicates the power of
1126 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1127 @tex
1128 $1 {15\over16}$,
1129 @end tex
1130 @ifnottex
1131 1 15/16,
1132 @end ifnottex
1133 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1134 is the same as @code{1.55e1}.
1136 Unlike for floating-point numbers in the decimal notation the exponent
1137 is always required in the hexadecimal notation.  Otherwise the compiler
1138 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1139 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1140 extension for floating-point constants of type @code{float}.
1142 @node Fixed-Point
1143 @section Fixed-Point Types
1144 @cindex fixed-point types
1145 @cindex @code{_Fract} data type
1146 @cindex @code{_Accum} data type
1147 @cindex @code{_Sat} data type
1148 @cindex @code{hr} fixed-suffix
1149 @cindex @code{r} fixed-suffix
1150 @cindex @code{lr} fixed-suffix
1151 @cindex @code{llr} fixed-suffix
1152 @cindex @code{uhr} fixed-suffix
1153 @cindex @code{ur} fixed-suffix
1154 @cindex @code{ulr} fixed-suffix
1155 @cindex @code{ullr} fixed-suffix
1156 @cindex @code{hk} fixed-suffix
1157 @cindex @code{k} fixed-suffix
1158 @cindex @code{lk} fixed-suffix
1159 @cindex @code{llk} fixed-suffix
1160 @cindex @code{uhk} fixed-suffix
1161 @cindex @code{uk} fixed-suffix
1162 @cindex @code{ulk} fixed-suffix
1163 @cindex @code{ullk} fixed-suffix
1164 @cindex @code{HR} fixed-suffix
1165 @cindex @code{R} fixed-suffix
1166 @cindex @code{LR} fixed-suffix
1167 @cindex @code{LLR} fixed-suffix
1168 @cindex @code{UHR} fixed-suffix
1169 @cindex @code{UR} fixed-suffix
1170 @cindex @code{ULR} fixed-suffix
1171 @cindex @code{ULLR} fixed-suffix
1172 @cindex @code{HK} fixed-suffix
1173 @cindex @code{K} fixed-suffix
1174 @cindex @code{LK} fixed-suffix
1175 @cindex @code{LLK} fixed-suffix
1176 @cindex @code{UHK} fixed-suffix
1177 @cindex @code{UK} fixed-suffix
1178 @cindex @code{ULK} fixed-suffix
1179 @cindex @code{ULLK} fixed-suffix
1181 As an extension, GNU C supports fixed-point types as
1182 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1183 types in GCC will evolve as the draft technical report changes.
1184 Calling conventions for any target might also change.  Not all targets
1185 support fixed-point types.
1187 The fixed-point types are
1188 @code{short _Fract},
1189 @code{_Fract},
1190 @code{long _Fract},
1191 @code{long long _Fract},
1192 @code{unsigned short _Fract},
1193 @code{unsigned _Fract},
1194 @code{unsigned long _Fract},
1195 @code{unsigned long long _Fract},
1196 @code{_Sat short _Fract},
1197 @code{_Sat _Fract},
1198 @code{_Sat long _Fract},
1199 @code{_Sat long long _Fract},
1200 @code{_Sat unsigned short _Fract},
1201 @code{_Sat unsigned _Fract},
1202 @code{_Sat unsigned long _Fract},
1203 @code{_Sat unsigned long long _Fract},
1204 @code{short _Accum},
1205 @code{_Accum},
1206 @code{long _Accum},
1207 @code{long long _Accum},
1208 @code{unsigned short _Accum},
1209 @code{unsigned _Accum},
1210 @code{unsigned long _Accum},
1211 @code{unsigned long long _Accum},
1212 @code{_Sat short _Accum},
1213 @code{_Sat _Accum},
1214 @code{_Sat long _Accum},
1215 @code{_Sat long long _Accum},
1216 @code{_Sat unsigned short _Accum},
1217 @code{_Sat unsigned _Accum},
1218 @code{_Sat unsigned long _Accum},
1219 @code{_Sat unsigned long long _Accum}.
1221 Fixed-point data values contain fractional and optional integral parts.
1222 The format of fixed-point data varies and depends on the target machine.
1224 Support for fixed-point types includes:
1225 @itemize @bullet
1226 @item
1227 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1228 @item
1229 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1230 @item
1231 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1232 @item
1233 binary shift operators (@code{<<}, @code{>>})
1234 @item
1235 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1236 @item
1237 equality operators (@code{==}, @code{!=})
1238 @item
1239 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1240 @code{<<=}, @code{>>=})
1241 @item
1242 conversions to and from integer, floating-point, or fixed-point types
1243 @end itemize
1245 Use a suffix in a fixed-point literal constant:
1246 @itemize
1247 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1248 @code{_Sat short _Fract}
1249 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1250 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1251 @code{_Sat long _Fract}
1252 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1253 @code{_Sat long long _Fract}
1254 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1255 @code{_Sat unsigned short _Fract}
1256 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1257 @code{_Sat unsigned _Fract}
1258 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1259 @code{_Sat unsigned long _Fract}
1260 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1261 and @code{_Sat unsigned long long _Fract}
1262 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1263 @code{_Sat short _Accum}
1264 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1265 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1266 @code{_Sat long _Accum}
1267 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1268 @code{_Sat long long _Accum}
1269 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1270 @code{_Sat unsigned short _Accum}
1271 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1272 @code{_Sat unsigned _Accum}
1273 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1274 @code{_Sat unsigned long _Accum}
1275 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1276 and @code{_Sat unsigned long long _Accum}
1277 @end itemize
1279 GCC support of fixed-point types as specified by the draft technical report
1280 is incomplete:
1282 @itemize @bullet
1283 @item
1284 Pragmas to control overflow and rounding behaviors are not implemented.
1285 @end itemize
1287 Fixed-point types are supported by the DWARF debug information format.
1289 @node Named Address Spaces
1290 @section Named Address Spaces
1291 @cindex Named Address Spaces
1293 As an extension, GNU C supports named address spaces as
1294 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1295 address spaces in GCC will evolve as the draft technical report
1296 changes.  Calling conventions for any target might also change.  At
1297 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1298 address spaces other than the generic address space.
1300 Address space identifiers may be used exactly like any other C type
1301 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1302 document for more details.
1304 @anchor{AVR Named Address Spaces}
1305 @subsection AVR Named Address Spaces
1307 On the AVR target, there are several address spaces that can be used
1308 in order to put read-only data into the flash memory and access that
1309 data by means of the special instructions @code{LPM} or @code{ELPM}
1310 needed to read from flash.
1312 Per default, any data including read-only data is located in RAM
1313 (the generic address space) so that non-generic address spaces are
1314 needed to locate read-only data in flash memory
1315 @emph{and} to generate the right instructions to access this data
1316 without using (inline) assembler code.
1318 @table @code
1319 @item __flash
1320 @cindex @code{__flash} AVR Named Address Spaces
1321 The @code{__flash} qualifier locates data in the
1322 @code{.progmem.data} section. Data is read using the @code{LPM}
1323 instruction. Pointers to this address space are 16 bits wide.
1325 @item __flash1
1326 @itemx __flash2
1327 @itemx __flash3
1328 @itemx __flash4
1329 @itemx __flash5
1330 @cindex @code{__flash1} AVR Named Address Spaces
1331 @cindex @code{__flash2} AVR Named Address Spaces
1332 @cindex @code{__flash3} AVR Named Address Spaces
1333 @cindex @code{__flash4} AVR Named Address Spaces
1334 @cindex @code{__flash5} AVR Named Address Spaces
1335 These are 16-bit address spaces locating data in section
1336 @code{.progmem@var{N}.data} where @var{N} refers to
1337 address space @code{__flash@var{N}}.
1338 The compiler sets the @code{RAMPZ} segment register appropriately 
1339 before reading data by means of the @code{ELPM} instruction.
1341 @item __memx
1342 @cindex @code{__memx} AVR Named Address Spaces
1343 This is a 24-bit address space that linearizes flash and RAM:
1344 If the high bit of the address is set, data is read from
1345 RAM using the lower two bytes as RAM address.
1346 If the high bit of the address is clear, data is read from flash
1347 with @code{RAMPZ} set according to the high byte of the address.
1348 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1350 Objects in this address space are located in @code{.progmemx.data}.
1351 @end table
1353 @b{Example}
1355 @smallexample
1356 char my_read (const __flash char ** p)
1358     /* p is a pointer to RAM that points to a pointer to flash.
1359        The first indirection of p reads that flash pointer
1360        from RAM and the second indirection reads a char from this
1361        flash address.  */
1363     return **p;
1366 /* Locate array[] in flash memory */
1367 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1369 int i = 1;
1371 int main (void)
1373    /* Return 17 by reading from flash memory */
1374    return array[array[i]];
1376 @end smallexample
1378 @noindent
1379 For each named address space supported by avr-gcc there is an equally
1380 named but uppercase built-in macro defined. 
1381 The purpose is to facilitate testing if respective address space
1382 support is available or not:
1384 @smallexample
1385 #ifdef __FLASH
1386 const __flash int var = 1;
1388 int read_var (void)
1390     return var;
1392 #else
1393 #include <avr/pgmspace.h> /* From AVR-LibC */
1395 const int var PROGMEM = 1;
1397 int read_var (void)
1399     return (int) pgm_read_word (&var);
1401 #endif /* __FLASH */
1402 @end smallexample
1404 @noindent
1405 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1406 locates data in flash but
1407 accesses to these data read from generic address space, i.e.@:
1408 from RAM,
1409 so that you need special accessors like @code{pgm_read_byte}
1410 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1411 together with attribute @code{progmem}.
1413 @noindent
1414 @b{Limitations and caveats}
1416 @itemize
1417 @item
1418 Reading across the 64@tie{}KiB section boundary of
1419 the @code{__flash} or @code{__flash@var{N}} address spaces
1420 shows undefined behavior. The only address space that
1421 supports reading across the 64@tie{}KiB flash segment boundaries is
1422 @code{__memx}.
1424 @item
1425 If you use one of the @code{__flash@var{N}} address spaces
1426 you must arrange your linker script to locate the
1427 @code{.progmem@var{N}.data} sections according to your needs.
1429 @item
1430 Any data or pointers to the non-generic address spaces must
1431 be qualified as @code{const}, i.e.@: as read-only data.
1432 This still applies if the data in one of these address
1433 spaces like software version number or calibration lookup table are intended to
1434 be changed after load time by, say, a boot loader. In this case
1435 the right qualification is @code{const} @code{volatile} so that the compiler
1436 must not optimize away known values or insert them
1437 as immediates into operands of instructions.
1439 @item
1440 The following code initializes a variable @code{pfoo}
1441 located in static storage with a 24-bit address:
1442 @smallexample
1443 extern const __memx char foo;
1444 const __memx void *pfoo = &foo;
1445 @end smallexample
1447 @noindent
1448 Such code requires at least binutils 2.23, see
1449 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1451 @item
1452 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1453 Data can be put into and read from flash memory by means of
1454 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1456 @end itemize
1458 @subsection M32C Named Address Spaces
1459 @cindex @code{__far} M32C Named Address Spaces
1461 On the M32C target, with the R8C and M16C CPU variants, variables
1462 qualified with @code{__far} are accessed using 32-bit addresses in
1463 order to access memory beyond the first 64@tie{}Ki bytes.  If
1464 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1465 effect.
1467 @subsection RL78 Named Address Spaces
1468 @cindex @code{__far} RL78 Named Address Spaces
1470 On the RL78 target, variables qualified with @code{__far} are accessed
1471 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1472 addresses.  Non-far variables are assumed to appear in the topmost
1473 64@tie{}KiB of the address space.
1475 @subsection SPU Named Address Spaces
1476 @cindex @code{__ea} SPU Named Address Spaces
1478 On the SPU target variables may be declared as
1479 belonging to another address space by qualifying the type with the
1480 @code{__ea} address space identifier:
1482 @smallexample
1483 extern int __ea i;
1484 @end smallexample
1486 @noindent 
1487 The compiler generates special code to access the variable @code{i}.
1488 It may use runtime library
1489 support, or generate special machine instructions to access that address
1490 space.
1492 @subsection x86 Named Address Spaces
1493 @cindex x86 named address spaces
1495 On the x86 target, variables may be declared as being relative
1496 to the @code{%fs} or @code{%gs} segments.
1498 @table @code
1499 @item __seg_fs
1500 @itemx __seg_gs
1501 @cindex @code{__seg_fs} x86 named address space
1502 @cindex @code{__seg_gs} x86 named address space
1503 The object is accessed with the respective segment override prefix.
1505 The respective segment base must be set via some method specific to
1506 the operating system.  Rather than require an expensive system call
1507 to retrieve the segment base, these address spaces are not considered
1508 to be subspaces of the generic (flat) address space.  This means that
1509 explicit casts are required to convert pointers between these address
1510 spaces and the generic address space.  In practice the application
1511 should cast to @code{uintptr_t} and apply the segment base offset
1512 that it installed previously.
1514 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1515 defined when these address spaces are supported.
1516 @end table
1518 @node Zero Length
1519 @section Arrays of Length Zero
1520 @cindex arrays of length zero
1521 @cindex zero-length arrays
1522 @cindex length-zero arrays
1523 @cindex flexible array members
1525 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1526 last element of a structure that is really a header for a variable-length
1527 object:
1529 @smallexample
1530 struct line @{
1531   int length;
1532   char contents[0];
1535 struct line *thisline = (struct line *)
1536   malloc (sizeof (struct line) + this_length);
1537 thisline->length = this_length;
1538 @end smallexample
1540 In ISO C90, you would have to give @code{contents} a length of 1, which
1541 means either you waste space or complicate the argument to @code{malloc}.
1543 In ISO C99, you would use a @dfn{flexible array member}, which is
1544 slightly different in syntax and semantics:
1546 @itemize @bullet
1547 @item
1548 Flexible array members are written as @code{contents[]} without
1549 the @code{0}.
1551 @item
1552 Flexible array members have incomplete type, and so the @code{sizeof}
1553 operator may not be applied.  As a quirk of the original implementation
1554 of zero-length arrays, @code{sizeof} evaluates to zero.
1556 @item
1557 Flexible array members may only appear as the last member of a
1558 @code{struct} that is otherwise non-empty.
1560 @item
1561 A structure containing a flexible array member, or a union containing
1562 such a structure (possibly recursively), may not be a member of a
1563 structure or an element of an array.  (However, these uses are
1564 permitted by GCC as extensions.)
1565 @end itemize
1567 Non-empty initialization of zero-length
1568 arrays is treated like any case where there are more initializer
1569 elements than the array holds, in that a suitable warning about ``excess
1570 elements in array'' is given, and the excess elements (all of them, in
1571 this case) are ignored.
1573 GCC allows static initialization of flexible array members.
1574 This is equivalent to defining a new structure containing the original
1575 structure followed by an array of sufficient size to contain the data.
1576 E.g.@: in the following, @code{f1} is constructed as if it were declared
1577 like @code{f2}.
1579 @smallexample
1580 struct f1 @{
1581   int x; int y[];
1582 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1584 struct f2 @{
1585   struct f1 f1; int data[3];
1586 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1587 @end smallexample
1589 @noindent
1590 The convenience of this extension is that @code{f1} has the desired
1591 type, eliminating the need to consistently refer to @code{f2.f1}.
1593 This has symmetry with normal static arrays, in that an array of
1594 unknown size is also written with @code{[]}.
1596 Of course, this extension only makes sense if the extra data comes at
1597 the end of a top-level object, as otherwise we would be overwriting
1598 data at subsequent offsets.  To avoid undue complication and confusion
1599 with initialization of deeply nested arrays, we simply disallow any
1600 non-empty initialization except when the structure is the top-level
1601 object.  For example:
1603 @smallexample
1604 struct foo @{ int x; int y[]; @};
1605 struct bar @{ struct foo z; @};
1607 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1608 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1609 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1610 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1611 @end smallexample
1613 @node Empty Structures
1614 @section Structures with No Members
1615 @cindex empty structures
1616 @cindex zero-size structures
1618 GCC permits a C structure to have no members:
1620 @smallexample
1621 struct empty @{
1623 @end smallexample
1625 The structure has size zero.  In C++, empty structures are part
1626 of the language.  G++ treats empty structures as if they had a single
1627 member of type @code{char}.
1629 @node Variable Length
1630 @section Arrays of Variable Length
1631 @cindex variable-length arrays
1632 @cindex arrays of variable length
1633 @cindex VLAs
1635 Variable-length automatic arrays are allowed in ISO C99, and as an
1636 extension GCC accepts them in C90 mode and in C++.  These arrays are
1637 declared like any other automatic arrays, but with a length that is not
1638 a constant expression.  The storage is allocated at the point of
1639 declaration and deallocated when the block scope containing the declaration
1640 exits.  For
1641 example:
1643 @smallexample
1644 FILE *
1645 concat_fopen (char *s1, char *s2, char *mode)
1647   char str[strlen (s1) + strlen (s2) + 1];
1648   strcpy (str, s1);
1649   strcat (str, s2);
1650   return fopen (str, mode);
1652 @end smallexample
1654 @cindex scope of a variable length array
1655 @cindex variable-length array scope
1656 @cindex deallocating variable length arrays
1657 Jumping or breaking out of the scope of the array name deallocates the
1658 storage.  Jumping into the scope is not allowed; you get an error
1659 message for it.
1661 @cindex variable-length array in a structure
1662 As an extension, GCC accepts variable-length arrays as a member of
1663 a structure or a union.  For example:
1665 @smallexample
1666 void
1667 foo (int n)
1669   struct S @{ int x[n]; @};
1671 @end smallexample
1673 @cindex @code{alloca} vs variable-length arrays
1674 You can use the function @code{alloca} to get an effect much like
1675 variable-length arrays.  The function @code{alloca} is available in
1676 many other C implementations (but not in all).  On the other hand,
1677 variable-length arrays are more elegant.
1679 There are other differences between these two methods.  Space allocated
1680 with @code{alloca} exists until the containing @emph{function} returns.
1681 The space for a variable-length array is deallocated as soon as the array
1682 name's scope ends, unless you also use @code{alloca} in this scope.
1684 You can also use variable-length arrays as arguments to functions:
1686 @smallexample
1687 struct entry
1688 tester (int len, char data[len][len])
1690   /* @r{@dots{}} */
1692 @end smallexample
1694 The length of an array is computed once when the storage is allocated
1695 and is remembered for the scope of the array in case you access it with
1696 @code{sizeof}.
1698 If you want to pass the array first and the length afterward, you can
1699 use a forward declaration in the parameter list---another GNU extension.
1701 @smallexample
1702 struct entry
1703 tester (int len; char data[len][len], int len)
1705   /* @r{@dots{}} */
1707 @end smallexample
1709 @cindex parameter forward declaration
1710 The @samp{int len} before the semicolon is a @dfn{parameter forward
1711 declaration}, and it serves the purpose of making the name @code{len}
1712 known when the declaration of @code{data} is parsed.
1714 You can write any number of such parameter forward declarations in the
1715 parameter list.  They can be separated by commas or semicolons, but the
1716 last one must end with a semicolon, which is followed by the ``real''
1717 parameter declarations.  Each forward declaration must match a ``real''
1718 declaration in parameter name and data type.  ISO C99 does not support
1719 parameter forward declarations.
1721 @node Variadic Macros
1722 @section Macros with a Variable Number of Arguments.
1723 @cindex variable number of arguments
1724 @cindex macro with variable arguments
1725 @cindex rest argument (in macro)
1726 @cindex variadic macros
1728 In the ISO C standard of 1999, a macro can be declared to accept a
1729 variable number of arguments much as a function can.  The syntax for
1730 defining the macro is similar to that of a function.  Here is an
1731 example:
1733 @smallexample
1734 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1735 @end smallexample
1737 @noindent
1738 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1739 such a macro, it represents the zero or more tokens until the closing
1740 parenthesis that ends the invocation, including any commas.  This set of
1741 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1742 wherever it appears.  See the CPP manual for more information.
1744 GCC has long supported variadic macros, and used a different syntax that
1745 allowed you to give a name to the variable arguments just like any other
1746 argument.  Here is an example:
1748 @smallexample
1749 #define debug(format, args...) fprintf (stderr, format, args)
1750 @end smallexample
1752 @noindent
1753 This is in all ways equivalent to the ISO C example above, but arguably
1754 more readable and descriptive.
1756 GNU CPP has two further variadic macro extensions, and permits them to
1757 be used with either of the above forms of macro definition.
1759 In standard C, you are not allowed to leave the variable argument out
1760 entirely; but you are allowed to pass an empty argument.  For example,
1761 this invocation is invalid in ISO C, because there is no comma after
1762 the string:
1764 @smallexample
1765 debug ("A message")
1766 @end smallexample
1768 GNU CPP permits you to completely omit the variable arguments in this
1769 way.  In the above examples, the compiler would complain, though since
1770 the expansion of the macro still has the extra comma after the format
1771 string.
1773 To help solve this problem, CPP behaves specially for variable arguments
1774 used with the token paste operator, @samp{##}.  If instead you write
1776 @smallexample
1777 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1778 @end smallexample
1780 @noindent
1781 and if the variable arguments are omitted or empty, the @samp{##}
1782 operator causes the preprocessor to remove the comma before it.  If you
1783 do provide some variable arguments in your macro invocation, GNU CPP
1784 does not complain about the paste operation and instead places the
1785 variable arguments after the comma.  Just like any other pasted macro
1786 argument, these arguments are not macro expanded.
1788 @node Escaped Newlines
1789 @section Slightly Looser Rules for Escaped Newlines
1790 @cindex escaped newlines
1791 @cindex newlines (escaped)
1793 The preprocessor treatment of escaped newlines is more relaxed 
1794 than that specified by the C90 standard, which requires the newline
1795 to immediately follow a backslash.  
1796 GCC's implementation allows whitespace in the form
1797 of spaces, horizontal and vertical tabs, and form feeds between the
1798 backslash and the subsequent newline.  The preprocessor issues a
1799 warning, but treats it as a valid escaped newline and combines the two
1800 lines to form a single logical line.  This works within comments and
1801 tokens, as well as between tokens.  Comments are @emph{not} treated as
1802 whitespace for the purposes of this relaxation, since they have not
1803 yet been replaced with spaces.
1805 @node Subscripting
1806 @section Non-Lvalue Arrays May Have Subscripts
1807 @cindex subscripting
1808 @cindex arrays, non-lvalue
1810 @cindex subscripting and function values
1811 In ISO C99, arrays that are not lvalues still decay to pointers, and
1812 may be subscripted, although they may not be modified or used after
1813 the next sequence point and the unary @samp{&} operator may not be
1814 applied to them.  As an extension, GNU C allows such arrays to be
1815 subscripted in C90 mode, though otherwise they do not decay to
1816 pointers outside C99 mode.  For example,
1817 this is valid in GNU C though not valid in C90:
1819 @smallexample
1820 @group
1821 struct foo @{int a[4];@};
1823 struct foo f();
1825 bar (int index)
1827   return f().a[index];
1829 @end group
1830 @end smallexample
1832 @node Pointer Arith
1833 @section Arithmetic on @code{void}- and Function-Pointers
1834 @cindex void pointers, arithmetic
1835 @cindex void, size of pointer to
1836 @cindex function pointers, arithmetic
1837 @cindex function, size of pointer to
1839 In GNU C, addition and subtraction operations are supported on pointers to
1840 @code{void} and on pointers to functions.  This is done by treating the
1841 size of a @code{void} or of a function as 1.
1843 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1844 and on function types, and returns 1.
1846 @opindex Wpointer-arith
1847 The option @option{-Wpointer-arith} requests a warning if these extensions
1848 are used.
1850 @node Pointers to Arrays
1851 @section Pointers to Arrays with Qualifiers Work as Expected
1852 @cindex pointers to arrays
1853 @cindex const qualifier
1855 In GNU C, pointers to arrays with qualifiers work similar to pointers
1856 to other qualified types. For example, a value of type @code{int (*)[5]}
1857 can be used to initialize a variable of type @code{const int (*)[5]}.
1858 These types are incompatible in ISO C because the @code{const} qualifier
1859 is formally attached to the element type of the array and not the
1860 array itself.
1862 @smallexample
1863 extern void
1864 transpose (int N, int M, double out[M][N], const double in[N][M]);
1865 double x[3][2];
1866 double y[2][3];
1867 @r{@dots{}}
1868 transpose(3, 2, y, x);
1869 @end smallexample
1871 @node Initializers
1872 @section Non-Constant Initializers
1873 @cindex initializers, non-constant
1874 @cindex non-constant initializers
1876 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1877 automatic variable are not required to be constant expressions in GNU C@.
1878 Here is an example of an initializer with run-time varying elements:
1880 @smallexample
1881 foo (float f, float g)
1883   float beat_freqs[2] = @{ f-g, f+g @};
1884   /* @r{@dots{}} */
1886 @end smallexample
1888 @node Compound Literals
1889 @section Compound Literals
1890 @cindex constructor expressions
1891 @cindex initializations in expressions
1892 @cindex structures, constructor expression
1893 @cindex expressions, constructor
1894 @cindex compound literals
1895 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1897 A compound literal looks like a cast of a brace-enclosed aggregate
1898 initializer list.  Its value is an object of the type specified in
1899 the cast, containing the elements specified in the initializer.
1900 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1901 C99 and later support compound literals.  As an extension, GCC
1902 supports compound literals also in C90 mode and in C++, although
1903 as explained below, the C++ semantics are somewhat different.
1905 Usually, the specified type of a compound literal is a structure.  Assume
1906 that @code{struct foo} and @code{structure} are declared as shown:
1908 @smallexample
1909 struct foo @{int a; char b[2];@} structure;
1910 @end smallexample
1912 @noindent
1913 Here is an example of constructing a @code{struct foo} with a compound literal:
1915 @smallexample
1916 structure = ((struct foo) @{x + y, 'a', 0@});
1917 @end smallexample
1919 @noindent
1920 This is equivalent to writing the following:
1922 @smallexample
1924   struct foo temp = @{x + y, 'a', 0@};
1925   structure = temp;
1927 @end smallexample
1929 You can also construct an array, though this is dangerous in C++, as
1930 explained below.  If all the elements of the compound literal are
1931 (made up of) simple constant expressions suitable for use in
1932 initializers of objects of static storage duration, then the compound
1933 literal can be coerced to a pointer to its first element and used in
1934 such an initializer, as shown here:
1936 @smallexample
1937 char **foo = (char *[]) @{ "x", "y", "z" @};
1938 @end smallexample
1940 Compound literals for scalar types and union types are also allowed.  In
1941 the following example the variable @code{i} is initialized to the value
1942 @code{2}, the result of incrementing the unnamed object created by
1943 the compound literal.
1945 @smallexample
1946 int i = ++(int) @{ 1 @};
1947 @end smallexample
1949 As a GNU extension, GCC allows initialization of objects with static storage
1950 duration by compound literals (which is not possible in ISO C99 because
1951 the initializer is not a constant).
1952 It is handled as if the object were initialized only with the brace-enclosed
1953 list if the types of the compound literal and the object match.
1954 The elements of the compound literal must be constant.
1955 If the object being initialized has array type of unknown size, the size is
1956 determined by the size of the compound literal.
1958 @smallexample
1959 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1960 static int y[] = (int []) @{1, 2, 3@};
1961 static int z[] = (int [3]) @{1@};
1962 @end smallexample
1964 @noindent
1965 The above lines are equivalent to the following:
1966 @smallexample
1967 static struct foo x = @{1, 'a', 'b'@};
1968 static int y[] = @{1, 2, 3@};
1969 static int z[] = @{1, 0, 0@};
1970 @end smallexample
1972 In C, a compound literal designates an unnamed object with static or
1973 automatic storage duration.  In C++, a compound literal designates a
1974 temporary object that only lives until the end of its full-expression.
1975 As a result, well-defined C code that takes the address of a subobject
1976 of a compound literal can be undefined in C++, so G++ rejects
1977 the conversion of a temporary array to a pointer.  For instance, if
1978 the array compound literal example above appeared inside a function,
1979 any subsequent use of @code{foo} in C++ would have undefined behavior
1980 because the lifetime of the array ends after the declaration of @code{foo}.
1982 As an optimization, G++ sometimes gives array compound literals longer
1983 lifetimes: when the array either appears outside a function or has
1984 a @code{const}-qualified type.  If @code{foo} and its initializer had
1985 elements of type @code{char *const} rather than @code{char *}, or if
1986 @code{foo} were a global variable, the array would have static storage
1987 duration.  But it is probably safest just to avoid the use of array
1988 compound literals in C++ code.
1990 @node Designated Inits
1991 @section Designated Initializers
1992 @cindex initializers with labeled elements
1993 @cindex labeled elements in initializers
1994 @cindex case labels in initializers
1995 @cindex designated initializers
1997 Standard C90 requires the elements of an initializer to appear in a fixed
1998 order, the same as the order of the elements in the array or structure
1999 being initialized.
2001 In ISO C99 you can give the elements in any order, specifying the array
2002 indices or structure field names they apply to, and GNU C allows this as
2003 an extension in C90 mode as well.  This extension is not
2004 implemented in GNU C++.
2006 To specify an array index, write
2007 @samp{[@var{index}] =} before the element value.  For example,
2009 @smallexample
2010 int a[6] = @{ [4] = 29, [2] = 15 @};
2011 @end smallexample
2013 @noindent
2014 is equivalent to
2016 @smallexample
2017 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2018 @end smallexample
2020 @noindent
2021 The index values must be constant expressions, even if the array being
2022 initialized is automatic.
2024 An alternative syntax for this that has been obsolete since GCC 2.5 but
2025 GCC still accepts is to write @samp{[@var{index}]} before the element
2026 value, with no @samp{=}.
2028 To initialize a range of elements to the same value, write
2029 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2030 extension.  For example,
2032 @smallexample
2033 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2034 @end smallexample
2036 @noindent
2037 If the value in it has side-effects, the side-effects happen only once,
2038 not for each initialized field by the range initializer.
2040 @noindent
2041 Note that the length of the array is the highest value specified
2042 plus one.
2044 In a structure initializer, specify the name of a field to initialize
2045 with @samp{.@var{fieldname} =} before the element value.  For example,
2046 given the following structure,
2048 @smallexample
2049 struct point @{ int x, y; @};
2050 @end smallexample
2052 @noindent
2053 the following initialization
2055 @smallexample
2056 struct point p = @{ .y = yvalue, .x = xvalue @};
2057 @end smallexample
2059 @noindent
2060 is equivalent to
2062 @smallexample
2063 struct point p = @{ xvalue, yvalue @};
2064 @end smallexample
2066 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2067 @samp{@var{fieldname}:}, as shown here:
2069 @smallexample
2070 struct point p = @{ y: yvalue, x: xvalue @};
2071 @end smallexample
2073 Omitted field members are implicitly initialized the same as objects
2074 that have static storage duration.
2076 @cindex designators
2077 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2078 @dfn{designator}.  You can also use a designator (or the obsolete colon
2079 syntax) when initializing a union, to specify which element of the union
2080 should be used.  For example,
2082 @smallexample
2083 union foo @{ int i; double d; @};
2085 union foo f = @{ .d = 4 @};
2086 @end smallexample
2088 @noindent
2089 converts 4 to a @code{double} to store it in the union using
2090 the second element.  By contrast, casting 4 to type @code{union foo}
2091 stores it into the union as the integer @code{i}, since it is
2092 an integer.  @xref{Cast to Union}.
2094 You can combine this technique of naming elements with ordinary C
2095 initialization of successive elements.  Each initializer element that
2096 does not have a designator applies to the next consecutive element of the
2097 array or structure.  For example,
2099 @smallexample
2100 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2101 @end smallexample
2103 @noindent
2104 is equivalent to
2106 @smallexample
2107 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2108 @end smallexample
2110 Labeling the elements of an array initializer is especially useful
2111 when the indices are characters or belong to an @code{enum} type.
2112 For example:
2114 @smallexample
2115 int whitespace[256]
2116   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2117       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2118 @end smallexample
2120 @cindex designator lists
2121 You can also write a series of @samp{.@var{fieldname}} and
2122 @samp{[@var{index}]} designators before an @samp{=} to specify a
2123 nested subobject to initialize; the list is taken relative to the
2124 subobject corresponding to the closest surrounding brace pair.  For
2125 example, with the @samp{struct point} declaration above:
2127 @smallexample
2128 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2129 @end smallexample
2131 @noindent
2132 If the same field is initialized multiple times, it has the value from
2133 the last initialization.  If any such overridden initialization has
2134 side-effect, it is unspecified whether the side-effect happens or not.
2135 Currently, GCC discards them and issues a warning.
2137 @node Case Ranges
2138 @section Case Ranges
2139 @cindex case ranges
2140 @cindex ranges in case statements
2142 You can specify a range of consecutive values in a single @code{case} label,
2143 like this:
2145 @smallexample
2146 case @var{low} ... @var{high}:
2147 @end smallexample
2149 @noindent
2150 This has the same effect as the proper number of individual @code{case}
2151 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2153 This feature is especially useful for ranges of ASCII character codes:
2155 @smallexample
2156 case 'A' ... 'Z':
2157 @end smallexample
2159 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2160 it may be parsed wrong when you use it with integer values.  For example,
2161 write this:
2163 @smallexample
2164 case 1 ... 5:
2165 @end smallexample
2167 @noindent
2168 rather than this:
2170 @smallexample
2171 case 1...5:
2172 @end smallexample
2174 @node Cast to Union
2175 @section Cast to a Union Type
2176 @cindex cast to a union
2177 @cindex union, casting to a
2179 A cast to union type looks similar to other casts, except that the type
2180 specified is a union type.  You can specify the type either with the
2181 @code{union} keyword or with a @code{typedef} name that refers to
2182 a union.  A cast to a union actually creates a compound literal and
2183 yields an lvalue, not an rvalue like true casts do.
2184 @xref{Compound Literals}.
2186 The types that may be cast to the union type are those of the members
2187 of the union.  Thus, given the following union and variables:
2189 @smallexample
2190 union foo @{ int i; double d; @};
2191 int x;
2192 double y;
2193 @end smallexample
2195 @noindent
2196 both @code{x} and @code{y} can be cast to type @code{union foo}.
2198 Using the cast as the right-hand side of an assignment to a variable of
2199 union type is equivalent to storing in a member of the union:
2201 @smallexample
2202 union foo u;
2203 /* @r{@dots{}} */
2204 u = (union foo) x  @equiv{}  u.i = x
2205 u = (union foo) y  @equiv{}  u.d = y
2206 @end smallexample
2208 You can also use the union cast as a function argument:
2210 @smallexample
2211 void hack (union foo);
2212 /* @r{@dots{}} */
2213 hack ((union foo) x);
2214 @end smallexample
2216 @node Mixed Declarations
2217 @section Mixed Declarations and Code
2218 @cindex mixed declarations and code
2219 @cindex declarations, mixed with code
2220 @cindex code, mixed with declarations
2222 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2223 within compound statements.  As an extension, GNU C also allows this in
2224 C90 mode.  For example, you could do:
2226 @smallexample
2227 int i;
2228 /* @r{@dots{}} */
2229 i++;
2230 int j = i + 2;
2231 @end smallexample
2233 Each identifier is visible from where it is declared until the end of
2234 the enclosing block.
2236 @node Function Attributes
2237 @section Declaring Attributes of Functions
2238 @cindex function attributes
2239 @cindex declaring attributes of functions
2240 @cindex @code{volatile} applied to function
2241 @cindex @code{const} applied to function
2243 In GNU C, you can use function attributes to declare certain things
2244 about functions called in your program which help the compiler
2245 optimize calls and check your code more carefully.  For example, you
2246 can use attributes to declare that a function never returns
2247 (@code{noreturn}), returns a value depending only on its arguments
2248 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2250 You can also use attributes to control memory placement, code
2251 generation options or call/return conventions within the function
2252 being annotated.  Many of these attributes are target-specific.  For
2253 example, many targets support attributes for defining interrupt
2254 handler functions, which typically must follow special register usage
2255 and return conventions.
2257 Function attributes are introduced by the @code{__attribute__} keyword
2258 on a declaration, followed by an attribute specification inside double
2259 parentheses.  You can specify multiple attributes in a declaration by
2260 separating them by commas within the double parentheses or by
2261 immediately following an attribute declaration with another attribute
2262 declaration.  @xref{Attribute Syntax}, for the exact rules on
2263 attribute syntax and placement.
2265 GCC also supports attributes on
2266 variable declarations (@pxref{Variable Attributes}),
2267 labels (@pxref{Label Attributes}),
2268 enumerators (@pxref{Enumerator Attributes}),
2269 statements (@pxref{Statement Attributes}),
2270 and types (@pxref{Type Attributes}).
2272 There is some overlap between the purposes of attributes and pragmas
2273 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2274 found convenient to use @code{__attribute__} to achieve a natural
2275 attachment of attributes to their corresponding declarations, whereas
2276 @code{#pragma} is of use for compatibility with other compilers
2277 or constructs that do not naturally form part of the grammar.
2279 In addition to the attributes documented here,
2280 GCC plugins may provide their own attributes.
2282 @menu
2283 * Common Function Attributes::
2284 * AArch64 Function Attributes::
2285 * ARC Function Attributes::
2286 * ARM Function Attributes::
2287 * AVR Function Attributes::
2288 * Blackfin Function Attributes::
2289 * CR16 Function Attributes::
2290 * Epiphany Function Attributes::
2291 * H8/300 Function Attributes::
2292 * IA-64 Function Attributes::
2293 * M32C Function Attributes::
2294 * M32R/D Function Attributes::
2295 * m68k Function Attributes::
2296 * MCORE Function Attributes::
2297 * MeP Function Attributes::
2298 * MicroBlaze Function Attributes::
2299 * Microsoft Windows Function Attributes::
2300 * MIPS Function Attributes::
2301 * MSP430 Function Attributes::
2302 * NDS32 Function Attributes::
2303 * Nios II Function Attributes::
2304 * Nvidia PTX Function Attributes::
2305 * PowerPC Function Attributes::
2306 * RL78 Function Attributes::
2307 * RX Function Attributes::
2308 * S/390 Function Attributes::
2309 * SH Function Attributes::
2310 * SPU Function Attributes::
2311 * Symbian OS Function Attributes::
2312 * V850 Function Attributes::
2313 * Visium Function Attributes::
2314 * x86 Function Attributes::
2315 * Xstormy16 Function Attributes::
2316 @end menu
2318 @node Common Function Attributes
2319 @subsection Common Function Attributes
2321 The following attributes are supported on most targets.
2323 @table @code
2324 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2326 @item alias ("@var{target}")
2327 @cindex @code{alias} function attribute
2328 The @code{alias} attribute causes the declaration to be emitted as an
2329 alias for another symbol, which must be specified.  For instance,
2331 @smallexample
2332 void __f () @{ /* @r{Do something.} */; @}
2333 void f () __attribute__ ((weak, alias ("__f")));
2334 @end smallexample
2336 @noindent
2337 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2338 mangled name for the target must be used.  It is an error if @samp{__f}
2339 is not defined in the same translation unit.
2341 This attribute requires assembler and object file support,
2342 and may not be available on all targets.
2344 @item aligned (@var{alignment})
2345 @cindex @code{aligned} function attribute
2346 This attribute specifies a minimum alignment for the function,
2347 measured in bytes.
2349 You cannot use this attribute to decrease the alignment of a function,
2350 only to increase it.  However, when you explicitly specify a function
2351 alignment this overrides the effect of the
2352 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2353 function.
2355 Note that the effectiveness of @code{aligned} attributes may be
2356 limited by inherent limitations in your linker.  On many systems, the
2357 linker is only able to arrange for functions to be aligned up to a
2358 certain maximum alignment.  (For some linkers, the maximum supported
2359 alignment may be very very small.)  See your linker documentation for
2360 further information.
2362 The @code{aligned} attribute can also be used for variables and fields
2363 (@pxref{Variable Attributes}.)
2365 @item alloc_align
2366 @cindex @code{alloc_align} function attribute
2367 The @code{alloc_align} attribute is used to tell the compiler that the
2368 function return value points to memory, where the returned pointer minimum
2369 alignment is given by one of the functions parameters.  GCC uses this
2370 information to improve pointer alignment analysis.
2372 The function parameter denoting the allocated alignment is specified by
2373 one integer argument, whose number is the argument of the attribute.
2374 Argument numbering starts at one.
2376 For instance,
2378 @smallexample
2379 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2380 @end smallexample
2382 @noindent
2383 declares that @code{my_memalign} returns memory with minimum alignment
2384 given by parameter 1.
2386 @item alloc_size
2387 @cindex @code{alloc_size} function attribute
2388 The @code{alloc_size} attribute is used to tell the compiler that the
2389 function return value points to memory, where the size is given by
2390 one or two of the functions parameters.  GCC uses this
2391 information to improve the correctness of @code{__builtin_object_size}.
2393 The function parameter(s) denoting the allocated size are specified by
2394 one or two integer arguments supplied to the attribute.  The allocated size
2395 is either the value of the single function argument specified or the product
2396 of the two function arguments specified.  Argument numbering starts at
2397 one.
2399 For instance,
2401 @smallexample
2402 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2403 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2404 @end smallexample
2406 @noindent
2407 declares that @code{my_calloc} returns memory of the size given by
2408 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2409 of the size given by parameter 2.
2411 @item always_inline
2412 @cindex @code{always_inline} function attribute
2413 Generally, functions are not inlined unless optimization is specified.
2414 For functions declared inline, this attribute inlines the function
2415 independent of any restrictions that otherwise apply to inlining.
2416 Failure to inline such a function is diagnosed as an error.
2417 Note that if such a function is called indirectly the compiler may
2418 or may not inline it depending on optimization level and a failure
2419 to inline an indirect call may or may not be diagnosed.
2421 @item artificial
2422 @cindex @code{artificial} function attribute
2423 This attribute is useful for small inline wrappers that if possible
2424 should appear during debugging as a unit.  Depending on the debug
2425 info format it either means marking the function as artificial
2426 or using the caller location for all instructions within the inlined
2427 body.
2429 @item assume_aligned
2430 @cindex @code{assume_aligned} function attribute
2431 The @code{assume_aligned} attribute is used to tell the compiler that the
2432 function return value points to memory, where the returned pointer minimum
2433 alignment is given by the first argument.
2434 If the attribute has two arguments, the second argument is misalignment offset.
2436 For instance
2438 @smallexample
2439 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2440 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2441 @end smallexample
2443 @noindent
2444 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2445 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2446 to 8.
2448 @item bnd_instrument
2449 @cindex @code{bnd_instrument} function attribute
2450 The @code{bnd_instrument} attribute on functions is used to inform the
2451 compiler that the function should be instrumented when compiled
2452 with the @option{-fchkp-instrument-marked-only} option.
2454 @item bnd_legacy
2455 @cindex @code{bnd_legacy} function attribute
2456 @cindex Pointer Bounds Checker attributes
2457 The @code{bnd_legacy} attribute on functions is used to inform the
2458 compiler that the function should not be instrumented when compiled
2459 with the @option{-fcheck-pointer-bounds} option.
2461 @item cold
2462 @cindex @code{cold} function attribute
2463 The @code{cold} attribute on functions is used to inform the compiler that
2464 the function is unlikely to be executed.  The function is optimized for
2465 size rather than speed and on many targets it is placed into a special
2466 subsection of the text section so all cold functions appear close together,
2467 improving code locality of non-cold parts of program.  The paths leading
2468 to calls of cold functions within code are marked as unlikely by the branch
2469 prediction mechanism.  It is thus useful to mark functions used to handle
2470 unlikely conditions, such as @code{perror}, as cold to improve optimization
2471 of hot functions that do call marked functions in rare occasions.
2473 When profile feedback is available, via @option{-fprofile-use}, cold functions
2474 are automatically detected and this attribute is ignored.
2476 @item const
2477 @cindex @code{const} function attribute
2478 @cindex functions that have no side effects
2479 Many functions do not examine any values except their arguments, and
2480 have no effects except the return value.  Basically this is just slightly
2481 more strict class than the @code{pure} attribute below, since function is not
2482 allowed to read global memory.
2484 @cindex pointer arguments
2485 Note that a function that has pointer arguments and examines the data
2486 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2487 function that calls a non-@code{const} function usually must not be
2488 @code{const}.  It does not make sense for a @code{const} function to
2489 return @code{void}.
2491 @item constructor
2492 @itemx destructor
2493 @itemx constructor (@var{priority})
2494 @itemx destructor (@var{priority})
2495 @cindex @code{constructor} function attribute
2496 @cindex @code{destructor} function attribute
2497 The @code{constructor} attribute causes the function to be called
2498 automatically before execution enters @code{main ()}.  Similarly, the
2499 @code{destructor} attribute causes the function to be called
2500 automatically after @code{main ()} completes or @code{exit ()} is
2501 called.  Functions with these attributes are useful for
2502 initializing data that is used implicitly during the execution of
2503 the program.
2505 You may provide an optional integer priority to control the order in
2506 which constructor and destructor functions are run.  A constructor
2507 with a smaller priority number runs before a constructor with a larger
2508 priority number; the opposite relationship holds for destructors.  So,
2509 if you have a constructor that allocates a resource and a destructor
2510 that deallocates the same resource, both functions typically have the
2511 same priority.  The priorities for constructor and destructor
2512 functions are the same as those specified for namespace-scope C++
2513 objects (@pxref{C++ Attributes}).
2515 @item deprecated
2516 @itemx deprecated (@var{msg})
2517 @cindex @code{deprecated} function attribute
2518 The @code{deprecated} attribute results in a warning if the function
2519 is used anywhere in the source file.  This is useful when identifying
2520 functions that are expected to be removed in a future version of a
2521 program.  The warning also includes the location of the declaration
2522 of the deprecated function, to enable users to easily find further
2523 information about why the function is deprecated, or what they should
2524 do instead.  Note that the warnings only occurs for uses:
2526 @smallexample
2527 int old_fn () __attribute__ ((deprecated));
2528 int old_fn ();
2529 int (*fn_ptr)() = old_fn;
2530 @end smallexample
2532 @noindent
2533 results in a warning on line 3 but not line 2.  The optional @var{msg}
2534 argument, which must be a string, is printed in the warning if
2535 present.
2537 The @code{deprecated} attribute can also be used for variables and
2538 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2540 @item error ("@var{message}")
2541 @itemx warning ("@var{message}")
2542 @cindex @code{error} function attribute
2543 @cindex @code{warning} function attribute
2544 If the @code{error} or @code{warning} attribute 
2545 is used on a function declaration and a call to such a function
2546 is not eliminated through dead code elimination or other optimizations, 
2547 an error or warning (respectively) that includes @var{message} is diagnosed.  
2548 This is useful
2549 for compile-time checking, especially together with @code{__builtin_constant_p}
2550 and inline functions where checking the inline function arguments is not
2551 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2553 While it is possible to leave the function undefined and thus invoke
2554 a link failure (to define the function with
2555 a message in @code{.gnu.warning*} section),
2556 when using these attributes the problem is diagnosed
2557 earlier and with exact location of the call even in presence of inline
2558 functions or when not emitting debugging information.
2560 @item externally_visible
2561 @cindex @code{externally_visible} function attribute
2562 This attribute, attached to a global variable or function, nullifies
2563 the effect of the @option{-fwhole-program} command-line option, so the
2564 object remains visible outside the current compilation unit.
2566 If @option{-fwhole-program} is used together with @option{-flto} and 
2567 @command{gold} is used as the linker plugin, 
2568 @code{externally_visible} attributes are automatically added to functions 
2569 (not variable yet due to a current @command{gold} issue) 
2570 that are accessed outside of LTO objects according to resolution file
2571 produced by @command{gold}.
2572 For other linkers that cannot generate resolution file,
2573 explicit @code{externally_visible} attributes are still necessary.
2575 @item flatten
2576 @cindex @code{flatten} function attribute
2577 Generally, inlining into a function is limited.  For a function marked with
2578 this attribute, every call inside this function is inlined, if possible.
2579 Whether the function itself is considered for inlining depends on its size and
2580 the current inlining parameters.
2582 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2583 @cindex @code{format} function attribute
2584 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2585 @opindex Wformat
2586 The @code{format} attribute specifies that a function takes @code{printf},
2587 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2588 should be type-checked against a format string.  For example, the
2589 declaration:
2591 @smallexample
2592 extern int
2593 my_printf (void *my_object, const char *my_format, ...)
2594       __attribute__ ((format (printf, 2, 3)));
2595 @end smallexample
2597 @noindent
2598 causes the compiler to check the arguments in calls to @code{my_printf}
2599 for consistency with the @code{printf} style format string argument
2600 @code{my_format}.
2602 The parameter @var{archetype} determines how the format string is
2603 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2604 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2605 @code{strfmon}.  (You can also use @code{__printf__},
2606 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2607 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2608 @code{ms_strftime} are also present.
2609 @var{archetype} values such as @code{printf} refer to the formats accepted
2610 by the system's C runtime library,
2611 while values prefixed with @samp{gnu_} always refer
2612 to the formats accepted by the GNU C Library.  On Microsoft Windows
2613 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2614 @file{msvcrt.dll} library.
2615 The parameter @var{string-index}
2616 specifies which argument is the format string argument (starting
2617 from 1), while @var{first-to-check} is the number of the first
2618 argument to check against the format string.  For functions
2619 where the arguments are not available to be checked (such as
2620 @code{vprintf}), specify the third parameter as zero.  In this case the
2621 compiler only checks the format string for consistency.  For
2622 @code{strftime} formats, the third parameter is required to be zero.
2623 Since non-static C++ methods have an implicit @code{this} argument, the
2624 arguments of such methods should be counted from two, not one, when
2625 giving values for @var{string-index} and @var{first-to-check}.
2627 In the example above, the format string (@code{my_format}) is the second
2628 argument of the function @code{my_print}, and the arguments to check
2629 start with the third argument, so the correct parameters for the format
2630 attribute are 2 and 3.
2632 @opindex ffreestanding
2633 @opindex fno-builtin
2634 The @code{format} attribute allows you to identify your own functions
2635 that take format strings as arguments, so that GCC can check the
2636 calls to these functions for errors.  The compiler always (unless
2637 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2638 for the standard library functions @code{printf}, @code{fprintf},
2639 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2640 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2641 warnings are requested (using @option{-Wformat}), so there is no need to
2642 modify the header file @file{stdio.h}.  In C99 mode, the functions
2643 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2644 @code{vsscanf} are also checked.  Except in strictly conforming C
2645 standard modes, the X/Open function @code{strfmon} is also checked as
2646 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2647 @xref{C Dialect Options,,Options Controlling C Dialect}.
2649 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2650 recognized in the same context.  Declarations including these format attributes
2651 are parsed for correct syntax, however the result of checking of such format
2652 strings is not yet defined, and is not carried out by this version of the
2653 compiler.
2655 The target may also provide additional types of format checks.
2656 @xref{Target Format Checks,,Format Checks Specific to Particular
2657 Target Machines}.
2659 @item format_arg (@var{string-index})
2660 @cindex @code{format_arg} function attribute
2661 @opindex Wformat-nonliteral
2662 The @code{format_arg} attribute specifies that a function takes a format
2663 string for a @code{printf}, @code{scanf}, @code{strftime} or
2664 @code{strfmon} style function and modifies it (for example, to translate
2665 it into another language), so the result can be passed to a
2666 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2667 function (with the remaining arguments to the format function the same
2668 as they would have been for the unmodified string).  For example, the
2669 declaration:
2671 @smallexample
2672 extern char *
2673 my_dgettext (char *my_domain, const char *my_format)
2674       __attribute__ ((format_arg (2)));
2675 @end smallexample
2677 @noindent
2678 causes the compiler to check the arguments in calls to a @code{printf},
2679 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2680 format string argument is a call to the @code{my_dgettext} function, for
2681 consistency with the format string argument @code{my_format}.  If the
2682 @code{format_arg} attribute had not been specified, all the compiler
2683 could tell in such calls to format functions would be that the format
2684 string argument is not constant; this would generate a warning when
2685 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2686 without the attribute.
2688 The parameter @var{string-index} specifies which argument is the format
2689 string argument (starting from one).  Since non-static C++ methods have
2690 an implicit @code{this} argument, the arguments of such methods should
2691 be counted from two.
2693 The @code{format_arg} attribute allows you to identify your own
2694 functions that modify format strings, so that GCC can check the
2695 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2696 type function whose operands are a call to one of your own function.
2697 The compiler always treats @code{gettext}, @code{dgettext}, and
2698 @code{dcgettext} in this manner except when strict ISO C support is
2699 requested by @option{-ansi} or an appropriate @option{-std} option, or
2700 @option{-ffreestanding} or @option{-fno-builtin}
2701 is used.  @xref{C Dialect Options,,Options
2702 Controlling C Dialect}.
2704 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2705 @code{NSString} reference for compatibility with the @code{format} attribute
2706 above.
2708 The target may also allow additional types in @code{format-arg} attributes.
2709 @xref{Target Format Checks,,Format Checks Specific to Particular
2710 Target Machines}.
2712 @item gnu_inline
2713 @cindex @code{gnu_inline} function attribute
2714 This attribute should be used with a function that is also declared
2715 with the @code{inline} keyword.  It directs GCC to treat the function
2716 as if it were defined in gnu90 mode even when compiling in C99 or
2717 gnu99 mode.
2719 If the function is declared @code{extern}, then this definition of the
2720 function is used only for inlining.  In no case is the function
2721 compiled as a standalone function, not even if you take its address
2722 explicitly.  Such an address becomes an external reference, as if you
2723 had only declared the function, and had not defined it.  This has
2724 almost the effect of a macro.  The way to use this is to put a
2725 function definition in a header file with this attribute, and put
2726 another copy of the function, without @code{extern}, in a library
2727 file.  The definition in the header file causes most calls to the
2728 function to be inlined.  If any uses of the function remain, they
2729 refer to the single copy in the library.  Note that the two
2730 definitions of the functions need not be precisely the same, although
2731 if they do not have the same effect your program may behave oddly.
2733 In C, if the function is neither @code{extern} nor @code{static}, then
2734 the function is compiled as a standalone function, as well as being
2735 inlined where possible.
2737 This is how GCC traditionally handled functions declared
2738 @code{inline}.  Since ISO C99 specifies a different semantics for
2739 @code{inline}, this function attribute is provided as a transition
2740 measure and as a useful feature in its own right.  This attribute is
2741 available in GCC 4.1.3 and later.  It is available if either of the
2742 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2743 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2744 Function is As Fast As a Macro}.
2746 In C++, this attribute does not depend on @code{extern} in any way,
2747 but it still requires the @code{inline} keyword to enable its special
2748 behavior.
2750 @item hot
2751 @cindex @code{hot} function attribute
2752 The @code{hot} attribute on a function is used to inform the compiler that
2753 the function is a hot spot of the compiled program.  The function is
2754 optimized more aggressively and on many targets it is placed into a special
2755 subsection of the text section so all hot functions appear close together,
2756 improving locality.
2758 When profile feedback is available, via @option{-fprofile-use}, hot functions
2759 are automatically detected and this attribute is ignored.
2761 @item ifunc ("@var{resolver}")
2762 @cindex @code{ifunc} function attribute
2763 @cindex indirect functions
2764 @cindex functions that are dynamically resolved
2765 The @code{ifunc} attribute is used to mark a function as an indirect
2766 function using the STT_GNU_IFUNC symbol type extension to the ELF
2767 standard.  This allows the resolution of the symbol value to be
2768 determined dynamically at load time, and an optimized version of the
2769 routine can be selected for the particular processor or other system
2770 characteristics determined then.  To use this attribute, first define
2771 the implementation functions available, and a resolver function that
2772 returns a pointer to the selected implementation function.  The
2773 implementation functions' declarations must match the API of the
2774 function being implemented, the resolver's declaration is be a
2775 function returning pointer to void function returning void:
2777 @smallexample
2778 void *my_memcpy (void *dst, const void *src, size_t len)
2780   @dots{}
2783 static void (*resolve_memcpy (void)) (void)
2785   return my_memcpy; // we'll just always select this routine
2787 @end smallexample
2789 @noindent
2790 The exported header file declaring the function the user calls would
2791 contain:
2793 @smallexample
2794 extern void *memcpy (void *, const void *, size_t);
2795 @end smallexample
2797 @noindent
2798 allowing the user to call this as a regular function, unaware of the
2799 implementation.  Finally, the indirect function needs to be defined in
2800 the same translation unit as the resolver function:
2802 @smallexample
2803 void *memcpy (void *, const void *, size_t)
2804      __attribute__ ((ifunc ("resolve_memcpy")));
2805 @end smallexample
2807 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2808 and GNU C Library version 2.11.1 are required to use this feature.
2810 @item interrupt
2811 @itemx interrupt_handler
2812 Many GCC back ends support attributes to indicate that a function is
2813 an interrupt handler, which tells the compiler to generate function
2814 entry and exit sequences that differ from those from regular
2815 functions.  The exact syntax and behavior are target-specific;
2816 refer to the following subsections for details.
2818 @item leaf
2819 @cindex @code{leaf} function attribute
2820 Calls to external functions with this attribute must return to the
2821 current compilation unit only by return or by exception handling.  In
2822 particular, a leaf function is not allowed to invoke callback functions
2823 passed to it from the current compilation unit, directly call functions
2824 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2825 might still call functions from other compilation units and thus they
2826 are not necessarily leaf in the sense that they contain no function
2827 calls at all.
2829 The attribute is intended for library functions to improve dataflow
2830 analysis.  The compiler takes the hint that any data not escaping the
2831 current compilation unit cannot be used or modified by the leaf
2832 function.  For example, the @code{sin} function is a leaf function, but
2833 @code{qsort} is not.
2835 Note that leaf functions might indirectly run a signal handler defined
2836 in the current compilation unit that uses static variables.  Similarly,
2837 when lazy symbol resolution is in effect, leaf functions might invoke
2838 indirect functions whose resolver function or implementation function is
2839 defined in the current compilation unit and uses static variables.  There
2840 is no standard-compliant way to write such a signal handler, resolver
2841 function, or implementation function, and the best that you can do is to
2842 remove the @code{leaf} attribute or mark all such static variables
2843 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2844 interposition, care should be taken that functions defined in the
2845 current compilation unit do not unexpectedly interpose other symbols
2846 based on the defined standards mode and defined feature test macros;
2847 otherwise an inadvertent callback would be added.
2849 The attribute has no effect on functions defined within the current
2850 compilation unit.  This is to allow easy merging of multiple compilation
2851 units into one, for example, by using the link-time optimization.  For
2852 this reason the attribute is not allowed on types to annotate indirect
2853 calls.
2855 @item malloc
2856 @cindex @code{malloc} function attribute
2857 @cindex functions that behave like malloc
2858 This tells the compiler that a function is @code{malloc}-like, i.e.,
2859 that the pointer @var{P} returned by the function cannot alias any
2860 other pointer valid when the function returns, and moreover no
2861 pointers to valid objects occur in any storage addressed by @var{P}.
2863 Using this attribute can improve optimization.  Functions like
2864 @code{malloc} and @code{calloc} have this property because they return
2865 a pointer to uninitialized or zeroed-out storage.  However, functions
2866 like @code{realloc} do not have this property, as they can return a
2867 pointer to storage containing pointers.
2869 @item no_icf
2870 @cindex @code{no_icf} function attribute
2871 This function attribute prevents a functions from being merged with another
2872 semantically equivalent function.
2874 @item no_instrument_function
2875 @cindex @code{no_instrument_function} function attribute
2876 @opindex finstrument-functions
2877 If @option{-finstrument-functions} is given, profiling function calls are
2878 generated at entry and exit of most user-compiled functions.
2879 Functions with this attribute are not so instrumented.
2881 @item no_profile_instrument_function
2882 @cindex @code{no_profile_instrument_function} function attribute
2883 The @code{no_profile_instrument_function} attribute on functions is used
2884 to inform the compiler that it should not process any profile feedback based
2885 optimization code instrumentation.
2887 @item no_reorder
2888 @cindex @code{no_reorder} function attribute
2889 Do not reorder functions or variables marked @code{no_reorder}
2890 against each other or top level assembler statements the executable.
2891 The actual order in the program will depend on the linker command
2892 line. Static variables marked like this are also not removed.
2893 This has a similar effect
2894 as the @option{-fno-toplevel-reorder} option, but only applies to the
2895 marked symbols.
2897 @item no_sanitize_address
2898 @itemx no_address_safety_analysis
2899 @cindex @code{no_sanitize_address} function attribute
2900 The @code{no_sanitize_address} attribute on functions is used
2901 to inform the compiler that it should not instrument memory accesses
2902 in the function when compiling with the @option{-fsanitize=address} option.
2903 The @code{no_address_safety_analysis} is a deprecated alias of the
2904 @code{no_sanitize_address} attribute, new code should use
2905 @code{no_sanitize_address}.
2907 @item no_sanitize_thread
2908 @cindex @code{no_sanitize_thread} function attribute
2909 The @code{no_sanitize_thread} attribute on functions is used
2910 to inform the compiler that it should not instrument memory accesses
2911 in the function when compiling with the @option{-fsanitize=thread} option.
2913 @item no_sanitize_undefined
2914 @cindex @code{no_sanitize_undefined} function attribute
2915 The @code{no_sanitize_undefined} attribute on functions is used
2916 to inform the compiler that it should not check for undefined behavior
2917 in the function when compiling with the @option{-fsanitize=undefined} option.
2919 @item no_split_stack
2920 @cindex @code{no_split_stack} function attribute
2921 @opindex fsplit-stack
2922 If @option{-fsplit-stack} is given, functions have a small
2923 prologue which decides whether to split the stack.  Functions with the
2924 @code{no_split_stack} attribute do not have that prologue, and thus
2925 may run with only a small amount of stack space available.
2927 @item no_stack_limit
2928 @cindex @code{no_stack_limit} function attribute
2929 This attribute locally overrides the @option{-fstack-limit-register}
2930 and @option{-fstack-limit-symbol} command-line options; it has the effect
2931 of disabling stack limit checking in the function it applies to.
2933 @item noclone
2934 @cindex @code{noclone} function attribute
2935 This function attribute prevents a function from being considered for
2936 cloning---a mechanism that produces specialized copies of functions
2937 and which is (currently) performed by interprocedural constant
2938 propagation.
2940 @item noinline
2941 @cindex @code{noinline} function attribute
2942 This function attribute prevents a function from being considered for
2943 inlining.
2944 @c Don't enumerate the optimizations by name here; we try to be
2945 @c future-compatible with this mechanism.
2946 If the function does not have side-effects, there are optimizations
2947 other than inlining that cause function calls to be optimized away,
2948 although the function call is live.  To keep such calls from being
2949 optimized away, put
2950 @smallexample
2951 asm ("");
2952 @end smallexample
2954 @noindent
2955 (@pxref{Extended Asm}) in the called function, to serve as a special
2956 side-effect.
2958 @item nonnull (@var{arg-index}, @dots{})
2959 @cindex @code{nonnull} function attribute
2960 @cindex functions with non-null pointer arguments
2961 The @code{nonnull} attribute specifies that some function parameters should
2962 be non-null pointers.  For instance, the declaration:
2964 @smallexample
2965 extern void *
2966 my_memcpy (void *dest, const void *src, size_t len)
2967         __attribute__((nonnull (1, 2)));
2968 @end smallexample
2970 @noindent
2971 causes the compiler to check that, in calls to @code{my_memcpy},
2972 arguments @var{dest} and @var{src} are non-null.  If the compiler
2973 determines that a null pointer is passed in an argument slot marked
2974 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2975 is issued.  The compiler may also choose to make optimizations based
2976 on the knowledge that certain function arguments will never be null.
2978 If no argument index list is given to the @code{nonnull} attribute,
2979 all pointer arguments are marked as non-null.  To illustrate, the
2980 following declaration is equivalent to the previous example:
2982 @smallexample
2983 extern void *
2984 my_memcpy (void *dest, const void *src, size_t len)
2985         __attribute__((nonnull));
2986 @end smallexample
2988 @item noplt
2989 @cindex @code{noplt} function attribute
2990 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2991 Calls to functions marked with this attribute in position-independent code
2992 do not use the PLT.
2994 @smallexample
2995 @group
2996 /* Externally defined function foo.  */
2997 int foo () __attribute__ ((noplt));
3000 main (/* @r{@dots{}} */)
3002   /* @r{@dots{}} */
3003   foo ();
3004   /* @r{@dots{}} */
3006 @end group
3007 @end smallexample
3009 The @code{noplt} attribute on function @code{foo}
3010 tells the compiler to assume that
3011 the function @code{foo} is externally defined and that the call to
3012 @code{foo} must avoid the PLT
3013 in position-independent code.
3015 In position-dependent code, a few targets also convert calls to
3016 functions that are marked to not use the PLT to use the GOT instead.
3018 @item noreturn
3019 @cindex @code{noreturn} function attribute
3020 @cindex functions that never return
3021 A few standard library functions, such as @code{abort} and @code{exit},
3022 cannot return.  GCC knows this automatically.  Some programs define
3023 their own functions that never return.  You can declare them
3024 @code{noreturn} to tell the compiler this fact.  For example,
3026 @smallexample
3027 @group
3028 void fatal () __attribute__ ((noreturn));
3030 void
3031 fatal (/* @r{@dots{}} */)
3033   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3034   exit (1);
3036 @end group
3037 @end smallexample
3039 The @code{noreturn} keyword tells the compiler to assume that
3040 @code{fatal} cannot return.  It can then optimize without regard to what
3041 would happen if @code{fatal} ever did return.  This makes slightly
3042 better code.  More importantly, it helps avoid spurious warnings of
3043 uninitialized variables.
3045 The @code{noreturn} keyword does not affect the exceptional path when that
3046 applies: a @code{noreturn}-marked function may still return to the caller
3047 by throwing an exception or calling @code{longjmp}.
3049 Do not assume that registers saved by the calling function are
3050 restored before calling the @code{noreturn} function.
3052 It does not make sense for a @code{noreturn} function to have a return
3053 type other than @code{void}.
3055 @item nothrow
3056 @cindex @code{nothrow} function attribute
3057 The @code{nothrow} attribute is used to inform the compiler that a
3058 function cannot throw an exception.  For example, most functions in
3059 the standard C library can be guaranteed not to throw an exception
3060 with the notable exceptions of @code{qsort} and @code{bsearch} that
3061 take function pointer arguments.
3063 @item optimize
3064 @cindex @code{optimize} function attribute
3065 The @code{optimize} attribute is used to specify that a function is to
3066 be compiled with different optimization options than specified on the
3067 command line.  Arguments can either be numbers or strings.  Numbers
3068 are assumed to be an optimization level.  Strings that begin with
3069 @code{O} are assumed to be an optimization option, while other options
3070 are assumed to be used with a @code{-f} prefix.  You can also use the
3071 @samp{#pragma GCC optimize} pragma to set the optimization options
3072 that affect more than one function.
3073 @xref{Function Specific Option Pragmas}, for details about the
3074 @samp{#pragma GCC optimize} pragma.
3076 This attribute should be used for debugging purposes only.  It is not
3077 suitable in production code.
3079 @item pure
3080 @cindex @code{pure} function attribute
3081 @cindex functions that have no side effects
3082 Many functions have no effects except the return value and their
3083 return value depends only on the parameters and/or global variables.
3084 Such a function can be subject
3085 to common subexpression elimination and loop optimization just as an
3086 arithmetic operator would be.  These functions should be declared
3087 with the attribute @code{pure}.  For example,
3089 @smallexample
3090 int square (int) __attribute__ ((pure));
3091 @end smallexample
3093 @noindent
3094 says that the hypothetical function @code{square} is safe to call
3095 fewer times than the program says.
3097 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3098 Interesting non-pure functions are functions with infinite loops or those
3099 depending on volatile memory or other system resource, that may change between
3100 two consecutive calls (such as @code{feof} in a multithreading environment).
3102 @item returns_nonnull
3103 @cindex @code{returns_nonnull} function attribute
3104 The @code{returns_nonnull} attribute specifies that the function
3105 return value should be a non-null pointer.  For instance, the declaration:
3107 @smallexample
3108 extern void *
3109 mymalloc (size_t len) __attribute__((returns_nonnull));
3110 @end smallexample
3112 @noindent
3113 lets the compiler optimize callers based on the knowledge
3114 that the return value will never be null.
3116 @item returns_twice
3117 @cindex @code{returns_twice} function attribute
3118 @cindex functions that return more than once
3119 The @code{returns_twice} attribute tells the compiler that a function may
3120 return more than one time.  The compiler ensures that all registers
3121 are dead before calling such a function and emits a warning about
3122 the variables that may be clobbered after the second return from the
3123 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3124 The @code{longjmp}-like counterpart of such function, if any, might need
3125 to be marked with the @code{noreturn} attribute.
3127 @item section ("@var{section-name}")
3128 @cindex @code{section} function attribute
3129 @cindex functions in arbitrary sections
3130 Normally, the compiler places the code it generates in the @code{text} section.
3131 Sometimes, however, you need additional sections, or you need certain
3132 particular functions to appear in special sections.  The @code{section}
3133 attribute specifies that a function lives in a particular section.
3134 For example, the declaration:
3136 @smallexample
3137 extern void foobar (void) __attribute__ ((section ("bar")));
3138 @end smallexample
3140 @noindent
3141 puts the function @code{foobar} in the @code{bar} section.
3143 Some file formats do not support arbitrary sections so the @code{section}
3144 attribute is not available on all platforms.
3145 If you need to map the entire contents of a module to a particular
3146 section, consider using the facilities of the linker instead.
3148 @item sentinel
3149 @cindex @code{sentinel} function attribute
3150 This function attribute ensures that a parameter in a function call is
3151 an explicit @code{NULL}.  The attribute is only valid on variadic
3152 functions.  By default, the sentinel is located at position zero, the
3153 last parameter of the function call.  If an optional integer position
3154 argument P is supplied to the attribute, the sentinel must be located at
3155 position P counting backwards from the end of the argument list.
3157 @smallexample
3158 __attribute__ ((sentinel))
3159 is equivalent to
3160 __attribute__ ((sentinel(0)))
3161 @end smallexample
3163 The attribute is automatically set with a position of 0 for the built-in
3164 functions @code{execl} and @code{execlp}.  The built-in function
3165 @code{execle} has the attribute set with a position of 1.
3167 A valid @code{NULL} in this context is defined as zero with any pointer
3168 type.  If your system defines the @code{NULL} macro with an integer type
3169 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3170 with a copy that redefines NULL appropriately.
3172 The warnings for missing or incorrect sentinels are enabled with
3173 @option{-Wformat}.
3175 @item simd
3176 @itemx simd("@var{mask}")
3177 @cindex @code{simd} function attribute
3178 This attribute enables creation of one or more function versions that
3179 can process multiple arguments using SIMD instructions from a
3180 single invocation.  Specifying this attribute allows compiler to
3181 assume that such versions are available at link time (provided
3182 in the same or another translation unit).  Generated versions are
3183 target-dependent and described in the corresponding Vector ABI document.  For
3184 x86_64 target this document can be found
3185 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3187 The optional argument @var{mask} may have the value
3188 @code{notinbranch} or @code{inbranch},
3189 and instructs the compiler to generate non-masked or masked
3190 clones correspondingly. By default, all clones are generated.
3192 The attribute should not be used together with Cilk Plus @code{vector}
3193 attribute on the same function.
3195 If the attribute is specified and @code{#pragma omp declare simd} is
3196 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3197 switch is specified, then the attribute is ignored.
3199 @item stack_protect
3200 @cindex @code{stack_protect} function attribute
3201 This attribute adds stack protection code to the function if 
3202 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3203 or @option{-fstack-protector-explicit} are set.
3205 @item target (@var{options})
3206 @cindex @code{target} function attribute
3207 Multiple target back ends implement the @code{target} attribute
3208 to specify that a function is to
3209 be compiled with different target options than specified on the
3210 command line.  This can be used for instance to have functions
3211 compiled with a different ISA (instruction set architecture) than the
3212 default.  You can also use the @samp{#pragma GCC target} pragma to set
3213 more than one function to be compiled with specific target options.
3214 @xref{Function Specific Option Pragmas}, for details about the
3215 @samp{#pragma GCC target} pragma.
3217 For instance, on an x86, you could declare one function with the
3218 @code{target("sse4.1,arch=core2")} attribute and another with
3219 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3220 compiling the first function with @option{-msse4.1} and
3221 @option{-march=core2} options, and the second function with
3222 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3223 to make sure that a function is only invoked on a machine that
3224 supports the particular ISA it is compiled for (for example by using
3225 @code{cpuid} on x86 to determine what feature bits and architecture
3226 family are used).
3228 @smallexample
3229 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3230 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3231 @end smallexample
3233 You can either use multiple
3234 strings separated by commas to specify multiple options,
3235 or separate the options with a comma (@samp{,}) within a single string.
3237 The options supported are specific to each target; refer to @ref{x86
3238 Function Attributes}, @ref{PowerPC Function Attributes},
3239 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3240 for details.
3242 @item target_clones (@var{options})
3243 @cindex @code{target_clones} function attribute
3244 The @code{target_clones} attribute is used to specify that a function
3245 be cloned into multiple versions compiled with different target options
3246 than specified on the command line.  The supported options and restrictions
3247 are the same as for @code{target} attribute.
3249 For instance, on an x86, you could compile a function with
3250 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3251 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3252 It also creates a resolver function (see the @code{ifunc} attribute
3253 above) that dynamically selects a clone suitable for current architecture.
3255 @item unused
3256 @cindex @code{unused} function attribute
3257 This attribute, attached to a function, means that the function is meant
3258 to be possibly unused.  GCC does not produce a warning for this
3259 function.
3261 @item used
3262 @cindex @code{used} function attribute
3263 This attribute, attached to a function, means that code must be emitted
3264 for the function even if it appears that the function is not referenced.
3265 This is useful, for example, when the function is referenced only in
3266 inline assembly.
3268 When applied to a member function of a C++ class template, the
3269 attribute also means that the function is instantiated if the
3270 class itself is instantiated.
3272 @item visibility ("@var{visibility_type}")
3273 @cindex @code{visibility} function attribute
3274 This attribute affects the linkage of the declaration to which it is attached.
3275 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3276 (@pxref{Common Type Attributes}) as well as functions.
3278 There are four supported @var{visibility_type} values: default,
3279 hidden, protected or internal visibility.
3281 @smallexample
3282 void __attribute__ ((visibility ("protected")))
3283 f () @{ /* @r{Do something.} */; @}
3284 int i __attribute__ ((visibility ("hidden")));
3285 @end smallexample
3287 The possible values of @var{visibility_type} correspond to the
3288 visibility settings in the ELF gABI.
3290 @table @code
3291 @c keep this list of visibilities in alphabetical order.
3293 @item default
3294 Default visibility is the normal case for the object file format.
3295 This value is available for the visibility attribute to override other
3296 options that may change the assumed visibility of entities.
3298 On ELF, default visibility means that the declaration is visible to other
3299 modules and, in shared libraries, means that the declared entity may be
3300 overridden.
3302 On Darwin, default visibility means that the declaration is visible to
3303 other modules.
3305 Default visibility corresponds to ``external linkage'' in the language.
3307 @item hidden
3308 Hidden visibility indicates that the entity declared has a new
3309 form of linkage, which we call ``hidden linkage''.  Two
3310 declarations of an object with hidden linkage refer to the same object
3311 if they are in the same shared object.
3313 @item internal
3314 Internal visibility is like hidden visibility, but with additional
3315 processor specific semantics.  Unless otherwise specified by the
3316 psABI, GCC defines internal visibility to mean that a function is
3317 @emph{never} called from another module.  Compare this with hidden
3318 functions which, while they cannot be referenced directly by other
3319 modules, can be referenced indirectly via function pointers.  By
3320 indicating that a function cannot be called from outside the module,
3321 GCC may for instance omit the load of a PIC register since it is known
3322 that the calling function loaded the correct value.
3324 @item protected
3325 Protected visibility is like default visibility except that it
3326 indicates that references within the defining module bind to the
3327 definition in that module.  That is, the declared entity cannot be
3328 overridden by another module.
3330 @end table
3332 All visibilities are supported on many, but not all, ELF targets
3333 (supported when the assembler supports the @samp{.visibility}
3334 pseudo-op).  Default visibility is supported everywhere.  Hidden
3335 visibility is supported on Darwin targets.
3337 The visibility attribute should be applied only to declarations that
3338 would otherwise have external linkage.  The attribute should be applied
3339 consistently, so that the same entity should not be declared with
3340 different settings of the attribute.
3342 In C++, the visibility attribute applies to types as well as functions
3343 and objects, because in C++ types have linkage.  A class must not have
3344 greater visibility than its non-static data member types and bases,
3345 and class members default to the visibility of their class.  Also, a
3346 declaration without explicit visibility is limited to the visibility
3347 of its type.
3349 In C++, you can mark member functions and static member variables of a
3350 class with the visibility attribute.  This is useful if you know a
3351 particular method or static member variable should only be used from
3352 one shared object; then you can mark it hidden while the rest of the
3353 class has default visibility.  Care must be taken to avoid breaking
3354 the One Definition Rule; for example, it is usually not useful to mark
3355 an inline method as hidden without marking the whole class as hidden.
3357 A C++ namespace declaration can also have the visibility attribute.
3359 @smallexample
3360 namespace nspace1 __attribute__ ((visibility ("protected")))
3361 @{ /* @r{Do something.} */; @}
3362 @end smallexample
3364 This attribute applies only to the particular namespace body, not to
3365 other definitions of the same namespace; it is equivalent to using
3366 @samp{#pragma GCC visibility} before and after the namespace
3367 definition (@pxref{Visibility Pragmas}).
3369 In C++, if a template argument has limited visibility, this
3370 restriction is implicitly propagated to the template instantiation.
3371 Otherwise, template instantiations and specializations default to the
3372 visibility of their template.
3374 If both the template and enclosing class have explicit visibility, the
3375 visibility from the template is used.
3377 @item warn_unused_result
3378 @cindex @code{warn_unused_result} function attribute
3379 The @code{warn_unused_result} attribute causes a warning to be emitted
3380 if a caller of the function with this attribute does not use its
3381 return value.  This is useful for functions where not checking
3382 the result is either a security problem or always a bug, such as
3383 @code{realloc}.
3385 @smallexample
3386 int fn () __attribute__ ((warn_unused_result));
3387 int foo ()
3389   if (fn () < 0) return -1;
3390   fn ();
3391   return 0;
3393 @end smallexample
3395 @noindent
3396 results in warning on line 5.
3398 @item weak
3399 @cindex @code{weak} function attribute
3400 The @code{weak} attribute causes the declaration to be emitted as a weak
3401 symbol rather than a global.  This is primarily useful in defining
3402 library functions that can be overridden in user code, though it can
3403 also be used with non-function declarations.  Weak symbols are supported
3404 for ELF targets, and also for a.out targets when using the GNU assembler
3405 and linker.
3407 @item weakref
3408 @itemx weakref ("@var{target}")
3409 @cindex @code{weakref} function attribute
3410 The @code{weakref} attribute marks a declaration as a weak reference.
3411 Without arguments, it should be accompanied by an @code{alias} attribute
3412 naming the target symbol.  Optionally, the @var{target} may be given as
3413 an argument to @code{weakref} itself.  In either case, @code{weakref}
3414 implicitly marks the declaration as @code{weak}.  Without a
3415 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3416 @code{weakref} is equivalent to @code{weak}.
3418 @smallexample
3419 static int x() __attribute__ ((weakref ("y")));
3420 /* is equivalent to... */
3421 static int x() __attribute__ ((weak, weakref, alias ("y")));
3422 /* and to... */
3423 static int x() __attribute__ ((weakref));
3424 static int x() __attribute__ ((alias ("y")));
3425 @end smallexample
3427 A weak reference is an alias that does not by itself require a
3428 definition to be given for the target symbol.  If the target symbol is
3429 only referenced through weak references, then it becomes a @code{weak}
3430 undefined symbol.  If it is directly referenced, however, then such
3431 strong references prevail, and a definition is required for the
3432 symbol, not necessarily in the same translation unit.
3434 The effect is equivalent to moving all references to the alias to a
3435 separate translation unit, renaming the alias to the aliased symbol,
3436 declaring it as weak, compiling the two separate translation units and
3437 performing a reloadable link on them.
3439 At present, a declaration to which @code{weakref} is attached can
3440 only be @code{static}.
3443 @end table
3445 @c This is the end of the target-independent attribute table
3447 @node AArch64 Function Attributes
3448 @subsection AArch64 Function Attributes
3450 The following target-specific function attributes are available for the
3451 AArch64 target.  For the most part, these options mirror the behavior of
3452 similar command-line options (@pxref{AArch64 Options}), but on a
3453 per-function basis.
3455 @table @code
3456 @item general-regs-only
3457 @cindex @code{general-regs-only} function attribute, AArch64
3458 Indicates that no floating-point or Advanced SIMD registers should be
3459 used when generating code for this function.  If the function explicitly
3460 uses floating-point code, then the compiler gives an error.  This is
3461 the same behavior as that of the command-line option
3462 @option{-mgeneral-regs-only}.
3464 @item fix-cortex-a53-835769
3465 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3466 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3467 applied to this function.  To explicitly disable the workaround for this
3468 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3469 This corresponds to the behavior of the command line options
3470 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3472 @item cmodel=
3473 @cindex @code{cmodel=} function attribute, AArch64
3474 Indicates that code should be generated for a particular code model for
3475 this function.  The behavior and permissible arguments are the same as
3476 for the command line option @option{-mcmodel=}.
3478 @item strict-align
3479 @cindex @code{strict-align} function attribute, AArch64
3480 Indicates that the compiler should not assume that unaligned memory references
3481 are handled by the system.  The behavior is the same as for the command-line
3482 option @option{-mstrict-align}.
3484 @item omit-leaf-frame-pointer
3485 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3486 Indicates that the frame pointer should be omitted for a leaf function call.
3487 To keep the frame pointer, the inverse attribute
3488 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3489 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3490 and @option{-mno-omit-leaf-frame-pointer}.
3492 @item tls-dialect=
3493 @cindex @code{tls-dialect=} function attribute, AArch64
3494 Specifies the TLS dialect to use for this function.  The behavior and
3495 permissible arguments are the same as for the command-line option
3496 @option{-mtls-dialect=}.
3498 @item arch=
3499 @cindex @code{arch=} function attribute, AArch64
3500 Specifies the architecture version and architectural extensions to use
3501 for this function.  The behavior and permissible arguments are the same as
3502 for the @option{-march=} command-line option.
3504 @item tune=
3505 @cindex @code{tune=} function attribute, AArch64
3506 Specifies the core for which to tune the performance of this function.
3507 The behavior and permissible arguments are the same as for the @option{-mtune=}
3508 command-line option.
3510 @item cpu=
3511 @cindex @code{cpu=} function attribute, AArch64
3512 Specifies the core for which to tune the performance of this function and also
3513 whose architectural features to use.  The behavior and valid arguments are the
3514 same as for the @option{-mcpu=} command-line option.
3516 @end table
3518 The above target attributes can be specified as follows:
3520 @smallexample
3521 __attribute__((target("@var{attr-string}")))
3523 f (int a)
3525   return a + 5;
3527 @end smallexample
3529 where @code{@var{attr-string}} is one of the attribute strings specified above.
3531 Additionally, the architectural extension string may be specified on its
3532 own.  This can be used to turn on and off particular architectural extensions
3533 without having to specify a particular architecture version or core.  Example:
3535 @smallexample
3536 __attribute__((target("+crc+nocrypto")))
3538 foo (int a)
3540   return a + 5;
3542 @end smallexample
3544 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3545 extension and disables the @code{crypto} extension for the function @code{foo}
3546 without modifying an existing @option{-march=} or @option{-mcpu} option.
3548 Multiple target function attributes can be specified by separating them with
3549 a comma.  For example:
3550 @smallexample
3551 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3553 foo (int a)
3555   return a + 5;
3557 @end smallexample
3559 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3560 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3562 @subsubsection Inlining rules
3563 Specifying target attributes on individual functions or performing link-time
3564 optimization across translation units compiled with different target options
3565 can affect function inlining rules:
3567 In particular, a caller function can inline a callee function only if the
3568 architectural features available to the callee are a subset of the features
3569 available to the caller.
3570 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3571 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3572 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3573 because the all the architectural features that function @code{bar} requires
3574 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3575 inline function @code{foo}.
3577 Additionally inlining a function compiled with @option{-mstrict-align} into a
3578 function compiled without @code{-mstrict-align} is not allowed.
3579 However, inlining a function compiled without @option{-mstrict-align} into a
3580 function compiled with @option{-mstrict-align} is allowed.
3582 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3583 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3584 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3585 architectural feature rules specified above.
3587 @node ARC Function Attributes
3588 @subsection ARC Function Attributes
3590 These function attributes are supported by the ARC back end:
3592 @table @code
3593 @item interrupt
3594 @cindex @code{interrupt} function attribute, ARC
3595 Use this attribute to indicate
3596 that the specified function is an interrupt handler.  The compiler generates
3597 function entry and exit sequences suitable for use in an interrupt handler
3598 when this attribute is present.
3600 On the ARC, you must specify the kind of interrupt to be handled
3601 in a parameter to the interrupt attribute like this:
3603 @smallexample
3604 void f () __attribute__ ((interrupt ("ilink1")));
3605 @end smallexample
3607 Permissible values for this parameter are: @w{@code{ilink1}} and
3608 @w{@code{ilink2}}.
3610 @item long_call
3611 @itemx medium_call
3612 @itemx short_call
3613 @cindex @code{long_call} function attribute, ARC
3614 @cindex @code{medium_call} function attribute, ARC
3615 @cindex @code{short_call} function attribute, ARC
3616 @cindex indirect calls, ARC
3617 These attributes specify how a particular function is called.
3618 These attributes override the
3619 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3620 command-line switches and @code{#pragma long_calls} settings.
3622 For ARC, a function marked with the @code{long_call} attribute is
3623 always called using register-indirect jump-and-link instructions,
3624 thereby enabling the called function to be placed anywhere within the
3625 32-bit address space.  A function marked with the @code{medium_call}
3626 attribute will always be close enough to be called with an unconditional
3627 branch-and-link instruction, which has a 25-bit offset from
3628 the call site.  A function marked with the @code{short_call}
3629 attribute will always be close enough to be called with a conditional
3630 branch-and-link instruction, which has a 21-bit offset from
3631 the call site.
3632 @end table
3634 @node ARM Function Attributes
3635 @subsection ARM Function Attributes
3637 These function attributes are supported for ARM targets:
3639 @table @code
3640 @item interrupt
3641 @cindex @code{interrupt} function attribute, ARM
3642 Use this attribute to indicate
3643 that the specified function is an interrupt handler.  The compiler generates
3644 function entry and exit sequences suitable for use in an interrupt handler
3645 when this attribute is present.
3647 You can specify the kind of interrupt to be handled by
3648 adding an optional parameter to the interrupt attribute like this:
3650 @smallexample
3651 void f () __attribute__ ((interrupt ("IRQ")));
3652 @end smallexample
3654 @noindent
3655 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3656 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3658 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3659 may be called with a word-aligned stack pointer.
3661 @item isr
3662 @cindex @code{isr} function attribute, ARM
3663 Use this attribute on ARM to write Interrupt Service Routines. This is an
3664 alias to the @code{interrupt} attribute above.
3666 @item long_call
3667 @itemx short_call
3668 @cindex @code{long_call} function attribute, ARM
3669 @cindex @code{short_call} function attribute, ARM
3670 @cindex indirect calls, ARM
3671 These attributes specify how a particular function is called.
3672 These attributes override the
3673 @option{-mlong-calls} (@pxref{ARM Options})
3674 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3675 @code{long_call} attribute indicates that the function might be far
3676 away from the call site and require a different (more expensive)
3677 calling sequence.   The @code{short_call} attribute always places
3678 the offset to the function from the call site into the @samp{BL}
3679 instruction directly.
3681 @item naked
3682 @cindex @code{naked} function attribute, ARM
3683 This attribute allows the compiler to construct the
3684 requisite function declaration, while allowing the body of the
3685 function to be assembly code. The specified function will not have
3686 prologue/epilogue sequences generated by the compiler. Only basic
3687 @code{asm} statements can safely be included in naked functions
3688 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3689 basic @code{asm} and C code may appear to work, they cannot be
3690 depended upon to work reliably and are not supported.
3692 @item pcs
3693 @cindex @code{pcs} function attribute, ARM
3695 The @code{pcs} attribute can be used to control the calling convention
3696 used for a function on ARM.  The attribute takes an argument that specifies
3697 the calling convention to use.
3699 When compiling using the AAPCS ABI (or a variant of it) then valid
3700 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3701 order to use a variant other than @code{"aapcs"} then the compiler must
3702 be permitted to use the appropriate co-processor registers (i.e., the
3703 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3704 For example,
3706 @smallexample
3707 /* Argument passed in r0, and result returned in r0+r1.  */
3708 double f2d (float) __attribute__((pcs("aapcs")));
3709 @end smallexample
3711 Variadic functions always use the @code{"aapcs"} calling convention and
3712 the compiler rejects attempts to specify an alternative.
3714 @item target (@var{options})
3715 @cindex @code{target} function attribute
3716 As discussed in @ref{Common Function Attributes}, this attribute 
3717 allows specification of target-specific compilation options.
3719 On ARM, the following options are allowed:
3721 @table @samp
3722 @item thumb
3723 @cindex @code{target("thumb")} function attribute, ARM
3724 Force code generation in the Thumb (T16/T32) ISA, depending on the
3725 architecture level.
3727 @item arm
3728 @cindex @code{target("arm")} function attribute, ARM
3729 Force code generation in the ARM (A32) ISA.
3731 Functions from different modes can be inlined in the caller's mode.
3733 @item fpu=
3734 @cindex @code{target("fpu=")} function attribute, ARM
3735 Specifies the fpu for which to tune the performance of this function.
3736 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3737 command-line option.
3739 @end table
3741 @end table
3743 @node AVR Function Attributes
3744 @subsection AVR Function Attributes
3746 These function attributes are supported by the AVR back end:
3748 @table @code
3749 @item interrupt
3750 @cindex @code{interrupt} function attribute, AVR
3751 Use this attribute to indicate
3752 that the specified function is an interrupt handler.  The compiler generates
3753 function entry and exit sequences suitable for use in an interrupt handler
3754 when this attribute is present.
3756 On the AVR, the hardware globally disables interrupts when an
3757 interrupt is executed.  The first instruction of an interrupt handler
3758 declared with this attribute is a @code{SEI} instruction to
3759 re-enable interrupts.  See also the @code{signal} function attribute
3760 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3761 @code{interrupt} are specified for the same function, @code{signal}
3762 is silently ignored.
3764 @item naked
3765 @cindex @code{naked} function attribute, AVR
3766 This attribute allows the compiler to construct the
3767 requisite function declaration, while allowing the body of the
3768 function to be assembly code. The specified function will not have
3769 prologue/epilogue sequences generated by the compiler. Only basic
3770 @code{asm} statements can safely be included in naked functions
3771 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3772 basic @code{asm} and C code may appear to work, they cannot be
3773 depended upon to work reliably and are not supported.
3775 @item OS_main
3776 @itemx OS_task
3777 @cindex @code{OS_main} function attribute, AVR
3778 @cindex @code{OS_task} function attribute, AVR
3779 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3780 do not save/restore any call-saved register in their prologue/epilogue.
3782 The @code{OS_main} attribute can be used when there @emph{is
3783 guarantee} that interrupts are disabled at the time when the function
3784 is entered.  This saves resources when the stack pointer has to be
3785 changed to set up a frame for local variables.
3787 The @code{OS_task} attribute can be used when there is @emph{no
3788 guarantee} that interrupts are disabled at that time when the function
3789 is entered like for, e@.g@. task functions in a multi-threading operating
3790 system. In that case, changing the stack pointer register is
3791 guarded by save/clear/restore of the global interrupt enable flag.
3793 The differences to the @code{naked} function attribute are:
3794 @itemize @bullet
3795 @item @code{naked} functions do not have a return instruction whereas 
3796 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3797 @code{RETI} return instruction.
3798 @item @code{naked} functions do not set up a frame for local variables
3799 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3800 as needed.
3801 @end itemize
3803 @item signal
3804 @cindex @code{signal} function attribute, AVR
3805 Use this attribute on the AVR to indicate that the specified
3806 function is an interrupt handler.  The compiler generates function
3807 entry and exit sequences suitable for use in an interrupt handler when this
3808 attribute is present.
3810 See also the @code{interrupt} function attribute. 
3812 The AVR hardware globally disables interrupts when an interrupt is executed.
3813 Interrupt handler functions defined with the @code{signal} attribute
3814 do not re-enable interrupts.  It is save to enable interrupts in a
3815 @code{signal} handler.  This ``save'' only applies to the code
3816 generated by the compiler and not to the IRQ layout of the
3817 application which is responsibility of the application.
3819 If both @code{signal} and @code{interrupt} are specified for the same
3820 function, @code{signal} is silently ignored.
3821 @end table
3823 @node Blackfin Function Attributes
3824 @subsection Blackfin Function Attributes
3826 These function attributes are supported by the Blackfin back end:
3828 @table @code
3830 @item exception_handler
3831 @cindex @code{exception_handler} function attribute
3832 @cindex exception handler functions, Blackfin
3833 Use this attribute on the Blackfin to indicate that the specified function
3834 is an exception handler.  The compiler generates function entry and
3835 exit sequences suitable for use in an exception handler when this
3836 attribute is present.
3838 @item interrupt_handler
3839 @cindex @code{interrupt_handler} function attribute, Blackfin
3840 Use this attribute to
3841 indicate that the specified function is an interrupt handler.  The compiler
3842 generates function entry and exit sequences suitable for use in an
3843 interrupt handler when this attribute is present.
3845 @item kspisusp
3846 @cindex @code{kspisusp} function attribute, Blackfin
3847 @cindex User stack pointer in interrupts on the Blackfin
3848 When used together with @code{interrupt_handler}, @code{exception_handler}
3849 or @code{nmi_handler}, code is generated to load the stack pointer
3850 from the USP register in the function prologue.
3852 @item l1_text
3853 @cindex @code{l1_text} function attribute, Blackfin
3854 This attribute specifies a function to be placed into L1 Instruction
3855 SRAM@. The function is put into a specific section named @code{.l1.text}.
3856 With @option{-mfdpic}, function calls with a such function as the callee
3857 or caller uses inlined PLT.
3859 @item l2
3860 @cindex @code{l2} function attribute, Blackfin
3861 This attribute specifies a function to be placed into L2
3862 SRAM. The function is put into a specific section named
3863 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3864 an inlined PLT.
3866 @item longcall
3867 @itemx shortcall
3868 @cindex indirect calls, Blackfin
3869 @cindex @code{longcall} function attribute, Blackfin
3870 @cindex @code{shortcall} function attribute, Blackfin
3871 The @code{longcall} attribute
3872 indicates that the function might be far away from the call site and
3873 require a different (more expensive) calling sequence.  The
3874 @code{shortcall} attribute indicates that the function is always close
3875 enough for the shorter calling sequence to be used.  These attributes
3876 override the @option{-mlongcall} switch.
3878 @item nesting
3879 @cindex @code{nesting} function attribute, Blackfin
3880 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3881 Use this attribute together with @code{interrupt_handler},
3882 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3883 entry code should enable nested interrupts or exceptions.
3885 @item nmi_handler
3886 @cindex @code{nmi_handler} function attribute, Blackfin
3887 @cindex NMI handler functions on the Blackfin processor
3888 Use this attribute on the Blackfin to indicate that the specified function
3889 is an NMI handler.  The compiler generates function entry and
3890 exit sequences suitable for use in an NMI handler when this
3891 attribute is present.
3893 @item saveall
3894 @cindex @code{saveall} function attribute, Blackfin
3895 @cindex save all registers on the Blackfin
3896 Use this attribute to indicate that
3897 all registers except the stack pointer should be saved in the prologue
3898 regardless of whether they are used or not.
3899 @end table
3901 @node CR16 Function Attributes
3902 @subsection CR16 Function Attributes
3904 These function attributes are supported by the CR16 back end:
3906 @table @code
3907 @item interrupt
3908 @cindex @code{interrupt} function attribute, CR16
3909 Use this attribute to indicate
3910 that the specified function is an interrupt handler.  The compiler generates
3911 function entry and exit sequences suitable for use in an interrupt handler
3912 when this attribute is present.
3913 @end table
3915 @node Epiphany Function Attributes
3916 @subsection Epiphany Function Attributes
3918 These function attributes are supported by the Epiphany back end:
3920 @table @code
3921 @item disinterrupt
3922 @cindex @code{disinterrupt} function attribute, Epiphany
3923 This attribute causes the compiler to emit
3924 instructions to disable interrupts for the duration of the given
3925 function.
3927 @item forwarder_section
3928 @cindex @code{forwarder_section} function attribute, Epiphany
3929 This attribute modifies the behavior of an interrupt handler.
3930 The interrupt handler may be in external memory which cannot be
3931 reached by a branch instruction, so generate a local memory trampoline
3932 to transfer control.  The single parameter identifies the section where
3933 the trampoline is placed.
3935 @item interrupt
3936 @cindex @code{interrupt} function attribute, Epiphany
3937 Use this attribute to indicate
3938 that the specified function is an interrupt handler.  The compiler generates
3939 function entry and exit sequences suitable for use in an interrupt handler
3940 when this attribute is present.  It may also generate
3941 a special section with code to initialize the interrupt vector table.
3943 On Epiphany targets one or more optional parameters can be added like this:
3945 @smallexample
3946 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3947 @end smallexample
3949 Permissible values for these parameters are: @w{@code{reset}},
3950 @w{@code{software_exception}}, @w{@code{page_miss}},
3951 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3952 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3953 Multiple parameters indicate that multiple entries in the interrupt
3954 vector table should be initialized for this function, i.e.@: for each
3955 parameter @w{@var{name}}, a jump to the function is emitted in
3956 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3957 entirely, in which case no interrupt vector table entry is provided.
3959 Note that interrupts are enabled inside the function
3960 unless the @code{disinterrupt} attribute is also specified.
3962 The following examples are all valid uses of these attributes on
3963 Epiphany targets:
3964 @smallexample
3965 void __attribute__ ((interrupt)) universal_handler ();
3966 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3967 void __attribute__ ((interrupt ("dma0, dma1"))) 
3968   universal_dma_handler ();
3969 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3970   fast_timer_handler ();
3971 void __attribute__ ((interrupt ("dma0, dma1"), 
3972                      forwarder_section ("tramp")))
3973   external_dma_handler ();
3974 @end smallexample
3976 @item long_call
3977 @itemx short_call
3978 @cindex @code{long_call} function attribute, Epiphany
3979 @cindex @code{short_call} function attribute, Epiphany
3980 @cindex indirect calls, Epiphany
3981 These attributes specify how a particular function is called.
3982 These attributes override the
3983 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3984 command-line switch and @code{#pragma long_calls} settings.
3985 @end table
3988 @node H8/300 Function Attributes
3989 @subsection H8/300 Function Attributes
3991 These function attributes are available for H8/300 targets:
3993 @table @code
3994 @item function_vector
3995 @cindex @code{function_vector} function attribute, H8/300
3996 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
3997 that the specified function should be called through the function vector.
3998 Calling a function through the function vector reduces code size; however,
3999 the function vector has a limited size (maximum 128 entries on the H8/300
4000 and 64 entries on the H8/300H and H8S)
4001 and shares space with the interrupt vector.
4003 @item interrupt_handler
4004 @cindex @code{interrupt_handler} function attribute, H8/300
4005 Use this attribute on the H8/300, H8/300H, and H8S to
4006 indicate that the specified function is an interrupt handler.  The compiler
4007 generates function entry and exit sequences suitable for use in an
4008 interrupt handler when this attribute is present.
4010 @item saveall
4011 @cindex @code{saveall} function attribute, H8/300
4012 @cindex save all registers on the H8/300, H8/300H, and H8S
4013 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4014 all registers except the stack pointer should be saved in the prologue
4015 regardless of whether they are used or not.
4016 @end table
4018 @node IA-64 Function Attributes
4019 @subsection IA-64 Function Attributes
4021 These function attributes are supported on IA-64 targets:
4023 @table @code
4024 @item syscall_linkage
4025 @cindex @code{syscall_linkage} function attribute, IA-64
4026 This attribute is used to modify the IA-64 calling convention by marking
4027 all input registers as live at all function exits.  This makes it possible
4028 to restart a system call after an interrupt without having to save/restore
4029 the input registers.  This also prevents kernel data from leaking into
4030 application code.
4032 @item version_id
4033 @cindex @code{version_id} function attribute, IA-64
4034 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4035 symbol to contain a version string, thus allowing for function level
4036 versioning.  HP-UX system header files may use function level versioning
4037 for some system calls.
4039 @smallexample
4040 extern int foo () __attribute__((version_id ("20040821")));
4041 @end smallexample
4043 @noindent
4044 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4045 @end table
4047 @node M32C Function Attributes
4048 @subsection M32C Function Attributes
4050 These function attributes are supported by the M32C back end:
4052 @table @code
4053 @item bank_switch
4054 @cindex @code{bank_switch} function attribute, M32C
4055 When added to an interrupt handler with the M32C port, causes the
4056 prologue and epilogue to use bank switching to preserve the registers
4057 rather than saving them on the stack.
4059 @item fast_interrupt
4060 @cindex @code{fast_interrupt} function attribute, M32C
4061 Use this attribute on the M32C port to indicate that the specified
4062 function is a fast interrupt handler.  This is just like the
4063 @code{interrupt} attribute, except that @code{freit} is used to return
4064 instead of @code{reit}.
4066 @item function_vector
4067 @cindex @code{function_vector} function attribute, M16C/M32C
4068 On M16C/M32C targets, the @code{function_vector} attribute declares a
4069 special page subroutine call function. Use of this attribute reduces
4070 the code size by 2 bytes for each call generated to the
4071 subroutine. The argument to the attribute is the vector number entry
4072 from the special page vector table which contains the 16 low-order
4073 bits of the subroutine's entry address. Each vector table has special
4074 page number (18 to 255) that is used in @code{jsrs} instructions.
4075 Jump addresses of the routines are generated by adding 0x0F0000 (in
4076 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4077 2-byte addresses set in the vector table. Therefore you need to ensure
4078 that all the special page vector routines should get mapped within the
4079 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4080 (for M32C).
4082 In the following example 2 bytes are saved for each call to
4083 function @code{foo}.
4085 @smallexample
4086 void foo (void) __attribute__((function_vector(0x18)));
4087 void foo (void)
4091 void bar (void)
4093     foo();
4095 @end smallexample
4097 If functions are defined in one file and are called in another file,
4098 then be sure to write this declaration in both files.
4100 This attribute is ignored for R8C target.
4102 @item interrupt
4103 @cindex @code{interrupt} function attribute, M32C
4104 Use this attribute to indicate
4105 that the specified function is an interrupt handler.  The compiler generates
4106 function entry and exit sequences suitable for use in an interrupt handler
4107 when this attribute is present.
4108 @end table
4110 @node M32R/D Function Attributes
4111 @subsection M32R/D Function Attributes
4113 These function attributes are supported by the M32R/D back end:
4115 @table @code
4116 @item interrupt
4117 @cindex @code{interrupt} function attribute, M32R/D
4118 Use this attribute to indicate
4119 that the specified function is an interrupt handler.  The compiler generates
4120 function entry and exit sequences suitable for use in an interrupt handler
4121 when this attribute is present.
4123 @item model (@var{model-name})
4124 @cindex @code{model} function attribute, M32R/D
4125 @cindex function addressability on the M32R/D
4127 On the M32R/D, use this attribute to set the addressability of an
4128 object, and of the code generated for a function.  The identifier
4129 @var{model-name} is one of @code{small}, @code{medium}, or
4130 @code{large}, representing each of the code models.
4132 Small model objects live in the lower 16MB of memory (so that their
4133 addresses can be loaded with the @code{ld24} instruction), and are
4134 callable with the @code{bl} instruction.
4136 Medium model objects may live anywhere in the 32-bit address space (the
4137 compiler generates @code{seth/add3} instructions to load their addresses),
4138 and are callable with the @code{bl} instruction.
4140 Large model objects may live anywhere in the 32-bit address space (the
4141 compiler generates @code{seth/add3} instructions to load their addresses),
4142 and may not be reachable with the @code{bl} instruction (the compiler
4143 generates the much slower @code{seth/add3/jl} instruction sequence).
4144 @end table
4146 @node m68k Function Attributes
4147 @subsection m68k Function Attributes
4149 These function attributes are supported by the m68k back end:
4151 @table @code
4152 @item interrupt
4153 @itemx interrupt_handler
4154 @cindex @code{interrupt} function attribute, m68k
4155 @cindex @code{interrupt_handler} function attribute, m68k
4156 Use this attribute to
4157 indicate that the specified function is an interrupt handler.  The compiler
4158 generates function entry and exit sequences suitable for use in an
4159 interrupt handler when this attribute is present.  Either name may be used.
4161 @item interrupt_thread
4162 @cindex @code{interrupt_thread} function attribute, fido
4163 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4164 that the specified function is an interrupt handler that is designed
4165 to run as a thread.  The compiler omits generate prologue/epilogue
4166 sequences and replaces the return instruction with a @code{sleep}
4167 instruction.  This attribute is available only on fido.
4168 @end table
4170 @node MCORE Function Attributes
4171 @subsection MCORE Function Attributes
4173 These function attributes are supported by the MCORE back end:
4175 @table @code
4176 @item naked
4177 @cindex @code{naked} function attribute, MCORE
4178 This attribute allows the compiler to construct the
4179 requisite function declaration, while allowing the body of the
4180 function to be assembly code. The specified function will not have
4181 prologue/epilogue sequences generated by the compiler. Only basic
4182 @code{asm} statements can safely be included in naked functions
4183 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4184 basic @code{asm} and C code may appear to work, they cannot be
4185 depended upon to work reliably and are not supported.
4186 @end table
4188 @node MeP Function Attributes
4189 @subsection MeP Function Attributes
4191 These function attributes are supported by the MeP back end:
4193 @table @code
4194 @item disinterrupt
4195 @cindex @code{disinterrupt} function attribute, MeP
4196 On MeP targets, this attribute causes the compiler to emit
4197 instructions to disable interrupts for the duration of the given
4198 function.
4200 @item interrupt
4201 @cindex @code{interrupt} function attribute, MeP
4202 Use this attribute to indicate
4203 that the specified function is an interrupt handler.  The compiler generates
4204 function entry and exit sequences suitable for use in an interrupt handler
4205 when this attribute is present.
4207 @item near
4208 @cindex @code{near} function attribute, MeP
4209 This attribute causes the compiler to assume the called
4210 function is close enough to use the normal calling convention,
4211 overriding the @option{-mtf} command-line option.
4213 @item far
4214 @cindex @code{far} function attribute, MeP
4215 On MeP targets this causes the compiler to use a calling convention
4216 that assumes the called function is too far away for the built-in
4217 addressing modes.
4219 @item vliw
4220 @cindex @code{vliw} function attribute, MeP
4221 The @code{vliw} attribute tells the compiler to emit
4222 instructions in VLIW mode instead of core mode.  Note that this
4223 attribute is not allowed unless a VLIW coprocessor has been configured
4224 and enabled through command-line options.
4225 @end table
4227 @node MicroBlaze Function Attributes
4228 @subsection MicroBlaze Function Attributes
4230 These function attributes are supported on MicroBlaze targets:
4232 @table @code
4233 @item save_volatiles
4234 @cindex @code{save_volatiles} function attribute, MicroBlaze
4235 Use this attribute to indicate that the function is
4236 an interrupt handler.  All volatile registers (in addition to non-volatile
4237 registers) are saved in the function prologue.  If the function is a leaf
4238 function, only volatiles used by the function are saved.  A normal function
4239 return is generated instead of a return from interrupt.
4241 @item break_handler
4242 @cindex @code{break_handler} function attribute, MicroBlaze
4243 @cindex break handler functions
4244 Use this attribute to indicate that
4245 the specified function is a break handler.  The compiler generates function
4246 entry and exit sequences suitable for use in an break handler when this
4247 attribute is present. The return from @code{break_handler} is done through
4248 the @code{rtbd} instead of @code{rtsd}.
4250 @smallexample
4251 void f () __attribute__ ((break_handler));
4252 @end smallexample
4254 @item interrupt_handler
4255 @itemx fast_interrupt 
4256 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4257 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4258 These attributes indicate that the specified function is an interrupt
4259 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4260 used in low-latency interrupt mode, and @code{interrupt_handler} for
4261 interrupts that do not use low-latency handlers.  In both cases, GCC
4262 emits appropriate prologue code and generates a return from the handler
4263 using @code{rtid} instead of @code{rtsd}.
4264 @end table
4266 @node Microsoft Windows Function Attributes
4267 @subsection Microsoft Windows Function Attributes
4269 The following attributes are available on Microsoft Windows and Symbian OS
4270 targets.
4272 @table @code
4273 @item dllexport
4274 @cindex @code{dllexport} function attribute
4275 @cindex @code{__declspec(dllexport)}
4276 On Microsoft Windows targets and Symbian OS targets the
4277 @code{dllexport} attribute causes the compiler to provide a global
4278 pointer to a pointer in a DLL, so that it can be referenced with the
4279 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4280 name is formed by combining @code{_imp__} and the function or variable
4281 name.
4283 You can use @code{__declspec(dllexport)} as a synonym for
4284 @code{__attribute__ ((dllexport))} for compatibility with other
4285 compilers.
4287 On systems that support the @code{visibility} attribute, this
4288 attribute also implies ``default'' visibility.  It is an error to
4289 explicitly specify any other visibility.
4291 GCC's default behavior is to emit all inline functions with the
4292 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4293 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4294 ignore the attribute for inlined functions unless the 
4295 @option{-fkeep-inline-functions} flag is used instead.
4297 The attribute is ignored for undefined symbols.
4299 When applied to C++ classes, the attribute marks defined non-inlined
4300 member functions and static data members as exports.  Static consts
4301 initialized in-class are not marked unless they are also defined
4302 out-of-class.
4304 For Microsoft Windows targets there are alternative methods for
4305 including the symbol in the DLL's export table such as using a
4306 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4307 the @option{--export-all} linker flag.
4309 @item dllimport
4310 @cindex @code{dllimport} function attribute
4311 @cindex @code{__declspec(dllimport)}
4312 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4313 attribute causes the compiler to reference a function or variable via
4314 a global pointer to a pointer that is set up by the DLL exporting the
4315 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4316 targets, the pointer name is formed by combining @code{_imp__} and the
4317 function or variable name.
4319 You can use @code{__declspec(dllimport)} as a synonym for
4320 @code{__attribute__ ((dllimport))} for compatibility with other
4321 compilers.
4323 On systems that support the @code{visibility} attribute, this
4324 attribute also implies ``default'' visibility.  It is an error to
4325 explicitly specify any other visibility.
4327 Currently, the attribute is ignored for inlined functions.  If the
4328 attribute is applied to a symbol @emph{definition}, an error is reported.
4329 If a symbol previously declared @code{dllimport} is later defined, the
4330 attribute is ignored in subsequent references, and a warning is emitted.
4331 The attribute is also overridden by a subsequent declaration as
4332 @code{dllexport}.
4334 When applied to C++ classes, the attribute marks non-inlined
4335 member functions and static data members as imports.  However, the
4336 attribute is ignored for virtual methods to allow creation of vtables
4337 using thunks.
4339 On the SH Symbian OS target the @code{dllimport} attribute also has
4340 another affect---it can cause the vtable and run-time type information
4341 for a class to be exported.  This happens when the class has a
4342 dllimported constructor or a non-inline, non-pure virtual function
4343 and, for either of those two conditions, the class also has an inline
4344 constructor or destructor and has a key function that is defined in
4345 the current translation unit.
4347 For Microsoft Windows targets the use of the @code{dllimport}
4348 attribute on functions is not necessary, but provides a small
4349 performance benefit by eliminating a thunk in the DLL@.  The use of the
4350 @code{dllimport} attribute on imported variables can be avoided by passing the
4351 @option{--enable-auto-import} switch to the GNU linker.  As with
4352 functions, using the attribute for a variable eliminates a thunk in
4353 the DLL@.
4355 One drawback to using this attribute is that a pointer to a
4356 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4357 address. However, a pointer to a @emph{function} with the
4358 @code{dllimport} attribute can be used as a constant initializer; in
4359 this case, the address of a stub function in the import lib is
4360 referenced.  On Microsoft Windows targets, the attribute can be disabled
4361 for functions by setting the @option{-mnop-fun-dllimport} flag.
4362 @end table
4364 @node MIPS Function Attributes
4365 @subsection MIPS Function Attributes
4367 These function attributes are supported by the MIPS back end:
4369 @table @code
4370 @item interrupt
4371 @cindex @code{interrupt} function attribute, MIPS
4372 Use this attribute to indicate that the specified function is an interrupt
4373 handler.  The compiler generates function entry and exit sequences suitable
4374 for use in an interrupt handler when this attribute is present.
4375 An optional argument is supported for the interrupt attribute which allows
4376 the interrupt mode to be described.  By default GCC assumes the external
4377 interrupt controller (EIC) mode is in use, this can be explicitly set using
4378 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4379 Priority Level (IPL) is copied to the current IPL which has the effect of only
4380 enabling higher priority interrupts.  To use vectored interrupt mode use
4381 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4382 the behavior of the non-masked interrupt support and GCC will arrange to mask
4383 all interrupts from sw0 up to and including the specified interrupt vector.
4385 You can use the following attributes to modify the behavior
4386 of an interrupt handler:
4387 @table @code
4388 @item use_shadow_register_set
4389 @cindex @code{use_shadow_register_set} function attribute, MIPS
4390 Assume that the handler uses a shadow register set, instead of
4391 the main general-purpose registers.  An optional argument @code{intstack} is
4392 supported to indicate that the shadow register set contains a valid stack
4393 pointer.
4395 @item keep_interrupts_masked
4396 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4397 Keep interrupts masked for the whole function.  Without this attribute,
4398 GCC tries to reenable interrupts for as much of the function as it can.
4400 @item use_debug_exception_return
4401 @cindex @code{use_debug_exception_return} function attribute, MIPS
4402 Return using the @code{deret} instruction.  Interrupt handlers that don't
4403 have this attribute return using @code{eret} instead.
4404 @end table
4406 You can use any combination of these attributes, as shown below:
4407 @smallexample
4408 void __attribute__ ((interrupt)) v0 ();
4409 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4410 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4411 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4412 void __attribute__ ((interrupt, use_shadow_register_set,
4413                      keep_interrupts_masked)) v4 ();
4414 void __attribute__ ((interrupt, use_shadow_register_set,
4415                      use_debug_exception_return)) v5 ();
4416 void __attribute__ ((interrupt, keep_interrupts_masked,
4417                      use_debug_exception_return)) v6 ();
4418 void __attribute__ ((interrupt, use_shadow_register_set,
4419                      keep_interrupts_masked,
4420                      use_debug_exception_return)) v7 ();
4421 void __attribute__ ((interrupt("eic"))) v8 ();
4422 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4423 @end smallexample
4425 @item long_call
4426 @itemx near
4427 @itemx far
4428 @cindex indirect calls, MIPS
4429 @cindex @code{long_call} function attribute, MIPS
4430 @cindex @code{near} function attribute, MIPS
4431 @cindex @code{far} function attribute, MIPS
4432 These attributes specify how a particular function is called on MIPS@.
4433 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4434 command-line switch.  The @code{long_call} and @code{far} attributes are
4435 synonyms, and cause the compiler to always call
4436 the function by first loading its address into a register, and then using
4437 the contents of that register.  The @code{near} attribute has the opposite
4438 effect; it specifies that non-PIC calls should be made using the more
4439 efficient @code{jal} instruction.
4441 @item mips16
4442 @itemx nomips16
4443 @cindex @code{mips16} function attribute, MIPS
4444 @cindex @code{nomips16} function attribute, MIPS
4446 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4447 function attributes to locally select or turn off MIPS16 code generation.
4448 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4449 while MIPS16 code generation is disabled for functions with the
4450 @code{nomips16} attribute.  These attributes override the
4451 @option{-mips16} and @option{-mno-mips16} options on the command line
4452 (@pxref{MIPS Options}).
4454 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4455 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4456 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4457 may interact badly with some GCC extensions such as @code{__builtin_apply}
4458 (@pxref{Constructing Calls}).
4460 @item micromips, MIPS
4461 @itemx nomicromips, MIPS
4462 @cindex @code{micromips} function attribute
4463 @cindex @code{nomicromips} function attribute
4465 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4466 function attributes to locally select or turn off microMIPS code generation.
4467 A function with the @code{micromips} attribute is emitted as microMIPS code,
4468 while microMIPS code generation is disabled for functions with the
4469 @code{nomicromips} attribute.  These attributes override the
4470 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4471 (@pxref{MIPS Options}).
4473 When compiling files containing mixed microMIPS and non-microMIPS code, the
4474 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4475 command line,
4476 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4477 may interact badly with some GCC extensions such as @code{__builtin_apply}
4478 (@pxref{Constructing Calls}).
4480 @item nocompression
4481 @cindex @code{nocompression} function attribute, MIPS
4482 On MIPS targets, you can use the @code{nocompression} function attribute
4483 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4484 overrides the @option{-mips16} and @option{-mmicromips} options on the
4485 command line (@pxref{MIPS Options}).
4486 @end table
4488 @node MSP430 Function Attributes
4489 @subsection MSP430 Function Attributes
4491 These function attributes are supported by the MSP430 back end:
4493 @table @code
4494 @item critical
4495 @cindex @code{critical} function attribute, MSP430
4496 Critical functions disable interrupts upon entry and restore the
4497 previous interrupt state upon exit.  Critical functions cannot also
4498 have the @code{naked} or @code{reentrant} attributes.  They can have
4499 the @code{interrupt} attribute.
4501 @item interrupt
4502 @cindex @code{interrupt} function attribute, MSP430
4503 Use this attribute to indicate
4504 that the specified function is an interrupt handler.  The compiler generates
4505 function entry and exit sequences suitable for use in an interrupt handler
4506 when this attribute is present.
4508 You can provide an argument to the interrupt
4509 attribute which specifies a name or number.  If the argument is a
4510 number it indicates the slot in the interrupt vector table (0 - 31) to
4511 which this handler should be assigned.  If the argument is a name it
4512 is treated as a symbolic name for the vector slot.  These names should
4513 match up with appropriate entries in the linker script.  By default
4514 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4515 @code{reset} for vector 31 are recognized.
4517 @item naked
4518 @cindex @code{naked} function attribute, MSP430
4519 This attribute allows the compiler to construct the
4520 requisite function declaration, while allowing the body of the
4521 function to be assembly code. The specified function will not have
4522 prologue/epilogue sequences generated by the compiler. Only basic
4523 @code{asm} statements can safely be included in naked functions
4524 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4525 basic @code{asm} and C code may appear to work, they cannot be
4526 depended upon to work reliably and are not supported.
4528 @item reentrant
4529 @cindex @code{reentrant} function attribute, MSP430
4530 Reentrant functions disable interrupts upon entry and enable them
4531 upon exit.  Reentrant functions cannot also have the @code{naked}
4532 or @code{critical} attributes.  They can have the @code{interrupt}
4533 attribute.
4535 @item wakeup
4536 @cindex @code{wakeup} function attribute, MSP430
4537 This attribute only applies to interrupt functions.  It is silently
4538 ignored if applied to a non-interrupt function.  A wakeup interrupt
4539 function will rouse the processor from any low-power state that it
4540 might be in when the function exits.
4542 @item lower
4543 @itemx upper
4544 @itemx either
4545 @cindex @code{lower} function attribute, MSP430
4546 @cindex @code{upper} function attribute, MSP430
4547 @cindex @code{either} function attribute, MSP430
4548 On the MSP430 target these attributes can be used to specify whether
4549 the function or variable should be placed into low memory, high
4550 memory, or the placement should be left to the linker to decide.  The
4551 attributes are only significant if compiling for the MSP430X
4552 architecture.
4554 The attributes work in conjunction with a linker script that has been
4555 augmented to specify where to place sections with a @code{.lower} and
4556 a @code{.upper} prefix.  So, for example, as well as placing the
4557 @code{.data} section, the script also specifies the placement of a
4558 @code{.lower.data} and a @code{.upper.data} section.  The intention
4559 is that @code{lower} sections are placed into a small but easier to
4560 access memory region and the upper sections are placed into a larger, but
4561 slower to access, region.
4563 The @code{either} attribute is special.  It tells the linker to place
4564 the object into the corresponding @code{lower} section if there is
4565 room for it.  If there is insufficient room then the object is placed
4566 into the corresponding @code{upper} section instead.  Note that the
4567 placement algorithm is not very sophisticated.  It does not attempt to
4568 find an optimal packing of the @code{lower} sections.  It just makes
4569 one pass over the objects and does the best that it can.  Using the
4570 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4571 options can help the packing, however, since they produce smaller,
4572 easier to pack regions.
4573 @end table
4575 @node NDS32 Function Attributes
4576 @subsection NDS32 Function Attributes
4578 These function attributes are supported by the NDS32 back end:
4580 @table @code
4581 @item exception
4582 @cindex @code{exception} function attribute
4583 @cindex exception handler functions, NDS32
4584 Use this attribute on the NDS32 target to indicate that the specified function
4585 is an exception handler.  The compiler will generate corresponding sections
4586 for use in an exception handler.
4588 @item interrupt
4589 @cindex @code{interrupt} function attribute, NDS32
4590 On NDS32 target, this attribute indicates that the specified function
4591 is an interrupt handler.  The compiler generates corresponding sections
4592 for use in an interrupt handler.  You can use the following attributes
4593 to modify the behavior:
4594 @table @code
4595 @item nested
4596 @cindex @code{nested} function attribute, NDS32
4597 This interrupt service routine is interruptible.
4598 @item not_nested
4599 @cindex @code{not_nested} function attribute, NDS32
4600 This interrupt service routine is not interruptible.
4601 @item nested_ready
4602 @cindex @code{nested_ready} function attribute, NDS32
4603 This interrupt service routine is interruptible after @code{PSW.GIE}
4604 (global interrupt enable) is set.  This allows interrupt service routine to
4605 finish some short critical code before enabling interrupts.
4606 @item save_all
4607 @cindex @code{save_all} function attribute, NDS32
4608 The system will help save all registers into stack before entering
4609 interrupt handler.
4610 @item partial_save
4611 @cindex @code{partial_save} function attribute, NDS32
4612 The system will help save caller registers into stack before entering
4613 interrupt handler.
4614 @end table
4616 @item naked
4617 @cindex @code{naked} function attribute, NDS32
4618 This attribute allows the compiler to construct the
4619 requisite function declaration, while allowing the body of the
4620 function to be assembly code. The specified function will not have
4621 prologue/epilogue sequences generated by the compiler. Only basic
4622 @code{asm} statements can safely be included in naked functions
4623 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4624 basic @code{asm} and C code may appear to work, they cannot be
4625 depended upon to work reliably and are not supported.
4627 @item reset
4628 @cindex @code{reset} function attribute, NDS32
4629 @cindex reset handler functions
4630 Use this attribute on the NDS32 target to indicate that the specified function
4631 is a reset handler.  The compiler will generate corresponding sections
4632 for use in a reset handler.  You can use the following attributes
4633 to provide extra exception handling:
4634 @table @code
4635 @item nmi
4636 @cindex @code{nmi} function attribute, NDS32
4637 Provide a user-defined function to handle NMI exception.
4638 @item warm
4639 @cindex @code{warm} function attribute, NDS32
4640 Provide a user-defined function to handle warm reset exception.
4641 @end table
4642 @end table
4644 @node Nios II Function Attributes
4645 @subsection Nios II Function Attributes
4647 These function attributes are supported by the Nios II back end:
4649 @table @code
4650 @item target (@var{options})
4651 @cindex @code{target} function attribute
4652 As discussed in @ref{Common Function Attributes}, this attribute 
4653 allows specification of target-specific compilation options.
4655 When compiling for Nios II, the following options are allowed:
4657 @table @samp
4658 @item custom-@var{insn}=@var{N}
4659 @itemx no-custom-@var{insn}
4660 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4661 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4662 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4663 custom instruction with encoding @var{N} when generating code that uses 
4664 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4665 the custom instruction @var{insn}.
4666 These target attributes correspond to the
4667 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4668 command-line options, and support the same set of @var{insn} keywords.
4669 @xref{Nios II Options}, for more information.
4671 @item custom-fpu-cfg=@var{name}
4672 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4673 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4674 command-line option, to select a predefined set of custom instructions
4675 named @var{name}.
4676 @xref{Nios II Options}, for more information.
4677 @end table
4678 @end table
4680 @node Nvidia PTX Function Attributes
4681 @subsection Nvidia PTX Function Attributes
4683 These function attributes are supported by the Nvidia PTX back end:
4685 @table @code
4686 @item kernel
4687 @cindex @code{kernel} attribute, Nvidia PTX
4688 This attribute indicates that the corresponding function should be compiled
4689 as a kernel function, which can be invoked from the host via the CUDA RT 
4690 library.
4691 By default functions are only callable only from other PTX functions.
4693 Kernel functions must have @code{void} return type.
4694 @end table
4696 @node PowerPC Function Attributes
4697 @subsection PowerPC Function Attributes
4699 These function attributes are supported by the PowerPC back end:
4701 @table @code
4702 @item longcall
4703 @itemx shortcall
4704 @cindex indirect calls, PowerPC
4705 @cindex @code{longcall} function attribute, PowerPC
4706 @cindex @code{shortcall} function attribute, PowerPC
4707 The @code{longcall} attribute
4708 indicates that the function might be far away from the call site and
4709 require a different (more expensive) calling sequence.  The
4710 @code{shortcall} attribute indicates that the function is always close
4711 enough for the shorter calling sequence to be used.  These attributes
4712 override both the @option{-mlongcall} switch and
4713 the @code{#pragma longcall} setting.
4715 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4716 calls are necessary.
4718 @item target (@var{options})
4719 @cindex @code{target} function attribute
4720 As discussed in @ref{Common Function Attributes}, this attribute 
4721 allows specification of target-specific compilation options.
4723 On the PowerPC, the following options are allowed:
4725 @table @samp
4726 @item altivec
4727 @itemx no-altivec
4728 @cindex @code{target("altivec")} function attribute, PowerPC
4729 Generate code that uses (does not use) AltiVec instructions.  In
4730 32-bit code, you cannot enable AltiVec instructions unless
4731 @option{-mabi=altivec} is used on the command line.
4733 @item cmpb
4734 @itemx no-cmpb
4735 @cindex @code{target("cmpb")} function attribute, PowerPC
4736 Generate code that uses (does not use) the compare bytes instruction
4737 implemented on the POWER6 processor and other processors that support
4738 the PowerPC V2.05 architecture.
4740 @item dlmzb
4741 @itemx no-dlmzb
4742 @cindex @code{target("dlmzb")} function attribute, PowerPC
4743 Generate code that uses (does not use) the string-search @samp{dlmzb}
4744 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4745 generated by default when targeting those processors.
4747 @item fprnd
4748 @itemx no-fprnd
4749 @cindex @code{target("fprnd")} function attribute, PowerPC
4750 Generate code that uses (does not use) the FP round to integer
4751 instructions implemented on the POWER5+ processor and other processors
4752 that support the PowerPC V2.03 architecture.
4754 @item hard-dfp
4755 @itemx no-hard-dfp
4756 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4757 Generate code that uses (does not use) the decimal floating-point
4758 instructions implemented on some POWER processors.
4760 @item isel
4761 @itemx no-isel
4762 @cindex @code{target("isel")} function attribute, PowerPC
4763 Generate code that uses (does not use) ISEL instruction.
4765 @item mfcrf
4766 @itemx no-mfcrf
4767 @cindex @code{target("mfcrf")} function attribute, PowerPC
4768 Generate code that uses (does not use) the move from condition
4769 register field instruction implemented on the POWER4 processor and
4770 other processors that support the PowerPC V2.01 architecture.
4772 @item mfpgpr
4773 @itemx no-mfpgpr
4774 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4775 Generate code that uses (does not use) the FP move to/from general
4776 purpose register instructions implemented on the POWER6X processor and
4777 other processors that support the extended PowerPC V2.05 architecture.
4779 @item mulhw
4780 @itemx no-mulhw
4781 @cindex @code{target("mulhw")} function attribute, PowerPC
4782 Generate code that uses (does not use) the half-word multiply and
4783 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4784 These instructions are generated by default when targeting those
4785 processors.
4787 @item multiple
4788 @itemx no-multiple
4789 @cindex @code{target("multiple")} function attribute, PowerPC
4790 Generate code that uses (does not use) the load multiple word
4791 instructions and the store multiple word instructions.
4793 @item update
4794 @itemx no-update
4795 @cindex @code{target("update")} function attribute, PowerPC
4796 Generate code that uses (does not use) the load or store instructions
4797 that update the base register to the address of the calculated memory
4798 location.
4800 @item popcntb
4801 @itemx no-popcntb
4802 @cindex @code{target("popcntb")} function attribute, PowerPC
4803 Generate code that uses (does not use) the popcount and double-precision
4804 FP reciprocal estimate instruction implemented on the POWER5
4805 processor and other processors that support the PowerPC V2.02
4806 architecture.
4808 @item popcntd
4809 @itemx no-popcntd
4810 @cindex @code{target("popcntd")} function attribute, PowerPC
4811 Generate code that uses (does not use) the popcount instruction
4812 implemented on the POWER7 processor and other processors that support
4813 the PowerPC V2.06 architecture.
4815 @item powerpc-gfxopt
4816 @itemx no-powerpc-gfxopt
4817 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4818 Generate code that uses (does not use) the optional PowerPC
4819 architecture instructions in the Graphics group, including
4820 floating-point select.
4822 @item powerpc-gpopt
4823 @itemx no-powerpc-gpopt
4824 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4825 Generate code that uses (does not use) the optional PowerPC
4826 architecture instructions in the General Purpose group, including
4827 floating-point square root.
4829 @item recip-precision
4830 @itemx no-recip-precision
4831 @cindex @code{target("recip-precision")} function attribute, PowerPC
4832 Assume (do not assume) that the reciprocal estimate instructions
4833 provide higher-precision estimates than is mandated by the PowerPC
4834 ABI.
4836 @item string
4837 @itemx no-string
4838 @cindex @code{target("string")} function attribute, PowerPC
4839 Generate code that uses (does not use) the load string instructions
4840 and the store string word instructions to save multiple registers and
4841 do small block moves.
4843 @item vsx
4844 @itemx no-vsx
4845 @cindex @code{target("vsx")} function attribute, PowerPC
4846 Generate code that uses (does not use) vector/scalar (VSX)
4847 instructions, and also enable the use of built-in functions that allow
4848 more direct access to the VSX instruction set.  In 32-bit code, you
4849 cannot enable VSX or AltiVec instructions unless
4850 @option{-mabi=altivec} is used on the command line.
4852 @item friz
4853 @itemx no-friz
4854 @cindex @code{target("friz")} function attribute, PowerPC
4855 Generate (do not generate) the @code{friz} instruction when the
4856 @option{-funsafe-math-optimizations} option is used to optimize
4857 rounding a floating-point value to 64-bit integer and back to floating
4858 point.  The @code{friz} instruction does not return the same value if
4859 the floating-point number is too large to fit in an integer.
4861 @item avoid-indexed-addresses
4862 @itemx no-avoid-indexed-addresses
4863 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4864 Generate code that tries to avoid (not avoid) the use of indexed load
4865 or store instructions.
4867 @item paired
4868 @itemx no-paired
4869 @cindex @code{target("paired")} function attribute, PowerPC
4870 Generate code that uses (does not use) the generation of PAIRED simd
4871 instructions.
4873 @item longcall
4874 @itemx no-longcall
4875 @cindex @code{target("longcall")} function attribute, PowerPC
4876 Generate code that assumes (does not assume) that all calls are far
4877 away so that a longer more expensive calling sequence is required.
4879 @item cpu=@var{CPU}
4880 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4881 Specify the architecture to generate code for when compiling the
4882 function.  If you select the @code{target("cpu=power7")} attribute when
4883 generating 32-bit code, VSX and AltiVec instructions are not generated
4884 unless you use the @option{-mabi=altivec} option on the command line.
4886 @item tune=@var{TUNE}
4887 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4888 Specify the architecture to tune for when compiling the function.  If
4889 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4890 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4891 compilation tunes for the @var{CPU} architecture, and not the
4892 default tuning specified on the command line.
4893 @end table
4895 On the PowerPC, the inliner does not inline a
4896 function that has different target options than the caller, unless the
4897 callee has a subset of the target options of the caller.
4898 @end table
4900 @node RL78 Function Attributes
4901 @subsection RL78 Function Attributes
4903 These function attributes are supported by the RL78 back end:
4905 @table @code
4906 @item interrupt
4907 @itemx brk_interrupt
4908 @cindex @code{interrupt} function attribute, RL78
4909 @cindex @code{brk_interrupt} function attribute, RL78
4910 These attributes indicate
4911 that the specified function is an interrupt handler.  The compiler generates
4912 function entry and exit sequences suitable for use in an interrupt handler
4913 when this attribute is present.
4915 Use @code{brk_interrupt} instead of @code{interrupt} for
4916 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4917 that must end with @code{RETB} instead of @code{RETI}).
4919 @item naked
4920 @cindex @code{naked} function attribute, RL78
4921 This attribute allows the compiler to construct the
4922 requisite function declaration, while allowing the body of the
4923 function to be assembly code. The specified function will not have
4924 prologue/epilogue sequences generated by the compiler. Only basic
4925 @code{asm} statements can safely be included in naked functions
4926 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4927 basic @code{asm} and C code may appear to work, they cannot be
4928 depended upon to work reliably and are not supported.
4929 @end table
4931 @node RX Function Attributes
4932 @subsection RX Function Attributes
4934 These function attributes are supported by the RX back end:
4936 @table @code
4937 @item fast_interrupt
4938 @cindex @code{fast_interrupt} function attribute, RX
4939 Use this attribute on the RX port to indicate that the specified
4940 function is a fast interrupt handler.  This is just like the
4941 @code{interrupt} attribute, except that @code{freit} is used to return
4942 instead of @code{reit}.
4944 @item interrupt
4945 @cindex @code{interrupt} function attribute, RX
4946 Use this attribute to indicate
4947 that the specified function is an interrupt handler.  The compiler generates
4948 function entry and exit sequences suitable for use in an interrupt handler
4949 when this attribute is present.
4951 On RX targets, you may specify one or more vector numbers as arguments
4952 to the attribute, as well as naming an alternate table name.
4953 Parameters are handled sequentially, so one handler can be assigned to
4954 multiple entries in multiple tables.  One may also pass the magic
4955 string @code{"$default"} which causes the function to be used for any
4956 unfilled slots in the current table.
4958 This example shows a simple assignment of a function to one vector in
4959 the default table (note that preprocessor macros may be used for
4960 chip-specific symbolic vector names):
4961 @smallexample
4962 void __attribute__ ((interrupt (5))) txd1_handler ();
4963 @end smallexample
4965 This example assigns a function to two slots in the default table
4966 (using preprocessor macros defined elsewhere) and makes it the default
4967 for the @code{dct} table:
4968 @smallexample
4969 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4970         txd1_handler ();
4971 @end smallexample
4973 @item naked
4974 @cindex @code{naked} function attribute, RX
4975 This attribute allows the compiler to construct the
4976 requisite function declaration, while allowing the body of the
4977 function to be assembly code. The specified function will not have
4978 prologue/epilogue sequences generated by the compiler. Only basic
4979 @code{asm} statements can safely be included in naked functions
4980 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4981 basic @code{asm} and C code may appear to work, they cannot be
4982 depended upon to work reliably and are not supported.
4984 @item vector
4985 @cindex @code{vector} function attribute, RX
4986 This RX attribute is similar to the @code{interrupt} attribute, including its
4987 parameters, but does not make the function an interrupt-handler type
4988 function (i.e. it retains the normal C function calling ABI).  See the
4989 @code{interrupt} attribute for a description of its arguments.
4990 @end table
4992 @node S/390 Function Attributes
4993 @subsection S/390 Function Attributes
4995 These function attributes are supported on the S/390:
4997 @table @code
4998 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4999 @cindex @code{hotpatch} function attribute, S/390
5001 On S/390 System z targets, you can use this function attribute to
5002 make GCC generate a ``hot-patching'' function prologue.  If the
5003 @option{-mhotpatch=} command-line option is used at the same time,
5004 the @code{hotpatch} attribute takes precedence.  The first of the
5005 two arguments specifies the number of halfwords to be added before
5006 the function label.  A second argument can be used to specify the
5007 number of halfwords to be added after the function label.  For
5008 both arguments the maximum allowed value is 1000000.
5010 If both arguments are zero, hotpatching is disabled.
5012 @item target (@var{options})
5013 @cindex @code{target} function attribute
5014 As discussed in @ref{Common Function Attributes}, this attribute
5015 allows specification of target-specific compilation options.
5017 On S/390, the following options are supported:
5019 @table @samp
5020 @item arch=
5021 @item tune=
5022 @item stack-guard=
5023 @item stack-size=
5024 @item branch-cost=
5025 @item warn-framesize=
5026 @item backchain
5027 @itemx no-backchain
5028 @item hard-dfp
5029 @itemx no-hard-dfp
5030 @item hard-float
5031 @itemx soft-float
5032 @item htm
5033 @itemx no-htm
5034 @item vx
5035 @itemx no-vx
5036 @item packed-stack
5037 @itemx no-packed-stack
5038 @item small-exec
5039 @itemx no-small-exec
5040 @item mvcle
5041 @itemx no-mvcle
5042 @item warn-dynamicstack
5043 @itemx no-warn-dynamicstack
5044 @end table
5046 The options work exactly like the S/390 specific command line
5047 options (without the prefix @option{-m}) except that they do not
5048 change any feature macros.  For example,
5050 @smallexample
5051 @code{target("no-vx")}
5052 @end smallexample
5054 does not undefine the @code{__VEC__} macro.
5055 @end table
5057 @node SH Function Attributes
5058 @subsection SH Function Attributes
5060 These function attributes are supported on the SH family of processors:
5062 @table @code
5063 @item function_vector
5064 @cindex @code{function_vector} function attribute, SH
5065 @cindex calling functions through the function vector on SH2A
5066 On SH2A targets, this attribute declares a function to be called using the
5067 TBR relative addressing mode.  The argument to this attribute is the entry
5068 number of the same function in a vector table containing all the TBR
5069 relative addressable functions.  For correct operation the TBR must be setup
5070 accordingly to point to the start of the vector table before any functions with
5071 this attribute are invoked.  Usually a good place to do the initialization is
5072 the startup routine.  The TBR relative vector table can have at max 256 function
5073 entries.  The jumps to these functions are generated using a SH2A specific,
5074 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5075 from GNU binutils version 2.7 or later for this attribute to work correctly.
5077 In an application, for a function being called once, this attribute
5078 saves at least 8 bytes of code; and if other successive calls are being
5079 made to the same function, it saves 2 bytes of code per each of these
5080 calls.
5082 @item interrupt_handler
5083 @cindex @code{interrupt_handler} function attribute, SH
5084 Use this attribute to
5085 indicate that the specified function is an interrupt handler.  The compiler
5086 generates function entry and exit sequences suitable for use in an
5087 interrupt handler when this attribute is present.
5089 @item nosave_low_regs
5090 @cindex @code{nosave_low_regs} function attribute, SH
5091 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5092 function should not save and restore registers R0..R7.  This can be used on SH3*
5093 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5094 interrupt handlers.
5096 @item renesas
5097 @cindex @code{renesas} function attribute, SH
5098 On SH targets this attribute specifies that the function or struct follows the
5099 Renesas ABI.
5101 @item resbank
5102 @cindex @code{resbank} function attribute, SH
5103 On the SH2A target, this attribute enables the high-speed register
5104 saving and restoration using a register bank for @code{interrupt_handler}
5105 routines.  Saving to the bank is performed automatically after the CPU
5106 accepts an interrupt that uses a register bank.
5108 The nineteen 32-bit registers comprising general register R0 to R14,
5109 control register GBR, and system registers MACH, MACL, and PR and the
5110 vector table address offset are saved into a register bank.  Register
5111 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5112 from the bank is executed by issuing a RESBANK instruction.
5114 @item sp_switch
5115 @cindex @code{sp_switch} function attribute, SH
5116 Use this attribute on the SH to indicate an @code{interrupt_handler}
5117 function should switch to an alternate stack.  It expects a string
5118 argument that names a global variable holding the address of the
5119 alternate stack.
5121 @smallexample
5122 void *alt_stack;
5123 void f () __attribute__ ((interrupt_handler,
5124                           sp_switch ("alt_stack")));
5125 @end smallexample
5127 @item trap_exit
5128 @cindex @code{trap_exit} function attribute, SH
5129 Use this attribute on the SH for an @code{interrupt_handler} to return using
5130 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5131 argument specifying the trap number to be used.
5133 @item trapa_handler
5134 @cindex @code{trapa_handler} function attribute, SH
5135 On SH targets this function attribute is similar to @code{interrupt_handler}
5136 but it does not save and restore all registers.
5137 @end table
5139 @node SPU Function Attributes
5140 @subsection SPU Function Attributes
5142 These function attributes are supported by the SPU back end:
5144 @table @code
5145 @item naked
5146 @cindex @code{naked} function attribute, SPU
5147 This attribute allows the compiler to construct the
5148 requisite function declaration, while allowing the body of the
5149 function to be assembly code. The specified function will not have
5150 prologue/epilogue sequences generated by the compiler. Only basic
5151 @code{asm} statements can safely be included in naked functions
5152 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5153 basic @code{asm} and C code may appear to work, they cannot be
5154 depended upon to work reliably and are not supported.
5155 @end table
5157 @node Symbian OS Function Attributes
5158 @subsection Symbian OS Function Attributes
5160 @xref{Microsoft Windows Function Attributes}, for discussion of the
5161 @code{dllexport} and @code{dllimport} attributes.
5163 @node V850 Function Attributes
5164 @subsection V850 Function Attributes
5166 The V850 back end supports these function attributes:
5168 @table @code
5169 @item interrupt
5170 @itemx interrupt_handler
5171 @cindex @code{interrupt} function attribute, V850
5172 @cindex @code{interrupt_handler} function attribute, V850
5173 Use these attributes to indicate
5174 that the specified function is an interrupt handler.  The compiler generates
5175 function entry and exit sequences suitable for use in an interrupt handler
5176 when either attribute is present.
5177 @end table
5179 @node Visium Function Attributes
5180 @subsection Visium Function Attributes
5182 These function attributes are supported by the Visium back end:
5184 @table @code
5185 @item interrupt
5186 @cindex @code{interrupt} function attribute, Visium
5187 Use this attribute to indicate
5188 that the specified function is an interrupt handler.  The compiler generates
5189 function entry and exit sequences suitable for use in an interrupt handler
5190 when this attribute is present.
5191 @end table
5193 @node x86 Function Attributes
5194 @subsection x86 Function Attributes
5196 These function attributes are supported by the x86 back end:
5198 @table @code
5199 @item cdecl
5200 @cindex @code{cdecl} function attribute, x86-32
5201 @cindex functions that pop the argument stack on x86-32
5202 @opindex mrtd
5203 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5204 assume that the calling function pops off the stack space used to
5205 pass arguments.  This is
5206 useful to override the effects of the @option{-mrtd} switch.
5208 @item fastcall
5209 @cindex @code{fastcall} function attribute, x86-32
5210 @cindex functions that pop the argument stack on x86-32
5211 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5212 pass the first argument (if of integral type) in the register ECX and
5213 the second argument (if of integral type) in the register EDX@.  Subsequent
5214 and other typed arguments are passed on the stack.  The called function
5215 pops the arguments off the stack.  If the number of arguments is variable all
5216 arguments are pushed on the stack.
5218 @item thiscall
5219 @cindex @code{thiscall} function attribute, x86-32
5220 @cindex functions that pop the argument stack on x86-32
5221 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5222 pass the first argument (if of integral type) in the register ECX.
5223 Subsequent and other typed arguments are passed on the stack. The called
5224 function pops the arguments off the stack.
5225 If the number of arguments is variable all arguments are pushed on the
5226 stack.
5227 The @code{thiscall} attribute is intended for C++ non-static member functions.
5228 As a GCC extension, this calling convention can be used for C functions
5229 and for static member methods.
5231 @item ms_abi
5232 @itemx sysv_abi
5233 @cindex @code{ms_abi} function attribute, x86
5234 @cindex @code{sysv_abi} function attribute, x86
5236 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5237 to indicate which calling convention should be used for a function.  The
5238 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5239 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5240 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5241 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5243 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5244 requires the @option{-maccumulate-outgoing-args} option.
5246 @item callee_pop_aggregate_return (@var{number})
5247 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5249 On x86-32 targets, you can use this attribute to control how
5250 aggregates are returned in memory.  If the caller is responsible for
5251 popping the hidden pointer together with the rest of the arguments, specify
5252 @var{number} equal to zero.  If callee is responsible for popping the
5253 hidden pointer, specify @var{number} equal to one.  
5255 The default x86-32 ABI assumes that the callee pops the
5256 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5257 the compiler assumes that the
5258 caller pops the stack for hidden pointer.
5260 @item ms_hook_prologue
5261 @cindex @code{ms_hook_prologue} function attribute, x86
5263 On 32-bit and 64-bit x86 targets, you can use
5264 this function attribute to make GCC generate the ``hot-patching'' function
5265 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5266 and newer.
5268 @item regparm (@var{number})
5269 @cindex @code{regparm} function attribute, x86
5270 @cindex functions that are passed arguments in registers on x86-32
5271 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5272 pass arguments number one to @var{number} if they are of integral type
5273 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5274 take a variable number of arguments continue to be passed all of their
5275 arguments on the stack.
5277 Beware that on some ELF systems this attribute is unsuitable for
5278 global functions in shared libraries with lazy binding (which is the
5279 default).  Lazy binding sends the first call via resolving code in
5280 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5281 per the standard calling conventions.  Solaris 8 is affected by this.
5282 Systems with the GNU C Library version 2.1 or higher
5283 and FreeBSD are believed to be
5284 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5285 disabled with the linker or the loader if desired, to avoid the
5286 problem.)
5288 @item sseregparm
5289 @cindex @code{sseregparm} function attribute, x86
5290 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5291 causes the compiler to pass up to 3 floating-point arguments in
5292 SSE registers instead of on the stack.  Functions that take a
5293 variable number of arguments continue to pass all of their
5294 floating-point arguments on the stack.
5296 @item force_align_arg_pointer
5297 @cindex @code{force_align_arg_pointer} function attribute, x86
5298 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5299 applied to individual function definitions, generating an alternate
5300 prologue and epilogue that realigns the run-time stack if necessary.
5301 This supports mixing legacy codes that run with a 4-byte aligned stack
5302 with modern codes that keep a 16-byte stack for SSE compatibility.
5304 @item stdcall
5305 @cindex @code{stdcall} function attribute, x86-32
5306 @cindex functions that pop the argument stack on x86-32
5307 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5308 assume that the called function pops off the stack space used to
5309 pass arguments, unless it takes a variable number of arguments.
5311 @item no_caller_saved_registers
5312 @cindex @code{no_caller_saved_registers} function attribute, x86
5313 Use this attribute to indicate that the specified function has no
5314 caller-saved registers. That is, all registers are callee-saved. For
5315 example, this attribute can be used for a function called from an
5316 interrupt handler. The compiler generates proper function entry and
5317 exit sequences to save and restore any modified registers, except for
5318 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5319 states, the GCC option @option{-mgeneral-regs-only} should be used to
5320 compile functions with @code{no_caller_saved_registers} attribute.
5322 @item interrupt
5323 @cindex @code{interrupt} function attribute, x86
5324 Use this attribute to indicate that the specified function is an
5325 interrupt handler or an exception handler (depending on parameters passed
5326 to the function, explained further).  The compiler generates function
5327 entry and exit sequences suitable for use in an interrupt handler when
5328 this attribute is present.  The @code{IRET} instruction, instead of the
5329 @code{RET} instruction, is used to return from interrupt handlers.  All
5330 registers, except for the EFLAGS register which is restored by the
5331 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5332 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5333 @option{-mgeneral-regs-only} should be used to compile interrupt and
5334 exception handlers.
5336 Any interruptible-without-stack-switch code must be compiled with
5337 @option{-mno-red-zone} since interrupt handlers can and will, because
5338 of the hardware design, touch the red zone.
5340 An interrupt handler must be declared with a mandatory pointer
5341 argument:
5343 @smallexample
5344 struct interrupt_frame;
5346 __attribute__ ((interrupt))
5347 void
5348 f (struct interrupt_frame *frame)
5351 @end smallexample
5353 @noindent
5354 and you must define @code{struct interrupt_frame} as described in the
5355 processor's manual.
5357 Exception handlers differ from interrupt handlers because the system
5358 pushes an error code on the stack.  An exception handler declaration is
5359 similar to that for an interrupt handler, but with a different mandatory
5360 function signature.  The compiler arranges to pop the error code off the
5361 stack before the @code{IRET} instruction.
5363 @smallexample
5364 #ifdef __x86_64__
5365 typedef unsigned long long int uword_t;
5366 #else
5367 typedef unsigned int uword_t;
5368 #endif
5370 struct interrupt_frame;
5372 __attribute__ ((interrupt))
5373 void
5374 f (struct interrupt_frame *frame, uword_t error_code)
5376   ...
5378 @end smallexample
5380 Exception handlers should only be used for exceptions that push an error
5381 code; you should use an interrupt handler in other cases.  The system
5382 will crash if the wrong kind of handler is used.
5384 @item target (@var{options})
5385 @cindex @code{target} function attribute
5386 As discussed in @ref{Common Function Attributes}, this attribute 
5387 allows specification of target-specific compilation options.
5389 On the x86, the following options are allowed:
5390 @table @samp
5391 @item abm
5392 @itemx no-abm
5393 @cindex @code{target("abm")} function attribute, x86
5394 Enable/disable the generation of the advanced bit instructions.
5396 @item aes
5397 @itemx no-aes
5398 @cindex @code{target("aes")} function attribute, x86
5399 Enable/disable the generation of the AES instructions.
5401 @item default
5402 @cindex @code{target("default")} function attribute, x86
5403 @xref{Function Multiversioning}, where it is used to specify the
5404 default function version.
5406 @item mmx
5407 @itemx no-mmx
5408 @cindex @code{target("mmx")} function attribute, x86
5409 Enable/disable the generation of the MMX instructions.
5411 @item pclmul
5412 @itemx no-pclmul
5413 @cindex @code{target("pclmul")} function attribute, x86
5414 Enable/disable the generation of the PCLMUL instructions.
5416 @item popcnt
5417 @itemx no-popcnt
5418 @cindex @code{target("popcnt")} function attribute, x86
5419 Enable/disable the generation of the POPCNT instruction.
5421 @item sse
5422 @itemx no-sse
5423 @cindex @code{target("sse")} function attribute, x86
5424 Enable/disable the generation of the SSE instructions.
5426 @item sse2
5427 @itemx no-sse2
5428 @cindex @code{target("sse2")} function attribute, x86
5429 Enable/disable the generation of the SSE2 instructions.
5431 @item sse3
5432 @itemx no-sse3
5433 @cindex @code{target("sse3")} function attribute, x86
5434 Enable/disable the generation of the SSE3 instructions.
5436 @item sse4
5437 @itemx no-sse4
5438 @cindex @code{target("sse4")} function attribute, x86
5439 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5440 and SSE4.2).
5442 @item sse4.1
5443 @itemx no-sse4.1
5444 @cindex @code{target("sse4.1")} function attribute, x86
5445 Enable/disable the generation of the sse4.1 instructions.
5447 @item sse4.2
5448 @itemx no-sse4.2
5449 @cindex @code{target("sse4.2")} function attribute, x86
5450 Enable/disable the generation of the sse4.2 instructions.
5452 @item sse4a
5453 @itemx no-sse4a
5454 @cindex @code{target("sse4a")} function attribute, x86
5455 Enable/disable the generation of the SSE4A instructions.
5457 @item fma4
5458 @itemx no-fma4
5459 @cindex @code{target("fma4")} function attribute, x86
5460 Enable/disable the generation of the FMA4 instructions.
5462 @item xop
5463 @itemx no-xop
5464 @cindex @code{target("xop")} function attribute, x86
5465 Enable/disable the generation of the XOP instructions.
5467 @item lwp
5468 @itemx no-lwp
5469 @cindex @code{target("lwp")} function attribute, x86
5470 Enable/disable the generation of the LWP instructions.
5472 @item ssse3
5473 @itemx no-ssse3
5474 @cindex @code{target("ssse3")} function attribute, x86
5475 Enable/disable the generation of the SSSE3 instructions.
5477 @item cld
5478 @itemx no-cld
5479 @cindex @code{target("cld")} function attribute, x86
5480 Enable/disable the generation of the CLD before string moves.
5482 @item fancy-math-387
5483 @itemx no-fancy-math-387
5484 @cindex @code{target("fancy-math-387")} function attribute, x86
5485 Enable/disable the generation of the @code{sin}, @code{cos}, and
5486 @code{sqrt} instructions on the 387 floating-point unit.
5488 @item ieee-fp
5489 @itemx no-ieee-fp
5490 @cindex @code{target("ieee-fp")} function attribute, x86
5491 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5493 @item inline-all-stringops
5494 @itemx no-inline-all-stringops
5495 @cindex @code{target("inline-all-stringops")} function attribute, x86
5496 Enable/disable inlining of string operations.
5498 @item inline-stringops-dynamically
5499 @itemx no-inline-stringops-dynamically
5500 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5501 Enable/disable the generation of the inline code to do small string
5502 operations and calling the library routines for large operations.
5504 @item align-stringops
5505 @itemx no-align-stringops
5506 @cindex @code{target("align-stringops")} function attribute, x86
5507 Do/do not align destination of inlined string operations.
5509 @item recip
5510 @itemx no-recip
5511 @cindex @code{target("recip")} function attribute, x86
5512 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5513 instructions followed an additional Newton-Raphson step instead of
5514 doing a floating-point division.
5516 @item arch=@var{ARCH}
5517 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5518 Specify the architecture to generate code for in compiling the function.
5520 @item tune=@var{TUNE}
5521 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5522 Specify the architecture to tune for in compiling the function.
5524 @item fpmath=@var{FPMATH}
5525 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5526 Specify which floating-point unit to use.  You must specify the
5527 @code{target("fpmath=sse,387")} option as
5528 @code{target("fpmath=sse+387")} because the comma would separate
5529 different options.
5530 @end table
5532 On the x86, the inliner does not inline a
5533 function that has different target options than the caller, unless the
5534 callee has a subset of the target options of the caller.  For example
5535 a function declared with @code{target("sse3")} can inline a function
5536 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5537 @end table
5539 @node Xstormy16 Function Attributes
5540 @subsection Xstormy16 Function Attributes
5542 These function attributes are supported by the Xstormy16 back end:
5544 @table @code
5545 @item interrupt
5546 @cindex @code{interrupt} function attribute, Xstormy16
5547 Use this attribute to indicate
5548 that the specified function is an interrupt handler.  The compiler generates
5549 function entry and exit sequences suitable for use in an interrupt handler
5550 when this attribute is present.
5551 @end table
5553 @node Variable Attributes
5554 @section Specifying Attributes of Variables
5555 @cindex attribute of variables
5556 @cindex variable attributes
5558 The keyword @code{__attribute__} allows you to specify special
5559 attributes of variables or structure fields.  This keyword is followed
5560 by an attribute specification inside double parentheses.  Some
5561 attributes are currently defined generically for variables.
5562 Other attributes are defined for variables on particular target
5563 systems.  Other attributes are available for functions
5564 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5565 enumerators (@pxref{Enumerator Attributes}), statements
5566 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5567 Other front ends might define more attributes
5568 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5570 @xref{Attribute Syntax}, for details of the exact syntax for using
5571 attributes.
5573 @menu
5574 * Common Variable Attributes::
5575 * AVR Variable Attributes::
5576 * Blackfin Variable Attributes::
5577 * H8/300 Variable Attributes::
5578 * IA-64 Variable Attributes::
5579 * M32R/D Variable Attributes::
5580 * MeP Variable Attributes::
5581 * Microsoft Windows Variable Attributes::
5582 * MSP430 Variable Attributes::
5583 * Nvidia PTX Variable Attributes::
5584 * PowerPC Variable Attributes::
5585 * RL78 Variable Attributes::
5586 * SPU Variable Attributes::
5587 * V850 Variable Attributes::
5588 * x86 Variable Attributes::
5589 * Xstormy16 Variable Attributes::
5590 @end menu
5592 @node Common Variable Attributes
5593 @subsection Common Variable Attributes
5595 The following attributes are supported on most targets.
5597 @table @code
5598 @cindex @code{aligned} variable attribute
5599 @item aligned (@var{alignment})
5600 This attribute specifies a minimum alignment for the variable or
5601 structure field, measured in bytes.  For example, the declaration:
5603 @smallexample
5604 int x __attribute__ ((aligned (16))) = 0;
5605 @end smallexample
5607 @noindent
5608 causes the compiler to allocate the global variable @code{x} on a
5609 16-byte boundary.  On a 68040, this could be used in conjunction with
5610 an @code{asm} expression to access the @code{move16} instruction which
5611 requires 16-byte aligned operands.
5613 You can also specify the alignment of structure fields.  For example, to
5614 create a double-word aligned @code{int} pair, you could write:
5616 @smallexample
5617 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5618 @end smallexample
5620 @noindent
5621 This is an alternative to creating a union with a @code{double} member,
5622 which forces the union to be double-word aligned.
5624 As in the preceding examples, you can explicitly specify the alignment
5625 (in bytes) that you wish the compiler to use for a given variable or
5626 structure field.  Alternatively, you can leave out the alignment factor
5627 and just ask the compiler to align a variable or field to the
5628 default alignment for the target architecture you are compiling for.
5629 The default alignment is sufficient for all scalar types, but may not be
5630 enough for all vector types on a target that supports vector operations.
5631 The default alignment is fixed for a particular target ABI.
5633 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5634 which is the largest alignment ever used for any data type on the
5635 target machine you are compiling for.  For example, you could write:
5637 @smallexample
5638 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5639 @end smallexample
5641 The compiler automatically sets the alignment for the declared
5642 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5643 often make copy operations more efficient, because the compiler can
5644 use whatever instructions copy the biggest chunks of memory when
5645 performing copies to or from the variables or fields that you have
5646 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5647 may change depending on command-line options.
5649 When used on a struct, or struct member, the @code{aligned} attribute can
5650 only increase the alignment; in order to decrease it, the @code{packed}
5651 attribute must be specified as well.  When used as part of a typedef, the
5652 @code{aligned} attribute can both increase and decrease alignment, and
5653 specifying the @code{packed} attribute generates a warning.
5655 Note that the effectiveness of @code{aligned} attributes may be limited
5656 by inherent limitations in your linker.  On many systems, the linker is
5657 only able to arrange for variables to be aligned up to a certain maximum
5658 alignment.  (For some linkers, the maximum supported alignment may
5659 be very very small.)  If your linker is only able to align variables
5660 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5661 in an @code{__attribute__} still only provides you with 8-byte
5662 alignment.  See your linker documentation for further information.
5664 The @code{aligned} attribute can also be used for functions
5665 (@pxref{Common Function Attributes}.)
5667 @item cleanup (@var{cleanup_function})
5668 @cindex @code{cleanup} variable attribute
5669 The @code{cleanup} attribute runs a function when the variable goes
5670 out of scope.  This attribute can only be applied to auto function
5671 scope variables; it may not be applied to parameters or variables
5672 with static storage duration.  The function must take one parameter,
5673 a pointer to a type compatible with the variable.  The return value
5674 of the function (if any) is ignored.
5676 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5677 is run during the stack unwinding that happens during the
5678 processing of the exception.  Note that the @code{cleanup} attribute
5679 does not allow the exception to be caught, only to perform an action.
5680 It is undefined what happens if @var{cleanup_function} does not
5681 return normally.
5683 @item common
5684 @itemx nocommon
5685 @cindex @code{common} variable attribute
5686 @cindex @code{nocommon} variable attribute
5687 @opindex fcommon
5688 @opindex fno-common
5689 The @code{common} attribute requests GCC to place a variable in
5690 ``common'' storage.  The @code{nocommon} attribute requests the
5691 opposite---to allocate space for it directly.
5693 These attributes override the default chosen by the
5694 @option{-fno-common} and @option{-fcommon} flags respectively.
5696 @item deprecated
5697 @itemx deprecated (@var{msg})
5698 @cindex @code{deprecated} variable attribute
5699 The @code{deprecated} attribute results in a warning if the variable
5700 is used anywhere in the source file.  This is useful when identifying
5701 variables that are expected to be removed in a future version of a
5702 program.  The warning also includes the location of the declaration
5703 of the deprecated variable, to enable users to easily find further
5704 information about why the variable is deprecated, or what they should
5705 do instead.  Note that the warning only occurs for uses:
5707 @smallexample
5708 extern int old_var __attribute__ ((deprecated));
5709 extern int old_var;
5710 int new_fn () @{ return old_var; @}
5711 @end smallexample
5713 @noindent
5714 results in a warning on line 3 but not line 2.  The optional @var{msg}
5715 argument, which must be a string, is printed in the warning if
5716 present.
5718 The @code{deprecated} attribute can also be used for functions and
5719 types (@pxref{Common Function Attributes},
5720 @pxref{Common Type Attributes}).
5722 @item mode (@var{mode})
5723 @cindex @code{mode} variable attribute
5724 This attribute specifies the data type for the declaration---whichever
5725 type corresponds to the mode @var{mode}.  This in effect lets you
5726 request an integer or floating-point type according to its width.
5728 You may also specify a mode of @code{byte} or @code{__byte__} to
5729 indicate the mode corresponding to a one-byte integer, @code{word} or
5730 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5731 or @code{__pointer__} for the mode used to represent pointers.
5733 @item packed
5734 @cindex @code{packed} variable attribute
5735 The @code{packed} attribute specifies that a variable or structure field
5736 should have the smallest possible alignment---one byte for a variable,
5737 and one bit for a field, unless you specify a larger value with the
5738 @code{aligned} attribute.
5740 Here is a structure in which the field @code{x} is packed, so that it
5741 immediately follows @code{a}:
5743 @smallexample
5744 struct foo
5746   char a;
5747   int x[2] __attribute__ ((packed));
5749 @end smallexample
5751 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5752 @code{packed} attribute on bit-fields of type @code{char}.  This has
5753 been fixed in GCC 4.4 but the change can lead to differences in the
5754 structure layout.  See the documentation of
5755 @option{-Wpacked-bitfield-compat} for more information.
5757 @item section ("@var{section-name}")
5758 @cindex @code{section} variable attribute
5759 Normally, the compiler places the objects it generates in sections like
5760 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5761 or you need certain particular variables to appear in special sections,
5762 for example to map to special hardware.  The @code{section}
5763 attribute specifies that a variable (or function) lives in a particular
5764 section.  For example, this small program uses several specific section names:
5766 @smallexample
5767 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5768 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5769 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5770 int init_data __attribute__ ((section ("INITDATA")));
5772 main()
5774   /* @r{Initialize stack pointer} */
5775   init_sp (stack + sizeof (stack));
5777   /* @r{Initialize initialized data} */
5778   memcpy (&init_data, &data, &edata - &data);
5780   /* @r{Turn on the serial ports} */
5781   init_duart (&a);
5782   init_duart (&b);
5784 @end smallexample
5786 @noindent
5787 Use the @code{section} attribute with
5788 @emph{global} variables and not @emph{local} variables,
5789 as shown in the example.
5791 You may use the @code{section} attribute with initialized or
5792 uninitialized global variables but the linker requires
5793 each object be defined once, with the exception that uninitialized
5794 variables tentatively go in the @code{common} (or @code{bss}) section
5795 and can be multiply ``defined''.  Using the @code{section} attribute
5796 changes what section the variable goes into and may cause the
5797 linker to issue an error if an uninitialized variable has multiple
5798 definitions.  You can force a variable to be initialized with the
5799 @option{-fno-common} flag or the @code{nocommon} attribute.
5801 Some file formats do not support arbitrary sections so the @code{section}
5802 attribute is not available on all platforms.
5803 If you need to map the entire contents of a module to a particular
5804 section, consider using the facilities of the linker instead.
5806 @item tls_model ("@var{tls_model}")
5807 @cindex @code{tls_model} variable attribute
5808 The @code{tls_model} attribute sets thread-local storage model
5809 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5810 overriding @option{-ftls-model=} command-line switch on a per-variable
5811 basis.
5812 The @var{tls_model} argument should be one of @code{global-dynamic},
5813 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5815 Not all targets support this attribute.
5817 @item unused
5818 @cindex @code{unused} variable attribute
5819 This attribute, attached to a variable, means that the variable is meant
5820 to be possibly unused.  GCC does not produce a warning for this
5821 variable.
5823 @item used
5824 @cindex @code{used} variable attribute
5825 This attribute, attached to a variable with static storage, means that
5826 the variable must be emitted even if it appears that the variable is not
5827 referenced.
5829 When applied to a static data member of a C++ class template, the
5830 attribute also means that the member is instantiated if the
5831 class itself is instantiated.
5833 @item vector_size (@var{bytes})
5834 @cindex @code{vector_size} variable attribute
5835 This attribute specifies the vector size for the variable, measured in
5836 bytes.  For example, the declaration:
5838 @smallexample
5839 int foo __attribute__ ((vector_size (16)));
5840 @end smallexample
5842 @noindent
5843 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5844 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5845 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5847 This attribute is only applicable to integral and float scalars,
5848 although arrays, pointers, and function return values are allowed in
5849 conjunction with this construct.
5851 Aggregates with this attribute are invalid, even if they are of the same
5852 size as a corresponding scalar.  For example, the declaration:
5854 @smallexample
5855 struct S @{ int a; @};
5856 struct S  __attribute__ ((vector_size (16))) foo;
5857 @end smallexample
5859 @noindent
5860 is invalid even if the size of the structure is the same as the size of
5861 the @code{int}.
5863 @item visibility ("@var{visibility_type}")
5864 @cindex @code{visibility} variable attribute
5865 This attribute affects the linkage of the declaration to which it is attached.
5866 The @code{visibility} attribute is described in
5867 @ref{Common Function Attributes}.
5869 @item weak
5870 @cindex @code{weak} variable attribute
5871 The @code{weak} attribute is described in
5872 @ref{Common Function Attributes}.
5874 @end table
5876 @node AVR Variable Attributes
5877 @subsection AVR Variable Attributes
5879 @table @code
5880 @item progmem
5881 @cindex @code{progmem} variable attribute, AVR
5882 The @code{progmem} attribute is used on the AVR to place read-only
5883 data in the non-volatile program memory (flash). The @code{progmem}
5884 attribute accomplishes this by putting respective variables into a
5885 section whose name starts with @code{.progmem}.
5887 This attribute works similar to the @code{section} attribute
5888 but adds additional checking.
5890 @table @asis
5891 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5892 @code{progmem} affects the location
5893 of the data but not how this data is accessed.
5894 In order to read data located with the @code{progmem} attribute
5895 (inline) assembler must be used.
5896 @smallexample
5897 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5898 #include <avr/pgmspace.h> 
5900 /* Locate var in flash memory */
5901 const int var[2] PROGMEM = @{ 1, 2 @};
5903 int read_var (int i)
5905     /* Access var[] by accessor macro from avr/pgmspace.h */
5906     return (int) pgm_read_word (& var[i]);
5908 @end smallexample
5910 AVR is a Harvard architecture processor and data and read-only data
5911 normally resides in the data memory (RAM).
5913 See also the @ref{AVR Named Address Spaces} section for
5914 an alternate way to locate and access data in flash memory.
5916 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5917 The compiler adds @code{0x4000}
5918 to the addresses of objects and declarations in @code{progmem} and locates
5919 the objects in flash memory, namely in section @code{.progmem.data}.
5920 The offset is needed because the flash memory is visible in the RAM
5921 address space starting at address @code{0x4000}.
5923 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5924 no special functions or macros are needed.
5926 @smallexample
5927 /* var is located in flash memory */
5928 extern const int var[2] __attribute__((progmem));
5930 int read_var (int i)
5932     return var[i];
5934 @end smallexample
5936 Please notice that on these devices, there is no need for @code{progmem}
5937 at all.  Just use an appropriate linker description file like outlined below.
5939 @smallexample
5940   .text :
5941   @{ ...
5942   @} > text
5943   /* Leave .rodata in flash and add an offset of 0x4000 to all
5944      addresses so that respective objects can be accessed by LD
5945      instructions and open coded C/C++.  This means there is no
5946      need for progmem in the source and no overhead by read-only
5947      data in RAM.  */
5948   .rodata ADDR(.text) + SIZEOF (.text) + 0x4000 :
5949   @{
5950     *(.rodata)
5951     *(.rodata*)
5952     *(.gnu.linkonce.r*)
5953   @} AT> text
5954   /* No more need to put .rodata into .data:
5955      Removed all .rodata entries from .data.  */
5956   .data :
5957   @{ ...
5958 @end smallexample
5960 @end table
5962 @item io
5963 @itemx io (@var{addr})
5964 @cindex @code{io} variable attribute, AVR
5965 Variables with the @code{io} attribute are used to address
5966 memory-mapped peripherals in the io address range.
5967 If an address is specified, the variable
5968 is assigned that address, and the value is interpreted as an
5969 address in the data address space.
5970 Example:
5972 @smallexample
5973 volatile int porta __attribute__((io (0x22)));
5974 @end smallexample
5976 The address specified in the address in the data address range.
5978 Otherwise, the variable it is not assigned an address, but the
5979 compiler will still use in/out instructions where applicable,
5980 assuming some other module assigns an address in the io address range.
5981 Example:
5983 @smallexample
5984 extern volatile int porta __attribute__((io));
5985 @end smallexample
5987 @item io_low
5988 @itemx io_low (@var{addr})
5989 @cindex @code{io_low} variable attribute, AVR
5990 This is like the @code{io} attribute, but additionally it informs the
5991 compiler that the object lies in the lower half of the I/O area,
5992 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5993 instructions.
5995 @item address
5996 @itemx address (@var{addr})
5997 @cindex @code{address} variable attribute, AVR
5998 Variables with the @code{address} attribute are used to address
5999 memory-mapped peripherals that may lie outside the io address range.
6001 @smallexample
6002 volatile int porta __attribute__((address (0x600)));
6003 @end smallexample
6005 @item absdata
6006 @cindex @code{absdata} variable attribute, AVR
6007 Variables in static storage and with the @code{absdata} attribute can
6008 be accessed by the @code{LDS} and @code{STS} instructions which take
6009 absolute addresses.
6011 @itemize @bullet
6012 @item
6013 This attribute is only supported for the reduced AVR Tiny core
6014 like ATtiny40.
6016 @item
6017 You must make sure that respective data is located in the
6018 address range @code{0x40}@dots{}@code{0xbf} accessible by
6019 @code{LDS} and @code{STS}.  One way to achieve this as an
6020 appropriate linker description file.
6022 @item
6023 If the location does not fit the address range of @code{LDS}
6024 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6025 warning like
6026 @quotation
6027 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6028 @end quotation
6030 @end itemize
6032 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6034 @end table
6036 @node Blackfin Variable Attributes
6037 @subsection Blackfin Variable Attributes
6039 Three attributes are currently defined for the Blackfin.
6041 @table @code
6042 @item l1_data
6043 @itemx l1_data_A
6044 @itemx l1_data_B
6045 @cindex @code{l1_data} variable attribute, Blackfin
6046 @cindex @code{l1_data_A} variable attribute, Blackfin
6047 @cindex @code{l1_data_B} variable attribute, Blackfin
6048 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6049 Variables with @code{l1_data} attribute are put into the specific section
6050 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6051 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6052 attribute are put into the specific section named @code{.l1.data.B}.
6054 @item l2
6055 @cindex @code{l2} variable attribute, Blackfin
6056 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6057 Variables with @code{l2} attribute are put into the specific section
6058 named @code{.l2.data}.
6059 @end table
6061 @node H8/300 Variable Attributes
6062 @subsection H8/300 Variable Attributes
6064 These variable attributes are available for H8/300 targets:
6066 @table @code
6067 @item eightbit_data
6068 @cindex @code{eightbit_data} variable attribute, H8/300
6069 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6070 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6071 variable should be placed into the eight-bit data section.
6072 The compiler generates more efficient code for certain operations
6073 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6074 256 bytes of data.
6076 You must use GAS and GLD from GNU binutils version 2.7 or later for
6077 this attribute to work correctly.
6079 @item tiny_data
6080 @cindex @code{tiny_data} variable attribute, H8/300
6081 @cindex tiny data section on the H8/300H and H8S
6082 Use this attribute on the H8/300H and H8S to indicate that the specified
6083 variable should be placed into the tiny data section.
6084 The compiler generates more efficient code for loads and stores
6085 on data in the tiny data section.  Note the tiny data area is limited to
6086 slightly under 32KB of data.
6088 @end table
6090 @node IA-64 Variable Attributes
6091 @subsection IA-64 Variable Attributes
6093 The IA-64 back end supports the following variable attribute:
6095 @table @code
6096 @item model (@var{model-name})
6097 @cindex @code{model} variable attribute, IA-64
6099 On IA-64, use this attribute to set the addressability of an object.
6100 At present, the only supported identifier for @var{model-name} is
6101 @code{small}, indicating addressability via ``small'' (22-bit)
6102 addresses (so that their addresses can be loaded with the @code{addl}
6103 instruction).  Caveat: such addressing is by definition not position
6104 independent and hence this attribute must not be used for objects
6105 defined by shared libraries.
6107 @end table
6109 @node M32R/D Variable Attributes
6110 @subsection M32R/D Variable Attributes
6112 One attribute is currently defined for the M32R/D@.
6114 @table @code
6115 @item model (@var{model-name})
6116 @cindex @code{model-name} variable attribute, M32R/D
6117 @cindex variable addressability on the M32R/D
6118 Use this attribute on the M32R/D to set the addressability of an object.
6119 The identifier @var{model-name} is one of @code{small}, @code{medium},
6120 or @code{large}, representing each of the code models.
6122 Small model objects live in the lower 16MB of memory (so that their
6123 addresses can be loaded with the @code{ld24} instruction).
6125 Medium and large model objects may live anywhere in the 32-bit address space
6126 (the compiler generates @code{seth/add3} instructions to load their
6127 addresses).
6128 @end table
6130 @node MeP Variable Attributes
6131 @subsection MeP Variable Attributes
6133 The MeP target has a number of addressing modes and busses.  The
6134 @code{near} space spans the standard memory space's first 16 megabytes
6135 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6136 The @code{based} space is a 128-byte region in the memory space that
6137 is addressed relative to the @code{$tp} register.  The @code{tiny}
6138 space is a 65536-byte region relative to the @code{$gp} register.  In
6139 addition to these memory regions, the MeP target has a separate 16-bit
6140 control bus which is specified with @code{cb} attributes.
6142 @table @code
6144 @item based
6145 @cindex @code{based} variable attribute, MeP
6146 Any variable with the @code{based} attribute is assigned to the
6147 @code{.based} section, and is accessed with relative to the
6148 @code{$tp} register.
6150 @item tiny
6151 @cindex @code{tiny} variable attribute, MeP
6152 Likewise, the @code{tiny} attribute assigned variables to the
6153 @code{.tiny} section, relative to the @code{$gp} register.
6155 @item near
6156 @cindex @code{near} variable attribute, MeP
6157 Variables with the @code{near} attribute are assumed to have addresses
6158 that fit in a 24-bit addressing mode.  This is the default for large
6159 variables (@code{-mtiny=4} is the default) but this attribute can
6160 override @code{-mtiny=} for small variables, or override @code{-ml}.
6162 @item far
6163 @cindex @code{far} variable attribute, MeP
6164 Variables with the @code{far} attribute are addressed using a full
6165 32-bit address.  Since this covers the entire memory space, this
6166 allows modules to make no assumptions about where variables might be
6167 stored.
6169 @item io
6170 @cindex @code{io} variable attribute, MeP
6171 @itemx io (@var{addr})
6172 Variables with the @code{io} attribute are used to address
6173 memory-mapped peripherals.  If an address is specified, the variable
6174 is assigned that address, else it is not assigned an address (it is
6175 assumed some other module assigns an address).  Example:
6177 @smallexample
6178 int timer_count __attribute__((io(0x123)));
6179 @end smallexample
6181 @item cb
6182 @itemx cb (@var{addr})
6183 @cindex @code{cb} variable attribute, MeP
6184 Variables with the @code{cb} attribute are used to access the control
6185 bus, using special instructions.  @code{addr} indicates the control bus
6186 address.  Example:
6188 @smallexample
6189 int cpu_clock __attribute__((cb(0x123)));
6190 @end smallexample
6192 @end table
6194 @node Microsoft Windows Variable Attributes
6195 @subsection Microsoft Windows Variable Attributes
6197 You can use these attributes on Microsoft Windows targets.
6198 @ref{x86 Variable Attributes} for additional Windows compatibility
6199 attributes available on all x86 targets.
6201 @table @code
6202 @item dllimport
6203 @itemx dllexport
6204 @cindex @code{dllimport} variable attribute
6205 @cindex @code{dllexport} variable attribute
6206 The @code{dllimport} and @code{dllexport} attributes are described in
6207 @ref{Microsoft Windows Function Attributes}.
6209 @item selectany
6210 @cindex @code{selectany} variable attribute
6211 The @code{selectany} attribute causes an initialized global variable to
6212 have link-once semantics.  When multiple definitions of the variable are
6213 encountered by the linker, the first is selected and the remainder are
6214 discarded.  Following usage by the Microsoft compiler, the linker is told
6215 @emph{not} to warn about size or content differences of the multiple
6216 definitions.
6218 Although the primary usage of this attribute is for POD types, the
6219 attribute can also be applied to global C++ objects that are initialized
6220 by a constructor.  In this case, the static initialization and destruction
6221 code for the object is emitted in each translation defining the object,
6222 but the calls to the constructor and destructor are protected by a
6223 link-once guard variable.
6225 The @code{selectany} attribute is only available on Microsoft Windows
6226 targets.  You can use @code{__declspec (selectany)} as a synonym for
6227 @code{__attribute__ ((selectany))} for compatibility with other
6228 compilers.
6230 @item shared
6231 @cindex @code{shared} variable attribute
6232 On Microsoft Windows, in addition to putting variable definitions in a named
6233 section, the section can also be shared among all running copies of an
6234 executable or DLL@.  For example, this small program defines shared data
6235 by putting it in a named section @code{shared} and marking the section
6236 shareable:
6238 @smallexample
6239 int foo __attribute__((section ("shared"), shared)) = 0;
6242 main()
6244   /* @r{Read and write foo.  All running
6245      copies see the same value.}  */
6246   return 0;
6248 @end smallexample
6250 @noindent
6251 You may only use the @code{shared} attribute along with @code{section}
6252 attribute with a fully-initialized global definition because of the way
6253 linkers work.  See @code{section} attribute for more information.
6255 The @code{shared} attribute is only available on Microsoft Windows@.
6257 @end table
6259 @node MSP430 Variable Attributes
6260 @subsection MSP430 Variable Attributes
6262 @table @code
6263 @item noinit
6264 @cindex @code{noinit} variable attribute, MSP430 
6265 Any data with the @code{noinit} attribute will not be initialised by
6266 the C runtime startup code, or the program loader.  Not initialising
6267 data in this way can reduce program startup times.
6269 @item persistent
6270 @cindex @code{persistent} variable attribute, MSP430 
6271 Any variable with the @code{persistent} attribute will not be
6272 initialised by the C runtime startup code.  Instead its value will be
6273 set once, when the application is loaded, and then never initialised
6274 again, even if the processor is reset or the program restarts.
6275 Persistent data is intended to be placed into FLASH RAM, where its
6276 value will be retained across resets.  The linker script being used to
6277 create the application should ensure that persistent data is correctly
6278 placed.
6280 @item lower
6281 @itemx upper
6282 @itemx either
6283 @cindex @code{lower} variable attribute, MSP430 
6284 @cindex @code{upper} variable attribute, MSP430 
6285 @cindex @code{either} variable attribute, MSP430 
6286 These attributes are the same as the MSP430 function attributes of the
6287 same name (@pxref{MSP430 Function Attributes}).  
6288 These attributes can be applied to both functions and variables.
6289 @end table
6291 @node Nvidia PTX Variable Attributes
6292 @subsection Nvidia PTX Variable Attributes
6294 These variable attributes are supported by the Nvidia PTX back end:
6296 @table @code
6297 @item shared
6298 @cindex @code{shared} attribute, Nvidia PTX
6299 Use this attribute to place a variable in the @code{.shared} memory space.
6300 This memory space is private to each cooperative thread array; only threads
6301 within one thread block refer to the same instance of the variable.
6302 The runtime does not initialize variables in this memory space.
6303 @end table
6305 @node PowerPC Variable Attributes
6306 @subsection PowerPC Variable Attributes
6308 Three attributes currently are defined for PowerPC configurations:
6309 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6311 @cindex @code{ms_struct} variable attribute, PowerPC
6312 @cindex @code{gcc_struct} variable attribute, PowerPC
6313 For full documentation of the struct attributes please see the
6314 documentation in @ref{x86 Variable Attributes}.
6316 @cindex @code{altivec} variable attribute, PowerPC
6317 For documentation of @code{altivec} attribute please see the
6318 documentation in @ref{PowerPC Type Attributes}.
6320 @node RL78 Variable Attributes
6321 @subsection RL78 Variable Attributes
6323 @cindex @code{saddr} variable attribute, RL78
6324 The RL78 back end supports the @code{saddr} variable attribute.  This
6325 specifies placement of the corresponding variable in the SADDR area,
6326 which can be accessed more efficiently than the default memory region.
6328 @node SPU Variable Attributes
6329 @subsection SPU Variable Attributes
6331 @cindex @code{spu_vector} variable attribute, SPU
6332 The SPU supports the @code{spu_vector} attribute for variables.  For
6333 documentation of this attribute please see the documentation in
6334 @ref{SPU Type Attributes}.
6336 @node V850 Variable Attributes
6337 @subsection V850 Variable Attributes
6339 These variable attributes are supported by the V850 back end:
6341 @table @code
6343 @item sda
6344 @cindex @code{sda} variable attribute, V850
6345 Use this attribute to explicitly place a variable in the small data area,
6346 which can hold up to 64 kilobytes.
6348 @item tda
6349 @cindex @code{tda} variable attribute, V850
6350 Use this attribute to explicitly place a variable in the tiny data area,
6351 which can hold up to 256 bytes in total.
6353 @item zda
6354 @cindex @code{zda} variable attribute, V850
6355 Use this attribute to explicitly place a variable in the first 32 kilobytes
6356 of memory.
6357 @end table
6359 @node x86 Variable Attributes
6360 @subsection x86 Variable Attributes
6362 Two attributes are currently defined for x86 configurations:
6363 @code{ms_struct} and @code{gcc_struct}.
6365 @table @code
6366 @item ms_struct
6367 @itemx gcc_struct
6368 @cindex @code{ms_struct} variable attribute, x86
6369 @cindex @code{gcc_struct} variable attribute, x86
6371 If @code{packed} is used on a structure, or if bit-fields are used,
6372 it may be that the Microsoft ABI lays out the structure differently
6373 than the way GCC normally does.  Particularly when moving packed
6374 data between functions compiled with GCC and the native Microsoft compiler
6375 (either via function call or as data in a file), it may be necessary to access
6376 either format.
6378 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6379 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6380 command-line options, respectively;
6381 see @ref{x86 Options}, for details of how structure layout is affected.
6382 @xref{x86 Type Attributes}, for information about the corresponding
6383 attributes on types.
6385 @end table
6387 @node Xstormy16 Variable Attributes
6388 @subsection Xstormy16 Variable Attributes
6390 One attribute is currently defined for xstormy16 configurations:
6391 @code{below100}.
6393 @table @code
6394 @item below100
6395 @cindex @code{below100} variable attribute, Xstormy16
6397 If a variable has the @code{below100} attribute (@code{BELOW100} is
6398 allowed also), GCC places the variable in the first 0x100 bytes of
6399 memory and use special opcodes to access it.  Such variables are
6400 placed in either the @code{.bss_below100} section or the
6401 @code{.data_below100} section.
6403 @end table
6405 @node Type Attributes
6406 @section Specifying Attributes of Types
6407 @cindex attribute of types
6408 @cindex type attributes
6410 The keyword @code{__attribute__} allows you to specify special
6411 attributes of types.  Some type attributes apply only to @code{struct}
6412 and @code{union} types, while others can apply to any type defined
6413 via a @code{typedef} declaration.  Other attributes are defined for
6414 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6415 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6416 statements (@pxref{Statement Attributes}), and for
6417 variables (@pxref{Variable Attributes}).
6419 The @code{__attribute__} keyword is followed by an attribute specification
6420 inside double parentheses.  
6422 You may specify type attributes in an enum, struct or union type
6423 declaration or definition by placing them immediately after the
6424 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6425 syntax is to place them just past the closing curly brace of the
6426 definition.
6428 You can also include type attributes in a @code{typedef} declaration.
6429 @xref{Attribute Syntax}, for details of the exact syntax for using
6430 attributes.
6432 @menu
6433 * Common Type Attributes::
6434 * ARM Type Attributes::
6435 * MeP Type Attributes::
6436 * PowerPC Type Attributes::
6437 * SPU Type Attributes::
6438 * x86 Type Attributes::
6439 @end menu
6441 @node Common Type Attributes
6442 @subsection Common Type Attributes
6444 The following type attributes are supported on most targets.
6446 @table @code
6447 @cindex @code{aligned} type attribute
6448 @item aligned (@var{alignment})
6449 This attribute specifies a minimum alignment (in bytes) for variables
6450 of the specified type.  For example, the declarations:
6452 @smallexample
6453 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6454 typedef int more_aligned_int __attribute__ ((aligned (8)));
6455 @end smallexample
6457 @noindent
6458 force the compiler to ensure (as far as it can) that each variable whose
6459 type is @code{struct S} or @code{more_aligned_int} is allocated and
6460 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6461 variables of type @code{struct S} aligned to 8-byte boundaries allows
6462 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6463 store) instructions when copying one variable of type @code{struct S} to
6464 another, thus improving run-time efficiency.
6466 Note that the alignment of any given @code{struct} or @code{union} type
6467 is required by the ISO C standard to be at least a perfect multiple of
6468 the lowest common multiple of the alignments of all of the members of
6469 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6470 effectively adjust the alignment of a @code{struct} or @code{union}
6471 type by attaching an @code{aligned} attribute to any one of the members
6472 of such a type, but the notation illustrated in the example above is a
6473 more obvious, intuitive, and readable way to request the compiler to
6474 adjust the alignment of an entire @code{struct} or @code{union} type.
6476 As in the preceding example, you can explicitly specify the alignment
6477 (in bytes) that you wish the compiler to use for a given @code{struct}
6478 or @code{union} type.  Alternatively, you can leave out the alignment factor
6479 and just ask the compiler to align a type to the maximum
6480 useful alignment for the target machine you are compiling for.  For
6481 example, you could write:
6483 @smallexample
6484 struct S @{ short f[3]; @} __attribute__ ((aligned));
6485 @end smallexample
6487 Whenever you leave out the alignment factor in an @code{aligned}
6488 attribute specification, the compiler automatically sets the alignment
6489 for the type to the largest alignment that is ever used for any data
6490 type on the target machine you are compiling for.  Doing this can often
6491 make copy operations more efficient, because the compiler can use
6492 whatever instructions copy the biggest chunks of memory when performing
6493 copies to or from the variables that have types that you have aligned
6494 this way.
6496 In the example above, if the size of each @code{short} is 2 bytes, then
6497 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6498 power of two that is greater than or equal to that is 8, so the
6499 compiler sets the alignment for the entire @code{struct S} type to 8
6500 bytes.
6502 Note that although you can ask the compiler to select a time-efficient
6503 alignment for a given type and then declare only individual stand-alone
6504 objects of that type, the compiler's ability to select a time-efficient
6505 alignment is primarily useful only when you plan to create arrays of
6506 variables having the relevant (efficiently aligned) type.  If you
6507 declare or use arrays of variables of an efficiently-aligned type, then
6508 it is likely that your program also does pointer arithmetic (or
6509 subscripting, which amounts to the same thing) on pointers to the
6510 relevant type, and the code that the compiler generates for these
6511 pointer arithmetic operations is often more efficient for
6512 efficiently-aligned types than for other types.
6514 Note that the effectiveness of @code{aligned} attributes may be limited
6515 by inherent limitations in your linker.  On many systems, the linker is
6516 only able to arrange for variables to be aligned up to a certain maximum
6517 alignment.  (For some linkers, the maximum supported alignment may
6518 be very very small.)  If your linker is only able to align variables
6519 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6520 in an @code{__attribute__} still only provides you with 8-byte
6521 alignment.  See your linker documentation for further information.
6523 The @code{aligned} attribute can only increase alignment.  Alignment
6524 can be decreased by specifying the @code{packed} attribute.  See below.
6526 @item bnd_variable_size
6527 @cindex @code{bnd_variable_size} type attribute
6528 @cindex Pointer Bounds Checker attributes
6529 When applied to a structure field, this attribute tells Pointer
6530 Bounds Checker that the size of this field should not be computed
6531 using static type information.  It may be used to mark variably-sized
6532 static array fields placed at the end of a structure.
6534 @smallexample
6535 struct S
6537   int size;
6538   char data[1];
6540 S *p = (S *)malloc (sizeof(S) + 100);
6541 p->data[10] = 0; //Bounds violation
6542 @end smallexample
6544 @noindent
6545 By using an attribute for the field we may avoid unwanted bound
6546 violation checks:
6548 @smallexample
6549 struct S
6551   int size;
6552   char data[1] __attribute__((bnd_variable_size));
6554 S *p = (S *)malloc (sizeof(S) + 100);
6555 p->data[10] = 0; //OK
6556 @end smallexample
6558 @item deprecated
6559 @itemx deprecated (@var{msg})
6560 @cindex @code{deprecated} type attribute
6561 The @code{deprecated} attribute results in a warning if the type
6562 is used anywhere in the source file.  This is useful when identifying
6563 types that are expected to be removed in a future version of a program.
6564 If possible, the warning also includes the location of the declaration
6565 of the deprecated type, to enable users to easily find further
6566 information about why the type is deprecated, or what they should do
6567 instead.  Note that the warnings only occur for uses and then only
6568 if the type is being applied to an identifier that itself is not being
6569 declared as deprecated.
6571 @smallexample
6572 typedef int T1 __attribute__ ((deprecated));
6573 T1 x;
6574 typedef T1 T2;
6575 T2 y;
6576 typedef T1 T3 __attribute__ ((deprecated));
6577 T3 z __attribute__ ((deprecated));
6578 @end smallexample
6580 @noindent
6581 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
6582 warning is issued for line 4 because T2 is not explicitly
6583 deprecated.  Line 5 has no warning because T3 is explicitly
6584 deprecated.  Similarly for line 6.  The optional @var{msg}
6585 argument, which must be a string, is printed in the warning if
6586 present.
6588 The @code{deprecated} attribute can also be used for functions and
6589 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6591 @item designated_init
6592 @cindex @code{designated_init} type attribute
6593 This attribute may only be applied to structure types.  It indicates
6594 that any initialization of an object of this type must use designated
6595 initializers rather than positional initializers.  The intent of this
6596 attribute is to allow the programmer to indicate that a structure's
6597 layout may change, and that therefore relying on positional
6598 initialization will result in future breakage.
6600 GCC emits warnings based on this attribute by default; use
6601 @option{-Wno-designated-init} to suppress them.
6603 @item may_alias
6604 @cindex @code{may_alias} type attribute
6605 Accesses through pointers to types with this attribute are not subject
6606 to type-based alias analysis, but are instead assumed to be able to alias
6607 any other type of objects.
6608 In the context of section 6.5 paragraph 7 of the C99 standard,
6609 an lvalue expression
6610 dereferencing such a pointer is treated like having a character type.
6611 See @option{-fstrict-aliasing} for more information on aliasing issues.
6612 This extension exists to support some vector APIs, in which pointers to
6613 one vector type are permitted to alias pointers to a different vector type.
6615 Note that an object of a type with this attribute does not have any
6616 special semantics.
6618 Example of use:
6620 @smallexample
6621 typedef short __attribute__((__may_alias__)) short_a;
6624 main (void)
6626   int a = 0x12345678;
6627   short_a *b = (short_a *) &a;
6629   b[1] = 0;
6631   if (a == 0x12345678)
6632     abort();
6634   exit(0);
6636 @end smallexample
6638 @noindent
6639 If you replaced @code{short_a} with @code{short} in the variable
6640 declaration, the above program would abort when compiled with
6641 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6642 above.
6644 @item packed
6645 @cindex @code{packed} type attribute
6646 This attribute, attached to @code{struct} or @code{union} type
6647 definition, specifies that each member (other than zero-width bit-fields)
6648 of the structure or union is placed to minimize the memory required.  When
6649 attached to an @code{enum} definition, it indicates that the smallest
6650 integral type should be used.
6652 @opindex fshort-enums
6653 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6654 types is equivalent to specifying the @code{packed} attribute on each
6655 of the structure or union members.  Specifying the @option{-fshort-enums}
6656 flag on the command line is equivalent to specifying the @code{packed}
6657 attribute on all @code{enum} definitions.
6659 In the following example @code{struct my_packed_struct}'s members are
6660 packed closely together, but the internal layout of its @code{s} member
6661 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6662 be packed too.
6664 @smallexample
6665 struct my_unpacked_struct
6666  @{
6667     char c;
6668     int i;
6669  @};
6671 struct __attribute__ ((__packed__)) my_packed_struct
6672   @{
6673      char c;
6674      int  i;
6675      struct my_unpacked_struct s;
6676   @};
6677 @end smallexample
6679 You may only specify the @code{packed} attribute attribute on the definition
6680 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6681 that does not also define the enumerated type, structure or union.
6683 @item scalar_storage_order ("@var{endianness}")
6684 @cindex @code{scalar_storage_order} type attribute
6685 When attached to a @code{union} or a @code{struct}, this attribute sets
6686 the storage order, aka endianness, of the scalar fields of the type, as
6687 well as the array fields whose component is scalar.  The supported
6688 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
6689 has no effects on fields which are themselves a @code{union}, a @code{struct}
6690 or an array whose component is a @code{union} or a @code{struct}, and it is
6691 possible for these fields to have a different scalar storage order than the
6692 enclosing type.
6694 This attribute is supported only for targets that use a uniform default
6695 scalar storage order (fortunately, most of them), i.e. targets that store
6696 the scalars either all in big-endian or all in little-endian.
6698 Additional restrictions are enforced for types with the reverse scalar
6699 storage order with regard to the scalar storage order of the target:
6701 @itemize
6702 @item Taking the address of a scalar field of a @code{union} or a
6703 @code{struct} with reverse scalar storage order is not permitted and yields
6704 an error.
6705 @item Taking the address of an array field, whose component is scalar, of
6706 a @code{union} or a @code{struct} with reverse scalar storage order is
6707 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6708 is specified.
6709 @item Taking the address of a @code{union} or a @code{struct} with reverse
6710 scalar storage order is permitted.
6711 @end itemize
6713 These restrictions exist because the storage order attribute is lost when
6714 the address of a scalar or the address of an array with scalar component is
6715 taken, so storing indirectly through this address generally does not work.
6716 The second case is nevertheless allowed to be able to perform a block copy
6717 from or to the array.
6719 Moreover, the use of type punning or aliasing to toggle the storage order
6720 is not supported; that is to say, a given scalar object cannot be accessed
6721 through distinct types that assign a different storage order to it.
6723 @item transparent_union
6724 @cindex @code{transparent_union} type attribute
6726 This attribute, attached to a @code{union} type definition, indicates
6727 that any function parameter having that union type causes calls to that
6728 function to be treated in a special way.
6730 First, the argument corresponding to a transparent union type can be of
6731 any type in the union; no cast is required.  Also, if the union contains
6732 a pointer type, the corresponding argument can be a null pointer
6733 constant or a void pointer expression; and if the union contains a void
6734 pointer type, the corresponding argument can be any pointer expression.
6735 If the union member type is a pointer, qualifiers like @code{const} on
6736 the referenced type must be respected, just as with normal pointer
6737 conversions.
6739 Second, the argument is passed to the function using the calling
6740 conventions of the first member of the transparent union, not the calling
6741 conventions of the union itself.  All members of the union must have the
6742 same machine representation; this is necessary for this argument passing
6743 to work properly.
6745 Transparent unions are designed for library functions that have multiple
6746 interfaces for compatibility reasons.  For example, suppose the
6747 @code{wait} function must accept either a value of type @code{int *} to
6748 comply with POSIX, or a value of type @code{union wait *} to comply with
6749 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
6750 @code{wait} would accept both kinds of arguments, but it would also
6751 accept any other pointer type and this would make argument type checking
6752 less useful.  Instead, @code{<sys/wait.h>} might define the interface
6753 as follows:
6755 @smallexample
6756 typedef union __attribute__ ((__transparent_union__))
6757   @{
6758     int *__ip;
6759     union wait *__up;
6760   @} wait_status_ptr_t;
6762 pid_t wait (wait_status_ptr_t);
6763 @end smallexample
6765 @noindent
6766 This interface allows either @code{int *} or @code{union wait *}
6767 arguments to be passed, using the @code{int *} calling convention.
6768 The program can call @code{wait} with arguments of either type:
6770 @smallexample
6771 int w1 () @{ int w; return wait (&w); @}
6772 int w2 () @{ union wait w; return wait (&w); @}
6773 @end smallexample
6775 @noindent
6776 With this interface, @code{wait}'s implementation might look like this:
6778 @smallexample
6779 pid_t wait (wait_status_ptr_t p)
6781   return waitpid (-1, p.__ip, 0);
6783 @end smallexample
6785 @item unused
6786 @cindex @code{unused} type attribute
6787 When attached to a type (including a @code{union} or a @code{struct}),
6788 this attribute means that variables of that type are meant to appear
6789 possibly unused.  GCC does not produce a warning for any variables of
6790 that type, even if the variable appears to do nothing.  This is often
6791 the case with lock or thread classes, which are usually defined and then
6792 not referenced, but contain constructors and destructors that have
6793 nontrivial bookkeeping functions.
6795 @item visibility
6796 @cindex @code{visibility} type attribute
6797 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6798 applied to class, struct, union and enum types.  Unlike other type
6799 attributes, the attribute must appear between the initial keyword and
6800 the name of the type; it cannot appear after the body of the type.
6802 Note that the type visibility is applied to vague linkage entities
6803 associated with the class (vtable, typeinfo node, etc.).  In
6804 particular, if a class is thrown as an exception in one shared object
6805 and caught in another, the class must have default visibility.
6806 Otherwise the two shared objects are unable to use the same
6807 typeinfo node and exception handling will break.
6809 @end table
6811 To specify multiple attributes, separate them by commas within the
6812 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6813 packed))}.
6815 @node ARM Type Attributes
6816 @subsection ARM Type Attributes
6818 @cindex @code{notshared} type attribute, ARM
6819 On those ARM targets that support @code{dllimport} (such as Symbian
6820 OS), you can use the @code{notshared} attribute to indicate that the
6821 virtual table and other similar data for a class should not be
6822 exported from a DLL@.  For example:
6824 @smallexample
6825 class __declspec(notshared) C @{
6826 public:
6827   __declspec(dllimport) C();
6828   virtual void f();
6831 __declspec(dllexport)
6832 C::C() @{@}
6833 @end smallexample
6835 @noindent
6836 In this code, @code{C::C} is exported from the current DLL, but the
6837 virtual table for @code{C} is not exported.  (You can use
6838 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6839 most Symbian OS code uses @code{__declspec}.)
6841 @node MeP Type Attributes
6842 @subsection MeP Type Attributes
6844 @cindex @code{based} type attribute, MeP
6845 @cindex @code{tiny} type attribute, MeP
6846 @cindex @code{near} type attribute, MeP
6847 @cindex @code{far} type attribute, MeP
6848 Many of the MeP variable attributes may be applied to types as well.
6849 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6850 @code{far} attributes may be applied to either.  The @code{io} and
6851 @code{cb} attributes may not be applied to types.
6853 @node PowerPC Type Attributes
6854 @subsection PowerPC Type Attributes
6856 Three attributes currently are defined for PowerPC configurations:
6857 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6859 @cindex @code{ms_struct} type attribute, PowerPC
6860 @cindex @code{gcc_struct} type attribute, PowerPC
6861 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6862 attributes please see the documentation in @ref{x86 Type Attributes}.
6864 @cindex @code{altivec} type attribute, PowerPC
6865 The @code{altivec} attribute allows one to declare AltiVec vector data
6866 types supported by the AltiVec Programming Interface Manual.  The
6867 attribute requires an argument to specify one of three vector types:
6868 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6869 and @code{bool__} (always followed by unsigned).
6871 @smallexample
6872 __attribute__((altivec(vector__)))
6873 __attribute__((altivec(pixel__))) unsigned short
6874 __attribute__((altivec(bool__))) unsigned
6875 @end smallexample
6877 These attributes mainly are intended to support the @code{__vector},
6878 @code{__pixel}, and @code{__bool} AltiVec keywords.
6880 @node SPU Type Attributes
6881 @subsection SPU Type Attributes
6883 @cindex @code{spu_vector} type attribute, SPU
6884 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6885 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6886 Language Extensions Specification.  It is intended to support the
6887 @code{__vector} keyword.
6889 @node x86 Type Attributes
6890 @subsection x86 Type Attributes
6892 Two attributes are currently defined for x86 configurations:
6893 @code{ms_struct} and @code{gcc_struct}.
6895 @table @code
6897 @item ms_struct
6898 @itemx gcc_struct
6899 @cindex @code{ms_struct} type attribute, x86
6900 @cindex @code{gcc_struct} type attribute, x86
6902 If @code{packed} is used on a structure, or if bit-fields are used
6903 it may be that the Microsoft ABI packs them differently
6904 than GCC normally packs them.  Particularly when moving packed
6905 data between functions compiled with GCC and the native Microsoft compiler
6906 (either via function call or as data in a file), it may be necessary to access
6907 either format.
6909 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6910 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6911 command-line options, respectively;
6912 see @ref{x86 Options}, for details of how structure layout is affected.
6913 @xref{x86 Variable Attributes}, for information about the corresponding
6914 attributes on variables.
6916 @end table
6918 @node Label Attributes
6919 @section Label Attributes
6920 @cindex Label Attributes
6922 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
6923 details of the exact syntax for using attributes.  Other attributes are 
6924 available for functions (@pxref{Function Attributes}), variables 
6925 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6926 statements (@pxref{Statement Attributes}), and for types
6927 (@pxref{Type Attributes}).
6929 This example uses the @code{cold} label attribute to indicate the 
6930 @code{ErrorHandling} branch is unlikely to be taken and that the
6931 @code{ErrorHandling} label is unused:
6933 @smallexample
6935    asm goto ("some asm" : : : : NoError);
6937 /* This branch (the fall-through from the asm) is less commonly used */
6938 ErrorHandling: 
6939    __attribute__((cold, unused)); /* Semi-colon is required here */
6940    printf("error\n");
6941    return 0;
6943 NoError:
6944    printf("no error\n");
6945    return 1;
6946 @end smallexample
6948 @table @code
6949 @item unused
6950 @cindex @code{unused} label attribute
6951 This feature is intended for program-generated code that may contain 
6952 unused labels, but which is compiled with @option{-Wall}.  It is
6953 not normally appropriate to use in it human-written code, though it
6954 could be useful in cases where the code that jumps to the label is
6955 contained within an @code{#ifdef} conditional.
6957 @item hot
6958 @cindex @code{hot} label attribute
6959 The @code{hot} attribute on a label is used to inform the compiler that
6960 the path following the label is more likely than paths that are not so
6961 annotated.  This attribute is used in cases where @code{__builtin_expect}
6962 cannot be used, for instance with computed goto or @code{asm goto}.
6964 @item cold
6965 @cindex @code{cold} label attribute
6966 The @code{cold} attribute on labels is used to inform the compiler that
6967 the path following the label is unlikely to be executed.  This attribute
6968 is used in cases where @code{__builtin_expect} cannot be used, for instance
6969 with computed goto or @code{asm goto}.
6971 @end table
6973 @node Enumerator Attributes
6974 @section Enumerator Attributes
6975 @cindex Enumerator Attributes
6977 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
6978 details of the exact syntax for using attributes.  Other attributes are
6979 available for functions (@pxref{Function Attributes}), variables
6980 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
6981 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6983 This example uses the @code{deprecated} enumerator attribute to indicate the
6984 @code{oldval} enumerator is deprecated:
6986 @smallexample
6987 enum E @{
6988   oldval __attribute__((deprecated)),
6989   newval
6993 fn (void)
6995   return oldval;
6997 @end smallexample
6999 @table @code
7000 @item deprecated
7001 @cindex @code{deprecated} enumerator attribute
7002 The @code{deprecated} attribute results in a warning if the enumerator
7003 is used anywhere in the source file.  This is useful when identifying
7004 enumerators that are expected to be removed in a future version of a
7005 program.  The warning also includes the location of the declaration
7006 of the deprecated enumerator, to enable users to easily find further
7007 information about why the enumerator is deprecated, or what they should
7008 do instead.  Note that the warnings only occurs for uses.
7010 @end table
7012 @node Statement Attributes
7013 @section Statement Attributes
7014 @cindex Statement Attributes
7016 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7017 for details of the exact syntax for using attributes.  Other attributes are
7018 available for functions (@pxref{Function Attributes}), variables
7019 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7020 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7022 This example uses the @code{fallthrough} statement attribute to indicate that
7023 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7025 @smallexample
7026 switch (cond)
7027   @{
7028   case 1:
7029     bar (1);
7030     __attribute__((fallthrough));
7031   case 2:
7032     @dots{}
7033   @}
7034 @end smallexample
7036 @table @code
7037 @item fallthrough
7038 @cindex @code{fallthrough} statement attribute
7039 The @code{fallthrough} attribute with a null statement serves as a
7040 fallthrough statement.  It hints to the compiler that a statement
7041 that falls through to another case label, or user-defined label
7042 in a switch statement is intentional and thus the
7043 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7044 fallthrough attribute may appear at most once in each attribute
7045 list, and may not be mixed with other attributes.  It can only
7046 be used in a switch statement (the compiler will issue an error
7047 otherwise), after a preceding statement and before a logically
7048 succeeding case label, or user-defined label.
7050 @end table
7052 @node Attribute Syntax
7053 @section Attribute Syntax
7054 @cindex attribute syntax
7056 This section describes the syntax with which @code{__attribute__} may be
7057 used, and the constructs to which attribute specifiers bind, for the C
7058 language.  Some details may vary for C++ and Objective-C@.  Because of
7059 infelicities in the grammar for attributes, some forms described here
7060 may not be successfully parsed in all cases.
7062 There are some problems with the semantics of attributes in C++.  For
7063 example, there are no manglings for attributes, although they may affect
7064 code generation, so problems may arise when attributed types are used in
7065 conjunction with templates or overloading.  Similarly, @code{typeid}
7066 does not distinguish between types with different attributes.  Support
7067 for attributes in C++ may be restricted in future to attributes on
7068 declarations only, but not on nested declarators.
7070 @xref{Function Attributes}, for details of the semantics of attributes
7071 applying to functions.  @xref{Variable Attributes}, for details of the
7072 semantics of attributes applying to variables.  @xref{Type Attributes},
7073 for details of the semantics of attributes applying to structure, union
7074 and enumerated types.
7075 @xref{Label Attributes}, for details of the semantics of attributes 
7076 applying to labels.
7077 @xref{Enumerator Attributes}, for details of the semantics of attributes
7078 applying to enumerators.
7079 @xref{Statement Attributes}, for details of the semantics of attributes
7080 applying to statements.
7082 An @dfn{attribute specifier} is of the form
7083 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7084 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7085 each attribute is one of the following:
7087 @itemize @bullet
7088 @item
7089 Empty.  Empty attributes are ignored.
7091 @item
7092 An attribute name
7093 (which may be an identifier such as @code{unused}, or a reserved
7094 word such as @code{const}).
7096 @item
7097 An attribute name followed by a parenthesized list of
7098 parameters for the attribute.
7099 These parameters take one of the following forms:
7101 @itemize @bullet
7102 @item
7103 An identifier.  For example, @code{mode} attributes use this form.
7105 @item
7106 An identifier followed by a comma and a non-empty comma-separated list
7107 of expressions.  For example, @code{format} attributes use this form.
7109 @item
7110 A possibly empty comma-separated list of expressions.  For example,
7111 @code{format_arg} attributes use this form with the list being a single
7112 integer constant expression, and @code{alias} attributes use this form
7113 with the list being a single string constant.
7114 @end itemize
7115 @end itemize
7117 An @dfn{attribute specifier list} is a sequence of one or more attribute
7118 specifiers, not separated by any other tokens.
7120 You may optionally specify attribute names with @samp{__}
7121 preceding and following the name.
7122 This allows you to use them in header files without
7123 being concerned about a possible macro of the same name.  For example,
7124 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7127 @subsubheading Label Attributes
7129 In GNU C, an attribute specifier list may appear after the colon following a
7130 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7131 attributes on labels if the attribute specifier is immediately
7132 followed by a semicolon (i.e., the label applies to an empty
7133 statement).  If the semicolon is missing, C++ label attributes are
7134 ambiguous, as it is permissible for a declaration, which could begin
7135 with an attribute list, to be labelled in C++.  Declarations cannot be
7136 labelled in C90 or C99, so the ambiguity does not arise there.
7138 @subsubheading Enumerator Attributes
7140 In GNU C, an attribute specifier list may appear as part of an enumerator.
7141 The attribute goes after the enumeration constant, before @code{=}, if
7142 present.  The optional attribute in the enumerator appertains to the
7143 enumeration constant.  It is not possible to place the attribute after
7144 the constant expression, if present.
7146 @subsubheading Statement Attributes
7147 In GNU C, an attribute specifier list may appear as part of a null
7148 statement.  The attribute goes before the semicolon.
7150 @subsubheading Type Attributes
7152 An attribute specifier list may appear as part of a @code{struct},
7153 @code{union} or @code{enum} specifier.  It may go either immediately
7154 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7155 the closing brace.  The former syntax is preferred.
7156 Where attribute specifiers follow the closing brace, they are considered
7157 to relate to the structure, union or enumerated type defined, not to any
7158 enclosing declaration the type specifier appears in, and the type
7159 defined is not complete until after the attribute specifiers.
7160 @c Otherwise, there would be the following problems: a shift/reduce
7161 @c conflict between attributes binding the struct/union/enum and
7162 @c binding to the list of specifiers/qualifiers; and "aligned"
7163 @c attributes could use sizeof for the structure, but the size could be
7164 @c changed later by "packed" attributes.
7167 @subsubheading All other attributes
7169 Otherwise, an attribute specifier appears as part of a declaration,
7170 counting declarations of unnamed parameters and type names, and relates
7171 to that declaration (which may be nested in another declaration, for
7172 example in the case of a parameter declaration), or to a particular declarator
7173 within a declaration.  Where an
7174 attribute specifier is applied to a parameter declared as a function or
7175 an array, it should apply to the function or array rather than the
7176 pointer to which the parameter is implicitly converted, but this is not
7177 yet correctly implemented.
7179 Any list of specifiers and qualifiers at the start of a declaration may
7180 contain attribute specifiers, whether or not such a list may in that
7181 context contain storage class specifiers.  (Some attributes, however,
7182 are essentially in the nature of storage class specifiers, and only make
7183 sense where storage class specifiers may be used; for example,
7184 @code{section}.)  There is one necessary limitation to this syntax: the
7185 first old-style parameter declaration in a function definition cannot
7186 begin with an attribute specifier, because such an attribute applies to
7187 the function instead by syntax described below (which, however, is not
7188 yet implemented in this case).  In some other cases, attribute
7189 specifiers are permitted by this grammar but not yet supported by the
7190 compiler.  All attribute specifiers in this place relate to the
7191 declaration as a whole.  In the obsolescent usage where a type of
7192 @code{int} is implied by the absence of type specifiers, such a list of
7193 specifiers and qualifiers may be an attribute specifier list with no
7194 other specifiers or qualifiers.
7196 At present, the first parameter in a function prototype must have some
7197 type specifier that is not an attribute specifier; this resolves an
7198 ambiguity in the interpretation of @code{void f(int
7199 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7200 the parentheses of a function declarator contain only attributes then
7201 those attributes are ignored, rather than yielding an error or warning
7202 or implying a single parameter of type int, but this is subject to
7203 change.
7205 An attribute specifier list may appear immediately before a declarator
7206 (other than the first) in a comma-separated list of declarators in a
7207 declaration of more than one identifier using a single list of
7208 specifiers and qualifiers.  Such attribute specifiers apply
7209 only to the identifier before whose declarator they appear.  For
7210 example, in
7212 @smallexample
7213 __attribute__((noreturn)) void d0 (void),
7214     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7215      d2 (void);
7216 @end smallexample
7218 @noindent
7219 the @code{noreturn} attribute applies to all the functions
7220 declared; the @code{format} attribute only applies to @code{d1}.
7222 An attribute specifier list may appear immediately before the comma,
7223 @code{=} or semicolon terminating the declaration of an identifier other
7224 than a function definition.  Such attribute specifiers apply
7225 to the declared object or function.  Where an
7226 assembler name for an object or function is specified (@pxref{Asm
7227 Labels}), the attribute must follow the @code{asm}
7228 specification.
7230 An attribute specifier list may, in future, be permitted to appear after
7231 the declarator in a function definition (before any old-style parameter
7232 declarations or the function body).
7234 Attribute specifiers may be mixed with type qualifiers appearing inside
7235 the @code{[]} of a parameter array declarator, in the C99 construct by
7236 which such qualifiers are applied to the pointer to which the array is
7237 implicitly converted.  Such attribute specifiers apply to the pointer,
7238 not to the array, but at present this is not implemented and they are
7239 ignored.
7241 An attribute specifier list may appear at the start of a nested
7242 declarator.  At present, there are some limitations in this usage: the
7243 attributes correctly apply to the declarator, but for most individual
7244 attributes the semantics this implies are not implemented.
7245 When attribute specifiers follow the @code{*} of a pointer
7246 declarator, they may be mixed with any type qualifiers present.
7247 The following describes the formal semantics of this syntax.  It makes the
7248 most sense if you are familiar with the formal specification of
7249 declarators in the ISO C standard.
7251 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7252 D1}, where @code{T} contains declaration specifiers that specify a type
7253 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7254 contains an identifier @var{ident}.  The type specified for @var{ident}
7255 for derived declarators whose type does not include an attribute
7256 specifier is as in the ISO C standard.
7258 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7259 and the declaration @code{T D} specifies the type
7260 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7261 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7262 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7264 If @code{D1} has the form @code{*
7265 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7266 declaration @code{T D} specifies the type
7267 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7268 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7269 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7270 @var{ident}.
7272 For example,
7274 @smallexample
7275 void (__attribute__((noreturn)) ****f) (void);
7276 @end smallexample
7278 @noindent
7279 specifies the type ``pointer to pointer to pointer to pointer to
7280 non-returning function returning @code{void}''.  As another example,
7282 @smallexample
7283 char *__attribute__((aligned(8))) *f;
7284 @end smallexample
7286 @noindent
7287 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7288 Note again that this does not work with most attributes; for example,
7289 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7290 is not yet supported.
7292 For compatibility with existing code written for compiler versions that
7293 did not implement attributes on nested declarators, some laxity is
7294 allowed in the placing of attributes.  If an attribute that only applies
7295 to types is applied to a declaration, it is treated as applying to
7296 the type of that declaration.  If an attribute that only applies to
7297 declarations is applied to the type of a declaration, it is treated
7298 as applying to that declaration; and, for compatibility with code
7299 placing the attributes immediately before the identifier declared, such
7300 an attribute applied to a function return type is treated as
7301 applying to the function type, and such an attribute applied to an array
7302 element type is treated as applying to the array type.  If an
7303 attribute that only applies to function types is applied to a
7304 pointer-to-function type, it is treated as applying to the pointer
7305 target type; if such an attribute is applied to a function return type
7306 that is not a pointer-to-function type, it is treated as applying
7307 to the function type.
7309 @node Function Prototypes
7310 @section Prototypes and Old-Style Function Definitions
7311 @cindex function prototype declarations
7312 @cindex old-style function definitions
7313 @cindex promotion of formal parameters
7315 GNU C extends ISO C to allow a function prototype to override a later
7316 old-style non-prototype definition.  Consider the following example:
7318 @smallexample
7319 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7320 #ifdef __STDC__
7321 #define P(x) x
7322 #else
7323 #define P(x) ()
7324 #endif
7326 /* @r{Prototype function declaration.}  */
7327 int isroot P((uid_t));
7329 /* @r{Old-style function definition.}  */
7331 isroot (x)   /* @r{??? lossage here ???} */
7332      uid_t x;
7334   return x == 0;
7336 @end smallexample
7338 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7339 not allow this example, because subword arguments in old-style
7340 non-prototype definitions are promoted.  Therefore in this example the
7341 function definition's argument is really an @code{int}, which does not
7342 match the prototype argument type of @code{short}.
7344 This restriction of ISO C makes it hard to write code that is portable
7345 to traditional C compilers, because the programmer does not know
7346 whether the @code{uid_t} type is @code{short}, @code{int}, or
7347 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7348 to override a later old-style definition.  More precisely, in GNU C, a
7349 function prototype argument type overrides the argument type specified
7350 by a later old-style definition if the former type is the same as the
7351 latter type before promotion.  Thus in GNU C the above example is
7352 equivalent to the following:
7354 @smallexample
7355 int isroot (uid_t);
7358 isroot (uid_t x)
7360   return x == 0;
7362 @end smallexample
7364 @noindent
7365 GNU C++ does not support old-style function definitions, so this
7366 extension is irrelevant.
7368 @node C++ Comments
7369 @section C++ Style Comments
7370 @cindex @code{//}
7371 @cindex C++ comments
7372 @cindex comments, C++ style
7374 In GNU C, you may use C++ style comments, which start with @samp{//} and
7375 continue until the end of the line.  Many other C implementations allow
7376 such comments, and they are included in the 1999 C standard.  However,
7377 C++ style comments are not recognized if you specify an @option{-std}
7378 option specifying a version of ISO C before C99, or @option{-ansi}
7379 (equivalent to @option{-std=c90}).
7381 @node Dollar Signs
7382 @section Dollar Signs in Identifier Names
7383 @cindex $
7384 @cindex dollar signs in identifier names
7385 @cindex identifier names, dollar signs in
7387 In GNU C, you may normally use dollar signs in identifier names.
7388 This is because many traditional C implementations allow such identifiers.
7389 However, dollar signs in identifiers are not supported on a few target
7390 machines, typically because the target assembler does not allow them.
7392 @node Character Escapes
7393 @section The Character @key{ESC} in Constants
7395 You can use the sequence @samp{\e} in a string or character constant to
7396 stand for the ASCII character @key{ESC}.
7398 @node Alignment
7399 @section Inquiring on Alignment of Types or Variables
7400 @cindex alignment
7401 @cindex type alignment
7402 @cindex variable alignment
7404 The keyword @code{__alignof__} allows you to inquire about how an object
7405 is aligned, or the minimum alignment usually required by a type.  Its
7406 syntax is just like @code{sizeof}.
7408 For example, if the target machine requires a @code{double} value to be
7409 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7410 This is true on many RISC machines.  On more traditional machine
7411 designs, @code{__alignof__ (double)} is 4 or even 2.
7413 Some machines never actually require alignment; they allow reference to any
7414 data type even at an odd address.  For these machines, @code{__alignof__}
7415 reports the smallest alignment that GCC gives the data type, usually as
7416 mandated by the target ABI.
7418 If the operand of @code{__alignof__} is an lvalue rather than a type,
7419 its value is the required alignment for its type, taking into account
7420 any minimum alignment specified with GCC's @code{__attribute__}
7421 extension (@pxref{Variable Attributes}).  For example, after this
7422 declaration:
7424 @smallexample
7425 struct foo @{ int x; char y; @} foo1;
7426 @end smallexample
7428 @noindent
7429 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7430 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7432 It is an error to ask for the alignment of an incomplete type.
7435 @node Inline
7436 @section An Inline Function is As Fast As a Macro
7437 @cindex inline functions
7438 @cindex integrating function code
7439 @cindex open coding
7440 @cindex macros, inline alternative
7442 By declaring a function inline, you can direct GCC to make
7443 calls to that function faster.  One way GCC can achieve this is to
7444 integrate that function's code into the code for its callers.  This
7445 makes execution faster by eliminating the function-call overhead; in
7446 addition, if any of the actual argument values are constant, their
7447 known values may permit simplifications at compile time so that not
7448 all of the inline function's code needs to be included.  The effect on
7449 code size is less predictable; object code may be larger or smaller
7450 with function inlining, depending on the particular case.  You can
7451 also direct GCC to try to integrate all ``simple enough'' functions
7452 into their callers with the option @option{-finline-functions}.
7454 GCC implements three different semantics of declaring a function
7455 inline.  One is available with @option{-std=gnu89} or
7456 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7457 on all inline declarations, another when
7458 @option{-std=c99}, @option{-std=c11},
7459 @option{-std=gnu99} or @option{-std=gnu11}
7460 (without @option{-fgnu89-inline}), and the third
7461 is used when compiling C++.
7463 To declare a function inline, use the @code{inline} keyword in its
7464 declaration, like this:
7466 @smallexample
7467 static inline int
7468 inc (int *a)
7470   return (*a)++;
7472 @end smallexample
7474 If you are writing a header file to be included in ISO C90 programs, write
7475 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7477 The three types of inlining behave similarly in two important cases:
7478 when the @code{inline} keyword is used on a @code{static} function,
7479 like the example above, and when a function is first declared without
7480 using the @code{inline} keyword and then is defined with
7481 @code{inline}, like this:
7483 @smallexample
7484 extern int inc (int *a);
7485 inline int
7486 inc (int *a)
7488   return (*a)++;
7490 @end smallexample
7492 In both of these common cases, the program behaves the same as if you
7493 had not used the @code{inline} keyword, except for its speed.
7495 @cindex inline functions, omission of
7496 @opindex fkeep-inline-functions
7497 When a function is both inline and @code{static}, if all calls to the
7498 function are integrated into the caller, and the function's address is
7499 never used, then the function's own assembler code is never referenced.
7500 In this case, GCC does not actually output assembler code for the
7501 function, unless you specify the option @option{-fkeep-inline-functions}.
7502 If there is a nonintegrated call, then the function is compiled to
7503 assembler code as usual.  The function must also be compiled as usual if
7504 the program refers to its address, because that can't be inlined.
7506 @opindex Winline
7507 Note that certain usages in a function definition can make it unsuitable
7508 for inline substitution.  Among these usages are: variadic functions,
7509 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7510 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7511 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7512 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7513 function marked @code{inline} could not be substituted, and gives the
7514 reason for the failure.
7516 @cindex automatic @code{inline} for C++ member fns
7517 @cindex @code{inline} automatic for C++ member fns
7518 @cindex member fns, automatically @code{inline}
7519 @cindex C++ member fns, automatically @code{inline}
7520 @opindex fno-default-inline
7521 As required by ISO C++, GCC considers member functions defined within
7522 the body of a class to be marked inline even if they are
7523 not explicitly declared with the @code{inline} keyword.  You can
7524 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7525 Options,,Options Controlling C++ Dialect}.
7527 GCC does not inline any functions when not optimizing unless you specify
7528 the @samp{always_inline} attribute for the function, like this:
7530 @smallexample
7531 /* @r{Prototype.}  */
7532 inline void foo (const char) __attribute__((always_inline));
7533 @end smallexample
7535 The remainder of this section is specific to GNU C90 inlining.
7537 @cindex non-static inline function
7538 When an inline function is not @code{static}, then the compiler must assume
7539 that there may be calls from other source files; since a global symbol can
7540 be defined only once in any program, the function must not be defined in
7541 the other source files, so the calls therein cannot be integrated.
7542 Therefore, a non-@code{static} inline function is always compiled on its
7543 own in the usual fashion.
7545 If you specify both @code{inline} and @code{extern} in the function
7546 definition, then the definition is used only for inlining.  In no case
7547 is the function compiled on its own, not even if you refer to its
7548 address explicitly.  Such an address becomes an external reference, as
7549 if you had only declared the function, and had not defined it.
7551 This combination of @code{inline} and @code{extern} has almost the
7552 effect of a macro.  The way to use it is to put a function definition in
7553 a header file with these keywords, and put another copy of the
7554 definition (lacking @code{inline} and @code{extern}) in a library file.
7555 The definition in the header file causes most calls to the function
7556 to be inlined.  If any uses of the function remain, they refer to
7557 the single copy in the library.
7559 @node Volatiles
7560 @section When is a Volatile Object Accessed?
7561 @cindex accessing volatiles
7562 @cindex volatile read
7563 @cindex volatile write
7564 @cindex volatile access
7566 C has the concept of volatile objects.  These are normally accessed by
7567 pointers and used for accessing hardware or inter-thread
7568 communication.  The standard encourages compilers to refrain from
7569 optimizations concerning accesses to volatile objects, but leaves it
7570 implementation defined as to what constitutes a volatile access.  The
7571 minimum requirement is that at a sequence point all previous accesses
7572 to volatile objects have stabilized and no subsequent accesses have
7573 occurred.  Thus an implementation is free to reorder and combine
7574 volatile accesses that occur between sequence points, but cannot do
7575 so for accesses across a sequence point.  The use of volatile does
7576 not allow you to violate the restriction on updating objects multiple
7577 times between two sequence points.
7579 Accesses to non-volatile objects are not ordered with respect to
7580 volatile accesses.  You cannot use a volatile object as a memory
7581 barrier to order a sequence of writes to non-volatile memory.  For
7582 instance:
7584 @smallexample
7585 int *ptr = @var{something};
7586 volatile int vobj;
7587 *ptr = @var{something};
7588 vobj = 1;
7589 @end smallexample
7591 @noindent
7592 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7593 that the write to @var{*ptr} occurs by the time the update
7594 of @var{vobj} happens.  If you need this guarantee, you must use
7595 a stronger memory barrier such as:
7597 @smallexample
7598 int *ptr = @var{something};
7599 volatile int vobj;
7600 *ptr = @var{something};
7601 asm volatile ("" : : : "memory");
7602 vobj = 1;
7603 @end smallexample
7605 A scalar volatile object is read when it is accessed in a void context:
7607 @smallexample
7608 volatile int *src = @var{somevalue};
7609 *src;
7610 @end smallexample
7612 Such expressions are rvalues, and GCC implements this as a
7613 read of the volatile object being pointed to.
7615 Assignments are also expressions and have an rvalue.  However when
7616 assigning to a scalar volatile, the volatile object is not reread,
7617 regardless of whether the assignment expression's rvalue is used or
7618 not.  If the assignment's rvalue is used, the value is that assigned
7619 to the volatile object.  For instance, there is no read of @var{vobj}
7620 in all the following cases:
7622 @smallexample
7623 int obj;
7624 volatile int vobj;
7625 vobj = @var{something};
7626 obj = vobj = @var{something};
7627 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7628 obj = (@var{something}, vobj = @var{anotherthing});
7629 @end smallexample
7631 If you need to read the volatile object after an assignment has
7632 occurred, you must use a separate expression with an intervening
7633 sequence point.
7635 As bit-fields are not individually addressable, volatile bit-fields may
7636 be implicitly read when written to, or when adjacent bit-fields are
7637 accessed.  Bit-field operations may be optimized such that adjacent
7638 bit-fields are only partially accessed, if they straddle a storage unit
7639 boundary.  For these reasons it is unwise to use volatile bit-fields to
7640 access hardware.
7642 @node Using Assembly Language with C
7643 @section How to Use Inline Assembly Language in C Code
7644 @cindex @code{asm} keyword
7645 @cindex assembly language in C
7646 @cindex inline assembly language
7647 @cindex mixing assembly language and C
7649 The @code{asm} keyword allows you to embed assembler instructions
7650 within C code.  GCC provides two forms of inline @code{asm}
7651 statements.  A @dfn{basic @code{asm}} statement is one with no
7652 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7653 statement (@pxref{Extended Asm}) includes one or more operands.  
7654 The extended form is preferred for mixing C and assembly language
7655 within a function, but to include assembly language at
7656 top level you must use basic @code{asm}.
7658 You can also use the @code{asm} keyword to override the assembler name
7659 for a C symbol, or to place a C variable in a specific register.
7661 @menu
7662 * Basic Asm::          Inline assembler without operands.
7663 * Extended Asm::       Inline assembler with operands.
7664 * Constraints::        Constraints for @code{asm} operands
7665 * Asm Labels::         Specifying the assembler name to use for a C symbol.
7666 * Explicit Register Variables::  Defining variables residing in specified 
7667                        registers.
7668 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
7669 @end menu
7671 @node Basic Asm
7672 @subsection Basic Asm --- Assembler Instructions Without Operands
7673 @cindex basic @code{asm}
7674 @cindex assembly language in C, basic
7676 A basic @code{asm} statement has the following syntax:
7678 @example
7679 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7680 @end example
7682 The @code{asm} keyword is a GNU extension.
7683 When writing code that can be compiled with @option{-ansi} and the
7684 various @option{-std} options, use @code{__asm__} instead of 
7685 @code{asm} (@pxref{Alternate Keywords}).
7687 @subsubheading Qualifiers
7688 @table @code
7689 @item volatile
7690 The optional @code{volatile} qualifier has no effect. 
7691 All basic @code{asm} blocks are implicitly volatile.
7692 @end table
7694 @subsubheading Parameters
7695 @table @var
7697 @item AssemblerInstructions
7698 This is a literal string that specifies the assembler code. The string can 
7699 contain any instructions recognized by the assembler, including directives. 
7700 GCC does not parse the assembler instructions themselves and 
7701 does not know what they mean or even whether they are valid assembler input. 
7703 You may place multiple assembler instructions together in a single @code{asm} 
7704 string, separated by the characters normally used in assembly code for the 
7705 system. A combination that works in most places is a newline to break the 
7706 line, plus a tab character (written as @samp{\n\t}).
7707 Some assemblers allow semicolons as a line separator. However, 
7708 note that some assembler dialects use semicolons to start a comment. 
7709 @end table
7711 @subsubheading Remarks
7712 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7713 smaller, safer, and more efficient code, and in most cases it is a
7714 better solution than basic @code{asm}.  However, there are two
7715 situations where only basic @code{asm} can be used:
7717 @itemize @bullet
7718 @item
7719 Extended @code{asm} statements have to be inside a C
7720 function, so to write inline assembly language at file scope (``top-level''),
7721 outside of C functions, you must use basic @code{asm}.
7722 You can use this technique to emit assembler directives,
7723 define assembly language macros that can be invoked elsewhere in the file,
7724 or write entire functions in assembly language.
7726 @item
7727 Functions declared
7728 with the @code{naked} attribute also require basic @code{asm}
7729 (@pxref{Function Attributes}).
7730 @end itemize
7732 Safely accessing C data and calling functions from basic @code{asm} is more 
7733 complex than it may appear. To access C data, it is better to use extended 
7734 @code{asm}.
7736 Do not expect a sequence of @code{asm} statements to remain perfectly 
7737 consecutive after compilation. If certain instructions need to remain 
7738 consecutive in the output, put them in a single multi-instruction @code{asm}
7739 statement. Note that GCC's optimizers can move @code{asm} statements 
7740 relative to other code, including across jumps.
7742 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7743 GCC does not know about these jumps, and therefore cannot take 
7744 account of them when deciding how to optimize. Jumps from @code{asm} to C 
7745 labels are only supported in extended @code{asm}.
7747 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
7748 assembly code when optimizing. This can lead to unexpected duplicate 
7749 symbol errors during compilation if your assembly code defines symbols or 
7750 labels.
7752 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7753 making it a potential source of incompatibilities between compilers.  These
7754 incompatibilities may not produce compiler warnings/errors.
7756 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7757 means there is no way to communicate to the compiler what is happening
7758 inside them.  GCC has no visibility of symbols in the @code{asm} and may
7759 discard them as unreferenced.  It also does not know about side effects of
7760 the assembler code, such as modifications to memory or registers.  Unlike
7761 some compilers, GCC assumes that no changes to general purpose registers
7762 occur.  This assumption may change in a future release.
7764 To avoid complications from future changes to the semantics and the
7765 compatibility issues between compilers, consider replacing basic @code{asm}
7766 with extended @code{asm}.  See
7767 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7768 from basic asm to extended asm} for information about how to perform this
7769 conversion.
7771 The compiler copies the assembler instructions in a basic @code{asm} 
7772 verbatim to the assembly language output file, without 
7773 processing dialects or any of the @samp{%} operators that are available with
7774 extended @code{asm}. This results in minor differences between basic 
7775 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
7776 registers you might use @samp{%eax} in basic @code{asm} and
7777 @samp{%%eax} in extended @code{asm}.
7779 On targets such as x86 that support multiple assembler dialects,
7780 all basic @code{asm} blocks use the assembler dialect specified by the 
7781 @option{-masm} command-line option (@pxref{x86 Options}).  
7782 Basic @code{asm} provides no
7783 mechanism to provide different assembler strings for different dialects.
7785 For basic @code{asm} with non-empty assembler string GCC assumes
7786 the assembler block does not change any general purpose registers,
7787 but it may read or write any globally accessible variable.
7789 Here is an example of basic @code{asm} for i386:
7791 @example
7792 /* Note that this code will not compile with -masm=intel */
7793 #define DebugBreak() asm("int $3")
7794 @end example
7796 @node Extended Asm
7797 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7798 @cindex extended @code{asm}
7799 @cindex assembly language in C, extended
7801 With extended @code{asm} you can read and write C variables from 
7802 assembler and perform jumps from assembler code to C labels.  
7803 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7804 the operand parameters after the assembler template:
7806 @example
7807 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
7808                  : @var{OutputOperands} 
7809                  @r{[} : @var{InputOperands}
7810                  @r{[} : @var{Clobbers} @r{]} @r{]})
7812 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
7813                       : 
7814                       : @var{InputOperands}
7815                       : @var{Clobbers}
7816                       : @var{GotoLabels})
7817 @end example
7819 The @code{asm} keyword is a GNU extension.
7820 When writing code that can be compiled with @option{-ansi} and the
7821 various @option{-std} options, use @code{__asm__} instead of 
7822 @code{asm} (@pxref{Alternate Keywords}).
7824 @subsubheading Qualifiers
7825 @table @code
7827 @item volatile
7828 The typical use of extended @code{asm} statements is to manipulate input 
7829 values to produce output values. However, your @code{asm} statements may 
7830 also produce side effects. If so, you may need to use the @code{volatile} 
7831 qualifier to disable certain optimizations. @xref{Volatile}.
7833 @item goto
7834 This qualifier informs the compiler that the @code{asm} statement may 
7835 perform a jump to one of the labels listed in the @var{GotoLabels}.
7836 @xref{GotoLabels}.
7837 @end table
7839 @subsubheading Parameters
7840 @table @var
7841 @item AssemblerTemplate
7842 This is a literal string that is the template for the assembler code. It is a 
7843 combination of fixed text and tokens that refer to the input, output, 
7844 and goto parameters. @xref{AssemblerTemplate}.
7846 @item OutputOperands
7847 A comma-separated list of the C variables modified by the instructions in the 
7848 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
7850 @item InputOperands
7851 A comma-separated list of C expressions read by the instructions in the 
7852 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
7854 @item Clobbers
7855 A comma-separated list of registers or other values changed by the 
7856 @var{AssemblerTemplate}, beyond those listed as outputs.
7857 An empty list is permitted.  @xref{Clobbers}.
7859 @item GotoLabels
7860 When you are using the @code{goto} form of @code{asm}, this section contains 
7861 the list of all C labels to which the code in the 
7862 @var{AssemblerTemplate} may jump. 
7863 @xref{GotoLabels}.
7865 @code{asm} statements may not perform jumps into other @code{asm} statements,
7866 only to the listed @var{GotoLabels}.
7867 GCC's optimizers do not know about other jumps; therefore they cannot take 
7868 account of them when deciding how to optimize.
7869 @end table
7871 The total number of input + output + goto operands is limited to 30.
7873 @subsubheading Remarks
7874 The @code{asm} statement allows you to include assembly instructions directly 
7875 within C code. This may help you to maximize performance in time-sensitive 
7876 code or to access assembly instructions that are not readily available to C 
7877 programs.
7879 Note that extended @code{asm} statements must be inside a function. Only 
7880 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7881 Functions declared with the @code{naked} attribute also require basic 
7882 @code{asm} (@pxref{Function Attributes}).
7884 While the uses of @code{asm} are many and varied, it may help to think of an 
7885 @code{asm} statement as a series of low-level instructions that convert input 
7886 parameters to output parameters. So a simple (if not particularly useful) 
7887 example for i386 using @code{asm} might look like this:
7889 @example
7890 int src = 1;
7891 int dst;   
7893 asm ("mov %1, %0\n\t"
7894     "add $1, %0"
7895     : "=r" (dst) 
7896     : "r" (src));
7898 printf("%d\n", dst);
7899 @end example
7901 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7903 @anchor{Volatile}
7904 @subsubsection Volatile
7905 @cindex volatile @code{asm}
7906 @cindex @code{asm} volatile
7908 GCC's optimizers sometimes discard @code{asm} statements if they determine 
7909 there is no need for the output variables. Also, the optimizers may move 
7910 code out of loops if they believe that the code will always return the same 
7911 result (i.e. none of its input values change between calls). Using the 
7912 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
7913 that have no output operands, including @code{asm goto} statements, 
7914 are implicitly volatile.
7916 This i386 code demonstrates a case that does not use (or require) the 
7917 @code{volatile} qualifier. If it is performing assertion checking, this code 
7918 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
7919 unreferenced by any code. As a result, the optimizers can discard the 
7920 @code{asm} statement, which in turn removes the need for the entire 
7921 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
7922 isn't needed you allow the optimizers to produce the most efficient code 
7923 possible.
7925 @example
7926 void DoCheck(uint32_t dwSomeValue)
7928    uint32_t dwRes;
7930    // Assumes dwSomeValue is not zero.
7931    asm ("bsfl %1,%0"
7932      : "=r" (dwRes)
7933      : "r" (dwSomeValue)
7934      : "cc");
7936    assert(dwRes > 3);
7938 @end example
7940 The next example shows a case where the optimizers can recognize that the input 
7941 (@code{dwSomeValue}) never changes during the execution of the function and can 
7942 therefore move the @code{asm} outside the loop to produce more efficient code. 
7943 Again, using @code{volatile} disables this type of optimization.
7945 @example
7946 void do_print(uint32_t dwSomeValue)
7948    uint32_t dwRes;
7950    for (uint32_t x=0; x < 5; x++)
7951    @{
7952       // Assumes dwSomeValue is not zero.
7953       asm ("bsfl %1,%0"
7954         : "=r" (dwRes)
7955         : "r" (dwSomeValue)
7956         : "cc");
7958       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7959    @}
7961 @end example
7963 The following example demonstrates a case where you need to use the 
7964 @code{volatile} qualifier. 
7965 It uses the x86 @code{rdtsc} instruction, which reads 
7966 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
7967 the optimizers might assume that the @code{asm} block will always return the 
7968 same value and therefore optimize away the second call.
7970 @example
7971 uint64_t msr;
7973 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7974         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7975         "or %%rdx, %0"        // 'Or' in the lower bits.
7976         : "=a" (msr)
7977         : 
7978         : "rdx");
7980 printf("msr: %llx\n", msr);
7982 // Do other work...
7984 // Reprint the timestamp
7985 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
7986         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
7987         "or %%rdx, %0"        // 'Or' in the lower bits.
7988         : "=a" (msr)
7989         : 
7990         : "rdx");
7992 printf("msr: %llx\n", msr);
7993 @end example
7995 GCC's optimizers do not treat this code like the non-volatile code in the 
7996 earlier examples. They do not move it out of loops or omit it on the 
7997 assumption that the result from a previous call is still valid.
7999 Note that the compiler can move even volatile @code{asm} instructions relative 
8000 to other code, including across jump instructions. For example, on many 
8001 targets there is a system register that controls the rounding mode of 
8002 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8003 following PowerPC example, does not work reliably.
8005 @example
8006 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8007 sum = x + y;
8008 @end example
8010 The compiler may move the addition back before the volatile @code{asm}. To 
8011 make it work as expected, add an artificial dependency to the @code{asm} by 
8012 referencing a variable in the subsequent code, for example: 
8014 @example
8015 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8016 sum = x + y;
8017 @end example
8019 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8020 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8021 errors during compilation if your asm code defines symbols or labels. 
8022 Using @samp{%=} 
8023 (@pxref{AssemblerTemplate}) may help resolve this problem.
8025 @anchor{AssemblerTemplate}
8026 @subsubsection Assembler Template
8027 @cindex @code{asm} assembler template
8029 An assembler template is a literal string containing assembler instructions.
8030 The compiler replaces tokens in the template that refer 
8031 to inputs, outputs, and goto labels,
8032 and then outputs the resulting string to the assembler. The 
8033 string can contain any instructions recognized by the assembler, including 
8034 directives. GCC does not parse the assembler instructions 
8035 themselves and does not know what they mean or even whether they are valid 
8036 assembler input. However, it does count the statements 
8037 (@pxref{Size of an asm}).
8039 You may place multiple assembler instructions together in a single @code{asm} 
8040 string, separated by the characters normally used in assembly code for the 
8041 system. A combination that works in most places is a newline to break the 
8042 line, plus a tab character to move to the instruction field (written as 
8043 @samp{\n\t}). 
8044 Some assemblers allow semicolons as a line separator. However, note 
8045 that some assembler dialects use semicolons to start a comment. 
8047 Do not expect a sequence of @code{asm} statements to remain perfectly 
8048 consecutive after compilation, even when you are using the @code{volatile} 
8049 qualifier. If certain instructions need to remain consecutive in the output, 
8050 put them in a single multi-instruction asm statement.
8052 Accessing data from C programs without using input/output operands (such as 
8053 by using global symbols directly from the assembler template) may not work as 
8054 expected. Similarly, calling functions directly from an assembler template 
8055 requires a detailed understanding of the target assembler and ABI.
8057 Since GCC does not parse the assembler template,
8058 it has no visibility of any 
8059 symbols it references. This may result in GCC discarding those symbols as 
8060 unreferenced unless they are also listed as input, output, or goto operands.
8062 @subsubheading Special format strings
8064 In addition to the tokens described by the input, output, and goto operands, 
8065 these tokens have special meanings in the assembler template:
8067 @table @samp
8068 @item %% 
8069 Outputs a single @samp{%} into the assembler code.
8071 @item %= 
8072 Outputs a number that is unique to each instance of the @code{asm} 
8073 statement in the entire compilation. This option is useful when creating local 
8074 labels and referring to them multiple times in a single template that 
8075 generates multiple assembler instructions. 
8077 @item %@{
8078 @itemx %|
8079 @itemx %@}
8080 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8081 into the assembler code.  When unescaped, these characters have special
8082 meaning to indicate multiple assembler dialects, as described below.
8083 @end table
8085 @subsubheading Multiple assembler dialects in @code{asm} templates
8087 On targets such as x86, GCC supports multiple assembler dialects.
8088 The @option{-masm} option controls which dialect GCC uses as its 
8089 default for inline assembler. The target-specific documentation for the 
8090 @option{-masm} option contains the list of supported dialects, as well as the 
8091 default dialect if the option is not specified. This information may be 
8092 important to understand, since assembler code that works correctly when 
8093 compiled using one dialect will likely fail if compiled using another.
8094 @xref{x86 Options}.
8096 If your code needs to support multiple assembler dialects (for example, if 
8097 you are writing public headers that need to support a variety of compilation 
8098 options), use constructs of this form:
8100 @example
8101 @{ dialect0 | dialect1 | dialect2... @}
8102 @end example
8104 This construct outputs @code{dialect0} 
8105 when using dialect #0 to compile the code, 
8106 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8107 braces than the number of dialects the compiler supports, the construct 
8108 outputs nothing.
8110 For example, if an x86 compiler supports two dialects
8111 (@samp{att}, @samp{intel}), an 
8112 assembler template such as this:
8114 @example
8115 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8116 @end example
8118 @noindent
8119 is equivalent to one of
8121 @example
8122 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8123 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8124 @end example
8126 Using that same compiler, this code:
8128 @example
8129 "xchg@{l@}\t@{%%@}ebx, %1"
8130 @end example
8132 @noindent
8133 corresponds to either
8135 @example
8136 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8137 "xchg\tebx, %1"                    @r{/* intel dialect */}
8138 @end example
8140 There is no support for nesting dialect alternatives.
8142 @anchor{OutputOperands}
8143 @subsubsection Output Operands
8144 @cindex @code{asm} output operands
8146 An @code{asm} statement has zero or more output operands indicating the names
8147 of C variables modified by the assembler code.
8149 In this i386 example, @code{old} (referred to in the template string as 
8150 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8151 (@code{%2}) is an input:
8153 @example
8154 bool old;
8156 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8157          "sbb %0,%0"      // Use the CF to calculate old.
8158    : "=r" (old), "+rm" (*Base)
8159    : "Ir" (Offset)
8160    : "cc");
8162 return old;
8163 @end example
8165 Operands are separated by commas.  Each operand has this format:
8167 @example
8168 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8169 @end example
8171 @table @var
8172 @item asmSymbolicName
8173 Specifies a symbolic name for the operand.
8174 Reference the name in the assembler template 
8175 by enclosing it in square brackets 
8176 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8177 that contains the definition. Any valid C variable name is acceptable, 
8178 including names already defined in the surrounding code. No two operands 
8179 within the same @code{asm} statement can use the same symbolic name.
8181 When not using an @var{asmSymbolicName}, use the (zero-based) position
8182 of the operand 
8183 in the list of operands in the assembler template. For example if there are 
8184 three output operands, use @samp{%0} in the template to refer to the first, 
8185 @samp{%1} for the second, and @samp{%2} for the third. 
8187 @item constraint
8188 A string constant specifying constraints on the placement of the operand; 
8189 @xref{Constraints}, for details.
8191 Output constraints must begin with either @samp{=} (a variable overwriting an 
8192 existing value) or @samp{+} (when reading and writing). When using 
8193 @samp{=}, do not assume the location contains the existing value
8194 on entry to the @code{asm}, except 
8195 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8197 After the prefix, there must be one or more additional constraints 
8198 (@pxref{Constraints}) that describe where the value resides. Common 
8199 constraints include @samp{r} for register and @samp{m} for memory. 
8200 When you list more than one possible location (for example, @code{"=rm"}),
8201 the compiler chooses the most efficient one based on the current context. 
8202 If you list as many alternates as the @code{asm} statement allows, you permit 
8203 the optimizers to produce the best possible code. 
8204 If you must use a specific register, but your Machine Constraints do not
8205 provide sufficient control to select the specific register you want, 
8206 local register variables may provide a solution (@pxref{Local Register 
8207 Variables}).
8209 @item cvariablename
8210 Specifies a C lvalue expression to hold the output, typically a variable name.
8211 The enclosing parentheses are a required part of the syntax.
8213 @end table
8215 When the compiler selects the registers to use to 
8216 represent the output operands, it does not use any of the clobbered registers 
8217 (@pxref{Clobbers}).
8219 Output operand expressions must be lvalues. The compiler cannot check whether 
8220 the operands have data types that are reasonable for the instruction being 
8221 executed. For output expressions that are not directly addressable (for 
8222 example a bit-field), the constraint must allow a register. In that case, GCC 
8223 uses the register as the output of the @code{asm}, and then stores that 
8224 register into the output. 
8226 Operands using the @samp{+} constraint modifier count as two operands 
8227 (that is, both as input and output) towards the total maximum of 30 operands
8228 per @code{asm} statement.
8230 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8231 operands that must not overlap an input.  Otherwise, 
8232 GCC may allocate the output operand in the same register as an unrelated 
8233 input operand, on the assumption that the assembler code consumes its 
8234 inputs before producing outputs. This assumption may be false if the assembler 
8235 code actually consists of more than one instruction.
8237 The same problem can occur if one output parameter (@var{a}) allows a register 
8238 constraint and another output parameter (@var{b}) allows a memory constraint.
8239 The code generated by GCC to access the memory address in @var{b} can contain
8240 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8241 registers to be inputs to the asm. As above, GCC assumes that such input
8242 registers are consumed before any outputs are written. This assumption may 
8243 result in incorrect behavior if the asm writes to @var{a} before using 
8244 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8245 ensures that modifying @var{a} does not affect the address referenced by 
8246 @var{b}. Otherwise, the location of @var{b} 
8247 is undefined if @var{a} is modified before using @var{b}.
8249 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8250 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8251 dependent. The list of supported modifiers for x86 is found at 
8252 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8254 If the C code that follows the @code{asm} makes no use of any of the output 
8255 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8256 optimizers from discarding the @code{asm} statement as unneeded 
8257 (see @ref{Volatile}).
8259 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8260 references the first output operand as @code{%0} (were there a second, it 
8261 would be @code{%1}, etc). The number of the first input operand is one greater 
8262 than that of the last output operand. In this i386 example, that makes 
8263 @code{Mask} referenced as @code{%1}:
8265 @example
8266 uint32_t Mask = 1234;
8267 uint32_t Index;
8269   asm ("bsfl %1, %0"
8270      : "=r" (Index)
8271      : "r" (Mask)
8272      : "cc");
8273 @end example
8275 That code overwrites the variable @code{Index} (@samp{=}),
8276 placing the value in a register (@samp{r}).
8277 Using the generic @samp{r} constraint instead of a constraint for a specific 
8278 register allows the compiler to pick the register to use, which can result 
8279 in more efficient code. This may not be possible if an assembler instruction 
8280 requires a specific register.
8282 The following i386 example uses the @var{asmSymbolicName} syntax.
8283 It produces the 
8284 same result as the code above, but some may consider it more readable or more 
8285 maintainable since reordering index numbers is not necessary when adding or 
8286 removing operands. The names @code{aIndex} and @code{aMask}
8287 are only used in this example to emphasize which 
8288 names get used where.
8289 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8291 @example
8292 uint32_t Mask = 1234;
8293 uint32_t Index;
8295   asm ("bsfl %[aMask], %[aIndex]"
8296      : [aIndex] "=r" (Index)
8297      : [aMask] "r" (Mask)
8298      : "cc");
8299 @end example
8301 Here are some more examples of output operands.
8303 @example
8304 uint32_t c = 1;
8305 uint32_t d;
8306 uint32_t *e = &c;
8308 asm ("mov %[e], %[d]"
8309    : [d] "=rm" (d)
8310    : [e] "rm" (*e));
8311 @end example
8313 Here, @code{d} may either be in a register or in memory. Since the compiler 
8314 might already have the current value of the @code{uint32_t} location
8315 pointed to by @code{e}
8316 in a register, you can enable it to choose the best location
8317 for @code{d} by specifying both constraints.
8319 @anchor{FlagOutputOperands}
8320 @subsubsection Flag Output Operands
8321 @cindex @code{asm} flag output operands
8323 Some targets have a special register that holds the ``flags'' for the
8324 result of an operation or comparison.  Normally, the contents of that
8325 register are either unmodifed by the asm, or the asm is considered to
8326 clobber the contents.
8328 On some targets, a special form of output operand exists by which
8329 conditions in the flags register may be outputs of the asm.  The set of
8330 conditions supported are target specific, but the general rule is that
8331 the output variable must be a scalar integer, and the value is boolean.
8332 When supported, the target defines the preprocessor symbol
8333 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8335 Because of the special nature of the flag output operands, the constraint
8336 may not include alternatives.
8338 Most often, the target has only one flags register, and thus is an implied
8339 operand of many instructions.  In this case, the operand should not be
8340 referenced within the assembler template via @code{%0} etc, as there's
8341 no corresponding text in the assembly language.
8343 @table @asis
8344 @item x86 family
8345 The flag output constraints for the x86 family are of the form
8346 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8347 conditions defined in the ISA manual for @code{j@var{cc}} or
8348 @code{set@var{cc}}.
8350 @table @code
8351 @item a
8352 ``above'' or unsigned greater than
8353 @item ae
8354 ``above or equal'' or unsigned greater than or equal
8355 @item b
8356 ``below'' or unsigned less than
8357 @item be
8358 ``below or equal'' or unsigned less than or equal
8359 @item c
8360 carry flag set
8361 @item e
8362 @itemx z
8363 ``equal'' or zero flag set
8364 @item g
8365 signed greater than
8366 @item ge
8367 signed greater than or equal
8368 @item l
8369 signed less than
8370 @item le
8371 signed less than or equal
8372 @item o
8373 overflow flag set
8374 @item p
8375 parity flag set
8376 @item s
8377 sign flag set
8378 @item na
8379 @itemx nae
8380 @itemx nb
8381 @itemx nbe
8382 @itemx nc
8383 @itemx ne
8384 @itemx ng
8385 @itemx nge
8386 @itemx nl
8387 @itemx nle
8388 @itemx no
8389 @itemx np
8390 @itemx ns
8391 @itemx nz
8392 ``not'' @var{flag}, or inverted versions of those above
8393 @end table
8395 @end table
8397 @anchor{InputOperands}
8398 @subsubsection Input Operands
8399 @cindex @code{asm} input operands
8400 @cindex @code{asm} expressions
8402 Input operands make values from C variables and expressions available to the 
8403 assembly code.
8405 Operands are separated by commas.  Each operand has this format:
8407 @example
8408 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8409 @end example
8411 @table @var
8412 @item asmSymbolicName
8413 Specifies a symbolic name for the operand.
8414 Reference the name in the assembler template 
8415 by enclosing it in square brackets 
8416 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8417 that contains the definition. Any valid C variable name is acceptable, 
8418 including names already defined in the surrounding code. No two operands 
8419 within the same @code{asm} statement can use the same symbolic name.
8421 When not using an @var{asmSymbolicName}, use the (zero-based) position
8422 of the operand 
8423 in the list of operands in the assembler template. For example if there are
8424 two output operands and three inputs,
8425 use @samp{%2} in the template to refer to the first input operand,
8426 @samp{%3} for the second, and @samp{%4} for the third. 
8428 @item constraint
8429 A string constant specifying constraints on the placement of the operand; 
8430 @xref{Constraints}, for details.
8432 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8433 When you list more than one possible location (for example, @samp{"irm"}), 
8434 the compiler chooses the most efficient one based on the current context.
8435 If you must use a specific register, but your Machine Constraints do not
8436 provide sufficient control to select the specific register you want, 
8437 local register variables may provide a solution (@pxref{Local Register 
8438 Variables}).
8440 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8441 that the specified input must be in the same place as the output constraint 
8442 at the (zero-based) index in the output constraint list. 
8443 When using @var{asmSymbolicName} syntax for the output operands,
8444 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8446 @item cexpression
8447 This is the C variable or expression being passed to the @code{asm} statement 
8448 as input.  The enclosing parentheses are a required part of the syntax.
8450 @end table
8452 When the compiler selects the registers to use to represent the input 
8453 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8455 If there are no output operands but there are input operands, place two 
8456 consecutive colons where the output operands would go:
8458 @example
8459 __asm__ ("some instructions"
8460    : /* No outputs. */
8461    : "r" (Offset / 8));
8462 @end example
8464 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8465 (except for inputs tied to outputs). The compiler assumes that on exit from 
8466 the @code{asm} statement these operands contain the same values as they 
8467 had before executing the statement. 
8468 It is @emph{not} possible to use clobbers
8469 to inform the compiler that the values in these inputs are changing. One 
8470 common work-around is to tie the changing input variable to an output variable 
8471 that never gets used. Note, however, that if the code that follows the 
8472 @code{asm} statement makes no use of any of the output operands, the GCC 
8473 optimizers may discard the @code{asm} statement as unneeded 
8474 (see @ref{Volatile}).
8476 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8477 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8478 dependent. The list of supported modifiers for x86 is found at 
8479 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8481 In this example using the fictitious @code{combine} instruction, the 
8482 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8483 location as output operand 0. Only input operands may use numbers in 
8484 constraints, and they must each refer to an output operand. Only a number (or 
8485 the symbolic assembler name) in the constraint can guarantee that one operand 
8486 is in the same place as another. The mere fact that @code{foo} is the value of 
8487 both operands is not enough to guarantee that they are in the same place in 
8488 the generated assembler code.
8490 @example
8491 asm ("combine %2, %0" 
8492    : "=r" (foo) 
8493    : "0" (foo), "g" (bar));
8494 @end example
8496 Here is an example using symbolic names.
8498 @example
8499 asm ("cmoveq %1, %2, %[result]" 
8500    : [result] "=r"(result) 
8501    : "r" (test), "r" (new), "[result]" (old));
8502 @end example
8504 @anchor{Clobbers}
8505 @subsubsection Clobbers
8506 @cindex @code{asm} clobbers
8508 While the compiler is aware of changes to entries listed in the output 
8509 operands, the inline @code{asm} code may modify more than just the outputs. For 
8510 example, calculations may require additional registers, or the processor may 
8511 overwrite a register as a side effect of a particular assembler instruction. 
8512 In order to inform the compiler of these changes, list them in the clobber 
8513 list. Clobber list items are either register names or the special clobbers 
8514 (listed below). Each clobber list item is a string constant 
8515 enclosed in double quotes and separated by commas.
8517 Clobber descriptions may not in any way overlap with an input or output 
8518 operand. For example, you may not have an operand describing a register class 
8519 with one member when listing that register in the clobber list. Variables 
8520 declared to live in specific registers (@pxref{Explicit Register 
8521 Variables}) and used 
8522 as @code{asm} input or output operands must have no part mentioned in the 
8523 clobber description. In particular, there is no way to specify that input 
8524 operands get modified without also specifying them as output operands.
8526 When the compiler selects which registers to use to represent input and output 
8527 operands, it does not use any of the clobbered registers. As a result, 
8528 clobbered registers are available for any use in the assembler code.
8530 Here is a realistic example for the VAX showing the use of clobbered 
8531 registers: 
8533 @example
8534 asm volatile ("movc3 %0, %1, %2"
8535                    : /* No outputs. */
8536                    : "g" (from), "g" (to), "g" (count)
8537                    : "r0", "r1", "r2", "r3", "r4", "r5");
8538 @end example
8540 Also, there are two special clobber arguments:
8542 @table @code
8543 @item "cc"
8544 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8545 register. On some machines, GCC represents the condition codes as a specific 
8546 hardware register; @code{"cc"} serves to name this register.
8547 On other machines, condition code handling is different, 
8548 and specifying @code{"cc"} has no effect. But 
8549 it is valid no matter what the target.
8551 @item "memory"
8552 The @code{"memory"} clobber tells the compiler that the assembly code
8553 performs memory 
8554 reads or writes to items other than those listed in the input and output 
8555 operands (for example, accessing the memory pointed to by one of the input 
8556 parameters). To ensure memory contains correct values, GCC may need to flush 
8557 specific register values to memory before executing the @code{asm}. Further, 
8558 the compiler does not assume that any values read from memory before an 
8559 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8560 needed.  
8561 Using the @code{"memory"} clobber effectively forms a read/write
8562 memory barrier for the compiler.
8564 Note that this clobber does not prevent the @emph{processor} from doing 
8565 speculative reads past the @code{asm} statement. To prevent that, you need 
8566 processor-specific fence instructions.
8568 Flushing registers to memory has performance implications and may be an issue 
8569 for time-sensitive code.  You can use a trick to avoid this if the size of 
8570 the memory being accessed is known at compile time. For example, if accessing 
8571 ten bytes of a string, use a memory input like: 
8573 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8575 @end table
8577 @anchor{GotoLabels}
8578 @subsubsection Goto Labels
8579 @cindex @code{asm} goto labels
8581 @code{asm goto} allows assembly code to jump to one or more C labels.  The
8582 @var{GotoLabels} section in an @code{asm goto} statement contains 
8583 a comma-separated 
8584 list of all C labels to which the assembler code may jump. GCC assumes that 
8585 @code{asm} execution falls through to the next statement (if this is not the 
8586 case, consider using the @code{__builtin_unreachable} intrinsic after the 
8587 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
8588 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
8589 Attributes}).
8591 An @code{asm goto} statement cannot have outputs.
8592 This is due to an internal restriction of 
8593 the compiler: control transfer instructions cannot have outputs. 
8594 If the assembler code does modify anything, use the @code{"memory"} clobber 
8595 to force the 
8596 optimizers to flush all register values to memory and reload them if 
8597 necessary after the @code{asm} statement.
8599 Also note that an @code{asm goto} statement is always implicitly
8600 considered volatile.
8602 To reference a label in the assembler template,
8603 prefix it with @samp{%l} (lowercase @samp{L}) followed 
8604 by its (zero-based) position in @var{GotoLabels} plus the number of input 
8605 operands.  For example, if the @code{asm} has three inputs and references two 
8606 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8608 Alternately, you can reference labels using the actual C label name enclosed
8609 in brackets.  For example, to reference a label named @code{carry}, you can
8610 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
8611 section when using this approach.
8613 Here is an example of @code{asm goto} for i386:
8615 @example
8616 asm goto (
8617     "btl %1, %0\n\t"
8618     "jc %l2"
8619     : /* No outputs. */
8620     : "r" (p1), "r" (p2) 
8621     : "cc" 
8622     : carry);
8624 return 0;
8626 carry:
8627 return 1;
8628 @end example
8630 The following example shows an @code{asm goto} that uses a memory clobber.
8632 @example
8633 int frob(int x)
8635   int y;
8636   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8637             : /* No outputs. */
8638             : "r"(x), "r"(&y)
8639             : "r5", "memory" 
8640             : error);
8641   return y;
8642 error:
8643   return -1;
8645 @end example
8647 @anchor{x86Operandmodifiers}
8648 @subsubsection x86 Operand Modifiers
8650 References to input, output, and goto operands in the assembler template
8651 of extended @code{asm} statements can use 
8652 modifiers to affect the way the operands are formatted in 
8653 the code output to the assembler. For example, the 
8654 following code uses the @samp{h} and @samp{b} modifiers for x86:
8656 @example
8657 uint16_t  num;
8658 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8659 @end example
8661 @noindent
8662 These modifiers generate this assembler code:
8664 @example
8665 xchg %ah, %al
8666 @end example
8668 The rest of this discussion uses the following code for illustrative purposes.
8670 @example
8671 int main()
8673    int iInt = 1;
8675 top:
8677    asm volatile goto ("some assembler instructions here"
8678    : /* No outputs. */
8679    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8680    : /* No clobbers. */
8681    : top);
8683 @end example
8685 With no modifiers, this is what the output from the operands would be for the 
8686 @samp{att} and @samp{intel} dialects of assembler:
8688 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8689 @headitem Operand @tab masm=att @tab masm=intel
8690 @item @code{%0}
8691 @tab @code{%eax}
8692 @tab @code{eax}
8693 @item @code{%1}
8694 @tab @code{$2}
8695 @tab @code{2}
8696 @item @code{%2}
8697 @tab @code{$.L2}
8698 @tab @code{OFFSET FLAT:.L2}
8699 @end multitable
8701 The table below shows the list of supported modifiers and their effects.
8703 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8704 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8705 @item @code{z}
8706 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8707 @tab @code{%z0}
8708 @tab @code{l}
8709 @tab 
8710 @item @code{b}
8711 @tab Print the QImode name of the register.
8712 @tab @code{%b0}
8713 @tab @code{%al}
8714 @tab @code{al}
8715 @item @code{h}
8716 @tab Print the QImode name for a ``high'' register.
8717 @tab @code{%h0}
8718 @tab @code{%ah}
8719 @tab @code{ah}
8720 @item @code{w}
8721 @tab Print the HImode name of the register.
8722 @tab @code{%w0}
8723 @tab @code{%ax}
8724 @tab @code{ax}
8725 @item @code{k}
8726 @tab Print the SImode name of the register.
8727 @tab @code{%k0}
8728 @tab @code{%eax}
8729 @tab @code{eax}
8730 @item @code{q}
8731 @tab Print the DImode name of the register.
8732 @tab @code{%q0}
8733 @tab @code{%rax}
8734 @tab @code{rax}
8735 @item @code{l}
8736 @tab Print the label name with no punctuation.
8737 @tab @code{%l2}
8738 @tab @code{.L2}
8739 @tab @code{.L2}
8740 @item @code{c}
8741 @tab Require a constant operand and print the constant expression with no punctuation.
8742 @tab @code{%c1}
8743 @tab @code{2}
8744 @tab @code{2}
8745 @end multitable
8747 @anchor{x86floatingpointasmoperands}
8748 @subsubsection x86 Floating-Point @code{asm} Operands
8750 On x86 targets, there are several rules on the usage of stack-like registers
8751 in the operands of an @code{asm}.  These rules apply only to the operands
8752 that are stack-like registers:
8754 @enumerate
8755 @item
8756 Given a set of input registers that die in an @code{asm}, it is
8757 necessary to know which are implicitly popped by the @code{asm}, and
8758 which must be explicitly popped by GCC@.
8760 An input register that is implicitly popped by the @code{asm} must be
8761 explicitly clobbered, unless it is constrained to match an
8762 output operand.
8764 @item
8765 For any input register that is implicitly popped by an @code{asm}, it is
8766 necessary to know how to adjust the stack to compensate for the pop.
8767 If any non-popped input is closer to the top of the reg-stack than
8768 the implicitly popped register, it would not be possible to know what the
8769 stack looked like---it's not clear how the rest of the stack ``slides
8770 up''.
8772 All implicitly popped input registers must be closer to the top of
8773 the reg-stack than any input that is not implicitly popped.
8775 It is possible that if an input dies in an @code{asm}, the compiler might
8776 use the input register for an output reload.  Consider this example:
8778 @smallexample
8779 asm ("foo" : "=t" (a) : "f" (b));
8780 @end smallexample
8782 @noindent
8783 This code says that input @code{b} is not popped by the @code{asm}, and that
8784 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8785 deeper after the @code{asm} than it was before.  But, it is possible that
8786 reload may think that it can use the same register for both the input and
8787 the output.
8789 To prevent this from happening,
8790 if any input operand uses the @samp{f} constraint, all output register
8791 constraints must use the @samp{&} early-clobber modifier.
8793 The example above is correctly written as:
8795 @smallexample
8796 asm ("foo" : "=&t" (a) : "f" (b));
8797 @end smallexample
8799 @item
8800 Some operands need to be in particular places on the stack.  All
8801 output operands fall in this category---GCC has no other way to
8802 know which registers the outputs appear in unless you indicate
8803 this in the constraints.
8805 Output operands must specifically indicate which register an output
8806 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
8807 constraints must select a class with a single register.
8809 @item
8810 Output operands may not be ``inserted'' between existing stack registers.
8811 Since no 387 opcode uses a read/write operand, all output operands
8812 are dead before the @code{asm}, and are pushed by the @code{asm}.
8813 It makes no sense to push anywhere but the top of the reg-stack.
8815 Output operands must start at the top of the reg-stack: output
8816 operands may not ``skip'' a register.
8818 @item
8819 Some @code{asm} statements may need extra stack space for internal
8820 calculations.  This can be guaranteed by clobbering stack registers
8821 unrelated to the inputs and outputs.
8823 @end enumerate
8825 This @code{asm}
8826 takes one input, which is internally popped, and produces two outputs.
8828 @smallexample
8829 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8830 @end smallexample
8832 @noindent
8833 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8834 and replaces them with one output.  The @code{st(1)} clobber is necessary 
8835 for the compiler to know that @code{fyl2xp1} pops both inputs.
8837 @smallexample
8838 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8839 @end smallexample
8841 @lowersections
8842 @include md.texi
8843 @raisesections
8845 @node Asm Labels
8846 @subsection Controlling Names Used in Assembler Code
8847 @cindex assembler names for identifiers
8848 @cindex names used in assembler code
8849 @cindex identifiers, names in assembler code
8851 You can specify the name to be used in the assembler code for a C
8852 function or variable by writing the @code{asm} (or @code{__asm__})
8853 keyword after the declarator.
8854 It is up to you to make sure that the assembler names you choose do not
8855 conflict with any other assembler symbols, or reference registers.
8857 @subsubheading Assembler names for data:
8859 This sample shows how to specify the assembler name for data:
8861 @smallexample
8862 int foo asm ("myfoo") = 2;
8863 @end smallexample
8865 @noindent
8866 This specifies that the name to be used for the variable @code{foo} in
8867 the assembler code should be @samp{myfoo} rather than the usual
8868 @samp{_foo}.
8870 On systems where an underscore is normally prepended to the name of a C
8871 variable, this feature allows you to define names for the
8872 linker that do not start with an underscore.
8874 GCC does not support using this feature with a non-static local variable 
8875 since such variables do not have assembler names.  If you are
8876 trying to put the variable in a particular register, see 
8877 @ref{Explicit Register Variables}.
8879 @subsubheading Assembler names for functions:
8881 To specify the assembler name for functions, write a declaration for the 
8882 function before its definition and put @code{asm} there, like this:
8884 @smallexample
8885 int func (int x, int y) asm ("MYFUNC");
8886      
8887 int func (int x, int y)
8889    /* @r{@dots{}} */
8890 @end smallexample
8892 @noindent
8893 This specifies that the name to be used for the function @code{func} in
8894 the assembler code should be @code{MYFUNC}.
8896 @node Explicit Register Variables
8897 @subsection Variables in Specified Registers
8898 @anchor{Explicit Reg Vars}
8899 @cindex explicit register variables
8900 @cindex variables in specified registers
8901 @cindex specified registers
8903 GNU C allows you to associate specific hardware registers with C 
8904 variables.  In almost all cases, allowing the compiler to assign
8905 registers produces the best code.  However under certain unusual
8906 circumstances, more precise control over the variable storage is 
8907 required.
8909 Both global and local variables can be associated with a register.  The
8910 consequences of performing this association are very different between
8911 the two, as explained in the sections below.
8913 @menu
8914 * Global Register Variables::   Variables declared at global scope.
8915 * Local Register Variables::    Variables declared within a function.
8916 @end menu
8918 @node Global Register Variables
8919 @subsubsection Defining Global Register Variables
8920 @anchor{Global Reg Vars}
8921 @cindex global register variables
8922 @cindex registers, global variables in
8923 @cindex registers, global allocation
8925 You can define a global register variable and associate it with a specified 
8926 register like this:
8928 @smallexample
8929 register int *foo asm ("r12");
8930 @end smallexample
8932 @noindent
8933 Here @code{r12} is the name of the register that should be used. Note that 
8934 this is the same syntax used for defining local register variables, but for 
8935 a global variable the declaration appears outside a function. The 
8936 @code{register} keyword is required, and cannot be combined with 
8937 @code{static}. The register name must be a valid register name for the
8938 target platform.
8940 Registers are a scarce resource on most systems and allowing the 
8941 compiler to manage their usage usually results in the best code. However, 
8942 under special circumstances it can make sense to reserve some globally.
8943 For example this may be useful in programs such as programming language 
8944 interpreters that have a couple of global variables that are accessed 
8945 very often.
8947 After defining a global register variable, for the current compilation
8948 unit:
8950 @itemize @bullet
8951 @item The register is reserved entirely for this use, and will not be 
8952 allocated for any other purpose.
8953 @item The register is not saved and restored by any functions.
8954 @item Stores into this register are never deleted even if they appear to be 
8955 dead, but references may be deleted, moved or simplified.
8956 @end itemize
8958 Note that these points @emph{only} apply to code that is compiled with the
8959 definition. The behavior of code that is merely linked in (for example 
8960 code from libraries) is not affected.
8962 If you want to recompile source files that do not actually use your global 
8963 register variable so they do not use the specified register for any other 
8964 purpose, you need not actually add the global register declaration to 
8965 their source code. It suffices to specify the compiler option 
8966 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
8967 register.
8969 @subsubheading Declaring the variable
8971 Global register variables can not have initial values, because an
8972 executable file has no means to supply initial contents for a register.
8974 When selecting a register, choose one that is normally saved and 
8975 restored by function calls on your machine. This ensures that code
8976 which is unaware of this reservation (such as library routines) will 
8977 restore it before returning.
8979 On machines with register windows, be sure to choose a global
8980 register that is not affected magically by the function call mechanism.
8982 @subsubheading Using the variable
8984 @cindex @code{qsort}, and global register variables
8985 When calling routines that are not aware of the reservation, be 
8986 cautious if those routines call back into code which uses them. As an 
8987 example, if you call the system library version of @code{qsort}, it may 
8988 clobber your registers during execution, but (if you have selected 
8989 appropriate registers) it will restore them before returning. However 
8990 it will @emph{not} restore them before calling @code{qsort}'s comparison 
8991 function. As a result, global values will not reliably be available to 
8992 the comparison function unless the @code{qsort} function itself is rebuilt.
8994 Similarly, it is not safe to access the global register variables from signal
8995 handlers or from more than one thread of control. Unless you recompile 
8996 them specially for the task at hand, the system library routines may 
8997 temporarily use the register for other things.
8999 @cindex register variable after @code{longjmp}
9000 @cindex global register after @code{longjmp}
9001 @cindex value after @code{longjmp}
9002 @findex longjmp
9003 @findex setjmp
9004 On most machines, @code{longjmp} restores to each global register
9005 variable the value it had at the time of the @code{setjmp}. On some
9006 machines, however, @code{longjmp} does not change the value of global
9007 register variables. To be portable, the function that called @code{setjmp}
9008 should make other arrangements to save the values of the global register
9009 variables, and to restore them in a @code{longjmp}. This way, the same
9010 thing happens regardless of what @code{longjmp} does.
9012 Eventually there may be a way of asking the compiler to choose a register 
9013 automatically, but first we need to figure out how it should choose and 
9014 how to enable you to guide the choice.  No solution is evident.
9016 @node Local Register Variables
9017 @subsubsection Specifying Registers for Local Variables
9018 @anchor{Local Reg Vars}
9019 @cindex local variables, specifying registers
9020 @cindex specifying registers for local variables
9021 @cindex registers for local variables
9023 You can define a local register variable and associate it with a specified 
9024 register like this:
9026 @smallexample
9027 register int *foo asm ("r12");
9028 @end smallexample
9030 @noindent
9031 Here @code{r12} is the name of the register that should be used.  Note
9032 that this is the same syntax used for defining global register variables, 
9033 but for a local variable the declaration appears within a function.  The 
9034 @code{register} keyword is required, and cannot be combined with 
9035 @code{static}.  The register name must be a valid register name for the
9036 target platform.
9038 As with global register variables, it is recommended that you choose 
9039 a register that is normally saved and restored by function calls on your 
9040 machine, so that calls to library routines will not clobber it.
9042 The only supported use for this feature is to specify registers
9043 for input and output operands when calling Extended @code{asm} 
9044 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9045 particular machine don't provide sufficient control to select the desired 
9046 register.  To force an operand into a register, create a local variable 
9047 and specify the register name after the variable's declaration.  Then use 
9048 the local variable for the @code{asm} operand and specify any constraint 
9049 letter that matches the register:
9051 @smallexample
9052 register int *p1 asm ("r0") = @dots{};
9053 register int *p2 asm ("r1") = @dots{};
9054 register int *result asm ("r0");
9055 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9056 @end smallexample
9058 @emph{Warning:} In the above example, be aware that a register (for example 
9059 @code{r0}) can be call-clobbered by subsequent code, including function 
9060 calls and library calls for arithmetic operators on other variables (for 
9061 example the initialization of @code{p2}).  In this case, use temporary 
9062 variables for expressions between the register assignments:
9064 @smallexample
9065 int t1 = @dots{};
9066 register int *p1 asm ("r0") = @dots{};
9067 register int *p2 asm ("r1") = t1;
9068 register int *result asm ("r0");
9069 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9070 @end smallexample
9072 Defining a register variable does not reserve the register.  Other than
9073 when invoking the Extended @code{asm}, the contents of the specified 
9074 register are not guaranteed.  For this reason, the following uses 
9075 are explicitly @emph{not} supported.  If they appear to work, it is only 
9076 happenstance, and may stop working as intended due to (seemingly) 
9077 unrelated changes in surrounding code, or even minor changes in the 
9078 optimization of a future version of gcc:
9080 @itemize @bullet
9081 @item Passing parameters to or from Basic @code{asm}
9082 @item Passing parameters to or from Extended @code{asm} without using input 
9083 or output operands.
9084 @item Passing parameters to or from routines written in assembler (or
9085 other languages) using non-standard calling conventions.
9086 @end itemize
9088 Some developers use Local Register Variables in an attempt to improve 
9089 gcc's allocation of registers, especially in large functions.  In this 
9090 case the register name is essentially a hint to the register allocator.
9091 While in some instances this can generate better code, improvements are
9092 subject to the whims of the allocator/optimizers.  Since there are no
9093 guarantees that your improvements won't be lost, this usage of Local
9094 Register Variables is discouraged.
9096 On the MIPS platform, there is related use for local register variables 
9097 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9098 Defining coprocessor specifics for MIPS targets, gccint, 
9099 GNU Compiler Collection (GCC) Internals}).
9101 @node Size of an asm
9102 @subsection Size of an @code{asm}
9104 Some targets require that GCC track the size of each instruction used
9105 in order to generate correct code.  Because the final length of the
9106 code produced by an @code{asm} statement is only known by the
9107 assembler, GCC must make an estimate as to how big it will be.  It
9108 does this by counting the number of instructions in the pattern of the
9109 @code{asm} and multiplying that by the length of the longest
9110 instruction supported by that processor.  (When working out the number
9111 of instructions, it assumes that any occurrence of a newline or of
9112 whatever statement separator character is supported by the assembler --
9113 typically @samp{;} --- indicates the end of an instruction.)
9115 Normally, GCC's estimate is adequate to ensure that correct
9116 code is generated, but it is possible to confuse the compiler if you use
9117 pseudo instructions or assembler macros that expand into multiple real
9118 instructions, or if you use assembler directives that expand to more
9119 space in the object file than is needed for a single instruction.
9120 If this happens then the assembler may produce a diagnostic saying that
9121 a label is unreachable.
9123 @node Alternate Keywords
9124 @section Alternate Keywords
9125 @cindex alternate keywords
9126 @cindex keywords, alternate
9128 @option{-ansi} and the various @option{-std} options disable certain
9129 keywords.  This causes trouble when you want to use GNU C extensions, or
9130 a general-purpose header file that should be usable by all programs,
9131 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9132 @code{inline} are not available in programs compiled with
9133 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9134 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9135 ISO C99 keyword
9136 @code{restrict} is only available when @option{-std=gnu99} (which will
9137 eventually be the default) or @option{-std=c99} (or the equivalent
9138 @option{-std=iso9899:1999}), or an option for a later standard
9139 version, is used.
9141 The way to solve these problems is to put @samp{__} at the beginning and
9142 end of each problematical keyword.  For example, use @code{__asm__}
9143 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9145 Other C compilers won't accept these alternative keywords; if you want to
9146 compile with another compiler, you can define the alternate keywords as
9147 macros to replace them with the customary keywords.  It looks like this:
9149 @smallexample
9150 #ifndef __GNUC__
9151 #define __asm__ asm
9152 #endif
9153 @end smallexample
9155 @findex __extension__
9156 @opindex pedantic
9157 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9158 You can
9159 prevent such warnings within one expression by writing
9160 @code{__extension__} before the expression.  @code{__extension__} has no
9161 effect aside from this.
9163 @node Incomplete Enums
9164 @section Incomplete @code{enum} Types
9166 You can define an @code{enum} tag without specifying its possible values.
9167 This results in an incomplete type, much like what you get if you write
9168 @code{struct foo} without describing the elements.  A later declaration
9169 that does specify the possible values completes the type.
9171 You can't allocate variables or storage using the type while it is
9172 incomplete.  However, you can work with pointers to that type.
9174 This extension may not be very useful, but it makes the handling of
9175 @code{enum} more consistent with the way @code{struct} and @code{union}
9176 are handled.
9178 This extension is not supported by GNU C++.
9180 @node Function Names
9181 @section Function Names as Strings
9182 @cindex @code{__func__} identifier
9183 @cindex @code{__FUNCTION__} identifier
9184 @cindex @code{__PRETTY_FUNCTION__} identifier
9186 GCC provides three magic constants that hold the name of the current
9187 function as a string.  In C++11 and later modes, all three are treated
9188 as constant expressions and can be used in @code{constexpr} constexts.
9189 The first of these constants is @code{__func__}, which is part of
9190 the C99 standard:
9192 The identifier @code{__func__} is implicitly declared by the translator
9193 as if, immediately following the opening brace of each function
9194 definition, the declaration
9196 @smallexample
9197 static const char __func__[] = "function-name";
9198 @end smallexample
9200 @noindent
9201 appeared, where function-name is the name of the lexically-enclosing
9202 function.  This name is the unadorned name of the function.  As an
9203 extension, at file (or, in C++, namespace scope), @code{__func__}
9204 evaluates to the empty string.
9206 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9207 backward compatibility with old versions of GCC.
9209 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9210 @code{__func__}, except that at file (or, in C++, namespace scope),
9211 it evaluates to the string @code{"top level"}.  In addition, in C++,
9212 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9213 well as its bare name.  For example, this program:
9215 @smallexample
9216 extern "C" int printf (const char *, ...);
9218 class a @{
9219  public:
9220   void sub (int i)
9221     @{
9222       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9223       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9224     @}
9228 main (void)
9230   a ax;
9231   ax.sub (0);
9232   return 0;
9234 @end smallexample
9236 @noindent
9237 gives this output:
9239 @smallexample
9240 __FUNCTION__ = sub
9241 __PRETTY_FUNCTION__ = void a::sub(int)
9242 @end smallexample
9244 These identifiers are variables, not preprocessor macros, and may not
9245 be used to initialize @code{char} arrays or be concatenated with string
9246 literals.
9248 @node Return Address
9249 @section Getting the Return or Frame Address of a Function
9251 These functions may be used to get information about the callers of a
9252 function.
9254 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9255 This function returns the return address of the current function, or of
9256 one of its callers.  The @var{level} argument is number of frames to
9257 scan up the call stack.  A value of @code{0} yields the return address
9258 of the current function, a value of @code{1} yields the return address
9259 of the caller of the current function, and so forth.  When inlining
9260 the expected behavior is that the function returns the address of
9261 the function that is returned to.  To work around this behavior use
9262 the @code{noinline} function attribute.
9264 The @var{level} argument must be a constant integer.
9266 On some machines it may be impossible to determine the return address of
9267 any function other than the current one; in such cases, or when the top
9268 of the stack has been reached, this function returns @code{0} or a
9269 random value.  In addition, @code{__builtin_frame_address} may be used
9270 to determine if the top of the stack has been reached.
9272 Additional post-processing of the returned value may be needed, see
9273 @code{__builtin_extract_return_addr}.
9275 Calling this function with a nonzero argument can have unpredictable
9276 effects, including crashing the calling program.  As a result, calls
9277 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9278 option is in effect.  Such calls should only be made in debugging
9279 situations.
9280 @end deftypefn
9282 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9283 The address as returned by @code{__builtin_return_address} may have to be fed
9284 through this function to get the actual encoded address.  For example, on the
9285 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9286 platforms an offset has to be added for the true next instruction to be
9287 executed.
9289 If no fixup is needed, this function simply passes through @var{addr}.
9290 @end deftypefn
9292 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9293 This function does the reverse of @code{__builtin_extract_return_addr}.
9294 @end deftypefn
9296 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9297 This function is similar to @code{__builtin_return_address}, but it
9298 returns the address of the function frame rather than the return address
9299 of the function.  Calling @code{__builtin_frame_address} with a value of
9300 @code{0} yields the frame address of the current function, a value of
9301 @code{1} yields the frame address of the caller of the current function,
9302 and so forth.
9304 The frame is the area on the stack that holds local variables and saved
9305 registers.  The frame address is normally the address of the first word
9306 pushed on to the stack by the function.  However, the exact definition
9307 depends upon the processor and the calling convention.  If the processor
9308 has a dedicated frame pointer register, and the function has a frame,
9309 then @code{__builtin_frame_address} returns the value of the frame
9310 pointer register.
9312 On some machines it may be impossible to determine the frame address of
9313 any function other than the current one; in such cases, or when the top
9314 of the stack has been reached, this function returns @code{0} if
9315 the first frame pointer is properly initialized by the startup code.
9317 Calling this function with a nonzero argument can have unpredictable
9318 effects, including crashing the calling program.  As a result, calls
9319 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9320 option is in effect.  Such calls should only be made in debugging
9321 situations.
9322 @end deftypefn
9324 @node Vector Extensions
9325 @section Using Vector Instructions through Built-in Functions
9327 On some targets, the instruction set contains SIMD vector instructions which
9328 operate on multiple values contained in one large register at the same time.
9329 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9330 this way.
9332 The first step in using these extensions is to provide the necessary data
9333 types.  This should be done using an appropriate @code{typedef}:
9335 @smallexample
9336 typedef int v4si __attribute__ ((vector_size (16)));
9337 @end smallexample
9339 @noindent
9340 The @code{int} type specifies the base type, while the attribute specifies
9341 the vector size for the variable, measured in bytes.  For example, the
9342 declaration above causes the compiler to set the mode for the @code{v4si}
9343 type to be 16 bytes wide and divided into @code{int} sized units.  For
9344 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9345 corresponding mode of @code{foo} is @acronym{V4SI}.
9347 The @code{vector_size} attribute is only applicable to integral and
9348 float scalars, although arrays, pointers, and function return values
9349 are allowed in conjunction with this construct. Only sizes that are
9350 a power of two are currently allowed.
9352 All the basic integer types can be used as base types, both as signed
9353 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9354 @code{long long}.  In addition, @code{float} and @code{double} can be
9355 used to build floating-point vector types.
9357 Specifying a combination that is not valid for the current architecture
9358 causes GCC to synthesize the instructions using a narrower mode.
9359 For example, if you specify a variable of type @code{V4SI} and your
9360 architecture does not allow for this specific SIMD type, GCC
9361 produces code that uses 4 @code{SIs}.
9363 The types defined in this manner can be used with a subset of normal C
9364 operations.  Currently, GCC allows using the following operators
9365 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9367 The operations behave like C++ @code{valarrays}.  Addition is defined as
9368 the addition of the corresponding elements of the operands.  For
9369 example, in the code below, each of the 4 elements in @var{a} is
9370 added to the corresponding 4 elements in @var{b} and the resulting
9371 vector is stored in @var{c}.
9373 @smallexample
9374 typedef int v4si __attribute__ ((vector_size (16)));
9376 v4si a, b, c;
9378 c = a + b;
9379 @end smallexample
9381 Subtraction, multiplication, division, and the logical operations
9382 operate in a similar manner.  Likewise, the result of using the unary
9383 minus or complement operators on a vector type is a vector whose
9384 elements are the negative or complemented values of the corresponding
9385 elements in the operand.
9387 It is possible to use shifting operators @code{<<}, @code{>>} on
9388 integer-type vectors. The operation is defined as following: @code{@{a0,
9389 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9390 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9391 elements. 
9393 For convenience, it is allowed to use a binary vector operation
9394 where one operand is a scalar. In that case the compiler transforms
9395 the scalar operand into a vector where each element is the scalar from
9396 the operation. The transformation happens only if the scalar could be
9397 safely converted to the vector-element type.
9398 Consider the following code.
9400 @smallexample
9401 typedef int v4si __attribute__ ((vector_size (16)));
9403 v4si a, b, c;
9404 long l;
9406 a = b + 1;    /* a = b + @{1,1,1,1@}; */
9407 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
9409 a = l + a;    /* Error, cannot convert long to int. */
9410 @end smallexample
9412 Vectors can be subscripted as if the vector were an array with
9413 the same number of elements and base type.  Out of bound accesses
9414 invoke undefined behavior at run time.  Warnings for out of bound
9415 accesses for vector subscription can be enabled with
9416 @option{-Warray-bounds}.
9418 Vector comparison is supported with standard comparison
9419 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9420 vector expressions of integer-type or real-type. Comparison between
9421 integer-type vectors and real-type vectors are not supported.  The
9422 result of the comparison is a vector of the same width and number of
9423 elements as the comparison operands with a signed integral element
9424 type.
9426 Vectors are compared element-wise producing 0 when comparison is false
9427 and -1 (constant of the appropriate type where all bits are set)
9428 otherwise. Consider the following example.
9430 @smallexample
9431 typedef int v4si __attribute__ ((vector_size (16)));
9433 v4si a = @{1,2,3,4@};
9434 v4si b = @{3,2,1,4@};
9435 v4si c;
9437 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
9438 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
9439 @end smallexample
9441 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9442 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9443 integer vector with the same number of elements of the same size as @code{b}
9444 and @code{c}, computes all three arguments and creates a vector
9445 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
9446 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9447 As in the case of binary operations, this syntax is also accepted when
9448 one of @code{b} or @code{c} is a scalar that is then transformed into a
9449 vector. If both @code{b} and @code{c} are scalars and the type of
9450 @code{true?b:c} has the same size as the element type of @code{a}, then
9451 @code{b} and @code{c} are converted to a vector type whose elements have
9452 this type and with the same number of elements as @code{a}.
9454 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9455 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9456 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9457 For mixed operations between a scalar @code{s} and a vector @code{v},
9458 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9459 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9461 Vector shuffling is available using functions
9462 @code{__builtin_shuffle (vec, mask)} and
9463 @code{__builtin_shuffle (vec0, vec1, mask)}.
9464 Both functions construct a permutation of elements from one or two
9465 vectors and return a vector of the same type as the input vector(s).
9466 The @var{mask} is an integral vector with the same width (@var{W})
9467 and element count (@var{N}) as the output vector.
9469 The elements of the input vectors are numbered in memory ordering of
9470 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
9471 elements of @var{mask} are considered modulo @var{N} in the single-operand
9472 case and modulo @math{2*@var{N}} in the two-operand case.
9474 Consider the following example,
9476 @smallexample
9477 typedef int v4si __attribute__ ((vector_size (16)));
9479 v4si a = @{1,2,3,4@};
9480 v4si b = @{5,6,7,8@};
9481 v4si mask1 = @{0,1,1,3@};
9482 v4si mask2 = @{0,4,2,5@};
9483 v4si res;
9485 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
9486 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
9487 @end smallexample
9489 Note that @code{__builtin_shuffle} is intentionally semantically
9490 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9492 You can declare variables and use them in function calls and returns, as
9493 well as in assignments and some casts.  You can specify a vector type as
9494 a return type for a function.  Vector types can also be used as function
9495 arguments.  It is possible to cast from one vector type to another,
9496 provided they are of the same size (in fact, you can also cast vectors
9497 to and from other datatypes of the same size).
9499 You cannot operate between vectors of different lengths or different
9500 signedness without a cast.
9502 @node Offsetof
9503 @section Support for @code{offsetof}
9504 @findex __builtin_offsetof
9506 GCC implements for both C and C++ a syntactic extension to implement
9507 the @code{offsetof} macro.
9509 @smallexample
9510 primary:
9511         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9513 offsetof_member_designator:
9514           @code{identifier}
9515         | offsetof_member_designator "." @code{identifier}
9516         | offsetof_member_designator "[" @code{expr} "]"
9517 @end smallexample
9519 This extension is sufficient such that
9521 @smallexample
9522 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
9523 @end smallexample
9525 @noindent
9526 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
9527 may be dependent.  In either case, @var{member} may consist of a single
9528 identifier, or a sequence of member accesses and array references.
9530 @node __sync Builtins
9531 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9533 The following built-in functions
9534 are intended to be compatible with those described
9535 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9536 section 7.4.  As such, they depart from normal GCC practice by not using
9537 the @samp{__builtin_} prefix and also by being overloaded so that they
9538 work on multiple types.
9540 The definition given in the Intel documentation allows only for the use of
9541 the types @code{int}, @code{long}, @code{long long} or their unsigned
9542 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9543 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9544 Operations on pointer arguments are performed as if the operands were
9545 of the @code{uintptr_t} type.  That is, they are not scaled by the size
9546 of the type to which the pointer points.
9548 These functions are implemented in terms of the @samp{__atomic}
9549 builtins (@pxref{__atomic Builtins}).  They should not be used for new
9550 code which should use the @samp{__atomic} builtins instead.
9552 Not all operations are supported by all target processors.  If a particular
9553 operation cannot be implemented on the target processor, a warning is
9554 generated and a call to an external function is generated.  The external
9555 function carries the same name as the built-in version,
9556 with an additional suffix
9557 @samp{_@var{n}} where @var{n} is the size of the data type.
9559 @c ??? Should we have a mechanism to suppress this warning?  This is almost
9560 @c useful for implementing the operation under the control of an external
9561 @c mutex.
9563 In most cases, these built-in functions are considered a @dfn{full barrier}.
9564 That is,
9565 no memory operand is moved across the operation, either forward or
9566 backward.  Further, instructions are issued as necessary to prevent the
9567 processor from speculating loads across the operation and from queuing stores
9568 after the operation.
9570 All of the routines are described in the Intel documentation to take
9571 ``an optional list of variables protected by the memory barrier''.  It's
9572 not clear what is meant by that; it could mean that @emph{only} the
9573 listed variables are protected, or it could mean a list of additional
9574 variables to be protected.  The list is ignored by GCC which treats it as
9575 empty.  GCC interprets an empty list as meaning that all globally
9576 accessible variables should be protected.
9578 @table @code
9579 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9580 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9581 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9582 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9583 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9584 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9585 @findex __sync_fetch_and_add
9586 @findex __sync_fetch_and_sub
9587 @findex __sync_fetch_and_or
9588 @findex __sync_fetch_and_and
9589 @findex __sync_fetch_and_xor
9590 @findex __sync_fetch_and_nand
9591 These built-in functions perform the operation suggested by the name, and
9592 returns the value that had previously been in memory.  That is, operations
9593 on integer operands have the following semantics.  Operations on pointer
9594 arguments are performed as if the operands were of the @code{uintptr_t}
9595 type.  That is, they are not scaled by the size of the type to which
9596 the pointer points.
9598 @smallexample
9599 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9600 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
9601 @end smallexample
9603 The object pointed to by the first argument must be of integer or pointer
9604 type.  It must not be a boolean type.
9606 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9607 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9609 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9610 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9611 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9612 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9613 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9614 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9615 @findex __sync_add_and_fetch
9616 @findex __sync_sub_and_fetch
9617 @findex __sync_or_and_fetch
9618 @findex __sync_and_and_fetch
9619 @findex __sync_xor_and_fetch
9620 @findex __sync_nand_and_fetch
9621 These built-in functions perform the operation suggested by the name, and
9622 return the new value.  That is, operations on integer operands have
9623 the following semantics.  Operations on pointer operands are performed as
9624 if the operand's type were @code{uintptr_t}.
9626 @smallexample
9627 @{ *ptr @var{op}= value; return *ptr; @}
9628 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
9629 @end smallexample
9631 The same constraints on arguments apply as for the corresponding
9632 @code{__sync_op_and_fetch} built-in functions.
9634 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9635 as @code{*ptr = ~(*ptr & value)} instead of
9636 @code{*ptr = ~*ptr & value}.
9638 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9639 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9640 @findex __sync_bool_compare_and_swap
9641 @findex __sync_val_compare_and_swap
9642 These built-in functions perform an atomic compare and swap.
9643 That is, if the current
9644 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9645 @code{*@var{ptr}}.
9647 The ``bool'' version returns true if the comparison is successful and
9648 @var{newval} is written.  The ``val'' version returns the contents
9649 of @code{*@var{ptr}} before the operation.
9651 @item __sync_synchronize (...)
9652 @findex __sync_synchronize
9653 This built-in function issues a full memory barrier.
9655 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9656 @findex __sync_lock_test_and_set
9657 This built-in function, as described by Intel, is not a traditional test-and-set
9658 operation, but rather an atomic exchange operation.  It writes @var{value}
9659 into @code{*@var{ptr}}, and returns the previous contents of
9660 @code{*@var{ptr}}.
9662 Many targets have only minimal support for such locks, and do not support
9663 a full exchange operation.  In this case, a target may support reduced
9664 functionality here by which the @emph{only} valid value to store is the
9665 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
9666 is implementation defined.
9668 This built-in function is not a full barrier,
9669 but rather an @dfn{acquire barrier}.
9670 This means that references after the operation cannot move to (or be
9671 speculated to) before the operation, but previous memory stores may not
9672 be globally visible yet, and previous memory loads may not yet be
9673 satisfied.
9675 @item void __sync_lock_release (@var{type} *ptr, ...)
9676 @findex __sync_lock_release
9677 This built-in function releases the lock acquired by
9678 @code{__sync_lock_test_and_set}.
9679 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9681 This built-in function is not a full barrier,
9682 but rather a @dfn{release barrier}.
9683 This means that all previous memory stores are globally visible, and all
9684 previous memory loads have been satisfied, but following memory reads
9685 are not prevented from being speculated to before the barrier.
9686 @end table
9688 @node __atomic Builtins
9689 @section Built-in Functions for Memory Model Aware Atomic Operations
9691 The following built-in functions approximately match the requirements
9692 for the C++11 memory model.  They are all
9693 identified by being prefixed with @samp{__atomic} and most are
9694 overloaded so that they work with multiple types.
9696 These functions are intended to replace the legacy @samp{__sync}
9697 builtins.  The main difference is that the memory order that is requested
9698 is a parameter to the functions.  New code should always use the
9699 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9701 Note that the @samp{__atomic} builtins assume that programs will
9702 conform to the C++11 memory model.  In particular, they assume
9703 that programs are free of data races.  See the C++11 standard for
9704 detailed requirements.
9706 The @samp{__atomic} builtins can be used with any integral scalar or
9707 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
9708 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9709 supported by the architecture.
9711 The four non-arithmetic functions (load, store, exchange, and 
9712 compare_exchange) all have a generic version as well.  This generic
9713 version works on any data type.  It uses the lock-free built-in function
9714 if the specific data type size makes that possible; otherwise, an
9715 external call is left to be resolved at run time.  This external call is
9716 the same format with the addition of a @samp{size_t} parameter inserted
9717 as the first parameter indicating the size of the object being pointed to.
9718 All objects must be the same size.
9720 There are 6 different memory orders that can be specified.  These map
9721 to the C++11 memory orders with the same names, see the C++11 standard
9722 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9723 on atomic synchronization} for detailed definitions.  Individual
9724 targets may also support additional memory orders for use on specific
9725 architectures.  Refer to the target documentation for details of
9726 these.
9728 An atomic operation can both constrain code motion and
9729 be mapped to hardware instructions for synchronization between threads
9730 (e.g., a fence).  To which extent this happens is controlled by the
9731 memory orders, which are listed here in approximately ascending order of
9732 strength.  The description of each memory order is only meant to roughly
9733 illustrate the effects and is not a specification; see the C++11
9734 memory model for precise semantics.
9736 @table  @code
9737 @item __ATOMIC_RELAXED
9738 Implies no inter-thread ordering constraints.
9739 @item __ATOMIC_CONSUME
9740 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9741 memory order because of a deficiency in C++11's semantics for
9742 @code{memory_order_consume}.
9743 @item __ATOMIC_ACQUIRE
9744 Creates an inter-thread happens-before constraint from the release (or
9745 stronger) semantic store to this acquire load.  Can prevent hoisting
9746 of code to before the operation.
9747 @item __ATOMIC_RELEASE
9748 Creates an inter-thread happens-before constraint to acquire (or stronger)
9749 semantic loads that read from this release store.  Can prevent sinking
9750 of code to after the operation.
9751 @item __ATOMIC_ACQ_REL
9752 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9753 @code{__ATOMIC_RELEASE}.
9754 @item __ATOMIC_SEQ_CST
9755 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9756 @end table
9758 Note that in the C++11 memory model, @emph{fences} (e.g.,
9759 @samp{__atomic_thread_fence}) take effect in combination with other
9760 atomic operations on specific memory locations (e.g., atomic loads);
9761 operations on specific memory locations do not necessarily affect other
9762 operations in the same way.
9764 Target architectures are encouraged to provide their own patterns for
9765 each of the atomic built-in functions.  If no target is provided, the original
9766 non-memory model set of @samp{__sync} atomic built-in functions are
9767 used, along with any required synchronization fences surrounding it in
9768 order to achieve the proper behavior.  Execution in this case is subject
9769 to the same restrictions as those built-in functions.
9771 If there is no pattern or mechanism to provide a lock-free instruction
9772 sequence, a call is made to an external routine with the same parameters
9773 to be resolved at run time.
9775 When implementing patterns for these built-in functions, the memory order
9776 parameter can be ignored as long as the pattern implements the most
9777 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
9778 orders execute correctly with this memory order but they may not execute as
9779 efficiently as they could with a more appropriate implementation of the
9780 relaxed requirements.
9782 Note that the C++11 standard allows for the memory order parameter to be
9783 determined at run time rather than at compile time.  These built-in
9784 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9785 than invoke a runtime library call or inline a switch statement.  This is
9786 standard compliant, safe, and the simplest approach for now.
9788 The memory order parameter is a signed int, but only the lower 16 bits are
9789 reserved for the memory order.  The remainder of the signed int is reserved
9790 for target use and should be 0.  Use of the predefined atomic values
9791 ensures proper usage.
9793 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9794 This built-in function implements an atomic load operation.  It returns the
9795 contents of @code{*@var{ptr}}.
9797 The valid memory order variants are
9798 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9799 and @code{__ATOMIC_CONSUME}.
9801 @end deftypefn
9803 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9804 This is the generic version of an atomic load.  It returns the
9805 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9807 @end deftypefn
9809 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9810 This built-in function implements an atomic store operation.  It writes 
9811 @code{@var{val}} into @code{*@var{ptr}}.  
9813 The valid memory order variants are
9814 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9816 @end deftypefn
9818 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9819 This is the generic version of an atomic store.  It stores the value
9820 of @code{*@var{val}} into @code{*@var{ptr}}.
9822 @end deftypefn
9824 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9825 This built-in function implements an atomic exchange operation.  It writes
9826 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9827 @code{*@var{ptr}}.
9829 The valid memory order variants are
9830 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9831 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9833 @end deftypefn
9835 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9836 This is the generic version of an atomic exchange.  It stores the
9837 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9838 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9840 @end deftypefn
9842 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memorder, int failure_memorder)
9843 This built-in function implements an atomic compare and exchange operation.
9844 This compares the contents of @code{*@var{ptr}} with the contents of
9845 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9846 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
9847 equal, the operation is a @emph{read} and the current contents of
9848 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
9849 for weak compare_exchange, which may fail spuriously, and false for
9850 the strong variation, which never fails spuriously.  Many targets
9851 only offer the strong variation and ignore the parameter.  When in doubt, use
9852 the strong variation.
9854 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9855 and memory is affected according to the
9856 memory order specified by @var{success_memorder}.  There are no
9857 restrictions on what memory order can be used here.
9859 Otherwise, false is returned and memory is affected according
9860 to @var{failure_memorder}. This memory order cannot be
9861 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
9862 stronger order than that specified by @var{success_memorder}.
9864 @end deftypefn
9866 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memorder, int failure_memorder)
9867 This built-in function implements the generic version of
9868 @code{__atomic_compare_exchange}.  The function is virtually identical to
9869 @code{__atomic_compare_exchange_n}, except the desired value is also a
9870 pointer.
9872 @end deftypefn
9874 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9875 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9876 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9877 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9878 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9879 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9880 These built-in functions perform the operation suggested by the name, and
9881 return the result of the operation.  Operations on pointer arguments are
9882 performed as if the operands were of the @code{uintptr_t} type.  That is,
9883 they are not scaled by the size of the type to which the pointer points.
9885 @smallexample
9886 @{ *ptr @var{op}= val; return *ptr; @}
9887 @end smallexample
9889 The object pointed to by the first argument must be of integer or pointer
9890 type.  It must not be a boolean type.  All memory orders are valid.
9892 @end deftypefn
9894 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9895 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9896 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9897 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9898 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9899 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9900 These built-in functions perform the operation suggested by the name, and
9901 return the value that had previously been in @code{*@var{ptr}}.  Operations
9902 on pointer arguments are performed as if the operands were of
9903 the @code{uintptr_t} type.  That is, they are not scaled by the size of
9904 the type to which the pointer points.
9906 @smallexample
9907 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9908 @end smallexample
9910 The same constraints on arguments apply as for the corresponding
9911 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
9913 @end deftypefn
9915 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9917 This built-in function performs an atomic test-and-set operation on
9918 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
9919 defined nonzero ``set'' value and the return value is @code{true} if and only
9920 if the previous contents were ``set''.
9921 It should be only used for operands of type @code{bool} or @code{char}. For 
9922 other types only part of the value may be set.
9924 All memory orders are valid.
9926 @end deftypefn
9928 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9930 This built-in function performs an atomic clear operation on
9931 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
9932 It should be only used for operands of type @code{bool} or @code{char} and 
9933 in conjunction with @code{__atomic_test_and_set}.
9934 For other types it may only clear partially. If the type is not @code{bool}
9935 prefer using @code{__atomic_store}.
9937 The valid memory order variants are
9938 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9939 @code{__ATOMIC_RELEASE}.
9941 @end deftypefn
9943 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9945 This built-in function acts as a synchronization fence between threads
9946 based on the specified memory order.
9948 All memory orders are valid.
9950 @end deftypefn
9952 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9954 This built-in function acts as a synchronization fence between a thread
9955 and signal handlers based in the same thread.
9957 All memory orders are valid.
9959 @end deftypefn
9961 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
9963 This built-in function returns true if objects of @var{size} bytes always
9964 generate lock-free atomic instructions for the target architecture.
9965 @var{size} must resolve to a compile-time constant and the result also
9966 resolves to a compile-time constant.
9968 @var{ptr} is an optional pointer to the object that may be used to determine
9969 alignment.  A value of 0 indicates typical alignment should be used.  The 
9970 compiler may also ignore this parameter.
9972 @smallexample
9973 if (__atomic_always_lock_free (sizeof (long long), 0))
9974 @end smallexample
9976 @end deftypefn
9978 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9980 This built-in function returns true if objects of @var{size} bytes always
9981 generate lock-free atomic instructions for the target architecture.  If
9982 the built-in function is not known to be lock-free, a call is made to a
9983 runtime routine named @code{__atomic_is_lock_free}.
9985 @var{ptr} is an optional pointer to the object that may be used to determine
9986 alignment.  A value of 0 indicates typical alignment should be used.  The 
9987 compiler may also ignore this parameter.
9988 @end deftypefn
9990 @node Integer Overflow Builtins
9991 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9993 The following built-in functions allow performing simple arithmetic operations
9994 together with checking whether the operations overflowed.
9996 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9997 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9998 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9999 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10000 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10001 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10002 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10004 These built-in functions promote the first two operands into infinite precision signed
10005 type and perform addition on those promoted operands.  The result is then
10006 cast to the type the third pointer argument points to and stored there.
10007 If the stored result is equal to the infinite precision result, the built-in
10008 functions return false, otherwise they return true.  As the addition is
10009 performed in infinite signed precision, these built-in functions have fully defined
10010 behavior for all argument values.
10012 The first built-in function allows arbitrary integral types for operands and
10013 the result type must be pointer to some integral type other than enumerated or
10014 boolean type, the rest of the built-in functions have explicit integer types.
10016 The compiler will attempt to use hardware instructions to implement
10017 these built-in functions where possible, like conditional jump on overflow
10018 after addition, conditional jump on carry etc.
10020 @end deftypefn
10022 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10023 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10024 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10025 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10026 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10027 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10028 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10030 These built-in functions are similar to the add overflow checking built-in
10031 functions above, except they perform subtraction, subtract the second argument
10032 from the first one, instead of addition.
10034 @end deftypefn
10036 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10037 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10038 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10039 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10040 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10041 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10042 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10044 These built-in functions are similar to the add overflow checking built-in
10045 functions above, except they perform multiplication, instead of addition.
10047 @end deftypefn
10049 The following built-in functions allow checking if simple arithmetic operation
10050 would overflow.
10052 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10053 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10054 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10056 These built-in functions are similar to @code{__builtin_add_overflow},
10057 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10058 they don't store the result of the arithmetic operation anywhere and the
10059 last argument is not a pointer, but some expression with integral type other
10060 than enumerated or boolean type.
10062 The built-in functions promote the first two operands into infinite precision signed type
10063 and perform addition on those promoted operands. The result is then
10064 cast to the type of the third argument.  If the cast result is equal to the infinite
10065 precision result, the built-in functions return false, otherwise they return true.
10066 The value of the third argument is ignored, just the side-effects in the third argument
10067 are evaluated, and no integral argument promotions are performed on the last argument.
10068 If the third argument is a bit-field, the type used for the result cast has the
10069 precision and signedness of the given bit-field, rather than precision and signedness
10070 of the underlying type.
10072 For example, the following macro can be used to portably check, at
10073 compile-time, whether or not adding two constant integers will overflow,
10074 and perform the addition only when it is known to be safe and not to trigger
10075 a @option{-Woverflow} warning.
10077 @smallexample
10078 #define INT_ADD_OVERFLOW_P(a, b) \
10079    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10081 enum @{
10082     A = INT_MAX, B = 3,
10083     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10084     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10086 @end smallexample
10088 The compiler will attempt to use hardware instructions to implement
10089 these built-in functions where possible, like conditional jump on overflow
10090 after addition, conditional jump on carry etc.
10092 @end deftypefn
10094 @node x86 specific memory model extensions for transactional memory
10095 @section x86-Specific Memory Model Extensions for Transactional Memory
10097 The x86 architecture supports additional memory ordering flags
10098 to mark lock critical sections for hardware lock elision. 
10099 These must be specified in addition to an existing memory order to
10100 atomic intrinsics.
10102 @table @code
10103 @item __ATOMIC_HLE_ACQUIRE
10104 Start lock elision on a lock variable.
10105 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10106 @item __ATOMIC_HLE_RELEASE
10107 End lock elision on a lock variable.
10108 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10109 @end table
10111 When a lock acquire fails, it is required for good performance to abort
10112 the transaction quickly. This can be done with a @code{_mm_pause}.
10114 @smallexample
10115 #include <immintrin.h> // For _mm_pause
10117 int lockvar;
10119 /* Acquire lock with lock elision */
10120 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10121     _mm_pause(); /* Abort failed transaction */
10123 /* Free lock with lock elision */
10124 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10125 @end smallexample
10127 @node Object Size Checking
10128 @section Object Size Checking Built-in Functions
10129 @findex __builtin_object_size
10130 @findex __builtin___memcpy_chk
10131 @findex __builtin___mempcpy_chk
10132 @findex __builtin___memmove_chk
10133 @findex __builtin___memset_chk
10134 @findex __builtin___strcpy_chk
10135 @findex __builtin___stpcpy_chk
10136 @findex __builtin___strncpy_chk
10137 @findex __builtin___strcat_chk
10138 @findex __builtin___strncat_chk
10139 @findex __builtin___sprintf_chk
10140 @findex __builtin___snprintf_chk
10141 @findex __builtin___vsprintf_chk
10142 @findex __builtin___vsnprintf_chk
10143 @findex __builtin___printf_chk
10144 @findex __builtin___vprintf_chk
10145 @findex __builtin___fprintf_chk
10146 @findex __builtin___vfprintf_chk
10148 GCC implements a limited buffer overflow protection mechanism that can
10149 prevent some buffer overflow attacks by determining the sizes of objects
10150 into which data is about to be written and preventing the writes when
10151 the size isn't sufficient.  The built-in functions described below yield
10152 the best results when used together and when optimization is enabled.
10153 For example, to detect object sizes across function boundaries or to
10154 follow pointer assignments through non-trivial control flow they rely
10155 on various optimization passes enabled with @option{-O2}.  However, to
10156 a limited extent, they can be used without optimization as well.
10158 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10159 is a built-in construct that returns a constant number of bytes from
10160 @var{ptr} to the end of the object @var{ptr} pointer points to
10161 (if known at compile time).  @code{__builtin_object_size} never evaluates
10162 its arguments for side-effects.  If there are any side-effects in them, it
10163 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10164 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10165 point to and all of them are known at compile time, the returned number
10166 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10167 0 and minimum if nonzero.  If it is not possible to determine which objects
10168 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10169 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10170 for @var{type} 2 or 3.
10172 @var{type} is an integer constant from 0 to 3.  If the least significant
10173 bit is clear, objects are whole variables, if it is set, a closest
10174 surrounding subobject is considered the object a pointer points to.
10175 The second bit determines if maximum or minimum of remaining bytes
10176 is computed.
10178 @smallexample
10179 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10180 char *p = &var.buf1[1], *q = &var.b;
10182 /* Here the object p points to is var.  */
10183 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10184 /* The subobject p points to is var.buf1.  */
10185 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10186 /* The object q points to is var.  */
10187 assert (__builtin_object_size (q, 0)
10188         == (char *) (&var + 1) - (char *) &var.b);
10189 /* The subobject q points to is var.b.  */
10190 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10191 @end smallexample
10192 @end deftypefn
10194 There are built-in functions added for many common string operation
10195 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10196 built-in is provided.  This built-in has an additional last argument,
10197 which is the number of bytes remaining in object the @var{dest}
10198 argument points to or @code{(size_t) -1} if the size is not known.
10200 The built-in functions are optimized into the normal string functions
10201 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10202 it is known at compile time that the destination object will not
10203 be overflown.  If the compiler can determine at compile time the
10204 object will be always overflown, it issues a warning.
10206 The intended use can be e.g.@:
10208 @smallexample
10209 #undef memcpy
10210 #define bos0(dest) __builtin_object_size (dest, 0)
10211 #define memcpy(dest, src, n) \
10212   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10214 char *volatile p;
10215 char buf[10];
10216 /* It is unknown what object p points to, so this is optimized
10217    into plain memcpy - no checking is possible.  */
10218 memcpy (p, "abcde", n);
10219 /* Destination is known and length too.  It is known at compile
10220    time there will be no overflow.  */
10221 memcpy (&buf[5], "abcde", 5);
10222 /* Destination is known, but the length is not known at compile time.
10223    This will result in __memcpy_chk call that can check for overflow
10224    at run time.  */
10225 memcpy (&buf[5], "abcde", n);
10226 /* Destination is known and it is known at compile time there will
10227    be overflow.  There will be a warning and __memcpy_chk call that
10228    will abort the program at run time.  */
10229 memcpy (&buf[6], "abcde", 5);
10230 @end smallexample
10232 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10233 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10234 @code{strcat} and @code{strncat}.
10236 There are also checking built-in functions for formatted output functions.
10237 @smallexample
10238 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10239 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10240                               const char *fmt, ...);
10241 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10242                               va_list ap);
10243 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10244                                const char *fmt, va_list ap);
10245 @end smallexample
10247 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10248 etc.@: functions and can contain implementation specific flags on what
10249 additional security measures the checking function might take, such as
10250 handling @code{%n} differently.
10252 The @var{os} argument is the object size @var{s} points to, like in the
10253 other built-in functions.  There is a small difference in the behavior
10254 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10255 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10256 the checking function is called with @var{os} argument set to
10257 @code{(size_t) -1}.
10259 In addition to this, there are checking built-in functions
10260 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10261 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10262 These have just one additional argument, @var{flag}, right before
10263 format string @var{fmt}.  If the compiler is able to optimize them to
10264 @code{fputc} etc.@: functions, it does, otherwise the checking function
10265 is called and the @var{flag} argument passed to it.
10267 @node Pointer Bounds Checker builtins
10268 @section Pointer Bounds Checker Built-in Functions
10269 @cindex Pointer Bounds Checker builtins
10270 @findex __builtin___bnd_set_ptr_bounds
10271 @findex __builtin___bnd_narrow_ptr_bounds
10272 @findex __builtin___bnd_copy_ptr_bounds
10273 @findex __builtin___bnd_init_ptr_bounds
10274 @findex __builtin___bnd_null_ptr_bounds
10275 @findex __builtin___bnd_store_ptr_bounds
10276 @findex __builtin___bnd_chk_ptr_lbounds
10277 @findex __builtin___bnd_chk_ptr_ubounds
10278 @findex __builtin___bnd_chk_ptr_bounds
10279 @findex __builtin___bnd_get_ptr_lbound
10280 @findex __builtin___bnd_get_ptr_ubound
10282 GCC provides a set of built-in functions to control Pointer Bounds Checker
10283 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10284 even if you compile with Pointer Bounds Checker off
10285 (@option{-fno-check-pointer-bounds}).
10286 The behavior may differ in such case as documented below.
10288 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10290 This built-in function returns a new pointer with the value of @var{q}, and
10291 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10292 Bounds Checker off, the built-in function just returns the first argument.
10294 @smallexample
10295 extern void *__wrap_malloc (size_t n)
10297   void *p = (void *)__real_malloc (n);
10298   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10299   return __builtin___bnd_set_ptr_bounds (p, n);
10301 @end smallexample
10303 @end deftypefn
10305 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10307 This built-in function returns a new pointer with the value of @var{p}
10308 and associates it with the narrowed bounds formed by the intersection
10309 of bounds associated with @var{q} and the bounds
10310 [@var{p}, @var{p} + @var{size} - 1].
10311 With Pointer Bounds Checker off, the built-in function just returns the first
10312 argument.
10314 @smallexample
10315 void init_objects (object *objs, size_t size)
10317   size_t i;
10318   /* Initialize objects one-by-one passing pointers with bounds of 
10319      an object, not the full array of objects.  */
10320   for (i = 0; i < size; i++)
10321     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10322                                                     sizeof(object)));
10324 @end smallexample
10326 @end deftypefn
10328 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10330 This built-in function returns a new pointer with the value of @var{q},
10331 and associates it with the bounds already associated with pointer @var{r}.
10332 With Pointer Bounds Checker off, the built-in function just returns the first
10333 argument.
10335 @smallexample
10336 /* Here is a way to get pointer to object's field but
10337    still with the full object's bounds.  */
10338 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10339                                                   objptr);
10340 @end smallexample
10342 @end deftypefn
10344 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10346 This built-in function returns a new pointer with the value of @var{q}, and
10347 associates it with INIT (allowing full memory access) bounds. With Pointer
10348 Bounds Checker off, the built-in function just returns the first argument.
10350 @end deftypefn
10352 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10354 This built-in function returns a new pointer with the value of @var{q}, and
10355 associates it with NULL (allowing no memory access) bounds. With Pointer
10356 Bounds Checker off, the built-in function just returns the first argument.
10358 @end deftypefn
10360 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10362 This built-in function stores the bounds associated with pointer @var{ptr_val}
10363 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10364 bounds from legacy code without touching the associated pointer's memory when
10365 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10366 function call is ignored.
10368 @end deftypefn
10370 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10372 This built-in function checks if the pointer @var{q} is within the lower
10373 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10374 function call is ignored.
10376 @smallexample
10377 extern void *__wrap_memset (void *dst, int c, size_t len)
10379   if (len > 0)
10380     @{
10381       __builtin___bnd_chk_ptr_lbounds (dst);
10382       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10383       __real_memset (dst, c, len);
10384     @}
10385   return dst;
10387 @end smallexample
10389 @end deftypefn
10391 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10393 This built-in function checks if the pointer @var{q} is within the upper
10394 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10395 function call is ignored.
10397 @end deftypefn
10399 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10401 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10402 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
10403 off, the built-in function call is ignored.
10405 @smallexample
10406 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10408   if (n > 0)
10409     @{
10410       __bnd_chk_ptr_bounds (dst, n);
10411       __bnd_chk_ptr_bounds (src, n);
10412       __real_memcpy (dst, src, n);
10413     @}
10414   return dst;
10416 @end smallexample
10418 @end deftypefn
10420 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10422 This built-in function returns the lower bound associated
10423 with the pointer @var{q}, as a pointer value.  
10424 This is useful for debugging using @code{printf}.
10425 With Pointer Bounds Checker off, the built-in function returns 0.
10427 @smallexample
10428 void *lb = __builtin___bnd_get_ptr_lbound (q);
10429 void *ub = __builtin___bnd_get_ptr_ubound (q);
10430 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
10431 @end smallexample
10433 @end deftypefn
10435 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10437 This built-in function returns the upper bound (which is a pointer) associated
10438 with the pointer @var{q}.  With Pointer Bounds Checker off,
10439 the built-in function returns -1.
10441 @end deftypefn
10443 @node Cilk Plus Builtins
10444 @section Cilk Plus C/C++ Language Extension Built-in Functions
10446 GCC provides support for the following built-in reduction functions if Cilk Plus
10447 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10449 @itemize @bullet
10450 @item @code{__sec_implicit_index}
10451 @item @code{__sec_reduce}
10452 @item @code{__sec_reduce_add}
10453 @item @code{__sec_reduce_all_nonzero}
10454 @item @code{__sec_reduce_all_zero}
10455 @item @code{__sec_reduce_any_nonzero}
10456 @item @code{__sec_reduce_any_zero}
10457 @item @code{__sec_reduce_max}
10458 @item @code{__sec_reduce_min}
10459 @item @code{__sec_reduce_max_ind}
10460 @item @code{__sec_reduce_min_ind}
10461 @item @code{__sec_reduce_mul}
10462 @item @code{__sec_reduce_mutating}
10463 @end itemize
10465 Further details and examples about these built-in functions are described 
10466 in the Cilk Plus language manual which can be found at 
10467 @uref{https://www.cilkplus.org}.
10469 @node Other Builtins
10470 @section Other Built-in Functions Provided by GCC
10471 @cindex built-in functions
10472 @findex __builtin_alloca
10473 @findex __builtin_alloca_with_align
10474 @findex __builtin_call_with_static_chain
10475 @findex __builtin_fpclassify
10476 @findex __builtin_isfinite
10477 @findex __builtin_isnormal
10478 @findex __builtin_isgreater
10479 @findex __builtin_isgreaterequal
10480 @findex __builtin_isinf_sign
10481 @findex __builtin_isless
10482 @findex __builtin_islessequal
10483 @findex __builtin_islessgreater
10484 @findex __builtin_isunordered
10485 @findex __builtin_powi
10486 @findex __builtin_powif
10487 @findex __builtin_powil
10488 @findex _Exit
10489 @findex _exit
10490 @findex abort
10491 @findex abs
10492 @findex acos
10493 @findex acosf
10494 @findex acosh
10495 @findex acoshf
10496 @findex acoshl
10497 @findex acosl
10498 @findex alloca
10499 @findex asin
10500 @findex asinf
10501 @findex asinh
10502 @findex asinhf
10503 @findex asinhl
10504 @findex asinl
10505 @findex atan
10506 @findex atan2
10507 @findex atan2f
10508 @findex atan2l
10509 @findex atanf
10510 @findex atanh
10511 @findex atanhf
10512 @findex atanhl
10513 @findex atanl
10514 @findex bcmp
10515 @findex bzero
10516 @findex cabs
10517 @findex cabsf
10518 @findex cabsl
10519 @findex cacos
10520 @findex cacosf
10521 @findex cacosh
10522 @findex cacoshf
10523 @findex cacoshl
10524 @findex cacosl
10525 @findex calloc
10526 @findex carg
10527 @findex cargf
10528 @findex cargl
10529 @findex casin
10530 @findex casinf
10531 @findex casinh
10532 @findex casinhf
10533 @findex casinhl
10534 @findex casinl
10535 @findex catan
10536 @findex catanf
10537 @findex catanh
10538 @findex catanhf
10539 @findex catanhl
10540 @findex catanl
10541 @findex cbrt
10542 @findex cbrtf
10543 @findex cbrtl
10544 @findex ccos
10545 @findex ccosf
10546 @findex ccosh
10547 @findex ccoshf
10548 @findex ccoshl
10549 @findex ccosl
10550 @findex ceil
10551 @findex ceilf
10552 @findex ceill
10553 @findex cexp
10554 @findex cexpf
10555 @findex cexpl
10556 @findex cimag
10557 @findex cimagf
10558 @findex cimagl
10559 @findex clog
10560 @findex clogf
10561 @findex clogl
10562 @findex clog10
10563 @findex clog10f
10564 @findex clog10l
10565 @findex conj
10566 @findex conjf
10567 @findex conjl
10568 @findex copysign
10569 @findex copysignf
10570 @findex copysignl
10571 @findex cos
10572 @findex cosf
10573 @findex cosh
10574 @findex coshf
10575 @findex coshl
10576 @findex cosl
10577 @findex cpow
10578 @findex cpowf
10579 @findex cpowl
10580 @findex cproj
10581 @findex cprojf
10582 @findex cprojl
10583 @findex creal
10584 @findex crealf
10585 @findex creall
10586 @findex csin
10587 @findex csinf
10588 @findex csinh
10589 @findex csinhf
10590 @findex csinhl
10591 @findex csinl
10592 @findex csqrt
10593 @findex csqrtf
10594 @findex csqrtl
10595 @findex ctan
10596 @findex ctanf
10597 @findex ctanh
10598 @findex ctanhf
10599 @findex ctanhl
10600 @findex ctanl
10601 @findex dcgettext
10602 @findex dgettext
10603 @findex drem
10604 @findex dremf
10605 @findex dreml
10606 @findex erf
10607 @findex erfc
10608 @findex erfcf
10609 @findex erfcl
10610 @findex erff
10611 @findex erfl
10612 @findex exit
10613 @findex exp
10614 @findex exp10
10615 @findex exp10f
10616 @findex exp10l
10617 @findex exp2
10618 @findex exp2f
10619 @findex exp2l
10620 @findex expf
10621 @findex expl
10622 @findex expm1
10623 @findex expm1f
10624 @findex expm1l
10625 @findex fabs
10626 @findex fabsf
10627 @findex fabsl
10628 @findex fdim
10629 @findex fdimf
10630 @findex fdiml
10631 @findex ffs
10632 @findex floor
10633 @findex floorf
10634 @findex floorl
10635 @findex fma
10636 @findex fmaf
10637 @findex fmal
10638 @findex fmax
10639 @findex fmaxf
10640 @findex fmaxl
10641 @findex fmin
10642 @findex fminf
10643 @findex fminl
10644 @findex fmod
10645 @findex fmodf
10646 @findex fmodl
10647 @findex fprintf
10648 @findex fprintf_unlocked
10649 @findex fputs
10650 @findex fputs_unlocked
10651 @findex frexp
10652 @findex frexpf
10653 @findex frexpl
10654 @findex fscanf
10655 @findex gamma
10656 @findex gammaf
10657 @findex gammal
10658 @findex gamma_r
10659 @findex gammaf_r
10660 @findex gammal_r
10661 @findex gettext
10662 @findex hypot
10663 @findex hypotf
10664 @findex hypotl
10665 @findex ilogb
10666 @findex ilogbf
10667 @findex ilogbl
10668 @findex imaxabs
10669 @findex index
10670 @findex isalnum
10671 @findex isalpha
10672 @findex isascii
10673 @findex isblank
10674 @findex iscntrl
10675 @findex isdigit
10676 @findex isgraph
10677 @findex islower
10678 @findex isprint
10679 @findex ispunct
10680 @findex isspace
10681 @findex isupper
10682 @findex iswalnum
10683 @findex iswalpha
10684 @findex iswblank
10685 @findex iswcntrl
10686 @findex iswdigit
10687 @findex iswgraph
10688 @findex iswlower
10689 @findex iswprint
10690 @findex iswpunct
10691 @findex iswspace
10692 @findex iswupper
10693 @findex iswxdigit
10694 @findex isxdigit
10695 @findex j0
10696 @findex j0f
10697 @findex j0l
10698 @findex j1
10699 @findex j1f
10700 @findex j1l
10701 @findex jn
10702 @findex jnf
10703 @findex jnl
10704 @findex labs
10705 @findex ldexp
10706 @findex ldexpf
10707 @findex ldexpl
10708 @findex lgamma
10709 @findex lgammaf
10710 @findex lgammal
10711 @findex lgamma_r
10712 @findex lgammaf_r
10713 @findex lgammal_r
10714 @findex llabs
10715 @findex llrint
10716 @findex llrintf
10717 @findex llrintl
10718 @findex llround
10719 @findex llroundf
10720 @findex llroundl
10721 @findex log
10722 @findex log10
10723 @findex log10f
10724 @findex log10l
10725 @findex log1p
10726 @findex log1pf
10727 @findex log1pl
10728 @findex log2
10729 @findex log2f
10730 @findex log2l
10731 @findex logb
10732 @findex logbf
10733 @findex logbl
10734 @findex logf
10735 @findex logl
10736 @findex lrint
10737 @findex lrintf
10738 @findex lrintl
10739 @findex lround
10740 @findex lroundf
10741 @findex lroundl
10742 @findex malloc
10743 @findex memchr
10744 @findex memcmp
10745 @findex memcpy
10746 @findex mempcpy
10747 @findex memset
10748 @findex modf
10749 @findex modff
10750 @findex modfl
10751 @findex nearbyint
10752 @findex nearbyintf
10753 @findex nearbyintl
10754 @findex nextafter
10755 @findex nextafterf
10756 @findex nextafterl
10757 @findex nexttoward
10758 @findex nexttowardf
10759 @findex nexttowardl
10760 @findex pow
10761 @findex pow10
10762 @findex pow10f
10763 @findex pow10l
10764 @findex powf
10765 @findex powl
10766 @findex printf
10767 @findex printf_unlocked
10768 @findex putchar
10769 @findex puts
10770 @findex remainder
10771 @findex remainderf
10772 @findex remainderl
10773 @findex remquo
10774 @findex remquof
10775 @findex remquol
10776 @findex rindex
10777 @findex rint
10778 @findex rintf
10779 @findex rintl
10780 @findex round
10781 @findex roundf
10782 @findex roundl
10783 @findex scalb
10784 @findex scalbf
10785 @findex scalbl
10786 @findex scalbln
10787 @findex scalblnf
10788 @findex scalblnf
10789 @findex scalbn
10790 @findex scalbnf
10791 @findex scanfnl
10792 @findex signbit
10793 @findex signbitf
10794 @findex signbitl
10795 @findex signbitd32
10796 @findex signbitd64
10797 @findex signbitd128
10798 @findex significand
10799 @findex significandf
10800 @findex significandl
10801 @findex sin
10802 @findex sincos
10803 @findex sincosf
10804 @findex sincosl
10805 @findex sinf
10806 @findex sinh
10807 @findex sinhf
10808 @findex sinhl
10809 @findex sinl
10810 @findex snprintf
10811 @findex sprintf
10812 @findex sqrt
10813 @findex sqrtf
10814 @findex sqrtl
10815 @findex sscanf
10816 @findex stpcpy
10817 @findex stpncpy
10818 @findex strcasecmp
10819 @findex strcat
10820 @findex strchr
10821 @findex strcmp
10822 @findex strcpy
10823 @findex strcspn
10824 @findex strdup
10825 @findex strfmon
10826 @findex strftime
10827 @findex strlen
10828 @findex strncasecmp
10829 @findex strncat
10830 @findex strncmp
10831 @findex strncpy
10832 @findex strndup
10833 @findex strpbrk
10834 @findex strrchr
10835 @findex strspn
10836 @findex strstr
10837 @findex tan
10838 @findex tanf
10839 @findex tanh
10840 @findex tanhf
10841 @findex tanhl
10842 @findex tanl
10843 @findex tgamma
10844 @findex tgammaf
10845 @findex tgammal
10846 @findex toascii
10847 @findex tolower
10848 @findex toupper
10849 @findex towlower
10850 @findex towupper
10851 @findex trunc
10852 @findex truncf
10853 @findex truncl
10854 @findex vfprintf
10855 @findex vfscanf
10856 @findex vprintf
10857 @findex vscanf
10858 @findex vsnprintf
10859 @findex vsprintf
10860 @findex vsscanf
10861 @findex y0
10862 @findex y0f
10863 @findex y0l
10864 @findex y1
10865 @findex y1f
10866 @findex y1l
10867 @findex yn
10868 @findex ynf
10869 @findex ynl
10871 GCC provides a large number of built-in functions other than the ones
10872 mentioned above.  Some of these are for internal use in the processing
10873 of exceptions or variable-length argument lists and are not
10874 documented here because they may change from time to time; we do not
10875 recommend general use of these functions.
10877 The remaining functions are provided for optimization purposes.
10879 With the exception of built-ins that have library equivalents such as
10880 the standard C library functions discussed below, or that expand to
10881 library calls, GCC built-in functions are always expanded inline and
10882 thus do not have corresponding entry points and their address cannot
10883 be obtained.  Attempting to use them in an expression other than
10884 a function call results in a compile-time error.
10886 @opindex fno-builtin
10887 GCC includes built-in versions of many of the functions in the standard
10888 C library.  These functions come in two forms: one whose names start with
10889 the @code{__builtin_} prefix, and the other without.  Both forms have the
10890 same type (including prototype), the same address (when their address is
10891 taken), and the same meaning as the C library functions even if you specify
10892 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
10893 functions are only optimized in certain cases; if they are not optimized in
10894 a particular case, a call to the library function is emitted.
10896 @opindex ansi
10897 @opindex std
10898 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10899 @option{-std=c99} or @option{-std=c11}), the functions
10900 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10901 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10902 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10903 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10904 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10905 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10906 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10907 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10908 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10909 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10910 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10911 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10912 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10913 @code{significandl}, @code{significand}, @code{sincosf},
10914 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10915 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10916 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10917 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10918 @code{yn}
10919 may be handled as built-in functions.
10920 All these functions have corresponding versions
10921 prefixed with @code{__builtin_}, which may be used even in strict C90
10922 mode.
10924 The ISO C99 functions
10925 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10926 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10927 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10928 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10929 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10930 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10931 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10932 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10933 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10934 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10935 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10936 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10937 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10938 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10939 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10940 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10941 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10942 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10943 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10944 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10945 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10946 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10947 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10948 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10949 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10950 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10951 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10952 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10953 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10954 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10955 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10956 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10957 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10958 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10959 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10960 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10961 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10962 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10963 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10964 are handled as built-in functions
10965 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10967 There are also built-in versions of the ISO C99 functions
10968 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10969 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10970 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10971 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10972 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10973 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10974 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10975 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10976 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10977 that are recognized in any mode since ISO C90 reserves these names for
10978 the purpose to which ISO C99 puts them.  All these functions have
10979 corresponding versions prefixed with @code{__builtin_}.
10981 There are also built-in functions @code{__builtin_fabsf@var{n}},
10982 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
10983 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
10984 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
10985 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
10986 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
10988 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10989 @code{clog10l} which names are reserved by ISO C99 for future use.
10990 All these functions have versions prefixed with @code{__builtin_}.
10992 The ISO C94 functions
10993 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10994 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10995 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10996 @code{towupper}
10997 are handled as built-in functions
10998 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11000 The ISO C90 functions
11001 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11002 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11003 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11004 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11005 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11006 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11007 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11008 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11009 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11010 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11011 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11012 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11013 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11014 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11015 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11016 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11017 are all recognized as built-in functions unless
11018 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11019 is specified for an individual function).  All of these functions have
11020 corresponding versions prefixed with @code{__builtin_}.
11022 GCC provides built-in versions of the ISO C99 floating-point comparison
11023 macros that avoid raising exceptions for unordered operands.  They have
11024 the same names as the standard macros ( @code{isgreater},
11025 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11026 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11027 prefixed.  We intend for a library implementor to be able to simply
11028 @code{#define} each standard macro to its built-in equivalent.
11029 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11030 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11031 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11032 built-in functions appear both with and without the @code{__builtin_} prefix.
11034 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11035 The @code{__builtin_alloca} function must be called at block scope.
11036 The function allocates an object @var{size} bytes large on the stack
11037 of the calling function.  The object is aligned on the default stack
11038 alignment boundary for the target determined by the
11039 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11040 function returns a pointer to the first byte of the allocated object.
11041 The lifetime of the allocated object ends just before the calling
11042 function returns to its caller.   This is so even when
11043 @code{__builtin_alloca} is called within a nested block.
11045 For example, the following function allocates eight objects of @code{n}
11046 bytes each on the stack, storing a pointer to each in consecutive elements
11047 of the array @code{a}.  It then passes the array to function @code{g}
11048 which can safely use the storage pointed to by each of the array elements.
11050 @smallexample
11051 void f (unsigned n)
11053   void *a [8];
11054   for (int i = 0; i != 8; ++i)
11055     a [i] = __builtin_alloca (n);
11057   g (a, n);   // @r{safe}
11059 @end smallexample
11061 Since the @code{__builtin_alloca} function doesn't validate its argument
11062 it is the responsibility of its caller to make sure the argument doesn't
11063 cause it to exceed the stack size limit.
11064 The @code{__builtin_alloca} function is provided to make it possible to
11065 allocate on the stack arrays of bytes with an upper bound that may be
11066 computed at run time.  Since C99 Variable Length Arrays offer
11067 similar functionality under a portable, more convenient, and safer
11068 interface they are recommended instead, in both C99 and C++ programs
11069 where GCC provides them as an extension.
11070 @xref{Variable Length}, for details.
11072 @end deftypefn
11074 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11075 The @code{__builtin_alloca_with_align} function must be called at block
11076 scope.  The function allocates an object @var{size} bytes large on
11077 the stack of the calling function.  The allocated object is aligned on
11078 the boundary specified by the argument @var{alignment} whose unit is given
11079 in bits (not bytes).  The @var{size} argument must be positive and not
11080 exceed the stack size limit.  The @var{alignment} argument must be a constant
11081 integer expression that evaluates to a power of 2 greater than or equal to
11082 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11083 with other values are rejected with an error indicating the valid bounds.
11084 The function returns a pointer to the first byte of the allocated object.
11085 The lifetime of the allocated object ends at the end of the block in which
11086 the function was called.  The allocated storage is released no later than
11087 just before the calling function returns to its caller, but may be released
11088 at the end of the block in which the function was called.
11090 For example, in the following function the call to @code{g} is unsafe
11091 because when @code{overalign} is non-zero, the space allocated by
11092 @code{__builtin_alloca_with_align} may have been released at the end
11093 of the @code{if} statement in which it was called.
11095 @smallexample
11096 void f (unsigned n, bool overalign)
11098   void *p;
11099   if (overalign)
11100     p = __builtin_alloca_with_align (n, 64 /* bits */);
11101   else
11102     p = __builtin_alloc (n);
11104   g (p, n);   // @r{unsafe}
11106 @end smallexample
11108 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11109 @var{size} argument it is the responsibility of its caller to make sure
11110 the argument doesn't cause it to exceed the stack size limit.
11111 The @code{__builtin_alloca_with_align} function is provided to make
11112 it possible to allocate on the stack overaligned arrays of bytes with
11113 an upper bound that may be computed at run time.  Since C99
11114 Variable Length Arrays offer the same functionality under
11115 a portable, more convenient, and safer interface they are recommended
11116 instead, in both C99 and C++ programs where GCC provides them as
11117 an extension.  @xref{Variable Length}, for details.
11119 @end deftypefn
11121 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11123 You can use the built-in function @code{__builtin_types_compatible_p} to
11124 determine whether two types are the same.
11126 This built-in function returns 1 if the unqualified versions of the
11127 types @var{type1} and @var{type2} (which are types, not expressions) are
11128 compatible, 0 otherwise.  The result of this built-in function can be
11129 used in integer constant expressions.
11131 This built-in function ignores top level qualifiers (e.g., @code{const},
11132 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11133 int}.
11135 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11136 hand, @code{int} and @code{char *} are not compatible, even if the size
11137 of their types, on the particular architecture are the same.  Also, the
11138 amount of pointer indirection is taken into account when determining
11139 similarity.  Consequently, @code{short *} is not similar to
11140 @code{short **}.  Furthermore, two types that are typedefed are
11141 considered compatible if their underlying types are compatible.
11143 An @code{enum} type is not considered to be compatible with another
11144 @code{enum} type even if both are compatible with the same integer
11145 type; this is what the C standard specifies.
11146 For example, @code{enum @{foo, bar@}} is not similar to
11147 @code{enum @{hot, dog@}}.
11149 You typically use this function in code whose execution varies
11150 depending on the arguments' types.  For example:
11152 @smallexample
11153 #define foo(x)                                                  \
11154   (@{                                                           \
11155     typeof (x) tmp = (x);                                       \
11156     if (__builtin_types_compatible_p (typeof (x), long double)) \
11157       tmp = foo_long_double (tmp);                              \
11158     else if (__builtin_types_compatible_p (typeof (x), double)) \
11159       tmp = foo_double (tmp);                                   \
11160     else if (__builtin_types_compatible_p (typeof (x), float))  \
11161       tmp = foo_float (tmp);                                    \
11162     else                                                        \
11163       abort ();                                                 \
11164     tmp;                                                        \
11165   @})
11166 @end smallexample
11168 @emph{Note:} This construct is only available for C@.
11170 @end deftypefn
11172 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11174 The @var{call_exp} expression must be a function call, and the
11175 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11176 is passed to the function call in the target's static chain location.
11177 The result of builtin is the result of the function call.
11179 @emph{Note:} This builtin is only available for C@.
11180 This builtin can be used to call Go closures from C.
11182 @end deftypefn
11184 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11186 You can use the built-in function @code{__builtin_choose_expr} to
11187 evaluate code depending on the value of a constant expression.  This
11188 built-in function returns @var{exp1} if @var{const_exp}, which is an
11189 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11191 This built-in function is analogous to the @samp{? :} operator in C,
11192 except that the expression returned has its type unaltered by promotion
11193 rules.  Also, the built-in function does not evaluate the expression
11194 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11195 @var{exp2} is not evaluated even if it has side-effects.
11197 This built-in function can return an lvalue if the chosen argument is an
11198 lvalue.
11200 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11201 type.  Similarly, if @var{exp2} is returned, its return type is the same
11202 as @var{exp2}.
11204 Example:
11206 @smallexample
11207 #define foo(x)                                                    \
11208   __builtin_choose_expr (                                         \
11209     __builtin_types_compatible_p (typeof (x), double),            \
11210     foo_double (x),                                               \
11211     __builtin_choose_expr (                                       \
11212       __builtin_types_compatible_p (typeof (x), float),           \
11213       foo_float (x),                                              \
11214       /* @r{The void expression results in a compile-time error}  \
11215          @r{when assigning the result to something.}  */          \
11216       (void)0))
11217 @end smallexample
11219 @emph{Note:} This construct is only available for C@.  Furthermore, the
11220 unused expression (@var{exp1} or @var{exp2} depending on the value of
11221 @var{const_exp}) may still generate syntax errors.  This may change in
11222 future revisions.
11224 @end deftypefn
11226 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11228 The built-in function @code{__builtin_complex} is provided for use in
11229 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11230 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11231 real binary floating-point type, and the result has the corresponding
11232 complex type with real and imaginary parts @var{real} and @var{imag}.
11233 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11234 infinities, NaNs and negative zeros are involved.
11236 @end deftypefn
11238 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11239 You can use the built-in function @code{__builtin_constant_p} to
11240 determine if a value is known to be constant at compile time and hence
11241 that GCC can perform constant-folding on expressions involving that
11242 value.  The argument of the function is the value to test.  The function
11243 returns the integer 1 if the argument is known to be a compile-time
11244 constant and 0 if it is not known to be a compile-time constant.  A
11245 return of 0 does not indicate that the value is @emph{not} a constant,
11246 but merely that GCC cannot prove it is a constant with the specified
11247 value of the @option{-O} option.
11249 You typically use this function in an embedded application where
11250 memory is a critical resource.  If you have some complex calculation,
11251 you may want it to be folded if it involves constants, but need to call
11252 a function if it does not.  For example:
11254 @smallexample
11255 #define Scale_Value(X)      \
11256   (__builtin_constant_p (X) \
11257   ? ((X) * SCALE + OFFSET) : Scale (X))
11258 @end smallexample
11260 You may use this built-in function in either a macro or an inline
11261 function.  However, if you use it in an inlined function and pass an
11262 argument of the function as the argument to the built-in, GCC 
11263 never returns 1 when you call the inline function with a string constant
11264 or compound literal (@pxref{Compound Literals}) and does not return 1
11265 when you pass a constant numeric value to the inline function unless you
11266 specify the @option{-O} option.
11268 You may also use @code{__builtin_constant_p} in initializers for static
11269 data.  For instance, you can write
11271 @smallexample
11272 static const int table[] = @{
11273    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11274    /* @r{@dots{}} */
11276 @end smallexample
11278 @noindent
11279 This is an acceptable initializer even if @var{EXPRESSION} is not a
11280 constant expression, including the case where
11281 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11282 folded to a constant but @var{EXPRESSION} contains operands that are
11283 not otherwise permitted in a static initializer (for example,
11284 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11285 built-in in this case, because it has no opportunity to perform
11286 optimization.
11287 @end deftypefn
11289 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11290 @opindex fprofile-arcs
11291 You may use @code{__builtin_expect} to provide the compiler with
11292 branch prediction information.  In general, you should prefer to
11293 use actual profile feedback for this (@option{-fprofile-arcs}), as
11294 programmers are notoriously bad at predicting how their programs
11295 actually perform.  However, there are applications in which this
11296 data is hard to collect.
11298 The return value is the value of @var{exp}, which should be an integral
11299 expression.  The semantics of the built-in are that it is expected that
11300 @var{exp} == @var{c}.  For example:
11302 @smallexample
11303 if (__builtin_expect (x, 0))
11304   foo ();
11305 @end smallexample
11307 @noindent
11308 indicates that we do not expect to call @code{foo}, since
11309 we expect @code{x} to be zero.  Since you are limited to integral
11310 expressions for @var{exp}, you should use constructions such as
11312 @smallexample
11313 if (__builtin_expect (ptr != NULL, 1))
11314   foo (*ptr);
11315 @end smallexample
11317 @noindent
11318 when testing pointer or floating-point values.
11319 @end deftypefn
11321 @deftypefn {Built-in Function} void __builtin_trap (void)
11322 This function causes the program to exit abnormally.  GCC implements
11323 this function by using a target-dependent mechanism (such as
11324 intentionally executing an illegal instruction) or by calling
11325 @code{abort}.  The mechanism used may vary from release to release so
11326 you should not rely on any particular implementation.
11327 @end deftypefn
11329 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11330 If control flow reaches the point of the @code{__builtin_unreachable},
11331 the program is undefined.  It is useful in situations where the
11332 compiler cannot deduce the unreachability of the code.
11334 One such case is immediately following an @code{asm} statement that
11335 either never terminates, or one that transfers control elsewhere
11336 and never returns.  In this example, without the
11337 @code{__builtin_unreachable}, GCC issues a warning that control
11338 reaches the end of a non-void function.  It also generates code
11339 to return after the @code{asm}.
11341 @smallexample
11342 int f (int c, int v)
11344   if (c)
11345     @{
11346       return v;
11347     @}
11348   else
11349     @{
11350       asm("jmp error_handler");
11351       __builtin_unreachable ();
11352     @}
11354 @end smallexample
11356 @noindent
11357 Because the @code{asm} statement unconditionally transfers control out
11358 of the function, control never reaches the end of the function
11359 body.  The @code{__builtin_unreachable} is in fact unreachable and
11360 communicates this fact to the compiler.
11362 Another use for @code{__builtin_unreachable} is following a call a
11363 function that never returns but that is not declared
11364 @code{__attribute__((noreturn))}, as in this example:
11366 @smallexample
11367 void function_that_never_returns (void);
11369 int g (int c)
11371   if (c)
11372     @{
11373       return 1;
11374     @}
11375   else
11376     @{
11377       function_that_never_returns ();
11378       __builtin_unreachable ();
11379     @}
11381 @end smallexample
11383 @end deftypefn
11385 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11386 This function returns its first argument, and allows the compiler
11387 to assume that the returned pointer is at least @var{align} bytes
11388 aligned.  This built-in can have either two or three arguments,
11389 if it has three, the third argument should have integer type, and
11390 if it is nonzero means misalignment offset.  For example:
11392 @smallexample
11393 void *x = __builtin_assume_aligned (arg, 16);
11394 @end smallexample
11396 @noindent
11397 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11398 16-byte aligned, while:
11400 @smallexample
11401 void *x = __builtin_assume_aligned (arg, 32, 8);
11402 @end smallexample
11404 @noindent
11405 means that the compiler can assume for @code{x}, set to @code{arg}, that
11406 @code{(char *) x - 8} is 32-byte aligned.
11407 @end deftypefn
11409 @deftypefn {Built-in Function} int __builtin_LINE ()
11410 This function is the equivalent of the preprocessor @code{__LINE__}
11411 macro and returns a constant integer expression that evaluates to
11412 the line number of the invocation of the built-in.  When used as a C++
11413 default argument for a function @var{F}, it returns the line number
11414 of the call to @var{F}.
11415 @end deftypefn
11417 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11418 This function is the equivalent of the @code{__FUNCTION__} symbol
11419 and returns an address constant pointing to the name of the function
11420 from which the built-in was invoked, or the empty string if
11421 the invocation is not at function scope.  When used as a C++ default
11422 argument for a function @var{F}, it returns the name of @var{F}'s
11423 caller or the empty string if the call was not made at function
11424 scope.
11425 @end deftypefn
11427 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11428 This function is the equivalent of the preprocessor @code{__FILE__}
11429 macro and returns an address constant pointing to the file name
11430 containing the invocation of the built-in, or the empty string if
11431 the invocation is not at function scope.  When used as a C++ default
11432 argument for a function @var{F}, it returns the file name of the call
11433 to @var{F} or the empty string if the call was not made at function
11434 scope.
11436 For example, in the following, each call to function @code{foo} will
11437 print a line similar to @code{"file.c:123: foo: message"} with the name
11438 of the file and the line number of the @code{printf} call, the name of
11439 the function @code{foo}, followed by the word @code{message}.
11441 @smallexample
11442 const char*
11443 function (const char *func = __builtin_FUNCTION ())
11445   return func;
11448 void foo (void)
11450   printf ("%s:%i: %s: message\n", file (), line (), function ());
11452 @end smallexample
11454 @end deftypefn
11456 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11457 This function is used to flush the processor's instruction cache for
11458 the region of memory between @var{begin} inclusive and @var{end}
11459 exclusive.  Some targets require that the instruction cache be
11460 flushed, after modifying memory containing code, in order to obtain
11461 deterministic behavior.
11463 If the target does not require instruction cache flushes,
11464 @code{__builtin___clear_cache} has no effect.  Otherwise either
11465 instructions are emitted in-line to clear the instruction cache or a
11466 call to the @code{__clear_cache} function in libgcc is made.
11467 @end deftypefn
11469 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11470 This function is used to minimize cache-miss latency by moving data into
11471 a cache before it is accessed.
11472 You can insert calls to @code{__builtin_prefetch} into code for which
11473 you know addresses of data in memory that is likely to be accessed soon.
11474 If the target supports them, data prefetch instructions are generated.
11475 If the prefetch is done early enough before the access then the data will
11476 be in the cache by the time it is accessed.
11478 The value of @var{addr} is the address of the memory to prefetch.
11479 There are two optional arguments, @var{rw} and @var{locality}.
11480 The value of @var{rw} is a compile-time constant one or zero; one
11481 means that the prefetch is preparing for a write to the memory address
11482 and zero, the default, means that the prefetch is preparing for a read.
11483 The value @var{locality} must be a compile-time constant integer between
11484 zero and three.  A value of zero means that the data has no temporal
11485 locality, so it need not be left in the cache after the access.  A value
11486 of three means that the data has a high degree of temporal locality and
11487 should be left in all levels of cache possible.  Values of one and two
11488 mean, respectively, a low or moderate degree of temporal locality.  The
11489 default is three.
11491 @smallexample
11492 for (i = 0; i < n; i++)
11493   @{
11494     a[i] = a[i] + b[i];
11495     __builtin_prefetch (&a[i+j], 1, 1);
11496     __builtin_prefetch (&b[i+j], 0, 1);
11497     /* @r{@dots{}} */
11498   @}
11499 @end smallexample
11501 Data prefetch does not generate faults if @var{addr} is invalid, but
11502 the address expression itself must be valid.  For example, a prefetch
11503 of @code{p->next} does not fault if @code{p->next} is not a valid
11504 address, but evaluation faults if @code{p} is not a valid address.
11506 If the target does not support data prefetch, the address expression
11507 is evaluated if it includes side effects but no other code is generated
11508 and GCC does not issue a warning.
11509 @end deftypefn
11511 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11512 Returns a positive infinity, if supported by the floating-point format,
11513 else @code{DBL_MAX}.  This function is suitable for implementing the
11514 ISO C macro @code{HUGE_VAL}.
11515 @end deftypefn
11517 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11518 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11519 @end deftypefn
11521 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11522 Similar to @code{__builtin_huge_val}, except the return
11523 type is @code{long double}.
11524 @end deftypefn
11526 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11527 Similar to @code{__builtin_huge_val}, except the return type is
11528 @code{_Float@var{n}}.
11529 @end deftypefn
11531 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11532 Similar to @code{__builtin_huge_val}, except the return type is
11533 @code{_Float@var{n}x}.
11534 @end deftypefn
11536 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11537 This built-in implements the C99 fpclassify functionality.  The first
11538 five int arguments should be the target library's notion of the
11539 possible FP classes and are used for return values.  They must be
11540 constant values and they must appear in this order: @code{FP_NAN},
11541 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11542 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
11543 to classify.  GCC treats the last argument as type-generic, which
11544 means it does not do default promotion from float to double.
11545 @end deftypefn
11547 @deftypefn {Built-in Function} double __builtin_inf (void)
11548 Similar to @code{__builtin_huge_val}, except a warning is generated
11549 if the target floating-point format does not support infinities.
11550 @end deftypefn
11552 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11553 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11554 @end deftypefn
11556 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11557 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11558 @end deftypefn
11560 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11561 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11562 @end deftypefn
11564 @deftypefn {Built-in Function} float __builtin_inff (void)
11565 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11566 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11567 @end deftypefn
11569 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11570 Similar to @code{__builtin_inf}, except the return
11571 type is @code{long double}.
11572 @end deftypefn
11574 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11575 Similar to @code{__builtin_inf}, except the return
11576 type is @code{_Float@var{n}}.
11577 @end deftypefn
11579 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11580 Similar to @code{__builtin_inf}, except the return
11581 type is @code{_Float@var{n}x}.
11582 @end deftypefn
11584 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11585 Similar to @code{isinf}, except the return value is -1 for
11586 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11587 Note while the parameter list is an
11588 ellipsis, this function only accepts exactly one floating-point
11589 argument.  GCC treats this parameter as type-generic, which means it
11590 does not do default promotion from float to double.
11591 @end deftypefn
11593 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11594 This is an implementation of the ISO C99 function @code{nan}.
11596 Since ISO C99 defines this function in terms of @code{strtod}, which we
11597 do not implement, a description of the parsing is in order.  The string
11598 is parsed as by @code{strtol}; that is, the base is recognized by
11599 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
11600 in the significand such that the least significant bit of the number
11601 is at the least significant bit of the significand.  The number is
11602 truncated to fit the significand field provided.  The significand is
11603 forced to be a quiet NaN@.
11605 This function, if given a string literal all of which would have been
11606 consumed by @code{strtol}, is evaluated early enough that it is considered a
11607 compile-time constant.
11608 @end deftypefn
11610 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11611 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11612 @end deftypefn
11614 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11615 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11616 @end deftypefn
11618 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11619 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11620 @end deftypefn
11622 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11623 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11624 @end deftypefn
11626 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11627 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11628 @end deftypefn
11630 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11631 Similar to @code{__builtin_nan}, except the return type is
11632 @code{_Float@var{n}}.
11633 @end deftypefn
11635 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11636 Similar to @code{__builtin_nan}, except the return type is
11637 @code{_Float@var{n}x}.
11638 @end deftypefn
11640 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11641 Similar to @code{__builtin_nan}, except the significand is forced
11642 to be a signaling NaN@.  The @code{nans} function is proposed by
11643 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11644 @end deftypefn
11646 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11647 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11648 @end deftypefn
11650 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11651 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11652 @end deftypefn
11654 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11655 Similar to @code{__builtin_nans}, except the return type is
11656 @code{_Float@var{n}}.
11657 @end deftypefn
11659 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11660 Similar to @code{__builtin_nans}, except the return type is
11661 @code{_Float@var{n}x}.
11662 @end deftypefn
11664 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11665 Returns one plus the index of the least significant 1-bit of @var{x}, or
11666 if @var{x} is zero, returns zero.
11667 @end deftypefn
11669 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11670 Returns the number of leading 0-bits in @var{x}, starting at the most
11671 significant bit position.  If @var{x} is 0, the result is undefined.
11672 @end deftypefn
11674 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11675 Returns the number of trailing 0-bits in @var{x}, starting at the least
11676 significant bit position.  If @var{x} is 0, the result is undefined.
11677 @end deftypefn
11679 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11680 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11681 number of bits following the most significant bit that are identical
11682 to it.  There are no special cases for 0 or other values. 
11683 @end deftypefn
11685 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11686 Returns the number of 1-bits in @var{x}.
11687 @end deftypefn
11689 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11690 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11691 modulo 2.
11692 @end deftypefn
11694 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11695 Similar to @code{__builtin_ffs}, except the argument type is
11696 @code{long}.
11697 @end deftypefn
11699 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11700 Similar to @code{__builtin_clz}, except the argument type is
11701 @code{unsigned long}.
11702 @end deftypefn
11704 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11705 Similar to @code{__builtin_ctz}, except the argument type is
11706 @code{unsigned long}.
11707 @end deftypefn
11709 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11710 Similar to @code{__builtin_clrsb}, except the argument type is
11711 @code{long}.
11712 @end deftypefn
11714 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11715 Similar to @code{__builtin_popcount}, except the argument type is
11716 @code{unsigned long}.
11717 @end deftypefn
11719 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11720 Similar to @code{__builtin_parity}, except the argument type is
11721 @code{unsigned long}.
11722 @end deftypefn
11724 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11725 Similar to @code{__builtin_ffs}, except the argument type is
11726 @code{long long}.
11727 @end deftypefn
11729 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11730 Similar to @code{__builtin_clz}, except the argument type is
11731 @code{unsigned long long}.
11732 @end deftypefn
11734 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11735 Similar to @code{__builtin_ctz}, except the argument type is
11736 @code{unsigned long long}.
11737 @end deftypefn
11739 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11740 Similar to @code{__builtin_clrsb}, except the argument type is
11741 @code{long long}.
11742 @end deftypefn
11744 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11745 Similar to @code{__builtin_popcount}, except the argument type is
11746 @code{unsigned long long}.
11747 @end deftypefn
11749 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11750 Similar to @code{__builtin_parity}, except the argument type is
11751 @code{unsigned long long}.
11752 @end deftypefn
11754 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11755 Returns the first argument raised to the power of the second.  Unlike the
11756 @code{pow} function no guarantees about precision and rounding are made.
11757 @end deftypefn
11759 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11760 Similar to @code{__builtin_powi}, except the argument and return types
11761 are @code{float}.
11762 @end deftypefn
11764 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11765 Similar to @code{__builtin_powi}, except the argument and return types
11766 are @code{long double}.
11767 @end deftypefn
11769 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11770 Returns @var{x} with the order of the bytes reversed; for example,
11771 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
11772 exactly 8 bits.
11773 @end deftypefn
11775 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11776 Similar to @code{__builtin_bswap16}, except the argument and return types
11777 are 32 bit.
11778 @end deftypefn
11780 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11781 Similar to @code{__builtin_bswap32}, except the argument and return types
11782 are 64 bit.
11783 @end deftypefn
11785 @node Target Builtins
11786 @section Built-in Functions Specific to Particular Target Machines
11788 On some target machines, GCC supports many built-in functions specific
11789 to those machines.  Generally these generate calls to specific machine
11790 instructions, but allow the compiler to schedule those calls.
11792 @menu
11793 * AArch64 Built-in Functions::
11794 * Alpha Built-in Functions::
11795 * Altera Nios II Built-in Functions::
11796 * ARC Built-in Functions::
11797 * ARC SIMD Built-in Functions::
11798 * ARM iWMMXt Built-in Functions::
11799 * ARM C Language Extensions (ACLE)::
11800 * ARM Floating Point Status and Control Intrinsics::
11801 * ARM ARMv8-M Security Extensions::
11802 * AVR Built-in Functions::
11803 * Blackfin Built-in Functions::
11804 * FR-V Built-in Functions::
11805 * MIPS DSP Built-in Functions::
11806 * MIPS Paired-Single Support::
11807 * MIPS Loongson Built-in Functions::
11808 * MIPS SIMD Architecture (MSA) Support::
11809 * Other MIPS Built-in Functions::
11810 * MSP430 Built-in Functions::
11811 * NDS32 Built-in Functions::
11812 * picoChip Built-in Functions::
11813 * PowerPC Built-in Functions::
11814 * PowerPC AltiVec/VSX Built-in Functions::
11815 * PowerPC Hardware Transactional Memory Built-in Functions::
11816 * RX Built-in Functions::
11817 * S/390 System z Built-in Functions::
11818 * SH Built-in Functions::
11819 * SPARC VIS Built-in Functions::
11820 * SPU Built-in Functions::
11821 * TI C6X Built-in Functions::
11822 * TILE-Gx Built-in Functions::
11823 * TILEPro Built-in Functions::
11824 * x86 Built-in Functions::
11825 * x86 transactional memory intrinsics::
11826 @end menu
11828 @node AArch64 Built-in Functions
11829 @subsection AArch64 Built-in Functions
11831 These built-in functions are available for the AArch64 family of
11832 processors.
11833 @smallexample
11834 unsigned int __builtin_aarch64_get_fpcr ()
11835 void __builtin_aarch64_set_fpcr (unsigned int)
11836 unsigned int __builtin_aarch64_get_fpsr ()
11837 void __builtin_aarch64_set_fpsr (unsigned int)
11838 @end smallexample
11840 @node Alpha Built-in Functions
11841 @subsection Alpha Built-in Functions
11843 These built-in functions are available for the Alpha family of
11844 processors, depending on the command-line switches used.
11846 The following built-in functions are always available.  They
11847 all generate the machine instruction that is part of the name.
11849 @smallexample
11850 long __builtin_alpha_implver (void)
11851 long __builtin_alpha_rpcc (void)
11852 long __builtin_alpha_amask (long)
11853 long __builtin_alpha_cmpbge (long, long)
11854 long __builtin_alpha_extbl (long, long)
11855 long __builtin_alpha_extwl (long, long)
11856 long __builtin_alpha_extll (long, long)
11857 long __builtin_alpha_extql (long, long)
11858 long __builtin_alpha_extwh (long, long)
11859 long __builtin_alpha_extlh (long, long)
11860 long __builtin_alpha_extqh (long, long)
11861 long __builtin_alpha_insbl (long, long)
11862 long __builtin_alpha_inswl (long, long)
11863 long __builtin_alpha_insll (long, long)
11864 long __builtin_alpha_insql (long, long)
11865 long __builtin_alpha_inswh (long, long)
11866 long __builtin_alpha_inslh (long, long)
11867 long __builtin_alpha_insqh (long, long)
11868 long __builtin_alpha_mskbl (long, long)
11869 long __builtin_alpha_mskwl (long, long)
11870 long __builtin_alpha_mskll (long, long)
11871 long __builtin_alpha_mskql (long, long)
11872 long __builtin_alpha_mskwh (long, long)
11873 long __builtin_alpha_msklh (long, long)
11874 long __builtin_alpha_mskqh (long, long)
11875 long __builtin_alpha_umulh (long, long)
11876 long __builtin_alpha_zap (long, long)
11877 long __builtin_alpha_zapnot (long, long)
11878 @end smallexample
11880 The following built-in functions are always with @option{-mmax}
11881 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11882 later.  They all generate the machine instruction that is part
11883 of the name.
11885 @smallexample
11886 long __builtin_alpha_pklb (long)
11887 long __builtin_alpha_pkwb (long)
11888 long __builtin_alpha_unpkbl (long)
11889 long __builtin_alpha_unpkbw (long)
11890 long __builtin_alpha_minub8 (long, long)
11891 long __builtin_alpha_minsb8 (long, long)
11892 long __builtin_alpha_minuw4 (long, long)
11893 long __builtin_alpha_minsw4 (long, long)
11894 long __builtin_alpha_maxub8 (long, long)
11895 long __builtin_alpha_maxsb8 (long, long)
11896 long __builtin_alpha_maxuw4 (long, long)
11897 long __builtin_alpha_maxsw4 (long, long)
11898 long __builtin_alpha_perr (long, long)
11899 @end smallexample
11901 The following built-in functions are always with @option{-mcix}
11902 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11903 later.  They all generate the machine instruction that is part
11904 of the name.
11906 @smallexample
11907 long __builtin_alpha_cttz (long)
11908 long __builtin_alpha_ctlz (long)
11909 long __builtin_alpha_ctpop (long)
11910 @end smallexample
11912 The following built-in functions are available on systems that use the OSF/1
11913 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
11914 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11915 @code{rdval} and @code{wrval}.
11917 @smallexample
11918 void *__builtin_thread_pointer (void)
11919 void __builtin_set_thread_pointer (void *)
11920 @end smallexample
11922 @node Altera Nios II Built-in Functions
11923 @subsection Altera Nios II Built-in Functions
11925 These built-in functions are available for the Altera Nios II
11926 family of processors.
11928 The following built-in functions are always available.  They
11929 all generate the machine instruction that is part of the name.
11931 @example
11932 int __builtin_ldbio (volatile const void *)
11933 int __builtin_ldbuio (volatile const void *)
11934 int __builtin_ldhio (volatile const void *)
11935 int __builtin_ldhuio (volatile const void *)
11936 int __builtin_ldwio (volatile const void *)
11937 void __builtin_stbio (volatile void *, int)
11938 void __builtin_sthio (volatile void *, int)
11939 void __builtin_stwio (volatile void *, int)
11940 void __builtin_sync (void)
11941 int __builtin_rdctl (int) 
11942 int __builtin_rdprs (int, int)
11943 void __builtin_wrctl (int, int)
11944 void __builtin_flushd (volatile void *)
11945 void __builtin_flushda (volatile void *)
11946 int __builtin_wrpie (int);
11947 void __builtin_eni (int);
11948 int __builtin_ldex (volatile const void *)
11949 int __builtin_stex (volatile void *, int)
11950 int __builtin_ldsex (volatile const void *)
11951 int __builtin_stsex (volatile void *, int)
11952 @end example
11954 The following built-in functions are always available.  They
11955 all generate a Nios II Custom Instruction. The name of the
11956 function represents the types that the function takes and
11957 returns. The letter before the @code{n} is the return type
11958 or void if absent. The @code{n} represents the first parameter
11959 to all the custom instructions, the custom instruction number.
11960 The two letters after the @code{n} represent the up to two
11961 parameters to the function.
11963 The letters represent the following data types:
11964 @table @code
11965 @item <no letter>
11966 @code{void} for return type and no parameter for parameter types.
11968 @item i
11969 @code{int} for return type and parameter type
11971 @item f
11972 @code{float} for return type and parameter type
11974 @item p
11975 @code{void *} for return type and parameter type
11977 @end table
11979 And the function names are:
11980 @example
11981 void __builtin_custom_n (void)
11982 void __builtin_custom_ni (int)
11983 void __builtin_custom_nf (float)
11984 void __builtin_custom_np (void *)
11985 void __builtin_custom_nii (int, int)
11986 void __builtin_custom_nif (int, float)
11987 void __builtin_custom_nip (int, void *)
11988 void __builtin_custom_nfi (float, int)
11989 void __builtin_custom_nff (float, float)
11990 void __builtin_custom_nfp (float, void *)
11991 void __builtin_custom_npi (void *, int)
11992 void __builtin_custom_npf (void *, float)
11993 void __builtin_custom_npp (void *, void *)
11994 int __builtin_custom_in (void)
11995 int __builtin_custom_ini (int)
11996 int __builtin_custom_inf (float)
11997 int __builtin_custom_inp (void *)
11998 int __builtin_custom_inii (int, int)
11999 int __builtin_custom_inif (int, float)
12000 int __builtin_custom_inip (int, void *)
12001 int __builtin_custom_infi (float, int)
12002 int __builtin_custom_inff (float, float)
12003 int __builtin_custom_infp (float, void *)
12004 int __builtin_custom_inpi (void *, int)
12005 int __builtin_custom_inpf (void *, float)
12006 int __builtin_custom_inpp (void *, void *)
12007 float __builtin_custom_fn (void)
12008 float __builtin_custom_fni (int)
12009 float __builtin_custom_fnf (float)
12010 float __builtin_custom_fnp (void *)
12011 float __builtin_custom_fnii (int, int)
12012 float __builtin_custom_fnif (int, float)
12013 float __builtin_custom_fnip (int, void *)
12014 float __builtin_custom_fnfi (float, int)
12015 float __builtin_custom_fnff (float, float)
12016 float __builtin_custom_fnfp (float, void *)
12017 float __builtin_custom_fnpi (void *, int)
12018 float __builtin_custom_fnpf (void *, float)
12019 float __builtin_custom_fnpp (void *, void *)
12020 void * __builtin_custom_pn (void)
12021 void * __builtin_custom_pni (int)
12022 void * __builtin_custom_pnf (float)
12023 void * __builtin_custom_pnp (void *)
12024 void * __builtin_custom_pnii (int, int)
12025 void * __builtin_custom_pnif (int, float)
12026 void * __builtin_custom_pnip (int, void *)
12027 void * __builtin_custom_pnfi (float, int)
12028 void * __builtin_custom_pnff (float, float)
12029 void * __builtin_custom_pnfp (float, void *)
12030 void * __builtin_custom_pnpi (void *, int)
12031 void * __builtin_custom_pnpf (void *, float)
12032 void * __builtin_custom_pnpp (void *, void *)
12033 @end example
12035 @node ARC Built-in Functions
12036 @subsection ARC Built-in Functions
12038 The following built-in functions are provided for ARC targets.  The
12039 built-ins generate the corresponding assembly instructions.  In the
12040 examples given below, the generated code often requires an operand or
12041 result to be in a register.  Where necessary further code will be
12042 generated to ensure this is true, but for brevity this is not
12043 described in each case.
12045 @emph{Note:} Using a built-in to generate an instruction not supported
12046 by a target may cause problems. At present the compiler is not
12047 guaranteed to detect such misuse, and as a result an internal compiler
12048 error may be generated.
12050 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12051 Return 1 if @var{val} is known to have the byte alignment given
12052 by @var{alignval}, otherwise return 0.
12053 Note that this is different from
12054 @smallexample
12055 __alignof__(*(char *)@var{val}) >= alignval
12056 @end smallexample
12057 because __alignof__ sees only the type of the dereference, whereas
12058 __builtin_arc_align uses alignment information from the pointer
12059 as well as from the pointed-to type.
12060 The information available will depend on optimization level.
12061 @end deftypefn
12063 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12064 Generates
12065 @example
12067 @end example
12068 @end deftypefn
12070 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12071 The operand is the number of a register to be read.  Generates:
12072 @example
12073 mov  @var{dest}, r@var{regno}
12074 @end example
12075 where the value in @var{dest} will be the result returned from the
12076 built-in.
12077 @end deftypefn
12079 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12080 The first operand is the number of a register to be written, the
12081 second operand is a compile time constant to write into that
12082 register.  Generates:
12083 @example
12084 mov  r@var{regno}, @var{val}
12085 @end example
12086 @end deftypefn
12088 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12089 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12090 Generates:
12091 @example
12092 divaw  @var{dest}, @var{a}, @var{b}
12093 @end example
12094 where the value in @var{dest} will be the result returned from the
12095 built-in.
12096 @end deftypefn
12098 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12099 Generates
12100 @example
12101 flag  @var{a}
12102 @end example
12103 @end deftypefn
12105 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12106 The operand, @var{auxv}, is the address of an auxiliary register and
12107 must be a compile time constant.  Generates:
12108 @example
12109 lr  @var{dest}, [@var{auxr}]
12110 @end example
12111 Where the value in @var{dest} will be the result returned from the
12112 built-in.
12113 @end deftypefn
12115 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12116 Only available with @option{-mmul64}.  Generates:
12117 @example
12118 mul64  @var{a}, @var{b}
12119 @end example
12120 @end deftypefn
12122 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12123 Only available with @option{-mmul64}.  Generates:
12124 @example
12125 mulu64  @var{a}, @var{b}
12126 @end example
12127 @end deftypefn
12129 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12130 Generates:
12131 @example
12133 @end example
12134 @end deftypefn
12136 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12137 Only valid if the @samp{norm} instruction is available through the
12138 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12139 Generates:
12140 @example
12141 norm  @var{dest}, @var{src}
12142 @end example
12143 Where the value in @var{dest} will be the result returned from the
12144 built-in.
12145 @end deftypefn
12147 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12148 Only valid if the @samp{normw} instruction is available through the
12149 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12150 Generates:
12151 @example
12152 normw  @var{dest}, @var{src}
12153 @end example
12154 Where the value in @var{dest} will be the result returned from the
12155 built-in.
12156 @end deftypefn
12158 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12159 Generates:
12160 @example
12161 rtie
12162 @end example
12163 @end deftypefn
12165 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12166 Generates:
12167 @example
12168 sleep  @var{a}
12169 @end example
12170 @end deftypefn
12172 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12173 The first argument, @var{auxv}, is the address of an auxiliary
12174 register, the second argument, @var{val}, is a compile time constant
12175 to be written to the register.  Generates:
12176 @example
12177 sr  @var{auxr}, [@var{val}]
12178 @end example
12179 @end deftypefn
12181 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12182 Only valid with @option{-mswap}.  Generates:
12183 @example
12184 swap  @var{dest}, @var{src}
12185 @end example
12186 Where the value in @var{dest} will be the result returned from the
12187 built-in.
12188 @end deftypefn
12190 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12191 Generates:
12192 @example
12194 @end example
12195 @end deftypefn
12197 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12198 Only available with @option{-mcpu=ARC700}.  Generates:
12199 @example
12200 sync
12201 @end example
12202 @end deftypefn
12204 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12205 Only available with @option{-mcpu=ARC700}.  Generates:
12206 @example
12207 trap_s  @var{c}
12208 @end example
12209 @end deftypefn
12211 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12212 Only available with @option{-mcpu=ARC700}.  Generates:
12213 @example
12214 unimp_s
12215 @end example
12216 @end deftypefn
12218 The instructions generated by the following builtins are not
12219 considered as candidates for scheduling.  They are not moved around by
12220 the compiler during scheduling, and thus can be expected to appear
12221 where they are put in the C code:
12222 @example
12223 __builtin_arc_brk()
12224 __builtin_arc_core_read()
12225 __builtin_arc_core_write()
12226 __builtin_arc_flag()
12227 __builtin_arc_lr()
12228 __builtin_arc_sleep()
12229 __builtin_arc_sr()
12230 __builtin_arc_swi()
12231 @end example
12233 @node ARC SIMD Built-in Functions
12234 @subsection ARC SIMD Built-in Functions
12236 SIMD builtins provided by the compiler can be used to generate the
12237 vector instructions.  This section describes the available builtins
12238 and their usage in programs.  With the @option{-msimd} option, the
12239 compiler provides 128-bit vector types, which can be specified using
12240 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12241 can be included to use the following predefined types:
12242 @example
12243 typedef int __v4si   __attribute__((vector_size(16)));
12244 typedef short __v8hi __attribute__((vector_size(16)));
12245 @end example
12247 These types can be used to define 128-bit variables.  The built-in
12248 functions listed in the following section can be used on these
12249 variables to generate the vector operations.
12251 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12252 @file{arc-simd.h} also provides equivalent macros called
12253 @code{_@var{someinsn}} that can be used for programming ease and
12254 improved readability.  The following macros for DMA control are also
12255 provided:
12256 @example
12257 #define _setup_dma_in_channel_reg _vdiwr
12258 #define _setup_dma_out_channel_reg _vdowr
12259 @end example
12261 The following is a complete list of all the SIMD built-ins provided
12262 for ARC, grouped by calling signature.
12264 The following take two @code{__v8hi} arguments and return a
12265 @code{__v8hi} result:
12266 @example
12267 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12268 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12269 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12270 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12271 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12272 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12273 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12274 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12275 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12276 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12277 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12278 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12279 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12280 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12281 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12282 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12283 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12284 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12285 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12286 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12287 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12288 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12289 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12290 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12291 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12292 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12293 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12294 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12295 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12296 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12297 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12298 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12299 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12300 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12301 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12302 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12303 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12304 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12305 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12306 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12307 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12308 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12309 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12310 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12311 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12312 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12313 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12314 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12315 @end example
12317 The following take one @code{__v8hi} and one @code{int} argument and return a
12318 @code{__v8hi} result:
12320 @example
12321 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12322 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12323 __v8hi __builtin_arc_vbminw (__v8hi, int)
12324 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12325 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12326 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12327 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12328 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12329 @end example
12331 The following take one @code{__v8hi} argument and one @code{int} argument which
12332 must be a 3-bit compile time constant indicating a register number
12333 I0-I7.  They return a @code{__v8hi} result.
12334 @example
12335 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12336 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12337 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12338 @end example
12340 The following take one @code{__v8hi} argument and one @code{int}
12341 argument which must be a 6-bit compile time constant.  They return a
12342 @code{__v8hi} result.
12343 @example
12344 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12345 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12346 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12347 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12348 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12349 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12350 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12351 @end example
12353 The following take one @code{__v8hi} argument and one @code{int} argument which
12354 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12355 result.
12356 @example
12357 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12358 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12359 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12360 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12361 @end example
12363 The following take two @code{int} arguments, the second of which which
12364 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12365 result:
12366 @example
12367 __v8hi __builtin_arc_vmovaw (int, const int)
12368 __v8hi __builtin_arc_vmovw (int, const int)
12369 __v8hi __builtin_arc_vmovzw (int, const int)
12370 @end example
12372 The following take a single @code{__v8hi} argument and return a
12373 @code{__v8hi} result:
12374 @example
12375 __v8hi __builtin_arc_vabsaw (__v8hi)
12376 __v8hi __builtin_arc_vabsw (__v8hi)
12377 __v8hi __builtin_arc_vaddsuw (__v8hi)
12378 __v8hi __builtin_arc_vexch1 (__v8hi)
12379 __v8hi __builtin_arc_vexch2 (__v8hi)
12380 __v8hi __builtin_arc_vexch4 (__v8hi)
12381 __v8hi __builtin_arc_vsignw (__v8hi)
12382 __v8hi __builtin_arc_vupbaw (__v8hi)
12383 __v8hi __builtin_arc_vupbw (__v8hi)
12384 __v8hi __builtin_arc_vupsbaw (__v8hi)
12385 __v8hi __builtin_arc_vupsbw (__v8hi)
12386 @end example
12388 The following take two @code{int} arguments and return no result:
12389 @example
12390 void __builtin_arc_vdirun (int, int)
12391 void __builtin_arc_vdorun (int, int)
12392 @end example
12394 The following take two @code{int} arguments and return no result.  The
12395 first argument must a 3-bit compile time constant indicating one of
12396 the DR0-DR7 DMA setup channels:
12397 @example
12398 void __builtin_arc_vdiwr (const int, int)
12399 void __builtin_arc_vdowr (const int, int)
12400 @end example
12402 The following take an @code{int} argument and return no result:
12403 @example
12404 void __builtin_arc_vendrec (int)
12405 void __builtin_arc_vrec (int)
12406 void __builtin_arc_vrecrun (int)
12407 void __builtin_arc_vrun (int)
12408 @end example
12410 The following take a @code{__v8hi} argument and two @code{int}
12411 arguments and return a @code{__v8hi} result.  The second argument must
12412 be a 3-bit compile time constants, indicating one the registers I0-I7,
12413 and the third argument must be an 8-bit compile time constant.
12415 @emph{Note:} Although the equivalent hardware instructions do not take
12416 an SIMD register as an operand, these builtins overwrite the relevant
12417 bits of the @code{__v8hi} register provided as the first argument with
12418 the value loaded from the @code{[Ib, u8]} location in the SDM.
12420 @example
12421 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12422 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12423 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12424 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12425 @end example
12427 The following take two @code{int} arguments and return a @code{__v8hi}
12428 result.  The first argument must be a 3-bit compile time constants,
12429 indicating one the registers I0-I7, and the second argument must be an
12430 8-bit compile time constant.
12432 @example
12433 __v8hi __builtin_arc_vld128 (const int, const int)
12434 __v8hi __builtin_arc_vld64w (const int, const int)
12435 @end example
12437 The following take a @code{__v8hi} argument and two @code{int}
12438 arguments and return no result.  The second argument must be a 3-bit
12439 compile time constants, indicating one the registers I0-I7, and the
12440 third argument must be an 8-bit compile time constant.
12442 @example
12443 void __builtin_arc_vst128 (__v8hi, const int, const int)
12444 void __builtin_arc_vst64 (__v8hi, const int, const int)
12445 @end example
12447 The following take a @code{__v8hi} argument and three @code{int}
12448 arguments and return no result.  The second argument must be a 3-bit
12449 compile-time constant, identifying the 16-bit sub-register to be
12450 stored, the third argument must be a 3-bit compile time constants,
12451 indicating one the registers I0-I7, and the fourth argument must be an
12452 8-bit compile time constant.
12454 @example
12455 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12456 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12457 @end example
12459 @node ARM iWMMXt Built-in Functions
12460 @subsection ARM iWMMXt Built-in Functions
12462 These built-in functions are available for the ARM family of
12463 processors when the @option{-mcpu=iwmmxt} switch is used:
12465 @smallexample
12466 typedef int v2si __attribute__ ((vector_size (8)));
12467 typedef short v4hi __attribute__ ((vector_size (8)));
12468 typedef char v8qi __attribute__ ((vector_size (8)));
12470 int __builtin_arm_getwcgr0 (void)
12471 void __builtin_arm_setwcgr0 (int)
12472 int __builtin_arm_getwcgr1 (void)
12473 void __builtin_arm_setwcgr1 (int)
12474 int __builtin_arm_getwcgr2 (void)
12475 void __builtin_arm_setwcgr2 (int)
12476 int __builtin_arm_getwcgr3 (void)
12477 void __builtin_arm_setwcgr3 (int)
12478 int __builtin_arm_textrmsb (v8qi, int)
12479 int __builtin_arm_textrmsh (v4hi, int)
12480 int __builtin_arm_textrmsw (v2si, int)
12481 int __builtin_arm_textrmub (v8qi, int)
12482 int __builtin_arm_textrmuh (v4hi, int)
12483 int __builtin_arm_textrmuw (v2si, int)
12484 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12485 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12486 v2si __builtin_arm_tinsrw (v2si, int, int)
12487 long long __builtin_arm_tmia (long long, int, int)
12488 long long __builtin_arm_tmiabb (long long, int, int)
12489 long long __builtin_arm_tmiabt (long long, int, int)
12490 long long __builtin_arm_tmiaph (long long, int, int)
12491 long long __builtin_arm_tmiatb (long long, int, int)
12492 long long __builtin_arm_tmiatt (long long, int, int)
12493 int __builtin_arm_tmovmskb (v8qi)
12494 int __builtin_arm_tmovmskh (v4hi)
12495 int __builtin_arm_tmovmskw (v2si)
12496 long long __builtin_arm_waccb (v8qi)
12497 long long __builtin_arm_wacch (v4hi)
12498 long long __builtin_arm_waccw (v2si)
12499 v8qi __builtin_arm_waddb (v8qi, v8qi)
12500 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12501 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12502 v4hi __builtin_arm_waddh (v4hi, v4hi)
12503 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12504 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12505 v2si __builtin_arm_waddw (v2si, v2si)
12506 v2si __builtin_arm_waddwss (v2si, v2si)
12507 v2si __builtin_arm_waddwus (v2si, v2si)
12508 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12509 long long __builtin_arm_wand(long long, long long)
12510 long long __builtin_arm_wandn (long long, long long)
12511 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12512 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12513 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12514 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12515 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12516 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12517 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12518 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12519 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12520 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12521 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12522 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12523 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12524 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12525 long long __builtin_arm_wmacsz (v4hi, v4hi)
12526 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12527 long long __builtin_arm_wmacuz (v4hi, v4hi)
12528 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12529 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12530 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12531 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12532 v2si __builtin_arm_wmaxsw (v2si, v2si)
12533 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12534 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12535 v2si __builtin_arm_wmaxuw (v2si, v2si)
12536 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12537 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12538 v2si __builtin_arm_wminsw (v2si, v2si)
12539 v8qi __builtin_arm_wminub (v8qi, v8qi)
12540 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12541 v2si __builtin_arm_wminuw (v2si, v2si)
12542 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12543 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12544 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12545 long long __builtin_arm_wor (long long, long long)
12546 v2si __builtin_arm_wpackdss (long long, long long)
12547 v2si __builtin_arm_wpackdus (long long, long long)
12548 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12549 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12550 v4hi __builtin_arm_wpackwss (v2si, v2si)
12551 v4hi __builtin_arm_wpackwus (v2si, v2si)
12552 long long __builtin_arm_wrord (long long, long long)
12553 long long __builtin_arm_wrordi (long long, int)
12554 v4hi __builtin_arm_wrorh (v4hi, long long)
12555 v4hi __builtin_arm_wrorhi (v4hi, int)
12556 v2si __builtin_arm_wrorw (v2si, long long)
12557 v2si __builtin_arm_wrorwi (v2si, int)
12558 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12559 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12560 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12561 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12562 v4hi __builtin_arm_wshufh (v4hi, int)
12563 long long __builtin_arm_wslld (long long, long long)
12564 long long __builtin_arm_wslldi (long long, int)
12565 v4hi __builtin_arm_wsllh (v4hi, long long)
12566 v4hi __builtin_arm_wsllhi (v4hi, int)
12567 v2si __builtin_arm_wsllw (v2si, long long)
12568 v2si __builtin_arm_wsllwi (v2si, int)
12569 long long __builtin_arm_wsrad (long long, long long)
12570 long long __builtin_arm_wsradi (long long, int)
12571 v4hi __builtin_arm_wsrah (v4hi, long long)
12572 v4hi __builtin_arm_wsrahi (v4hi, int)
12573 v2si __builtin_arm_wsraw (v2si, long long)
12574 v2si __builtin_arm_wsrawi (v2si, int)
12575 long long __builtin_arm_wsrld (long long, long long)
12576 long long __builtin_arm_wsrldi (long long, int)
12577 v4hi __builtin_arm_wsrlh (v4hi, long long)
12578 v4hi __builtin_arm_wsrlhi (v4hi, int)
12579 v2si __builtin_arm_wsrlw (v2si, long long)
12580 v2si __builtin_arm_wsrlwi (v2si, int)
12581 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12582 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12583 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12584 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12585 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12586 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12587 v2si __builtin_arm_wsubw (v2si, v2si)
12588 v2si __builtin_arm_wsubwss (v2si, v2si)
12589 v2si __builtin_arm_wsubwus (v2si, v2si)
12590 v4hi __builtin_arm_wunpckehsb (v8qi)
12591 v2si __builtin_arm_wunpckehsh (v4hi)
12592 long long __builtin_arm_wunpckehsw (v2si)
12593 v4hi __builtin_arm_wunpckehub (v8qi)
12594 v2si __builtin_arm_wunpckehuh (v4hi)
12595 long long __builtin_arm_wunpckehuw (v2si)
12596 v4hi __builtin_arm_wunpckelsb (v8qi)
12597 v2si __builtin_arm_wunpckelsh (v4hi)
12598 long long __builtin_arm_wunpckelsw (v2si)
12599 v4hi __builtin_arm_wunpckelub (v8qi)
12600 v2si __builtin_arm_wunpckeluh (v4hi)
12601 long long __builtin_arm_wunpckeluw (v2si)
12602 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12603 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12604 v2si __builtin_arm_wunpckihw (v2si, v2si)
12605 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12606 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12607 v2si __builtin_arm_wunpckilw (v2si, v2si)
12608 long long __builtin_arm_wxor (long long, long long)
12609 long long __builtin_arm_wzero ()
12610 @end smallexample
12613 @node ARM C Language Extensions (ACLE)
12614 @subsection ARM C Language Extensions (ACLE)
12616 GCC implements extensions for C as described in the ARM C Language
12617 Extensions (ACLE) specification, which can be found at
12618 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12620 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12621 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
12622 intrinsics can be found at
12623 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12624 The built-in intrinsics for the Advanced SIMD extension are available when
12625 NEON is enabled.
12627 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
12628 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
12629 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12630 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12631 intrinsics yet.
12633 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12634 availability of extensions.
12636 @node ARM Floating Point Status and Control Intrinsics
12637 @subsection ARM Floating Point Status and Control Intrinsics
12639 These built-in functions are available for the ARM family of
12640 processors with floating-point unit.
12642 @smallexample
12643 unsigned int __builtin_arm_get_fpscr ()
12644 void __builtin_arm_set_fpscr (unsigned int)
12645 @end smallexample
12647 @node ARM ARMv8-M Security Extensions
12648 @subsection ARM ARMv8-M Security Extensions
12650 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
12651 Security Extensions: Requiremenets on Development Tools Engineering
12652 Specification, which can be found at
12653 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
12655 As part of the Security Extensions GCC implements two new function attributes:
12656 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
12658 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
12659 is used here to mean any function pointer type.
12661 @smallexample
12662 cmse_address_info_t cmse_TT (void *)
12663 cmse_address_info_t cmse_TT_fptr (FPTR)
12664 cmse_address_info_t cmse_TTT (void *)
12665 cmse_address_info_t cmse_TTT_fptr (FPTR)
12666 cmse_address_info_t cmse_TTA (void *)
12667 cmse_address_info_t cmse_TTA_fptr (FPTR)
12668 cmse_address_info_t cmse_TTAT (void *)
12669 cmse_address_info_t cmse_TTAT_fptr (FPTR)
12670 void * cmse_check_address_range (void *, size_t, int)
12671 typeof(p) cmse_nsfptr_create (FPTR p)
12672 intptr_t cmse_is_nsfptr (FPTR)
12673 int cmse_nonsecure_caller (void)
12674 @end smallexample
12676 @node AVR Built-in Functions
12677 @subsection AVR Built-in Functions
12679 For each built-in function for AVR, there is an equally named,
12680 uppercase built-in macro defined. That way users can easily query if
12681 or if not a specific built-in is implemented or not. For example, if
12682 @code{__builtin_avr_nop} is available the macro
12683 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12685 The following built-in functions map to the respective machine
12686 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12687 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12688 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12689 as library call if no hardware multiplier is available.
12691 @smallexample
12692 void __builtin_avr_nop (void)
12693 void __builtin_avr_sei (void)
12694 void __builtin_avr_cli (void)
12695 void __builtin_avr_sleep (void)
12696 void __builtin_avr_wdr (void)
12697 unsigned char __builtin_avr_swap (unsigned char)
12698 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12699 int __builtin_avr_fmuls (char, char)
12700 int __builtin_avr_fmulsu (char, unsigned char)
12701 @end smallexample
12703 In order to delay execution for a specific number of cycles, GCC
12704 implements
12705 @smallexample
12706 void __builtin_avr_delay_cycles (unsigned long ticks)
12707 @end smallexample
12709 @noindent
12710 @code{ticks} is the number of ticks to delay execution. Note that this
12711 built-in does not take into account the effect of interrupts that
12712 might increase delay time. @code{ticks} must be a compile-time
12713 integer constant; delays with a variable number of cycles are not supported.
12715 @smallexample
12716 char __builtin_avr_flash_segment (const __memx void*)
12717 @end smallexample
12719 @noindent
12720 This built-in takes a byte address to the 24-bit
12721 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12722 the number of the flash segment (the 64 KiB chunk) where the address
12723 points to.  Counting starts at @code{0}.
12724 If the address does not point to flash memory, return @code{-1}.
12726 @smallexample
12727 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12728 @end smallexample
12730 @noindent
12731 Insert bits from @var{bits} into @var{val} and return the resulting
12732 value. The nibbles of @var{map} determine how the insertion is
12733 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12734 @enumerate
12735 @item If @var{X} is @code{0xf},
12736 then the @var{n}-th bit of @var{val} is returned unaltered.
12738 @item If X is in the range 0@dots{}7,
12739 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12741 @item If X is in the range 8@dots{}@code{0xe},
12742 then the @var{n}-th result bit is undefined.
12743 @end enumerate
12745 @noindent
12746 One typical use case for this built-in is adjusting input and
12747 output values to non-contiguous port layouts. Some examples:
12749 @smallexample
12750 // same as val, bits is unused
12751 __builtin_avr_insert_bits (0xffffffff, bits, val)
12752 @end smallexample
12754 @smallexample
12755 // same as bits, val is unused
12756 __builtin_avr_insert_bits (0x76543210, bits, val)
12757 @end smallexample
12759 @smallexample
12760 // same as rotating bits by 4
12761 __builtin_avr_insert_bits (0x32107654, bits, 0)
12762 @end smallexample
12764 @smallexample
12765 // high nibble of result is the high nibble of val
12766 // low nibble of result is the low nibble of bits
12767 __builtin_avr_insert_bits (0xffff3210, bits, val)
12768 @end smallexample
12770 @smallexample
12771 // reverse the bit order of bits
12772 __builtin_avr_insert_bits (0x01234567, bits, 0)
12773 @end smallexample
12775 @smallexample
12776 void __builtin_avr_nops (unsigned count)
12777 @end smallexample
12779 @noindent
12780 Insert @code{count} @code{NOP} instructions.
12781 The number of instructions must be a compile-time integer constant.
12783 @node Blackfin Built-in Functions
12784 @subsection Blackfin Built-in Functions
12786 Currently, there are two Blackfin-specific built-in functions.  These are
12787 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12788 using inline assembly; by using these built-in functions the compiler can
12789 automatically add workarounds for hardware errata involving these
12790 instructions.  These functions are named as follows:
12792 @smallexample
12793 void __builtin_bfin_csync (void)
12794 void __builtin_bfin_ssync (void)
12795 @end smallexample
12797 @node FR-V Built-in Functions
12798 @subsection FR-V Built-in Functions
12800 GCC provides many FR-V-specific built-in functions.  In general,
12801 these functions are intended to be compatible with those described
12802 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12803 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
12804 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12805 pointer rather than by value.
12807 Most of the functions are named after specific FR-V instructions.
12808 Such functions are said to be ``directly mapped'' and are summarized
12809 here in tabular form.
12811 @menu
12812 * Argument Types::
12813 * Directly-mapped Integer Functions::
12814 * Directly-mapped Media Functions::
12815 * Raw read/write Functions::
12816 * Other Built-in Functions::
12817 @end menu
12819 @node Argument Types
12820 @subsubsection Argument Types
12822 The arguments to the built-in functions can be divided into three groups:
12823 register numbers, compile-time constants and run-time values.  In order
12824 to make this classification clear at a glance, the arguments and return
12825 values are given the following pseudo types:
12827 @multitable @columnfractions .20 .30 .15 .35
12828 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12829 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12830 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12831 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12832 @item @code{uw2} @tab @code{unsigned long long} @tab No
12833 @tab an unsigned doubleword
12834 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12835 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12836 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12837 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12838 @end multitable
12840 These pseudo types are not defined by GCC, they are simply a notational
12841 convenience used in this manual.
12843 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12844 and @code{sw2} are evaluated at run time.  They correspond to
12845 register operands in the underlying FR-V instructions.
12847 @code{const} arguments represent immediate operands in the underlying
12848 FR-V instructions.  They must be compile-time constants.
12850 @code{acc} arguments are evaluated at compile time and specify the number
12851 of an accumulator register.  For example, an @code{acc} argument of 2
12852 selects the ACC2 register.
12854 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12855 number of an IACC register.  See @pxref{Other Built-in Functions}
12856 for more details.
12858 @node Directly-mapped Integer Functions
12859 @subsubsection Directly-Mapped Integer Functions
12861 The functions listed below map directly to FR-V I-type instructions.
12863 @multitable @columnfractions .45 .32 .23
12864 @item Function prototype @tab Example usage @tab Assembly output
12865 @item @code{sw1 __ADDSS (sw1, sw1)}
12866 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12867 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12868 @item @code{sw1 __SCAN (sw1, sw1)}
12869 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12870 @tab @code{SCAN @var{a},@var{b},@var{c}}
12871 @item @code{sw1 __SCUTSS (sw1)}
12872 @tab @code{@var{b} = __SCUTSS (@var{a})}
12873 @tab @code{SCUTSS @var{a},@var{b}}
12874 @item @code{sw1 __SLASS (sw1, sw1)}
12875 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12876 @tab @code{SLASS @var{a},@var{b},@var{c}}
12877 @item @code{void __SMASS (sw1, sw1)}
12878 @tab @code{__SMASS (@var{a}, @var{b})}
12879 @tab @code{SMASS @var{a},@var{b}}
12880 @item @code{void __SMSSS (sw1, sw1)}
12881 @tab @code{__SMSSS (@var{a}, @var{b})}
12882 @tab @code{SMSSS @var{a},@var{b}}
12883 @item @code{void __SMU (sw1, sw1)}
12884 @tab @code{__SMU (@var{a}, @var{b})}
12885 @tab @code{SMU @var{a},@var{b}}
12886 @item @code{sw2 __SMUL (sw1, sw1)}
12887 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12888 @tab @code{SMUL @var{a},@var{b},@var{c}}
12889 @item @code{sw1 __SUBSS (sw1, sw1)}
12890 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12891 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12892 @item @code{uw2 __UMUL (uw1, uw1)}
12893 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12894 @tab @code{UMUL @var{a},@var{b},@var{c}}
12895 @end multitable
12897 @node Directly-mapped Media Functions
12898 @subsubsection Directly-Mapped Media Functions
12900 The functions listed below map directly to FR-V M-type instructions.
12902 @multitable @columnfractions .45 .32 .23
12903 @item Function prototype @tab Example usage @tab Assembly output
12904 @item @code{uw1 __MABSHS (sw1)}
12905 @tab @code{@var{b} = __MABSHS (@var{a})}
12906 @tab @code{MABSHS @var{a},@var{b}}
12907 @item @code{void __MADDACCS (acc, acc)}
12908 @tab @code{__MADDACCS (@var{b}, @var{a})}
12909 @tab @code{MADDACCS @var{a},@var{b}}
12910 @item @code{sw1 __MADDHSS (sw1, sw1)}
12911 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12912 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12913 @item @code{uw1 __MADDHUS (uw1, uw1)}
12914 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12915 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12916 @item @code{uw1 __MAND (uw1, uw1)}
12917 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12918 @tab @code{MAND @var{a},@var{b},@var{c}}
12919 @item @code{void __MASACCS (acc, acc)}
12920 @tab @code{__MASACCS (@var{b}, @var{a})}
12921 @tab @code{MASACCS @var{a},@var{b}}
12922 @item @code{uw1 __MAVEH (uw1, uw1)}
12923 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12924 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12925 @item @code{uw2 __MBTOH (uw1)}
12926 @tab @code{@var{b} = __MBTOH (@var{a})}
12927 @tab @code{MBTOH @var{a},@var{b}}
12928 @item @code{void __MBTOHE (uw1 *, uw1)}
12929 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12930 @tab @code{MBTOHE @var{a},@var{b}}
12931 @item @code{void __MCLRACC (acc)}
12932 @tab @code{__MCLRACC (@var{a})}
12933 @tab @code{MCLRACC @var{a}}
12934 @item @code{void __MCLRACCA (void)}
12935 @tab @code{__MCLRACCA ()}
12936 @tab @code{MCLRACCA}
12937 @item @code{uw1 __Mcop1 (uw1, uw1)}
12938 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12939 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12940 @item @code{uw1 __Mcop2 (uw1, uw1)}
12941 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12942 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12943 @item @code{uw1 __MCPLHI (uw2, const)}
12944 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12945 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12946 @item @code{uw1 __MCPLI (uw2, const)}
12947 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12948 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12949 @item @code{void __MCPXIS (acc, sw1, sw1)}
12950 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12951 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12952 @item @code{void __MCPXIU (acc, uw1, uw1)}
12953 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12954 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12955 @item @code{void __MCPXRS (acc, sw1, sw1)}
12956 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12957 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12958 @item @code{void __MCPXRU (acc, uw1, uw1)}
12959 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12960 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12961 @item @code{uw1 __MCUT (acc, uw1)}
12962 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12963 @tab @code{MCUT @var{a},@var{b},@var{c}}
12964 @item @code{uw1 __MCUTSS (acc, sw1)}
12965 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12966 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12967 @item @code{void __MDADDACCS (acc, acc)}
12968 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12969 @tab @code{MDADDACCS @var{a},@var{b}}
12970 @item @code{void __MDASACCS (acc, acc)}
12971 @tab @code{__MDASACCS (@var{b}, @var{a})}
12972 @tab @code{MDASACCS @var{a},@var{b}}
12973 @item @code{uw2 __MDCUTSSI (acc, const)}
12974 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12975 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12976 @item @code{uw2 __MDPACKH (uw2, uw2)}
12977 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12978 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12979 @item @code{uw2 __MDROTLI (uw2, const)}
12980 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12981 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12982 @item @code{void __MDSUBACCS (acc, acc)}
12983 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12984 @tab @code{MDSUBACCS @var{a},@var{b}}
12985 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12986 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12987 @tab @code{MDUNPACKH @var{a},@var{b}}
12988 @item @code{uw2 __MEXPDHD (uw1, const)}
12989 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12990 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12991 @item @code{uw1 __MEXPDHW (uw1, const)}
12992 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12993 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12994 @item @code{uw1 __MHDSETH (uw1, const)}
12995 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12996 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12997 @item @code{sw1 __MHDSETS (const)}
12998 @tab @code{@var{b} = __MHDSETS (@var{a})}
12999 @tab @code{MHDSETS #@var{a},@var{b}}
13000 @item @code{uw1 __MHSETHIH (uw1, const)}
13001 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13002 @tab @code{MHSETHIH #@var{a},@var{b}}
13003 @item @code{sw1 __MHSETHIS (sw1, const)}
13004 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13005 @tab @code{MHSETHIS #@var{a},@var{b}}
13006 @item @code{uw1 __MHSETLOH (uw1, const)}
13007 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13008 @tab @code{MHSETLOH #@var{a},@var{b}}
13009 @item @code{sw1 __MHSETLOS (sw1, const)}
13010 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13011 @tab @code{MHSETLOS #@var{a},@var{b}}
13012 @item @code{uw1 __MHTOB (uw2)}
13013 @tab @code{@var{b} = __MHTOB (@var{a})}
13014 @tab @code{MHTOB @var{a},@var{b}}
13015 @item @code{void __MMACHS (acc, sw1, sw1)}
13016 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13017 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13018 @item @code{void __MMACHU (acc, uw1, uw1)}
13019 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13020 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13021 @item @code{void __MMRDHS (acc, sw1, sw1)}
13022 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13023 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13024 @item @code{void __MMRDHU (acc, uw1, uw1)}
13025 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13026 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13027 @item @code{void __MMULHS (acc, sw1, sw1)}
13028 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13029 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13030 @item @code{void __MMULHU (acc, uw1, uw1)}
13031 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13032 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13033 @item @code{void __MMULXHS (acc, sw1, sw1)}
13034 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13035 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13036 @item @code{void __MMULXHU (acc, uw1, uw1)}
13037 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13038 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13039 @item @code{uw1 __MNOT (uw1)}
13040 @tab @code{@var{b} = __MNOT (@var{a})}
13041 @tab @code{MNOT @var{a},@var{b}}
13042 @item @code{uw1 __MOR (uw1, uw1)}
13043 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13044 @tab @code{MOR @var{a},@var{b},@var{c}}
13045 @item @code{uw1 __MPACKH (uh, uh)}
13046 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13047 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13048 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13049 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13050 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13051 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13052 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13053 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13054 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13055 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13056 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13057 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13058 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13059 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13060 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13061 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13062 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13063 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13064 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13065 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13066 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13067 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13068 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13069 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13070 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13071 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13072 @item @code{void __MQMACHS (acc, sw2, sw2)}
13073 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13074 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13075 @item @code{void __MQMACHU (acc, uw2, uw2)}
13076 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13077 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13078 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13079 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13080 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13081 @item @code{void __MQMULHS (acc, sw2, sw2)}
13082 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13083 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13084 @item @code{void __MQMULHU (acc, uw2, uw2)}
13085 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13086 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13087 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13088 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13089 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13090 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13091 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13092 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13093 @item @code{sw2 __MQSATHS (sw2, sw2)}
13094 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13095 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13096 @item @code{uw2 __MQSLLHI (uw2, int)}
13097 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13098 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13099 @item @code{sw2 __MQSRAHI (sw2, int)}
13100 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13101 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13102 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13103 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13104 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13105 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13106 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13107 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13108 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13109 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13110 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13111 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13112 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13113 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13114 @item @code{uw1 __MRDACC (acc)}
13115 @tab @code{@var{b} = __MRDACC (@var{a})}
13116 @tab @code{MRDACC @var{a},@var{b}}
13117 @item @code{uw1 __MRDACCG (acc)}
13118 @tab @code{@var{b} = __MRDACCG (@var{a})}
13119 @tab @code{MRDACCG @var{a},@var{b}}
13120 @item @code{uw1 __MROTLI (uw1, const)}
13121 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13122 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13123 @item @code{uw1 __MROTRI (uw1, const)}
13124 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13125 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13126 @item @code{sw1 __MSATHS (sw1, sw1)}
13127 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13128 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13129 @item @code{uw1 __MSATHU (uw1, uw1)}
13130 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13131 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13132 @item @code{uw1 __MSLLHI (uw1, const)}
13133 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13134 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13135 @item @code{sw1 __MSRAHI (sw1, const)}
13136 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13137 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13138 @item @code{uw1 __MSRLHI (uw1, const)}
13139 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13140 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13141 @item @code{void __MSUBACCS (acc, acc)}
13142 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13143 @tab @code{MSUBACCS @var{a},@var{b}}
13144 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13145 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13146 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13147 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13148 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13149 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13150 @item @code{void __MTRAP (void)}
13151 @tab @code{__MTRAP ()}
13152 @tab @code{MTRAP}
13153 @item @code{uw2 __MUNPACKH (uw1)}
13154 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13155 @tab @code{MUNPACKH @var{a},@var{b}}
13156 @item @code{uw1 __MWCUT (uw2, uw1)}
13157 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13158 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13159 @item @code{void __MWTACC (acc, uw1)}
13160 @tab @code{__MWTACC (@var{b}, @var{a})}
13161 @tab @code{MWTACC @var{a},@var{b}}
13162 @item @code{void __MWTACCG (acc, uw1)}
13163 @tab @code{__MWTACCG (@var{b}, @var{a})}
13164 @tab @code{MWTACCG @var{a},@var{b}}
13165 @item @code{uw1 __MXOR (uw1, uw1)}
13166 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13167 @tab @code{MXOR @var{a},@var{b},@var{c}}
13168 @end multitable
13170 @node Raw read/write Functions
13171 @subsubsection Raw Read/Write Functions
13173 This sections describes built-in functions related to read and write
13174 instructions to access memory.  These functions generate
13175 @code{membar} instructions to flush the I/O load and stores where
13176 appropriate, as described in Fujitsu's manual described above.
13178 @table @code
13180 @item unsigned char __builtin_read8 (void *@var{data})
13181 @item unsigned short __builtin_read16 (void *@var{data})
13182 @item unsigned long __builtin_read32 (void *@var{data})
13183 @item unsigned long long __builtin_read64 (void *@var{data})
13185 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13186 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13187 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13188 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13189 @end table
13191 @node Other Built-in Functions
13192 @subsubsection Other Built-in Functions
13194 This section describes built-in functions that are not named after
13195 a specific FR-V instruction.
13197 @table @code
13198 @item sw2 __IACCreadll (iacc @var{reg})
13199 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13200 for future expansion and must be 0.
13202 @item sw1 __IACCreadl (iacc @var{reg})
13203 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13204 Other values of @var{reg} are rejected as invalid.
13206 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13207 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13208 is reserved for future expansion and must be 0.
13210 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13211 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13212 is 1.  Other values of @var{reg} are rejected as invalid.
13214 @item void __data_prefetch0 (const void *@var{x})
13215 Use the @code{dcpl} instruction to load the contents of address @var{x}
13216 into the data cache.
13218 @item void __data_prefetch (const void *@var{x})
13219 Use the @code{nldub} instruction to load the contents of address @var{x}
13220 into the data cache.  The instruction is issued in slot I1@.
13221 @end table
13223 @node MIPS DSP Built-in Functions
13224 @subsection MIPS DSP Built-in Functions
13226 The MIPS DSP Application-Specific Extension (ASE) includes new
13227 instructions that are designed to improve the performance of DSP and
13228 media applications.  It provides instructions that operate on packed
13229 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13231 GCC supports MIPS DSP operations using both the generic
13232 vector extensions (@pxref{Vector Extensions}) and a collection of
13233 MIPS-specific built-in functions.  Both kinds of support are
13234 enabled by the @option{-mdsp} command-line option.
13236 Revision 2 of the ASE was introduced in the second half of 2006.
13237 This revision adds extra instructions to the original ASE, but is
13238 otherwise backwards-compatible with it.  You can select revision 2
13239 using the command-line option @option{-mdspr2}; this option implies
13240 @option{-mdsp}.
13242 The SCOUNT and POS bits of the DSP control register are global.  The
13243 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13244 POS bits.  During optimization, the compiler does not delete these
13245 instructions and it does not delete calls to functions containing
13246 these instructions.
13248 At present, GCC only provides support for operations on 32-bit
13249 vectors.  The vector type associated with 8-bit integer data is
13250 usually called @code{v4i8}, the vector type associated with Q7
13251 is usually called @code{v4q7}, the vector type associated with 16-bit
13252 integer data is usually called @code{v2i16}, and the vector type
13253 associated with Q15 is usually called @code{v2q15}.  They can be
13254 defined in C as follows:
13256 @smallexample
13257 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13258 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13259 typedef short v2i16 __attribute__ ((vector_size(4)));
13260 typedef short v2q15 __attribute__ ((vector_size(4)));
13261 @end smallexample
13263 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13264 initialized in the same way as aggregates.  For example:
13266 @smallexample
13267 v4i8 a = @{1, 2, 3, 4@};
13268 v4i8 b;
13269 b = (v4i8) @{5, 6, 7, 8@};
13271 v2q15 c = @{0x0fcb, 0x3a75@};
13272 v2q15 d;
13273 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13274 @end smallexample
13276 @emph{Note:} The CPU's endianness determines the order in which values
13277 are packed.  On little-endian targets, the first value is the least
13278 significant and the last value is the most significant.  The opposite
13279 order applies to big-endian targets.  For example, the code above
13280 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13281 and @code{4} on big-endian targets.
13283 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13284 representation.  As shown in this example, the integer representation
13285 of a Q7 value can be obtained by multiplying the fractional value by
13286 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13287 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13288 @code{0x1.0p31}.
13290 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13291 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13292 and @code{c} and @code{d} are @code{v2q15} values.
13294 @multitable @columnfractions .50 .50
13295 @item C code @tab MIPS instruction
13296 @item @code{a + b} @tab @code{addu.qb}
13297 @item @code{c + d} @tab @code{addq.ph}
13298 @item @code{a - b} @tab @code{subu.qb}
13299 @item @code{c - d} @tab @code{subq.ph}
13300 @end multitable
13302 The table below lists the @code{v2i16} operation for which
13303 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13304 @code{v2i16} values.
13306 @multitable @columnfractions .50 .50
13307 @item C code @tab MIPS instruction
13308 @item @code{e * f} @tab @code{mul.ph}
13309 @end multitable
13311 It is easier to describe the DSP built-in functions if we first define
13312 the following types:
13314 @smallexample
13315 typedef int q31;
13316 typedef int i32;
13317 typedef unsigned int ui32;
13318 typedef long long a64;
13319 @end smallexample
13321 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13322 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13323 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13324 @code{long long}, but we use @code{a64} to indicate values that are
13325 placed in one of the four DSP accumulators (@code{$ac0},
13326 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13328 Also, some built-in functions prefer or require immediate numbers as
13329 parameters, because the corresponding DSP instructions accept both immediate
13330 numbers and register operands, or accept immediate numbers only.  The
13331 immediate parameters are listed as follows.
13333 @smallexample
13334 imm0_3: 0 to 3.
13335 imm0_7: 0 to 7.
13336 imm0_15: 0 to 15.
13337 imm0_31: 0 to 31.
13338 imm0_63: 0 to 63.
13339 imm0_255: 0 to 255.
13340 imm_n32_31: -32 to 31.
13341 imm_n512_511: -512 to 511.
13342 @end smallexample
13344 The following built-in functions map directly to a particular MIPS DSP
13345 instruction.  Please refer to the architecture specification
13346 for details on what each instruction does.
13348 @smallexample
13349 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13350 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13351 q31 __builtin_mips_addq_s_w (q31, q31)
13352 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13353 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13354 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13355 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13356 q31 __builtin_mips_subq_s_w (q31, q31)
13357 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13358 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13359 i32 __builtin_mips_addsc (i32, i32)
13360 i32 __builtin_mips_addwc (i32, i32)
13361 i32 __builtin_mips_modsub (i32, i32)
13362 i32 __builtin_mips_raddu_w_qb (v4i8)
13363 v2q15 __builtin_mips_absq_s_ph (v2q15)
13364 q31 __builtin_mips_absq_s_w (q31)
13365 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13366 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13367 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13368 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13369 q31 __builtin_mips_preceq_w_phl (v2q15)
13370 q31 __builtin_mips_preceq_w_phr (v2q15)
13371 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13372 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13373 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13374 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13375 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13376 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13377 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13378 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13379 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13380 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13381 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13382 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13383 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13384 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13385 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13386 q31 __builtin_mips_shll_s_w (q31, i32)
13387 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13388 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13389 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13390 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13391 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13392 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13393 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13394 q31 __builtin_mips_shra_r_w (q31, i32)
13395 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13396 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13397 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13398 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13399 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13400 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13401 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13402 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13403 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13404 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13405 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13406 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13407 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13408 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13409 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13410 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13411 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13412 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13413 i32 __builtin_mips_bitrev (i32)
13414 i32 __builtin_mips_insv (i32, i32)
13415 v4i8 __builtin_mips_repl_qb (imm0_255)
13416 v4i8 __builtin_mips_repl_qb (i32)
13417 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13418 v2q15 __builtin_mips_repl_ph (i32)
13419 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13420 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13421 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13422 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13423 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13424 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13425 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13426 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13427 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13428 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13429 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13430 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13431 i32 __builtin_mips_extr_w (a64, imm0_31)
13432 i32 __builtin_mips_extr_w (a64, i32)
13433 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13434 i32 __builtin_mips_extr_s_h (a64, i32)
13435 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13436 i32 __builtin_mips_extr_rs_w (a64, i32)
13437 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13438 i32 __builtin_mips_extr_r_w (a64, i32)
13439 i32 __builtin_mips_extp (a64, imm0_31)
13440 i32 __builtin_mips_extp (a64, i32)
13441 i32 __builtin_mips_extpdp (a64, imm0_31)
13442 i32 __builtin_mips_extpdp (a64, i32)
13443 a64 __builtin_mips_shilo (a64, imm_n32_31)
13444 a64 __builtin_mips_shilo (a64, i32)
13445 a64 __builtin_mips_mthlip (a64, i32)
13446 void __builtin_mips_wrdsp (i32, imm0_63)
13447 i32 __builtin_mips_rddsp (imm0_63)
13448 i32 __builtin_mips_lbux (void *, i32)
13449 i32 __builtin_mips_lhx (void *, i32)
13450 i32 __builtin_mips_lwx (void *, i32)
13451 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13452 i32 __builtin_mips_bposge32 (void)
13453 a64 __builtin_mips_madd (a64, i32, i32);
13454 a64 __builtin_mips_maddu (a64, ui32, ui32);
13455 a64 __builtin_mips_msub (a64, i32, i32);
13456 a64 __builtin_mips_msubu (a64, ui32, ui32);
13457 a64 __builtin_mips_mult (i32, i32);
13458 a64 __builtin_mips_multu (ui32, ui32);
13459 @end smallexample
13461 The following built-in functions map directly to a particular MIPS DSP REV 2
13462 instruction.  Please refer to the architecture specification
13463 for details on what each instruction does.
13465 @smallexample
13466 v4q7 __builtin_mips_absq_s_qb (v4q7);
13467 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13468 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13469 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13470 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13471 i32 __builtin_mips_append (i32, i32, imm0_31);
13472 i32 __builtin_mips_balign (i32, i32, imm0_3);
13473 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13474 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13475 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13476 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13477 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13478 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13479 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13480 q31 __builtin_mips_mulq_rs_w (q31, q31);
13481 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13482 q31 __builtin_mips_mulq_s_w (q31, q31);
13483 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13484 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13485 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13486 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13487 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13488 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13489 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13490 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13491 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13492 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13493 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13494 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13495 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13496 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13497 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13498 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13499 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13500 q31 __builtin_mips_addqh_w (q31, q31);
13501 q31 __builtin_mips_addqh_r_w (q31, q31);
13502 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13503 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13504 q31 __builtin_mips_subqh_w (q31, q31);
13505 q31 __builtin_mips_subqh_r_w (q31, q31);
13506 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13507 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13508 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13509 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13510 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13511 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13512 @end smallexample
13515 @node MIPS Paired-Single Support
13516 @subsection MIPS Paired-Single Support
13518 The MIPS64 architecture includes a number of instructions that
13519 operate on pairs of single-precision floating-point values.
13520 Each pair is packed into a 64-bit floating-point register,
13521 with one element being designated the ``upper half'' and
13522 the other being designated the ``lower half''.
13524 GCC supports paired-single operations using both the generic
13525 vector extensions (@pxref{Vector Extensions}) and a collection of
13526 MIPS-specific built-in functions.  Both kinds of support are
13527 enabled by the @option{-mpaired-single} command-line option.
13529 The vector type associated with paired-single values is usually
13530 called @code{v2sf}.  It can be defined in C as follows:
13532 @smallexample
13533 typedef float v2sf __attribute__ ((vector_size (8)));
13534 @end smallexample
13536 @code{v2sf} values are initialized in the same way as aggregates.
13537 For example:
13539 @smallexample
13540 v2sf a = @{1.5, 9.1@};
13541 v2sf b;
13542 float e, f;
13543 b = (v2sf) @{e, f@};
13544 @end smallexample
13546 @emph{Note:} The CPU's endianness determines which value is stored in
13547 the upper half of a register and which value is stored in the lower half.
13548 On little-endian targets, the first value is the lower one and the second
13549 value is the upper one.  The opposite order applies to big-endian targets.
13550 For example, the code above sets the lower half of @code{a} to
13551 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13553 @node MIPS Loongson Built-in Functions
13554 @subsection MIPS Loongson Built-in Functions
13556 GCC provides intrinsics to access the SIMD instructions provided by the
13557 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
13558 available after inclusion of the @code{loongson.h} header file,
13559 operate on the following 64-bit vector types:
13561 @itemize
13562 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13563 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13564 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13565 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13566 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13567 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13568 @end itemize
13570 The intrinsics provided are listed below; each is named after the
13571 machine instruction to which it corresponds, with suffixes added as
13572 appropriate to distinguish intrinsics that expand to the same machine
13573 instruction yet have different argument types.  Refer to the architecture
13574 documentation for a description of the functionality of each
13575 instruction.
13577 @smallexample
13578 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13579 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13580 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13581 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13582 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13583 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13584 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13585 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13586 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13587 uint64_t paddd_u (uint64_t s, uint64_t t);
13588 int64_t paddd_s (int64_t s, int64_t t);
13589 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13590 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13591 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13592 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13593 uint64_t pandn_ud (uint64_t s, uint64_t t);
13594 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13595 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13596 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13597 int64_t pandn_sd (int64_t s, int64_t t);
13598 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13599 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13600 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13601 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13602 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13603 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13604 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13605 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13606 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13607 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13608 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13609 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13610 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13611 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13612 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13613 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13614 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13615 uint16x4_t pextrh_u (uint16x4_t s, int field);
13616 int16x4_t pextrh_s (int16x4_t s, int field);
13617 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13618 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13619 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13620 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13621 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13622 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13623 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13624 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13625 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13626 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13627 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13628 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13629 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13630 uint8x8_t pmovmskb_u (uint8x8_t s);
13631 int8x8_t pmovmskb_s (int8x8_t s);
13632 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13633 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13634 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13635 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13636 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13637 uint16x4_t biadd (uint8x8_t s);
13638 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13639 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13640 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13641 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13642 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13643 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13644 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13645 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13646 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13647 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13648 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13649 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13650 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13651 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13652 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13653 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13654 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13655 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13656 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13657 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13658 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13659 uint64_t psubd_u (uint64_t s, uint64_t t);
13660 int64_t psubd_s (int64_t s, int64_t t);
13661 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13662 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13663 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13664 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13665 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13666 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13667 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13668 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13669 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13670 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13671 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13672 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13673 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13674 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13675 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13676 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13677 @end smallexample
13679 @menu
13680 * Paired-Single Arithmetic::
13681 * Paired-Single Built-in Functions::
13682 * MIPS-3D Built-in Functions::
13683 @end menu
13685 @node Paired-Single Arithmetic
13686 @subsubsection Paired-Single Arithmetic
13688 The table below lists the @code{v2sf} operations for which hardware
13689 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
13690 values and @code{x} is an integral value.
13692 @multitable @columnfractions .50 .50
13693 @item C code @tab MIPS instruction
13694 @item @code{a + b} @tab @code{add.ps}
13695 @item @code{a - b} @tab @code{sub.ps}
13696 @item @code{-a} @tab @code{neg.ps}
13697 @item @code{a * b} @tab @code{mul.ps}
13698 @item @code{a * b + c} @tab @code{madd.ps}
13699 @item @code{a * b - c} @tab @code{msub.ps}
13700 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13701 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13702 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13703 @end multitable
13705 Note that the multiply-accumulate instructions can be disabled
13706 using the command-line option @code{-mno-fused-madd}.
13708 @node Paired-Single Built-in Functions
13709 @subsubsection Paired-Single Built-in Functions
13711 The following paired-single functions map directly to a particular
13712 MIPS instruction.  Please refer to the architecture specification
13713 for details on what each instruction does.
13715 @table @code
13716 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13717 Pair lower lower (@code{pll.ps}).
13719 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13720 Pair upper lower (@code{pul.ps}).
13722 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13723 Pair lower upper (@code{plu.ps}).
13725 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13726 Pair upper upper (@code{puu.ps}).
13728 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13729 Convert pair to paired single (@code{cvt.ps.s}).
13731 @item float __builtin_mips_cvt_s_pl (v2sf)
13732 Convert pair lower to single (@code{cvt.s.pl}).
13734 @item float __builtin_mips_cvt_s_pu (v2sf)
13735 Convert pair upper to single (@code{cvt.s.pu}).
13737 @item v2sf __builtin_mips_abs_ps (v2sf)
13738 Absolute value (@code{abs.ps}).
13740 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13741 Align variable (@code{alnv.ps}).
13743 @emph{Note:} The value of the third parameter must be 0 or 4
13744 modulo 8, otherwise the result is unpredictable.  Please read the
13745 instruction description for details.
13746 @end table
13748 The following multi-instruction functions are also available.
13749 In each case, @var{cond} can be any of the 16 floating-point conditions:
13750 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13751 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13752 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13754 @table @code
13755 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13756 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13757 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13758 @code{movt.ps}/@code{movf.ps}).
13760 The @code{movt} functions return the value @var{x} computed by:
13762 @smallexample
13763 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13764 mov.ps @var{x},@var{c}
13765 movt.ps @var{x},@var{d},@var{cc}
13766 @end smallexample
13768 The @code{movf} functions are similar but use @code{movf.ps} instead
13769 of @code{movt.ps}.
13771 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13772 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13773 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13774 @code{bc1t}/@code{bc1f}).
13776 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13777 and return either the upper or lower half of the result.  For example:
13779 @smallexample
13780 v2sf a, b;
13781 if (__builtin_mips_upper_c_eq_ps (a, b))
13782   upper_halves_are_equal ();
13783 else
13784   upper_halves_are_unequal ();
13786 if (__builtin_mips_lower_c_eq_ps (a, b))
13787   lower_halves_are_equal ();
13788 else
13789   lower_halves_are_unequal ();
13790 @end smallexample
13791 @end table
13793 @node MIPS-3D Built-in Functions
13794 @subsubsection MIPS-3D Built-in Functions
13796 The MIPS-3D Application-Specific Extension (ASE) includes additional
13797 paired-single instructions that are designed to improve the performance
13798 of 3D graphics operations.  Support for these instructions is controlled
13799 by the @option{-mips3d} command-line option.
13801 The functions listed below map directly to a particular MIPS-3D
13802 instruction.  Please refer to the architecture specification for
13803 more details on what each instruction does.
13805 @table @code
13806 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13807 Reduction add (@code{addr.ps}).
13809 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13810 Reduction multiply (@code{mulr.ps}).
13812 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13813 Convert paired single to paired word (@code{cvt.pw.ps}).
13815 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13816 Convert paired word to paired single (@code{cvt.ps.pw}).
13818 @item float __builtin_mips_recip1_s (float)
13819 @itemx double __builtin_mips_recip1_d (double)
13820 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13821 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13823 @item float __builtin_mips_recip2_s (float, float)
13824 @itemx double __builtin_mips_recip2_d (double, double)
13825 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13826 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13828 @item float __builtin_mips_rsqrt1_s (float)
13829 @itemx double __builtin_mips_rsqrt1_d (double)
13830 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13831 Reduced-precision reciprocal square root (sequence step 1)
13832 (@code{rsqrt1.@var{fmt}}).
13834 @item float __builtin_mips_rsqrt2_s (float, float)
13835 @itemx double __builtin_mips_rsqrt2_d (double, double)
13836 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13837 Reduced-precision reciprocal square root (sequence step 2)
13838 (@code{rsqrt2.@var{fmt}}).
13839 @end table
13841 The following multi-instruction functions are also available.
13842 In each case, @var{cond} can be any of the 16 floating-point conditions:
13843 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13844 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13845 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13847 @table @code
13848 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13849 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13850 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13851 @code{bc1t}/@code{bc1f}).
13853 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13854 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13855 For example:
13857 @smallexample
13858 float a, b;
13859 if (__builtin_mips_cabs_eq_s (a, b))
13860   true ();
13861 else
13862   false ();
13863 @end smallexample
13865 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13866 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13867 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13868 @code{bc1t}/@code{bc1f}).
13870 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13871 and return either the upper or lower half of the result.  For example:
13873 @smallexample
13874 v2sf a, b;
13875 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13876   upper_halves_are_equal ();
13877 else
13878   upper_halves_are_unequal ();
13880 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13881   lower_halves_are_equal ();
13882 else
13883   lower_halves_are_unequal ();
13884 @end smallexample
13886 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13887 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13888 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13889 @code{movt.ps}/@code{movf.ps}).
13891 The @code{movt} functions return the value @var{x} computed by:
13893 @smallexample
13894 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13895 mov.ps @var{x},@var{c}
13896 movt.ps @var{x},@var{d},@var{cc}
13897 @end smallexample
13899 The @code{movf} functions are similar but use @code{movf.ps} instead
13900 of @code{movt.ps}.
13902 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13903 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13904 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13905 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13906 Comparison of two paired-single values
13907 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13908 @code{bc1any2t}/@code{bc1any2f}).
13910 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13911 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
13912 result is true and the @code{all} forms return true if both results are true.
13913 For example:
13915 @smallexample
13916 v2sf a, b;
13917 if (__builtin_mips_any_c_eq_ps (a, b))
13918   one_is_true ();
13919 else
13920   both_are_false ();
13922 if (__builtin_mips_all_c_eq_ps (a, b))
13923   both_are_true ();
13924 else
13925   one_is_false ();
13926 @end smallexample
13928 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13929 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13930 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13931 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13932 Comparison of four paired-single values
13933 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13934 @code{bc1any4t}/@code{bc1any4f}).
13936 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13937 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13938 The @code{any} forms return true if any of the four results are true
13939 and the @code{all} forms return true if all four results are true.
13940 For example:
13942 @smallexample
13943 v2sf a, b, c, d;
13944 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13945   some_are_true ();
13946 else
13947   all_are_false ();
13949 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13950   all_are_true ();
13951 else
13952   some_are_false ();
13953 @end smallexample
13954 @end table
13956 @node MIPS SIMD Architecture (MSA) Support
13957 @subsection MIPS SIMD Architecture (MSA) Support
13959 @menu
13960 * MIPS SIMD Architecture Built-in Functions::
13961 @end menu
13963 GCC provides intrinsics to access the SIMD instructions provided by the
13964 MSA MIPS SIMD Architecture.  The interface is made available by including
13965 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13966 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13967 @code{__msa_*}.
13969 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13970 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13971 data elements.  The following vectors typedefs are included in @code{msa.h}:
13972 @itemize
13973 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13974 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13975 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13976 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13977 @item @code{v4i32}, a vector of four signed 32-bit integers;
13978 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13979 @item @code{v2i64}, a vector of two signed 64-bit integers;
13980 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13981 @item @code{v4f32}, a vector of four 32-bit floats;
13982 @item @code{v2f64}, a vector of two 64-bit doubles.
13983 @end itemize
13985 Intructions and corresponding built-ins may have additional restrictions and/or
13986 input/output values manipulated:
13987 @itemize
13988 @item @code{imm0_1}, an integer literal in range 0 to 1;
13989 @item @code{imm0_3}, an integer literal in range 0 to 3;
13990 @item @code{imm0_7}, an integer literal in range 0 to 7;
13991 @item @code{imm0_15}, an integer literal in range 0 to 15;
13992 @item @code{imm0_31}, an integer literal in range 0 to 31;
13993 @item @code{imm0_63}, an integer literal in range 0 to 63;
13994 @item @code{imm0_255}, an integer literal in range 0 to 255;
13995 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
13996 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
13997 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
13998 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
13999 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14000 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14001 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14002 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14003 @item @code{imm1_4}, an integer literal in range 1 to 4;
14004 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14005 @end itemize
14007 @smallexample
14009 typedef int i32;
14010 #if __LONG_MAX__ == __LONG_LONG_MAX__
14011 typedef long i64;
14012 #else
14013 typedef long long i64;
14014 #endif
14016 typedef unsigned int u32;
14017 #if __LONG_MAX__ == __LONG_LONG_MAX__
14018 typedef unsigned long u64;
14019 #else
14020 typedef unsigned long long u64;
14021 #endif
14023 typedef double f64;
14024 typedef float f32;
14026 @end smallexample
14028 @node MIPS SIMD Architecture Built-in Functions
14029 @subsubsection MIPS SIMD Architecture Built-in Functions
14031 The intrinsics provided are listed below; each is named after the
14032 machine instruction.
14034 @smallexample
14035 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14036 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14037 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14038 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14040 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14041 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14042 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14043 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14045 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14046 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14047 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14048 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14050 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14051 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14052 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14053 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14055 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14056 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14057 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14058 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14060 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14061 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14062 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14063 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14065 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14067 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14069 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14070 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14071 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14072 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14074 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14075 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14076 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14077 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14079 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14080 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14081 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14082 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14084 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14085 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14086 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14087 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14089 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14090 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14091 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14092 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14094 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14095 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14096 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14097 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14099 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14100 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14101 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14102 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14104 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14105 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14106 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14107 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14109 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14110 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14111 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14112 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14114 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14115 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14116 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14117 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14119 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14120 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14121 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14122 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14124 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14125 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14126 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14127 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14129 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14131 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14133 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14135 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14137 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14138 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14139 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14140 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14142 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14143 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14144 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14145 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14147 i32 __builtin_msa_bnz_b (v16u8);
14148 i32 __builtin_msa_bnz_h (v8u16);
14149 i32 __builtin_msa_bnz_w (v4u32);
14150 i32 __builtin_msa_bnz_d (v2u64);
14152 i32 __builtin_msa_bnz_v (v16u8);
14154 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14156 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14158 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14159 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14160 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14161 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14163 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14164 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14165 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14166 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14168 i32 __builtin_msa_bz_b (v16u8);
14169 i32 __builtin_msa_bz_h (v8u16);
14170 i32 __builtin_msa_bz_w (v4u32);
14171 i32 __builtin_msa_bz_d (v2u64);
14173 i32 __builtin_msa_bz_v (v16u8);
14175 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14176 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14177 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14178 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14180 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14181 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14182 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14183 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14185 i32 __builtin_msa_cfcmsa (imm0_31);
14187 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14188 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14189 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14190 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14192 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14193 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14194 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14195 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14197 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14198 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14199 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14200 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14202 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14203 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14204 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14205 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14207 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14208 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14209 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14210 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14212 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14213 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14214 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14215 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14217 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14218 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14219 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14220 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14222 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14223 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14224 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14225 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14227 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14228 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14229 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14230 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14232 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14233 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14234 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14235 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14237 void __builtin_msa_ctcmsa (imm0_31, i32);
14239 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14240 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14241 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14242 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14244 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14245 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14246 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14247 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14249 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14250 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14251 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14253 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14254 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14255 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14257 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14258 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14259 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14261 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14262 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14263 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14265 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14266 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14267 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14269 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14270 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14271 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14273 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14274 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14276 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14277 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14279 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14280 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14282 v4i32 __builtin_msa_fclass_w (v4f32);
14283 v2i64 __builtin_msa_fclass_d (v2f64);
14285 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14286 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14288 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14289 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14291 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14292 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14294 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14295 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14297 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14298 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14300 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14301 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14303 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14304 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14306 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14307 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14309 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14310 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14312 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14313 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14315 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14316 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14318 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14319 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14321 v4f32 __builtin_msa_fexupl_w (v8i16);
14322 v2f64 __builtin_msa_fexupl_d (v4f32);
14324 v4f32 __builtin_msa_fexupr_w (v8i16);
14325 v2f64 __builtin_msa_fexupr_d (v4f32);
14327 v4f32 __builtin_msa_ffint_s_w (v4i32);
14328 v2f64 __builtin_msa_ffint_s_d (v2i64);
14330 v4f32 __builtin_msa_ffint_u_w (v4u32);
14331 v2f64 __builtin_msa_ffint_u_d (v2u64);
14333 v4f32 __builtin_msa_ffql_w (v8i16);
14334 v2f64 __builtin_msa_ffql_d (v4i32);
14336 v4f32 __builtin_msa_ffqr_w (v8i16);
14337 v2f64 __builtin_msa_ffqr_d (v4i32);
14339 v16i8 __builtin_msa_fill_b (i32);
14340 v8i16 __builtin_msa_fill_h (i32);
14341 v4i32 __builtin_msa_fill_w (i32);
14342 v2i64 __builtin_msa_fill_d (i64);
14344 v4f32 __builtin_msa_flog2_w (v4f32);
14345 v2f64 __builtin_msa_flog2_d (v2f64);
14347 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14348 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14350 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14351 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14353 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14354 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14356 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14357 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14359 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14360 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14362 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14363 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14365 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14366 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14368 v4f32 __builtin_msa_frint_w (v4f32);
14369 v2f64 __builtin_msa_frint_d (v2f64);
14371 v4f32 __builtin_msa_frcp_w (v4f32);
14372 v2f64 __builtin_msa_frcp_d (v2f64);
14374 v4f32 __builtin_msa_frsqrt_w (v4f32);
14375 v2f64 __builtin_msa_frsqrt_d (v2f64);
14377 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14378 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14380 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14381 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14383 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14384 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14386 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14387 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14389 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14390 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14392 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14393 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14395 v4f32 __builtin_msa_fsqrt_w (v4f32);
14396 v2f64 __builtin_msa_fsqrt_d (v2f64);
14398 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14399 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14401 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14402 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14404 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14405 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14407 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14408 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14410 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14411 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14413 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14414 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14416 v4i32 __builtin_msa_ftint_s_w (v4f32);
14417 v2i64 __builtin_msa_ftint_s_d (v2f64);
14419 v4u32 __builtin_msa_ftint_u_w (v4f32);
14420 v2u64 __builtin_msa_ftint_u_d (v2f64);
14422 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14423 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14425 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14426 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14428 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14429 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14431 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14432 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14433 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14435 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14436 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14437 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14439 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14440 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14441 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14443 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14444 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14445 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14447 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14448 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14449 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14450 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14452 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14453 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14454 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14455 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14457 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14458 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14459 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14460 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14462 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14463 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14464 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14465 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14467 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14468 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14469 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14470 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14472 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14473 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14474 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14475 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14477 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14478 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14479 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14480 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14482 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14483 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14484 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14485 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14487 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14488 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14490 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14491 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14493 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14494 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14495 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14496 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14498 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14499 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14500 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14501 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14503 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14504 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14505 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14506 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14508 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14509 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14510 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14511 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14513 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14514 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14515 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14516 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14518 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14519 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14520 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14521 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14523 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14524 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14525 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14526 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14528 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14529 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14530 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14531 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14533 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14534 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14535 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14536 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14538 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14539 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14540 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14541 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14543 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14544 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14545 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14546 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14548 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14549 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14550 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14551 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14553 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14554 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14555 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14556 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14558 v16i8 __builtin_msa_move_v (v16i8);
14560 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14561 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14563 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14564 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14566 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14567 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14568 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14569 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14571 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14572 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14574 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14575 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14577 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14578 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14579 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14580 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14582 v16i8 __builtin_msa_nloc_b (v16i8);
14583 v8i16 __builtin_msa_nloc_h (v8i16);
14584 v4i32 __builtin_msa_nloc_w (v4i32);
14585 v2i64 __builtin_msa_nloc_d (v2i64);
14587 v16i8 __builtin_msa_nlzc_b (v16i8);
14588 v8i16 __builtin_msa_nlzc_h (v8i16);
14589 v4i32 __builtin_msa_nlzc_w (v4i32);
14590 v2i64 __builtin_msa_nlzc_d (v2i64);
14592 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14594 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14596 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14598 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14600 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14601 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14602 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14603 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14605 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14606 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14607 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14608 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14610 v16i8 __builtin_msa_pcnt_b (v16i8);
14611 v8i16 __builtin_msa_pcnt_h (v8i16);
14612 v4i32 __builtin_msa_pcnt_w (v4i32);
14613 v2i64 __builtin_msa_pcnt_d (v2i64);
14615 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14616 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14617 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14618 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14620 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14621 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14622 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14623 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14625 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14626 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14627 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14629 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14630 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14631 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14632 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14634 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14635 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14636 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14637 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14639 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14640 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14641 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14642 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14644 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14645 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14646 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14647 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14649 v16i8 __builtin_msa_splat_b (v16i8, i32);
14650 v8i16 __builtin_msa_splat_h (v8i16, i32);
14651 v4i32 __builtin_msa_splat_w (v4i32, i32);
14652 v2i64 __builtin_msa_splat_d (v2i64, i32);
14654 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14655 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14656 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14657 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14659 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14660 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14661 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14662 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14664 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14665 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14666 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14667 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14669 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14670 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14671 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14672 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14674 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14675 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14676 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14677 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14679 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14680 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14681 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14682 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14684 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14685 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14686 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14687 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14689 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14690 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14691 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14692 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14694 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14695 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14696 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14697 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14699 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14700 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14701 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14702 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14704 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14705 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14706 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14707 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14709 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14710 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14711 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14712 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14714 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14715 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14716 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14717 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14719 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14720 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14721 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14722 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14724 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14725 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14726 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14727 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14729 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14730 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14731 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14732 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14734 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14735 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14736 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14737 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14739 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14741 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14742 @end smallexample
14744 @node Other MIPS Built-in Functions
14745 @subsection Other MIPS Built-in Functions
14747 GCC provides other MIPS-specific built-in functions:
14749 @table @code
14750 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14751 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14752 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14753 when this function is available.
14755 @item unsigned int __builtin_mips_get_fcsr (void)
14756 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14757 Get and set the contents of the floating-point control and status register
14758 (FPU control register 31).  These functions are only available in hard-float
14759 code but can be called in both MIPS16 and non-MIPS16 contexts.
14761 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14762 register except the condition codes, which GCC assumes are preserved.
14763 @end table
14765 @node MSP430 Built-in Functions
14766 @subsection MSP430 Built-in Functions
14768 GCC provides a couple of special builtin functions to aid in the
14769 writing of interrupt handlers in C.
14771 @table @code
14772 @item __bic_SR_register_on_exit (int @var{mask})
14773 This clears the indicated bits in the saved copy of the status register
14774 currently residing on the stack.  This only works inside interrupt
14775 handlers and the changes to the status register will only take affect
14776 once the handler returns.
14778 @item __bis_SR_register_on_exit (int @var{mask})
14779 This sets the indicated bits in the saved copy of the status register
14780 currently residing on the stack.  This only works inside interrupt
14781 handlers and the changes to the status register will only take affect
14782 once the handler returns.
14784 @item __delay_cycles (long long @var{cycles})
14785 This inserts an instruction sequence that takes exactly @var{cycles}
14786 cycles (between 0 and about 17E9) to complete.  The inserted sequence
14787 may use jumps, loops, or no-ops, and does not interfere with any other
14788 instructions.  Note that @var{cycles} must be a compile-time constant
14789 integer - that is, you must pass a number, not a variable that may be
14790 optimized to a constant later.  The number of cycles delayed by this
14791 builtin is exact.
14792 @end table
14794 @node NDS32 Built-in Functions
14795 @subsection NDS32 Built-in Functions
14797 These built-in functions are available for the NDS32 target:
14799 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14800 Insert an ISYNC instruction into the instruction stream where
14801 @var{addr} is an instruction address for serialization.
14802 @end deftypefn
14804 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14805 Insert an ISB instruction into the instruction stream.
14806 @end deftypefn
14808 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14809 Return the content of a system register which is mapped by @var{sr}.
14810 @end deftypefn
14812 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14813 Return the content of a user space register which is mapped by @var{usr}.
14814 @end deftypefn
14816 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14817 Move the @var{value} to a system register which is mapped by @var{sr}.
14818 @end deftypefn
14820 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14821 Move the @var{value} to a user space register which is mapped by @var{usr}.
14822 @end deftypefn
14824 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14825 Enable global interrupt.
14826 @end deftypefn
14828 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14829 Disable global interrupt.
14830 @end deftypefn
14832 @node picoChip Built-in Functions
14833 @subsection picoChip Built-in Functions
14835 GCC provides an interface to selected machine instructions from the
14836 picoChip instruction set.
14838 @table @code
14839 @item int __builtin_sbc (int @var{value})
14840 Sign bit count.  Return the number of consecutive bits in @var{value}
14841 that have the same value as the sign bit.  The result is the number of
14842 leading sign bits minus one, giving the number of redundant sign bits in
14843 @var{value}.
14845 @item int __builtin_byteswap (int @var{value})
14846 Byte swap.  Return the result of swapping the upper and lower bytes of
14847 @var{value}.
14849 @item int __builtin_brev (int @var{value})
14850 Bit reversal.  Return the result of reversing the bits in
14851 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14852 and so on.
14854 @item int __builtin_adds (int @var{x}, int @var{y})
14855 Saturating addition.  Return the result of adding @var{x} and @var{y},
14856 storing the value 32767 if the result overflows.
14858 @item int __builtin_subs (int @var{x}, int @var{y})
14859 Saturating subtraction.  Return the result of subtracting @var{y} from
14860 @var{x}, storing the value @minus{}32768 if the result overflows.
14862 @item void __builtin_halt (void)
14863 Halt.  The processor stops execution.  This built-in is useful for
14864 implementing assertions.
14866 @end table
14868 @node PowerPC Built-in Functions
14869 @subsection PowerPC Built-in Functions
14871 The following built-in functions are always available and can be used to
14872 check the PowerPC target platform type:
14874 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14875 This function is a @code{nop} on the PowerPC platform and is included solely
14876 to maintain API compatibility with the x86 builtins.
14877 @end deftypefn
14879 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14880 This function returns a value of @code{1} if the run-time CPU is of type
14881 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14882 detected:
14884 @table @samp
14885 @item power9
14886 IBM POWER9 Server CPU.
14887 @item power8
14888 IBM POWER8 Server CPU.
14889 @item power7
14890 IBM POWER7 Server CPU.
14891 @item power6x
14892 IBM POWER6 Server CPU (RAW mode).
14893 @item power6
14894 IBM POWER6 Server CPU (Architected mode).
14895 @item power5+
14896 IBM POWER5+ Server CPU.
14897 @item power5
14898 IBM POWER5 Server CPU.
14899 @item ppc970
14900 IBM 970 Server CPU (ie, Apple G5).
14901 @item power4
14902 IBM POWER4 Server CPU.
14903 @item ppca2
14904 IBM A2 64-bit Embedded CPU
14905 @item ppc476
14906 IBM PowerPC 476FP 32-bit Embedded CPU.
14907 @item ppc464
14908 IBM PowerPC 464 32-bit Embedded CPU.
14909 @item ppc440
14910 PowerPC 440 32-bit Embedded CPU.
14911 @item ppc405
14912 PowerPC 405 32-bit Embedded CPU.
14913 @item ppc-cell-be
14914 IBM PowerPC Cell Broadband Engine Architecture CPU.
14915 @end table
14917 Here is an example:
14918 @smallexample
14919 if (__builtin_cpu_is ("power8"))
14920   @{
14921      do_power8 (); // POWER8 specific implementation.
14922   @}
14923 else
14924   @{
14925      do_generic (); // Generic implementation.
14926   @}
14927 @end smallexample
14928 @end deftypefn
14930 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14931 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14932 feature @var{feature} and returns @code{0} otherwise. The following features can be
14933 detected:
14935 @table @samp
14936 @item 4xxmac
14937 4xx CPU has a Multiply Accumulator.
14938 @item altivec
14939 CPU has a SIMD/Vector Unit.
14940 @item arch_2_05
14941 CPU supports ISA 2.05 (eg, POWER6)
14942 @item arch_2_06
14943 CPU supports ISA 2.06 (eg, POWER7)
14944 @item arch_2_07
14945 CPU supports ISA 2.07 (eg, POWER8)
14946 @item arch_3_00
14947 CPU supports ISA 3.0 (eg, POWER9)
14948 @item archpmu
14949 CPU supports the set of compatible performance monitoring events.
14950 @item booke
14951 CPU supports the Embedded ISA category.
14952 @item cellbe
14953 CPU has a CELL broadband engine.
14954 @item dfp
14955 CPU has a decimal floating point unit.
14956 @item dscr
14957 CPU supports the data stream control register.
14958 @item ebb
14959 CPU supports event base branching.
14960 @item efpdouble
14961 CPU has a SPE double precision floating point unit.
14962 @item efpsingle
14963 CPU has a SPE single precision floating point unit.
14964 @item fpu
14965 CPU has a floating point unit.
14966 @item htm
14967 CPU has hardware transaction memory instructions.
14968 @item htm-nosc
14969 Kernel aborts hardware transactions when a syscall is made.
14970 @item ic_snoop
14971 CPU supports icache snooping capabilities.
14972 @item ieee128
14973 CPU supports 128-bit IEEE binary floating point instructions.
14974 @item isel
14975 CPU supports the integer select instruction.
14976 @item mmu
14977 CPU has a memory management unit.
14978 @item notb
14979 CPU does not have a timebase (eg, 601 and 403gx).
14980 @item pa6t
14981 CPU supports the PA Semi 6T CORE ISA.
14982 @item power4
14983 CPU supports ISA 2.00 (eg, POWER4)
14984 @item power5
14985 CPU supports ISA 2.02 (eg, POWER5)
14986 @item power5+
14987 CPU supports ISA 2.03 (eg, POWER5+)
14988 @item power6x
14989 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
14990 @item ppc32
14991 CPU supports 32-bit mode execution.
14992 @item ppc601
14993 CPU supports the old POWER ISA (eg, 601)
14994 @item ppc64
14995 CPU supports 64-bit mode execution.
14996 @item ppcle
14997 CPU supports a little-endian mode that uses address swizzling.
14998 @item smt
14999 CPU support simultaneous multi-threading.
15000 @item spe
15001 CPU has a signal processing extension unit.
15002 @item tar
15003 CPU supports the target address register.
15004 @item true_le
15005 CPU supports true little-endian mode.
15006 @item ucache
15007 CPU has unified I/D cache.
15008 @item vcrypto
15009 CPU supports the vector cryptography instructions.
15010 @item vsx
15011 CPU supports the vector-scalar extension.
15012 @end table
15014 Here is an example:
15015 @smallexample
15016 if (__builtin_cpu_supports ("fpu"))
15017   @{
15018      asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15019   @}
15020 else
15021   @{
15022      dst = __fadd (src1, src2); // Software FP addition function.
15023   @}
15024 @end smallexample
15025 @end deftypefn
15027 These built-in functions are available for the PowerPC family of
15028 processors:
15029 @smallexample
15030 float __builtin_recipdivf (float, float);
15031 float __builtin_rsqrtf (float);
15032 double __builtin_recipdiv (double, double);
15033 double __builtin_rsqrt (double);
15034 uint64_t __builtin_ppc_get_timebase ();
15035 unsigned long __builtin_ppc_mftb ();
15036 double __builtin_unpack_longdouble (long double, int);
15037 long double __builtin_pack_longdouble (double, double);
15038 @end smallexample
15040 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15041 @code{__builtin_rsqrtf} functions generate multiple instructions to
15042 implement the reciprocal sqrt functionality using reciprocal sqrt
15043 estimate instructions.
15045 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15046 functions generate multiple instructions to implement division using
15047 the reciprocal estimate instructions.
15049 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15050 functions generate instructions to read the Time Base Register.  The
15051 @code{__builtin_ppc_get_timebase} function may generate multiple
15052 instructions and always returns the 64 bits of the Time Base Register.
15053 The @code{__builtin_ppc_mftb} function always generates one instruction and
15054 returns the Time Base Register value as an unsigned long, throwing away
15055 the most significant word on 32-bit environments.
15057 Additional built-in functions are available for the 64-bit PowerPC
15058 family of processors, for efficient use of 128-bit floating point
15059 (@code{__float128}) values.
15061 The following floating-point built-in functions are available with
15062 @code{-mfloat128} and Altivec support.  All of them implement the
15063 function that is part of the name.
15065 @smallexample
15066 __float128 __builtin_fabsq (__float128)
15067 __float128 __builtin_copysignq (__float128, __float128)
15068 @end smallexample
15070 The following built-in functions are available with @code{-mfloat128}
15071 and Altivec support.
15073 @table @code
15074 @item __float128 __builtin_infq (void)
15075 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15076 @findex __builtin_infq
15078 @item __float128 __builtin_huge_valq (void)
15079 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15080 @findex __builtin_huge_valq
15082 @item __float128 __builtin_nanq (void)
15083 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
15084 @findex __builtin_nanq
15086 @item __float128 __builtin_nansq (void)
15087 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
15088 @findex __builtin_nansq
15089 @end table
15091 The following built-in functions are available for the PowerPC family
15092 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15093 or @option{-mpopcntd}):
15094 @smallexample
15095 long __builtin_bpermd (long, long);
15096 int __builtin_divwe (int, int);
15097 int __builtin_divweo (int, int);
15098 unsigned int __builtin_divweu (unsigned int, unsigned int);
15099 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15100 long __builtin_divde (long, long);
15101 long __builtin_divdeo (long, long);
15102 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15103 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15104 unsigned int cdtbcd (unsigned int);
15105 unsigned int cbcdtd (unsigned int);
15106 unsigned int addg6s (unsigned int, unsigned int);
15107 @end smallexample
15109 The @code{__builtin_divde}, @code{__builtin_divdeo},
15110 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15111 64-bit environment support ISA 2.06 or later.
15113 The following built-in functions are available for the PowerPC family
15114 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15115 @smallexample
15116 long long __builtin_darn (void);
15117 long long __builtin_darn_raw (void);
15118 int __builtin_darn_32 (void);
15120 unsigned int scalar_extract_exp (double source);
15121 unsigned long long int scalar_extract_sig (double source);
15123 double
15124 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15126 int scalar_cmp_exp_gt (double arg1, double arg2);
15127 int scalar_cmp_exp_lt (double arg1, double arg2);
15128 int scalar_cmp_exp_eq (double arg1, double arg2);
15129 int scalar_cmp_exp_unordered (double arg1, double arg2);
15131 int scalar_test_data_class (float source, unsigned int condition);
15132 int scalar_test_data_class (double source, unsigned int condition);
15134 int scalar_test_neg (float source);
15135 int scalar_test_neg (double source);
15137 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15138 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15139 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15141 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15142 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15143 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15144 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15146 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15147 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15148 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15149 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15151 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15152 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15153 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15154 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15156 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15157 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15158 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15159 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15160 @end smallexample
15162 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15163 functions require a
15164 64-bit environment supporting ISA 3.0 or later.
15165 The @code{__builtin_darn} function provides a 64-bit conditioned
15166 random number.  The @code{__builtin_darn_raw} function provides a
15167 64-bit raw random number.  The @code{__builtin_darn_32} function
15168 provides a 32-bit random number.
15170 The @code{scalar_extract_sig} and @code{scalar_insert_exp}
15171 functions require a 64-bit environment supporting ISA 3.0 or later.
15172 The @code{scalar_extract_exp} and @code{vec_extract_sig} built-in
15173 functions return the significand and exponent respectively of their
15174 @code{source} arguments.  The
15175 @code{scalar_insert_exp} built-in function returns a double-precision
15176 floating point value that is constructed by assembling the values of its
15177 @code{significand} and @code{exponent} arguments.  The sign of the
15178 result is copied from the most significant bit of the
15179 @code{significand} argument.  The significand and exponent components
15180 of the result are composed of the least significant 11 bits of the
15181 @code{significand} argument and the least significant 52 bits of the
15182 @code{exponent} argument.
15184 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15185 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15186 functions return a non-zero value if @code{arg1} is greater than, less
15187 than, equal to, or not comparable to @code{arg2} respectively.  The
15188 arguments are not comparable if one or the other equals NaN (not a
15189 number). 
15191 The @code{scalar_test_data_class} built-in functions return a non-zero
15192 value if any of the condition tests enabled by the value of the
15193 @code{condition} variable are true.  The
15194 @code{condition} argument must be an unsigned integer with value not
15195 exceeding 127.  The
15196 @code{condition} argument is encoded as a bitmask with each bit
15197 enabling the testing of a different condition, as characterized by the
15198 following:
15199 @smallexample
15200 0x40    Test for NaN
15201 0x20    Test for +Infinity
15202 0x10    Test for -Infinity
15203 0x08    Test for +Zero
15204 0x04    Test for -Zero
15205 0x02    Test for +Denormal
15206 0x01    Test for -Denormal
15207 @end smallexample
15209 If all of the enabled test conditions are false, the return value is 0.
15211 The @code{scalar_test_neg} built-in functions return a non-zero value
15212 if their @code{source} argument holds a negative value.
15214 The @code{__builtin_byte_in_set} function requires a
15215 64-bit environment supporting ISA 3.0 or later.  This function returns
15216 a non-zero value if and only if its @code{u} argument exactly equals one of
15217 the eight bytes contained within its 64-bit @code{set} argument.
15219 The @code{__builtin_byte_in_range} and
15220 @code{__builtin_byte_in_either_range} require an environment
15221 supporting ISA 3.0 or later.  For these two functions, the
15222 @code{range} argument is encoded as 4 bytes, organized as
15223 @code{hi_1:lo_1:hi_2:lo_2}.
15224 The @code{__builtin_byte_in_range} function returns a
15225 non-zero value if and only if its @code{u} argument is within the
15226 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15227 The @code{__builtin_byte_in_either_range} function returns non-zero if
15228 and only if its @code{u} argument is within either the range bounded
15229 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15230 between @code{lo_2} and @code{hi_2} inclusive.
15232 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15233 if and only if the number of signficant digits of its @code{value} argument
15234 is less than its @code{comparison} argument.  The
15235 @code{__builtin_dfp_dtstsfi_lt_dd} and
15236 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15237 require that the type of the @code{value} argument be
15238 @code{__Decimal64} and @code{__Decimal128} respectively.
15240 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15241 if and only if the number of signficant digits of its @code{value} argument
15242 is greater than its @code{comparison} argument.  The
15243 @code{__builtin_dfp_dtstsfi_gt_dd} and
15244 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15245 require that the type of the @code{value} argument be
15246 @code{__Decimal64} and @code{__Decimal128} respectively.
15248 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15249 if and only if the number of signficant digits of its @code{value} argument
15250 equals its @code{comparison} argument.  The
15251 @code{__builtin_dfp_dtstsfi_eq_dd} and
15252 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15253 require that the type of the @code{value} argument be
15254 @code{__Decimal64} and @code{__Decimal128} respectively.
15256 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15257 if and only if its @code{value} argument has an undefined number of
15258 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15259 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15260 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15261 require that the type of the @code{value} argument be
15262 @code{__Decimal64} and @code{__Decimal128} respectively.
15264 The following built-in functions are also available for the PowerPC family
15265 of processors, starting with ISA 3.0 or later
15266 (@option{-mcpu=power9}).  These string functions are described
15267 separately in order to group the descriptions closer to the function
15268 prototypes:
15269 @smallexample
15270 int vec_all_nez (vector signed char, vector signed char);
15271 int vec_all_nez (vector unsigned char, vector unsigned char);
15272 int vec_all_nez (vector signed short, vector signed short);
15273 int vec_all_nez (vector unsigned short, vector unsigned short);
15274 int vec_all_nez (vector signed int, vector signed int);
15275 int vec_all_nez (vector unsigned int, vector unsigned int);
15277 int vec_any_eqz (vector signed char, vector signed char);
15278 int vec_any_eqz (vector unsigned char, vector unsigned char);
15279 int vec_any_eqz (vector signed short, vector signed short);
15280 int vec_any_eqz (vector unsigned short, vector unsigned short);
15281 int vec_any_eqz (vector signed int, vector signed int);
15282 int vec_any_eqz (vector unsigned int, vector unsigned int);
15284 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15285 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15286 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15287 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15288 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15289 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15291 signed int vec_cntlz_lsbb (vector signed char);
15292 signed int vec_cntlz_lsbb (vector unsigned char);
15294 signed int vec_cnttz_lsbb (vector signed char);
15295 signed int vec_cnttz_lsbb (vector unsigned char);
15297 vector signed char vec_xl_len (signed char *addr, size_t len);
15298 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
15299 vector signed int vec_xl_len (signed int *addr, size_t len);
15300 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
15301 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
15302 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
15303 vector signed long long vec_xl_len (signed long long *addr, size_t len);
15304 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
15305 vector signed short vec_xl_len (signed short *addr, size_t len);
15306 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
15307 vector double vec_xl_len (double *addr, size_t len);
15308 vector float vec_xl_len (float *addr, size_t len);
15310 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
15311 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
15312 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
15313 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
15314 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
15315 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
15316 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
15317 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
15318 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
15319 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
15320 void vec_xst_len (vector double data, double *addr, size_t len);
15321 void vec_xst_len (vector float data, float *addr, size_t len);
15323 signed char vec_xlx (unsigned int index, vector signed char data);
15324 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
15325 signed short vec_xlx (unsigned int index, vector signed short data);
15326 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
15327 signed int vec_xlx (unsigned int index, vector signed int data);
15328 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
15329 float vec_xlx (unsigned int index, vector float data);
15331 signed char vec_xrx (unsigned int index, vector signed char data);
15332 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
15333 signed short vec_xrx (unsigned int index, vector signed short data);
15334 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
15335 signed int vec_xrx (unsigned int index, vector signed int data);
15336 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
15337 float vec_xrx (unsigned int index, vector float data);
15338 @end smallexample
15340 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
15341 perform pairwise comparisons between the elements at the same
15342 positions within their two vector arguments.
15343 The @code{vec_all_nez} function returns a
15344 non-zero value if and only if all pairwise comparisons are not
15345 equal and no element of either vector argument contains a zero.
15346 The @code{vec_any_eqz} function returns a
15347 non-zero value if and only if at least one pairwise comparison is equal
15348 or if at least one element of either vector argument contains a zero.
15349 The @code{vec_cmpnez} function returns a vector of the same type as
15350 its two arguments, within which each element consists of all ones to
15351 denote that either the corresponding elements of the incoming arguments are
15352 not equal or that at least one of the corresponding elements contains
15353 zero.  Otherwise, the element of the returned vector contains all zeros.
15355 The @code{vec_cntlz_lsbb} function returns the count of the number of
15356 consecutive leading byte elements (starting from position 0 within the
15357 supplied vector argument) for which the least-significant bit
15358 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
15359 the number of consecutive trailing byte elements (starting from
15360 position 15 and counting backwards within the supplied vector
15361 argument) for which the least-significant bit equals zero.
15363 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
15364 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
15365 function loads a variable length vector from memory.  The
15366 @code{vec_xst_len} function stores a variable length vector to memory.
15367 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
15368 @code{addr} argument represents the memory address to or from which
15369 data will be transferred, and the
15370 @code{len} argument represents the number of bytes to be
15371 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
15372 If this expression's value is not a multiple of the vector element's
15373 size, the behavior of this function is undefined.
15374 In the case that the underlying computer is configured to run in
15375 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
15376 the corresponding vector.  In little-endian mode, the data transfer
15377 moves bytes @code{(16 - len)} to @code{15} of the corresponding
15378 vector.  For the load function, any bytes of the result vector that
15379 are not loaded from memory are set to zero.
15380 The value of the @code{addr} argument need not be aligned on a
15381 multiple of the vector's element size.
15383 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
15384 element selected by the @code{index} argument from the vector
15385 represented by the @code{data} argument.  The @code{index} argument
15386 always specifies a byte offset, regardless of the size of the vector
15387 element.  With @code{vec_xlx}, @code{index} is the offset of the first
15388 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
15389 represents the last byte of the element to be extracted, measured
15390 from the right end of the vector.  In other words, the last byte of
15391 the element to be extracted is found at position @code{(15 - index)}.
15392 There is no requirement that @code{index} be a multiple of the vector
15393 element size.  However, if the size of the vector element added to
15394 @code{index} is greater than 15, the content of the returned value is
15395 undefined.
15397 The following built-in functions are available for the PowerPC family
15398 of processors when hardware decimal floating point
15399 (@option{-mhard-dfp}) is available:
15400 @smallexample
15401 _Decimal64 __builtin_dxex (_Decimal64);
15402 _Decimal128 __builtin_dxexq (_Decimal128);
15403 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15404 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15405 _Decimal64 __builtin_denbcd (int, _Decimal64);
15406 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15407 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
15408 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
15409 _Decimal64 __builtin_dscli (_Decimal64, int);
15410 _Decimal128 __builtin_dscliq (_Decimal128, int);
15411 _Decimal64 __builtin_dscri (_Decimal64, int);
15412 _Decimal128 __builtin_dscriq (_Decimal128, int);
15413 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15414 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15415 @end smallexample
15417 The following built-in functions are available for the PowerPC family
15418 of processors when the Vector Scalar (vsx) instruction set is
15419 available:
15420 @smallexample
15421 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15422 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15423                                                 unsigned long long);
15424 @end smallexample
15426 @node PowerPC AltiVec/VSX Built-in Functions
15427 @subsection PowerPC AltiVec Built-in Functions
15429 GCC provides an interface for the PowerPC family of processors to access
15430 the AltiVec operations described in Motorola's AltiVec Programming
15431 Interface Manual.  The interface is made available by including
15432 @code{<altivec.h>} and using @option{-maltivec} and
15433 @option{-mabi=altivec}.  The interface supports the following vector
15434 types.
15436 @smallexample
15437 vector unsigned char
15438 vector signed char
15439 vector bool char
15441 vector unsigned short
15442 vector signed short
15443 vector bool short
15444 vector pixel
15446 vector unsigned int
15447 vector signed int
15448 vector bool int
15449 vector float
15450 @end smallexample
15452 If @option{-mvsx} is used the following additional vector types are
15453 implemented.
15455 @smallexample
15456 vector unsigned long
15457 vector signed long
15458 vector double
15459 @end smallexample
15461 The long types are only implemented for 64-bit code generation, and
15462 the long type is only used in the floating point/integer conversion
15463 instructions.
15465 GCC's implementation of the high-level language interface available from
15466 C and C++ code differs from Motorola's documentation in several ways.
15468 @itemize @bullet
15470 @item
15471 A vector constant is a list of constant expressions within curly braces.
15473 @item
15474 A vector initializer requires no cast if the vector constant is of the
15475 same type as the variable it is initializing.
15477 @item
15478 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15479 vector type is the default signedness of the base type.  The default
15480 varies depending on the operating system, so a portable program should
15481 always specify the signedness.
15483 @item
15484 Compiling with @option{-maltivec} adds keywords @code{__vector},
15485 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15486 @code{bool}.  When compiling ISO C, the context-sensitive substitution
15487 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15488 disabled.  To use them, you must include @code{<altivec.h>} instead.
15490 @item
15491 GCC allows using a @code{typedef} name as the type specifier for a
15492 vector type.
15494 @item
15495 For C, overloaded functions are implemented with macros so the following
15496 does not work:
15498 @smallexample
15499   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15500 @end smallexample
15502 @noindent
15503 Since @code{vec_add} is a macro, the vector constant in the example
15504 is treated as four separate arguments.  Wrap the entire argument in
15505 parentheses for this to work.
15506 @end itemize
15508 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15509 Internally, GCC uses built-in functions to achieve the functionality in
15510 the aforementioned header file, but they are not supported and are
15511 subject to change without notice.
15513 The following interfaces are supported for the generic and specific
15514 AltiVec operations and the AltiVec predicates.  In cases where there
15515 is a direct mapping between generic and specific operations, only the
15516 generic names are shown here, although the specific operations can also
15517 be used.
15519 Arguments that are documented as @code{const int} require literal
15520 integral values within the range required for that operation.
15522 @smallexample
15523 vector signed char vec_abs (vector signed char);
15524 vector signed short vec_abs (vector signed short);
15525 vector signed int vec_abs (vector signed int);
15526 vector float vec_abs (vector float);
15528 vector signed char vec_abss (vector signed char);
15529 vector signed short vec_abss (vector signed short);
15530 vector signed int vec_abss (vector signed int);
15532 vector signed char vec_add (vector bool char, vector signed char);
15533 vector signed char vec_add (vector signed char, vector bool char);
15534 vector signed char vec_add (vector signed char, vector signed char);
15535 vector unsigned char vec_add (vector bool char, vector unsigned char);
15536 vector unsigned char vec_add (vector unsigned char, vector bool char);
15537 vector unsigned char vec_add (vector unsigned char,
15538                               vector unsigned char);
15539 vector signed short vec_add (vector bool short, vector signed short);
15540 vector signed short vec_add (vector signed short, vector bool short);
15541 vector signed short vec_add (vector signed short, vector signed short);
15542 vector unsigned short vec_add (vector bool short,
15543                                vector unsigned short);
15544 vector unsigned short vec_add (vector unsigned short,
15545                                vector bool short);
15546 vector unsigned short vec_add (vector unsigned short,
15547                                vector unsigned short);
15548 vector signed int vec_add (vector bool int, vector signed int);
15549 vector signed int vec_add (vector signed int, vector bool int);
15550 vector signed int vec_add (vector signed int, vector signed int);
15551 vector unsigned int vec_add (vector bool int, vector unsigned int);
15552 vector unsigned int vec_add (vector unsigned int, vector bool int);
15553 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15554 vector float vec_add (vector float, vector float);
15556 vector float vec_vaddfp (vector float, vector float);
15558 vector signed int vec_vadduwm (vector bool int, vector signed int);
15559 vector signed int vec_vadduwm (vector signed int, vector bool int);
15560 vector signed int vec_vadduwm (vector signed int, vector signed int);
15561 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15562 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15563 vector unsigned int vec_vadduwm (vector unsigned int,
15564                                  vector unsigned int);
15566 vector signed short vec_vadduhm (vector bool short,
15567                                  vector signed short);
15568 vector signed short vec_vadduhm (vector signed short,
15569                                  vector bool short);
15570 vector signed short vec_vadduhm (vector signed short,
15571                                  vector signed short);
15572 vector unsigned short vec_vadduhm (vector bool short,
15573                                    vector unsigned short);
15574 vector unsigned short vec_vadduhm (vector unsigned short,
15575                                    vector bool short);
15576 vector unsigned short vec_vadduhm (vector unsigned short,
15577                                    vector unsigned short);
15579 vector signed char vec_vaddubm (vector bool char, vector signed char);
15580 vector signed char vec_vaddubm (vector signed char, vector bool char);
15581 vector signed char vec_vaddubm (vector signed char, vector signed char);
15582 vector unsigned char vec_vaddubm (vector bool char,
15583                                   vector unsigned char);
15584 vector unsigned char vec_vaddubm (vector unsigned char,
15585                                   vector bool char);
15586 vector unsigned char vec_vaddubm (vector unsigned char,
15587                                   vector unsigned char);
15589 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15591 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15592 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15593 vector unsigned char vec_adds (vector unsigned char,
15594                                vector unsigned char);
15595 vector signed char vec_adds (vector bool char, vector signed char);
15596 vector signed char vec_adds (vector signed char, vector bool char);
15597 vector signed char vec_adds (vector signed char, vector signed char);
15598 vector unsigned short vec_adds (vector bool short,
15599                                 vector unsigned short);
15600 vector unsigned short vec_adds (vector unsigned short,
15601                                 vector bool short);
15602 vector unsigned short vec_adds (vector unsigned short,
15603                                 vector unsigned short);
15604 vector signed short vec_adds (vector bool short, vector signed short);
15605 vector signed short vec_adds (vector signed short, vector bool short);
15606 vector signed short vec_adds (vector signed short, vector signed short);
15607 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15608 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15609 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15610 vector signed int vec_adds (vector bool int, vector signed int);
15611 vector signed int vec_adds (vector signed int, vector bool int);
15612 vector signed int vec_adds (vector signed int, vector signed int);
15614 vector signed int vec_vaddsws (vector bool int, vector signed int);
15615 vector signed int vec_vaddsws (vector signed int, vector bool int);
15616 vector signed int vec_vaddsws (vector signed int, vector signed int);
15618 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15619 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15620 vector unsigned int vec_vadduws (vector unsigned int,
15621                                  vector unsigned int);
15623 vector signed short vec_vaddshs (vector bool short,
15624                                  vector signed short);
15625 vector signed short vec_vaddshs (vector signed short,
15626                                  vector bool short);
15627 vector signed short vec_vaddshs (vector signed short,
15628                                  vector signed short);
15630 vector unsigned short vec_vadduhs (vector bool short,
15631                                    vector unsigned short);
15632 vector unsigned short vec_vadduhs (vector unsigned short,
15633                                    vector bool short);
15634 vector unsigned short vec_vadduhs (vector unsigned short,
15635                                    vector unsigned short);
15637 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15638 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15639 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15641 vector unsigned char vec_vaddubs (vector bool char,
15642                                   vector unsigned char);
15643 vector unsigned char vec_vaddubs (vector unsigned char,
15644                                   vector bool char);
15645 vector unsigned char vec_vaddubs (vector unsigned char,
15646                                   vector unsigned char);
15648 vector float vec_and (vector float, vector float);
15649 vector float vec_and (vector float, vector bool int);
15650 vector float vec_and (vector bool int, vector float);
15651 vector bool int vec_and (vector bool int, vector bool int);
15652 vector signed int vec_and (vector bool int, vector signed int);
15653 vector signed int vec_and (vector signed int, vector bool int);
15654 vector signed int vec_and (vector signed int, vector signed int);
15655 vector unsigned int vec_and (vector bool int, vector unsigned int);
15656 vector unsigned int vec_and (vector unsigned int, vector bool int);
15657 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15658 vector bool short vec_and (vector bool short, vector bool short);
15659 vector signed short vec_and (vector bool short, vector signed short);
15660 vector signed short vec_and (vector signed short, vector bool short);
15661 vector signed short vec_and (vector signed short, vector signed short);
15662 vector unsigned short vec_and (vector bool short,
15663                                vector unsigned short);
15664 vector unsigned short vec_and (vector unsigned short,
15665                                vector bool short);
15666 vector unsigned short vec_and (vector unsigned short,
15667                                vector unsigned short);
15668 vector signed char vec_and (vector bool char, vector signed char);
15669 vector bool char vec_and (vector bool char, vector bool char);
15670 vector signed char vec_and (vector signed char, vector bool char);
15671 vector signed char vec_and (vector signed char, vector signed char);
15672 vector unsigned char vec_and (vector bool char, vector unsigned char);
15673 vector unsigned char vec_and (vector unsigned char, vector bool char);
15674 vector unsigned char vec_and (vector unsigned char,
15675                               vector unsigned char);
15677 vector float vec_andc (vector float, vector float);
15678 vector float vec_andc (vector float, vector bool int);
15679 vector float vec_andc (vector bool int, vector float);
15680 vector bool int vec_andc (vector bool int, vector bool int);
15681 vector signed int vec_andc (vector bool int, vector signed int);
15682 vector signed int vec_andc (vector signed int, vector bool int);
15683 vector signed int vec_andc (vector signed int, vector signed int);
15684 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15685 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15686 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15687 vector bool short vec_andc (vector bool short, vector bool short);
15688 vector signed short vec_andc (vector bool short, vector signed short);
15689 vector signed short vec_andc (vector signed short, vector bool short);
15690 vector signed short vec_andc (vector signed short, vector signed short);
15691 vector unsigned short vec_andc (vector bool short,
15692                                 vector unsigned short);
15693 vector unsigned short vec_andc (vector unsigned short,
15694                                 vector bool short);
15695 vector unsigned short vec_andc (vector unsigned short,
15696                                 vector unsigned short);
15697 vector signed char vec_andc (vector bool char, vector signed char);
15698 vector bool char vec_andc (vector bool char, vector bool char);
15699 vector signed char vec_andc (vector signed char, vector bool char);
15700 vector signed char vec_andc (vector signed char, vector signed char);
15701 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15702 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15703 vector unsigned char vec_andc (vector unsigned char,
15704                                vector unsigned char);
15706 vector unsigned char vec_avg (vector unsigned char,
15707                               vector unsigned char);
15708 vector signed char vec_avg (vector signed char, vector signed char);
15709 vector unsigned short vec_avg (vector unsigned short,
15710                                vector unsigned short);
15711 vector signed short vec_avg (vector signed short, vector signed short);
15712 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15713 vector signed int vec_avg (vector signed int, vector signed int);
15715 vector signed int vec_vavgsw (vector signed int, vector signed int);
15717 vector unsigned int vec_vavguw (vector unsigned int,
15718                                 vector unsigned int);
15720 vector signed short vec_vavgsh (vector signed short,
15721                                 vector signed short);
15723 vector unsigned short vec_vavguh (vector unsigned short,
15724                                   vector unsigned short);
15726 vector signed char vec_vavgsb (vector signed char, vector signed char);
15728 vector unsigned char vec_vavgub (vector unsigned char,
15729                                  vector unsigned char);
15731 vector float vec_copysign (vector float);
15733 vector float vec_ceil (vector float);
15735 vector signed int vec_cmpb (vector float, vector float);
15737 vector bool char vec_cmpeq (vector bool char, vector bool char);
15738 vector bool short vec_cmpeq (vector bool short, vector bool short);
15739 vector bool int vec_cmpeq (vector bool int, vector bool int);
15740 vector bool char vec_cmpeq (vector signed char, vector signed char);
15741 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15742 vector bool short vec_cmpeq (vector signed short, vector signed short);
15743 vector bool short vec_cmpeq (vector unsigned short,
15744                              vector unsigned short);
15745 vector bool int vec_cmpeq (vector signed int, vector signed int);
15746 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15747 vector bool int vec_cmpeq (vector float, vector float);
15749 vector bool int vec_vcmpeqfp (vector float, vector float);
15751 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15752 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15754 vector bool short vec_vcmpequh (vector signed short,
15755                                 vector signed short);
15756 vector bool short vec_vcmpequh (vector unsigned short,
15757                                 vector unsigned short);
15759 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15760 vector bool char vec_vcmpequb (vector unsigned char,
15761                                vector unsigned char);
15763 vector bool int vec_cmpge (vector float, vector float);
15765 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15766 vector bool char vec_cmpgt (vector signed char, vector signed char);
15767 vector bool short vec_cmpgt (vector unsigned short,
15768                              vector unsigned short);
15769 vector bool short vec_cmpgt (vector signed short, vector signed short);
15770 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15771 vector bool int vec_cmpgt (vector signed int, vector signed int);
15772 vector bool int vec_cmpgt (vector float, vector float);
15774 vector bool int vec_vcmpgtfp (vector float, vector float);
15776 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15778 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15780 vector bool short vec_vcmpgtsh (vector signed short,
15781                                 vector signed short);
15783 vector bool short vec_vcmpgtuh (vector unsigned short,
15784                                 vector unsigned short);
15786 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15788 vector bool char vec_vcmpgtub (vector unsigned char,
15789                                vector unsigned char);
15791 vector bool int vec_cmple (vector float, vector float);
15793 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15794 vector bool char vec_cmplt (vector signed char, vector signed char);
15795 vector bool short vec_cmplt (vector unsigned short,
15796                              vector unsigned short);
15797 vector bool short vec_cmplt (vector signed short, vector signed short);
15798 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15799 vector bool int vec_cmplt (vector signed int, vector signed int);
15800 vector bool int vec_cmplt (vector float, vector float);
15802 vector float vec_cpsgn (vector float, vector float);
15804 vector float vec_ctf (vector unsigned int, const int);
15805 vector float vec_ctf (vector signed int, const int);
15806 vector double vec_ctf (vector unsigned long, const int);
15807 vector double vec_ctf (vector signed long, const int);
15809 vector float vec_vcfsx (vector signed int, const int);
15811 vector float vec_vcfux (vector unsigned int, const int);
15813 vector signed int vec_cts (vector float, const int);
15814 vector signed long vec_cts (vector double, const int);
15816 vector unsigned int vec_ctu (vector float, const int);
15817 vector unsigned long vec_ctu (vector double, const int);
15819 void vec_dss (const int);
15821 void vec_dssall (void);
15823 void vec_dst (const vector unsigned char *, int, const int);
15824 void vec_dst (const vector signed char *, int, const int);
15825 void vec_dst (const vector bool char *, int, const int);
15826 void vec_dst (const vector unsigned short *, int, const int);
15827 void vec_dst (const vector signed short *, int, const int);
15828 void vec_dst (const vector bool short *, int, const int);
15829 void vec_dst (const vector pixel *, int, const int);
15830 void vec_dst (const vector unsigned int *, int, const int);
15831 void vec_dst (const vector signed int *, int, const int);
15832 void vec_dst (const vector bool int *, int, const int);
15833 void vec_dst (const vector float *, int, const int);
15834 void vec_dst (const unsigned char *, int, const int);
15835 void vec_dst (const signed char *, int, const int);
15836 void vec_dst (const unsigned short *, int, const int);
15837 void vec_dst (const short *, int, const int);
15838 void vec_dst (const unsigned int *, int, const int);
15839 void vec_dst (const int *, int, const int);
15840 void vec_dst (const unsigned long *, int, const int);
15841 void vec_dst (const long *, int, const int);
15842 void vec_dst (const float *, int, const int);
15844 void vec_dstst (const vector unsigned char *, int, const int);
15845 void vec_dstst (const vector signed char *, int, const int);
15846 void vec_dstst (const vector bool char *, int, const int);
15847 void vec_dstst (const vector unsigned short *, int, const int);
15848 void vec_dstst (const vector signed short *, int, const int);
15849 void vec_dstst (const vector bool short *, int, const int);
15850 void vec_dstst (const vector pixel *, int, const int);
15851 void vec_dstst (const vector unsigned int *, int, const int);
15852 void vec_dstst (const vector signed int *, int, const int);
15853 void vec_dstst (const vector bool int *, int, const int);
15854 void vec_dstst (const vector float *, int, const int);
15855 void vec_dstst (const unsigned char *, int, const int);
15856 void vec_dstst (const signed char *, int, const int);
15857 void vec_dstst (const unsigned short *, int, const int);
15858 void vec_dstst (const short *, int, const int);
15859 void vec_dstst (const unsigned int *, int, const int);
15860 void vec_dstst (const int *, int, const int);
15861 void vec_dstst (const unsigned long *, int, const int);
15862 void vec_dstst (const long *, int, const int);
15863 void vec_dstst (const float *, int, const int);
15865 void vec_dststt (const vector unsigned char *, int, const int);
15866 void vec_dststt (const vector signed char *, int, const int);
15867 void vec_dststt (const vector bool char *, int, const int);
15868 void vec_dststt (const vector unsigned short *, int, const int);
15869 void vec_dststt (const vector signed short *, int, const int);
15870 void vec_dststt (const vector bool short *, int, const int);
15871 void vec_dststt (const vector pixel *, int, const int);
15872 void vec_dststt (const vector unsigned int *, int, const int);
15873 void vec_dststt (const vector signed int *, int, const int);
15874 void vec_dststt (const vector bool int *, int, const int);
15875 void vec_dststt (const vector float *, int, const int);
15876 void vec_dststt (const unsigned char *, int, const int);
15877 void vec_dststt (const signed char *, int, const int);
15878 void vec_dststt (const unsigned short *, int, const int);
15879 void vec_dststt (const short *, int, const int);
15880 void vec_dststt (const unsigned int *, int, const int);
15881 void vec_dststt (const int *, int, const int);
15882 void vec_dststt (const unsigned long *, int, const int);
15883 void vec_dststt (const long *, int, const int);
15884 void vec_dststt (const float *, int, const int);
15886 void vec_dstt (const vector unsigned char *, int, const int);
15887 void vec_dstt (const vector signed char *, int, const int);
15888 void vec_dstt (const vector bool char *, int, const int);
15889 void vec_dstt (const vector unsigned short *, int, const int);
15890 void vec_dstt (const vector signed short *, int, const int);
15891 void vec_dstt (const vector bool short *, int, const int);
15892 void vec_dstt (const vector pixel *, int, const int);
15893 void vec_dstt (const vector unsigned int *, int, const int);
15894 void vec_dstt (const vector signed int *, int, const int);
15895 void vec_dstt (const vector bool int *, int, const int);
15896 void vec_dstt (const vector float *, int, const int);
15897 void vec_dstt (const unsigned char *, int, const int);
15898 void vec_dstt (const signed char *, int, const int);
15899 void vec_dstt (const unsigned short *, int, const int);
15900 void vec_dstt (const short *, int, const int);
15901 void vec_dstt (const unsigned int *, int, const int);
15902 void vec_dstt (const int *, int, const int);
15903 void vec_dstt (const unsigned long *, int, const int);
15904 void vec_dstt (const long *, int, const int);
15905 void vec_dstt (const float *, int, const int);
15907 vector float vec_expte (vector float);
15909 vector float vec_floor (vector float);
15911 vector float vec_ld (int, const vector float *);
15912 vector float vec_ld (int, const float *);
15913 vector bool int vec_ld (int, const vector bool int *);
15914 vector signed int vec_ld (int, const vector signed int *);
15915 vector signed int vec_ld (int, const int *);
15916 vector signed int vec_ld (int, const long *);
15917 vector unsigned int vec_ld (int, const vector unsigned int *);
15918 vector unsigned int vec_ld (int, const unsigned int *);
15919 vector unsigned int vec_ld (int, const unsigned long *);
15920 vector bool short vec_ld (int, const vector bool short *);
15921 vector pixel vec_ld (int, const vector pixel *);
15922 vector signed short vec_ld (int, const vector signed short *);
15923 vector signed short vec_ld (int, const short *);
15924 vector unsigned short vec_ld (int, const vector unsigned short *);
15925 vector unsigned short vec_ld (int, const unsigned short *);
15926 vector bool char vec_ld (int, const vector bool char *);
15927 vector signed char vec_ld (int, const vector signed char *);
15928 vector signed char vec_ld (int, const signed char *);
15929 vector unsigned char vec_ld (int, const vector unsigned char *);
15930 vector unsigned char vec_ld (int, const unsigned char *);
15932 vector signed char vec_lde (int, const signed char *);
15933 vector unsigned char vec_lde (int, const unsigned char *);
15934 vector signed short vec_lde (int, const short *);
15935 vector unsigned short vec_lde (int, const unsigned short *);
15936 vector float vec_lde (int, const float *);
15937 vector signed int vec_lde (int, const int *);
15938 vector unsigned int vec_lde (int, const unsigned int *);
15939 vector signed int vec_lde (int, const long *);
15940 vector unsigned int vec_lde (int, const unsigned long *);
15942 vector float vec_lvewx (int, float *);
15943 vector signed int vec_lvewx (int, int *);
15944 vector unsigned int vec_lvewx (int, unsigned int *);
15945 vector signed int vec_lvewx (int, long *);
15946 vector unsigned int vec_lvewx (int, unsigned long *);
15948 vector signed short vec_lvehx (int, short *);
15949 vector unsigned short vec_lvehx (int, unsigned short *);
15951 vector signed char vec_lvebx (int, char *);
15952 vector unsigned char vec_lvebx (int, unsigned char *);
15954 vector float vec_ldl (int, const vector float *);
15955 vector float vec_ldl (int, const float *);
15956 vector bool int vec_ldl (int, const vector bool int *);
15957 vector signed int vec_ldl (int, const vector signed int *);
15958 vector signed int vec_ldl (int, const int *);
15959 vector signed int vec_ldl (int, const long *);
15960 vector unsigned int vec_ldl (int, const vector unsigned int *);
15961 vector unsigned int vec_ldl (int, const unsigned int *);
15962 vector unsigned int vec_ldl (int, const unsigned long *);
15963 vector bool short vec_ldl (int, const vector bool short *);
15964 vector pixel vec_ldl (int, const vector pixel *);
15965 vector signed short vec_ldl (int, const vector signed short *);
15966 vector signed short vec_ldl (int, const short *);
15967 vector unsigned short vec_ldl (int, const vector unsigned short *);
15968 vector unsigned short vec_ldl (int, const unsigned short *);
15969 vector bool char vec_ldl (int, const vector bool char *);
15970 vector signed char vec_ldl (int, const vector signed char *);
15971 vector signed char vec_ldl (int, const signed char *);
15972 vector unsigned char vec_ldl (int, const vector unsigned char *);
15973 vector unsigned char vec_ldl (int, const unsigned char *);
15975 vector float vec_loge (vector float);
15977 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
15978 vector unsigned char vec_lvsl (int, const volatile signed char *);
15979 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
15980 vector unsigned char vec_lvsl (int, const volatile short *);
15981 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
15982 vector unsigned char vec_lvsl (int, const volatile int *);
15983 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
15984 vector unsigned char vec_lvsl (int, const volatile long *);
15985 vector unsigned char vec_lvsl (int, const volatile float *);
15987 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
15988 vector unsigned char vec_lvsr (int, const volatile signed char *);
15989 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
15990 vector unsigned char vec_lvsr (int, const volatile short *);
15991 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
15992 vector unsigned char vec_lvsr (int, const volatile int *);
15993 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
15994 vector unsigned char vec_lvsr (int, const volatile long *);
15995 vector unsigned char vec_lvsr (int, const volatile float *);
15997 vector float vec_madd (vector float, vector float, vector float);
15999 vector signed short vec_madds (vector signed short,
16000                                vector signed short,
16001                                vector signed short);
16003 vector unsigned char vec_max (vector bool char, vector unsigned char);
16004 vector unsigned char vec_max (vector unsigned char, vector bool char);
16005 vector unsigned char vec_max (vector unsigned char,
16006                               vector unsigned char);
16007 vector signed char vec_max (vector bool char, vector signed char);
16008 vector signed char vec_max (vector signed char, vector bool char);
16009 vector signed char vec_max (vector signed char, vector signed char);
16010 vector unsigned short vec_max (vector bool short,
16011                                vector unsigned short);
16012 vector unsigned short vec_max (vector unsigned short,
16013                                vector bool short);
16014 vector unsigned short vec_max (vector unsigned short,
16015                                vector unsigned short);
16016 vector signed short vec_max (vector bool short, vector signed short);
16017 vector signed short vec_max (vector signed short, vector bool short);
16018 vector signed short vec_max (vector signed short, vector signed short);
16019 vector unsigned int vec_max (vector bool int, vector unsigned int);
16020 vector unsigned int vec_max (vector unsigned int, vector bool int);
16021 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16022 vector signed int vec_max (vector bool int, vector signed int);
16023 vector signed int vec_max (vector signed int, vector bool int);
16024 vector signed int vec_max (vector signed int, vector signed int);
16025 vector float vec_max (vector float, vector float);
16027 vector float vec_vmaxfp (vector float, vector float);
16029 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16030 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16031 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16033 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16034 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16035 vector unsigned int vec_vmaxuw (vector unsigned int,
16036                                 vector unsigned int);
16038 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16039 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16040 vector signed short vec_vmaxsh (vector signed short,
16041                                 vector signed short);
16043 vector unsigned short vec_vmaxuh (vector bool short,
16044                                   vector unsigned short);
16045 vector unsigned short vec_vmaxuh (vector unsigned short,
16046                                   vector bool short);
16047 vector unsigned short vec_vmaxuh (vector unsigned short,
16048                                   vector unsigned short);
16050 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16051 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16052 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16054 vector unsigned char vec_vmaxub (vector bool char,
16055                                  vector unsigned char);
16056 vector unsigned char vec_vmaxub (vector unsigned char,
16057                                  vector bool char);
16058 vector unsigned char vec_vmaxub (vector unsigned char,
16059                                  vector unsigned char);
16061 vector bool char vec_mergeh (vector bool char, vector bool char);
16062 vector signed char vec_mergeh (vector signed char, vector signed char);
16063 vector unsigned char vec_mergeh (vector unsigned char,
16064                                  vector unsigned char);
16065 vector bool short vec_mergeh (vector bool short, vector bool short);
16066 vector pixel vec_mergeh (vector pixel, vector pixel);
16067 vector signed short vec_mergeh (vector signed short,
16068                                 vector signed short);
16069 vector unsigned short vec_mergeh (vector unsigned short,
16070                                   vector unsigned short);
16071 vector float vec_mergeh (vector float, vector float);
16072 vector bool int vec_mergeh (vector bool int, vector bool int);
16073 vector signed int vec_mergeh (vector signed int, vector signed int);
16074 vector unsigned int vec_mergeh (vector unsigned int,
16075                                 vector unsigned int);
16077 vector float vec_vmrghw (vector float, vector float);
16078 vector bool int vec_vmrghw (vector bool int, vector bool int);
16079 vector signed int vec_vmrghw (vector signed int, vector signed int);
16080 vector unsigned int vec_vmrghw (vector unsigned int,
16081                                 vector unsigned int);
16083 vector bool short vec_vmrghh (vector bool short, vector bool short);
16084 vector signed short vec_vmrghh (vector signed short,
16085                                 vector signed short);
16086 vector unsigned short vec_vmrghh (vector unsigned short,
16087                                   vector unsigned short);
16088 vector pixel vec_vmrghh (vector pixel, vector pixel);
16090 vector bool char vec_vmrghb (vector bool char, vector bool char);
16091 vector signed char vec_vmrghb (vector signed char, vector signed char);
16092 vector unsigned char vec_vmrghb (vector unsigned char,
16093                                  vector unsigned char);
16095 vector bool char vec_mergel (vector bool char, vector bool char);
16096 vector signed char vec_mergel (vector signed char, vector signed char);
16097 vector unsigned char vec_mergel (vector unsigned char,
16098                                  vector unsigned char);
16099 vector bool short vec_mergel (vector bool short, vector bool short);
16100 vector pixel vec_mergel (vector pixel, vector pixel);
16101 vector signed short vec_mergel (vector signed short,
16102                                 vector signed short);
16103 vector unsigned short vec_mergel (vector unsigned short,
16104                                   vector unsigned short);
16105 vector float vec_mergel (vector float, vector float);
16106 vector bool int vec_mergel (vector bool int, vector bool int);
16107 vector signed int vec_mergel (vector signed int, vector signed int);
16108 vector unsigned int vec_mergel (vector unsigned int,
16109                                 vector unsigned int);
16111 vector float vec_vmrglw (vector float, vector float);
16112 vector signed int vec_vmrglw (vector signed int, vector signed int);
16113 vector unsigned int vec_vmrglw (vector unsigned int,
16114                                 vector unsigned int);
16115 vector bool int vec_vmrglw (vector bool int, vector bool int);
16117 vector bool short vec_vmrglh (vector bool short, vector bool short);
16118 vector signed short vec_vmrglh (vector signed short,
16119                                 vector signed short);
16120 vector unsigned short vec_vmrglh (vector unsigned short,
16121                                   vector unsigned short);
16122 vector pixel vec_vmrglh (vector pixel, vector pixel);
16124 vector bool char vec_vmrglb (vector bool char, vector bool char);
16125 vector signed char vec_vmrglb (vector signed char, vector signed char);
16126 vector unsigned char vec_vmrglb (vector unsigned char,
16127                                  vector unsigned char);
16129 vector unsigned short vec_mfvscr (void);
16131 vector unsigned char vec_min (vector bool char, vector unsigned char);
16132 vector unsigned char vec_min (vector unsigned char, vector bool char);
16133 vector unsigned char vec_min (vector unsigned char,
16134                               vector unsigned char);
16135 vector signed char vec_min (vector bool char, vector signed char);
16136 vector signed char vec_min (vector signed char, vector bool char);
16137 vector signed char vec_min (vector signed char, vector signed char);
16138 vector unsigned short vec_min (vector bool short,
16139                                vector unsigned short);
16140 vector unsigned short vec_min (vector unsigned short,
16141                                vector bool short);
16142 vector unsigned short vec_min (vector unsigned short,
16143                                vector unsigned short);
16144 vector signed short vec_min (vector bool short, vector signed short);
16145 vector signed short vec_min (vector signed short, vector bool short);
16146 vector signed short vec_min (vector signed short, vector signed short);
16147 vector unsigned int vec_min (vector bool int, vector unsigned int);
16148 vector unsigned int vec_min (vector unsigned int, vector bool int);
16149 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16150 vector signed int vec_min (vector bool int, vector signed int);
16151 vector signed int vec_min (vector signed int, vector bool int);
16152 vector signed int vec_min (vector signed int, vector signed int);
16153 vector float vec_min (vector float, vector float);
16155 vector float vec_vminfp (vector float, vector float);
16157 vector signed int vec_vminsw (vector bool int, vector signed int);
16158 vector signed int vec_vminsw (vector signed int, vector bool int);
16159 vector signed int vec_vminsw (vector signed int, vector signed int);
16161 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16162 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16163 vector unsigned int vec_vminuw (vector unsigned int,
16164                                 vector unsigned int);
16166 vector signed short vec_vminsh (vector bool short, vector signed short);
16167 vector signed short vec_vminsh (vector signed short, vector bool short);
16168 vector signed short vec_vminsh (vector signed short,
16169                                 vector signed short);
16171 vector unsigned short vec_vminuh (vector bool short,
16172                                   vector unsigned short);
16173 vector unsigned short vec_vminuh (vector unsigned short,
16174                                   vector bool short);
16175 vector unsigned short vec_vminuh (vector unsigned short,
16176                                   vector unsigned short);
16178 vector signed char vec_vminsb (vector bool char, vector signed char);
16179 vector signed char vec_vminsb (vector signed char, vector bool char);
16180 vector signed char vec_vminsb (vector signed char, vector signed char);
16182 vector unsigned char vec_vminub (vector bool char,
16183                                  vector unsigned char);
16184 vector unsigned char vec_vminub (vector unsigned char,
16185                                  vector bool char);
16186 vector unsigned char vec_vminub (vector unsigned char,
16187                                  vector unsigned char);
16189 vector signed short vec_mladd (vector signed short,
16190                                vector signed short,
16191                                vector signed short);
16192 vector signed short vec_mladd (vector signed short,
16193                                vector unsigned short,
16194                                vector unsigned short);
16195 vector signed short vec_mladd (vector unsigned short,
16196                                vector signed short,
16197                                vector signed short);
16198 vector unsigned short vec_mladd (vector unsigned short,
16199                                  vector unsigned short,
16200                                  vector unsigned short);
16202 vector signed short vec_mradds (vector signed short,
16203                                 vector signed short,
16204                                 vector signed short);
16206 vector unsigned int vec_msum (vector unsigned char,
16207                               vector unsigned char,
16208                               vector unsigned int);
16209 vector signed int vec_msum (vector signed char,
16210                             vector unsigned char,
16211                             vector signed int);
16212 vector unsigned int vec_msum (vector unsigned short,
16213                               vector unsigned short,
16214                               vector unsigned int);
16215 vector signed int vec_msum (vector signed short,
16216                             vector signed short,
16217                             vector signed int);
16219 vector signed int vec_vmsumshm (vector signed short,
16220                                 vector signed short,
16221                                 vector signed int);
16223 vector unsigned int vec_vmsumuhm (vector unsigned short,
16224                                   vector unsigned short,
16225                                   vector unsigned int);
16227 vector signed int vec_vmsummbm (vector signed char,
16228                                 vector unsigned char,
16229                                 vector signed int);
16231 vector unsigned int vec_vmsumubm (vector unsigned char,
16232                                   vector unsigned char,
16233                                   vector unsigned int);
16235 vector unsigned int vec_msums (vector unsigned short,
16236                                vector unsigned short,
16237                                vector unsigned int);
16238 vector signed int vec_msums (vector signed short,
16239                              vector signed short,
16240                              vector signed int);
16242 vector signed int vec_vmsumshs (vector signed short,
16243                                 vector signed short,
16244                                 vector signed int);
16246 vector unsigned int vec_vmsumuhs (vector unsigned short,
16247                                   vector unsigned short,
16248                                   vector unsigned int);
16250 void vec_mtvscr (vector signed int);
16251 void vec_mtvscr (vector unsigned int);
16252 void vec_mtvscr (vector bool int);
16253 void vec_mtvscr (vector signed short);
16254 void vec_mtvscr (vector unsigned short);
16255 void vec_mtvscr (vector bool short);
16256 void vec_mtvscr (vector pixel);
16257 void vec_mtvscr (vector signed char);
16258 void vec_mtvscr (vector unsigned char);
16259 void vec_mtvscr (vector bool char);
16261 vector unsigned short vec_mule (vector unsigned char,
16262                                 vector unsigned char);
16263 vector signed short vec_mule (vector signed char,
16264                               vector signed char);
16265 vector unsigned int vec_mule (vector unsigned short,
16266                               vector unsigned short);
16267 vector signed int vec_mule (vector signed short, vector signed short);
16269 vector signed int vec_vmulesh (vector signed short,
16270                                vector signed short);
16272 vector unsigned int vec_vmuleuh (vector unsigned short,
16273                                  vector unsigned short);
16275 vector signed short vec_vmulesb (vector signed char,
16276                                  vector signed char);
16278 vector unsigned short vec_vmuleub (vector unsigned char,
16279                                   vector unsigned char);
16281 vector unsigned short vec_mulo (vector unsigned char,
16282                                 vector unsigned char);
16283 vector signed short vec_mulo (vector signed char, vector signed char);
16284 vector unsigned int vec_mulo (vector unsigned short,
16285                               vector unsigned short);
16286 vector signed int vec_mulo (vector signed short, vector signed short);
16288 vector signed int vec_vmulosh (vector signed short,
16289                                vector signed short);
16291 vector unsigned int vec_vmulouh (vector unsigned short,
16292                                  vector unsigned short);
16294 vector signed short vec_vmulosb (vector signed char,
16295                                  vector signed char);
16297 vector unsigned short vec_vmuloub (vector unsigned char,
16298                                    vector unsigned char);
16300 vector float vec_nmsub (vector float, vector float, vector float);
16302 vector float vec_nor (vector float, vector float);
16303 vector signed int vec_nor (vector signed int, vector signed int);
16304 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16305 vector bool int vec_nor (vector bool int, vector bool int);
16306 vector signed short vec_nor (vector signed short, vector signed short);
16307 vector unsigned short vec_nor (vector unsigned short,
16308                                vector unsigned short);
16309 vector bool short vec_nor (vector bool short, vector bool short);
16310 vector signed char vec_nor (vector signed char, vector signed char);
16311 vector unsigned char vec_nor (vector unsigned char,
16312                               vector unsigned char);
16313 vector bool char vec_nor (vector bool char, vector bool char);
16315 vector float vec_or (vector float, vector float);
16316 vector float vec_or (vector float, vector bool int);
16317 vector float vec_or (vector bool int, vector float);
16318 vector bool int vec_or (vector bool int, vector bool int);
16319 vector signed int vec_or (vector bool int, vector signed int);
16320 vector signed int vec_or (vector signed int, vector bool int);
16321 vector signed int vec_or (vector signed int, vector signed int);
16322 vector unsigned int vec_or (vector bool int, vector unsigned int);
16323 vector unsigned int vec_or (vector unsigned int, vector bool int);
16324 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16325 vector bool short vec_or (vector bool short, vector bool short);
16326 vector signed short vec_or (vector bool short, vector signed short);
16327 vector signed short vec_or (vector signed short, vector bool short);
16328 vector signed short vec_or (vector signed short, vector signed short);
16329 vector unsigned short vec_or (vector bool short, vector unsigned short);
16330 vector unsigned short vec_or (vector unsigned short, vector bool short);
16331 vector unsigned short vec_or (vector unsigned short,
16332                               vector unsigned short);
16333 vector signed char vec_or (vector bool char, vector signed char);
16334 vector bool char vec_or (vector bool char, vector bool char);
16335 vector signed char vec_or (vector signed char, vector bool char);
16336 vector signed char vec_or (vector signed char, vector signed char);
16337 vector unsigned char vec_or (vector bool char, vector unsigned char);
16338 vector unsigned char vec_or (vector unsigned char, vector bool char);
16339 vector unsigned char vec_or (vector unsigned char,
16340                              vector unsigned char);
16342 vector signed char vec_pack (vector signed short, vector signed short);
16343 vector unsigned char vec_pack (vector unsigned short,
16344                                vector unsigned short);
16345 vector bool char vec_pack (vector bool short, vector bool short);
16346 vector signed short vec_pack (vector signed int, vector signed int);
16347 vector unsigned short vec_pack (vector unsigned int,
16348                                 vector unsigned int);
16349 vector bool short vec_pack (vector bool int, vector bool int);
16351 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16352 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16353 vector unsigned short vec_vpkuwum (vector unsigned int,
16354                                    vector unsigned int);
16356 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16357 vector signed char vec_vpkuhum (vector signed short,
16358                                 vector signed short);
16359 vector unsigned char vec_vpkuhum (vector unsigned short,
16360                                   vector unsigned short);
16362 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16364 vector unsigned char vec_packs (vector unsigned short,
16365                                 vector unsigned short);
16366 vector signed char vec_packs (vector signed short, vector signed short);
16367 vector unsigned short vec_packs (vector unsigned int,
16368                                  vector unsigned int);
16369 vector signed short vec_packs (vector signed int, vector signed int);
16371 vector signed short vec_vpkswss (vector signed int, vector signed int);
16373 vector unsigned short vec_vpkuwus (vector unsigned int,
16374                                    vector unsigned int);
16376 vector signed char vec_vpkshss (vector signed short,
16377                                 vector signed short);
16379 vector unsigned char vec_vpkuhus (vector unsigned short,
16380                                   vector unsigned short);
16382 vector unsigned char vec_packsu (vector unsigned short,
16383                                  vector unsigned short);
16384 vector unsigned char vec_packsu (vector signed short,
16385                                  vector signed short);
16386 vector unsigned short vec_packsu (vector unsigned int,
16387                                   vector unsigned int);
16388 vector unsigned short vec_packsu (vector signed int, vector signed int);
16390 vector unsigned short vec_vpkswus (vector signed int,
16391                                    vector signed int);
16393 vector unsigned char vec_vpkshus (vector signed short,
16394                                   vector signed short);
16396 vector float vec_perm (vector float,
16397                        vector float,
16398                        vector unsigned char);
16399 vector signed int vec_perm (vector signed int,
16400                             vector signed int,
16401                             vector unsigned char);
16402 vector unsigned int vec_perm (vector unsigned int,
16403                               vector unsigned int,
16404                               vector unsigned char);
16405 vector bool int vec_perm (vector bool int,
16406                           vector bool int,
16407                           vector unsigned char);
16408 vector signed short vec_perm (vector signed short,
16409                               vector signed short,
16410                               vector unsigned char);
16411 vector unsigned short vec_perm (vector unsigned short,
16412                                 vector unsigned short,
16413                                 vector unsigned char);
16414 vector bool short vec_perm (vector bool short,
16415                             vector bool short,
16416                             vector unsigned char);
16417 vector pixel vec_perm (vector pixel,
16418                        vector pixel,
16419                        vector unsigned char);
16420 vector signed char vec_perm (vector signed char,
16421                              vector signed char,
16422                              vector unsigned char);
16423 vector unsigned char vec_perm (vector unsigned char,
16424                                vector unsigned char,
16425                                vector unsigned char);
16426 vector bool char vec_perm (vector bool char,
16427                            vector bool char,
16428                            vector unsigned char);
16430 vector float vec_re (vector float);
16432 vector signed char vec_rl (vector signed char,
16433                            vector unsigned char);
16434 vector unsigned char vec_rl (vector unsigned char,
16435                              vector unsigned char);
16436 vector signed short vec_rl (vector signed short, vector unsigned short);
16437 vector unsigned short vec_rl (vector unsigned short,
16438                               vector unsigned short);
16439 vector signed int vec_rl (vector signed int, vector unsigned int);
16440 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16442 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16443 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16445 vector signed short vec_vrlh (vector signed short,
16446                               vector unsigned short);
16447 vector unsigned short vec_vrlh (vector unsigned short,
16448                                 vector unsigned short);
16450 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16451 vector unsigned char vec_vrlb (vector unsigned char,
16452                                vector unsigned char);
16454 vector float vec_round (vector float);
16456 vector float vec_recip (vector float, vector float);
16458 vector float vec_rsqrt (vector float);
16460 vector float vec_rsqrte (vector float);
16462 vector float vec_sel (vector float, vector float, vector bool int);
16463 vector float vec_sel (vector float, vector float, vector unsigned int);
16464 vector signed int vec_sel (vector signed int,
16465                            vector signed int,
16466                            vector bool int);
16467 vector signed int vec_sel (vector signed int,
16468                            vector signed int,
16469                            vector unsigned int);
16470 vector unsigned int vec_sel (vector unsigned int,
16471                              vector unsigned int,
16472                              vector bool int);
16473 vector unsigned int vec_sel (vector unsigned int,
16474                              vector unsigned int,
16475                              vector unsigned int);
16476 vector bool int vec_sel (vector bool int,
16477                          vector bool int,
16478                          vector bool int);
16479 vector bool int vec_sel (vector bool int,
16480                          vector bool int,
16481                          vector unsigned int);
16482 vector signed short vec_sel (vector signed short,
16483                              vector signed short,
16484                              vector bool short);
16485 vector signed short vec_sel (vector signed short,
16486                              vector signed short,
16487                              vector unsigned short);
16488 vector unsigned short vec_sel (vector unsigned short,
16489                                vector unsigned short,
16490                                vector bool short);
16491 vector unsigned short vec_sel (vector unsigned short,
16492                                vector unsigned short,
16493                                vector unsigned short);
16494 vector bool short vec_sel (vector bool short,
16495                            vector bool short,
16496                            vector bool short);
16497 vector bool short vec_sel (vector bool short,
16498                            vector bool short,
16499                            vector unsigned short);
16500 vector signed char vec_sel (vector signed char,
16501                             vector signed char,
16502                             vector bool char);
16503 vector signed char vec_sel (vector signed char,
16504                             vector signed char,
16505                             vector unsigned char);
16506 vector unsigned char vec_sel (vector unsigned char,
16507                               vector unsigned char,
16508                               vector bool char);
16509 vector unsigned char vec_sel (vector unsigned char,
16510                               vector unsigned char,
16511                               vector unsigned char);
16512 vector bool char vec_sel (vector bool char,
16513                           vector bool char,
16514                           vector bool char);
16515 vector bool char vec_sel (vector bool char,
16516                           vector bool char,
16517                           vector unsigned char);
16519 vector signed char vec_sl (vector signed char,
16520                            vector unsigned char);
16521 vector unsigned char vec_sl (vector unsigned char,
16522                              vector unsigned char);
16523 vector signed short vec_sl (vector signed short, vector unsigned short);
16524 vector unsigned short vec_sl (vector unsigned short,
16525                               vector unsigned short);
16526 vector signed int vec_sl (vector signed int, vector unsigned int);
16527 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16529 vector signed int vec_vslw (vector signed int, vector unsigned int);
16530 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16532 vector signed short vec_vslh (vector signed short,
16533                               vector unsigned short);
16534 vector unsigned short vec_vslh (vector unsigned short,
16535                                 vector unsigned short);
16537 vector signed char vec_vslb (vector signed char, vector unsigned char);
16538 vector unsigned char vec_vslb (vector unsigned char,
16539                                vector unsigned char);
16541 vector float vec_sld (vector float, vector float, const int);
16542 vector double vec_sld (vector double, vector double, const int);
16544 vector signed int vec_sld (vector signed int,
16545                            vector signed int,
16546                            const int);
16547 vector unsigned int vec_sld (vector unsigned int,
16548                              vector unsigned int,
16549                              const int);
16550 vector bool int vec_sld (vector bool int,
16551                          vector bool int,
16552                          const int);
16553 vector signed short vec_sld (vector signed short,
16554                              vector signed short,
16555                              const int);
16556 vector unsigned short vec_sld (vector unsigned short,
16557                                vector unsigned short,
16558                                const int);
16559 vector bool short vec_sld (vector bool short,
16560                            vector bool short,
16561                            const int);
16562 vector pixel vec_sld (vector pixel,
16563                       vector pixel,
16564                       const int);
16565 vector signed char vec_sld (vector signed char,
16566                             vector signed char,
16567                             const int);
16568 vector unsigned char vec_sld (vector unsigned char,
16569                               vector unsigned char,
16570                               const int);
16571 vector bool char vec_sld (vector bool char,
16572                           vector bool char,
16573                           const int);
16575 vector signed int vec_sll (vector signed int,
16576                            vector unsigned int);
16577 vector signed int vec_sll (vector signed int,
16578                            vector unsigned short);
16579 vector signed int vec_sll (vector signed int,
16580                            vector unsigned char);
16581 vector unsigned int vec_sll (vector unsigned int,
16582                              vector unsigned int);
16583 vector unsigned int vec_sll (vector unsigned int,
16584                              vector unsigned short);
16585 vector unsigned int vec_sll (vector unsigned int,
16586                              vector unsigned char);
16587 vector bool int vec_sll (vector bool int,
16588                          vector unsigned int);
16589 vector bool int vec_sll (vector bool int,
16590                          vector unsigned short);
16591 vector bool int vec_sll (vector bool int,
16592                          vector unsigned char);
16593 vector signed short vec_sll (vector signed short,
16594                              vector unsigned int);
16595 vector signed short vec_sll (vector signed short,
16596                              vector unsigned short);
16597 vector signed short vec_sll (vector signed short,
16598                              vector unsigned char);
16599 vector unsigned short vec_sll (vector unsigned short,
16600                                vector unsigned int);
16601 vector unsigned short vec_sll (vector unsigned short,
16602                                vector unsigned short);
16603 vector unsigned short vec_sll (vector unsigned short,
16604                                vector unsigned char);
16605 vector bool short vec_sll (vector bool short, vector unsigned int);
16606 vector bool short vec_sll (vector bool short, vector unsigned short);
16607 vector bool short vec_sll (vector bool short, vector unsigned char);
16608 vector pixel vec_sll (vector pixel, vector unsigned int);
16609 vector pixel vec_sll (vector pixel, vector unsigned short);
16610 vector pixel vec_sll (vector pixel, vector unsigned char);
16611 vector signed char vec_sll (vector signed char, vector unsigned int);
16612 vector signed char vec_sll (vector signed char, vector unsigned short);
16613 vector signed char vec_sll (vector signed char, vector unsigned char);
16614 vector unsigned char vec_sll (vector unsigned char,
16615                               vector unsigned int);
16616 vector unsigned char vec_sll (vector unsigned char,
16617                               vector unsigned short);
16618 vector unsigned char vec_sll (vector unsigned char,
16619                               vector unsigned char);
16620 vector bool char vec_sll (vector bool char, vector unsigned int);
16621 vector bool char vec_sll (vector bool char, vector unsigned short);
16622 vector bool char vec_sll (vector bool char, vector unsigned char);
16624 vector float vec_slo (vector float, vector signed char);
16625 vector float vec_slo (vector float, vector unsigned char);
16626 vector signed int vec_slo (vector signed int, vector signed char);
16627 vector signed int vec_slo (vector signed int, vector unsigned char);
16628 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16629 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16630 vector signed short vec_slo (vector signed short, vector signed char);
16631 vector signed short vec_slo (vector signed short, vector unsigned char);
16632 vector unsigned short vec_slo (vector unsigned short,
16633                                vector signed char);
16634 vector unsigned short vec_slo (vector unsigned short,
16635                                vector unsigned char);
16636 vector pixel vec_slo (vector pixel, vector signed char);
16637 vector pixel vec_slo (vector pixel, vector unsigned char);
16638 vector signed char vec_slo (vector signed char, vector signed char);
16639 vector signed char vec_slo (vector signed char, vector unsigned char);
16640 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16641 vector unsigned char vec_slo (vector unsigned char,
16642                               vector unsigned char);
16644 vector signed char vec_splat (vector signed char, const int);
16645 vector unsigned char vec_splat (vector unsigned char, const int);
16646 vector bool char vec_splat (vector bool char, const int);
16647 vector signed short vec_splat (vector signed short, const int);
16648 vector unsigned short vec_splat (vector unsigned short, const int);
16649 vector bool short vec_splat (vector bool short, const int);
16650 vector pixel vec_splat (vector pixel, const int);
16651 vector float vec_splat (vector float, const int);
16652 vector signed int vec_splat (vector signed int, const int);
16653 vector unsigned int vec_splat (vector unsigned int, const int);
16654 vector bool int vec_splat (vector bool int, const int);
16655 vector signed long vec_splat (vector signed long, const int);
16656 vector unsigned long vec_splat (vector unsigned long, const int);
16658 vector signed char vec_splats (signed char);
16659 vector unsigned char vec_splats (unsigned char);
16660 vector signed short vec_splats (signed short);
16661 vector unsigned short vec_splats (unsigned short);
16662 vector signed int vec_splats (signed int);
16663 vector unsigned int vec_splats (unsigned int);
16664 vector float vec_splats (float);
16666 vector float vec_vspltw (vector float, const int);
16667 vector signed int vec_vspltw (vector signed int, const int);
16668 vector unsigned int vec_vspltw (vector unsigned int, const int);
16669 vector bool int vec_vspltw (vector bool int, const int);
16671 vector bool short vec_vsplth (vector bool short, const int);
16672 vector signed short vec_vsplth (vector signed short, const int);
16673 vector unsigned short vec_vsplth (vector unsigned short, const int);
16674 vector pixel vec_vsplth (vector pixel, const int);
16676 vector signed char vec_vspltb (vector signed char, const int);
16677 vector unsigned char vec_vspltb (vector unsigned char, const int);
16678 vector bool char vec_vspltb (vector bool char, const int);
16680 vector signed char vec_splat_s8 (const int);
16682 vector signed short vec_splat_s16 (const int);
16684 vector signed int vec_splat_s32 (const int);
16686 vector unsigned char vec_splat_u8 (const int);
16688 vector unsigned short vec_splat_u16 (const int);
16690 vector unsigned int vec_splat_u32 (const int);
16692 vector signed char vec_sr (vector signed char, vector unsigned char);
16693 vector unsigned char vec_sr (vector unsigned char,
16694                              vector unsigned char);
16695 vector signed short vec_sr (vector signed short,
16696                             vector unsigned short);
16697 vector unsigned short vec_sr (vector unsigned short,
16698                               vector unsigned short);
16699 vector signed int vec_sr (vector signed int, vector unsigned int);
16700 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16702 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16703 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16705 vector signed short vec_vsrh (vector signed short,
16706                               vector unsigned short);
16707 vector unsigned short vec_vsrh (vector unsigned short,
16708                                 vector unsigned short);
16710 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16711 vector unsigned char vec_vsrb (vector unsigned char,
16712                                vector unsigned char);
16714 vector signed char vec_sra (vector signed char, vector unsigned char);
16715 vector unsigned char vec_sra (vector unsigned char,
16716                               vector unsigned char);
16717 vector signed short vec_sra (vector signed short,
16718                              vector unsigned short);
16719 vector unsigned short vec_sra (vector unsigned short,
16720                                vector unsigned short);
16721 vector signed int vec_sra (vector signed int, vector unsigned int);
16722 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16724 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16725 vector unsigned int vec_vsraw (vector unsigned int,
16726                                vector unsigned int);
16728 vector signed short vec_vsrah (vector signed short,
16729                                vector unsigned short);
16730 vector unsigned short vec_vsrah (vector unsigned short,
16731                                  vector unsigned short);
16733 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16734 vector unsigned char vec_vsrab (vector unsigned char,
16735                                 vector unsigned char);
16737 vector signed int vec_srl (vector signed int, vector unsigned int);
16738 vector signed int vec_srl (vector signed int, vector unsigned short);
16739 vector signed int vec_srl (vector signed int, vector unsigned char);
16740 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16741 vector unsigned int vec_srl (vector unsigned int,
16742                              vector unsigned short);
16743 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16744 vector bool int vec_srl (vector bool int, vector unsigned int);
16745 vector bool int vec_srl (vector bool int, vector unsigned short);
16746 vector bool int vec_srl (vector bool int, vector unsigned char);
16747 vector signed short vec_srl (vector signed short, vector unsigned int);
16748 vector signed short vec_srl (vector signed short,
16749                              vector unsigned short);
16750 vector signed short vec_srl (vector signed short, vector unsigned char);
16751 vector unsigned short vec_srl (vector unsigned short,
16752                                vector unsigned int);
16753 vector unsigned short vec_srl (vector unsigned short,
16754                                vector unsigned short);
16755 vector unsigned short vec_srl (vector unsigned short,
16756                                vector unsigned char);
16757 vector bool short vec_srl (vector bool short, vector unsigned int);
16758 vector bool short vec_srl (vector bool short, vector unsigned short);
16759 vector bool short vec_srl (vector bool short, vector unsigned char);
16760 vector pixel vec_srl (vector pixel, vector unsigned int);
16761 vector pixel vec_srl (vector pixel, vector unsigned short);
16762 vector pixel vec_srl (vector pixel, vector unsigned char);
16763 vector signed char vec_srl (vector signed char, vector unsigned int);
16764 vector signed char vec_srl (vector signed char, vector unsigned short);
16765 vector signed char vec_srl (vector signed char, vector unsigned char);
16766 vector unsigned char vec_srl (vector unsigned char,
16767                               vector unsigned int);
16768 vector unsigned char vec_srl (vector unsigned char,
16769                               vector unsigned short);
16770 vector unsigned char vec_srl (vector unsigned char,
16771                               vector unsigned char);
16772 vector bool char vec_srl (vector bool char, vector unsigned int);
16773 vector bool char vec_srl (vector bool char, vector unsigned short);
16774 vector bool char vec_srl (vector bool char, vector unsigned char);
16776 vector float vec_sro (vector float, vector signed char);
16777 vector float vec_sro (vector float, vector unsigned char);
16778 vector signed int vec_sro (vector signed int, vector signed char);
16779 vector signed int vec_sro (vector signed int, vector unsigned char);
16780 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16781 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16782 vector signed short vec_sro (vector signed short, vector signed char);
16783 vector signed short vec_sro (vector signed short, vector unsigned char);
16784 vector unsigned short vec_sro (vector unsigned short,
16785                                vector signed char);
16786 vector unsigned short vec_sro (vector unsigned short,
16787                                vector unsigned char);
16788 vector pixel vec_sro (vector pixel, vector signed char);
16789 vector pixel vec_sro (vector pixel, vector unsigned char);
16790 vector signed char vec_sro (vector signed char, vector signed char);
16791 vector signed char vec_sro (vector signed char, vector unsigned char);
16792 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16793 vector unsigned char vec_sro (vector unsigned char,
16794                               vector unsigned char);
16796 void vec_st (vector float, int, vector float *);
16797 void vec_st (vector float, int, float *);
16798 void vec_st (vector signed int, int, vector signed int *);
16799 void vec_st (vector signed int, int, int *);
16800 void vec_st (vector unsigned int, int, vector unsigned int *);
16801 void vec_st (vector unsigned int, int, unsigned int *);
16802 void vec_st (vector bool int, int, vector bool int *);
16803 void vec_st (vector bool int, int, unsigned int *);
16804 void vec_st (vector bool int, int, int *);
16805 void vec_st (vector signed short, int, vector signed short *);
16806 void vec_st (vector signed short, int, short *);
16807 void vec_st (vector unsigned short, int, vector unsigned short *);
16808 void vec_st (vector unsigned short, int, unsigned short *);
16809 void vec_st (vector bool short, int, vector bool short *);
16810 void vec_st (vector bool short, int, unsigned short *);
16811 void vec_st (vector pixel, int, vector pixel *);
16812 void vec_st (vector pixel, int, unsigned short *);
16813 void vec_st (vector pixel, int, short *);
16814 void vec_st (vector bool short, int, short *);
16815 void vec_st (vector signed char, int, vector signed char *);
16816 void vec_st (vector signed char, int, signed char *);
16817 void vec_st (vector unsigned char, int, vector unsigned char *);
16818 void vec_st (vector unsigned char, int, unsigned char *);
16819 void vec_st (vector bool char, int, vector bool char *);
16820 void vec_st (vector bool char, int, unsigned char *);
16821 void vec_st (vector bool char, int, signed char *);
16823 void vec_ste (vector signed char, int, signed char *);
16824 void vec_ste (vector unsigned char, int, unsigned char *);
16825 void vec_ste (vector bool char, int, signed char *);
16826 void vec_ste (vector bool char, int, unsigned char *);
16827 void vec_ste (vector signed short, int, short *);
16828 void vec_ste (vector unsigned short, int, unsigned short *);
16829 void vec_ste (vector bool short, int, short *);
16830 void vec_ste (vector bool short, int, unsigned short *);
16831 void vec_ste (vector pixel, int, short *);
16832 void vec_ste (vector pixel, int, unsigned short *);
16833 void vec_ste (vector float, int, float *);
16834 void vec_ste (vector signed int, int, int *);
16835 void vec_ste (vector unsigned int, int, unsigned int *);
16836 void vec_ste (vector bool int, int, int *);
16837 void vec_ste (vector bool int, int, unsigned int *);
16839 void vec_stvewx (vector float, int, float *);
16840 void vec_stvewx (vector signed int, int, int *);
16841 void vec_stvewx (vector unsigned int, int, unsigned int *);
16842 void vec_stvewx (vector bool int, int, int *);
16843 void vec_stvewx (vector bool int, int, unsigned int *);
16845 void vec_stvehx (vector signed short, int, short *);
16846 void vec_stvehx (vector unsigned short, int, unsigned short *);
16847 void vec_stvehx (vector bool short, int, short *);
16848 void vec_stvehx (vector bool short, int, unsigned short *);
16849 void vec_stvehx (vector pixel, int, short *);
16850 void vec_stvehx (vector pixel, int, unsigned short *);
16852 void vec_stvebx (vector signed char, int, signed char *);
16853 void vec_stvebx (vector unsigned char, int, unsigned char *);
16854 void vec_stvebx (vector bool char, int, signed char *);
16855 void vec_stvebx (vector bool char, int, unsigned char *);
16857 void vec_stl (vector float, int, vector float *);
16858 void vec_stl (vector float, int, float *);
16859 void vec_stl (vector signed int, int, vector signed int *);
16860 void vec_stl (vector signed int, int, int *);
16861 void vec_stl (vector unsigned int, int, vector unsigned int *);
16862 void vec_stl (vector unsigned int, int, unsigned int *);
16863 void vec_stl (vector bool int, int, vector bool int *);
16864 void vec_stl (vector bool int, int, unsigned int *);
16865 void vec_stl (vector bool int, int, int *);
16866 void vec_stl (vector signed short, int, vector signed short *);
16867 void vec_stl (vector signed short, int, short *);
16868 void vec_stl (vector unsigned short, int, vector unsigned short *);
16869 void vec_stl (vector unsigned short, int, unsigned short *);
16870 void vec_stl (vector bool short, int, vector bool short *);
16871 void vec_stl (vector bool short, int, unsigned short *);
16872 void vec_stl (vector bool short, int, short *);
16873 void vec_stl (vector pixel, int, vector pixel *);
16874 void vec_stl (vector pixel, int, unsigned short *);
16875 void vec_stl (vector pixel, int, short *);
16876 void vec_stl (vector signed char, int, vector signed char *);
16877 void vec_stl (vector signed char, int, signed char *);
16878 void vec_stl (vector unsigned char, int, vector unsigned char *);
16879 void vec_stl (vector unsigned char, int, unsigned char *);
16880 void vec_stl (vector bool char, int, vector bool char *);
16881 void vec_stl (vector bool char, int, unsigned char *);
16882 void vec_stl (vector bool char, int, signed char *);
16884 vector signed char vec_sub (vector bool char, vector signed char);
16885 vector signed char vec_sub (vector signed char, vector bool char);
16886 vector signed char vec_sub (vector signed char, vector signed char);
16887 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16888 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16889 vector unsigned char vec_sub (vector unsigned char,
16890                               vector unsigned char);
16891 vector signed short vec_sub (vector bool short, vector signed short);
16892 vector signed short vec_sub (vector signed short, vector bool short);
16893 vector signed short vec_sub (vector signed short, vector signed short);
16894 vector unsigned short vec_sub (vector bool short,
16895                                vector unsigned short);
16896 vector unsigned short vec_sub (vector unsigned short,
16897                                vector bool short);
16898 vector unsigned short vec_sub (vector unsigned short,
16899                                vector unsigned short);
16900 vector signed int vec_sub (vector bool int, vector signed int);
16901 vector signed int vec_sub (vector signed int, vector bool int);
16902 vector signed int vec_sub (vector signed int, vector signed int);
16903 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16904 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16905 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16906 vector float vec_sub (vector float, vector float);
16908 vector float vec_vsubfp (vector float, vector float);
16910 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16911 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16912 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16913 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16914 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16915 vector unsigned int vec_vsubuwm (vector unsigned int,
16916                                  vector unsigned int);
16918 vector signed short vec_vsubuhm (vector bool short,
16919                                  vector signed short);
16920 vector signed short vec_vsubuhm (vector signed short,
16921                                  vector bool short);
16922 vector signed short vec_vsubuhm (vector signed short,
16923                                  vector signed short);
16924 vector unsigned short vec_vsubuhm (vector bool short,
16925                                    vector unsigned short);
16926 vector unsigned short vec_vsubuhm (vector unsigned short,
16927                                    vector bool short);
16928 vector unsigned short vec_vsubuhm (vector unsigned short,
16929                                    vector unsigned short);
16931 vector signed char vec_vsububm (vector bool char, vector signed char);
16932 vector signed char vec_vsububm (vector signed char, vector bool char);
16933 vector signed char vec_vsububm (vector signed char, vector signed char);
16934 vector unsigned char vec_vsububm (vector bool char,
16935                                   vector unsigned char);
16936 vector unsigned char vec_vsububm (vector unsigned char,
16937                                   vector bool char);
16938 vector unsigned char vec_vsububm (vector unsigned char,
16939                                   vector unsigned char);
16941 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16943 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16944 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16945 vector unsigned char vec_subs (vector unsigned char,
16946                                vector unsigned char);
16947 vector signed char vec_subs (vector bool char, vector signed char);
16948 vector signed char vec_subs (vector signed char, vector bool char);
16949 vector signed char vec_subs (vector signed char, vector signed char);
16950 vector unsigned short vec_subs (vector bool short,
16951                                 vector unsigned short);
16952 vector unsigned short vec_subs (vector unsigned short,
16953                                 vector bool short);
16954 vector unsigned short vec_subs (vector unsigned short,
16955                                 vector unsigned short);
16956 vector signed short vec_subs (vector bool short, vector signed short);
16957 vector signed short vec_subs (vector signed short, vector bool short);
16958 vector signed short vec_subs (vector signed short, vector signed short);
16959 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16960 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16961 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16962 vector signed int vec_subs (vector bool int, vector signed int);
16963 vector signed int vec_subs (vector signed int, vector bool int);
16964 vector signed int vec_subs (vector signed int, vector signed int);
16966 vector signed int vec_vsubsws (vector bool int, vector signed int);
16967 vector signed int vec_vsubsws (vector signed int, vector bool int);
16968 vector signed int vec_vsubsws (vector signed int, vector signed int);
16970 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16971 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
16972 vector unsigned int vec_vsubuws (vector unsigned int,
16973                                  vector unsigned int);
16975 vector signed short vec_vsubshs (vector bool short,
16976                                  vector signed short);
16977 vector signed short vec_vsubshs (vector signed short,
16978                                  vector bool short);
16979 vector signed short vec_vsubshs (vector signed short,
16980                                  vector signed short);
16982 vector unsigned short vec_vsubuhs (vector bool short,
16983                                    vector unsigned short);
16984 vector unsigned short vec_vsubuhs (vector unsigned short,
16985                                    vector bool short);
16986 vector unsigned short vec_vsubuhs (vector unsigned short,
16987                                    vector unsigned short);
16989 vector signed char vec_vsubsbs (vector bool char, vector signed char);
16990 vector signed char vec_vsubsbs (vector signed char, vector bool char);
16991 vector signed char vec_vsubsbs (vector signed char, vector signed char);
16993 vector unsigned char vec_vsububs (vector bool char,
16994                                   vector unsigned char);
16995 vector unsigned char vec_vsububs (vector unsigned char,
16996                                   vector bool char);
16997 vector unsigned char vec_vsububs (vector unsigned char,
16998                                   vector unsigned char);
17000 vector unsigned int vec_sum4s (vector unsigned char,
17001                                vector unsigned int);
17002 vector signed int vec_sum4s (vector signed char, vector signed int);
17003 vector signed int vec_sum4s (vector signed short, vector signed int);
17005 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17007 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17009 vector unsigned int vec_vsum4ubs (vector unsigned char,
17010                                   vector unsigned int);
17012 vector signed int vec_sum2s (vector signed int, vector signed int);
17014 vector signed int vec_sums (vector signed int, vector signed int);
17016 vector float vec_trunc (vector float);
17018 vector signed short vec_unpackh (vector signed char);
17019 vector bool short vec_unpackh (vector bool char);
17020 vector signed int vec_unpackh (vector signed short);
17021 vector bool int vec_unpackh (vector bool short);
17022 vector unsigned int vec_unpackh (vector pixel);
17024 vector bool int vec_vupkhsh (vector bool short);
17025 vector signed int vec_vupkhsh (vector signed short);
17027 vector unsigned int vec_vupkhpx (vector pixel);
17029 vector bool short vec_vupkhsb (vector bool char);
17030 vector signed short vec_vupkhsb (vector signed char);
17032 vector signed short vec_unpackl (vector signed char);
17033 vector bool short vec_unpackl (vector bool char);
17034 vector unsigned int vec_unpackl (vector pixel);
17035 vector signed int vec_unpackl (vector signed short);
17036 vector bool int vec_unpackl (vector bool short);
17038 vector unsigned int vec_vupklpx (vector pixel);
17040 vector bool int vec_vupklsh (vector bool short);
17041 vector signed int vec_vupklsh (vector signed short);
17043 vector bool short vec_vupklsb (vector bool char);
17044 vector signed short vec_vupklsb (vector signed char);
17046 vector float vec_xor (vector float, vector float);
17047 vector float vec_xor (vector float, vector bool int);
17048 vector float vec_xor (vector bool int, vector float);
17049 vector bool int vec_xor (vector bool int, vector bool int);
17050 vector signed int vec_xor (vector bool int, vector signed int);
17051 vector signed int vec_xor (vector signed int, vector bool int);
17052 vector signed int vec_xor (vector signed int, vector signed int);
17053 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17054 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17055 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17056 vector bool short vec_xor (vector bool short, vector bool short);
17057 vector signed short vec_xor (vector bool short, vector signed short);
17058 vector signed short vec_xor (vector signed short, vector bool short);
17059 vector signed short vec_xor (vector signed short, vector signed short);
17060 vector unsigned short vec_xor (vector bool short,
17061                                vector unsigned short);
17062 vector unsigned short vec_xor (vector unsigned short,
17063                                vector bool short);
17064 vector unsigned short vec_xor (vector unsigned short,
17065                                vector unsigned short);
17066 vector signed char vec_xor (vector bool char, vector signed char);
17067 vector bool char vec_xor (vector bool char, vector bool char);
17068 vector signed char vec_xor (vector signed char, vector bool char);
17069 vector signed char vec_xor (vector signed char, vector signed char);
17070 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17071 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17072 vector unsigned char vec_xor (vector unsigned char,
17073                               vector unsigned char);
17075 int vec_all_eq (vector signed char, vector bool char);
17076 int vec_all_eq (vector signed char, vector signed char);
17077 int vec_all_eq (vector unsigned char, vector bool char);
17078 int vec_all_eq (vector unsigned char, vector unsigned char);
17079 int vec_all_eq (vector bool char, vector bool char);
17080 int vec_all_eq (vector bool char, vector unsigned char);
17081 int vec_all_eq (vector bool char, vector signed char);
17082 int vec_all_eq (vector signed short, vector bool short);
17083 int vec_all_eq (vector signed short, vector signed short);
17084 int vec_all_eq (vector unsigned short, vector bool short);
17085 int vec_all_eq (vector unsigned short, vector unsigned short);
17086 int vec_all_eq (vector bool short, vector bool short);
17087 int vec_all_eq (vector bool short, vector unsigned short);
17088 int vec_all_eq (vector bool short, vector signed short);
17089 int vec_all_eq (vector pixel, vector pixel);
17090 int vec_all_eq (vector signed int, vector bool int);
17091 int vec_all_eq (vector signed int, vector signed int);
17092 int vec_all_eq (vector unsigned int, vector bool int);
17093 int vec_all_eq (vector unsigned int, vector unsigned int);
17094 int vec_all_eq (vector bool int, vector bool int);
17095 int vec_all_eq (vector bool int, vector unsigned int);
17096 int vec_all_eq (vector bool int, vector signed int);
17097 int vec_all_eq (vector float, vector float);
17099 int vec_all_ge (vector bool char, vector unsigned char);
17100 int vec_all_ge (vector unsigned char, vector bool char);
17101 int vec_all_ge (vector unsigned char, vector unsigned char);
17102 int vec_all_ge (vector bool char, vector signed char);
17103 int vec_all_ge (vector signed char, vector bool char);
17104 int vec_all_ge (vector signed char, vector signed char);
17105 int vec_all_ge (vector bool short, vector unsigned short);
17106 int vec_all_ge (vector unsigned short, vector bool short);
17107 int vec_all_ge (vector unsigned short, vector unsigned short);
17108 int vec_all_ge (vector signed short, vector signed short);
17109 int vec_all_ge (vector bool short, vector signed short);
17110 int vec_all_ge (vector signed short, vector bool short);
17111 int vec_all_ge (vector bool int, vector unsigned int);
17112 int vec_all_ge (vector unsigned int, vector bool int);
17113 int vec_all_ge (vector unsigned int, vector unsigned int);
17114 int vec_all_ge (vector bool int, vector signed int);
17115 int vec_all_ge (vector signed int, vector bool int);
17116 int vec_all_ge (vector signed int, vector signed int);
17117 int vec_all_ge (vector float, vector float);
17119 int vec_all_gt (vector bool char, vector unsigned char);
17120 int vec_all_gt (vector unsigned char, vector bool char);
17121 int vec_all_gt (vector unsigned char, vector unsigned char);
17122 int vec_all_gt (vector bool char, vector signed char);
17123 int vec_all_gt (vector signed char, vector bool char);
17124 int vec_all_gt (vector signed char, vector signed char);
17125 int vec_all_gt (vector bool short, vector unsigned short);
17126 int vec_all_gt (vector unsigned short, vector bool short);
17127 int vec_all_gt (vector unsigned short, vector unsigned short);
17128 int vec_all_gt (vector bool short, vector signed short);
17129 int vec_all_gt (vector signed short, vector bool short);
17130 int vec_all_gt (vector signed short, vector signed short);
17131 int vec_all_gt (vector bool int, vector unsigned int);
17132 int vec_all_gt (vector unsigned int, vector bool int);
17133 int vec_all_gt (vector unsigned int, vector unsigned int);
17134 int vec_all_gt (vector bool int, vector signed int);
17135 int vec_all_gt (vector signed int, vector bool int);
17136 int vec_all_gt (vector signed int, vector signed int);
17137 int vec_all_gt (vector float, vector float);
17139 int vec_all_in (vector float, vector float);
17141 int vec_all_le (vector bool char, vector unsigned char);
17142 int vec_all_le (vector unsigned char, vector bool char);
17143 int vec_all_le (vector unsigned char, vector unsigned char);
17144 int vec_all_le (vector bool char, vector signed char);
17145 int vec_all_le (vector signed char, vector bool char);
17146 int vec_all_le (vector signed char, vector signed char);
17147 int vec_all_le (vector bool short, vector unsigned short);
17148 int vec_all_le (vector unsigned short, vector bool short);
17149 int vec_all_le (vector unsigned short, vector unsigned short);
17150 int vec_all_le (vector bool short, vector signed short);
17151 int vec_all_le (vector signed short, vector bool short);
17152 int vec_all_le (vector signed short, vector signed short);
17153 int vec_all_le (vector bool int, vector unsigned int);
17154 int vec_all_le (vector unsigned int, vector bool int);
17155 int vec_all_le (vector unsigned int, vector unsigned int);
17156 int vec_all_le (vector bool int, vector signed int);
17157 int vec_all_le (vector signed int, vector bool int);
17158 int vec_all_le (vector signed int, vector signed int);
17159 int vec_all_le (vector float, vector float);
17161 int vec_all_lt (vector bool char, vector unsigned char);
17162 int vec_all_lt (vector unsigned char, vector bool char);
17163 int vec_all_lt (vector unsigned char, vector unsigned char);
17164 int vec_all_lt (vector bool char, vector signed char);
17165 int vec_all_lt (vector signed char, vector bool char);
17166 int vec_all_lt (vector signed char, vector signed char);
17167 int vec_all_lt (vector bool short, vector unsigned short);
17168 int vec_all_lt (vector unsigned short, vector bool short);
17169 int vec_all_lt (vector unsigned short, vector unsigned short);
17170 int vec_all_lt (vector bool short, vector signed short);
17171 int vec_all_lt (vector signed short, vector bool short);
17172 int vec_all_lt (vector signed short, vector signed short);
17173 int vec_all_lt (vector bool int, vector unsigned int);
17174 int vec_all_lt (vector unsigned int, vector bool int);
17175 int vec_all_lt (vector unsigned int, vector unsigned int);
17176 int vec_all_lt (vector bool int, vector signed int);
17177 int vec_all_lt (vector signed int, vector bool int);
17178 int vec_all_lt (vector signed int, vector signed int);
17179 int vec_all_lt (vector float, vector float);
17181 int vec_all_nan (vector float);
17183 int vec_all_ne (vector signed char, vector bool char);
17184 int vec_all_ne (vector signed char, vector signed char);
17185 int vec_all_ne (vector unsigned char, vector bool char);
17186 int vec_all_ne (vector unsigned char, vector unsigned char);
17187 int vec_all_ne (vector bool char, vector bool char);
17188 int vec_all_ne (vector bool char, vector unsigned char);
17189 int vec_all_ne (vector bool char, vector signed char);
17190 int vec_all_ne (vector signed short, vector bool short);
17191 int vec_all_ne (vector signed short, vector signed short);
17192 int vec_all_ne (vector unsigned short, vector bool short);
17193 int vec_all_ne (vector unsigned short, vector unsigned short);
17194 int vec_all_ne (vector bool short, vector bool short);
17195 int vec_all_ne (vector bool short, vector unsigned short);
17196 int vec_all_ne (vector bool short, vector signed short);
17197 int vec_all_ne (vector pixel, vector pixel);
17198 int vec_all_ne (vector signed int, vector bool int);
17199 int vec_all_ne (vector signed int, vector signed int);
17200 int vec_all_ne (vector unsigned int, vector bool int);
17201 int vec_all_ne (vector unsigned int, vector unsigned int);
17202 int vec_all_ne (vector bool int, vector bool int);
17203 int vec_all_ne (vector bool int, vector unsigned int);
17204 int vec_all_ne (vector bool int, vector signed int);
17205 int vec_all_ne (vector float, vector float);
17207 int vec_all_nge (vector float, vector float);
17209 int vec_all_ngt (vector float, vector float);
17211 int vec_all_nle (vector float, vector float);
17213 int vec_all_nlt (vector float, vector float);
17215 int vec_all_numeric (vector float);
17217 int vec_any_eq (vector signed char, vector bool char);
17218 int vec_any_eq (vector signed char, vector signed char);
17219 int vec_any_eq (vector unsigned char, vector bool char);
17220 int vec_any_eq (vector unsigned char, vector unsigned char);
17221 int vec_any_eq (vector bool char, vector bool char);
17222 int vec_any_eq (vector bool char, vector unsigned char);
17223 int vec_any_eq (vector bool char, vector signed char);
17224 int vec_any_eq (vector signed short, vector bool short);
17225 int vec_any_eq (vector signed short, vector signed short);
17226 int vec_any_eq (vector unsigned short, vector bool short);
17227 int vec_any_eq (vector unsigned short, vector unsigned short);
17228 int vec_any_eq (vector bool short, vector bool short);
17229 int vec_any_eq (vector bool short, vector unsigned short);
17230 int vec_any_eq (vector bool short, vector signed short);
17231 int vec_any_eq (vector pixel, vector pixel);
17232 int vec_any_eq (vector signed int, vector bool int);
17233 int vec_any_eq (vector signed int, vector signed int);
17234 int vec_any_eq (vector unsigned int, vector bool int);
17235 int vec_any_eq (vector unsigned int, vector unsigned int);
17236 int vec_any_eq (vector bool int, vector bool int);
17237 int vec_any_eq (vector bool int, vector unsigned int);
17238 int vec_any_eq (vector bool int, vector signed int);
17239 int vec_any_eq (vector float, vector float);
17241 int vec_any_ge (vector signed char, vector bool char);
17242 int vec_any_ge (vector unsigned char, vector bool char);
17243 int vec_any_ge (vector unsigned char, vector unsigned char);
17244 int vec_any_ge (vector signed char, vector signed char);
17245 int vec_any_ge (vector bool char, vector unsigned char);
17246 int vec_any_ge (vector bool char, vector signed char);
17247 int vec_any_ge (vector unsigned short, vector bool short);
17248 int vec_any_ge (vector unsigned short, vector unsigned short);
17249 int vec_any_ge (vector signed short, vector signed short);
17250 int vec_any_ge (vector signed short, vector bool short);
17251 int vec_any_ge (vector bool short, vector unsigned short);
17252 int vec_any_ge (vector bool short, vector signed short);
17253 int vec_any_ge (vector signed int, vector bool int);
17254 int vec_any_ge (vector unsigned int, vector bool int);
17255 int vec_any_ge (vector unsigned int, vector unsigned int);
17256 int vec_any_ge (vector signed int, vector signed int);
17257 int vec_any_ge (vector bool int, vector unsigned int);
17258 int vec_any_ge (vector bool int, vector signed int);
17259 int vec_any_ge (vector float, vector float);
17261 int vec_any_gt (vector bool char, vector unsigned char);
17262 int vec_any_gt (vector unsigned char, vector bool char);
17263 int vec_any_gt (vector unsigned char, vector unsigned char);
17264 int vec_any_gt (vector bool char, vector signed char);
17265 int vec_any_gt (vector signed char, vector bool char);
17266 int vec_any_gt (vector signed char, vector signed char);
17267 int vec_any_gt (vector bool short, vector unsigned short);
17268 int vec_any_gt (vector unsigned short, vector bool short);
17269 int vec_any_gt (vector unsigned short, vector unsigned short);
17270 int vec_any_gt (vector bool short, vector signed short);
17271 int vec_any_gt (vector signed short, vector bool short);
17272 int vec_any_gt (vector signed short, vector signed short);
17273 int vec_any_gt (vector bool int, vector unsigned int);
17274 int vec_any_gt (vector unsigned int, vector bool int);
17275 int vec_any_gt (vector unsigned int, vector unsigned int);
17276 int vec_any_gt (vector bool int, vector signed int);
17277 int vec_any_gt (vector signed int, vector bool int);
17278 int vec_any_gt (vector signed int, vector signed int);
17279 int vec_any_gt (vector float, vector float);
17281 int vec_any_le (vector bool char, vector unsigned char);
17282 int vec_any_le (vector unsigned char, vector bool char);
17283 int vec_any_le (vector unsigned char, vector unsigned char);
17284 int vec_any_le (vector bool char, vector signed char);
17285 int vec_any_le (vector signed char, vector bool char);
17286 int vec_any_le (vector signed char, vector signed char);
17287 int vec_any_le (vector bool short, vector unsigned short);
17288 int vec_any_le (vector unsigned short, vector bool short);
17289 int vec_any_le (vector unsigned short, vector unsigned short);
17290 int vec_any_le (vector bool short, vector signed short);
17291 int vec_any_le (vector signed short, vector bool short);
17292 int vec_any_le (vector signed short, vector signed short);
17293 int vec_any_le (vector bool int, vector unsigned int);
17294 int vec_any_le (vector unsigned int, vector bool int);
17295 int vec_any_le (vector unsigned int, vector unsigned int);
17296 int vec_any_le (vector bool int, vector signed int);
17297 int vec_any_le (vector signed int, vector bool int);
17298 int vec_any_le (vector signed int, vector signed int);
17299 int vec_any_le (vector float, vector float);
17301 int vec_any_lt (vector bool char, vector unsigned char);
17302 int vec_any_lt (vector unsigned char, vector bool char);
17303 int vec_any_lt (vector unsigned char, vector unsigned char);
17304 int vec_any_lt (vector bool char, vector signed char);
17305 int vec_any_lt (vector signed char, vector bool char);
17306 int vec_any_lt (vector signed char, vector signed char);
17307 int vec_any_lt (vector bool short, vector unsigned short);
17308 int vec_any_lt (vector unsigned short, vector bool short);
17309 int vec_any_lt (vector unsigned short, vector unsigned short);
17310 int vec_any_lt (vector bool short, vector signed short);
17311 int vec_any_lt (vector signed short, vector bool short);
17312 int vec_any_lt (vector signed short, vector signed short);
17313 int vec_any_lt (vector bool int, vector unsigned int);
17314 int vec_any_lt (vector unsigned int, vector bool int);
17315 int vec_any_lt (vector unsigned int, vector unsigned int);
17316 int vec_any_lt (vector bool int, vector signed int);
17317 int vec_any_lt (vector signed int, vector bool int);
17318 int vec_any_lt (vector signed int, vector signed int);
17319 int vec_any_lt (vector float, vector float);
17321 int vec_any_nan (vector float);
17323 int vec_any_ne (vector signed char, vector bool char);
17324 int vec_any_ne (vector signed char, vector signed char);
17325 int vec_any_ne (vector unsigned char, vector bool char);
17326 int vec_any_ne (vector unsigned char, vector unsigned char);
17327 int vec_any_ne (vector bool char, vector bool char);
17328 int vec_any_ne (vector bool char, vector unsigned char);
17329 int vec_any_ne (vector bool char, vector signed char);
17330 int vec_any_ne (vector signed short, vector bool short);
17331 int vec_any_ne (vector signed short, vector signed short);
17332 int vec_any_ne (vector unsigned short, vector bool short);
17333 int vec_any_ne (vector unsigned short, vector unsigned short);
17334 int vec_any_ne (vector bool short, vector bool short);
17335 int vec_any_ne (vector bool short, vector unsigned short);
17336 int vec_any_ne (vector bool short, vector signed short);
17337 int vec_any_ne (vector pixel, vector pixel);
17338 int vec_any_ne (vector signed int, vector bool int);
17339 int vec_any_ne (vector signed int, vector signed int);
17340 int vec_any_ne (vector unsigned int, vector bool int);
17341 int vec_any_ne (vector unsigned int, vector unsigned int);
17342 int vec_any_ne (vector bool int, vector bool int);
17343 int vec_any_ne (vector bool int, vector unsigned int);
17344 int vec_any_ne (vector bool int, vector signed int);
17345 int vec_any_ne (vector float, vector float);
17347 int vec_any_nge (vector float, vector float);
17349 int vec_any_ngt (vector float, vector float);
17351 int vec_any_nle (vector float, vector float);
17353 int vec_any_nlt (vector float, vector float);
17355 int vec_any_numeric (vector float);
17357 int vec_any_out (vector float, vector float);
17358 @end smallexample
17360 If the vector/scalar (VSX) instruction set is available, the following
17361 additional functions are available:
17363 @smallexample
17364 vector double vec_abs (vector double);
17365 vector double vec_add (vector double, vector double);
17366 vector double vec_and (vector double, vector double);
17367 vector double vec_and (vector double, vector bool long);
17368 vector double vec_and (vector bool long, vector double);
17369 vector long vec_and (vector long, vector long);
17370 vector long vec_and (vector long, vector bool long);
17371 vector long vec_and (vector bool long, vector long);
17372 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17373 vector unsigned long vec_and (vector unsigned long, vector bool long);
17374 vector unsigned long vec_and (vector bool long, vector unsigned long);
17375 vector double vec_andc (vector double, vector double);
17376 vector double vec_andc (vector double, vector bool long);
17377 vector double vec_andc (vector bool long, vector double);
17378 vector long vec_andc (vector long, vector long);
17379 vector long vec_andc (vector long, vector bool long);
17380 vector long vec_andc (vector bool long, vector long);
17381 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17382 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17383 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17384 vector double vec_ceil (vector double);
17385 vector bool long vec_cmpeq (vector double, vector double);
17386 vector bool long vec_cmpge (vector double, vector double);
17387 vector bool long vec_cmpgt (vector double, vector double);
17388 vector bool long vec_cmple (vector double, vector double);
17389 vector bool long vec_cmplt (vector double, vector double);
17390 vector double vec_cpsgn (vector double, vector double);
17391 vector float vec_div (vector float, vector float);
17392 vector double vec_div (vector double, vector double);
17393 vector long vec_div (vector long, vector long);
17394 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17395 vector double vec_floor (vector double);
17396 vector double vec_ld (int, const vector double *);
17397 vector double vec_ld (int, const double *);
17398 vector double vec_ldl (int, const vector double *);
17399 vector double vec_ldl (int, const double *);
17400 vector unsigned char vec_lvsl (int, const volatile double *);
17401 vector unsigned char vec_lvsr (int, const volatile double *);
17402 vector double vec_madd (vector double, vector double, vector double);
17403 vector double vec_max (vector double, vector double);
17404 vector signed long vec_mergeh (vector signed long, vector signed long);
17405 vector signed long vec_mergeh (vector signed long, vector bool long);
17406 vector signed long vec_mergeh (vector bool long, vector signed long);
17407 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17408 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17409 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17410 vector signed long vec_mergel (vector signed long, vector signed long);
17411 vector signed long vec_mergel (vector signed long, vector bool long);
17412 vector signed long vec_mergel (vector bool long, vector signed long);
17413 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17414 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17415 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17416 vector double vec_min (vector double, vector double);
17417 vector float vec_msub (vector float, vector float, vector float);
17418 vector double vec_msub (vector double, vector double, vector double);
17419 vector float vec_mul (vector float, vector float);
17420 vector double vec_mul (vector double, vector double);
17421 vector long vec_mul (vector long, vector long);
17422 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17423 vector float vec_nearbyint (vector float);
17424 vector double vec_nearbyint (vector double);
17425 vector float vec_nmadd (vector float, vector float, vector float);
17426 vector double vec_nmadd (vector double, vector double, vector double);
17427 vector double vec_nmsub (vector double, vector double, vector double);
17428 vector double vec_nor (vector double, vector double);
17429 vector long vec_nor (vector long, vector long);
17430 vector long vec_nor (vector long, vector bool long);
17431 vector long vec_nor (vector bool long, vector long);
17432 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17433 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17434 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17435 vector double vec_or (vector double, vector double);
17436 vector double vec_or (vector double, vector bool long);
17437 vector double vec_or (vector bool long, vector double);
17438 vector long vec_or (vector long, vector long);
17439 vector long vec_or (vector long, vector bool long);
17440 vector long vec_or (vector bool long, vector long);
17441 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17442 vector unsigned long vec_or (vector unsigned long, vector bool long);
17443 vector unsigned long vec_or (vector bool long, vector unsigned long);
17444 vector double vec_perm (vector double, vector double, vector unsigned char);
17445 vector long vec_perm (vector long, vector long, vector unsigned char);
17446 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17447                                vector unsigned char);
17448 vector double vec_rint (vector double);
17449 vector double vec_recip (vector double, vector double);
17450 vector double vec_rsqrt (vector double);
17451 vector double vec_rsqrte (vector double);
17452 vector double vec_sel (vector double, vector double, vector bool long);
17453 vector double vec_sel (vector double, vector double, vector unsigned long);
17454 vector long vec_sel (vector long, vector long, vector long);
17455 vector long vec_sel (vector long, vector long, vector unsigned long);
17456 vector long vec_sel (vector long, vector long, vector bool long);
17457 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17458                               vector long);
17459 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17460                               vector unsigned long);
17461 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17462                               vector bool long);
17463 vector double vec_splats (double);
17464 vector signed long vec_splats (signed long);
17465 vector unsigned long vec_splats (unsigned long);
17466 vector float vec_sqrt (vector float);
17467 vector double vec_sqrt (vector double);
17468 void vec_st (vector double, int, vector double *);
17469 void vec_st (vector double, int, double *);
17470 vector double vec_sub (vector double, vector double);
17471 vector double vec_trunc (vector double);
17472 vector double vec_xl (int, vector double *);
17473 vector double vec_xl (int, double *);
17474 vector long long vec_xl (int, vector long long *);
17475 vector long long vec_xl (int, long long *);
17476 vector unsigned long long vec_xl (int, vector unsigned long long *);
17477 vector unsigned long long vec_xl (int, unsigned long long *);
17478 vector float vec_xl (int, vector float *);
17479 vector float vec_xl (int, float *);
17480 vector int vec_xl (int, vector int *);
17481 vector int vec_xl (int, int *);
17482 vector unsigned int vec_xl (int, vector unsigned int *);
17483 vector unsigned int vec_xl (int, unsigned int *);
17484 vector double vec_xor (vector double, vector double);
17485 vector double vec_xor (vector double, vector bool long);
17486 vector double vec_xor (vector bool long, vector double);
17487 vector long vec_xor (vector long, vector long);
17488 vector long vec_xor (vector long, vector bool long);
17489 vector long vec_xor (vector bool long, vector long);
17490 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17491 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17492 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17493 void vec_xst (vector double, int, vector double *);
17494 void vec_xst (vector double, int, double *);
17495 void vec_xst (vector long long, int, vector long long *);
17496 void vec_xst (vector long long, int, long long *);
17497 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17498 void vec_xst (vector unsigned long long, int, unsigned long long *);
17499 void vec_xst (vector float, int, vector float *);
17500 void vec_xst (vector float, int, float *);
17501 void vec_xst (vector int, int, vector int *);
17502 void vec_xst (vector int, int, int *);
17503 void vec_xst (vector unsigned int, int, vector unsigned int *);
17504 void vec_xst (vector unsigned int, int, unsigned int *);
17505 int vec_all_eq (vector double, vector double);
17506 int vec_all_ge (vector double, vector double);
17507 int vec_all_gt (vector double, vector double);
17508 int vec_all_le (vector double, vector double);
17509 int vec_all_lt (vector double, vector double);
17510 int vec_all_nan (vector double);
17511 int vec_all_ne (vector double, vector double);
17512 int vec_all_nge (vector double, vector double);
17513 int vec_all_ngt (vector double, vector double);
17514 int vec_all_nle (vector double, vector double);
17515 int vec_all_nlt (vector double, vector double);
17516 int vec_all_numeric (vector double);
17517 int vec_any_eq (vector double, vector double);
17518 int vec_any_ge (vector double, vector double);
17519 int vec_any_gt (vector double, vector double);
17520 int vec_any_le (vector double, vector double);
17521 int vec_any_lt (vector double, vector double);
17522 int vec_any_nan (vector double);
17523 int vec_any_ne (vector double, vector double);
17524 int vec_any_nge (vector double, vector double);
17525 int vec_any_ngt (vector double, vector double);
17526 int vec_any_nle (vector double, vector double);
17527 int vec_any_nlt (vector double, vector double);
17528 int vec_any_numeric (vector double);
17530 vector double vec_vsx_ld (int, const vector double *);
17531 vector double vec_vsx_ld (int, const double *);
17532 vector float vec_vsx_ld (int, const vector float *);
17533 vector float vec_vsx_ld (int, const float *);
17534 vector bool int vec_vsx_ld (int, const vector bool int *);
17535 vector signed int vec_vsx_ld (int, const vector signed int *);
17536 vector signed int vec_vsx_ld (int, const int *);
17537 vector signed int vec_vsx_ld (int, const long *);
17538 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17539 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17540 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17541 vector bool short vec_vsx_ld (int, const vector bool short *);
17542 vector pixel vec_vsx_ld (int, const vector pixel *);
17543 vector signed short vec_vsx_ld (int, const vector signed short *);
17544 vector signed short vec_vsx_ld (int, const short *);
17545 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17546 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17547 vector bool char vec_vsx_ld (int, const vector bool char *);
17548 vector signed char vec_vsx_ld (int, const vector signed char *);
17549 vector signed char vec_vsx_ld (int, const signed char *);
17550 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17551 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17553 void vec_vsx_st (vector double, int, vector double *);
17554 void vec_vsx_st (vector double, int, double *);
17555 void vec_vsx_st (vector float, int, vector float *);
17556 void vec_vsx_st (vector float, int, float *);
17557 void vec_vsx_st (vector signed int, int, vector signed int *);
17558 void vec_vsx_st (vector signed int, int, int *);
17559 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17560 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17561 void vec_vsx_st (vector bool int, int, vector bool int *);
17562 void vec_vsx_st (vector bool int, int, unsigned int *);
17563 void vec_vsx_st (vector bool int, int, int *);
17564 void vec_vsx_st (vector signed short, int, vector signed short *);
17565 void vec_vsx_st (vector signed short, int, short *);
17566 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17567 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17568 void vec_vsx_st (vector bool short, int, vector bool short *);
17569 void vec_vsx_st (vector bool short, int, unsigned short *);
17570 void vec_vsx_st (vector pixel, int, vector pixel *);
17571 void vec_vsx_st (vector pixel, int, unsigned short *);
17572 void vec_vsx_st (vector pixel, int, short *);
17573 void vec_vsx_st (vector bool short, int, short *);
17574 void vec_vsx_st (vector signed char, int, vector signed char *);
17575 void vec_vsx_st (vector signed char, int, signed char *);
17576 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17577 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17578 void vec_vsx_st (vector bool char, int, vector bool char *);
17579 void vec_vsx_st (vector bool char, int, unsigned char *);
17580 void vec_vsx_st (vector bool char, int, signed char *);
17582 vector double vec_xxpermdi (vector double, vector double, int);
17583 vector float vec_xxpermdi (vector float, vector float, int);
17584 vector long long vec_xxpermdi (vector long long, vector long long, int);
17585 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17586                                         vector unsigned long long, int);
17587 vector int vec_xxpermdi (vector int, vector int, int);
17588 vector unsigned int vec_xxpermdi (vector unsigned int,
17589                                   vector unsigned int, int);
17590 vector short vec_xxpermdi (vector short, vector short, int);
17591 vector unsigned short vec_xxpermdi (vector unsigned short,
17592                                     vector unsigned short, int);
17593 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
17594 vector unsigned char vec_xxpermdi (vector unsigned char,
17595                                    vector unsigned char, int);
17597 vector double vec_xxsldi (vector double, vector double, int);
17598 vector float vec_xxsldi (vector float, vector float, int);
17599 vector long long vec_xxsldi (vector long long, vector long long, int);
17600 vector unsigned long long vec_xxsldi (vector unsigned long long,
17601                                       vector unsigned long long, int);
17602 vector int vec_xxsldi (vector int, vector int, int);
17603 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17604 vector short vec_xxsldi (vector short, vector short, int);
17605 vector unsigned short vec_xxsldi (vector unsigned short,
17606                                   vector unsigned short, int);
17607 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17608 vector unsigned char vec_xxsldi (vector unsigned char,
17609                                  vector unsigned char, int);
17610 @end smallexample
17612 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17613 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17614 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
17615 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17616 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17618 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17619 instruction set are available, the following additional functions are
17620 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
17621 can use @var{vector long} instead of @var{vector long long},
17622 @var{vector bool long} instead of @var{vector bool long long}, and
17623 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17625 @smallexample
17626 vector long long vec_abs (vector long long);
17628 vector long long vec_add (vector long long, vector long long);
17629 vector unsigned long long vec_add (vector unsigned long long,
17630                                    vector unsigned long long);
17632 int vec_all_eq (vector long long, vector long long);
17633 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17634 int vec_all_ge (vector long long, vector long long);
17635 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17636 int vec_all_gt (vector long long, vector long long);
17637 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17638 int vec_all_le (vector long long, vector long long);
17639 int vec_all_le (vector unsigned long long, vector unsigned long long);
17640 int vec_all_lt (vector long long, vector long long);
17641 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17642 int vec_all_ne (vector long long, vector long long);
17643 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17645 int vec_any_eq (vector long long, vector long long);
17646 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17647 int vec_any_ge (vector long long, vector long long);
17648 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17649 int vec_any_gt (vector long long, vector long long);
17650 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17651 int vec_any_le (vector long long, vector long long);
17652 int vec_any_le (vector unsigned long long, vector unsigned long long);
17653 int vec_any_lt (vector long long, vector long long);
17654 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17655 int vec_any_ne (vector long long, vector long long);
17656 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17658 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
17660 vector long long vec_eqv (vector long long, vector long long);
17661 vector long long vec_eqv (vector bool long long, vector long long);
17662 vector long long vec_eqv (vector long long, vector bool long long);
17663 vector unsigned long long vec_eqv (vector unsigned long long,
17664                                    vector unsigned long long);
17665 vector unsigned long long vec_eqv (vector bool long long,
17666                                    vector unsigned long long);
17667 vector unsigned long long vec_eqv (vector unsigned long long,
17668                                    vector bool long long);
17669 vector int vec_eqv (vector int, vector int);
17670 vector int vec_eqv (vector bool int, vector int);
17671 vector int vec_eqv (vector int, vector bool int);
17672 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17673 vector unsigned int vec_eqv (vector bool unsigned int,
17674                              vector unsigned int);
17675 vector unsigned int vec_eqv (vector unsigned int,
17676                              vector bool unsigned int);
17677 vector short vec_eqv (vector short, vector short);
17678 vector short vec_eqv (vector bool short, vector short);
17679 vector short vec_eqv (vector short, vector bool short);
17680 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17681 vector unsigned short vec_eqv (vector bool unsigned short,
17682                                vector unsigned short);
17683 vector unsigned short vec_eqv (vector unsigned short,
17684                                vector bool unsigned short);
17685 vector signed char vec_eqv (vector signed char, vector signed char);
17686 vector signed char vec_eqv (vector bool signed char, vector signed char);
17687 vector signed char vec_eqv (vector signed char, vector bool signed char);
17688 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17689 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17690 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17692 vector long long vec_max (vector long long, vector long long);
17693 vector unsigned long long vec_max (vector unsigned long long,
17694                                    vector unsigned long long);
17696 vector signed int vec_mergee (vector signed int, vector signed int);
17697 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17698 vector bool int vec_mergee (vector bool int, vector bool int);
17700 vector signed int vec_mergeo (vector signed int, vector signed int);
17701 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17702 vector bool int vec_mergeo (vector bool int, vector bool int);
17704 vector long long vec_min (vector long long, vector long long);
17705 vector unsigned long long vec_min (vector unsigned long long,
17706                                    vector unsigned long long);
17708 vector long long vec_nand (vector long long, vector long long);
17709 vector long long vec_nand (vector bool long long, vector long long);
17710 vector long long vec_nand (vector long long, vector bool long long);
17711 vector unsigned long long vec_nand (vector unsigned long long,
17712                                     vector unsigned long long);
17713 vector unsigned long long vec_nand (vector bool long long,
17714                                    vector unsigned long long);
17715 vector unsigned long long vec_nand (vector unsigned long long,
17716                                     vector bool long long);
17717 vector int vec_nand (vector int, vector int);
17718 vector int vec_nand (vector bool int, vector int);
17719 vector int vec_nand (vector int, vector bool int);
17720 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17721 vector unsigned int vec_nand (vector bool unsigned int,
17722                               vector unsigned int);
17723 vector unsigned int vec_nand (vector unsigned int,
17724                               vector bool unsigned int);
17725 vector short vec_nand (vector short, vector short);
17726 vector short vec_nand (vector bool short, vector short);
17727 vector short vec_nand (vector short, vector bool short);
17728 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17729 vector unsigned short vec_nand (vector bool unsigned short,
17730                                 vector unsigned short);
17731 vector unsigned short vec_nand (vector unsigned short,
17732                                 vector bool unsigned short);
17733 vector signed char vec_nand (vector signed char, vector signed char);
17734 vector signed char vec_nand (vector bool signed char, vector signed char);
17735 vector signed char vec_nand (vector signed char, vector bool signed char);
17736 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17737 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17738 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17740 vector long long vec_orc (vector long long, vector long long);
17741 vector long long vec_orc (vector bool long long, vector long long);
17742 vector long long vec_orc (vector long long, vector bool long long);
17743 vector unsigned long long vec_orc (vector unsigned long long,
17744                                    vector unsigned long long);
17745 vector unsigned long long vec_orc (vector bool long long,
17746                                    vector unsigned long long);
17747 vector unsigned long long vec_orc (vector unsigned long long,
17748                                    vector bool long long);
17749 vector int vec_orc (vector int, vector int);
17750 vector int vec_orc (vector bool int, vector int);
17751 vector int vec_orc (vector int, vector bool int);
17752 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17753 vector unsigned int vec_orc (vector bool unsigned int,
17754                              vector unsigned int);
17755 vector unsigned int vec_orc (vector unsigned int,
17756                              vector bool unsigned int);
17757 vector short vec_orc (vector short, vector short);
17758 vector short vec_orc (vector bool short, vector short);
17759 vector short vec_orc (vector short, vector bool short);
17760 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17761 vector unsigned short vec_orc (vector bool unsigned short,
17762                                vector unsigned short);
17763 vector unsigned short vec_orc (vector unsigned short,
17764                                vector bool unsigned short);
17765 vector signed char vec_orc (vector signed char, vector signed char);
17766 vector signed char vec_orc (vector bool signed char, vector signed char);
17767 vector signed char vec_orc (vector signed char, vector bool signed char);
17768 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17769 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17770 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17772 vector int vec_pack (vector long long, vector long long);
17773 vector unsigned int vec_pack (vector unsigned long long,
17774                               vector unsigned long long);
17775 vector bool int vec_pack (vector bool long long, vector bool long long);
17776 vector float vec_pack (vector double, vector double);
17778 vector int vec_packs (vector long long, vector long long);
17779 vector unsigned int vec_packs (vector unsigned long long,
17780                                vector unsigned long long);
17782 vector unsigned int vec_packsu (vector long long, vector long long);
17783 vector unsigned int vec_packsu (vector unsigned long long,
17784                                 vector unsigned long long);
17786 vector long long vec_rl (vector long long,
17787                          vector unsigned long long);
17788 vector long long vec_rl (vector unsigned long long,
17789                          vector unsigned long long);
17791 vector long long vec_sl (vector long long, vector unsigned long long);
17792 vector long long vec_sl (vector unsigned long long,
17793                          vector unsigned long long);
17795 vector long long vec_sr (vector long long, vector unsigned long long);
17796 vector unsigned long long char vec_sr (vector unsigned long long,
17797                                        vector unsigned long long);
17799 vector long long vec_sra (vector long long, vector unsigned long long);
17800 vector unsigned long long vec_sra (vector unsigned long long,
17801                                    vector unsigned long long);
17803 vector long long vec_sub (vector long long, vector long long);
17804 vector unsigned long long vec_sub (vector unsigned long long,
17805                                    vector unsigned long long);
17807 vector long long vec_unpackh (vector int);
17808 vector unsigned long long vec_unpackh (vector unsigned int);
17810 vector long long vec_unpackl (vector int);
17811 vector unsigned long long vec_unpackl (vector unsigned int);
17813 vector long long vec_vaddudm (vector long long, vector long long);
17814 vector long long vec_vaddudm (vector bool long long, vector long long);
17815 vector long long vec_vaddudm (vector long long, vector bool long long);
17816 vector unsigned long long vec_vaddudm (vector unsigned long long,
17817                                        vector unsigned long long);
17818 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17819                                        vector unsigned long long);
17820 vector unsigned long long vec_vaddudm (vector unsigned long long,
17821                                        vector bool unsigned long long);
17823 vector long long vec_vbpermq (vector signed char, vector signed char);
17824 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17826 vector long long vec_cntlz (vector long long);
17827 vector unsigned long long vec_cntlz (vector unsigned long long);
17828 vector int vec_cntlz (vector int);
17829 vector unsigned int vec_cntlz (vector int);
17830 vector short vec_cntlz (vector short);
17831 vector unsigned short vec_cntlz (vector unsigned short);
17832 vector signed char vec_cntlz (vector signed char);
17833 vector unsigned char vec_cntlz (vector unsigned char);
17835 vector long long vec_vclz (vector long long);
17836 vector unsigned long long vec_vclz (vector unsigned long long);
17837 vector int vec_vclz (vector int);
17838 vector unsigned int vec_vclz (vector int);
17839 vector short vec_vclz (vector short);
17840 vector unsigned short vec_vclz (vector unsigned short);
17841 vector signed char vec_vclz (vector signed char);
17842 vector unsigned char vec_vclz (vector unsigned char);
17844 vector signed char vec_vclzb (vector signed char);
17845 vector unsigned char vec_vclzb (vector unsigned char);
17847 vector long long vec_vclzd (vector long long);
17848 vector unsigned long long vec_vclzd (vector unsigned long long);
17850 vector short vec_vclzh (vector short);
17851 vector unsigned short vec_vclzh (vector unsigned short);
17853 vector int vec_vclzw (vector int);
17854 vector unsigned int vec_vclzw (vector int);
17856 vector signed char vec_vgbbd (vector signed char);
17857 vector unsigned char vec_vgbbd (vector unsigned char);
17859 vector long long vec_vmaxsd (vector long long, vector long long);
17861 vector unsigned long long vec_vmaxud (vector unsigned long long,
17862                                       unsigned vector long long);
17864 vector long long vec_vminsd (vector long long, vector long long);
17866 vector unsigned long long vec_vminud (vector long long,
17867                                       vector long long);
17869 vector int vec_vpksdss (vector long long, vector long long);
17870 vector unsigned int vec_vpksdss (vector long long, vector long long);
17872 vector unsigned int vec_vpkudus (vector unsigned long long,
17873                                  vector unsigned long long);
17875 vector int vec_vpkudum (vector long long, vector long long);
17876 vector unsigned int vec_vpkudum (vector unsigned long long,
17877                                  vector unsigned long long);
17878 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17880 vector long long vec_vpopcnt (vector long long);
17881 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17882 vector int vec_vpopcnt (vector int);
17883 vector unsigned int vec_vpopcnt (vector int);
17884 vector short vec_vpopcnt (vector short);
17885 vector unsigned short vec_vpopcnt (vector unsigned short);
17886 vector signed char vec_vpopcnt (vector signed char);
17887 vector unsigned char vec_vpopcnt (vector unsigned char);
17889 vector signed char vec_vpopcntb (vector signed char);
17890 vector unsigned char vec_vpopcntb (vector unsigned char);
17892 vector long long vec_vpopcntd (vector long long);
17893 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17895 vector short vec_vpopcnth (vector short);
17896 vector unsigned short vec_vpopcnth (vector unsigned short);
17898 vector int vec_vpopcntw (vector int);
17899 vector unsigned int vec_vpopcntw (vector int);
17901 vector long long vec_vrld (vector long long, vector unsigned long long);
17902 vector unsigned long long vec_vrld (vector unsigned long long,
17903                                     vector unsigned long long);
17905 vector long long vec_vsld (vector long long, vector unsigned long long);
17906 vector long long vec_vsld (vector unsigned long long,
17907                            vector unsigned long long);
17909 vector long long vec_vsrad (vector long long, vector unsigned long long);
17910 vector unsigned long long vec_vsrad (vector unsigned long long,
17911                                      vector unsigned long long);
17913 vector long long vec_vsrd (vector long long, vector unsigned long long);
17914 vector unsigned long long char vec_vsrd (vector unsigned long long,
17915                                          vector unsigned long long);
17917 vector long long vec_vsubudm (vector long long, vector long long);
17918 vector long long vec_vsubudm (vector bool long long, vector long long);
17919 vector long long vec_vsubudm (vector long long, vector bool long long);
17920 vector unsigned long long vec_vsubudm (vector unsigned long long,
17921                                        vector unsigned long long);
17922 vector unsigned long long vec_vsubudm (vector bool long long,
17923                                        vector unsigned long long);
17924 vector unsigned long long vec_vsubudm (vector unsigned long long,
17925                                        vector bool long long);
17927 vector long long vec_vupkhsw (vector int);
17928 vector unsigned long long vec_vupkhsw (vector unsigned int);
17930 vector long long vec_vupklsw (vector int);
17931 vector unsigned long long vec_vupklsw (vector int);
17932 @end smallexample
17934 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17935 instruction set are available, the following additional functions are
17936 available for 64-bit targets.  New vector types
17937 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17938 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17939 builtins.
17941 The normal vector extract, and set operations work on
17942 @var{vector __int128_t} and @var{vector __uint128_t} types,
17943 but the index value must be 0.
17945 @smallexample
17946 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17947 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17949 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17950 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17952 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17953                                 vector __int128_t);
17954 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17955                                  vector __uint128_t);
17957 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17958                                 vector __int128_t);
17959 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17960                                  vector __uint128_t);
17962 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17963                                 vector __int128_t);
17964 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17965                                  vector __uint128_t);
17967 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
17968                                 vector __int128_t);
17969 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
17970                                  vector __uint128_t);
17972 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
17973 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
17975 __int128_t vec_vsubuqm (__int128_t, __int128_t);
17976 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
17978 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
17979 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
17980 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
17981 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
17982 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
17983 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
17984 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
17985 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
17986 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
17987 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
17988 @end smallexample
17990 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
17991 are available:
17993 @smallexample
17994 vector bool char vec_cmpne (vector bool char, vector bool char);
17995 vector bool short vec_cmpne (vector bool short, vector bool short);
17996 vector bool int vec_cmpne (vector bool int, vector bool int);
17997 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
17999 vector long long vec_vctz (vector long long);
18000 vector unsigned long long vec_vctz (vector unsigned long long);
18001 vector int vec_vctz (vector int);
18002 vector unsigned int vec_vctz (vector int);
18003 vector short vec_vctz (vector short);
18004 vector unsigned short vec_vctz (vector unsigned short);
18005 vector signed char vec_vctz (vector signed char);
18006 vector unsigned char vec_vctz (vector unsigned char);
18008 vector signed char vec_vctzb (vector signed char);
18009 vector unsigned char vec_vctzb (vector unsigned char);
18011 vector long long vec_vctzd (vector long long);
18012 vector unsigned long long vec_vctzd (vector unsigned long long);
18014 vector short vec_vctzh (vector short);
18015 vector unsigned short vec_vctzh (vector unsigned short);
18017 vector int vec_vctzw (vector int);
18018 vector unsigned int vec_vctzw (vector int);
18020 long long vec_vextract4b (const vector signed char, const int);
18021 long long vec_vextract4b (const vector unsigned char, const int);
18023 vector signed char vec_insert4b (vector int, vector signed char, const int);
18024 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
18025                                    const int);
18026 vector signed char vec_insert4b (long long, vector signed char, const int);
18027 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
18029 vector int vec_vprtyb (vector int);
18030 vector unsigned int vec_vprtyb (vector unsigned int);
18031 vector long long vec_vprtyb (vector long long);
18032 vector unsigned long long vec_vprtyb (vector unsigned long long);
18034 vector int vec_vprtybw (vector int);
18035 vector unsigned int vec_vprtybw (vector unsigned int);
18037 vector long long vec_vprtybd (vector long long);
18038 vector unsigned long long vec_vprtybd (vector unsigned long long);
18039 @end smallexample
18041 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
18042 are available:
18044 @smallexample
18045 vector long vec_vprtyb (vector long);
18046 vector unsigned long vec_vprtyb (vector unsigned long);
18047 vector __int128_t vec_vprtyb (vector __int128_t);
18048 vector __uint128_t vec_vprtyb (vector __uint128_t);
18050 vector long vec_vprtybd (vector long);
18051 vector unsigned long vec_vprtybd (vector unsigned long);
18053 vector __int128_t vec_vprtybq (vector __int128_t);
18054 vector __uint128_t vec_vprtybd (vector __uint128_t);
18055 @end smallexample
18057 The following built-in vector functions are available for the PowerPC family
18058 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18059 @smallexample
18060 __vector unsigned char
18061 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
18062 __vector unsigned char
18063 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
18064 @end smallexample
18066 The @code{vec_slv} and @code{vec_srv} functions operate on
18067 all of the bytes of their @code{src} and @code{shift_distance}
18068 arguments in parallel.  The behavior of the @code{vec_slv} is as if
18069 there existed a temporary array of 17 unsigned characters
18070 @code{slv_array} within which elements 0 through 15 are the same as
18071 the entries in the @code{src} array and element 16 equals 0.  The
18072 result returned from the @code{vec_slv} function is a
18073 @code{__vector} of 16 unsigned characters within which element
18074 @code{i} is computed using the C expression
18075 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
18076 shift_distance[i]))},
18077 with this resulting value coerced to the @code{unsigned char} type.
18078 The behavior of the @code{vec_srv} is as if
18079 there existed a temporary array of 17 unsigned characters
18080 @code{srv_array} within which element 0 equals zero and
18081 elements 1 through 16 equal the elements 0 through 15 of
18082 the @code{src} array.  The
18083 result returned from the @code{vec_srv} function is a
18084 @code{__vector} of 16 unsigned characters within which element
18085 @code{i} is computed using the C expression
18086 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
18087 (0x07 & shift_distance[i]))},
18088 with this resulting value coerced to the @code{unsigned char} type.
18090 The following built-in functions are available for the PowerPC family
18091 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18092 @smallexample
18093 __vector unsigned char
18094 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
18095 __vector unsigned short
18096 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
18097 __vector unsigned int
18098 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
18100 __vector unsigned char
18101 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
18102 __vector unsigned short
18103 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
18104 __vector unsigned int
18105 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
18106 @end smallexample
18108 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
18109 @code{vec_absdw} built-in functions each computes the absolute
18110 differences of the pairs of vector elements supplied in its two vector
18111 arguments, placing the absolute differences into the corresponding
18112 elements of the vector result.
18114 The following built-in functions are available for the PowerPC family
18115 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
18116 @smallexample
18117 __vector int
18118 vec_extract_exp (__vector float source);
18119 __vector long long int
18120 vec_extract_exp (__vector double source);
18122 __vector int
18123 vec_extract_sig (__vector float source);
18124 __vector long long int
18125 vec_extract_sig (__vector double source);
18127 __vector float
18128 vec_insert_exp (__vector unsigned int significands,  __vector unsigned int exponents);
18129 __vector double
18130 vec_insert_exp (__vector unsigned long long int significands,
18131                 __vector unsigned long long int exponents);
18133 __vector int vec_test_data_class (__vector float source, unsigned int condition);
18134 __vector long long int vec_test_data_class (__vector double source, unsigned int condition);
18135 @end smallexample
18137 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
18138 functions return vectors representing the significands and exponents
18139 of their @code{source} arguments respectively.  The
18140 @code{vec_insert_exp} built-in functions return a vector of single- or
18141 double-precision floating
18142 point values constructed by assembling the values of their
18143 @code{significands} and @code{exponents} arguments into the
18144 corresponding elements of the returned vector.  The sign of each
18145 element of the result is copied from the most significant bit of the
18146 corresponding entry within the @code{significands} argument.  The
18147 significand and exponent components of each element of the result are
18148 composed of the least significant bits of the corresponding
18149 @code{significands} element and the least significant bits of the
18150 corresponding @code{exponents} element.
18152 The @code{vec_test_data_class} built-in function returns a vector
18153 representing the results of testing the @code{source} vector for the
18154 condition selected by the @code{condition} argument.  The
18155 @code{condition} argument must be an unsigned integer with value not
18156 exceeding 127.  The
18157 @code{condition} argument is encoded as a bitmask with each bit
18158 enabling the testing of a different condition, as characterized by the
18159 following:
18160 @smallexample
18161 0x40    Test for NaN
18162 0x20    Test for +Infinity
18163 0x10    Test for -Infinity
18164 0x08    Test for +Zero
18165 0x04    Test for -Zero
18166 0x02    Test for +Denormal
18167 0x01    Test for -Denormal
18168 @end smallexample
18170 If any of the enabled test conditions is true, the corresponding entry
18171 in the result vector is -1.  Otherwise (all of the enabled test
18172 conditions are false), the corresponding entry of the result vector is 0.
18174 If the cryptographic instructions are enabled (@option{-mcrypto} or
18175 @option{-mcpu=power8}), the following builtins are enabled.
18177 @smallexample
18178 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
18180 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
18181                                                     vector unsigned long long);
18183 vector unsigned long long __builtin_crypto_vcipherlast
18184                                      (vector unsigned long long,
18185                                       vector unsigned long long);
18187 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
18188                                                      vector unsigned long long);
18190 vector unsigned long long __builtin_crypto_vncipherlast
18191                                      (vector unsigned long long,
18192                                       vector unsigned long long);
18194 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
18195                                                 vector unsigned char,
18196                                                 vector unsigned char);
18198 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
18199                                                  vector unsigned short,
18200                                                  vector unsigned short);
18202 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
18203                                                vector unsigned int,
18204                                                vector unsigned int);
18206 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
18207                                                      vector unsigned long long,
18208                                                      vector unsigned long long);
18210 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
18211                                                vector unsigned char);
18213 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
18214                                                 vector unsigned short);
18216 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
18217                                               vector unsigned int);
18219 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
18220                                                     vector unsigned long long);
18222 vector unsigned long long __builtin_crypto_vshasigmad
18223                                (vector unsigned long long, int, int);
18225 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
18226                                                  int, int);
18227 @end smallexample
18229 The second argument to the @var{__builtin_crypto_vshasigmad} and
18230 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
18231 integer that is 0 or 1.  The third argument to these builtin functions
18232 must be a constant integer in the range of 0 to 15.
18234 If the ISA 3.0 instruction set additions 
18235 are enabled (@option{-mcpu=power9}), the following additional
18236 functions are available for both 32-bit and 64-bit targets.
18238 vector short vec_xl (int, vector short *);
18239 vector short vec_xl (int, short *);
18240 vector unsigned short vec_xl (int, vector unsigned short *);
18241 vector unsigned short vec_xl (int, unsigned short *);
18242 vector char vec_xl (int, vector char *);
18243 vector char vec_xl (int, char *);
18244 vector unsigned char vec_xl (int, vector unsigned char *);
18245 vector unsigned char vec_xl (int, unsigned char *);
18247 void vec_xst (vector short, int, vector short *);
18248 void vec_xst (vector short, int, short *);
18249 void vec_xst (vector unsigned short, int, vector unsigned short *);
18250 void vec_xst (vector unsigned short, int, unsigned short *);
18251 void vec_xst (vector char, int, vector char *);
18252 void vec_xst (vector char, int, char *);
18253 void vec_xst (vector unsigned char, int, vector unsigned char *);
18254 void vec_xst (vector unsigned char, int, unsigned char *);
18256 @node PowerPC Hardware Transactional Memory Built-in Functions
18257 @subsection PowerPC Hardware Transactional Memory Built-in Functions
18258 GCC provides two interfaces for accessing the Hardware Transactional
18259 Memory (HTM) instructions available on some of the PowerPC family
18260 of processors (eg, POWER8).  The two interfaces come in a low level
18261 interface, consisting of built-in functions specific to PowerPC and a
18262 higher level interface consisting of inline functions that are common
18263 between PowerPC and S/390.
18265 @subsubsection PowerPC HTM Low Level Built-in Functions
18267 The following low level built-in functions are available with
18268 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
18269 They all generate the machine instruction that is part of the name.
18271 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
18272 the full 4-bit condition register value set by their associated hardware
18273 instruction.  The header file @code{htmintrin.h} defines some macros that can
18274 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
18275 returns a simple true or false value depending on whether a transaction was
18276 successfully started or not.  The arguments of the builtins match exactly the
18277 type and order of the associated hardware instruction's operands, except for
18278 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18279 Refer to the ISA manual for a description of each instruction's operands.
18281 @smallexample
18282 unsigned int __builtin_tbegin (unsigned int)
18283 unsigned int __builtin_tend (unsigned int)
18285 unsigned int __builtin_tabort (unsigned int)
18286 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18287 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18288 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18289 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18291 unsigned int __builtin_tcheck (void)
18292 unsigned int __builtin_treclaim (unsigned int)
18293 unsigned int __builtin_trechkpt (void)
18294 unsigned int __builtin_tsr (unsigned int)
18295 @end smallexample
18297 In addition to the above HTM built-ins, we have added built-ins for
18298 some common extended mnemonics of the HTM instructions:
18300 @smallexample
18301 unsigned int __builtin_tendall (void)
18302 unsigned int __builtin_tresume (void)
18303 unsigned int __builtin_tsuspend (void)
18304 @end smallexample
18306 Note that the semantics of the above HTM builtins are required to mimic
18307 the locking semantics used for critical sections.  Builtins that are used
18308 to create a new transaction or restart a suspended transaction must have
18309 lock acquisition like semantics while those builtins that end or suspend a
18310 transaction must have lock release like semantics.  Specifically, this must
18311 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18312 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18313 that returns 0, and lock release is as-if an execution of
18314 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18315 implicit implementation-defined lock used for all transactions.  The HTM
18316 instructions associated with with the builtins inherently provide the
18317 correct acquisition and release hardware barriers required.  However,
18318 the compiler must also be prohibited from moving loads and stores across
18319 the builtins in a way that would violate their semantics.  This has been
18320 accomplished by adding memory barriers to the associated HTM instructions
18321 (which is a conservative approach to provide acquire and release semantics).
18322 Earlier versions of the compiler did not treat the HTM instructions as
18323 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
18324 be used to determine whether the current compiler treats HTM instructions
18325 as memory barriers or not.  This allows the user to explicitly add memory
18326 barriers to their code when using an older version of the compiler.
18328 The following set of built-in functions are available to gain access
18329 to the HTM specific special purpose registers.
18331 @smallexample
18332 unsigned long __builtin_get_texasr (void)
18333 unsigned long __builtin_get_texasru (void)
18334 unsigned long __builtin_get_tfhar (void)
18335 unsigned long __builtin_get_tfiar (void)
18337 void __builtin_set_texasr (unsigned long);
18338 void __builtin_set_texasru (unsigned long);
18339 void __builtin_set_tfhar (unsigned long);
18340 void __builtin_set_tfiar (unsigned long);
18341 @end smallexample
18343 Example usage of these low level built-in functions may look like:
18345 @smallexample
18346 #include <htmintrin.h>
18348 int num_retries = 10;
18350 while (1)
18351   @{
18352     if (__builtin_tbegin (0))
18353       @{
18354         /* Transaction State Initiated.  */
18355         if (is_locked (lock))
18356           __builtin_tabort (0);
18357         ... transaction code...
18358         __builtin_tend (0);
18359         break;
18360       @}
18361     else
18362       @{
18363         /* Transaction State Failed.  Use locks if the transaction
18364            failure is "persistent" or we've tried too many times.  */
18365         if (num_retries-- <= 0
18366             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18367           @{
18368             acquire_lock (lock);
18369             ... non transactional fallback path...
18370             release_lock (lock);
18371             break;
18372           @}
18373       @}
18374   @}
18375 @end smallexample
18377 One final built-in function has been added that returns the value of
18378 the 2-bit Transaction State field of the Machine Status Register (MSR)
18379 as stored in @code{CR0}.
18381 @smallexample
18382 unsigned long __builtin_ttest (void)
18383 @end smallexample
18385 This built-in can be used to determine the current transaction state
18386 using the following code example:
18388 @smallexample
18389 #include <htmintrin.h>
18391 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18393 if (tx_state == _HTM_TRANSACTIONAL)
18394   @{
18395     /* Code to use in transactional state.  */
18396   @}
18397 else if (tx_state == _HTM_NONTRANSACTIONAL)
18398   @{
18399     /* Code to use in non-transactional state.  */
18400   @}
18401 else if (tx_state == _HTM_SUSPENDED)
18402   @{
18403     /* Code to use in transaction suspended state.  */
18404   @}
18405 @end smallexample
18407 @subsubsection PowerPC HTM High Level Inline Functions
18409 The following high level HTM interface is made available by including
18410 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18411 where CPU is `power8' or later.  This interface is common between PowerPC
18412 and S/390, allowing users to write one HTM source implementation that
18413 can be compiled and executed on either system.
18415 @smallexample
18416 long __TM_simple_begin (void)
18417 long __TM_begin (void* const TM_buff)
18418 long __TM_end (void)
18419 void __TM_abort (void)
18420 void __TM_named_abort (unsigned char const code)
18421 void __TM_resume (void)
18422 void __TM_suspend (void)
18424 long __TM_is_user_abort (void* const TM_buff)
18425 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18426 long __TM_is_illegal (void* const TM_buff)
18427 long __TM_is_footprint_exceeded (void* const TM_buff)
18428 long __TM_nesting_depth (void* const TM_buff)
18429 long __TM_is_nested_too_deep(void* const TM_buff)
18430 long __TM_is_conflict(void* const TM_buff)
18431 long __TM_is_failure_persistent(void* const TM_buff)
18432 long __TM_failure_address(void* const TM_buff)
18433 long long __TM_failure_code(void* const TM_buff)
18434 @end smallexample
18436 Using these common set of HTM inline functions, we can create
18437 a more portable version of the HTM example in the previous
18438 section that will work on either PowerPC or S/390:
18440 @smallexample
18441 #include <htmxlintrin.h>
18443 int num_retries = 10;
18444 TM_buff_type TM_buff;
18446 while (1)
18447   @{
18448     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18449       @{
18450         /* Transaction State Initiated.  */
18451         if (is_locked (lock))
18452           __TM_abort ();
18453         ... transaction code...
18454         __TM_end ();
18455         break;
18456       @}
18457     else
18458       @{
18459         /* Transaction State Failed.  Use locks if the transaction
18460            failure is "persistent" or we've tried too many times.  */
18461         if (num_retries-- <= 0
18462             || __TM_is_failure_persistent (TM_buff))
18463           @{
18464             acquire_lock (lock);
18465             ... non transactional fallback path...
18466             release_lock (lock);
18467             break;
18468           @}
18469       @}
18470   @}
18471 @end smallexample
18473 @node RX Built-in Functions
18474 @subsection RX Built-in Functions
18475 GCC supports some of the RX instructions which cannot be expressed in
18476 the C programming language via the use of built-in functions.  The
18477 following functions are supported:
18479 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
18480 Generates the @code{brk} machine instruction.
18481 @end deftypefn
18483 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
18484 Generates the @code{clrpsw} machine instruction to clear the specified
18485 bit in the processor status word.
18486 @end deftypefn
18488 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
18489 Generates the @code{int} machine instruction to generate an interrupt
18490 with the specified value.
18491 @end deftypefn
18493 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
18494 Generates the @code{machi} machine instruction to add the result of
18495 multiplying the top 16 bits of the two arguments into the
18496 accumulator.
18497 @end deftypefn
18499 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
18500 Generates the @code{maclo} machine instruction to add the result of
18501 multiplying the bottom 16 bits of the two arguments into the
18502 accumulator.
18503 @end deftypefn
18505 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
18506 Generates the @code{mulhi} machine instruction to place the result of
18507 multiplying the top 16 bits of the two arguments into the
18508 accumulator.
18509 @end deftypefn
18511 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
18512 Generates the @code{mullo} machine instruction to place the result of
18513 multiplying the bottom 16 bits of the two arguments into the
18514 accumulator.
18515 @end deftypefn
18517 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
18518 Generates the @code{mvfachi} machine instruction to read the top
18519 32 bits of the accumulator.
18520 @end deftypefn
18522 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
18523 Generates the @code{mvfacmi} machine instruction to read the middle
18524 32 bits of the accumulator.
18525 @end deftypefn
18527 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
18528 Generates the @code{mvfc} machine instruction which reads the control
18529 register specified in its argument and returns its value.
18530 @end deftypefn
18532 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
18533 Generates the @code{mvtachi} machine instruction to set the top
18534 32 bits of the accumulator.
18535 @end deftypefn
18537 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
18538 Generates the @code{mvtaclo} machine instruction to set the bottom
18539 32 bits of the accumulator.
18540 @end deftypefn
18542 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
18543 Generates the @code{mvtc} machine instruction which sets control
18544 register number @code{reg} to @code{val}.
18545 @end deftypefn
18547 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
18548 Generates the @code{mvtipl} machine instruction set the interrupt
18549 priority level.
18550 @end deftypefn
18552 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
18553 Generates the @code{racw} machine instruction to round the accumulator
18554 according to the specified mode.
18555 @end deftypefn
18557 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
18558 Generates the @code{revw} machine instruction which swaps the bytes in
18559 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18560 and also bits 16--23 occupy bits 24--31 and vice versa.
18561 @end deftypefn
18563 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
18564 Generates the @code{rmpa} machine instruction which initiates a
18565 repeated multiply and accumulate sequence.
18566 @end deftypefn
18568 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
18569 Generates the @code{round} machine instruction which returns the
18570 floating-point argument rounded according to the current rounding mode
18571 set in the floating-point status word register.
18572 @end deftypefn
18574 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
18575 Generates the @code{sat} machine instruction which returns the
18576 saturated value of the argument.
18577 @end deftypefn
18579 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
18580 Generates the @code{setpsw} machine instruction to set the specified
18581 bit in the processor status word.
18582 @end deftypefn
18584 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
18585 Generates the @code{wait} machine instruction.
18586 @end deftypefn
18588 @node S/390 System z Built-in Functions
18589 @subsection S/390 System z Built-in Functions
18590 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18591 Generates the @code{tbegin} machine instruction starting a
18592 non-constrained hardware transaction.  If the parameter is non-NULL the
18593 memory area is used to store the transaction diagnostic buffer and
18594 will be passed as first operand to @code{tbegin}.  This buffer can be
18595 defined using the @code{struct __htm_tdb} C struct defined in
18596 @code{htmintrin.h} and must reside on a double-word boundary.  The
18597 second tbegin operand is set to @code{0xff0c}. This enables
18598 save/restore of all GPRs and disables aborts for FPR and AR
18599 manipulations inside the transaction body.  The condition code set by
18600 the tbegin instruction is returned as integer value.  The tbegin
18601 instruction by definition overwrites the content of all FPRs.  The
18602 compiler will generate code which saves and restores the FPRs.  For
18603 soft-float code it is recommended to used the @code{*_nofloat}
18604 variant.  In order to prevent a TDB from being written it is required
18605 to pass a constant zero value as parameter.  Passing a zero value
18606 through a variable is not sufficient.  Although modifications of
18607 access registers inside the transaction will not trigger an
18608 transaction abort it is not supported to actually modify them.  Access
18609 registers do not get saved when entering a transaction. They will have
18610 undefined state when reaching the abort code.
18611 @end deftypefn
18613 Macros for the possible return codes of tbegin are defined in the
18614 @code{htmintrin.h} header file:
18616 @table @code
18617 @item _HTM_TBEGIN_STARTED
18618 @code{tbegin} has been executed as part of normal processing.  The
18619 transaction body is supposed to be executed.
18620 @item _HTM_TBEGIN_INDETERMINATE
18621 The transaction was aborted due to an indeterminate condition which
18622 might be persistent.
18623 @item _HTM_TBEGIN_TRANSIENT
18624 The transaction aborted due to a transient failure.  The transaction
18625 should be re-executed in that case.
18626 @item _HTM_TBEGIN_PERSISTENT
18627 The transaction aborted due to a persistent failure.  Re-execution
18628 under same circumstances will not be productive.
18629 @end table
18631 @defmac _HTM_FIRST_USER_ABORT_CODE
18632 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18633 specifies the first abort code which can be used for
18634 @code{__builtin_tabort}.  Values below this threshold are reserved for
18635 machine use.
18636 @end defmac
18638 @deftp {Data type} {struct __htm_tdb}
18639 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18640 the structure of the transaction diagnostic block as specified in the
18641 Principles of Operation manual chapter 5-91.
18642 @end deftp
18644 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18645 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18646 Using this variant in code making use of FPRs will leave the FPRs in
18647 undefined state when entering the transaction abort handler code.
18648 @end deftypefn
18650 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18651 In addition to @code{__builtin_tbegin} a loop for transient failures
18652 is generated.  If tbegin returns a condition code of 2 the transaction
18653 will be retried as often as specified in the second argument.  The
18654 perform processor assist instruction is used to tell the CPU about the
18655 number of fails so far.
18656 @end deftypefn
18658 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18659 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18660 restores.  Using this variant in code making use of FPRs will leave
18661 the FPRs in undefined state when entering the transaction abort
18662 handler code.
18663 @end deftypefn
18665 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18666 Generates the @code{tbeginc} machine instruction starting a constrained
18667 hardware transaction.  The second operand is set to @code{0xff08}.
18668 @end deftypefn
18670 @deftypefn {Built-in Function} int __builtin_tend (void)
18671 Generates the @code{tend} machine instruction finishing a transaction
18672 and making the changes visible to other threads.  The condition code
18673 generated by tend is returned as integer value.
18674 @end deftypefn
18676 @deftypefn {Built-in Function} void __builtin_tabort (int)
18677 Generates the @code{tabort} machine instruction with the specified
18678 abort code.  Abort codes from 0 through 255 are reserved and will
18679 result in an error message.
18680 @end deftypefn
18682 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18683 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
18684 integer parameter is loaded into rX and a value of zero is loaded into
18685 rY.  The integer parameter specifies the number of times the
18686 transaction repeatedly aborted.
18687 @end deftypefn
18689 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18690 Generates the @code{etnd} machine instruction.  The current nesting
18691 depth is returned as integer value.  For a nesting depth of 0 the code
18692 is not executed as part of an transaction.
18693 @end deftypefn
18695 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18697 Generates the @code{ntstg} machine instruction.  The second argument
18698 is written to the first arguments location.  The store operation will
18699 not be rolled-back in case of an transaction abort.
18700 @end deftypefn
18702 @node SH Built-in Functions
18703 @subsection SH Built-in Functions
18704 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18705 families of processors:
18707 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18708 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
18709 used by system code that manages threads and execution contexts.  The compiler
18710 normally does not generate code that modifies the contents of @samp{GBR} and
18711 thus the value is preserved across function calls.  Changing the @samp{GBR}
18712 value in user code must be done with caution, since the compiler might use
18713 @samp{GBR} in order to access thread local variables.
18715 @end deftypefn
18717 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18718 Returns the value that is currently set in the @samp{GBR} register.
18719 Memory loads and stores that use the thread pointer as a base address are
18720 turned into @samp{GBR} based displacement loads and stores, if possible.
18721 For example:
18722 @smallexample
18723 struct my_tcb
18725    int a, b, c, d, e;
18728 int get_tcb_value (void)
18730   // Generate @samp{mov.l @@(8,gbr),r0} instruction
18731   return ((my_tcb*)__builtin_thread_pointer ())->c;
18734 @end smallexample
18735 @end deftypefn
18737 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18738 Returns the value that is currently set in the @samp{FPSCR} register.
18739 @end deftypefn
18741 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18742 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18743 preserving the current values of the FR, SZ and PR bits.
18744 @end deftypefn
18746 @node SPARC VIS Built-in Functions
18747 @subsection SPARC VIS Built-in Functions
18749 GCC supports SIMD operations on the SPARC using both the generic vector
18750 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18751 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
18752 switch, the VIS extension is exposed as the following built-in functions:
18754 @smallexample
18755 typedef int v1si __attribute__ ((vector_size (4)));
18756 typedef int v2si __attribute__ ((vector_size (8)));
18757 typedef short v4hi __attribute__ ((vector_size (8)));
18758 typedef short v2hi __attribute__ ((vector_size (4)));
18759 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18760 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18762 void __builtin_vis_write_gsr (int64_t);
18763 int64_t __builtin_vis_read_gsr (void);
18765 void * __builtin_vis_alignaddr (void *, long);
18766 void * __builtin_vis_alignaddrl (void *, long);
18767 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18768 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18769 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18770 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18772 v4hi __builtin_vis_fexpand (v4qi);
18774 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18775 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18776 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18777 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18778 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18779 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18780 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18782 v4qi __builtin_vis_fpack16 (v4hi);
18783 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18784 v2hi __builtin_vis_fpackfix (v2si);
18785 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18787 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18789 long __builtin_vis_edge8 (void *, void *);
18790 long __builtin_vis_edge8l (void *, void *);
18791 long __builtin_vis_edge16 (void *, void *);
18792 long __builtin_vis_edge16l (void *, void *);
18793 long __builtin_vis_edge32 (void *, void *);
18794 long __builtin_vis_edge32l (void *, void *);
18796 long __builtin_vis_fcmple16 (v4hi, v4hi);
18797 long __builtin_vis_fcmple32 (v2si, v2si);
18798 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18799 long __builtin_vis_fcmpne32 (v2si, v2si);
18800 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18801 long __builtin_vis_fcmpgt32 (v2si, v2si);
18802 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18803 long __builtin_vis_fcmpeq32 (v2si, v2si);
18805 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18806 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18807 v2si __builtin_vis_fpadd32 (v2si, v2si);
18808 v1si __builtin_vis_fpadd32s (v1si, v1si);
18809 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18810 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18811 v2si __builtin_vis_fpsub32 (v2si, v2si);
18812 v1si __builtin_vis_fpsub32s (v1si, v1si);
18814 long __builtin_vis_array8 (long, long);
18815 long __builtin_vis_array16 (long, long);
18816 long __builtin_vis_array32 (long, long);
18817 @end smallexample
18819 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18820 functions also become available:
18822 @smallexample
18823 long __builtin_vis_bmask (long, long);
18824 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18825 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18826 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18827 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18829 long __builtin_vis_edge8n (void *, void *);
18830 long __builtin_vis_edge8ln (void *, void *);
18831 long __builtin_vis_edge16n (void *, void *);
18832 long __builtin_vis_edge16ln (void *, void *);
18833 long __builtin_vis_edge32n (void *, void *);
18834 long __builtin_vis_edge32ln (void *, void *);
18835 @end smallexample
18837 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18838 functions also become available:
18840 @smallexample
18841 void __builtin_vis_cmask8 (long);
18842 void __builtin_vis_cmask16 (long);
18843 void __builtin_vis_cmask32 (long);
18845 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18847 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18848 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18849 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18850 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18851 v2si __builtin_vis_fsll16 (v2si, v2si);
18852 v2si __builtin_vis_fslas16 (v2si, v2si);
18853 v2si __builtin_vis_fsrl16 (v2si, v2si);
18854 v2si __builtin_vis_fsra16 (v2si, v2si);
18856 long __builtin_vis_pdistn (v8qi, v8qi);
18858 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18860 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18861 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18863 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18864 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18865 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18866 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18867 v2si __builtin_vis_fpadds32 (v2si, v2si);
18868 v1si __builtin_vis_fpadds32s (v1si, v1si);
18869 v2si __builtin_vis_fpsubs32 (v2si, v2si);
18870 v1si __builtin_vis_fpsubs32s (v1si, v1si);
18872 long __builtin_vis_fucmple8 (v8qi, v8qi);
18873 long __builtin_vis_fucmpne8 (v8qi, v8qi);
18874 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
18875 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
18877 float __builtin_vis_fhadds (float, float);
18878 double __builtin_vis_fhaddd (double, double);
18879 float __builtin_vis_fhsubs (float, float);
18880 double __builtin_vis_fhsubd (double, double);
18881 float __builtin_vis_fnhadds (float, float);
18882 double __builtin_vis_fnhaddd (double, double);
18884 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
18885 int64_t __builtin_vis_xmulx (int64_t, int64_t);
18886 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
18887 @end smallexample
18889 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
18890 functions also become available:
18892 @smallexample
18893 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
18894 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
18895 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
18896 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
18898 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
18899 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
18900 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
18901 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
18903 long __builtin_vis_fpcmple8 (v8qi, v8qi);
18904 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
18905 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
18906 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
18907 long __builtin_vis_fpcmpule32 (v2si, v2si);
18908 long __builtin_vis_fpcmpugt32 (v2si, v2si);
18910 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
18911 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
18912 v2si __builtin_vis_fpmax32 (v2si, v2si);
18914 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
18915 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
18916 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
18919 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
18920 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
18921 v2si __builtin_vis_fpmin32 (v2si, v2si);
18923 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
18924 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
18925 v2si __builtin_vis_fpminu32 (v2si, v2si);
18926 @end smallexample
18928 @node SPU Built-in Functions
18929 @subsection SPU Built-in Functions
18931 GCC provides extensions for the SPU processor as described in the
18932 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
18933 implementation differs in several ways.
18935 @itemize @bullet
18937 @item
18938 The optional extension of specifying vector constants in parentheses is
18939 not supported.
18941 @item
18942 A vector initializer requires no cast if the vector constant is of the
18943 same type as the variable it is initializing.
18945 @item
18946 If @code{signed} or @code{unsigned} is omitted, the signedness of the
18947 vector type is the default signedness of the base type.  The default
18948 varies depending on the operating system, so a portable program should
18949 always specify the signedness.
18951 @item
18952 By default, the keyword @code{__vector} is added. The macro
18953 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
18954 undefined.
18956 @item
18957 GCC allows using a @code{typedef} name as the type specifier for a
18958 vector type.
18960 @item
18961 For C, overloaded functions are implemented with macros so the following
18962 does not work:
18964 @smallexample
18965   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
18966 @end smallexample
18968 @noindent
18969 Since @code{spu_add} is a macro, the vector constant in the example
18970 is treated as four separate arguments.  Wrap the entire argument in
18971 parentheses for this to work.
18973 @item
18974 The extended version of @code{__builtin_expect} is not supported.
18976 @end itemize
18978 @emph{Note:} Only the interface described in the aforementioned
18979 specification is supported. Internally, GCC uses built-in functions to
18980 implement the required functionality, but these are not supported and
18981 are subject to change without notice.
18983 @node TI C6X Built-in Functions
18984 @subsection TI C6X Built-in Functions
18986 GCC provides intrinsics to access certain instructions of the TI C6X
18987 processors.  These intrinsics, listed below, are available after
18988 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
18989 to C6X instructions.
18991 @smallexample
18993 int _sadd (int, int)
18994 int _ssub (int, int)
18995 int _sadd2 (int, int)
18996 int _ssub2 (int, int)
18997 long long _mpy2 (int, int)
18998 long long _smpy2 (int, int)
18999 int _add4 (int, int)
19000 int _sub4 (int, int)
19001 int _saddu4 (int, int)
19003 int _smpy (int, int)
19004 int _smpyh (int, int)
19005 int _smpyhl (int, int)
19006 int _smpylh (int, int)
19008 int _sshl (int, int)
19009 int _subc (int, int)
19011 int _avg2 (int, int)
19012 int _avgu4 (int, int)
19014 int _clrr (int, int)
19015 int _extr (int, int)
19016 int _extru (int, int)
19017 int _abs (int)
19018 int _abs2 (int)
19020 @end smallexample
19022 @node TILE-Gx Built-in Functions
19023 @subsection TILE-Gx Built-in Functions
19025 GCC provides intrinsics to access every instruction of the TILE-Gx
19026 processor.  The intrinsics are of the form:
19028 @smallexample
19030 unsigned long long __insn_@var{op} (...)
19032 @end smallexample
19034 Where @var{op} is the name of the instruction.  Refer to the ISA manual
19035 for the complete list of instructions.
19037 GCC also provides intrinsics to directly access the network registers.
19038 The intrinsics are:
19040 @smallexample
19042 unsigned long long __tile_idn0_receive (void)
19043 unsigned long long __tile_idn1_receive (void)
19044 unsigned long long __tile_udn0_receive (void)
19045 unsigned long long __tile_udn1_receive (void)
19046 unsigned long long __tile_udn2_receive (void)
19047 unsigned long long __tile_udn3_receive (void)
19048 void __tile_idn_send (unsigned long long)
19049 void __tile_udn_send (unsigned long long)
19051 @end smallexample
19053 The intrinsic @code{void __tile_network_barrier (void)} is used to
19054 guarantee that no network operations before it are reordered with
19055 those after it.
19057 @node TILEPro Built-in Functions
19058 @subsection TILEPro Built-in Functions
19060 GCC provides intrinsics to access every instruction of the TILEPro
19061 processor.  The intrinsics are of the form:
19063 @smallexample
19065 unsigned __insn_@var{op} (...)
19067 @end smallexample
19069 @noindent
19070 where @var{op} is the name of the instruction.  Refer to the ISA manual
19071 for the complete list of instructions.
19073 GCC also provides intrinsics to directly access the network registers.
19074 The intrinsics are:
19076 @smallexample
19078 unsigned __tile_idn0_receive (void)
19079 unsigned __tile_idn1_receive (void)
19080 unsigned __tile_sn_receive (void)
19081 unsigned __tile_udn0_receive (void)
19082 unsigned __tile_udn1_receive (void)
19083 unsigned __tile_udn2_receive (void)
19084 unsigned __tile_udn3_receive (void)
19085 void __tile_idn_send (unsigned)
19086 void __tile_sn_send (unsigned)
19087 void __tile_udn_send (unsigned)
19089 @end smallexample
19091 The intrinsic @code{void __tile_network_barrier (void)} is used to
19092 guarantee that no network operations before it are reordered with
19093 those after it.
19095 @node x86 Built-in Functions
19096 @subsection x86 Built-in Functions
19098 These built-in functions are available for the x86-32 and x86-64 family
19099 of computers, depending on the command-line switches used.
19101 If you specify command-line switches such as @option{-msse},
19102 the compiler could use the extended instruction sets even if the built-ins
19103 are not used explicitly in the program.  For this reason, applications
19104 that perform run-time CPU detection must compile separate files for each
19105 supported architecture, using the appropriate flags.  In particular,
19106 the file containing the CPU detection code should be compiled without
19107 these options.
19109 The following machine modes are available for use with MMX built-in functions
19110 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
19111 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
19112 vector of eight 8-bit integers.  Some of the built-in functions operate on
19113 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
19115 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
19116 of two 32-bit floating-point values.
19118 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
19119 floating-point values.  Some instructions use a vector of four 32-bit
19120 integers, these use @code{V4SI}.  Finally, some instructions operate on an
19121 entire vector register, interpreting it as a 128-bit integer, these use mode
19122 @code{TI}.
19124 The x86-32 and x86-64 family of processors use additional built-in
19125 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
19126 floating point and @code{TC} 128-bit complex floating-point values.
19128 The following floating-point built-in functions are always available.  All
19129 of them implement the function that is part of the name.
19131 @smallexample
19132 __float128 __builtin_fabsq (__float128)
19133 __float128 __builtin_copysignq (__float128, __float128)
19134 @end smallexample
19136 The following built-in functions are always available.
19138 @table @code
19139 @item __float128 __builtin_infq (void)
19140 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
19141 @findex __builtin_infq
19143 @item __float128 __builtin_huge_valq (void)
19144 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
19145 @findex __builtin_huge_valq
19147 @item __float128 __builtin_nanq (void)
19148 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
19149 @findex __builtin_nanq
19151 @item __float128 __builtin_nansq (void)
19152 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
19153 @findex __builtin_nansq
19154 @end table
19156 The following built-in function is always available.
19158 @table @code
19159 @item void __builtin_ia32_pause (void)
19160 Generates the @code{pause} machine instruction with a compiler memory
19161 barrier.
19162 @end table
19164 The following built-in functions are always available and can be used to
19165 check the target platform type.
19167 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
19168 This function runs the CPU detection code to check the type of CPU and the
19169 features supported.  This built-in function needs to be invoked along with the built-in functions
19170 to check CPU type and features, @code{__builtin_cpu_is} and
19171 @code{__builtin_cpu_supports}, only when used in a function that is
19172 executed before any constructors are called.  The CPU detection code is
19173 automatically executed in a very high priority constructor.
19175 For example, this function has to be used in @code{ifunc} resolvers that
19176 check for CPU type using the built-in functions @code{__builtin_cpu_is}
19177 and @code{__builtin_cpu_supports}, or in constructors on targets that
19178 don't support constructor priority.
19179 @smallexample
19181 static void (*resolve_memcpy (void)) (void)
19183   // ifunc resolvers fire before constructors, explicitly call the init
19184   // function.
19185   __builtin_cpu_init ();
19186   if (__builtin_cpu_supports ("ssse3"))
19187     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
19188   else
19189     return default_memcpy;
19192 void *memcpy (void *, const void *, size_t)
19193      __attribute__ ((ifunc ("resolve_memcpy")));
19194 @end smallexample
19196 @end deftypefn
19198 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
19199 This function returns a positive integer if the run-time CPU
19200 is of type @var{cpuname}
19201 and returns @code{0} otherwise. The following CPU names can be detected:
19203 @table @samp
19204 @item intel
19205 Intel CPU.
19207 @item atom
19208 Intel Atom CPU.
19210 @item core2
19211 Intel Core 2 CPU.
19213 @item corei7
19214 Intel Core i7 CPU.
19216 @item nehalem
19217 Intel Core i7 Nehalem CPU.
19219 @item westmere
19220 Intel Core i7 Westmere CPU.
19222 @item sandybridge
19223 Intel Core i7 Sandy Bridge CPU.
19225 @item amd
19226 AMD CPU.
19228 @item amdfam10h
19229 AMD Family 10h CPU.
19231 @item barcelona
19232 AMD Family 10h Barcelona CPU.
19234 @item shanghai
19235 AMD Family 10h Shanghai CPU.
19237 @item istanbul
19238 AMD Family 10h Istanbul CPU.
19240 @item btver1
19241 AMD Family 14h CPU.
19243 @item amdfam15h
19244 AMD Family 15h CPU.
19246 @item bdver1
19247 AMD Family 15h Bulldozer version 1.
19249 @item bdver2
19250 AMD Family 15h Bulldozer version 2.
19252 @item bdver3
19253 AMD Family 15h Bulldozer version 3.
19255 @item bdver4
19256 AMD Family 15h Bulldozer version 4.
19258 @item btver2
19259 AMD Family 16h CPU.
19261 @item znver1
19262 AMD Family 17h CPU.
19263 @end table
19265 Here is an example:
19266 @smallexample
19267 if (__builtin_cpu_is ("corei7"))
19268   @{
19269      do_corei7 (); // Core i7 specific implementation.
19270   @}
19271 else
19272   @{
19273      do_generic (); // Generic implementation.
19274   @}
19275 @end smallexample
19276 @end deftypefn
19278 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19279 This function returns a positive integer if the run-time CPU
19280 supports @var{feature}
19281 and returns @code{0} otherwise. The following features can be detected:
19283 @table @samp
19284 @item cmov
19285 CMOV instruction.
19286 @item mmx
19287 MMX instructions.
19288 @item popcnt
19289 POPCNT instruction.
19290 @item sse
19291 SSE instructions.
19292 @item sse2
19293 SSE2 instructions.
19294 @item sse3
19295 SSE3 instructions.
19296 @item ssse3
19297 SSSE3 instructions.
19298 @item sse4.1
19299 SSE4.1 instructions.
19300 @item sse4.2
19301 SSE4.2 instructions.
19302 @item avx
19303 AVX instructions.
19304 @item avx2
19305 AVX2 instructions.
19306 @item avx512f
19307 AVX512F instructions.
19308 @end table
19310 Here is an example:
19311 @smallexample
19312 if (__builtin_cpu_supports ("popcnt"))
19313   @{
19314      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19315   @}
19316 else
19317   @{
19318      count = generic_countbits (n); //generic implementation.
19319   @}
19320 @end smallexample
19321 @end deftypefn
19324 The following built-in functions are made available by @option{-mmmx}.
19325 All of them generate the machine instruction that is part of the name.
19327 @smallexample
19328 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19329 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19330 v2si __builtin_ia32_paddd (v2si, v2si)
19331 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19332 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19333 v2si __builtin_ia32_psubd (v2si, v2si)
19334 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19335 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19336 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19337 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19338 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19339 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19340 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19341 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19342 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19343 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19344 di __builtin_ia32_pand (di, di)
19345 di __builtin_ia32_pandn (di,di)
19346 di __builtin_ia32_por (di, di)
19347 di __builtin_ia32_pxor (di, di)
19348 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19349 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19350 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19351 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19352 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19353 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19354 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19355 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19356 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19357 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19358 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19359 v2si __builtin_ia32_punpckldq (v2si, v2si)
19360 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19361 v4hi __builtin_ia32_packssdw (v2si, v2si)
19362 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19364 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19365 v2si __builtin_ia32_pslld (v2si, v2si)
19366 v1di __builtin_ia32_psllq (v1di, v1di)
19367 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19368 v2si __builtin_ia32_psrld (v2si, v2si)
19369 v1di __builtin_ia32_psrlq (v1di, v1di)
19370 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19371 v2si __builtin_ia32_psrad (v2si, v2si)
19372 v4hi __builtin_ia32_psllwi (v4hi, int)
19373 v2si __builtin_ia32_pslldi (v2si, int)
19374 v1di __builtin_ia32_psllqi (v1di, int)
19375 v4hi __builtin_ia32_psrlwi (v4hi, int)
19376 v2si __builtin_ia32_psrldi (v2si, int)
19377 v1di __builtin_ia32_psrlqi (v1di, int)
19378 v4hi __builtin_ia32_psrawi (v4hi, int)
19379 v2si __builtin_ia32_psradi (v2si, int)
19381 @end smallexample
19383 The following built-in functions are made available either with
19384 @option{-msse}, or with a combination of @option{-m3dnow} and
19385 @option{-march=athlon}.  All of them generate the machine
19386 instruction that is part of the name.
19388 @smallexample
19389 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19390 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19391 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19392 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19393 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19394 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19395 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19396 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19397 int __builtin_ia32_pmovmskb (v8qi)
19398 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19399 void __builtin_ia32_movntq (di *, di)
19400 void __builtin_ia32_sfence (void)
19401 @end smallexample
19403 The following built-in functions are available when @option{-msse} is used.
19404 All of them generate the machine instruction that is part of the name.
19406 @smallexample
19407 int __builtin_ia32_comieq (v4sf, v4sf)
19408 int __builtin_ia32_comineq (v4sf, v4sf)
19409 int __builtin_ia32_comilt (v4sf, v4sf)
19410 int __builtin_ia32_comile (v4sf, v4sf)
19411 int __builtin_ia32_comigt (v4sf, v4sf)
19412 int __builtin_ia32_comige (v4sf, v4sf)
19413 int __builtin_ia32_ucomieq (v4sf, v4sf)
19414 int __builtin_ia32_ucomineq (v4sf, v4sf)
19415 int __builtin_ia32_ucomilt (v4sf, v4sf)
19416 int __builtin_ia32_ucomile (v4sf, v4sf)
19417 int __builtin_ia32_ucomigt (v4sf, v4sf)
19418 int __builtin_ia32_ucomige (v4sf, v4sf)
19419 v4sf __builtin_ia32_addps (v4sf, v4sf)
19420 v4sf __builtin_ia32_subps (v4sf, v4sf)
19421 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19422 v4sf __builtin_ia32_divps (v4sf, v4sf)
19423 v4sf __builtin_ia32_addss (v4sf, v4sf)
19424 v4sf __builtin_ia32_subss (v4sf, v4sf)
19425 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19426 v4sf __builtin_ia32_divss (v4sf, v4sf)
19427 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19428 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19429 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19430 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19431 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19432 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19433 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19434 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19435 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19436 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19437 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19438 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19439 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19440 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19441 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19442 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19443 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19444 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19445 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19446 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19447 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19448 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19449 v4sf __builtin_ia32_minps (v4sf, v4sf)
19450 v4sf __builtin_ia32_minss (v4sf, v4sf)
19451 v4sf __builtin_ia32_andps (v4sf, v4sf)
19452 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19453 v4sf __builtin_ia32_orps (v4sf, v4sf)
19454 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19455 v4sf __builtin_ia32_movss (v4sf, v4sf)
19456 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19457 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19458 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19459 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19460 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19461 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19462 v2si __builtin_ia32_cvtps2pi (v4sf)
19463 int __builtin_ia32_cvtss2si (v4sf)
19464 v2si __builtin_ia32_cvttps2pi (v4sf)
19465 int __builtin_ia32_cvttss2si (v4sf)
19466 v4sf __builtin_ia32_rcpps (v4sf)
19467 v4sf __builtin_ia32_rsqrtps (v4sf)
19468 v4sf __builtin_ia32_sqrtps (v4sf)
19469 v4sf __builtin_ia32_rcpss (v4sf)
19470 v4sf __builtin_ia32_rsqrtss (v4sf)
19471 v4sf __builtin_ia32_sqrtss (v4sf)
19472 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19473 void __builtin_ia32_movntps (float *, v4sf)
19474 int __builtin_ia32_movmskps (v4sf)
19475 @end smallexample
19477 The following built-in functions are available when @option{-msse} is used.
19479 @table @code
19480 @item v4sf __builtin_ia32_loadups (float *)
19481 Generates the @code{movups} machine instruction as a load from memory.
19482 @item void __builtin_ia32_storeups (float *, v4sf)
19483 Generates the @code{movups} machine instruction as a store to memory.
19484 @item v4sf __builtin_ia32_loadss (float *)
19485 Generates the @code{movss} machine instruction as a load from memory.
19486 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19487 Generates the @code{movhps} machine instruction as a load from memory.
19488 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19489 Generates the @code{movlps} machine instruction as a load from memory
19490 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19491 Generates the @code{movhps} machine instruction as a store to memory.
19492 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19493 Generates the @code{movlps} machine instruction as a store to memory.
19494 @end table
19496 The following built-in functions are available when @option{-msse2} is used.
19497 All of them generate the machine instruction that is part of the name.
19499 @smallexample
19500 int __builtin_ia32_comisdeq (v2df, v2df)
19501 int __builtin_ia32_comisdlt (v2df, v2df)
19502 int __builtin_ia32_comisdle (v2df, v2df)
19503 int __builtin_ia32_comisdgt (v2df, v2df)
19504 int __builtin_ia32_comisdge (v2df, v2df)
19505 int __builtin_ia32_comisdneq (v2df, v2df)
19506 int __builtin_ia32_ucomisdeq (v2df, v2df)
19507 int __builtin_ia32_ucomisdlt (v2df, v2df)
19508 int __builtin_ia32_ucomisdle (v2df, v2df)
19509 int __builtin_ia32_ucomisdgt (v2df, v2df)
19510 int __builtin_ia32_ucomisdge (v2df, v2df)
19511 int __builtin_ia32_ucomisdneq (v2df, v2df)
19512 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19513 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19514 v2df __builtin_ia32_cmplepd (v2df, v2df)
19515 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19516 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19517 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19518 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19519 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19520 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19521 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19522 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19523 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19524 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19525 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19526 v2df __builtin_ia32_cmplesd (v2df, v2df)
19527 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19528 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19529 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19530 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19531 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19532 v2di __builtin_ia32_paddq (v2di, v2di)
19533 v2di __builtin_ia32_psubq (v2di, v2di)
19534 v2df __builtin_ia32_addpd (v2df, v2df)
19535 v2df __builtin_ia32_subpd (v2df, v2df)
19536 v2df __builtin_ia32_mulpd (v2df, v2df)
19537 v2df __builtin_ia32_divpd (v2df, v2df)
19538 v2df __builtin_ia32_addsd (v2df, v2df)
19539 v2df __builtin_ia32_subsd (v2df, v2df)
19540 v2df __builtin_ia32_mulsd (v2df, v2df)
19541 v2df __builtin_ia32_divsd (v2df, v2df)
19542 v2df __builtin_ia32_minpd (v2df, v2df)
19543 v2df __builtin_ia32_maxpd (v2df, v2df)
19544 v2df __builtin_ia32_minsd (v2df, v2df)
19545 v2df __builtin_ia32_maxsd (v2df, v2df)
19546 v2df __builtin_ia32_andpd (v2df, v2df)
19547 v2df __builtin_ia32_andnpd (v2df, v2df)
19548 v2df __builtin_ia32_orpd (v2df, v2df)
19549 v2df __builtin_ia32_xorpd (v2df, v2df)
19550 v2df __builtin_ia32_movsd (v2df, v2df)
19551 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19552 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19553 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19554 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19555 v4si __builtin_ia32_paddd128 (v4si, v4si)
19556 v2di __builtin_ia32_paddq128 (v2di, v2di)
19557 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19558 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19559 v4si __builtin_ia32_psubd128 (v4si, v4si)
19560 v2di __builtin_ia32_psubq128 (v2di, v2di)
19561 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19562 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19563 v2di __builtin_ia32_pand128 (v2di, v2di)
19564 v2di __builtin_ia32_pandn128 (v2di, v2di)
19565 v2di __builtin_ia32_por128 (v2di, v2di)
19566 v2di __builtin_ia32_pxor128 (v2di, v2di)
19567 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19568 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19569 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19570 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19571 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19572 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19573 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19574 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19575 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19576 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19577 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19578 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19579 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19580 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19581 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19582 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19583 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19584 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19585 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19586 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19587 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19588 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19589 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19590 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19591 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19592 v2df __builtin_ia32_loadupd (double *)
19593 void __builtin_ia32_storeupd (double *, v2df)
19594 v2df __builtin_ia32_loadhpd (v2df, double const *)
19595 v2df __builtin_ia32_loadlpd (v2df, double const *)
19596 int __builtin_ia32_movmskpd (v2df)
19597 int __builtin_ia32_pmovmskb128 (v16qi)
19598 void __builtin_ia32_movnti (int *, int)
19599 void __builtin_ia32_movnti64 (long long int *, long long int)
19600 void __builtin_ia32_movntpd (double *, v2df)
19601 void __builtin_ia32_movntdq (v2df *, v2df)
19602 v4si __builtin_ia32_pshufd (v4si, int)
19603 v8hi __builtin_ia32_pshuflw (v8hi, int)
19604 v8hi __builtin_ia32_pshufhw (v8hi, int)
19605 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19606 v2df __builtin_ia32_sqrtpd (v2df)
19607 v2df __builtin_ia32_sqrtsd (v2df)
19608 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19609 v2df __builtin_ia32_cvtdq2pd (v4si)
19610 v4sf __builtin_ia32_cvtdq2ps (v4si)
19611 v4si __builtin_ia32_cvtpd2dq (v2df)
19612 v2si __builtin_ia32_cvtpd2pi (v2df)
19613 v4sf __builtin_ia32_cvtpd2ps (v2df)
19614 v4si __builtin_ia32_cvttpd2dq (v2df)
19615 v2si __builtin_ia32_cvttpd2pi (v2df)
19616 v2df __builtin_ia32_cvtpi2pd (v2si)
19617 int __builtin_ia32_cvtsd2si (v2df)
19618 int __builtin_ia32_cvttsd2si (v2df)
19619 long long __builtin_ia32_cvtsd2si64 (v2df)
19620 long long __builtin_ia32_cvttsd2si64 (v2df)
19621 v4si __builtin_ia32_cvtps2dq (v4sf)
19622 v2df __builtin_ia32_cvtps2pd (v4sf)
19623 v4si __builtin_ia32_cvttps2dq (v4sf)
19624 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19625 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19626 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19627 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19628 void __builtin_ia32_clflush (const void *)
19629 void __builtin_ia32_lfence (void)
19630 void __builtin_ia32_mfence (void)
19631 v16qi __builtin_ia32_loaddqu (const char *)
19632 void __builtin_ia32_storedqu (char *, v16qi)
19633 v1di __builtin_ia32_pmuludq (v2si, v2si)
19634 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19635 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19636 v4si __builtin_ia32_pslld128 (v4si, v4si)
19637 v2di __builtin_ia32_psllq128 (v2di, v2di)
19638 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19639 v4si __builtin_ia32_psrld128 (v4si, v4si)
19640 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19641 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19642 v4si __builtin_ia32_psrad128 (v4si, v4si)
19643 v2di __builtin_ia32_pslldqi128 (v2di, int)
19644 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19645 v4si __builtin_ia32_pslldi128 (v4si, int)
19646 v2di __builtin_ia32_psllqi128 (v2di, int)
19647 v2di __builtin_ia32_psrldqi128 (v2di, int)
19648 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19649 v4si __builtin_ia32_psrldi128 (v4si, int)
19650 v2di __builtin_ia32_psrlqi128 (v2di, int)
19651 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19652 v4si __builtin_ia32_psradi128 (v4si, int)
19653 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19654 v2di __builtin_ia32_movq128 (v2di)
19655 @end smallexample
19657 The following built-in functions are available when @option{-msse3} is used.
19658 All of them generate the machine instruction that is part of the name.
19660 @smallexample
19661 v2df __builtin_ia32_addsubpd (v2df, v2df)
19662 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19663 v2df __builtin_ia32_haddpd (v2df, v2df)
19664 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19665 v2df __builtin_ia32_hsubpd (v2df, v2df)
19666 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19667 v16qi __builtin_ia32_lddqu (char const *)
19668 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19669 v4sf __builtin_ia32_movshdup (v4sf)
19670 v4sf __builtin_ia32_movsldup (v4sf)
19671 void __builtin_ia32_mwait (unsigned int, unsigned int)
19672 @end smallexample
19674 The following built-in functions are available when @option{-mssse3} is used.
19675 All of them generate the machine instruction that is part of the name.
19677 @smallexample
19678 v2si __builtin_ia32_phaddd (v2si, v2si)
19679 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19680 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19681 v2si __builtin_ia32_phsubd (v2si, v2si)
19682 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19683 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19684 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19685 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19686 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19687 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19688 v2si __builtin_ia32_psignd (v2si, v2si)
19689 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19690 v1di __builtin_ia32_palignr (v1di, v1di, int)
19691 v8qi __builtin_ia32_pabsb (v8qi)
19692 v2si __builtin_ia32_pabsd (v2si)
19693 v4hi __builtin_ia32_pabsw (v4hi)
19694 @end smallexample
19696 The following built-in functions are available when @option{-mssse3} is used.
19697 All of them generate the machine instruction that is part of the name.
19699 @smallexample
19700 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19701 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19702 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19703 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19704 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19705 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19706 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19707 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19708 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19709 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19710 v4si __builtin_ia32_psignd128 (v4si, v4si)
19711 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19712 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19713 v16qi __builtin_ia32_pabsb128 (v16qi)
19714 v4si __builtin_ia32_pabsd128 (v4si)
19715 v8hi __builtin_ia32_pabsw128 (v8hi)
19716 @end smallexample
19718 The following built-in functions are available when @option{-msse4.1} is
19719 used.  All of them generate the machine instruction that is part of the
19720 name.
19722 @smallexample
19723 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19724 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19725 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19726 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19727 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19728 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19729 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19730 v2di __builtin_ia32_movntdqa (v2di *);
19731 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19732 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19733 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19734 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19735 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19736 v8hi __builtin_ia32_phminposuw128 (v8hi)
19737 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19738 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19739 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19740 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19741 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19742 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19743 v4si __builtin_ia32_pminud128 (v4si, v4si)
19744 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19745 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19746 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19747 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19748 v2di __builtin_ia32_pmovsxdq128 (v4si)
19749 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19750 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19751 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19752 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19753 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19754 v2di __builtin_ia32_pmovzxdq128 (v4si)
19755 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19756 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19757 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19758 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19759 int __builtin_ia32_ptestc128 (v2di, v2di)
19760 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19761 int __builtin_ia32_ptestz128 (v2di, v2di)
19762 v2df __builtin_ia32_roundpd (v2df, const int)
19763 v4sf __builtin_ia32_roundps (v4sf, const int)
19764 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19765 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19766 @end smallexample
19768 The following built-in functions are available when @option{-msse4.1} is
19769 used.
19771 @table @code
19772 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19773 Generates the @code{insertps} machine instruction.
19774 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19775 Generates the @code{pextrb} machine instruction.
19776 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19777 Generates the @code{pinsrb} machine instruction.
19778 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19779 Generates the @code{pinsrd} machine instruction.
19780 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19781 Generates the @code{pinsrq} machine instruction in 64bit mode.
19782 @end table
19784 The following built-in functions are changed to generate new SSE4.1
19785 instructions when @option{-msse4.1} is used.
19787 @table @code
19788 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19789 Generates the @code{extractps} machine instruction.
19790 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19791 Generates the @code{pextrd} machine instruction.
19792 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19793 Generates the @code{pextrq} machine instruction in 64bit mode.
19794 @end table
19796 The following built-in functions are available when @option{-msse4.2} is
19797 used.  All of them generate the machine instruction that is part of the
19798 name.
19800 @smallexample
19801 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19802 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19803 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19804 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19805 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19806 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19807 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19808 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19809 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19810 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19811 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19812 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19813 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19814 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19815 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19816 @end smallexample
19818 The following built-in functions are available when @option{-msse4.2} is
19819 used.
19821 @table @code
19822 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19823 Generates the @code{crc32b} machine instruction.
19824 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19825 Generates the @code{crc32w} machine instruction.
19826 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19827 Generates the @code{crc32l} machine instruction.
19828 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19829 Generates the @code{crc32q} machine instruction.
19830 @end table
19832 The following built-in functions are changed to generate new SSE4.2
19833 instructions when @option{-msse4.2} is used.
19835 @table @code
19836 @item int __builtin_popcount (unsigned int)
19837 Generates the @code{popcntl} machine instruction.
19838 @item int __builtin_popcountl (unsigned long)
19839 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19840 depending on the size of @code{unsigned long}.
19841 @item int __builtin_popcountll (unsigned long long)
19842 Generates the @code{popcntq} machine instruction.
19843 @end table
19845 The following built-in functions are available when @option{-mavx} is
19846 used. All of them generate the machine instruction that is part of the
19847 name.
19849 @smallexample
19850 v4df __builtin_ia32_addpd256 (v4df,v4df)
19851 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19852 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19853 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19854 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19855 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19856 v4df __builtin_ia32_andpd256 (v4df,v4df)
19857 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19858 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19859 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19860 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19861 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19862 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19863 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19864 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19865 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19866 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19867 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
19868 v4df __builtin_ia32_cvtdq2pd256 (v4si)
19869 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
19870 v4si __builtin_ia32_cvtpd2dq256 (v4df)
19871 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
19872 v8si __builtin_ia32_cvtps2dq256 (v8sf)
19873 v4df __builtin_ia32_cvtps2pd256 (v4sf)
19874 v4si __builtin_ia32_cvttpd2dq256 (v4df)
19875 v8si __builtin_ia32_cvttps2dq256 (v8sf)
19876 v4df __builtin_ia32_divpd256 (v4df,v4df)
19877 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
19878 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
19879 v4df __builtin_ia32_haddpd256 (v4df,v4df)
19880 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
19881 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
19882 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
19883 v32qi __builtin_ia32_lddqu256 (pcchar)
19884 v32qi __builtin_ia32_loaddqu256 (pcchar)
19885 v4df __builtin_ia32_loadupd256 (pcdouble)
19886 v8sf __builtin_ia32_loadups256 (pcfloat)
19887 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
19888 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
19889 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
19890 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
19891 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
19892 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
19893 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
19894 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
19895 v4df __builtin_ia32_maxpd256 (v4df,v4df)
19896 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
19897 v4df __builtin_ia32_minpd256 (v4df,v4df)
19898 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
19899 v4df __builtin_ia32_movddup256 (v4df)
19900 int __builtin_ia32_movmskpd256 (v4df)
19901 int __builtin_ia32_movmskps256 (v8sf)
19902 v8sf __builtin_ia32_movshdup256 (v8sf)
19903 v8sf __builtin_ia32_movsldup256 (v8sf)
19904 v4df __builtin_ia32_mulpd256 (v4df,v4df)
19905 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
19906 v4df __builtin_ia32_orpd256 (v4df,v4df)
19907 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
19908 v2df __builtin_ia32_pd_pd256 (v4df)
19909 v4df __builtin_ia32_pd256_pd (v2df)
19910 v4sf __builtin_ia32_ps_ps256 (v8sf)
19911 v8sf __builtin_ia32_ps256_ps (v4sf)
19912 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
19913 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
19914 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
19915 v8sf __builtin_ia32_rcpps256 (v8sf)
19916 v4df __builtin_ia32_roundpd256 (v4df,int)
19917 v8sf __builtin_ia32_roundps256 (v8sf,int)
19918 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
19919 v8sf __builtin_ia32_rsqrtps256 (v8sf)
19920 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
19921 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
19922 v4si __builtin_ia32_si_si256 (v8si)
19923 v8si __builtin_ia32_si256_si (v4si)
19924 v4df __builtin_ia32_sqrtpd256 (v4df)
19925 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
19926 v8sf __builtin_ia32_sqrtps256 (v8sf)
19927 void __builtin_ia32_storedqu256 (pchar,v32qi)
19928 void __builtin_ia32_storeupd256 (pdouble,v4df)
19929 void __builtin_ia32_storeups256 (pfloat,v8sf)
19930 v4df __builtin_ia32_subpd256 (v4df,v4df)
19931 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
19932 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
19933 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
19934 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
19935 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
19936 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
19937 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
19938 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
19939 v4sf __builtin_ia32_vbroadcastss (pcfloat)
19940 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
19941 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
19942 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
19943 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
19944 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
19945 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
19946 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
19947 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
19948 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
19949 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
19950 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
19951 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
19952 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
19953 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
19954 v2df __builtin_ia32_vpermilpd (v2df,int)
19955 v4df __builtin_ia32_vpermilpd256 (v4df,int)
19956 v4sf __builtin_ia32_vpermilps (v4sf,int)
19957 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
19958 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
19959 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
19960 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
19961 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
19962 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
19963 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
19964 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
19965 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
19966 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
19967 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
19968 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
19969 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
19970 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
19971 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
19972 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
19973 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
19974 void __builtin_ia32_vzeroall (void)
19975 void __builtin_ia32_vzeroupper (void)
19976 v4df __builtin_ia32_xorpd256 (v4df,v4df)
19977 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
19978 @end smallexample
19980 The following built-in functions are available when @option{-mavx2} is
19981 used. All of them generate the machine instruction that is part of the
19982 name.
19984 @smallexample
19985 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
19986 v32qi __builtin_ia32_pabsb256 (v32qi)
19987 v16hi __builtin_ia32_pabsw256 (v16hi)
19988 v8si __builtin_ia32_pabsd256 (v8si)
19989 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
19990 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
19991 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
19992 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
19993 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
19994 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
19995 v8si __builtin_ia32_paddd256 (v8si,v8si)
19996 v4di __builtin_ia32_paddq256 (v4di,v4di)
19997 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
19998 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
19999 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
20000 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
20001 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
20002 v4di __builtin_ia32_andsi256 (v4di,v4di)
20003 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
20004 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
20005 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
20006 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
20007 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
20008 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
20009 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
20010 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
20011 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
20012 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
20013 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
20014 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
20015 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
20016 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
20017 v8si __builtin_ia32_phaddd256 (v8si,v8si)
20018 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
20019 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
20020 v8si __builtin_ia32_phsubd256 (v8si,v8si)
20021 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
20022 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
20023 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
20024 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
20025 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
20026 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
20027 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
20028 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
20029 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
20030 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
20031 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
20032 v8si __builtin_ia32_pminsd256 (v8si,v8si)
20033 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
20034 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
20035 v8si __builtin_ia32_pminud256 (v8si,v8si)
20036 int __builtin_ia32_pmovmskb256 (v32qi)
20037 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
20038 v8si __builtin_ia32_pmovsxbd256 (v16qi)
20039 v4di __builtin_ia32_pmovsxbq256 (v16qi)
20040 v8si __builtin_ia32_pmovsxwd256 (v8hi)
20041 v4di __builtin_ia32_pmovsxwq256 (v8hi)
20042 v4di __builtin_ia32_pmovsxdq256 (v4si)
20043 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
20044 v8si __builtin_ia32_pmovzxbd256 (v16qi)
20045 v4di __builtin_ia32_pmovzxbq256 (v16qi)
20046 v8si __builtin_ia32_pmovzxwd256 (v8hi)
20047 v4di __builtin_ia32_pmovzxwq256 (v8hi)
20048 v4di __builtin_ia32_pmovzxdq256 (v4si)
20049 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
20050 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
20051 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
20052 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
20053 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
20054 v8si __builtin_ia32_pmulld256 (v8si,v8si)
20055 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
20056 v4di __builtin_ia32_por256 (v4di,v4di)
20057 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
20058 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
20059 v8si __builtin_ia32_pshufd256 (v8si,int)
20060 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
20061 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
20062 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
20063 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
20064 v8si __builtin_ia32_psignd256 (v8si,v8si)
20065 v4di __builtin_ia32_pslldqi256 (v4di,int)
20066 v16hi __builtin_ia32_psllwi256 (16hi,int)
20067 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
20068 v8si __builtin_ia32_pslldi256 (v8si,int)
20069 v8si __builtin_ia32_pslld256(v8si,v4si)
20070 v4di __builtin_ia32_psllqi256 (v4di,int)
20071 v4di __builtin_ia32_psllq256(v4di,v2di)
20072 v16hi __builtin_ia32_psrawi256 (v16hi,int)
20073 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
20074 v8si __builtin_ia32_psradi256 (v8si,int)
20075 v8si __builtin_ia32_psrad256 (v8si,v4si)
20076 v4di __builtin_ia32_psrldqi256 (v4di, int)
20077 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
20078 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
20079 v8si __builtin_ia32_psrldi256 (v8si,int)
20080 v8si __builtin_ia32_psrld256 (v8si,v4si)
20081 v4di __builtin_ia32_psrlqi256 (v4di,int)
20082 v4di __builtin_ia32_psrlq256(v4di,v2di)
20083 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
20084 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
20085 v8si __builtin_ia32_psubd256 (v8si,v8si)
20086 v4di __builtin_ia32_psubq256 (v4di,v4di)
20087 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
20088 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
20089 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
20090 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
20091 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
20092 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
20093 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
20094 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
20095 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
20096 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
20097 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
20098 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
20099 v4di __builtin_ia32_pxor256 (v4di,v4di)
20100 v4di __builtin_ia32_movntdqa256 (pv4di)
20101 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
20102 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
20103 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
20104 v4di __builtin_ia32_vbroadcastsi256 (v2di)
20105 v4si __builtin_ia32_pblendd128 (v4si,v4si)
20106 v8si __builtin_ia32_pblendd256 (v8si,v8si)
20107 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
20108 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
20109 v8si __builtin_ia32_pbroadcastd256 (v4si)
20110 v4di __builtin_ia32_pbroadcastq256 (v2di)
20111 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
20112 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
20113 v4si __builtin_ia32_pbroadcastd128 (v4si)
20114 v2di __builtin_ia32_pbroadcastq128 (v2di)
20115 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
20116 v4df __builtin_ia32_permdf256 (v4df,int)
20117 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
20118 v4di __builtin_ia32_permdi256 (v4di,int)
20119 v4di __builtin_ia32_permti256 (v4di,v4di,int)
20120 v4di __builtin_ia32_extract128i256 (v4di,int)
20121 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
20122 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
20123 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
20124 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
20125 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
20126 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
20127 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
20128 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
20129 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
20130 v8si __builtin_ia32_psllv8si (v8si,v8si)
20131 v4si __builtin_ia32_psllv4si (v4si,v4si)
20132 v4di __builtin_ia32_psllv4di (v4di,v4di)
20133 v2di __builtin_ia32_psllv2di (v2di,v2di)
20134 v8si __builtin_ia32_psrav8si (v8si,v8si)
20135 v4si __builtin_ia32_psrav4si (v4si,v4si)
20136 v8si __builtin_ia32_psrlv8si (v8si,v8si)
20137 v4si __builtin_ia32_psrlv4si (v4si,v4si)
20138 v4di __builtin_ia32_psrlv4di (v4di,v4di)
20139 v2di __builtin_ia32_psrlv2di (v2di,v2di)
20140 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
20141 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
20142 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
20143 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
20144 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
20145 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
20146 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
20147 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
20148 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
20149 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
20150 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
20151 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
20152 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
20153 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
20154 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
20155 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
20156 @end smallexample
20158 The following built-in functions are available when @option{-maes} is
20159 used.  All of them generate the machine instruction that is part of the
20160 name.
20162 @smallexample
20163 v2di __builtin_ia32_aesenc128 (v2di, v2di)
20164 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
20165 v2di __builtin_ia32_aesdec128 (v2di, v2di)
20166 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
20167 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
20168 v2di __builtin_ia32_aesimc128 (v2di)
20169 @end smallexample
20171 The following built-in function is available when @option{-mpclmul} is
20172 used.
20174 @table @code
20175 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
20176 Generates the @code{pclmulqdq} machine instruction.
20177 @end table
20179 The following built-in function is available when @option{-mfsgsbase} is
20180 used.  All of them generate the machine instruction that is part of the
20181 name.
20183 @smallexample
20184 unsigned int __builtin_ia32_rdfsbase32 (void)
20185 unsigned long long __builtin_ia32_rdfsbase64 (void)
20186 unsigned int __builtin_ia32_rdgsbase32 (void)
20187 unsigned long long __builtin_ia32_rdgsbase64 (void)
20188 void _writefsbase_u32 (unsigned int)
20189 void _writefsbase_u64 (unsigned long long)
20190 void _writegsbase_u32 (unsigned int)
20191 void _writegsbase_u64 (unsigned long long)
20192 @end smallexample
20194 The following built-in function is available when @option{-mrdrnd} is
20195 used.  All of them generate the machine instruction that is part of the
20196 name.
20198 @smallexample
20199 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
20200 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
20201 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
20202 @end smallexample
20204 The following built-in functions are available when @option{-msse4a} is used.
20205 All of them generate the machine instruction that is part of the name.
20207 @smallexample
20208 void __builtin_ia32_movntsd (double *, v2df)
20209 void __builtin_ia32_movntss (float *, v4sf)
20210 v2di __builtin_ia32_extrq  (v2di, v16qi)
20211 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
20212 v2di __builtin_ia32_insertq (v2di, v2di)
20213 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
20214 @end smallexample
20216 The following built-in functions are available when @option{-mxop} is used.
20217 @smallexample
20218 v2df __builtin_ia32_vfrczpd (v2df)
20219 v4sf __builtin_ia32_vfrczps (v4sf)
20220 v2df __builtin_ia32_vfrczsd (v2df)
20221 v4sf __builtin_ia32_vfrczss (v4sf)
20222 v4df __builtin_ia32_vfrczpd256 (v4df)
20223 v8sf __builtin_ia32_vfrczps256 (v8sf)
20224 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
20225 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
20226 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
20227 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
20228 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
20229 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
20230 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
20231 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
20232 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
20233 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
20234 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
20235 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
20236 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
20237 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
20238 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20239 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
20240 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
20241 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
20242 v4si __builtin_ia32_vpcomequd (v4si, v4si)
20243 v2di __builtin_ia32_vpcomequq (v2di, v2di)
20244 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
20245 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
20246 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
20247 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
20248 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
20249 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
20250 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
20251 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
20252 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
20253 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
20254 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
20255 v4si __builtin_ia32_vpcomged (v4si, v4si)
20256 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
20257 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
20258 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
20259 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
20260 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
20261 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
20262 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
20263 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
20264 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
20265 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
20266 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
20267 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
20268 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
20269 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
20270 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
20271 v4si __builtin_ia32_vpcomled (v4si, v4si)
20272 v2di __builtin_ia32_vpcomleq (v2di, v2di)
20273 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
20274 v4si __builtin_ia32_vpcomleud (v4si, v4si)
20275 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
20276 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
20277 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
20278 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20279 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20280 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20281 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20282 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20283 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20284 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20285 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20286 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20287 v4si __builtin_ia32_vpcomned (v4si, v4si)
20288 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20289 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20290 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20291 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20292 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20293 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20294 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20295 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20296 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20297 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20298 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20299 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20300 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20301 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20302 v4si __builtin_ia32_vphaddbd (v16qi)
20303 v2di __builtin_ia32_vphaddbq (v16qi)
20304 v8hi __builtin_ia32_vphaddbw (v16qi)
20305 v2di __builtin_ia32_vphadddq (v4si)
20306 v4si __builtin_ia32_vphaddubd (v16qi)
20307 v2di __builtin_ia32_vphaddubq (v16qi)
20308 v8hi __builtin_ia32_vphaddubw (v16qi)
20309 v2di __builtin_ia32_vphaddudq (v4si)
20310 v4si __builtin_ia32_vphadduwd (v8hi)
20311 v2di __builtin_ia32_vphadduwq (v8hi)
20312 v4si __builtin_ia32_vphaddwd (v8hi)
20313 v2di __builtin_ia32_vphaddwq (v8hi)
20314 v8hi __builtin_ia32_vphsubbw (v16qi)
20315 v2di __builtin_ia32_vphsubdq (v4si)
20316 v4si __builtin_ia32_vphsubwd (v8hi)
20317 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20318 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20319 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20320 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20321 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20322 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20323 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20324 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20325 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20326 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20327 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20328 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20329 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20330 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20331 v4si __builtin_ia32_vprotd (v4si, v4si)
20332 v2di __builtin_ia32_vprotq (v2di, v2di)
20333 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20334 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20335 v4si __builtin_ia32_vpshad (v4si, v4si)
20336 v2di __builtin_ia32_vpshaq (v2di, v2di)
20337 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20338 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20339 v4si __builtin_ia32_vpshld (v4si, v4si)
20340 v2di __builtin_ia32_vpshlq (v2di, v2di)
20341 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20342 @end smallexample
20344 The following built-in functions are available when @option{-mfma4} is used.
20345 All of them generate the machine instruction that is part of the name.
20347 @smallexample
20348 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20349 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20350 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20351 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20352 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20353 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20354 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20355 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20356 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20357 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20358 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20359 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20360 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20361 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20362 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20363 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20364 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
20365 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
20366 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
20367 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
20368 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20369 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20370 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20371 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20372 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20373 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20374 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20375 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20376 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20377 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20378 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20379 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20381 @end smallexample
20383 The following built-in functions are available when @option{-mlwp} is used.
20385 @smallexample
20386 void __builtin_ia32_llwpcb16 (void *);
20387 void __builtin_ia32_llwpcb32 (void *);
20388 void __builtin_ia32_llwpcb64 (void *);
20389 void * __builtin_ia32_llwpcb16 (void);
20390 void * __builtin_ia32_llwpcb32 (void);
20391 void * __builtin_ia32_llwpcb64 (void);
20392 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20393 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20394 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20395 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20396 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20397 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20398 @end smallexample
20400 The following built-in functions are available when @option{-mbmi} is used.
20401 All of them generate the machine instruction that is part of the name.
20402 @smallexample
20403 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20404 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20405 @end smallexample
20407 The following built-in functions are available when @option{-mbmi2} is used.
20408 All of them generate the machine instruction that is part of the name.
20409 @smallexample
20410 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20411 unsigned int _pdep_u32 (unsigned int, unsigned int)
20412 unsigned int _pext_u32 (unsigned int, unsigned int)
20413 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20414 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20415 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20416 @end smallexample
20418 The following built-in functions are available when @option{-mlzcnt} is used.
20419 All of them generate the machine instruction that is part of the name.
20420 @smallexample
20421 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20422 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20423 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20424 @end smallexample
20426 The following built-in functions are available when @option{-mfxsr} is used.
20427 All of them generate the machine instruction that is part of the name.
20428 @smallexample
20429 void __builtin_ia32_fxsave (void *)
20430 void __builtin_ia32_fxrstor (void *)
20431 void __builtin_ia32_fxsave64 (void *)
20432 void __builtin_ia32_fxrstor64 (void *)
20433 @end smallexample
20435 The following built-in functions are available when @option{-mxsave} is used.
20436 All of them generate the machine instruction that is part of the name.
20437 @smallexample
20438 void __builtin_ia32_xsave (void *, long long)
20439 void __builtin_ia32_xrstor (void *, long long)
20440 void __builtin_ia32_xsave64 (void *, long long)
20441 void __builtin_ia32_xrstor64 (void *, long long)
20442 @end smallexample
20444 The following built-in functions are available when @option{-mxsaveopt} is used.
20445 All of them generate the machine instruction that is part of the name.
20446 @smallexample
20447 void __builtin_ia32_xsaveopt (void *, long long)
20448 void __builtin_ia32_xsaveopt64 (void *, long long)
20449 @end smallexample
20451 The following built-in functions are available when @option{-mtbm} is used.
20452 Both of them generate the immediate form of the bextr machine instruction.
20453 @smallexample
20454 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
20455 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
20456 @end smallexample
20459 The following built-in functions are available when @option{-m3dnow} is used.
20460 All of them generate the machine instruction that is part of the name.
20462 @smallexample
20463 void __builtin_ia32_femms (void)
20464 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20465 v2si __builtin_ia32_pf2id (v2sf)
20466 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20467 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20468 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20469 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20470 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20471 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20472 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20473 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20474 v2sf __builtin_ia32_pfrcp (v2sf)
20475 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20476 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20477 v2sf __builtin_ia32_pfrsqrt (v2sf)
20478 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20479 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20480 v2sf __builtin_ia32_pi2fd (v2si)
20481 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20482 @end smallexample
20484 The following built-in functions are available when both @option{-m3dnow}
20485 and @option{-march=athlon} are used.  All of them generate the machine
20486 instruction that is part of the name.
20488 @smallexample
20489 v2si __builtin_ia32_pf2iw (v2sf)
20490 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20491 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20492 v2sf __builtin_ia32_pi2fw (v2si)
20493 v2sf __builtin_ia32_pswapdsf (v2sf)
20494 v2si __builtin_ia32_pswapdsi (v2si)
20495 @end smallexample
20497 The following built-in functions are available when @option{-mrtm} is used
20498 They are used for restricted transactional memory. These are the internal
20499 low level functions. Normally the functions in 
20500 @ref{x86 transactional memory intrinsics} should be used instead.
20502 @smallexample
20503 int __builtin_ia32_xbegin ()
20504 void __builtin_ia32_xend ()
20505 void __builtin_ia32_xabort (status)
20506 int __builtin_ia32_xtest ()
20507 @end smallexample
20509 The following built-in functions are available when @option{-mmwaitx} is used.
20510 All of them generate the machine instruction that is part of the name.
20511 @smallexample
20512 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20513 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20514 @end smallexample
20516 The following built-in functions are available when @option{-mclzero} is used.
20517 All of them generate the machine instruction that is part of the name.
20518 @smallexample
20519 void __builtin_i32_clzero (void *)
20520 @end smallexample
20522 The following built-in functions are available when @option{-mpku} is used.
20523 They generate reads and writes to PKRU.
20524 @smallexample
20525 void __builtin_ia32_wrpkru (unsigned int)
20526 unsigned int __builtin_ia32_rdpkru ()
20527 @end smallexample
20529 @node x86 transactional memory intrinsics
20530 @subsection x86 Transactional Memory Intrinsics
20532 These hardware transactional memory intrinsics for x86 allow you to use
20533 memory transactions with RTM (Restricted Transactional Memory).
20534 This support is enabled with the @option{-mrtm} option.
20535 For using HLE (Hardware Lock Elision) see 
20536 @ref{x86 specific memory model extensions for transactional memory} instead.
20538 A memory transaction commits all changes to memory in an atomic way,
20539 as visible to other threads. If the transaction fails it is rolled back
20540 and all side effects discarded.
20542 Generally there is no guarantee that a memory transaction ever succeeds
20543 and suitable fallback code always needs to be supplied.
20545 @deftypefn {RTM Function} {unsigned} _xbegin ()
20546 Start a RTM (Restricted Transactional Memory) transaction. 
20547 Returns @code{_XBEGIN_STARTED} when the transaction
20548 started successfully (note this is not 0, so the constant has to be 
20549 explicitly tested).  
20551 If the transaction aborts, all side-effects 
20552 are undone and an abort code encoded as a bit mask is returned.
20553 The following macros are defined:
20555 @table @code
20556 @item _XABORT_EXPLICIT
20557 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
20558 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20559 @item _XABORT_RETRY
20560 Transaction retry is possible.
20561 @item _XABORT_CONFLICT
20562 Transaction abort due to a memory conflict with another thread.
20563 @item _XABORT_CAPACITY
20564 Transaction abort due to the transaction using too much memory.
20565 @item _XABORT_DEBUG
20566 Transaction abort due to a debug trap.
20567 @item _XABORT_NESTED
20568 Transaction abort in an inner nested transaction.
20569 @end table
20571 There is no guarantee
20572 any transaction ever succeeds, so there always needs to be a valid
20573 fallback path.
20574 @end deftypefn
20576 @deftypefn {RTM Function} {void} _xend ()
20577 Commit the current transaction. When no transaction is active this faults.
20578 All memory side-effects of the transaction become visible
20579 to other threads in an atomic manner.
20580 @end deftypefn
20582 @deftypefn {RTM Function} {int} _xtest ()
20583 Return a nonzero value if a transaction is currently active, otherwise 0.
20584 @end deftypefn
20586 @deftypefn {RTM Function} {void} _xabort (status)
20587 Abort the current transaction. When no transaction is active this is a no-op.
20588 The @var{status} is an 8-bit constant; its value is encoded in the return 
20589 value from @code{_xbegin}.
20590 @end deftypefn
20592 Here is an example showing handling for @code{_XABORT_RETRY}
20593 and a fallback path for other failures:
20595 @smallexample
20596 #include <immintrin.h>
20598 int n_tries, max_tries;
20599 unsigned status = _XABORT_EXPLICIT;
20602 for (n_tries = 0; n_tries < max_tries; n_tries++) 
20603   @{
20604     status = _xbegin ();
20605     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20606       break;
20607   @}
20608 if (status == _XBEGIN_STARTED) 
20609   @{
20610     ... transaction code...
20611     _xend ();
20612   @} 
20613 else 
20614   @{
20615     ... non-transactional fallback path...
20616   @}
20617 @end smallexample
20619 @noindent
20620 Note that, in most cases, the transactional and non-transactional code
20621 must synchronize together to ensure consistency.
20623 @node Target Format Checks
20624 @section Format Checks Specific to Particular Target Machines
20626 For some target machines, GCC supports additional options to the
20627 format attribute
20628 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20630 @menu
20631 * Solaris Format Checks::
20632 * Darwin Format Checks::
20633 @end menu
20635 @node Solaris Format Checks
20636 @subsection Solaris Format Checks
20638 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20639 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
20640 conversions, and the two-argument @code{%b} conversion for displaying
20641 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
20643 @node Darwin Format Checks
20644 @subsection Darwin Format Checks
20646 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20647 attribute context.  Declarations made with such attribution are parsed for correct syntax
20648 and format argument types.  However, parsing of the format string itself is currently undefined
20649 and is not carried out by this version of the compiler.
20651 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20652 also be used as format arguments.  Note that the relevant headers are only likely to be
20653 available on Darwin (OSX) installations.  On such installations, the XCode and system
20654 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20655 associated functions.
20657 @node Pragmas
20658 @section Pragmas Accepted by GCC
20659 @cindex pragmas
20660 @cindex @code{#pragma}
20662 GCC supports several types of pragmas, primarily in order to compile
20663 code originally written for other compilers.  Note that in general
20664 we do not recommend the use of pragmas; @xref{Function Attributes},
20665 for further explanation.
20667 @menu
20668 * AArch64 Pragmas::
20669 * ARM Pragmas::
20670 * M32C Pragmas::
20671 * MeP Pragmas::
20672 * RS/6000 and PowerPC Pragmas::
20673 * S/390 Pragmas::
20674 * Darwin Pragmas::
20675 * Solaris Pragmas::
20676 * Symbol-Renaming Pragmas::
20677 * Structure-Layout Pragmas::
20678 * Weak Pragmas::
20679 * Diagnostic Pragmas::
20680 * Visibility Pragmas::
20681 * Push/Pop Macro Pragmas::
20682 * Function Specific Option Pragmas::
20683 * Loop-Specific Pragmas::
20684 @end menu
20686 @node AArch64 Pragmas
20687 @subsection AArch64 Pragmas
20689 The pragmas defined by the AArch64 target correspond to the AArch64
20690 target function attributes.  They can be specified as below:
20691 @smallexample
20692 #pragma GCC target("string")
20693 @end smallexample
20695 where @code{@var{string}} can be any string accepted as an AArch64 target
20696 attribute.  @xref{AArch64 Function Attributes}, for more details
20697 on the permissible values of @code{string}.
20699 @node ARM Pragmas
20700 @subsection ARM Pragmas
20702 The ARM target defines pragmas for controlling the default addition of
20703 @code{long_call} and @code{short_call} attributes to functions.
20704 @xref{Function Attributes}, for information about the effects of these
20705 attributes.
20707 @table @code
20708 @item long_calls
20709 @cindex pragma, long_calls
20710 Set all subsequent functions to have the @code{long_call} attribute.
20712 @item no_long_calls
20713 @cindex pragma, no_long_calls
20714 Set all subsequent functions to have the @code{short_call} attribute.
20716 @item long_calls_off
20717 @cindex pragma, long_calls_off
20718 Do not affect the @code{long_call} or @code{short_call} attributes of
20719 subsequent functions.
20720 @end table
20722 @node M32C Pragmas
20723 @subsection M32C Pragmas
20725 @table @code
20726 @item GCC memregs @var{number}
20727 @cindex pragma, memregs
20728 Overrides the command-line option @code{-memregs=} for the current
20729 file.  Use with care!  This pragma must be before any function in the
20730 file, and mixing different memregs values in different objects may
20731 make them incompatible.  This pragma is useful when a
20732 performance-critical function uses a memreg for temporary values,
20733 as it may allow you to reduce the number of memregs used.
20735 @item ADDRESS @var{name} @var{address}
20736 @cindex pragma, address
20737 For any declared symbols matching @var{name}, this does three things
20738 to that symbol: it forces the symbol to be located at the given
20739 address (a number), it forces the symbol to be volatile, and it
20740 changes the symbol's scope to be static.  This pragma exists for
20741 compatibility with other compilers, but note that the common
20742 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20743 instead).  Example:
20745 @smallexample
20746 #pragma ADDRESS port3 0x103
20747 char port3;
20748 @end smallexample
20750 @end table
20752 @node MeP Pragmas
20753 @subsection MeP Pragmas
20755 @table @code
20757 @item custom io_volatile (on|off)
20758 @cindex pragma, custom io_volatile
20759 Overrides the command-line option @code{-mio-volatile} for the current
20760 file.  Note that for compatibility with future GCC releases, this
20761 option should only be used once before any @code{io} variables in each
20762 file.
20764 @item GCC coprocessor available @var{registers}
20765 @cindex pragma, coprocessor available
20766 Specifies which coprocessor registers are available to the register
20767 allocator.  @var{registers} may be a single register, register range
20768 separated by ellipses, or comma-separated list of those.  Example:
20770 @smallexample
20771 #pragma GCC coprocessor available $c0...$c10, $c28
20772 @end smallexample
20774 @item GCC coprocessor call_saved @var{registers}
20775 @cindex pragma, coprocessor call_saved
20776 Specifies which coprocessor registers are to be saved and restored by
20777 any function using them.  @var{registers} may be a single register,
20778 register range separated by ellipses, or comma-separated list of
20779 those.  Example:
20781 @smallexample
20782 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20783 @end smallexample
20785 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20786 @cindex pragma, coprocessor subclass
20787 Creates and defines a register class.  These register classes can be
20788 used by inline @code{asm} constructs.  @var{registers} may be a single
20789 register, register range separated by ellipses, or comma-separated
20790 list of those.  Example:
20792 @smallexample
20793 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20795 asm ("cpfoo %0" : "=B" (x));
20796 @end smallexample
20798 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20799 @cindex pragma, disinterrupt
20800 For the named functions, the compiler adds code to disable interrupts
20801 for the duration of those functions.  If any functions so named 
20802 are not encountered in the source, a warning is emitted that the pragma is
20803 not used.  Examples:
20805 @smallexample
20806 #pragma disinterrupt foo
20807 #pragma disinterrupt bar, grill
20808 int foo () @{ @dots{} @}
20809 @end smallexample
20811 @item GCC call @var{name} , @var{name} @dots{}
20812 @cindex pragma, call
20813 For the named functions, the compiler always uses a register-indirect
20814 call model when calling the named functions.  Examples:
20816 @smallexample
20817 extern int foo ();
20818 #pragma call foo
20819 @end smallexample
20821 @end table
20823 @node RS/6000 and PowerPC Pragmas
20824 @subsection RS/6000 and PowerPC Pragmas
20826 The RS/6000 and PowerPC targets define one pragma for controlling
20827 whether or not the @code{longcall} attribute is added to function
20828 declarations by default.  This pragma overrides the @option{-mlongcall}
20829 option, but not the @code{longcall} and @code{shortcall} attributes.
20830 @xref{RS/6000 and PowerPC Options}, for more information about when long
20831 calls are and are not necessary.
20833 @table @code
20834 @item longcall (1)
20835 @cindex pragma, longcall
20836 Apply the @code{longcall} attribute to all subsequent function
20837 declarations.
20839 @item longcall (0)
20840 Do not apply the @code{longcall} attribute to subsequent function
20841 declarations.
20842 @end table
20844 @c Describe h8300 pragmas here.
20845 @c Describe sh pragmas here.
20846 @c Describe v850 pragmas here.
20848 @node S/390 Pragmas
20849 @subsection S/390 Pragmas
20851 The pragmas defined by the S/390 target correspond to the S/390
20852 target function attributes and some the additional options:
20854 @table @samp
20855 @item zvector
20856 @itemx no-zvector
20857 @end table
20859 Note that options of the pragma, unlike options of the target
20860 attribute, do change the value of preprocessor macros like
20861 @code{__VEC__}.  They can be specified as below:
20863 @smallexample
20864 #pragma GCC target("string[,string]...")
20865 #pragma GCC target("string"[,"string"]...)
20866 @end smallexample
20868 @node Darwin Pragmas
20869 @subsection Darwin Pragmas
20871 The following pragmas are available for all architectures running the
20872 Darwin operating system.  These are useful for compatibility with other
20873 Mac OS compilers.
20875 @table @code
20876 @item mark @var{tokens}@dots{}
20877 @cindex pragma, mark
20878 This pragma is accepted, but has no effect.
20880 @item options align=@var{alignment}
20881 @cindex pragma, options align
20882 This pragma sets the alignment of fields in structures.  The values of
20883 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
20884 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
20885 properly; to restore the previous setting, use @code{reset} for the
20886 @var{alignment}.
20888 @item segment @var{tokens}@dots{}
20889 @cindex pragma, segment
20890 This pragma is accepted, but has no effect.
20892 @item unused (@var{var} [, @var{var}]@dots{})
20893 @cindex pragma, unused
20894 This pragma declares variables to be possibly unused.  GCC does not
20895 produce warnings for the listed variables.  The effect is similar to
20896 that of the @code{unused} attribute, except that this pragma may appear
20897 anywhere within the variables' scopes.
20898 @end table
20900 @node Solaris Pragmas
20901 @subsection Solaris Pragmas
20903 The Solaris target supports @code{#pragma redefine_extname}
20904 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
20905 @code{#pragma} directives for compatibility with the system compiler.
20907 @table @code
20908 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
20909 @cindex pragma, align
20911 Increase the minimum alignment of each @var{variable} to @var{alignment}.
20912 This is the same as GCC's @code{aligned} attribute @pxref{Variable
20913 Attributes}).  Macro expansion occurs on the arguments to this pragma
20914 when compiling C and Objective-C@.  It does not currently occur when
20915 compiling C++, but this is a bug which may be fixed in a future
20916 release.
20918 @item fini (@var{function} [, @var{function}]...)
20919 @cindex pragma, fini
20921 This pragma causes each listed @var{function} to be called after
20922 main, or during shared module unloading, by adding a call to the
20923 @code{.fini} section.
20925 @item init (@var{function} [, @var{function}]...)
20926 @cindex pragma, init
20928 This pragma causes each listed @var{function} to be called during
20929 initialization (before @code{main}) or during shared module loading, by
20930 adding a call to the @code{.init} section.
20932 @end table
20934 @node Symbol-Renaming Pragmas
20935 @subsection Symbol-Renaming Pragmas
20937 GCC supports a @code{#pragma} directive that changes the name used in
20938 assembly for a given declaration. While this pragma is supported on all
20939 platforms, it is intended primarily to provide compatibility with the
20940 Solaris system headers. This effect can also be achieved using the asm
20941 labels extension (@pxref{Asm Labels}).
20943 @table @code
20944 @item redefine_extname @var{oldname} @var{newname}
20945 @cindex pragma, redefine_extname
20947 This pragma gives the C function @var{oldname} the assembly symbol
20948 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
20949 is defined if this pragma is available (currently on all platforms).
20950 @end table
20952 This pragma and the asm labels extension interact in a complicated
20953 manner.  Here are some corner cases you may want to be aware of:
20955 @enumerate
20956 @item This pragma silently applies only to declarations with external
20957 linkage.  Asm labels do not have this restriction.
20959 @item In C++, this pragma silently applies only to declarations with
20960 ``C'' linkage.  Again, asm labels do not have this restriction.
20962 @item If either of the ways of changing the assembly name of a
20963 declaration are applied to a declaration whose assembly name has
20964 already been determined (either by a previous use of one of these
20965 features, or because the compiler needed the assembly name in order to
20966 generate code), and the new name is different, a warning issues and
20967 the name does not change.
20969 @item The @var{oldname} used by @code{#pragma redefine_extname} is
20970 always the C-language name.
20971 @end enumerate
20973 @node Structure-Layout Pragmas
20974 @subsection Structure-Layout Pragmas
20976 For compatibility with Microsoft Windows compilers, GCC supports a
20977 set of @code{#pragma} directives that change the maximum alignment of
20978 members of structures (other than zero-width bit-fields), unions, and
20979 classes subsequently defined. The @var{n} value below always is required
20980 to be a small power of two and specifies the new alignment in bytes.
20982 @enumerate
20983 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
20984 @item @code{#pragma pack()} sets the alignment to the one that was in
20985 effect when compilation started (see also command-line option
20986 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
20987 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
20988 setting on an internal stack and then optionally sets the new alignment.
20989 @item @code{#pragma pack(pop)} restores the alignment setting to the one
20990 saved at the top of the internal stack (and removes that stack entry).
20991 Note that @code{#pragma pack([@var{n}])} does not influence this internal
20992 stack; thus it is possible to have @code{#pragma pack(push)} followed by
20993 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
20994 @code{#pragma pack(pop)}.
20995 @end enumerate
20997 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
20998 directive which lays out structures and unions subsequently defined as the
20999 documented @code{__attribute__ ((ms_struct))}.
21001 @enumerate
21002 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
21003 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
21004 @item @code{#pragma ms_struct reset} goes back to the default layout.
21005 @end enumerate
21007 Most targets also support the @code{#pragma scalar_storage_order} directive
21008 which lays out structures and unions subsequently defined as the documented
21009 @code{__attribute__ ((scalar_storage_order))}.
21011 @enumerate
21012 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
21013 of the scalar fields to big-endian.
21014 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
21015 of the scalar fields to little-endian.
21016 @item @code{#pragma scalar_storage_order default} goes back to the endianness
21017 that was in effect when compilation started (see also command-line option
21018 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
21019 @end enumerate
21021 @node Weak Pragmas
21022 @subsection Weak Pragmas
21024 For compatibility with SVR4, GCC supports a set of @code{#pragma}
21025 directives for declaring symbols to be weak, and defining weak
21026 aliases.
21028 @table @code
21029 @item #pragma weak @var{symbol}
21030 @cindex pragma, weak
21031 This pragma declares @var{symbol} to be weak, as if the declaration
21032 had the attribute of the same name.  The pragma may appear before
21033 or after the declaration of @var{symbol}.  It is not an error for
21034 @var{symbol} to never be defined at all.
21036 @item #pragma weak @var{symbol1} = @var{symbol2}
21037 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
21038 It is an error if @var{symbol2} is not defined in the current
21039 translation unit.
21040 @end table
21042 @node Diagnostic Pragmas
21043 @subsection Diagnostic Pragmas
21045 GCC allows the user to selectively enable or disable certain types of
21046 diagnostics, and change the kind of the diagnostic.  For example, a
21047 project's policy might require that all sources compile with
21048 @option{-Werror} but certain files might have exceptions allowing
21049 specific types of warnings.  Or, a project might selectively enable
21050 diagnostics and treat them as errors depending on which preprocessor
21051 macros are defined.
21053 @table @code
21054 @item #pragma GCC diagnostic @var{kind} @var{option}
21055 @cindex pragma, diagnostic
21057 Modifies the disposition of a diagnostic.  Note that not all
21058 diagnostics are modifiable; at the moment only warnings (normally
21059 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
21060 Use @option{-fdiagnostics-show-option} to determine which diagnostics
21061 are controllable and which option controls them.
21063 @var{kind} is @samp{error} to treat this diagnostic as an error,
21064 @samp{warning} to treat it like a warning (even if @option{-Werror} is
21065 in effect), or @samp{ignored} if the diagnostic is to be ignored.
21066 @var{option} is a double quoted string that matches the command-line
21067 option.
21069 @smallexample
21070 #pragma GCC diagnostic warning "-Wformat"
21071 #pragma GCC diagnostic error "-Wformat"
21072 #pragma GCC diagnostic ignored "-Wformat"
21073 @end smallexample
21075 Note that these pragmas override any command-line options.  GCC keeps
21076 track of the location of each pragma, and issues diagnostics according
21077 to the state as of that point in the source file.  Thus, pragmas occurring
21078 after a line do not affect diagnostics caused by that line.
21080 @item #pragma GCC diagnostic push
21081 @itemx #pragma GCC diagnostic pop
21083 Causes GCC to remember the state of the diagnostics as of each
21084 @code{push}, and restore to that point at each @code{pop}.  If a
21085 @code{pop} has no matching @code{push}, the command-line options are
21086 restored.
21088 @smallexample
21089 #pragma GCC diagnostic error "-Wuninitialized"
21090   foo(a);                       /* error is given for this one */
21091 #pragma GCC diagnostic push
21092 #pragma GCC diagnostic ignored "-Wuninitialized"
21093   foo(b);                       /* no diagnostic for this one */
21094 #pragma GCC diagnostic pop
21095   foo(c);                       /* error is given for this one */
21096 #pragma GCC diagnostic pop
21097   foo(d);                       /* depends on command-line options */
21098 @end smallexample
21100 @end table
21102 GCC also offers a simple mechanism for printing messages during
21103 compilation.
21105 @table @code
21106 @item #pragma message @var{string}
21107 @cindex pragma, diagnostic
21109 Prints @var{string} as a compiler message on compilation.  The message
21110 is informational only, and is neither a compilation warning nor an error.
21112 @smallexample
21113 #pragma message "Compiling " __FILE__ "..."
21114 @end smallexample
21116 @var{string} may be parenthesized, and is printed with location
21117 information.  For example,
21119 @smallexample
21120 #define DO_PRAGMA(x) _Pragma (#x)
21121 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
21123 TODO(Remember to fix this)
21124 @end smallexample
21126 @noindent
21127 prints @samp{/tmp/file.c:4: note: #pragma message:
21128 TODO - Remember to fix this}.
21130 @end table
21132 @node Visibility Pragmas
21133 @subsection Visibility Pragmas
21135 @table @code
21136 @item #pragma GCC visibility push(@var{visibility})
21137 @itemx #pragma GCC visibility pop
21138 @cindex pragma, visibility
21140 This pragma allows the user to set the visibility for multiple
21141 declarations without having to give each a visibility attribute
21142 (@pxref{Function Attributes}).
21144 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
21145 declarations.  Class members and template specializations are not
21146 affected; if you want to override the visibility for a particular
21147 member or instantiation, you must use an attribute.
21149 @end table
21152 @node Push/Pop Macro Pragmas
21153 @subsection Push/Pop Macro Pragmas
21155 For compatibility with Microsoft Windows compilers, GCC supports
21156 @samp{#pragma push_macro(@var{"macro_name"})}
21157 and @samp{#pragma pop_macro(@var{"macro_name"})}.
21159 @table @code
21160 @item #pragma push_macro(@var{"macro_name"})
21161 @cindex pragma, push_macro
21162 This pragma saves the value of the macro named as @var{macro_name} to
21163 the top of the stack for this macro.
21165 @item #pragma pop_macro(@var{"macro_name"})
21166 @cindex pragma, pop_macro
21167 This pragma sets the value of the macro named as @var{macro_name} to
21168 the value on top of the stack for this macro. If the stack for
21169 @var{macro_name} is empty, the value of the macro remains unchanged.
21170 @end table
21172 For example:
21174 @smallexample
21175 #define X  1
21176 #pragma push_macro("X")
21177 #undef X
21178 #define X -1
21179 #pragma pop_macro("X")
21180 int x [X];
21181 @end smallexample
21183 @noindent
21184 In this example, the definition of X as 1 is saved by @code{#pragma
21185 push_macro} and restored by @code{#pragma pop_macro}.
21187 @node Function Specific Option Pragmas
21188 @subsection Function Specific Option Pragmas
21190 @table @code
21191 @item #pragma GCC target (@var{"string"}...)
21192 @cindex pragma GCC target
21194 This pragma allows you to set target specific options for functions
21195 defined later in the source file.  One or more strings can be
21196 specified.  Each function that is defined after this point is as
21197 if @code{attribute((target("STRING")))} was specified for that
21198 function.  The parenthesis around the options is optional.
21199 @xref{Function Attributes}, for more information about the
21200 @code{target} attribute and the attribute syntax.
21202 The @code{#pragma GCC target} pragma is presently implemented for
21203 x86, PowerPC, and Nios II targets only.
21204 @end table
21206 @table @code
21207 @item #pragma GCC optimize (@var{"string"}...)
21208 @cindex pragma GCC optimize
21210 This pragma allows you to set global optimization options for functions
21211 defined later in the source file.  One or more strings can be
21212 specified.  Each function that is defined after this point is as
21213 if @code{attribute((optimize("STRING")))} was specified for that
21214 function.  The parenthesis around the options is optional.
21215 @xref{Function Attributes}, for more information about the
21216 @code{optimize} attribute and the attribute syntax.
21217 @end table
21219 @table @code
21220 @item #pragma GCC push_options
21221 @itemx #pragma GCC pop_options
21222 @cindex pragma GCC push_options
21223 @cindex pragma GCC pop_options
21225 These pragmas maintain a stack of the current target and optimization
21226 options.  It is intended for include files where you temporarily want
21227 to switch to using a different @samp{#pragma GCC target} or
21228 @samp{#pragma GCC optimize} and then to pop back to the previous
21229 options.
21230 @end table
21232 @table @code
21233 @item #pragma GCC reset_options
21234 @cindex pragma GCC reset_options
21236 This pragma clears the current @code{#pragma GCC target} and
21237 @code{#pragma GCC optimize} to use the default switches as specified
21238 on the command line.
21239 @end table
21241 @node Loop-Specific Pragmas
21242 @subsection Loop-Specific Pragmas
21244 @table @code
21245 @item #pragma GCC ivdep
21246 @cindex pragma GCC ivdep
21247 @end table
21249 With this pragma, the programmer asserts that there are no loop-carried
21250 dependencies which would prevent consecutive iterations of
21251 the following loop from executing concurrently with SIMD
21252 (single instruction multiple data) instructions.
21254 For example, the compiler can only unconditionally vectorize the following
21255 loop with the pragma:
21257 @smallexample
21258 void foo (int n, int *a, int *b, int *c)
21260   int i, j;
21261 #pragma GCC ivdep
21262   for (i = 0; i < n; ++i)
21263     a[i] = b[i] + c[i];
21265 @end smallexample
21267 @noindent
21268 In this example, using the @code{restrict} qualifier had the same
21269 effect. In the following example, that would not be possible. Assume
21270 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
21271 that it can unconditionally vectorize the following loop:
21273 @smallexample
21274 void ignore_vec_dep (int *a, int k, int c, int m)
21276 #pragma GCC ivdep
21277   for (int i = 0; i < m; i++)
21278     a[i] = a[i + k] * c;
21280 @end smallexample
21283 @node Unnamed Fields
21284 @section Unnamed Structure and Union Fields
21285 @cindex @code{struct}
21286 @cindex @code{union}
21288 As permitted by ISO C11 and for compatibility with other compilers,
21289 GCC allows you to define
21290 a structure or union that contains, as fields, structures and unions
21291 without names.  For example:
21293 @smallexample
21294 struct @{
21295   int a;
21296   union @{
21297     int b;
21298     float c;
21299   @};
21300   int d;
21301 @} foo;
21302 @end smallexample
21304 @noindent
21305 In this example, you are able to access members of the unnamed
21306 union with code like @samp{foo.b}.  Note that only unnamed structs and
21307 unions are allowed, you may not have, for example, an unnamed
21308 @code{int}.
21310 You must never create such structures that cause ambiguous field definitions.
21311 For example, in this structure:
21313 @smallexample
21314 struct @{
21315   int a;
21316   struct @{
21317     int a;
21318   @};
21319 @} foo;
21320 @end smallexample
21322 @noindent
21323 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21324 The compiler gives errors for such constructs.
21326 @opindex fms-extensions
21327 Unless @option{-fms-extensions} is used, the unnamed field must be a
21328 structure or union definition without a tag (for example, @samp{struct
21329 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
21330 also be a definition with a tag such as @samp{struct foo @{ int a;
21331 @};}, a reference to a previously defined structure or union such as
21332 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21333 previously defined structure or union type.
21335 @opindex fplan9-extensions
21336 The option @option{-fplan9-extensions} enables
21337 @option{-fms-extensions} as well as two other extensions.  First, a
21338 pointer to a structure is automatically converted to a pointer to an
21339 anonymous field for assignments and function calls.  For example:
21341 @smallexample
21342 struct s1 @{ int a; @};
21343 struct s2 @{ struct s1; @};
21344 extern void f1 (struct s1 *);
21345 void f2 (struct s2 *p) @{ f1 (p); @}
21346 @end smallexample
21348 @noindent
21349 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21350 converted into a pointer to the anonymous field.
21352 Second, when the type of an anonymous field is a @code{typedef} for a
21353 @code{struct} or @code{union}, code may refer to the field using the
21354 name of the @code{typedef}.
21356 @smallexample
21357 typedef struct @{ int a; @} s1;
21358 struct s2 @{ s1; @};
21359 s1 f1 (struct s2 *p) @{ return p->s1; @}
21360 @end smallexample
21362 These usages are only permitted when they are not ambiguous.
21364 @node Thread-Local
21365 @section Thread-Local Storage
21366 @cindex Thread-Local Storage
21367 @cindex @acronym{TLS}
21368 @cindex @code{__thread}
21370 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21371 are allocated such that there is one instance of the variable per extant
21372 thread.  The runtime model GCC uses to implement this originates
21373 in the IA-64 processor-specific ABI, but has since been migrated
21374 to other processors as well.  It requires significant support from
21375 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21376 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21377 is not available everywhere.
21379 At the user level, the extension is visible with a new storage
21380 class keyword: @code{__thread}.  For example:
21382 @smallexample
21383 __thread int i;
21384 extern __thread struct state s;
21385 static __thread char *p;
21386 @end smallexample
21388 The @code{__thread} specifier may be used alone, with the @code{extern}
21389 or @code{static} specifiers, but with no other storage class specifier.
21390 When used with @code{extern} or @code{static}, @code{__thread} must appear
21391 immediately after the other storage class specifier.
21393 The @code{__thread} specifier may be applied to any global, file-scoped
21394 static, function-scoped static, or static data member of a class.  It may
21395 not be applied to block-scoped automatic or non-static data member.
21397 When the address-of operator is applied to a thread-local variable, it is
21398 evaluated at run time and returns the address of the current thread's
21399 instance of that variable.  An address so obtained may be used by any
21400 thread.  When a thread terminates, any pointers to thread-local variables
21401 in that thread become invalid.
21403 No static initialization may refer to the address of a thread-local variable.
21405 In C++, if an initializer is present for a thread-local variable, it must
21406 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21407 standard.
21409 See @uref{http://www.akkadia.org/drepper/tls.pdf,
21410 ELF Handling For Thread-Local Storage} for a detailed explanation of
21411 the four thread-local storage addressing models, and how the runtime
21412 is expected to function.
21414 @menu
21415 * C99 Thread-Local Edits::
21416 * C++98 Thread-Local Edits::
21417 @end menu
21419 @node C99 Thread-Local Edits
21420 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21422 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21423 that document the exact semantics of the language extension.
21425 @itemize @bullet
21426 @item
21427 @cite{5.1.2  Execution environments}
21429 Add new text after paragraph 1
21431 @quotation
21432 Within either execution environment, a @dfn{thread} is a flow of
21433 control within a program.  It is implementation defined whether
21434 or not there may be more than one thread associated with a program.
21435 It is implementation defined how threads beyond the first are
21436 created, the name and type of the function called at thread
21437 startup, and how threads may be terminated.  However, objects
21438 with thread storage duration shall be initialized before thread
21439 startup.
21440 @end quotation
21442 @item
21443 @cite{6.2.4  Storage durations of objects}
21445 Add new text before paragraph 3
21447 @quotation
21448 An object whose identifier is declared with the storage-class
21449 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21450 Its lifetime is the entire execution of the thread, and its
21451 stored value is initialized only once, prior to thread startup.
21452 @end quotation
21454 @item
21455 @cite{6.4.1  Keywords}
21457 Add @code{__thread}.
21459 @item
21460 @cite{6.7.1  Storage-class specifiers}
21462 Add @code{__thread} to the list of storage class specifiers in
21463 paragraph 1.
21465 Change paragraph 2 to
21467 @quotation
21468 With the exception of @code{__thread}, at most one storage-class
21469 specifier may be given [@dots{}].  The @code{__thread} specifier may
21470 be used alone, or immediately following @code{extern} or
21471 @code{static}.
21472 @end quotation
21474 Add new text after paragraph 6
21476 @quotation
21477 The declaration of an identifier for a variable that has
21478 block scope that specifies @code{__thread} shall also
21479 specify either @code{extern} or @code{static}.
21481 The @code{__thread} specifier shall be used only with
21482 variables.
21483 @end quotation
21484 @end itemize
21486 @node C++98 Thread-Local Edits
21487 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21489 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21490 that document the exact semantics of the language extension.
21492 @itemize @bullet
21493 @item
21494 @b{[intro.execution]}
21496 New text after paragraph 4
21498 @quotation
21499 A @dfn{thread} is a flow of control within the abstract machine.
21500 It is implementation defined whether or not there may be more than
21501 one thread.
21502 @end quotation
21504 New text after paragraph 7
21506 @quotation
21507 It is unspecified whether additional action must be taken to
21508 ensure when and whether side effects are visible to other threads.
21509 @end quotation
21511 @item
21512 @b{[lex.key]}
21514 Add @code{__thread}.
21516 @item
21517 @b{[basic.start.main]}
21519 Add after paragraph 5
21521 @quotation
21522 The thread that begins execution at the @code{main} function is called
21523 the @dfn{main thread}.  It is implementation defined how functions
21524 beginning threads other than the main thread are designated or typed.
21525 A function so designated, as well as the @code{main} function, is called
21526 a @dfn{thread startup function}.  It is implementation defined what
21527 happens if a thread startup function returns.  It is implementation
21528 defined what happens to other threads when any thread calls @code{exit}.
21529 @end quotation
21531 @item
21532 @b{[basic.start.init]}
21534 Add after paragraph 4
21536 @quotation
21537 The storage for an object of thread storage duration shall be
21538 statically initialized before the first statement of the thread startup
21539 function.  An object of thread storage duration shall not require
21540 dynamic initialization.
21541 @end quotation
21543 @item
21544 @b{[basic.start.term]}
21546 Add after paragraph 3
21548 @quotation
21549 The type of an object with thread storage duration shall not have a
21550 non-trivial destructor, nor shall it be an array type whose elements
21551 (directly or indirectly) have non-trivial destructors.
21552 @end quotation
21554 @item
21555 @b{[basic.stc]}
21557 Add ``thread storage duration'' to the list in paragraph 1.
21559 Change paragraph 2
21561 @quotation
21562 Thread, static, and automatic storage durations are associated with
21563 objects introduced by declarations [@dots{}].
21564 @end quotation
21566 Add @code{__thread} to the list of specifiers in paragraph 3.
21568 @item
21569 @b{[basic.stc.thread]}
21571 New section before @b{[basic.stc.static]}
21573 @quotation
21574 The keyword @code{__thread} applied to a non-local object gives the
21575 object thread storage duration.
21577 A local variable or class data member declared both @code{static}
21578 and @code{__thread} gives the variable or member thread storage
21579 duration.
21580 @end quotation
21582 @item
21583 @b{[basic.stc.static]}
21585 Change paragraph 1
21587 @quotation
21588 All objects that have neither thread storage duration, dynamic
21589 storage duration nor are local [@dots{}].
21590 @end quotation
21592 @item
21593 @b{[dcl.stc]}
21595 Add @code{__thread} to the list in paragraph 1.
21597 Change paragraph 1
21599 @quotation
21600 With the exception of @code{__thread}, at most one
21601 @var{storage-class-specifier} shall appear in a given
21602 @var{decl-specifier-seq}.  The @code{__thread} specifier may
21603 be used alone, or immediately following the @code{extern} or
21604 @code{static} specifiers.  [@dots{}]
21605 @end quotation
21607 Add after paragraph 5
21609 @quotation
21610 The @code{__thread} specifier can be applied only to the names of objects
21611 and to anonymous unions.
21612 @end quotation
21614 @item
21615 @b{[class.mem]}
21617 Add after paragraph 6
21619 @quotation
21620 Non-@code{static} members shall not be @code{__thread}.
21621 @end quotation
21622 @end itemize
21624 @node Binary constants
21625 @section Binary Constants using the @samp{0b} Prefix
21626 @cindex Binary constants using the @samp{0b} prefix
21628 Integer constants can be written as binary constants, consisting of a
21629 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21630 @samp{0B}.  This is particularly useful in environments that operate a
21631 lot on the bit level (like microcontrollers).
21633 The following statements are identical:
21635 @smallexample
21636 i =       42;
21637 i =     0x2a;
21638 i =      052;
21639 i = 0b101010;
21640 @end smallexample
21642 The type of these constants follows the same rules as for octal or
21643 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21644 can be applied.
21646 @node C++ Extensions
21647 @chapter Extensions to the C++ Language
21648 @cindex extensions, C++ language
21649 @cindex C++ language extensions
21651 The GNU compiler provides these extensions to the C++ language (and you
21652 can also use most of the C language extensions in your C++ programs).  If you
21653 want to write code that checks whether these features are available, you can
21654 test for the GNU compiler the same way as for C programs: check for a
21655 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
21656 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21657 Predefined Macros,cpp,The GNU C Preprocessor}).
21659 @menu
21660 * C++ Volatiles::       What constitutes an access to a volatile object.
21661 * Restricted Pointers:: C99 restricted pointers and references.
21662 * Vague Linkage::       Where G++ puts inlines, vtables and such.
21663 * C++ Interface::       You can use a single C++ header file for both
21664                         declarations and definitions.
21665 * Template Instantiation:: Methods for ensuring that exactly one copy of
21666                         each needed template instantiation is emitted.
21667 * Bound member functions:: You can extract a function pointer to the
21668                         method denoted by a @samp{->*} or @samp{.*} expression.
21669 * C++ Attributes::      Variable, function, and type attributes for C++ only.
21670 * Function Multiversioning::   Declaring multiple function versions.
21671 * Namespace Association:: Strong using-directives for namespace association.
21672 * Type Traits::         Compiler support for type traits.
21673 * C++ Concepts::        Improved support for generic programming.
21674 * Deprecated Features:: Things will disappear from G++.
21675 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21676 @end menu
21678 @node C++ Volatiles
21679 @section When is a Volatile C++ Object Accessed?
21680 @cindex accessing volatiles
21681 @cindex volatile read
21682 @cindex volatile write
21683 @cindex volatile access
21685 The C++ standard differs from the C standard in its treatment of
21686 volatile objects.  It fails to specify what constitutes a volatile
21687 access, except to say that C++ should behave in a similar manner to C
21688 with respect to volatiles, where possible.  However, the different
21689 lvalueness of expressions between C and C++ complicate the behavior.
21690 G++ behaves the same as GCC for volatile access, @xref{C
21691 Extensions,,Volatiles}, for a description of GCC's behavior.
21693 The C and C++ language specifications differ when an object is
21694 accessed in a void context:
21696 @smallexample
21697 volatile int *src = @var{somevalue};
21698 *src;
21699 @end smallexample
21701 The C++ standard specifies that such expressions do not undergo lvalue
21702 to rvalue conversion, and that the type of the dereferenced object may
21703 be incomplete.  The C++ standard does not specify explicitly that it
21704 is lvalue to rvalue conversion that is responsible for causing an
21705 access.  There is reason to believe that it is, because otherwise
21706 certain simple expressions become undefined.  However, because it
21707 would surprise most programmers, G++ treats dereferencing a pointer to
21708 volatile object of complete type as GCC would do for an equivalent
21709 type in C@.  When the object has incomplete type, G++ issues a
21710 warning; if you wish to force an error, you must force a conversion to
21711 rvalue with, for instance, a static cast.
21713 When using a reference to volatile, G++ does not treat equivalent
21714 expressions as accesses to volatiles, but instead issues a warning that
21715 no volatile is accessed.  The rationale for this is that otherwise it
21716 becomes difficult to determine where volatile access occur, and not
21717 possible to ignore the return value from functions returning volatile
21718 references.  Again, if you wish to force a read, cast the reference to
21719 an rvalue.
21721 G++ implements the same behavior as GCC does when assigning to a
21722 volatile object---there is no reread of the assigned-to object, the
21723 assigned rvalue is reused.  Note that in C++ assignment expressions
21724 are lvalues, and if used as an lvalue, the volatile object is
21725 referred to.  For instance, @var{vref} refers to @var{vobj}, as
21726 expected, in the following example:
21728 @smallexample
21729 volatile int vobj;
21730 volatile int &vref = vobj = @var{something};
21731 @end smallexample
21733 @node Restricted Pointers
21734 @section Restricting Pointer Aliasing
21735 @cindex restricted pointers
21736 @cindex restricted references
21737 @cindex restricted this pointer
21739 As with the C front end, G++ understands the C99 feature of restricted pointers,
21740 specified with the @code{__restrict__}, or @code{__restrict} type
21741 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
21742 language flag, @code{restrict} is not a keyword in C++.
21744 In addition to allowing restricted pointers, you can specify restricted
21745 references, which indicate that the reference is not aliased in the local
21746 context.
21748 @smallexample
21749 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21751   /* @r{@dots{}} */
21753 @end smallexample
21755 @noindent
21756 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21757 @var{rref} refers to a (different) unaliased integer.
21759 You may also specify whether a member function's @var{this} pointer is
21760 unaliased by using @code{__restrict__} as a member function qualifier.
21762 @smallexample
21763 void T::fn () __restrict__
21765   /* @r{@dots{}} */
21767 @end smallexample
21769 @noindent
21770 Within the body of @code{T::fn}, @var{this} has the effective
21771 definition @code{T *__restrict__ const this}.  Notice that the
21772 interpretation of a @code{__restrict__} member function qualifier is
21773 different to that of @code{const} or @code{volatile} qualifier, in that it
21774 is applied to the pointer rather than the object.  This is consistent with
21775 other compilers that implement restricted pointers.
21777 As with all outermost parameter qualifiers, @code{__restrict__} is
21778 ignored in function definition matching.  This means you only need to
21779 specify @code{__restrict__} in a function definition, rather than
21780 in a function prototype as well.
21782 @node Vague Linkage
21783 @section Vague Linkage
21784 @cindex vague linkage
21786 There are several constructs in C++ that require space in the object
21787 file but are not clearly tied to a single translation unit.  We say that
21788 these constructs have ``vague linkage''.  Typically such constructs are
21789 emitted wherever they are needed, though sometimes we can be more
21790 clever.
21792 @table @asis
21793 @item Inline Functions
21794 Inline functions are typically defined in a header file which can be
21795 included in many different compilations.  Hopefully they can usually be
21796 inlined, but sometimes an out-of-line copy is necessary, if the address
21797 of the function is taken or if inlining fails.  In general, we emit an
21798 out-of-line copy in all translation units where one is needed.  As an
21799 exception, we only emit inline virtual functions with the vtable, since
21800 it always requires a copy.
21802 Local static variables and string constants used in an inline function
21803 are also considered to have vague linkage, since they must be shared
21804 between all inlined and out-of-line instances of the function.
21806 @item VTables
21807 @cindex vtable
21808 C++ virtual functions are implemented in most compilers using a lookup
21809 table, known as a vtable.  The vtable contains pointers to the virtual
21810 functions provided by a class, and each object of the class contains a
21811 pointer to its vtable (or vtables, in some multiple-inheritance
21812 situations).  If the class declares any non-inline, non-pure virtual
21813 functions, the first one is chosen as the ``key method'' for the class,
21814 and the vtable is only emitted in the translation unit where the key
21815 method is defined.
21817 @emph{Note:} If the chosen key method is later defined as inline, the
21818 vtable is still emitted in every translation unit that defines it.
21819 Make sure that any inline virtuals are declared inline in the class
21820 body, even if they are not defined there.
21822 @item @code{type_info} objects
21823 @cindex @code{type_info}
21824 @cindex RTTI
21825 C++ requires information about types to be written out in order to
21826 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21827 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21828 object is written out along with the vtable so that @samp{dynamic_cast}
21829 can determine the dynamic type of a class object at run time.  For all
21830 other types, we write out the @samp{type_info} object when it is used: when
21831 applying @samp{typeid} to an expression, throwing an object, or
21832 referring to a type in a catch clause or exception specification.
21834 @item Template Instantiations
21835 Most everything in this section also applies to template instantiations,
21836 but there are other options as well.
21837 @xref{Template Instantiation,,Where's the Template?}.
21839 @end table
21841 When used with GNU ld version 2.8 or later on an ELF system such as
21842 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21843 these constructs will be discarded at link time.  This is known as
21844 COMDAT support.
21846 On targets that don't support COMDAT, but do support weak symbols, GCC
21847 uses them.  This way one copy overrides all the others, but
21848 the unused copies still take up space in the executable.
21850 For targets that do not support either COMDAT or weak symbols,
21851 most entities with vague linkage are emitted as local symbols to
21852 avoid duplicate definition errors from the linker.  This does not happen
21853 for local statics in inlines, however, as having multiple copies
21854 almost certainly breaks things.
21856 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21857 another way to control placement of these constructs.
21859 @node C++ Interface
21860 @section C++ Interface and Implementation Pragmas
21862 @cindex interface and implementation headers, C++
21863 @cindex C++ interface and implementation headers
21864 @cindex pragmas, interface and implementation
21866 @code{#pragma interface} and @code{#pragma implementation} provide the
21867 user with a way of explicitly directing the compiler to emit entities
21868 with vague linkage (and debugging information) in a particular
21869 translation unit.
21871 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
21872 by COMDAT support and the ``key method'' heuristic
21873 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
21874 program to grow due to unnecessary out-of-line copies of inline
21875 functions.
21877 @table @code
21878 @item #pragma interface
21879 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
21880 @kindex #pragma interface
21881 Use this directive in @emph{header files} that define object classes, to save
21882 space in most of the object files that use those classes.  Normally,
21883 local copies of certain information (backup copies of inline member
21884 functions, debugging information, and the internal tables that implement
21885 virtual functions) must be kept in each object file that includes class
21886 definitions.  You can use this pragma to avoid such duplication.  When a
21887 header file containing @samp{#pragma interface} is included in a
21888 compilation, this auxiliary information is not generated (unless
21889 the main input source file itself uses @samp{#pragma implementation}).
21890 Instead, the object files contain references to be resolved at link
21891 time.
21893 The second form of this directive is useful for the case where you have
21894 multiple headers with the same name in different directories.  If you
21895 use this form, you must specify the same string to @samp{#pragma
21896 implementation}.
21898 @item #pragma implementation
21899 @itemx #pragma implementation "@var{objects}.h"
21900 @kindex #pragma implementation
21901 Use this pragma in a @emph{main input file}, when you want full output from
21902 included header files to be generated (and made globally visible).  The
21903 included header file, in turn, should use @samp{#pragma interface}.
21904 Backup copies of inline member functions, debugging information, and the
21905 internal tables used to implement virtual functions are all generated in
21906 implementation files.
21908 @cindex implied @code{#pragma implementation}
21909 @cindex @code{#pragma implementation}, implied
21910 @cindex naming convention, implementation headers
21911 If you use @samp{#pragma implementation} with no argument, it applies to
21912 an include file with the same basename@footnote{A file's @dfn{basename}
21913 is the name stripped of all leading path information and of trailing
21914 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
21915 file.  For example, in @file{allclass.cc}, giving just
21916 @samp{#pragma implementation}
21917 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
21919 Use the string argument if you want a single implementation file to
21920 include code from multiple header files.  (You must also use
21921 @samp{#include} to include the header file; @samp{#pragma
21922 implementation} only specifies how to use the file---it doesn't actually
21923 include it.)
21925 There is no way to split up the contents of a single header file into
21926 multiple implementation files.
21927 @end table
21929 @cindex inlining and C++ pragmas
21930 @cindex C++ pragmas, effect on inlining
21931 @cindex pragmas in C++, effect on inlining
21932 @samp{#pragma implementation} and @samp{#pragma interface} also have an
21933 effect on function inlining.
21935 If you define a class in a header file marked with @samp{#pragma
21936 interface}, the effect on an inline function defined in that class is
21937 similar to an explicit @code{extern} declaration---the compiler emits
21938 no code at all to define an independent version of the function.  Its
21939 definition is used only for inlining with its callers.
21941 @opindex fno-implement-inlines
21942 Conversely, when you include the same header file in a main source file
21943 that declares it as @samp{#pragma implementation}, the compiler emits
21944 code for the function itself; this defines a version of the function
21945 that can be found via pointers (or by callers compiled without
21946 inlining).  If all calls to the function can be inlined, you can avoid
21947 emitting the function by compiling with @option{-fno-implement-inlines}.
21948 If any calls are not inlined, you will get linker errors.
21950 @node Template Instantiation
21951 @section Where's the Template?
21952 @cindex template instantiation
21954 C++ templates were the first language feature to require more
21955 intelligence from the environment than was traditionally found on a UNIX
21956 system.  Somehow the compiler and linker have to make sure that each
21957 template instance occurs exactly once in the executable if it is needed,
21958 and not at all otherwise.  There are two basic approaches to this
21959 problem, which are referred to as the Borland model and the Cfront model.
21961 @table @asis
21962 @item Borland model
21963 Borland C++ solved the template instantiation problem by adding the code
21964 equivalent of common blocks to their linker; the compiler emits template
21965 instances in each translation unit that uses them, and the linker
21966 collapses them together.  The advantage of this model is that the linker
21967 only has to consider the object files themselves; there is no external
21968 complexity to worry about.  The disadvantage is that compilation time
21969 is increased because the template code is being compiled repeatedly.
21970 Code written for this model tends to include definitions of all
21971 templates in the header file, since they must be seen to be
21972 instantiated.
21974 @item Cfront model
21975 The AT&T C++ translator, Cfront, solved the template instantiation
21976 problem by creating the notion of a template repository, an
21977 automatically maintained place where template instances are stored.  A
21978 more modern version of the repository works as follows: As individual
21979 object files are built, the compiler places any template definitions and
21980 instantiations encountered in the repository.  At link time, the link
21981 wrapper adds in the objects in the repository and compiles any needed
21982 instances that were not previously emitted.  The advantages of this
21983 model are more optimal compilation speed and the ability to use the
21984 system linker; to implement the Borland model a compiler vendor also
21985 needs to replace the linker.  The disadvantages are vastly increased
21986 complexity, and thus potential for error; for some code this can be
21987 just as transparent, but in practice it can been very difficult to build
21988 multiple programs in one directory and one program in multiple
21989 directories.  Code written for this model tends to separate definitions
21990 of non-inline member templates into a separate file, which should be
21991 compiled separately.
21992 @end table
21994 G++ implements the Borland model on targets where the linker supports it,
21995 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
21996 Otherwise G++ implements neither automatic model.
21998 You have the following options for dealing with template instantiations:
22000 @enumerate
22001 @item
22002 Do nothing.  Code written for the Borland model works fine, but
22003 each translation unit contains instances of each of the templates it
22004 uses.  The duplicate instances will be discarded by the linker, but in
22005 a large program, this can lead to an unacceptable amount of code
22006 duplication in object files or shared libraries.
22008 Duplicate instances of a template can be avoided by defining an explicit
22009 instantiation in one object file, and preventing the compiler from doing
22010 implicit instantiations in any other object files by using an explicit
22011 instantiation declaration, using the @code{extern template} syntax:
22013 @smallexample
22014 extern template int max (int, int);
22015 @end smallexample
22017 This syntax is defined in the C++ 2011 standard, but has been supported by
22018 G++ and other compilers since well before 2011.
22020 Explicit instantiations can be used for the largest or most frequently
22021 duplicated instances, without having to know exactly which other instances
22022 are used in the rest of the program.  You can scatter the explicit
22023 instantiations throughout your program, perhaps putting them in the
22024 translation units where the instances are used or the translation units
22025 that define the templates themselves; you can put all of the explicit
22026 instantiations you need into one big file; or you can create small files
22027 like
22029 @smallexample
22030 #include "Foo.h"
22031 #include "Foo.cc"
22033 template class Foo<int>;
22034 template ostream& operator <<
22035                 (ostream&, const Foo<int>&);
22036 @end smallexample
22038 @noindent
22039 for each of the instances you need, and create a template instantiation
22040 library from those.
22042 This is the simplest option, but also offers flexibility and
22043 fine-grained control when necessary. It is also the most portable
22044 alternative and programs using this approach will work with most modern
22045 compilers.
22047 @item
22048 @opindex frepo
22049 Compile your template-using code with @option{-frepo}.  The compiler
22050 generates files with the extension @samp{.rpo} listing all of the
22051 template instantiations used in the corresponding object files that
22052 could be instantiated there; the link wrapper, @samp{collect2},
22053 then updates the @samp{.rpo} files to tell the compiler where to place
22054 those instantiations and rebuild any affected object files.  The
22055 link-time overhead is negligible after the first pass, as the compiler
22056 continues to place the instantiations in the same files.
22058 This can be a suitable option for application code written for the Borland
22059 model, as it usually just works.  Code written for the Cfront model 
22060 needs to be modified so that the template definitions are available at
22061 one or more points of instantiation; usually this is as simple as adding
22062 @code{#include <tmethods.cc>} to the end of each template header.
22064 For library code, if you want the library to provide all of the template
22065 instantiations it needs, just try to link all of its object files
22066 together; the link will fail, but cause the instantiations to be
22067 generated as a side effect.  Be warned, however, that this may cause
22068 conflicts if multiple libraries try to provide the same instantiations.
22069 For greater control, use explicit instantiation as described in the next
22070 option.
22072 @item
22073 @opindex fno-implicit-templates
22074 Compile your code with @option{-fno-implicit-templates} to disable the
22075 implicit generation of template instances, and explicitly instantiate
22076 all the ones you use.  This approach requires more knowledge of exactly
22077 which instances you need than do the others, but it's less
22078 mysterious and allows greater control if you want to ensure that only
22079 the intended instances are used.
22081 If you are using Cfront-model code, you can probably get away with not
22082 using @option{-fno-implicit-templates} when compiling files that don't
22083 @samp{#include} the member template definitions.
22085 If you use one big file to do the instantiations, you may want to
22086 compile it without @option{-fno-implicit-templates} so you get all of the
22087 instances required by your explicit instantiations (but not by any
22088 other files) without having to specify them as well.
22090 In addition to forward declaration of explicit instantiations
22091 (with @code{extern}), G++ has extended the template instantiation
22092 syntax to support instantiation of the compiler support data for a
22093 template class (i.e.@: the vtable) without instantiating any of its
22094 members (with @code{inline}), and instantiation of only the static data
22095 members of a template class, without the support data or member
22096 functions (with @code{static}):
22098 @smallexample
22099 inline template class Foo<int>;
22100 static template class Foo<int>;
22101 @end smallexample
22102 @end enumerate
22104 @node Bound member functions
22105 @section Extracting the Function Pointer from a Bound Pointer to Member Function
22106 @cindex pmf
22107 @cindex pointer to member function
22108 @cindex bound pointer to member function
22110 In C++, pointer to member functions (PMFs) are implemented using a wide
22111 pointer of sorts to handle all the possible call mechanisms; the PMF
22112 needs to store information about how to adjust the @samp{this} pointer,
22113 and if the function pointed to is virtual, where to find the vtable, and
22114 where in the vtable to look for the member function.  If you are using
22115 PMFs in an inner loop, you should really reconsider that decision.  If
22116 that is not an option, you can extract the pointer to the function that
22117 would be called for a given object/PMF pair and call it directly inside
22118 the inner loop, to save a bit of time.
22120 Note that you still pay the penalty for the call through a
22121 function pointer; on most modern architectures, such a call defeats the
22122 branch prediction features of the CPU@.  This is also true of normal
22123 virtual function calls.
22125 The syntax for this extension is
22127 @smallexample
22128 extern A a;
22129 extern int (A::*fp)();
22130 typedef int (*fptr)(A *);
22132 fptr p = (fptr)(a.*fp);
22133 @end smallexample
22135 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
22136 no object is needed to obtain the address of the function.  They can be
22137 converted to function pointers directly:
22139 @smallexample
22140 fptr p1 = (fptr)(&A::foo);
22141 @end smallexample
22143 @opindex Wno-pmf-conversions
22144 You must specify @option{-Wno-pmf-conversions} to use this extension.
22146 @node C++ Attributes
22147 @section C++-Specific Variable, Function, and Type Attributes
22149 Some attributes only make sense for C++ programs.
22151 @table @code
22152 @item abi_tag ("@var{tag}", ...)
22153 @cindex @code{abi_tag} function attribute
22154 @cindex @code{abi_tag} variable attribute
22155 @cindex @code{abi_tag} type attribute
22156 The @code{abi_tag} attribute can be applied to a function, variable, or class
22157 declaration.  It modifies the mangled name of the entity to
22158 incorporate the tag name, in order to distinguish the function or
22159 class from an earlier version with a different ABI; perhaps the class
22160 has changed size, or the function has a different return type that is
22161 not encoded in the mangled name.
22163 The attribute can also be applied to an inline namespace, but does not
22164 affect the mangled name of the namespace; in this case it is only used
22165 for @option{-Wabi-tag} warnings and automatic tagging of functions and
22166 variables.  Tagging inline namespaces is generally preferable to
22167 tagging individual declarations, but the latter is sometimes
22168 necessary, such as when only certain members of a class need to be
22169 tagged.
22171 The argument can be a list of strings of arbitrary length.  The
22172 strings are sorted on output, so the order of the list is
22173 unimportant.
22175 A redeclaration of an entity must not add new ABI tags,
22176 since doing so would change the mangled name.
22178 The ABI tags apply to a name, so all instantiations and
22179 specializations of a template have the same tags.  The attribute will
22180 be ignored if applied to an explicit specialization or instantiation.
22182 The @option{-Wabi-tag} flag enables a warning about a class which does
22183 not have all the ABI tags used by its subobjects and virtual functions; for users with code
22184 that needs to coexist with an earlier ABI, using this option can help
22185 to find all affected types that need to be tagged.
22187 When a type involving an ABI tag is used as the type of a variable or
22188 return type of a function where that tag is not already present in the
22189 signature of the function, the tag is automatically applied to the
22190 variable or function.  @option{-Wabi-tag} also warns about this
22191 situation; this warning can be avoided by explicitly tagging the
22192 variable or function or moving it into a tagged inline namespace.
22194 @item init_priority (@var{priority})
22195 @cindex @code{init_priority} variable attribute
22197 In Standard C++, objects defined at namespace scope are guaranteed to be
22198 initialized in an order in strict accordance with that of their definitions
22199 @emph{in a given translation unit}.  No guarantee is made for initializations
22200 across translation units.  However, GNU C++ allows users to control the
22201 order of initialization of objects defined at namespace scope with the
22202 @code{init_priority} attribute by specifying a relative @var{priority},
22203 a constant integral expression currently bounded between 101 and 65535
22204 inclusive.  Lower numbers indicate a higher priority.
22206 In the following example, @code{A} would normally be created before
22207 @code{B}, but the @code{init_priority} attribute reverses that order:
22209 @smallexample
22210 Some_Class  A  __attribute__ ((init_priority (2000)));
22211 Some_Class  B  __attribute__ ((init_priority (543)));
22212 @end smallexample
22214 @noindent
22215 Note that the particular values of @var{priority} do not matter; only their
22216 relative ordering.
22218 @item warn_unused
22219 @cindex @code{warn_unused} type attribute
22221 For C++ types with non-trivial constructors and/or destructors it is
22222 impossible for the compiler to determine whether a variable of this
22223 type is truly unused if it is not referenced. This type attribute
22224 informs the compiler that variables of this type should be warned
22225 about if they appear to be unused, just like variables of fundamental
22226 types.
22228 This attribute is appropriate for types which just represent a value,
22229 such as @code{std::string}; it is not appropriate for types which
22230 control a resource, such as @code{std::lock_guard}.
22232 This attribute is also accepted in C, but it is unnecessary because C
22233 does not have constructors or destructors.
22235 @end table
22237 See also @ref{Namespace Association}.
22239 @node Function Multiversioning
22240 @section Function Multiversioning
22241 @cindex function versions
22243 With the GNU C++ front end, for x86 targets, you may specify multiple
22244 versions of a function, where each function is specialized for a
22245 specific target feature.  At runtime, the appropriate version of the
22246 function is automatically executed depending on the characteristics of
22247 the execution platform.  Here is an example.
22249 @smallexample
22250 __attribute__ ((target ("default")))
22251 int foo ()
22253   // The default version of foo.
22254   return 0;
22257 __attribute__ ((target ("sse4.2")))
22258 int foo ()
22260   // foo version for SSE4.2
22261   return 1;
22264 __attribute__ ((target ("arch=atom")))
22265 int foo ()
22267   // foo version for the Intel ATOM processor
22268   return 2;
22271 __attribute__ ((target ("arch=amdfam10")))
22272 int foo ()
22274   // foo version for the AMD Family 0x10 processors.
22275   return 3;
22278 int main ()
22280   int (*p)() = &foo;
22281   assert ((*p) () == foo ());
22282   return 0;
22284 @end smallexample
22286 In the above example, four versions of function foo are created. The
22287 first version of foo with the target attribute "default" is the default
22288 version.  This version gets executed when no other target specific
22289 version qualifies for execution on a particular platform. A new version
22290 of foo is created by using the same function signature but with a
22291 different target string.  Function foo is called or a pointer to it is
22292 taken just like a regular function.  GCC takes care of doing the
22293 dispatching to call the right version at runtime.  Refer to the
22294 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22295 Function Multiversioning} for more details.
22297 @node Namespace Association
22298 @section Namespace Association
22300 @strong{Caution:} The semantics of this extension are equivalent
22301 to C++ 2011 inline namespaces.  Users should use inline namespaces
22302 instead as this extension will be removed in future versions of G++.
22304 A using-directive with @code{__attribute ((strong))} is stronger
22305 than a normal using-directive in two ways:
22307 @itemize @bullet
22308 @item
22309 Templates from the used namespace can be specialized and explicitly
22310 instantiated as though they were members of the using namespace.
22312 @item
22313 The using namespace is considered an associated namespace of all
22314 templates in the used namespace for purposes of argument-dependent
22315 name lookup.
22316 @end itemize
22318 The used namespace must be nested within the using namespace so that
22319 normal unqualified lookup works properly.
22321 This is useful for composing a namespace transparently from
22322 implementation namespaces.  For example:
22324 @smallexample
22325 namespace std @{
22326   namespace debug @{
22327     template <class T> struct A @{ @};
22328   @}
22329   using namespace debug __attribute ((__strong__));
22330   template <> struct A<int> @{ @};   // @r{OK to specialize}
22332   template <class T> void f (A<T>);
22335 int main()
22337   f (std::A<float>());             // @r{lookup finds} std::f
22338   f (std::A<int>());
22340 @end smallexample
22342 @node Type Traits
22343 @section Type Traits
22345 The C++ front end implements syntactic extensions that allow
22346 compile-time determination of 
22347 various characteristics of a type (or of a
22348 pair of types).
22350 @table @code
22351 @item __has_nothrow_assign (type)
22352 If @code{type} is const qualified or is a reference type then the trait is
22353 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22354 is true, else if @code{type} is a cv class or union type with copy assignment
22355 operators that are known not to throw an exception then the trait is true,
22356 else it is false.  Requires: @code{type} shall be a complete type,
22357 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22359 @item __has_nothrow_copy (type)
22360 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22361 @code{type} is a cv class or union type with copy constructors that
22362 are known not to throw an exception then the trait is true, else it is false.
22363 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22364 @code{void}, or an array of unknown bound.
22366 @item __has_nothrow_constructor (type)
22367 If @code{__has_trivial_constructor (type)} is true then the trait is
22368 true, else if @code{type} is a cv class or union type (or array
22369 thereof) with a default constructor that is known not to throw an
22370 exception then the trait is true, else it is false.  Requires:
22371 @code{type} shall be a complete type, (possibly cv-qualified)
22372 @code{void}, or an array of unknown bound.
22374 @item __has_trivial_assign (type)
22375 If @code{type} is const qualified or is a reference type then the trait is
22376 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
22377 true, else if @code{type} is a cv class or union type with a trivial
22378 copy assignment ([class.copy]) then the trait is true, else it is
22379 false.  Requires: @code{type} shall be a complete type, (possibly
22380 cv-qualified) @code{void}, or an array of unknown bound.
22382 @item __has_trivial_copy (type)
22383 If @code{__is_pod (type)} is true or @code{type} is a reference type
22384 then the trait is true, else if @code{type} is a cv class or union type
22385 with a trivial copy constructor ([class.copy]) then the trait
22386 is true, else it is false.  Requires: @code{type} shall be a complete
22387 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22389 @item __has_trivial_constructor (type)
22390 If @code{__is_pod (type)} is true then the trait is true, else if
22391 @code{type} is a cv class or union type (or array thereof) with a
22392 trivial default constructor ([class.ctor]) then the trait is true,
22393 else it is false.  Requires: @code{type} shall be a complete
22394 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22396 @item __has_trivial_destructor (type)
22397 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22398 the trait is true, else if @code{type} is a cv class or union type (or
22399 array thereof) with a trivial destructor ([class.dtor]) then the trait
22400 is true, else it is false.  Requires: @code{type} shall be a complete
22401 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22403 @item __has_virtual_destructor (type)
22404 If @code{type} is a class type with a virtual destructor
22405 ([class.dtor]) then the trait is true, else it is false.  Requires:
22406 @code{type} shall be a complete type, (possibly cv-qualified)
22407 @code{void}, or an array of unknown bound.
22409 @item __is_abstract (type)
22410 If @code{type} is an abstract class ([class.abstract]) then the trait
22411 is true, else it is false.  Requires: @code{type} shall be a complete
22412 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22414 @item __is_base_of (base_type, derived_type)
22415 If @code{base_type} is a base class of @code{derived_type}
22416 ([class.derived]) then the trait is true, otherwise it is false.
22417 Top-level cv qualifications of @code{base_type} and
22418 @code{derived_type} are ignored.  For the purposes of this trait, a
22419 class type is considered is own base.  Requires: if @code{__is_class
22420 (base_type)} and @code{__is_class (derived_type)} are true and
22421 @code{base_type} and @code{derived_type} are not the same type
22422 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22423 type.  A diagnostic is produced if this requirement is not met.
22425 @item __is_class (type)
22426 If @code{type} is a cv class type, and not a union type
22427 ([basic.compound]) the trait is true, else it is false.
22429 @item __is_empty (type)
22430 If @code{__is_class (type)} is false then the trait is false.
22431 Otherwise @code{type} is considered empty if and only if: @code{type}
22432 has no non-static data members, or all non-static data members, if
22433 any, are bit-fields of length 0, and @code{type} has no virtual
22434 members, and @code{type} has no virtual base classes, and @code{type}
22435 has no base classes @code{base_type} for which
22436 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
22437 be a complete type, (possibly cv-qualified) @code{void}, or an array
22438 of unknown bound.
22440 @item __is_enum (type)
22441 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22442 true, else it is false.
22444 @item __is_literal_type (type)
22445 If @code{type} is a literal type ([basic.types]) the trait is
22446 true, else it is false.  Requires: @code{type} shall be a complete type,
22447 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22449 @item __is_pod (type)
22450 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22451 else it is false.  Requires: @code{type} shall be a complete type,
22452 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22454 @item __is_polymorphic (type)
22455 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22456 is true, else it is false.  Requires: @code{type} shall be a complete
22457 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22459 @item __is_standard_layout (type)
22460 If @code{type} is a standard-layout type ([basic.types]) the trait is
22461 true, else it is false.  Requires: @code{type} shall be a complete
22462 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22464 @item __is_trivial (type)
22465 If @code{type} is a trivial type ([basic.types]) the trait is
22466 true, else it is false.  Requires: @code{type} shall be a complete
22467 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22469 @item __is_union (type)
22470 If @code{type} is a cv union type ([basic.compound]) the trait is
22471 true, else it is false.
22473 @item __underlying_type (type)
22474 The underlying type of @code{type}.  Requires: @code{type} shall be
22475 an enumeration type ([dcl.enum]).
22477 @end table
22480 @node C++ Concepts
22481 @section C++ Concepts
22483 C++ concepts provide much-improved support for generic programming. In
22484 particular, they allow the specification of constraints on template arguments.
22485 The constraints are used to extend the usual overloading and partial
22486 specialization capabilities of the language, allowing generic data structures
22487 and algorithms to be ``refined'' based on their properties rather than their
22488 type names.
22490 The following keywords are reserved for concepts.
22492 @table @code
22493 @item assumes
22494 States an expression as an assumption, and if possible, verifies that the
22495 assumption is valid. For example, @code{assume(n > 0)}.
22497 @item axiom
22498 Introduces an axiom definition. Axioms introduce requirements on values.
22500 @item forall
22501 Introduces a universally quantified object in an axiom. For example,
22502 @code{forall (int n) n + 0 == n}).
22504 @item concept
22505 Introduces a concept definition. Concepts are sets of syntactic and semantic
22506 requirements on types and their values.
22508 @item requires
22509 Introduces constraints on template arguments or requirements for a member
22510 function of a class template.
22512 @end table
22514 The front end also exposes a number of internal mechanism that can be used
22515 to simplify the writing of type traits. Note that some of these traits are
22516 likely to be removed in the future.
22518 @table @code
22519 @item __is_same (type1, type2)
22520 A binary type trait: true whenever the type arguments are the same.
22522 @end table
22525 @node Deprecated Features
22526 @section Deprecated Features
22528 In the past, the GNU C++ compiler was extended to experiment with new
22529 features, at a time when the C++ language was still evolving.  Now that
22530 the C++ standard is complete, some of those features are superseded by
22531 superior alternatives.  Using the old features might cause a warning in
22532 some cases that the feature will be dropped in the future.  In other
22533 cases, the feature might be gone already.
22535 While the list below is not exhaustive, it documents some of the options
22536 that are now deprecated:
22538 @table @code
22539 @item -fexternal-templates
22540 @itemx -falt-external-templates
22541 These are two of the many ways for G++ to implement template
22542 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
22543 defines how template definitions have to be organized across
22544 implementation units.  G++ has an implicit instantiation mechanism that
22545 should work just fine for standard-conforming code.
22547 @item -fstrict-prototype
22548 @itemx -fno-strict-prototype
22549 Previously it was possible to use an empty prototype parameter list to
22550 indicate an unspecified number of parameters (like C), rather than no
22551 parameters, as C++ demands.  This feature has been removed, except where
22552 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
22553 @end table
22555 G++ allows a virtual function returning @samp{void *} to be overridden
22556 by one returning a different pointer type.  This extension to the
22557 covariant return type rules is now deprecated and will be removed from a
22558 future version.
22560 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22561 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22562 and are now removed from G++.  Code using these operators should be
22563 modified to use @code{std::min} and @code{std::max} instead.
22565 The named return value extension has been deprecated, and is now
22566 removed from G++.
22568 The use of initializer lists with new expressions has been deprecated,
22569 and is now removed from G++.
22571 Floating and complex non-type template parameters have been deprecated,
22572 and are now removed from G++.
22574 The implicit typename extension has been deprecated and is now
22575 removed from G++.
22577 The use of default arguments in function pointers, function typedefs
22578 and other places where they are not permitted by the standard is
22579 deprecated and will be removed from a future version of G++.
22581 G++ allows floating-point literals to appear in integral constant expressions,
22582 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22583 This extension is deprecated and will be removed from a future version.
22585 G++ allows static data members of const floating-point type to be declared
22586 with an initializer in a class definition. The standard only allows
22587 initializers for static members of const integral types and const
22588 enumeration types so this extension has been deprecated and will be removed
22589 from a future version.
22591 @node Backwards Compatibility
22592 @section Backwards Compatibility
22593 @cindex Backwards Compatibility
22594 @cindex ARM [Annotated C++ Reference Manual]
22596 Now that there is a definitive ISO standard C++, G++ has a specification
22597 to adhere to.  The C++ language evolved over time, and features that
22598 used to be acceptable in previous drafts of the standard, such as the ARM
22599 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
22600 compilation of C++ written to such drafts, G++ contains some backwards
22601 compatibilities.  @emph{All such backwards compatibility features are
22602 liable to disappear in future versions of G++.} They should be considered
22603 deprecated.   @xref{Deprecated Features}.
22605 @table @code
22606 @item For scope
22607 If a variable is declared at for scope, it used to remain in scope until
22608 the end of the scope that contained the for statement (rather than just
22609 within the for scope).  G++ retains this, but issues a warning, if such a
22610 variable is accessed outside the for scope.
22612 @item Implicit C language
22613 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22614 scope to set the language.  On such systems, all header files are
22615 implicitly scoped inside a C language scope.  Also, an empty prototype
22616 @code{()} is treated as an unspecified number of arguments, rather
22617 than no arguments, as C++ demands.
22618 @end table
22620 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
22621 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr