PR tree-optimization/65217
[official-gcc.git] / gcc / doc / extend.texi
blobc7a0a3fdd2f6224b3c0beffbe89aa09f01f04a23
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Label Attributes::    Specifying attributes on labels.
60 * Attribute Syntax::    Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments::        C++ comments are recognized.
63 * Dollar Signs::        Dollar sign is allowed in identifiers.
64 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes::     Specifying attributes of types.
67 * Alignment::           Inquiring about the alignment of a type or variable.
68 * Inline::              Defining inline functions (as fast as macros).
69 * Volatiles::           What constitutes an access to a volatile object.
70 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
71 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
72 * Incomplete Enums::    @code{enum foo;}, with details to follow.
73 * Function Names::      Printable strings which are the name of the current
74                         function.
75 * Return Address::      Getting the return or frame address of a function.
76 * Vector Extensions::   Using vector instructions through built-in functions.
77 * Offsetof::            Special syntax for implementing @code{offsetof}.
78 * __sync Builtins::     Legacy built-in functions for atomic memory access.
79 * __atomic Builtins::   Atomic built-in functions with memory model.
80 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
81                         arithmetic overflow checking.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84                         checking.
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
87 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
162 @smallexample
163         A a;
165         (@{a;@}).Foo ()
166 @end smallexample
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186 void foo ()
188   macro (X ());
189   function (X ());
191 @end smallexample
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
238 A local label declaration looks like this:
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
244 @noindent
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
282 This could also be written using a statement expression:
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
300 @end smallexample
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
329 @smallexample
330 goto *ptr;
331 @end smallexample
333 @noindent
334 Any expression of type @code{void *} is allowed.
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
343 @noindent
344 Then you can select a label with indexing, like this:
346 @smallexample
347 goto *array[i];
348 @end smallexample
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
368 An alternate way to write the above example is
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
404 @smallexample
405 @group
406 foo (double a, double b)
408   double square (double z) @{ return z * z; @}
410   return square (a) + square (b);
412 @end group
413 @end smallexample
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @end group
432 @end smallexample
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
441 @smallexample
442 hack (int *array, int size)
444   void store (int index, int value)
445     @{ array[index] = value; @}
447   intermediate (store, size);
449 @end smallexample
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
499 @end group
500 @end smallexample
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
507 @smallexample
508 bar (int *array, int offset, int size)
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
521 @end smallexample
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
602 @end smallexample
603 @end deftypefn
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
634   return open (path, oflag, __builtin_va_arg_pack ());
636 #endif
637 @end smallexample
638 @end deftypefn
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
661 Here is an example with a typename as the argument:
663 @smallexample
664 typeof (int *)
665 @end smallexample
667 @noindent
668 Here the type described is that of pointers to @code{int}.
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
708 @noindent
709 Some more examples of the use of @code{typeof}:
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
719 @item
720 This declares @code{y} as an array of such values.
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
726 @item
727 This declares @code{y} as an array of pointers to characters:
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
733 @noindent
734 It is equivalent to the following traditional C declaration:
736 @smallexample
737 char *y[4];
738 @end smallexample
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
748 @noindent
749 Now the declaration can be rewritten this way:
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
789 @node Conditionals
790 @section Conditionals with Omitted Operands
791 @cindex conditional expressions, extensions
792 @cindex omitted middle-operands
793 @cindex middle-operands, omitted
794 @cindex extensions, @code{?:}
795 @cindex @code{?:} extensions
797 The middle operand in a conditional expression may be omitted.  Then
798 if the first operand is nonzero, its value is the value of the conditional
799 expression.
801 Therefore, the expression
803 @smallexample
804 x ? : y
805 @end smallexample
807 @noindent
808 has the value of @code{x} if that is nonzero; otherwise, the value of
809 @code{y}.
811 This example is perfectly equivalent to
813 @smallexample
814 x ? x : y
815 @end smallexample
817 @cindex side effect in @code{?:}
818 @cindex @code{?:} side effect
819 @noindent
820 In this simple case, the ability to omit the middle operand is not
821 especially useful.  When it becomes useful is when the first operand does,
822 or may (if it is a macro argument), contain a side effect.  Then repeating
823 the operand in the middle would perform the side effect twice.  Omitting
824 the middle operand uses the value already computed without the undesirable
825 effects of recomputing it.
827 @node __int128
828 @section 128-bit Integers
829 @cindex @code{__int128} data types
831 As an extension the integer scalar type @code{__int128} is supported for
832 targets which have an integer mode wide enough to hold 128 bits.
833 Simply write @code{__int128} for a signed 128-bit integer, or
834 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
835 support in GCC for expressing an integer constant of type @code{__int128}
836 for targets with @code{long long} integer less than 128 bits wide.
838 @node Long Long
839 @section Double-Word Integers
840 @cindex @code{long long} data types
841 @cindex double-word arithmetic
842 @cindex multiprecision arithmetic
843 @cindex @code{LL} integer suffix
844 @cindex @code{ULL} integer suffix
846 ISO C99 supports data types for integers that are at least 64 bits wide,
847 and as an extension GCC supports them in C90 mode and in C++.
848 Simply write @code{long long int} for a signed integer, or
849 @code{unsigned long long int} for an unsigned integer.  To make an
850 integer constant of type @code{long long int}, add the suffix @samp{LL}
851 to the integer.  To make an integer constant of type @code{unsigned long
852 long int}, add the suffix @samp{ULL} to the integer.
854 You can use these types in arithmetic like any other integer types.
855 Addition, subtraction, and bitwise boolean operations on these types
856 are open-coded on all types of machines.  Multiplication is open-coded
857 if the machine supports a fullword-to-doubleword widening multiply
858 instruction.  Division and shifts are open-coded only on machines that
859 provide special support.  The operations that are not open-coded use
860 special library routines that come with GCC@.
862 There may be pitfalls when you use @code{long long} types for function
863 arguments without function prototypes.  If a function
864 expects type @code{int} for its argument, and you pass a value of type
865 @code{long long int}, confusion results because the caller and the
866 subroutine disagree about the number of bytes for the argument.
867 Likewise, if the function expects @code{long long int} and you pass
868 @code{int}.  The best way to avoid such problems is to use prototypes.
870 @node Complex
871 @section Complex Numbers
872 @cindex complex numbers
873 @cindex @code{_Complex} keyword
874 @cindex @code{__complex__} keyword
876 ISO C99 supports complex floating data types, and as an extension GCC
877 supports them in C90 mode and in C++.  GCC also supports complex integer data
878 types which are not part of ISO C99.  You can declare complex types
879 using the keyword @code{_Complex}.  As an extension, the older GNU
880 keyword @code{__complex__} is also supported.
882 For example, @samp{_Complex double x;} declares @code{x} as a
883 variable whose real part and imaginary part are both of type
884 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
885 have real and imaginary parts of type @code{short int}; this is not
886 likely to be useful, but it shows that the set of complex types is
887 complete.
889 To write a constant with a complex data type, use the suffix @samp{i} or
890 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
891 has type @code{_Complex float} and @code{3i} has type
892 @code{_Complex int}.  Such a constant always has a pure imaginary
893 value, but you can form any complex value you like by adding one to a
894 real constant.  This is a GNU extension; if you have an ISO C99
895 conforming C library (such as the GNU C Library), and want to construct complex
896 constants of floating type, you should include @code{<complex.h>} and
897 use the macros @code{I} or @code{_Complex_I} instead.
899 @cindex @code{__real__} keyword
900 @cindex @code{__imag__} keyword
901 To extract the real part of a complex-valued expression @var{exp}, write
902 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
903 extract the imaginary part.  This is a GNU extension; for values of
904 floating type, you should use the ISO C99 functions @code{crealf},
905 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
906 @code{cimagl}, declared in @code{<complex.h>} and also provided as
907 built-in functions by GCC@.
909 @cindex complex conjugation
910 The operator @samp{~} performs complex conjugation when used on a value
911 with a complex type.  This is a GNU extension; for values of
912 floating type, you should use the ISO C99 functions @code{conjf},
913 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
914 provided as built-in functions by GCC@.
916 GCC can allocate complex automatic variables in a noncontiguous
917 fashion; it's even possible for the real part to be in a register while
918 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
919 debug info format can represent this, so use of DWARF 2 is recommended.
920 If you are using the stabs debug info format, GCC describes a noncontiguous
921 complex variable as if it were two separate variables of noncomplex type.
922 If the variable's actual name is @code{foo}, the two fictitious
923 variables are named @code{foo$real} and @code{foo$imag}.  You can
924 examine and set these two fictitious variables with your debugger.
926 @node Floating Types
927 @section Additional Floating Types
928 @cindex additional floating types
929 @cindex @code{__float80} data type
930 @cindex @code{__float128} data type
931 @cindex @code{w} floating point suffix
932 @cindex @code{q} floating point suffix
933 @cindex @code{W} floating point suffix
934 @cindex @code{Q} floating point suffix
936 As an extension, GNU C supports additional floating
937 types, @code{__float80} and @code{__float128} to support 80-bit
938 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
939 Support for additional types includes the arithmetic operators:
940 add, subtract, multiply, divide; unary arithmetic operators;
941 relational operators; equality operators; and conversions to and from
942 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
943 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
944 for @code{_float128}.  You can declare complex types using the
945 corresponding internal complex type, @code{XCmode} for @code{__float80}
946 type and @code{TCmode} for @code{__float128} type:
948 @smallexample
949 typedef _Complex float __attribute__((mode(TC))) _Complex128;
950 typedef _Complex float __attribute__((mode(XC))) _Complex80;
951 @end smallexample
953 Not all targets support additional floating-point types.  @code{__float80}
954 and @code{__float128} types are supported on x86 and IA-64 targets.
955 The @code{__float128} type is supported on hppa HP-UX targets.
957 @node Half-Precision
958 @section Half-Precision Floating Point
959 @cindex half-precision floating point
960 @cindex @code{__fp16} data type
962 On ARM targets, GCC supports half-precision (16-bit) floating point via
963 the @code{__fp16} type.  You must enable this type explicitly
964 with the @option{-mfp16-format} command-line option in order to use it.
966 ARM supports two incompatible representations for half-precision
967 floating-point values.  You must choose one of the representations and
968 use it consistently in your program.
970 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
971 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
972 There are 11 bits of significand precision, approximately 3
973 decimal digits.
975 Specifying @option{-mfp16-format=alternative} selects the ARM
976 alternative format.  This representation is similar to the IEEE
977 format, but does not support infinities or NaNs.  Instead, the range
978 of exponents is extended, so that this format can represent normalized
979 values in the range of @math{2^{-14}} to 131008.
981 The @code{__fp16} type is a storage format only.  For purposes
982 of arithmetic and other operations, @code{__fp16} values in C or C++
983 expressions are automatically promoted to @code{float}.  In addition,
984 you cannot declare a function with a return value or parameters
985 of type @code{__fp16}.
987 Note that conversions from @code{double} to @code{__fp16}
988 involve an intermediate conversion to @code{float}.  Because
989 of rounding, this can sometimes produce a different result than a
990 direct conversion.
992 ARM provides hardware support for conversions between
993 @code{__fp16} and @code{float} values
994 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
995 code using these hardware instructions if you compile with
996 options to select an FPU that provides them;
997 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
998 in addition to the @option{-mfp16-format} option to select
999 a half-precision format.
1001 Language-level support for the @code{__fp16} data type is
1002 independent of whether GCC generates code using hardware floating-point
1003 instructions.  In cases where hardware support is not specified, GCC
1004 implements conversions between @code{__fp16} and @code{float} values
1005 as library calls.
1007 @node Decimal Float
1008 @section Decimal Floating Types
1009 @cindex decimal floating types
1010 @cindex @code{_Decimal32} data type
1011 @cindex @code{_Decimal64} data type
1012 @cindex @code{_Decimal128} data type
1013 @cindex @code{df} integer suffix
1014 @cindex @code{dd} integer suffix
1015 @cindex @code{dl} integer suffix
1016 @cindex @code{DF} integer suffix
1017 @cindex @code{DD} integer suffix
1018 @cindex @code{DL} integer suffix
1020 As an extension, GNU C supports decimal floating types as
1021 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1022 floating types in GCC will evolve as the draft technical report changes.
1023 Calling conventions for any target might also change.  Not all targets
1024 support decimal floating types.
1026 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1027 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1028 @code{float}, @code{double}, and @code{long double} whose radix is not
1029 specified by the C standard but is usually two.
1031 Support for decimal floating types includes the arithmetic operators
1032 add, subtract, multiply, divide; unary arithmetic operators;
1033 relational operators; equality operators; and conversions to and from
1034 integer and other floating types.  Use a suffix @samp{df} or
1035 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1036 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1037 @code{_Decimal128}.
1039 GCC support of decimal float as specified by the draft technical report
1040 is incomplete:
1042 @itemize @bullet
1043 @item
1044 When the value of a decimal floating type cannot be represented in the
1045 integer type to which it is being converted, the result is undefined
1046 rather than the result value specified by the draft technical report.
1048 @item
1049 GCC does not provide the C library functionality associated with
1050 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1051 @file{wchar.h}, which must come from a separate C library implementation.
1052 Because of this the GNU C compiler does not define macro
1053 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1054 the technical report.
1055 @end itemize
1057 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1058 are supported by the DWARF 2 debug information format.
1060 @node Hex Floats
1061 @section Hex Floats
1062 @cindex hex floats
1064 ISO C99 supports floating-point numbers written not only in the usual
1065 decimal notation, such as @code{1.55e1}, but also numbers such as
1066 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1067 supports this in C90 mode (except in some cases when strictly
1068 conforming) and in C++.  In that format the
1069 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1070 mandatory.  The exponent is a decimal number that indicates the power of
1071 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1072 @tex
1073 $1 {15\over16}$,
1074 @end tex
1075 @ifnottex
1076 1 15/16,
1077 @end ifnottex
1078 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1079 is the same as @code{1.55e1}.
1081 Unlike for floating-point numbers in the decimal notation the exponent
1082 is always required in the hexadecimal notation.  Otherwise the compiler
1083 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1084 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1085 extension for floating-point constants of type @code{float}.
1087 @node Fixed-Point
1088 @section Fixed-Point Types
1089 @cindex fixed-point types
1090 @cindex @code{_Fract} data type
1091 @cindex @code{_Accum} data type
1092 @cindex @code{_Sat} data type
1093 @cindex @code{hr} fixed-suffix
1094 @cindex @code{r} fixed-suffix
1095 @cindex @code{lr} fixed-suffix
1096 @cindex @code{llr} fixed-suffix
1097 @cindex @code{uhr} fixed-suffix
1098 @cindex @code{ur} fixed-suffix
1099 @cindex @code{ulr} fixed-suffix
1100 @cindex @code{ullr} fixed-suffix
1101 @cindex @code{hk} fixed-suffix
1102 @cindex @code{k} fixed-suffix
1103 @cindex @code{lk} fixed-suffix
1104 @cindex @code{llk} fixed-suffix
1105 @cindex @code{uhk} fixed-suffix
1106 @cindex @code{uk} fixed-suffix
1107 @cindex @code{ulk} fixed-suffix
1108 @cindex @code{ullk} fixed-suffix
1109 @cindex @code{HR} fixed-suffix
1110 @cindex @code{R} fixed-suffix
1111 @cindex @code{LR} fixed-suffix
1112 @cindex @code{LLR} fixed-suffix
1113 @cindex @code{UHR} fixed-suffix
1114 @cindex @code{UR} fixed-suffix
1115 @cindex @code{ULR} fixed-suffix
1116 @cindex @code{ULLR} fixed-suffix
1117 @cindex @code{HK} fixed-suffix
1118 @cindex @code{K} fixed-suffix
1119 @cindex @code{LK} fixed-suffix
1120 @cindex @code{LLK} fixed-suffix
1121 @cindex @code{UHK} fixed-suffix
1122 @cindex @code{UK} fixed-suffix
1123 @cindex @code{ULK} fixed-suffix
1124 @cindex @code{ULLK} fixed-suffix
1126 As an extension, GNU C supports fixed-point types as
1127 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1128 types in GCC will evolve as the draft technical report changes.
1129 Calling conventions for any target might also change.  Not all targets
1130 support fixed-point types.
1132 The fixed-point types are
1133 @code{short _Fract},
1134 @code{_Fract},
1135 @code{long _Fract},
1136 @code{long long _Fract},
1137 @code{unsigned short _Fract},
1138 @code{unsigned _Fract},
1139 @code{unsigned long _Fract},
1140 @code{unsigned long long _Fract},
1141 @code{_Sat short _Fract},
1142 @code{_Sat _Fract},
1143 @code{_Sat long _Fract},
1144 @code{_Sat long long _Fract},
1145 @code{_Sat unsigned short _Fract},
1146 @code{_Sat unsigned _Fract},
1147 @code{_Sat unsigned long _Fract},
1148 @code{_Sat unsigned long long _Fract},
1149 @code{short _Accum},
1150 @code{_Accum},
1151 @code{long _Accum},
1152 @code{long long _Accum},
1153 @code{unsigned short _Accum},
1154 @code{unsigned _Accum},
1155 @code{unsigned long _Accum},
1156 @code{unsigned long long _Accum},
1157 @code{_Sat short _Accum},
1158 @code{_Sat _Accum},
1159 @code{_Sat long _Accum},
1160 @code{_Sat long long _Accum},
1161 @code{_Sat unsigned short _Accum},
1162 @code{_Sat unsigned _Accum},
1163 @code{_Sat unsigned long _Accum},
1164 @code{_Sat unsigned long long _Accum}.
1166 Fixed-point data values contain fractional and optional integral parts.
1167 The format of fixed-point data varies and depends on the target machine.
1169 Support for fixed-point types includes:
1170 @itemize @bullet
1171 @item
1172 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1173 @item
1174 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1175 @item
1176 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1177 @item
1178 binary shift operators (@code{<<}, @code{>>})
1179 @item
1180 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1181 @item
1182 equality operators (@code{==}, @code{!=})
1183 @item
1184 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1185 @code{<<=}, @code{>>=})
1186 @item
1187 conversions to and from integer, floating-point, or fixed-point types
1188 @end itemize
1190 Use a suffix in a fixed-point literal constant:
1191 @itemize
1192 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1193 @code{_Sat short _Fract}
1194 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1195 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1196 @code{_Sat long _Fract}
1197 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1198 @code{_Sat long long _Fract}
1199 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1200 @code{_Sat unsigned short _Fract}
1201 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1202 @code{_Sat unsigned _Fract}
1203 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1204 @code{_Sat unsigned long _Fract}
1205 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1206 and @code{_Sat unsigned long long _Fract}
1207 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1208 @code{_Sat short _Accum}
1209 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1210 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1211 @code{_Sat long _Accum}
1212 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1213 @code{_Sat long long _Accum}
1214 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1215 @code{_Sat unsigned short _Accum}
1216 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1217 @code{_Sat unsigned _Accum}
1218 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1219 @code{_Sat unsigned long _Accum}
1220 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1221 and @code{_Sat unsigned long long _Accum}
1222 @end itemize
1224 GCC support of fixed-point types as specified by the draft technical report
1225 is incomplete:
1227 @itemize @bullet
1228 @item
1229 Pragmas to control overflow and rounding behaviors are not implemented.
1230 @end itemize
1232 Fixed-point types are supported by the DWARF 2 debug information format.
1234 @node Named Address Spaces
1235 @section Named Address Spaces
1236 @cindex Named Address Spaces
1238 As an extension, GNU C supports named address spaces as
1239 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1240 address spaces in GCC will evolve as the draft technical report
1241 changes.  Calling conventions for any target might also change.  At
1242 present, only the AVR, SPU, M32C, and RL78 targets support address
1243 spaces other than the generic address space.
1245 Address space identifiers may be used exactly like any other C type
1246 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1247 document for more details.
1249 @anchor{AVR Named Address Spaces}
1250 @subsection AVR Named Address Spaces
1252 On the AVR target, there are several address spaces that can be used
1253 in order to put read-only data into the flash memory and access that
1254 data by means of the special instructions @code{LPM} or @code{ELPM}
1255 needed to read from flash.
1257 Per default, any data including read-only data is located in RAM
1258 (the generic address space) so that non-generic address spaces are
1259 needed to locate read-only data in flash memory
1260 @emph{and} to generate the right instructions to access this data
1261 without using (inline) assembler code.
1263 @table @code
1264 @item __flash
1265 @cindex @code{__flash} AVR Named Address Spaces
1266 The @code{__flash} qualifier locates data in the
1267 @code{.progmem.data} section. Data is read using the @code{LPM}
1268 instruction. Pointers to this address space are 16 bits wide.
1270 @item __flash1
1271 @itemx __flash2
1272 @itemx __flash3
1273 @itemx __flash4
1274 @itemx __flash5
1275 @cindex @code{__flash1} AVR Named Address Spaces
1276 @cindex @code{__flash2} AVR Named Address Spaces
1277 @cindex @code{__flash3} AVR Named Address Spaces
1278 @cindex @code{__flash4} AVR Named Address Spaces
1279 @cindex @code{__flash5} AVR Named Address Spaces
1280 These are 16-bit address spaces locating data in section
1281 @code{.progmem@var{N}.data} where @var{N} refers to
1282 address space @code{__flash@var{N}}.
1283 The compiler sets the @code{RAMPZ} segment register appropriately 
1284 before reading data by means of the @code{ELPM} instruction.
1286 @item __memx
1287 @cindex @code{__memx} AVR Named Address Spaces
1288 This is a 24-bit address space that linearizes flash and RAM:
1289 If the high bit of the address is set, data is read from
1290 RAM using the lower two bytes as RAM address.
1291 If the high bit of the address is clear, data is read from flash
1292 with @code{RAMPZ} set according to the high byte of the address.
1293 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1295 Objects in this address space are located in @code{.progmemx.data}.
1296 @end table
1298 @b{Example}
1300 @smallexample
1301 char my_read (const __flash char ** p)
1303     /* p is a pointer to RAM that points to a pointer to flash.
1304        The first indirection of p reads that flash pointer
1305        from RAM and the second indirection reads a char from this
1306        flash address.  */
1308     return **p;
1311 /* Locate array[] in flash memory */
1312 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1314 int i = 1;
1316 int main (void)
1318    /* Return 17 by reading from flash memory */
1319    return array[array[i]];
1321 @end smallexample
1323 @noindent
1324 For each named address space supported by avr-gcc there is an equally
1325 named but uppercase built-in macro defined. 
1326 The purpose is to facilitate testing if respective address space
1327 support is available or not:
1329 @smallexample
1330 #ifdef __FLASH
1331 const __flash int var = 1;
1333 int read_var (void)
1335     return var;
1337 #else
1338 #include <avr/pgmspace.h> /* From AVR-LibC */
1340 const int var PROGMEM = 1;
1342 int read_var (void)
1344     return (int) pgm_read_word (&var);
1346 #endif /* __FLASH */
1347 @end smallexample
1349 @noindent
1350 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1351 locates data in flash but
1352 accesses to these data read from generic address space, i.e.@:
1353 from RAM,
1354 so that you need special accessors like @code{pgm_read_byte}
1355 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1356 together with attribute @code{progmem}.
1358 @noindent
1359 @b{Limitations and caveats}
1361 @itemize
1362 @item
1363 Reading across the 64@tie{}KiB section boundary of
1364 the @code{__flash} or @code{__flash@var{N}} address spaces
1365 shows undefined behavior. The only address space that
1366 supports reading across the 64@tie{}KiB flash segment boundaries is
1367 @code{__memx}.
1369 @item
1370 If you use one of the @code{__flash@var{N}} address spaces
1371 you must arrange your linker script to locate the
1372 @code{.progmem@var{N}.data} sections according to your needs.
1374 @item
1375 Any data or pointers to the non-generic address spaces must
1376 be qualified as @code{const}, i.e.@: as read-only data.
1377 This still applies if the data in one of these address
1378 spaces like software version number or calibration lookup table are intended to
1379 be changed after load time by, say, a boot loader. In this case
1380 the right qualification is @code{const} @code{volatile} so that the compiler
1381 must not optimize away known values or insert them
1382 as immediates into operands of instructions.
1384 @item
1385 The following code initializes a variable @code{pfoo}
1386 located in static storage with a 24-bit address:
1387 @smallexample
1388 extern const __memx char foo;
1389 const __memx void *pfoo = &foo;
1390 @end smallexample
1392 @noindent
1393 Such code requires at least binutils 2.23, see
1394 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1396 @end itemize
1398 @subsection M32C Named Address Spaces
1399 @cindex @code{__far} M32C Named Address Spaces
1401 On the M32C target, with the R8C and M16C CPU variants, variables
1402 qualified with @code{__far} are accessed using 32-bit addresses in
1403 order to access memory beyond the first 64@tie{}Ki bytes.  If
1404 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1405 effect.
1407 @subsection RL78 Named Address Spaces
1408 @cindex @code{__far} RL78 Named Address Spaces
1410 On the RL78 target, variables qualified with @code{__far} are accessed
1411 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1412 addresses.  Non-far variables are assumed to appear in the topmost
1413 64@tie{}KiB of the address space.
1415 @subsection SPU Named Address Spaces
1416 @cindex @code{__ea} SPU Named Address Spaces
1418 On the SPU target variables may be declared as
1419 belonging to another address space by qualifying the type with the
1420 @code{__ea} address space identifier:
1422 @smallexample
1423 extern int __ea i;
1424 @end smallexample
1426 @noindent 
1427 The compiler generates special code to access the variable @code{i}.
1428 It may use runtime library
1429 support, or generate special machine instructions to access that address
1430 space.
1432 @node Zero Length
1433 @section Arrays of Length Zero
1434 @cindex arrays of length zero
1435 @cindex zero-length arrays
1436 @cindex length-zero arrays
1437 @cindex flexible array members
1439 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1440 last element of a structure that is really a header for a variable-length
1441 object:
1443 @smallexample
1444 struct line @{
1445   int length;
1446   char contents[0];
1449 struct line *thisline = (struct line *)
1450   malloc (sizeof (struct line) + this_length);
1451 thisline->length = this_length;
1452 @end smallexample
1454 In ISO C90, you would have to give @code{contents} a length of 1, which
1455 means either you waste space or complicate the argument to @code{malloc}.
1457 In ISO C99, you would use a @dfn{flexible array member}, which is
1458 slightly different in syntax and semantics:
1460 @itemize @bullet
1461 @item
1462 Flexible array members are written as @code{contents[]} without
1463 the @code{0}.
1465 @item
1466 Flexible array members have incomplete type, and so the @code{sizeof}
1467 operator may not be applied.  As a quirk of the original implementation
1468 of zero-length arrays, @code{sizeof} evaluates to zero.
1470 @item
1471 Flexible array members may only appear as the last member of a
1472 @code{struct} that is otherwise non-empty.
1474 @item
1475 A structure containing a flexible array member, or a union containing
1476 such a structure (possibly recursively), may not be a member of a
1477 structure or an element of an array.  (However, these uses are
1478 permitted by GCC as extensions.)
1479 @end itemize
1481 Non-empty initialization of zero-length
1482 arrays is treated like any case where there are more initializer
1483 elements than the array holds, in that a suitable warning about ``excess
1484 elements in array'' is given, and the excess elements (all of them, in
1485 this case) are ignored.
1487 GCC allows static initialization of flexible array members.
1488 This is equivalent to defining a new structure containing the original
1489 structure followed by an array of sufficient size to contain the data.
1490 E.g.@: in the following, @code{f1} is constructed as if it were declared
1491 like @code{f2}.
1493 @smallexample
1494 struct f1 @{
1495   int x; int y[];
1496 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1498 struct f2 @{
1499   struct f1 f1; int data[3];
1500 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1501 @end smallexample
1503 @noindent
1504 The convenience of this extension is that @code{f1} has the desired
1505 type, eliminating the need to consistently refer to @code{f2.f1}.
1507 This has symmetry with normal static arrays, in that an array of
1508 unknown size is also written with @code{[]}.
1510 Of course, this extension only makes sense if the extra data comes at
1511 the end of a top-level object, as otherwise we would be overwriting
1512 data at subsequent offsets.  To avoid undue complication and confusion
1513 with initialization of deeply nested arrays, we simply disallow any
1514 non-empty initialization except when the structure is the top-level
1515 object.  For example:
1517 @smallexample
1518 struct foo @{ int x; int y[]; @};
1519 struct bar @{ struct foo z; @};
1521 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1522 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1523 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1524 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1525 @end smallexample
1527 @node Empty Structures
1528 @section Structures with No Members
1529 @cindex empty structures
1530 @cindex zero-size structures
1532 GCC permits a C structure to have no members:
1534 @smallexample
1535 struct empty @{
1537 @end smallexample
1539 The structure has size zero.  In C++, empty structures are part
1540 of the language.  G++ treats empty structures as if they had a single
1541 member of type @code{char}.
1543 @node Variable Length
1544 @section Arrays of Variable Length
1545 @cindex variable-length arrays
1546 @cindex arrays of variable length
1547 @cindex VLAs
1549 Variable-length automatic arrays are allowed in ISO C99, and as an
1550 extension GCC accepts them in C90 mode and in C++.  These arrays are
1551 declared like any other automatic arrays, but with a length that is not
1552 a constant expression.  The storage is allocated at the point of
1553 declaration and deallocated when the block scope containing the declaration
1554 exits.  For
1555 example:
1557 @smallexample
1558 FILE *
1559 concat_fopen (char *s1, char *s2, char *mode)
1561   char str[strlen (s1) + strlen (s2) + 1];
1562   strcpy (str, s1);
1563   strcat (str, s2);
1564   return fopen (str, mode);
1566 @end smallexample
1568 @cindex scope of a variable length array
1569 @cindex variable-length array scope
1570 @cindex deallocating variable length arrays
1571 Jumping or breaking out of the scope of the array name deallocates the
1572 storage.  Jumping into the scope is not allowed; you get an error
1573 message for it.
1575 @cindex variable-length array in a structure
1576 As an extension, GCC accepts variable-length arrays as a member of
1577 a structure or a union.  For example:
1579 @smallexample
1580 void
1581 foo (int n)
1583   struct S @{ int x[n]; @};
1585 @end smallexample
1587 @cindex @code{alloca} vs variable-length arrays
1588 You can use the function @code{alloca} to get an effect much like
1589 variable-length arrays.  The function @code{alloca} is available in
1590 many other C implementations (but not in all).  On the other hand,
1591 variable-length arrays are more elegant.
1593 There are other differences between these two methods.  Space allocated
1594 with @code{alloca} exists until the containing @emph{function} returns.
1595 The space for a variable-length array is deallocated as soon as the array
1596 name's scope ends.  (If you use both variable-length arrays and
1597 @code{alloca} in the same function, deallocation of a variable-length array
1598 also deallocates anything more recently allocated with @code{alloca}.)
1600 You can also use variable-length arrays as arguments to functions:
1602 @smallexample
1603 struct entry
1604 tester (int len, char data[len][len])
1606   /* @r{@dots{}} */
1608 @end smallexample
1610 The length of an array is computed once when the storage is allocated
1611 and is remembered for the scope of the array in case you access it with
1612 @code{sizeof}.
1614 If you want to pass the array first and the length afterward, you can
1615 use a forward declaration in the parameter list---another GNU extension.
1617 @smallexample
1618 struct entry
1619 tester (int len; char data[len][len], int len)
1621   /* @r{@dots{}} */
1623 @end smallexample
1625 @cindex parameter forward declaration
1626 The @samp{int len} before the semicolon is a @dfn{parameter forward
1627 declaration}, and it serves the purpose of making the name @code{len}
1628 known when the declaration of @code{data} is parsed.
1630 You can write any number of such parameter forward declarations in the
1631 parameter list.  They can be separated by commas or semicolons, but the
1632 last one must end with a semicolon, which is followed by the ``real''
1633 parameter declarations.  Each forward declaration must match a ``real''
1634 declaration in parameter name and data type.  ISO C99 does not support
1635 parameter forward declarations.
1637 @node Variadic Macros
1638 @section Macros with a Variable Number of Arguments.
1639 @cindex variable number of arguments
1640 @cindex macro with variable arguments
1641 @cindex rest argument (in macro)
1642 @cindex variadic macros
1644 In the ISO C standard of 1999, a macro can be declared to accept a
1645 variable number of arguments much as a function can.  The syntax for
1646 defining the macro is similar to that of a function.  Here is an
1647 example:
1649 @smallexample
1650 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1651 @end smallexample
1653 @noindent
1654 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1655 such a macro, it represents the zero or more tokens until the closing
1656 parenthesis that ends the invocation, including any commas.  This set of
1657 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1658 wherever it appears.  See the CPP manual for more information.
1660 GCC has long supported variadic macros, and used a different syntax that
1661 allowed you to give a name to the variable arguments just like any other
1662 argument.  Here is an example:
1664 @smallexample
1665 #define debug(format, args...) fprintf (stderr, format, args)
1666 @end smallexample
1668 @noindent
1669 This is in all ways equivalent to the ISO C example above, but arguably
1670 more readable and descriptive.
1672 GNU CPP has two further variadic macro extensions, and permits them to
1673 be used with either of the above forms of macro definition.
1675 In standard C, you are not allowed to leave the variable argument out
1676 entirely; but you are allowed to pass an empty argument.  For example,
1677 this invocation is invalid in ISO C, because there is no comma after
1678 the string:
1680 @smallexample
1681 debug ("A message")
1682 @end smallexample
1684 GNU CPP permits you to completely omit the variable arguments in this
1685 way.  In the above examples, the compiler would complain, though since
1686 the expansion of the macro still has the extra comma after the format
1687 string.
1689 To help solve this problem, CPP behaves specially for variable arguments
1690 used with the token paste operator, @samp{##}.  If instead you write
1692 @smallexample
1693 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1694 @end smallexample
1696 @noindent
1697 and if the variable arguments are omitted or empty, the @samp{##}
1698 operator causes the preprocessor to remove the comma before it.  If you
1699 do provide some variable arguments in your macro invocation, GNU CPP
1700 does not complain about the paste operation and instead places the
1701 variable arguments after the comma.  Just like any other pasted macro
1702 argument, these arguments are not macro expanded.
1704 @node Escaped Newlines
1705 @section Slightly Looser Rules for Escaped Newlines
1706 @cindex escaped newlines
1707 @cindex newlines (escaped)
1709 The preprocessor treatment of escaped newlines is more relaxed 
1710 than that specified by the C90 standard, which requires the newline
1711 to immediately follow a backslash.  
1712 GCC's implementation allows whitespace in the form
1713 of spaces, horizontal and vertical tabs, and form feeds between the
1714 backslash and the subsequent newline.  The preprocessor issues a
1715 warning, but treats it as a valid escaped newline and combines the two
1716 lines to form a single logical line.  This works within comments and
1717 tokens, as well as between tokens.  Comments are @emph{not} treated as
1718 whitespace for the purposes of this relaxation, since they have not
1719 yet been replaced with spaces.
1721 @node Subscripting
1722 @section Non-Lvalue Arrays May Have Subscripts
1723 @cindex subscripting
1724 @cindex arrays, non-lvalue
1726 @cindex subscripting and function values
1727 In ISO C99, arrays that are not lvalues still decay to pointers, and
1728 may be subscripted, although they may not be modified or used after
1729 the next sequence point and the unary @samp{&} operator may not be
1730 applied to them.  As an extension, GNU C allows such arrays to be
1731 subscripted in C90 mode, though otherwise they do not decay to
1732 pointers outside C99 mode.  For example,
1733 this is valid in GNU C though not valid in C90:
1735 @smallexample
1736 @group
1737 struct foo @{int a[4];@};
1739 struct foo f();
1741 bar (int index)
1743   return f().a[index];
1745 @end group
1746 @end smallexample
1748 @node Pointer Arith
1749 @section Arithmetic on @code{void}- and Function-Pointers
1750 @cindex void pointers, arithmetic
1751 @cindex void, size of pointer to
1752 @cindex function pointers, arithmetic
1753 @cindex function, size of pointer to
1755 In GNU C, addition and subtraction operations are supported on pointers to
1756 @code{void} and on pointers to functions.  This is done by treating the
1757 size of a @code{void} or of a function as 1.
1759 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1760 and on function types, and returns 1.
1762 @opindex Wpointer-arith
1763 The option @option{-Wpointer-arith} requests a warning if these extensions
1764 are used.
1766 @node Pointers to Arrays
1767 @section Pointers to Arrays with Qualifiers Work as Expected
1768 @cindex pointers to arrays
1769 @cindex const qualifier
1771 In GNU C, pointers to arrays with qualifiers work similar to pointers
1772 to other qualified types. For example, a value of type @code{int (*)[5]}
1773 can be used to initialize a variable of type @code{const int (*)[5]}.
1774 These types are incompatible in ISO C because the @code{const} qualifier
1775 is formally attached to the element type of the array and not the
1776 array itself.
1778 @smallexample
1779 extern void
1780 transpose (int N, int M, double out[M][N], const double in[N][M]);
1781 double x[3][2];
1782 double y[2][3];
1783 @r{@dots{}}
1784 transpose(3, 2, y, x);
1785 @end smallexample
1787 @node Initializers
1788 @section Non-Constant Initializers
1789 @cindex initializers, non-constant
1790 @cindex non-constant initializers
1792 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1793 automatic variable are not required to be constant expressions in GNU C@.
1794 Here is an example of an initializer with run-time varying elements:
1796 @smallexample
1797 foo (float f, float g)
1799   float beat_freqs[2] = @{ f-g, f+g @};
1800   /* @r{@dots{}} */
1802 @end smallexample
1804 @node Compound Literals
1805 @section Compound Literals
1806 @cindex constructor expressions
1807 @cindex initializations in expressions
1808 @cindex structures, constructor expression
1809 @cindex expressions, constructor
1810 @cindex compound literals
1811 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1813 ISO C99 supports compound literals.  A compound literal looks like
1814 a cast containing an initializer.  Its value is an object of the
1815 type specified in the cast, containing the elements specified in
1816 the initializer; it is an lvalue.  As an extension, GCC supports
1817 compound literals in C90 mode and in C++, though the semantics are
1818 somewhat different in C++.
1820 Usually, the specified type is a structure.  Assume that
1821 @code{struct foo} and @code{structure} are declared as shown:
1823 @smallexample
1824 struct foo @{int a; char b[2];@} structure;
1825 @end smallexample
1827 @noindent
1828 Here is an example of constructing a @code{struct foo} with a compound literal:
1830 @smallexample
1831 structure = ((struct foo) @{x + y, 'a', 0@});
1832 @end smallexample
1834 @noindent
1835 This is equivalent to writing the following:
1837 @smallexample
1839   struct foo temp = @{x + y, 'a', 0@};
1840   structure = temp;
1842 @end smallexample
1844 You can also construct an array, though this is dangerous in C++, as
1845 explained below.  If all the elements of the compound literal are
1846 (made up of) simple constant expressions, suitable for use in
1847 initializers of objects of static storage duration, then the compound
1848 literal can be coerced to a pointer to its first element and used in
1849 such an initializer, as shown here:
1851 @smallexample
1852 char **foo = (char *[]) @{ "x", "y", "z" @};
1853 @end smallexample
1855 Compound literals for scalar types and union types are
1856 also allowed, but then the compound literal is equivalent
1857 to a cast.
1859 As a GNU extension, GCC allows initialization of objects with static storage
1860 duration by compound literals (which is not possible in ISO C99, because
1861 the initializer is not a constant).
1862 It is handled as if the object is initialized only with the bracket
1863 enclosed list if the types of the compound literal and the object match.
1864 The initializer list of the compound literal must be constant.
1865 If the object being initialized has array type of unknown size, the size is
1866 determined by compound literal size.
1868 @smallexample
1869 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1870 static int y[] = (int []) @{1, 2, 3@};
1871 static int z[] = (int [3]) @{1@};
1872 @end smallexample
1874 @noindent
1875 The above lines are equivalent to the following:
1876 @smallexample
1877 static struct foo x = @{1, 'a', 'b'@};
1878 static int y[] = @{1, 2, 3@};
1879 static int z[] = @{1, 0, 0@};
1880 @end smallexample
1882 In C, a compound literal designates an unnamed object with static or
1883 automatic storage duration.  In C++, a compound literal designates a
1884 temporary object, which only lives until the end of its
1885 full-expression.  As a result, well-defined C code that takes the
1886 address of a subobject of a compound literal can be undefined in C++,
1887 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1888 For instance, if the array compound literal example above appeared
1889 inside a function, any subsequent use of @samp{foo} in C++ has
1890 undefined behavior because the lifetime of the array ends after the
1891 declaration of @samp{foo}.  
1893 As an optimization, the C++ compiler sometimes gives array compound
1894 literals longer lifetimes: when the array either appears outside a
1895 function or has const-qualified type.  If @samp{foo} and its
1896 initializer had elements of @samp{char *const} type rather than
1897 @samp{char *}, or if @samp{foo} were a global variable, the array
1898 would have static storage duration.  But it is probably safest just to
1899 avoid the use of array compound literals in code compiled as C++.
1901 @node Designated Inits
1902 @section Designated Initializers
1903 @cindex initializers with labeled elements
1904 @cindex labeled elements in initializers
1905 @cindex case labels in initializers
1906 @cindex designated initializers
1908 Standard C90 requires the elements of an initializer to appear in a fixed
1909 order, the same as the order of the elements in the array or structure
1910 being initialized.
1912 In ISO C99 you can give the elements in any order, specifying the array
1913 indices or structure field names they apply to, and GNU C allows this as
1914 an extension in C90 mode as well.  This extension is not
1915 implemented in GNU C++.
1917 To specify an array index, write
1918 @samp{[@var{index}] =} before the element value.  For example,
1920 @smallexample
1921 int a[6] = @{ [4] = 29, [2] = 15 @};
1922 @end smallexample
1924 @noindent
1925 is equivalent to
1927 @smallexample
1928 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1929 @end smallexample
1931 @noindent
1932 The index values must be constant expressions, even if the array being
1933 initialized is automatic.
1935 An alternative syntax for this that has been obsolete since GCC 2.5 but
1936 GCC still accepts is to write @samp{[@var{index}]} before the element
1937 value, with no @samp{=}.
1939 To initialize a range of elements to the same value, write
1940 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1941 extension.  For example,
1943 @smallexample
1944 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1945 @end smallexample
1947 @noindent
1948 If the value in it has side-effects, the side-effects happen only once,
1949 not for each initialized field by the range initializer.
1951 @noindent
1952 Note that the length of the array is the highest value specified
1953 plus one.
1955 In a structure initializer, specify the name of a field to initialize
1956 with @samp{.@var{fieldname} =} before the element value.  For example,
1957 given the following structure,
1959 @smallexample
1960 struct point @{ int x, y; @};
1961 @end smallexample
1963 @noindent
1964 the following initialization
1966 @smallexample
1967 struct point p = @{ .y = yvalue, .x = xvalue @};
1968 @end smallexample
1970 @noindent
1971 is equivalent to
1973 @smallexample
1974 struct point p = @{ xvalue, yvalue @};
1975 @end smallexample
1977 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1978 @samp{@var{fieldname}:}, as shown here:
1980 @smallexample
1981 struct point p = @{ y: yvalue, x: xvalue @};
1982 @end smallexample
1984 Omitted field members are implicitly initialized the same as objects
1985 that have static storage duration.
1987 @cindex designators
1988 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1989 @dfn{designator}.  You can also use a designator (or the obsolete colon
1990 syntax) when initializing a union, to specify which element of the union
1991 should be used.  For example,
1993 @smallexample
1994 union foo @{ int i; double d; @};
1996 union foo f = @{ .d = 4 @};
1997 @end smallexample
1999 @noindent
2000 converts 4 to a @code{double} to store it in the union using
2001 the second element.  By contrast, casting 4 to type @code{union foo}
2002 stores it into the union as the integer @code{i}, since it is
2003 an integer.  (@xref{Cast to Union}.)
2005 You can combine this technique of naming elements with ordinary C
2006 initialization of successive elements.  Each initializer element that
2007 does not have a designator applies to the next consecutive element of the
2008 array or structure.  For example,
2010 @smallexample
2011 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2012 @end smallexample
2014 @noindent
2015 is equivalent to
2017 @smallexample
2018 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2019 @end smallexample
2021 Labeling the elements of an array initializer is especially useful
2022 when the indices are characters or belong to an @code{enum} type.
2023 For example:
2025 @smallexample
2026 int whitespace[256]
2027   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2028       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2029 @end smallexample
2031 @cindex designator lists
2032 You can also write a series of @samp{.@var{fieldname}} and
2033 @samp{[@var{index}]} designators before an @samp{=} to specify a
2034 nested subobject to initialize; the list is taken relative to the
2035 subobject corresponding to the closest surrounding brace pair.  For
2036 example, with the @samp{struct point} declaration above:
2038 @smallexample
2039 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2040 @end smallexample
2042 @noindent
2043 If the same field is initialized multiple times, it has the value from
2044 the last initialization.  If any such overridden initialization has
2045 side-effect, it is unspecified whether the side-effect happens or not.
2046 Currently, GCC discards them and issues a warning.
2048 @node Case Ranges
2049 @section Case Ranges
2050 @cindex case ranges
2051 @cindex ranges in case statements
2053 You can specify a range of consecutive values in a single @code{case} label,
2054 like this:
2056 @smallexample
2057 case @var{low} ... @var{high}:
2058 @end smallexample
2060 @noindent
2061 This has the same effect as the proper number of individual @code{case}
2062 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2064 This feature is especially useful for ranges of ASCII character codes:
2066 @smallexample
2067 case 'A' ... 'Z':
2068 @end smallexample
2070 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2071 it may be parsed wrong when you use it with integer values.  For example,
2072 write this:
2074 @smallexample
2075 case 1 ... 5:
2076 @end smallexample
2078 @noindent
2079 rather than this:
2081 @smallexample
2082 case 1...5:
2083 @end smallexample
2085 @node Cast to Union
2086 @section Cast to a Union Type
2087 @cindex cast to a union
2088 @cindex union, casting to a
2090 A cast to union type is similar to other casts, except that the type
2091 specified is a union type.  You can specify the type either with
2092 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2093 a constructor, not a cast, and hence does not yield an lvalue like
2094 normal casts.  (@xref{Compound Literals}.)
2096 The types that may be cast to the union type are those of the members
2097 of the union.  Thus, given the following union and variables:
2099 @smallexample
2100 union foo @{ int i; double d; @};
2101 int x;
2102 double y;
2103 @end smallexample
2105 @noindent
2106 both @code{x} and @code{y} can be cast to type @code{union foo}.
2108 Using the cast as the right-hand side of an assignment to a variable of
2109 union type is equivalent to storing in a member of the union:
2111 @smallexample
2112 union foo u;
2113 /* @r{@dots{}} */
2114 u = (union foo) x  @equiv{}  u.i = x
2115 u = (union foo) y  @equiv{}  u.d = y
2116 @end smallexample
2118 You can also use the union cast as a function argument:
2120 @smallexample
2121 void hack (union foo);
2122 /* @r{@dots{}} */
2123 hack ((union foo) x);
2124 @end smallexample
2126 @node Mixed Declarations
2127 @section Mixed Declarations and Code
2128 @cindex mixed declarations and code
2129 @cindex declarations, mixed with code
2130 @cindex code, mixed with declarations
2132 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2133 within compound statements.  As an extension, GNU C also allows this in
2134 C90 mode.  For example, you could do:
2136 @smallexample
2137 int i;
2138 /* @r{@dots{}} */
2139 i++;
2140 int j = i + 2;
2141 @end smallexample
2143 Each identifier is visible from where it is declared until the end of
2144 the enclosing block.
2146 @node Function Attributes
2147 @section Declaring Attributes of Functions
2148 @cindex function attributes
2149 @cindex declaring attributes of functions
2150 @cindex functions that never return
2151 @cindex functions that return more than once
2152 @cindex functions that have no side effects
2153 @cindex functions in arbitrary sections
2154 @cindex functions that behave like malloc
2155 @cindex @code{volatile} applied to function
2156 @cindex @code{const} applied to function
2157 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2158 @cindex functions with non-null pointer arguments
2159 @cindex functions that are passed arguments in registers on x86-32
2160 @cindex functions that pop the argument stack on x86-32
2161 @cindex functions that do not pop the argument stack on x86-32
2162 @cindex functions that have different compilation options on x86-32
2163 @cindex functions that have different optimization options
2164 @cindex functions that are dynamically resolved
2166 In GNU C, you declare certain things about functions called in your program
2167 which help the compiler optimize function calls and check your code more
2168 carefully.
2170 The keyword @code{__attribute__} allows you to specify special
2171 attributes when making a declaration.  This keyword is followed by an
2172 attribute specification inside double parentheses.  The following
2173 attributes are currently defined for functions on all targets:
2174 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2175 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2176 @code{no_icf},
2177 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2178 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2179 @code{no_instrument_function}, @code{no_split_stack},
2180 @code{section}, @code{constructor},
2181 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2182 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2183 @code{warn_unused_result}, @code{nonnull},
2184 @code{returns_nonnull}, @code{gnu_inline},
2185 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2186 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2187 @code{no_sanitize_thread},
2188 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2189 @code{bnd_instrument}, @code{stack_protect},
2190 @code{error} and @code{warning}.
2191 Several other attributes are defined for functions on particular
2192 target systems.  Other attributes, including @code{section} are
2193 supported for variables declarations (@pxref{Variable Attributes}),
2194 labels (@pxref{Label Attributes})
2195 and for types (@pxref{Type Attributes}).
2197 GCC plugins may provide their own attributes.
2199 You may also specify attributes with @samp{__} preceding and following
2200 each keyword.  This allows you to use them in header files without
2201 being concerned about a possible macro of the same name.  For example,
2202 you may use @code{__noreturn__} instead of @code{noreturn}.
2204 @xref{Attribute Syntax}, for details of the exact syntax for using
2205 attributes.
2207 @table @code
2208 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2210 @item alias ("@var{target}")
2211 @cindex @code{alias} function attribute
2212 The @code{alias} attribute causes the declaration to be emitted as an
2213 alias for another symbol, which must be specified.  For instance,
2215 @smallexample
2216 void __f () @{ /* @r{Do something.} */; @}
2217 void f () __attribute__ ((weak, alias ("__f")));
2218 @end smallexample
2220 @noindent
2221 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2222 mangled name for the target must be used.  It is an error if @samp{__f}
2223 is not defined in the same translation unit.
2225 Not all target machines support this attribute.
2227 @item aligned (@var{alignment})
2228 @cindex @code{aligned} function attribute
2229 This attribute specifies a minimum alignment for the function,
2230 measured in bytes.
2232 You cannot use this attribute to decrease the alignment of a function,
2233 only to increase it.  However, when you explicitly specify a function
2234 alignment this overrides the effect of the
2235 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2236 function.
2238 Note that the effectiveness of @code{aligned} attributes may be
2239 limited by inherent limitations in your linker.  On many systems, the
2240 linker is only able to arrange for functions to be aligned up to a
2241 certain maximum alignment.  (For some linkers, the maximum supported
2242 alignment may be very very small.)  See your linker documentation for
2243 further information.
2245 The @code{aligned} attribute can also be used for variables and fields
2246 (@pxref{Variable Attributes}.)
2248 @item alloc_size
2249 @cindex @code{alloc_size} function attribute
2250 The @code{alloc_size} attribute is used to tell the compiler that the
2251 function return value points to memory, where the size is given by
2252 one or two of the functions parameters.  GCC uses this
2253 information to improve the correctness of @code{__builtin_object_size}.
2255 The function parameter(s) denoting the allocated size are specified by
2256 one or two integer arguments supplied to the attribute.  The allocated size
2257 is either the value of the single function argument specified or the product
2258 of the two function arguments specified.  Argument numbering starts at
2259 one.
2261 For instance,
2263 @smallexample
2264 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2265 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2266 @end smallexample
2268 @noindent
2269 declares that @code{my_calloc} returns memory of the size given by
2270 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2271 of the size given by parameter 2.
2273 @item alloc_align
2274 @cindex @code{alloc_align} function attribute
2275 The @code{alloc_align} attribute is used to tell the compiler that the
2276 function return value points to memory, where the returned pointer minimum
2277 alignment is given by one of the functions parameters.  GCC uses this
2278 information to improve pointer alignment analysis.
2280 The function parameter denoting the allocated alignment is specified by
2281 one integer argument, whose number is the argument of the attribute.
2282 Argument numbering starts at one.
2284 For instance,
2286 @smallexample
2287 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2288 @end smallexample
2290 @noindent
2291 declares that @code{my_memalign} returns memory with minimum alignment
2292 given by parameter 1.
2294 @item assume_aligned
2295 @cindex @code{assume_aligned} function attribute
2296 The @code{assume_aligned} attribute is used to tell the compiler that the
2297 function return value points to memory, where the returned pointer minimum
2298 alignment is given by the first argument.
2299 If the attribute has two arguments, the second argument is misalignment offset.
2301 For instance
2303 @smallexample
2304 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2305 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2306 @end smallexample
2308 @noindent
2309 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2310 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2311 to 8.
2313 @item always_inline
2314 @cindex @code{always_inline} function attribute
2315 Generally, functions are not inlined unless optimization is specified.
2316 For functions declared inline, this attribute inlines the function
2317 independent of any restrictions that otherwise apply to inlining.
2318 Failure to inline such a function is diagnosed as an error.
2319 Note that if such a function is called indirectly the compiler may
2320 or may not inline it depending on optimization level and a failure
2321 to inline an indirect call may or may not be diagnosed.
2323 @item gnu_inline
2324 @cindex @code{gnu_inline} function attribute
2325 This attribute should be used with a function that is also declared
2326 with the @code{inline} keyword.  It directs GCC to treat the function
2327 as if it were defined in gnu90 mode even when compiling in C99 or
2328 gnu99 mode.
2330 If the function is declared @code{extern}, then this definition of the
2331 function is used only for inlining.  In no case is the function
2332 compiled as a standalone function, not even if you take its address
2333 explicitly.  Such an address becomes an external reference, as if you
2334 had only declared the function, and had not defined it.  This has
2335 almost the effect of a macro.  The way to use this is to put a
2336 function definition in a header file with this attribute, and put
2337 another copy of the function, without @code{extern}, in a library
2338 file.  The definition in the header file causes most calls to the
2339 function to be inlined.  If any uses of the function remain, they
2340 refer to the single copy in the library.  Note that the two
2341 definitions of the functions need not be precisely the same, although
2342 if they do not have the same effect your program may behave oddly.
2344 In C, if the function is neither @code{extern} nor @code{static}, then
2345 the function is compiled as a standalone function, as well as being
2346 inlined where possible.
2348 This is how GCC traditionally handled functions declared
2349 @code{inline}.  Since ISO C99 specifies a different semantics for
2350 @code{inline}, this function attribute is provided as a transition
2351 measure and as a useful feature in its own right.  This attribute is
2352 available in GCC 4.1.3 and later.  It is available if either of the
2353 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2354 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2355 Function is As Fast As a Macro}.
2357 In C++, this attribute does not depend on @code{extern} in any way,
2358 but it still requires the @code{inline} keyword to enable its special
2359 behavior.
2361 @item artificial
2362 @cindex @code{artificial} function attribute
2363 This attribute is useful for small inline wrappers that if possible
2364 should appear during debugging as a unit.  Depending on the debug
2365 info format it either means marking the function as artificial
2366 or using the caller location for all instructions within the inlined
2367 body.
2369 @item bank_switch
2370 @cindex @code{bank_switch} function attribute, M32C
2371 When added to an interrupt handler with the M32C port, causes the
2372 prologue and epilogue to use bank switching to preserve the registers
2373 rather than saving them on the stack.
2375 @item flatten
2376 @cindex @code{flatten} function attribute
2377 Generally, inlining into a function is limited.  For a function marked with
2378 this attribute, every call inside this function is inlined, if possible.
2379 Whether the function itself is considered for inlining depends on its size and
2380 the current inlining parameters.
2382 @item error ("@var{message}")
2383 @cindex @code{error} function attribute
2384 If this attribute is used on a function declaration and a call to such a function
2385 is not eliminated through dead code elimination or other optimizations, an error
2386 that includes @var{message} is diagnosed.  This is useful
2387 for compile-time checking, especially together with @code{__builtin_constant_p}
2388 and inline functions where checking the inline function arguments is not
2389 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2390 While it is possible to leave the function undefined and thus invoke
2391 a link failure, when using this attribute the problem is diagnosed
2392 earlier and with exact location of the call even in presence of inline
2393 functions or when not emitting debugging information.
2395 @item warning ("@var{message}")
2396 @cindex @code{warning} function attribute
2397 If this attribute is used on a function declaration and a call to such a function
2398 is not eliminated through dead code elimination or other optimizations, a warning
2399 that includes @var{message} is diagnosed.  This is useful
2400 for compile-time checking, especially together with @code{__builtin_constant_p}
2401 and inline functions.  While it is possible to define the function with
2402 a message in @code{.gnu.warning*} section, when using this attribute the problem
2403 is diagnosed earlier and with exact location of the call even in presence
2404 of inline functions or when not emitting debugging information.
2406 @item cdecl
2407 @cindex @code{cdecl} function attribute, x86-32
2408 @cindex functions that do pop the argument stack on x86-32
2409 @opindex mrtd
2410 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
2411 assume that the calling function pops off the stack space used to
2412 pass arguments.  This is
2413 useful to override the effects of the @option{-mrtd} switch.
2415 @item const
2416 @cindex @code{const} function attribute
2417 Many functions do not examine any values except their arguments, and
2418 have no effects except the return value.  Basically this is just slightly
2419 more strict class than the @code{pure} attribute below, since function is not
2420 allowed to read global memory.
2422 @cindex pointer arguments
2423 Note that a function that has pointer arguments and examines the data
2424 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2425 function that calls a non-@code{const} function usually must not be
2426 @code{const}.  It does not make sense for a @code{const} function to
2427 return @code{void}.
2429 @item constructor
2430 @itemx destructor
2431 @itemx constructor (@var{priority})
2432 @itemx destructor (@var{priority})
2433 @cindex @code{constructor} function attribute
2434 @cindex @code{destructor} function attribute
2435 The @code{constructor} attribute causes the function to be called
2436 automatically before execution enters @code{main ()}.  Similarly, the
2437 @code{destructor} attribute causes the function to be called
2438 automatically after @code{main ()} completes or @code{exit ()} is
2439 called.  Functions with these attributes are useful for
2440 initializing data that is used implicitly during the execution of
2441 the program.
2443 You may provide an optional integer priority to control the order in
2444 which constructor and destructor functions are run.  A constructor
2445 with a smaller priority number runs before a constructor with a larger
2446 priority number; the opposite relationship holds for destructors.  So,
2447 if you have a constructor that allocates a resource and a destructor
2448 that deallocates the same resource, both functions typically have the
2449 same priority.  The priorities for constructor and destructor
2450 functions are the same as those specified for namespace-scope C++
2451 objects (@pxref{C++ Attributes}).
2453 These attributes are not currently implemented for Objective-C@.
2455 @item deprecated
2456 @itemx deprecated (@var{msg})
2457 @cindex @code{deprecated} function attribute
2458 The @code{deprecated} attribute results in a warning if the function
2459 is used anywhere in the source file.  This is useful when identifying
2460 functions that are expected to be removed in a future version of a
2461 program.  The warning also includes the location of the declaration
2462 of the deprecated function, to enable users to easily find further
2463 information about why the function is deprecated, or what they should
2464 do instead.  Note that the warnings only occurs for uses:
2466 @smallexample
2467 int old_fn () __attribute__ ((deprecated));
2468 int old_fn ();
2469 int (*fn_ptr)() = old_fn;
2470 @end smallexample
2472 @noindent
2473 results in a warning on line 3 but not line 2.  The optional @var{msg}
2474 argument, which must be a string, is printed in the warning if
2475 present.
2477 The @code{deprecated} attribute can also be used for variables and
2478 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2480 @item disinterrupt
2481 @cindex @code{disinterrupt} function attribute, Epiphany
2482 @cindex @code{disinterrupt} function attribute, MeP
2483 On Epiphany and MeP targets, this attribute causes the compiler to emit
2484 instructions to disable interrupts for the duration of the given
2485 function.
2487 @item dllexport
2488 @cindex @code{dllexport} function attribute
2489 @cindex @code{__declspec(dllexport)}
2490 On Microsoft Windows targets and Symbian OS targets the
2491 @code{dllexport} attribute causes the compiler to provide a global
2492 pointer to a pointer in a DLL, so that it can be referenced with the
2493 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2494 name is formed by combining @code{_imp__} and the function or variable
2495 name.
2497 You can use @code{__declspec(dllexport)} as a synonym for
2498 @code{__attribute__ ((dllexport))} for compatibility with other
2499 compilers.
2501 On systems that support the @code{visibility} attribute, this
2502 attribute also implies ``default'' visibility.  It is an error to
2503 explicitly specify any other visibility.
2505 GCC's default behavior is to emit all inline functions with the
2506 @code{dllexport} attribute.  Since this can cause object file-size bloat,
2507 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
2508 ignore the attribute for inlined functions unless the 
2509 @option{-fkeep-inline-functions} flag is used instead.
2511 The attribute is ignored for undefined symbols.
2513 When applied to C++ classes, the attribute marks defined non-inlined
2514 member functions and static data members as exports.  Static consts
2515 initialized in-class are not marked unless they are also defined
2516 out-of-class.
2518 For Microsoft Windows targets there are alternative methods for
2519 including the symbol in the DLL's export table such as using a
2520 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2521 the @option{--export-all} linker flag.
2523 @item dllimport
2524 @cindex @code{dllimport} function attribute
2525 @cindex @code{__declspec(dllimport)}
2526 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2527 attribute causes the compiler to reference a function or variable via
2528 a global pointer to a pointer that is set up by the DLL exporting the
2529 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2530 targets, the pointer name is formed by combining @code{_imp__} and the
2531 function or variable name.
2533 You can use @code{__declspec(dllimport)} as a synonym for
2534 @code{__attribute__ ((dllimport))} for compatibility with other
2535 compilers.
2537 On systems that support the @code{visibility} attribute, this
2538 attribute also implies ``default'' visibility.  It is an error to
2539 explicitly specify any other visibility.
2541 Currently, the attribute is ignored for inlined functions.  If the
2542 attribute is applied to a symbol @emph{definition}, an error is reported.
2543 If a symbol previously declared @code{dllimport} is later defined, the
2544 attribute is ignored in subsequent references, and a warning is emitted.
2545 The attribute is also overridden by a subsequent declaration as
2546 @code{dllexport}.
2548 When applied to C++ classes, the attribute marks non-inlined
2549 member functions and static data members as imports.  However, the
2550 attribute is ignored for virtual methods to allow creation of vtables
2551 using thunks.
2553 On the SH Symbian OS target the @code{dllimport} attribute also has
2554 another affect---it can cause the vtable and run-time type information
2555 for a class to be exported.  This happens when the class has a
2556 dllimported constructor or a non-inline, non-pure virtual function
2557 and, for either of those two conditions, the class also has an inline
2558 constructor or destructor and has a key function that is defined in
2559 the current translation unit.
2561 For Microsoft Windows targets the use of the @code{dllimport}
2562 attribute on functions is not necessary, but provides a small
2563 performance benefit by eliminating a thunk in the DLL@.  The use of the
2564 @code{dllimport} attribute on imported variables can be avoided by passing the
2565 @option{--enable-auto-import} switch to the GNU linker.  As with
2566 functions, using the attribute for a variable eliminates a thunk in
2567 the DLL@.
2569 One drawback to using this attribute is that a pointer to a
2570 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2571 address. However, a pointer to a @emph{function} with the
2572 @code{dllimport} attribute can be used as a constant initializer; in
2573 this case, the address of a stub function in the import lib is
2574 referenced.  On Microsoft Windows targets, the attribute can be disabled
2575 for functions by setting the @option{-mnop-fun-dllimport} flag.
2577 @item exception
2578 @cindex @code{exception} function attribute
2579 @cindex exception handler functions, NDS32
2580 Use this attribute on the NDS32 target to indicate that the specified function
2581 is an exception handler.  The compiler will generate corresponding sections
2582 for use in an exception handler.
2584 @item exception_handler
2585 @cindex @code{exception_handler} function attribute
2586 @cindex exception handler functions, Blackfin
2587 Use this attribute on the Blackfin to indicate that the specified function
2588 is an exception handler.  The compiler generates function entry and
2589 exit sequences suitable for use in an exception handler when this
2590 attribute is present.
2592 @item externally_visible
2593 @cindex @code{externally_visible} function attribute
2594 This attribute, attached to a global variable or function, nullifies
2595 the effect of the @option{-fwhole-program} command-line option, so the
2596 object remains visible outside the current compilation unit.
2598 If @option{-fwhole-program} is used together with @option{-flto} and 
2599 @command{gold} is used as the linker plugin, 
2600 @code{externally_visible} attributes are automatically added to functions 
2601 (not variable yet due to a current @command{gold} issue) 
2602 that are accessed outside of LTO objects according to resolution file
2603 produced by @command{gold}.
2604 For other linkers that cannot generate resolution file,
2605 explicit @code{externally_visible} attributes are still necessary.
2607 @item far
2608 @cindex @code{far} function attribute
2610 On MeP targets this causes the compiler to use a calling convention
2611 that assumes the called function is too far away for the built-in
2612 addressing modes.
2614 @item fast_interrupt
2615 @cindex @code{fast_interrupt} function attribute, M32C
2616 @cindex @code{fast_interrupt} function attribute, RX
2617 Use this attribute on the M32C and RX ports to indicate that the specified
2618 function is a fast interrupt handler.  This is just like the
2619 @code{interrupt} attribute, except that @code{freit} is used to return
2620 instead of @code{reit}.
2622 @item fastcall
2623 @cindex @code{fastcall} function attribute, x86-32
2624 @cindex functions that pop the argument stack on x86-32
2625 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
2626 pass the first argument (if of integral type) in the register ECX and
2627 the second argument (if of integral type) in the register EDX@.  Subsequent
2628 and other typed arguments are passed on the stack.  The called function
2629 pops the arguments off the stack.  If the number of arguments is variable all
2630 arguments are pushed on the stack.
2632 @item thiscall
2633 @cindex @code{thiscall} function attribute, x86-32
2634 @cindex functions that pop the argument stack on x86-32
2635 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
2636 pass the first argument (if of integral type) in the register ECX.
2637 Subsequent and other typed arguments are passed on the stack. The called
2638 function pops the arguments off the stack.
2639 If the number of arguments is variable all arguments are pushed on the
2640 stack.
2641 The @code{thiscall} attribute is intended for C++ non-static member functions.
2642 As a GCC extension, this calling convention can be used for C functions
2643 and for static member methods.
2645 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2646 @cindex @code{format} function attribute
2647 @opindex Wformat
2648 The @code{format} attribute specifies that a function takes @code{printf},
2649 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2650 should be type-checked against a format string.  For example, the
2651 declaration:
2653 @smallexample
2654 extern int
2655 my_printf (void *my_object, const char *my_format, ...)
2656       __attribute__ ((format (printf, 2, 3)));
2657 @end smallexample
2659 @noindent
2660 causes the compiler to check the arguments in calls to @code{my_printf}
2661 for consistency with the @code{printf} style format string argument
2662 @code{my_format}.
2664 The parameter @var{archetype} determines how the format string is
2665 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2666 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2667 @code{strfmon}.  (You can also use @code{__printf__},
2668 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2669 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2670 @code{ms_strftime} are also present.
2671 @var{archetype} values such as @code{printf} refer to the formats accepted
2672 by the system's C runtime library,
2673 while values prefixed with @samp{gnu_} always refer
2674 to the formats accepted by the GNU C Library.  On Microsoft Windows
2675 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2676 @file{msvcrt.dll} library.
2677 The parameter @var{string-index}
2678 specifies which argument is the format string argument (starting
2679 from 1), while @var{first-to-check} is the number of the first
2680 argument to check against the format string.  For functions
2681 where the arguments are not available to be checked (such as
2682 @code{vprintf}), specify the third parameter as zero.  In this case the
2683 compiler only checks the format string for consistency.  For
2684 @code{strftime} formats, the third parameter is required to be zero.
2685 Since non-static C++ methods have an implicit @code{this} argument, the
2686 arguments of such methods should be counted from two, not one, when
2687 giving values for @var{string-index} and @var{first-to-check}.
2689 In the example above, the format string (@code{my_format}) is the second
2690 argument of the function @code{my_print}, and the arguments to check
2691 start with the third argument, so the correct parameters for the format
2692 attribute are 2 and 3.
2694 @opindex ffreestanding
2695 @opindex fno-builtin
2696 The @code{format} attribute allows you to identify your own functions
2697 that take format strings as arguments, so that GCC can check the
2698 calls to these functions for errors.  The compiler always (unless
2699 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2700 for the standard library functions @code{printf}, @code{fprintf},
2701 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2702 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2703 warnings are requested (using @option{-Wformat}), so there is no need to
2704 modify the header file @file{stdio.h}.  In C99 mode, the functions
2705 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2706 @code{vsscanf} are also checked.  Except in strictly conforming C
2707 standard modes, the X/Open function @code{strfmon} is also checked as
2708 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2709 @xref{C Dialect Options,,Options Controlling C Dialect}.
2711 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2712 recognized in the same context.  Declarations including these format attributes
2713 are parsed for correct syntax, however the result of checking of such format
2714 strings is not yet defined, and is not carried out by this version of the
2715 compiler.
2717 The target may also provide additional types of format checks.
2718 @xref{Target Format Checks,,Format Checks Specific to Particular
2719 Target Machines}.
2721 @item format_arg (@var{string-index})
2722 @cindex @code{format_arg} function attribute
2723 @opindex Wformat-nonliteral
2724 The @code{format_arg} attribute specifies that a function takes a format
2725 string for a @code{printf}, @code{scanf}, @code{strftime} or
2726 @code{strfmon} style function and modifies it (for example, to translate
2727 it into another language), so the result can be passed to a
2728 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2729 function (with the remaining arguments to the format function the same
2730 as they would have been for the unmodified string).  For example, the
2731 declaration:
2733 @smallexample
2734 extern char *
2735 my_dgettext (char *my_domain, const char *my_format)
2736       __attribute__ ((format_arg (2)));
2737 @end smallexample
2739 @noindent
2740 causes the compiler to check the arguments in calls to a @code{printf},
2741 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2742 format string argument is a call to the @code{my_dgettext} function, for
2743 consistency with the format string argument @code{my_format}.  If the
2744 @code{format_arg} attribute had not been specified, all the compiler
2745 could tell in such calls to format functions would be that the format
2746 string argument is not constant; this would generate a warning when
2747 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2748 without the attribute.
2750 The parameter @var{string-index} specifies which argument is the format
2751 string argument (starting from one).  Since non-static C++ methods have
2752 an implicit @code{this} argument, the arguments of such methods should
2753 be counted from two.
2755 The @code{format_arg} attribute allows you to identify your own
2756 functions that modify format strings, so that GCC can check the
2757 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2758 type function whose operands are a call to one of your own function.
2759 The compiler always treats @code{gettext}, @code{dgettext}, and
2760 @code{dcgettext} in this manner except when strict ISO C support is
2761 requested by @option{-ansi} or an appropriate @option{-std} option, or
2762 @option{-ffreestanding} or @option{-fno-builtin}
2763 is used.  @xref{C Dialect Options,,Options
2764 Controlling C Dialect}.
2766 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2767 @code{NSString} reference for compatibility with the @code{format} attribute
2768 above.
2770 The target may also allow additional types in @code{format-arg} attributes.
2771 @xref{Target Format Checks,,Format Checks Specific to Particular
2772 Target Machines}.
2774 @item function_vector
2775 @cindex @code{function_vector} function attribute, H8/300
2776 @cindex @code{function_vector} function attribute, M16C/M32C
2777 @cindex @code{function_vector} function attribute, SH
2778 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2779 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2780 function should be called through the function vector.  Calling a
2781 function through the function vector reduces code size, however;
2782 the function vector has a limited size (maximum 128 entries on the H8/300
2783 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2785 On SH2A targets, this attribute declares a function to be called using the
2786 TBR relative addressing mode.  The argument to this attribute is the entry
2787 number of the same function in a vector table containing all the TBR
2788 relative addressable functions.  For correct operation the TBR must be setup
2789 accordingly to point to the start of the vector table before any functions with
2790 this attribute are invoked.  Usually a good place to do the initialization is
2791 the startup routine.  The TBR relative vector table can have at max 256 function
2792 entries.  The jumps to these functions are generated using a SH2A specific,
2793 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2794 from GNU binutils version 2.7 or later for this attribute to work correctly.
2796 Please refer the example of M16C target, to see the use of this
2797 attribute while declaring a function,
2799 In an application, for a function being called once, this attribute
2800 saves at least 8 bytes of code; and if other successive calls are being
2801 made to the same function, it saves 2 bytes of code per each of these
2802 calls.
2804 On M16C/M32C targets, the @code{function_vector} attribute declares a
2805 special page subroutine call function. Use of this attribute reduces
2806 the code size by 2 bytes for each call generated to the
2807 subroutine. The argument to the attribute is the vector number entry
2808 from the special page vector table which contains the 16 low-order
2809 bits of the subroutine's entry address. Each vector table has special
2810 page number (18 to 255) that is used in @code{jsrs} instructions.
2811 Jump addresses of the routines are generated by adding 0x0F0000 (in
2812 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2813 2-byte addresses set in the vector table. Therefore you need to ensure
2814 that all the special page vector routines should get mapped within the
2815 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2816 (for M32C).
2818 In the following example 2 bytes are saved for each call to
2819 function @code{foo}.
2821 @smallexample
2822 void foo (void) __attribute__((function_vector(0x18)));
2823 void foo (void)
2827 void bar (void)
2829     foo();
2831 @end smallexample
2833 If functions are defined in one file and are called in another file,
2834 then be sure to write this declaration in both files.
2836 This attribute is ignored for R8C target.
2838 @item ifunc ("@var{resolver}")
2839 @cindex @code{ifunc} function attribute
2840 The @code{ifunc} attribute is used to mark a function as an indirect
2841 function using the STT_GNU_IFUNC symbol type extension to the ELF
2842 standard.  This allows the resolution of the symbol value to be
2843 determined dynamically at load time, and an optimized version of the
2844 routine can be selected for the particular processor or other system
2845 characteristics determined then.  To use this attribute, first define
2846 the implementation functions available, and a resolver function that
2847 returns a pointer to the selected implementation function.  The
2848 implementation functions' declarations must match the API of the
2849 function being implemented, the resolver's declaration is be a
2850 function returning pointer to void function returning void:
2852 @smallexample
2853 void *my_memcpy (void *dst, const void *src, size_t len)
2855   @dots{}
2858 static void (*resolve_memcpy (void)) (void)
2860   return my_memcpy; // we'll just always select this routine
2862 @end smallexample
2864 @noindent
2865 The exported header file declaring the function the user calls would
2866 contain:
2868 @smallexample
2869 extern void *memcpy (void *, const void *, size_t);
2870 @end smallexample
2872 @noindent
2873 allowing the user to call this as a regular function, unaware of the
2874 implementation.  Finally, the indirect function needs to be defined in
2875 the same translation unit as the resolver function:
2877 @smallexample
2878 void *memcpy (void *, const void *, size_t)
2879      __attribute__ ((ifunc ("resolve_memcpy")));
2880 @end smallexample
2882 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2883 and GNU C Library version 2.11.1 are required to use this feature.
2885 @item interrupt
2886 @cindex @code{interrupt} function attribute, ARC
2887 @cindex @code{interrupt} function attribute, ARM
2888 @cindex @code{interrupt} function attribute, AVR
2889 @cindex @code{interrupt} function attribute, CR16
2890 @cindex @code{interrupt} function attribute, Epiphany
2891 @cindex @code{interrupt} function attribute, M32C
2892 @cindex @code{interrupt} function attribute, M32R/D
2893 @cindex @code{interrupt} function attribute, m68k
2894 @cindex @code{interrupt} function attribute, MeP
2895 @cindex @code{interrupt} function attribute, MIPS
2896 @cindex @code{interrupt} function attribute, MSP430
2897 @cindex @code{interrupt} function attribute, NDS32
2898 @cindex @code{interrupt} function attribute, RL78
2899 @cindex @code{interrupt} function attribute, RX
2900 @cindex @code{interrupt} function attribute, Visium
2901 @cindex @code{interrupt} function attribute, Xstormy16
2902 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2903 m68k, MeP, MIPS, MSP430, NDS32, RL78, RX, Visium and Xstormy16 ports to indicate
2904 that the specified function is an interrupt handler.  The compiler generates
2905 function entry and exit sequences suitable for use in an interrupt handler
2906 when this attribute is present.  With Epiphany targets it may also generate
2907 a special section with code to initialize the interrupt vector table.
2909 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2910 and SH processors can be specified via the @code{interrupt_handler} attribute.
2912 Note, on the ARC, you must specify the kind of interrupt to be handled
2913 in a parameter to the interrupt attribute like this:
2915 @smallexample
2916 void f () __attribute__ ((interrupt ("ilink1")));
2917 @end smallexample
2919 Permissible values for this parameter are: @w{@code{ilink1}} and
2920 @w{@code{ilink2}}.
2922 Note, on the AVR, the hardware globally disables interrupts when an
2923 interrupt is executed.  The first instruction of an interrupt handler
2924 declared with this attribute is a @code{SEI} instruction to
2925 re-enable interrupts.  See also the @code{signal} function attribute
2926 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2927 @code{interrupt} are specified for the same function, @code{signal}
2928 is silently ignored.
2930 Note, for the ARM, you can specify the kind of interrupt to be handled by
2931 adding an optional parameter to the interrupt attribute like this:
2933 @smallexample
2934 void f () __attribute__ ((interrupt ("IRQ")));
2935 @end smallexample
2937 @noindent
2938 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2939 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2941 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2942 may be called with a word-aligned stack pointer.
2944 Note, for the MSP430 you can provide an argument to the interrupt
2945 attribute which specifies a name or number.  If the argument is a
2946 number it indicates the slot in the interrupt vector table (0 - 31) to
2947 which this handler should be assigned.  If the argument is a name it
2948 is treated as a symbolic name for the vector slot.  These names should
2949 match up with appropriate entries in the linker script.  By default
2950 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2951 @code{reset} for vector 31 are recognized.
2953 You can also use the following function attributes to modify how
2954 normal functions interact with interrupt functions:
2956 @table @code
2957 @item critical
2958 @cindex @code{critical} function attribute, MSP430
2959 Critical functions disable interrupts upon entry and restore the
2960 previous interrupt state upon exit.  Critical functions cannot also
2961 have the @code{naked} or @code{reentrant} attributes.  They can have
2962 the @code{interrupt} attribute.
2964 @item reentrant
2965 @cindex @code{reentrant} function attribute, MSP430
2966 Reentrant functions disable interrupts upon entry and enable them
2967 upon exit.  Reentrant functions cannot also have the @code{naked}
2968 or @code{critical} attributes.  They can have the @code{interrupt}
2969 attribute.
2971 @item wakeup
2972 @cindex @code{wakeup} function attribute, MSP430
2973 This attribute only applies to interrupt functions.  It is silently
2974 ignored if applied to a non-interrupt function.  A wakeup interrupt
2975 function will rouse the processor from any low-power state that it
2976 might be in when the function exits.
2978 @end table
2980 On Epiphany targets one or more optional parameters can be added like this:
2982 @smallexample
2983 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2984 @end smallexample
2986 Permissible values for these parameters are: @w{@code{reset}},
2987 @w{@code{software_exception}}, @w{@code{page_miss}},
2988 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2989 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2990 Multiple parameters indicate that multiple entries in the interrupt
2991 vector table should be initialized for this function, i.e.@: for each
2992 parameter @w{@var{name}}, a jump to the function is emitted in
2993 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
2994 entirely, in which case no interrupt vector table entry is provided.
2996 Note, on Epiphany targets, interrupts are enabled inside the function
2997 unless the @code{disinterrupt} attribute is also specified.
2999 On Epiphany targets, you can also use the following attribute to
3000 modify the behavior of an interrupt handler:
3001 @table @code
3002 @item forwarder_section
3003 @cindex @code{forwarder_section} function attribute, Epiphany
3004 The interrupt handler may be in external memory which cannot be
3005 reached by a branch instruction, so generate a local memory trampoline
3006 to transfer control.  The single parameter identifies the section where
3007 the trampoline is placed.
3008 @end table
3010 The following examples are all valid uses of these attributes on
3011 Epiphany targets:
3012 @smallexample
3013 void __attribute__ ((interrupt)) universal_handler ();
3014 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3015 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3016 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3017   fast_timer_handler ();
3018 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3019   external_dma_handler ();
3020 @end smallexample
3022 On MIPS targets, you can use the following attributes to modify the behavior
3023 of an interrupt handler:
3024 @table @code
3025 @item use_shadow_register_set
3026 @cindex @code{use_shadow_register_set} function attribute, MIPS
3027 Assume that the handler uses a shadow register set, instead of
3028 the main general-purpose registers.
3030 @item keep_interrupts_masked
3031 @cindex @code{keep_interrupts_masked} function attribute, MIPS
3032 Keep interrupts masked for the whole function.  Without this attribute,
3033 GCC tries to reenable interrupts for as much of the function as it can.
3035 @item use_debug_exception_return
3036 @cindex @code{use_debug_exception_return} function attribute, MIPS
3037 Return using the @code{deret} instruction.  Interrupt handlers that don't
3038 have this attribute return using @code{eret} instead.
3039 @end table
3041 You can use any combination of these attributes, as shown below:
3042 @smallexample
3043 void __attribute__ ((interrupt)) v0 ();
3044 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3045 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3046 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3047 void __attribute__ ((interrupt, use_shadow_register_set,
3048                      keep_interrupts_masked)) v4 ();
3049 void __attribute__ ((interrupt, use_shadow_register_set,
3050                      use_debug_exception_return)) v5 ();
3051 void __attribute__ ((interrupt, keep_interrupts_masked,
3052                      use_debug_exception_return)) v6 ();
3053 void __attribute__ ((interrupt, use_shadow_register_set,
3054                      keep_interrupts_masked,
3055                      use_debug_exception_return)) v7 ();
3056 @end smallexample
3058 On NDS32 target, this attribute indicates that the specified function
3059 is an interrupt handler.  The compiler generates corresponding sections
3060 for use in an interrupt handler.  You can use the following attributes
3061 to modify the behavior:
3062 @table @code
3063 @item nested
3064 @cindex @code{nested} function attribute, NDS32
3065 This interrupt service routine is interruptible.
3066 @item not_nested
3067 @cindex @code{not_nested} function attribute, NDS32
3068 This interrupt service routine is not interruptible.
3069 @item nested_ready
3070 @cindex @code{nested_ready} function attribute, NDS32
3071 This interrupt service routine is interruptible after @code{PSW.GIE}
3072 (global interrupt enable) is set.  This allows interrupt service routine to
3073 finish some short critical code before enabling interrupts.
3074 @item save_all
3075 @cindex @code{save_all} function attribute, NDS32
3076 The system will help save all registers into stack before entering
3077 interrupt handler.
3078 @item partial_save
3079 @cindex @code{partial_save} function attribute, NDS32
3080 The system will help save caller registers into stack before entering
3081 interrupt handler.
3082 @end table
3084 @cindex @code{brk_interrupt} function attribute, RL78
3085 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3086 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3087 that must end with @code{RETB} instead of @code{RETI}).
3089 On RX targets, you may specify one or more vector numbers as arguments
3090 to the attribute, as well as naming an alternate table name.
3091 Parameters are handled sequentially, so one handler can be assigned to
3092 multiple entries in multiple tables.  One may also pass the magic
3093 string @code{"$default"} which causes the function to be used for any
3094 unfilled slots in the current table.
3096 This example shows a simple assignment of a function to one vector in
3097 the default table (note that preprocessor macros may be used for
3098 chip-specific symbolic vector names):
3099 @smallexample
3100 void __attribute__ ((interrupt (5))) txd1_handler ();
3101 @end smallexample
3103 This example assigns a function to two slots in the default table
3104 (using preprocessor macros defined elsewhere) and makes it the default
3105 for the @code{dct} table:
3106 @smallexample
3107 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3108         txd1_handler ();
3109 @end smallexample
3111 @item interrupt_handler
3112 @cindex @code{interrupt_handler} function attribute, Blackfin
3113 @cindex @code{interrupt_handler} function attribute, m68k
3114 @cindex @code{interrupt_handler} function attribute, H8/300
3115 @cindex @code{interrupt_handler} function attribute, SH
3116 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3117 indicate that the specified function is an interrupt handler.  The compiler
3118 generates function entry and exit sequences suitable for use in an
3119 interrupt handler when this attribute is present.
3121 @item interrupt_thread
3122 @cindex @code{interrupt_thread} function attribute, fido
3123 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3124 that the specified function is an interrupt handler that is designed
3125 to run as a thread.  The compiler omits generate prologue/epilogue
3126 sequences and replaces the return instruction with a @code{sleep}
3127 instruction.  This attribute is available only on fido.
3129 @item isr
3130 @cindex @code{isr} function attribute, ARM
3131 Use this attribute on ARM to write Interrupt Service Routines. This is an
3132 alias to the @code{interrupt} attribute above.
3134 @item kspisusp
3135 @cindex @code{kspisusp} function attribute, Blackfin
3136 @cindex User stack pointer in interrupts on the Blackfin
3137 When used together with @code{interrupt_handler}, @code{exception_handler}
3138 or @code{nmi_handler}, code is generated to load the stack pointer
3139 from the USP register in the function prologue.
3141 @item l1_text
3142 @cindex @code{l1_text} function attribute, Blackfin
3143 This attribute specifies a function to be placed into L1 Instruction
3144 SRAM@. The function is put into a specific section named @code{.l1.text}.
3145 With @option{-mfdpic}, function calls with a such function as the callee
3146 or caller uses inlined PLT.
3148 @item l2
3149 @cindex @code{l2} function attribute, Blackfin
3150 On the Blackfin, this attribute specifies a function to be placed into L2
3151 SRAM. The function is put into a specific section named
3152 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3153 an inlined PLT.
3155 @item leaf
3156 @cindex @code{leaf} function attribute
3157 Calls to external functions with this attribute must return to the current
3158 compilation unit only by return or by exception handling.  In particular, leaf
3159 functions are not allowed to call callback function passed to it from the current
3160 compilation unit or directly call functions exported by the unit or longjmp
3161 into the unit.  Leaf function might still call functions from other compilation
3162 units and thus they are not necessarily leaf in the sense that they contain no
3163 function calls at all.
3165 The attribute is intended for library functions to improve dataflow analysis.
3166 The compiler takes the hint that any data not escaping the current compilation unit can
3167 not be used or modified by the leaf function.  For example, the @code{sin} function
3168 is a leaf function, but @code{qsort} is not.
3170 Note that leaf functions might invoke signals and signal handlers might be
3171 defined in the current compilation unit and use static variables.  The only
3172 compliant way to write such a signal handler is to declare such variables
3173 @code{volatile}.
3175 The attribute has no effect on functions defined within the current compilation
3176 unit.  This is to allow easy merging of multiple compilation units into one,
3177 for example, by using the link-time optimization.  For this reason the
3178 attribute is not allowed on types to annotate indirect calls.
3180 @item long_call
3181 @itemx medium_call
3182 @itemx short_call
3183 @cindex @code{long_call} function attribute, ARC
3184 @cindex @code{long_call} function attribute, ARM
3185 @cindex @code{long_call} function attribute, Epiphany
3186 @cindex @code{medium_call} function attribute, ARC
3187 @cindex @code{short_call} function attribute, ARC
3188 @cindex @code{short_call} function attribute, ARM
3189 @cindex @code{short_call} function attribute, Epiphany
3190 @cindex indirect calls, ARC
3191 @cindex indirect calls, ARM
3192 @cindex indirect calls, Epiphany
3193 These attributes specify how a particular function is called on
3194 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3195 These attributes override the
3196 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3197 and @option{-mmedium-calls} (@pxref{ARC Options})
3198 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3199 @code{long_call} attribute indicates that the function might be far
3200 away from the call site and require a different (more expensive)
3201 calling sequence.   The @code{short_call} attribute always places
3202 the offset to the function from the call site into the @samp{BL}
3203 instruction directly.
3205 For ARC, a function marked with the @code{long_call} attribute is
3206 always called using register-indirect jump-and-link instructions,
3207 thereby enabling the called function to be placed anywhere within the
3208 32-bit address space.  A function marked with the @code{medium_call}
3209 attribute will always be close enough to be called with an unconditional
3210 branch-and-link instruction, which has a 25-bit offset from
3211 the call site.  A function marked with the @code{short_call}
3212 attribute will always be close enough to be called with a conditional
3213 branch-and-link instruction, which has a 21-bit offset from
3214 the call site.
3216 @item longcall
3217 @itemx shortcall
3218 @cindex indirect calls, Blackfin
3219 @cindex indirect calls, PowerPC
3220 @cindex @code{longcall} function attribute, Blackfin
3221 @cindex @code{longcall} function attribute, PowerPC
3222 @cindex @code{shortcall} function attribute, Blackfin
3223 @cindex @code{shortcall} function attribute, PowerPC
3224 On Blackfin and PowerPC, the @code{longcall} attribute
3225 indicates that the function might be far away from the call site and
3226 require a different (more expensive) calling sequence.  The
3227 @code{shortcall} attribute indicates that the function is always close
3228 enough for the shorter calling sequence to be used.  These attributes
3229 override both the @option{-mlongcall} switch and, on the RS/6000 and
3230 PowerPC, the @code{#pragma longcall} setting.
3232 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3233 calls are necessary.
3235 @item long_call
3236 @itemx near
3237 @itemx far
3238 @cindex indirect calls, MIPS
3239 @cindex @code{long_call} function attribute, MIPS
3240 @cindex @code{near} function attribute, MIPS
3241 @cindex @code{far} function attribute, MIPS
3242 These attributes specify how a particular function is called on MIPS@.
3243 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3244 command-line switch.  The @code{long_call} and @code{far} attributes are
3245 synonyms, and cause the compiler to always call
3246 the function by first loading its address into a register, and then using
3247 the contents of that register.  The @code{near} attribute has the opposite
3248 effect; it specifies that non-PIC calls should be made using the more
3249 efficient @code{jal} instruction.
3251 @item malloc
3252 @cindex @code{malloc} function attribute
3253 This tells the compiler that a function is @code{malloc}-like, i.e.,
3254 that the pointer @var{P} returned by the function cannot alias any
3255 other pointer valid when the function returns, and moreover no
3256 pointers to valid objects occur in any storage addressed by @var{P}.
3258 Using this attribute can improve optimization.  Functions like
3259 @code{malloc} and @code{calloc} have this property because they return
3260 a pointer to uninitialized or zeroed-out storage.  However, functions
3261 like @code{realloc} do not have this property, as they can return a
3262 pointer to storage containing pointers.
3264 @item mips16
3265 @itemx nomips16
3266 @cindex @code{mips16} function attribute, MIPS
3267 @cindex @code{nomips16} function attribute, MIPS
3269 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3270 function attributes to locally select or turn off MIPS16 code generation.
3271 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3272 while MIPS16 code generation is disabled for functions with the
3273 @code{nomips16} attribute.  These attributes override the
3274 @option{-mips16} and @option{-mno-mips16} options on the command line
3275 (@pxref{MIPS Options}).
3277 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3278 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3279 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3280 may interact badly with some GCC extensions such as @code{__builtin_apply}
3281 (@pxref{Constructing Calls}).
3283 @item micromips, MIPS
3284 @itemx nomicromips, MIPS
3285 @cindex @code{micromips} function attribute
3286 @cindex @code{nomicromips} function attribute
3288 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3289 function attributes to locally select or turn off microMIPS code generation.
3290 A function with the @code{micromips} attribute is emitted as microMIPS code,
3291 while microMIPS code generation is disabled for functions with the
3292 @code{nomicromips} attribute.  These attributes override the
3293 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3294 (@pxref{MIPS Options}).
3296 When compiling files containing mixed microMIPS and non-microMIPS code, the
3297 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3298 command line,
3299 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3300 may interact badly with some GCC extensions such as @code{__builtin_apply}
3301 (@pxref{Constructing Calls}).
3303 @item model (@var{model-name})
3304 @cindex @code{model} function attribute, M32R/D
3305 @cindex function addressability on the M32R/D
3307 On the M32R/D, use this attribute to set the addressability of an
3308 object, and of the code generated for a function.  The identifier
3309 @var{model-name} is one of @code{small}, @code{medium}, or
3310 @code{large}, representing each of the code models.
3312 Small model objects live in the lower 16MB of memory (so that their
3313 addresses can be loaded with the @code{ld24} instruction), and are
3314 callable with the @code{bl} instruction.
3316 Medium model objects may live anywhere in the 32-bit address space (the
3317 compiler generates @code{seth/add3} instructions to load their addresses),
3318 and are callable with the @code{bl} instruction.
3320 Large model objects may live anywhere in the 32-bit address space (the
3321 compiler generates @code{seth/add3} instructions to load their addresses),
3322 and may not be reachable with the @code{bl} instruction (the compiler
3323 generates the much slower @code{seth/add3/jl} instruction sequence).
3325 @item ms_abi
3326 @itemx sysv_abi
3327 @cindex @code{ms_abi} function attribute, x86
3328 @cindex @code{sysv_abi} function attribute, x86
3330 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
3331 to indicate which calling convention should be used for a function.  The
3332 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3333 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3334 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3335 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3337 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3338 requires the @option{-maccumulate-outgoing-args} option.
3340 @item callee_pop_aggregate_return (@var{number})
3341 @cindex @code{callee_pop_aggregate_return} function attribute, x86
3343 On x86-32 targets, you can use this attribute to control how
3344 aggregates are returned in memory.  If the caller is responsible for
3345 popping the hidden pointer together with the rest of the arguments, specify
3346 @var{number} equal to zero.  If callee is responsible for popping the
3347 hidden pointer, specify @var{number} equal to one.  
3349 The default x86-32 ABI assumes that the callee pops the
3350 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
3351 the compiler assumes that the
3352 caller pops the stack for hidden pointer.
3354 @item ms_hook_prologue
3355 @cindex @code{ms_hook_prologue} function attribute, x86
3357 On 32-bit and 64-bit x86 targets, you can use
3358 this function attribute to make GCC generate the ``hot-patching'' function
3359 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3360 and newer.
3362 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
3363 @cindex @code{hotpatch} function attribute, S/390
3365 On S/390 System z targets, you can use this function attribute to
3366 make GCC generate a ``hot-patching'' function prologue.  If the
3367 @option{-mhotpatch=} command-line option is used at the same time,
3368 the @code{hotpatch} attribute takes precedence.  The first of the
3369 two arguments specifies the number of halfwords to be added before
3370 the function label.  A second argument can be used to specify the
3371 number of halfwords to be added after the function label.  For
3372 both arguments the maximum allowed value is 1000000.
3374 If both arguments are zero, hotpatching is disabled.
3376 @item naked
3377 @cindex @code{naked} function attribute, ARM
3378 @cindex @code{naked} function attribute, AVR
3379 @cindex @code{naked} function attribute, MCORE
3380 @cindex @code{naked} function attribute, MSP430
3381 @cindex @code{naked} function attribute, NDS32
3382 @cindex @code{naked} function attribute, RL78
3383 @cindex @code{naked} function attribute, RX
3384 @cindex @code{naked} function attribute, SPU
3385 @cindex function without prologue/epilogue code
3386 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3387 RL78, RX and SPU ports.  It allows the compiler to construct the
3388 requisite function declaration, while allowing the body of the
3389 function to be assembly code. The specified function will not have
3390 prologue/epilogue sequences generated by the compiler. Only basic
3391 @code{asm} statements can safely be included in naked functions
3392 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3393 basic @code{asm} and C code may appear to work, they cannot be
3394 depended upon to work reliably and are not supported.
3396 @item near
3397 @cindex @code{near} function attribute, MeP
3398 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3399 On MeP targets this attribute causes the compiler to assume the called
3400 function is close enough to use the normal calling convention,
3401 overriding the @option{-mtf} command-line option.
3403 @item nesting
3404 @cindex @code{nesting} function attribute, Blackfin
3405 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3406 Use this attribute together with @code{interrupt_handler},
3407 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3408 entry code should enable nested interrupts or exceptions.
3410 @item nmi_handler
3411 @cindex @code{nmi_handler} function attribute, Blackfin
3412 @cindex NMI handler functions on the Blackfin processor
3413 Use this attribute on the Blackfin to indicate that the specified function
3414 is an NMI handler.  The compiler generates function entry and
3415 exit sequences suitable for use in an NMI handler when this
3416 attribute is present.
3418 @item nocompression
3419 @cindex @code{nocompression} function attribute, MIPS
3420 On MIPS targets, you can use the @code{nocompression} function attribute
3421 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3422 overrides the @option{-mips16} and @option{-mmicromips} options on the
3423 command line (@pxref{MIPS Options}).
3425 @item no_instrument_function
3426 @cindex @code{no_instrument_function} function attribute
3427 @opindex finstrument-functions
3428 If @option{-finstrument-functions} is given, profiling function calls are
3429 generated at entry and exit of most user-compiled functions.
3430 Functions with this attribute are not so instrumented.
3432 @item no_split_stack
3433 @cindex @code{no_split_stack} function attribute
3434 @opindex fsplit-stack
3435 If @option{-fsplit-stack} is given, functions have a small
3436 prologue which decides whether to split the stack.  Functions with the
3437 @code{no_split_stack} attribute do not have that prologue, and thus
3438 may run with only a small amount of stack space available.
3440 @item stack_protect
3441 @cindex @code{stack_protect} function attribute
3442 This function attribute make a stack protection of the function if 
3443 flags @option{fstack-protector} or @option{fstack-protector-strong}
3444 or @option{fstack-protector-explicit} are set.
3446 @item noinline
3447 @cindex @code{noinline} function attribute
3448 This function attribute prevents a function from being considered for
3449 inlining.
3450 @c Don't enumerate the optimizations by name here; we try to be
3451 @c future-compatible with this mechanism.
3452 If the function does not have side-effects, there are optimizations
3453 other than inlining that cause function calls to be optimized away,
3454 although the function call is live.  To keep such calls from being
3455 optimized away, put
3456 @smallexample
3457 asm ("");
3458 @end smallexample
3460 @noindent
3461 (@pxref{Extended Asm}) in the called function, to serve as a special
3462 side-effect.
3464 @item noclone
3465 @cindex @code{noclone} function attribute
3466 This function attribute prevents a function from being considered for
3467 cloning---a mechanism that produces specialized copies of functions
3468 and which is (currently) performed by interprocedural constant
3469 propagation.
3471 @item no_icf
3472 @cindex @code{no_icf} function attribute
3473 This function attribute prevents a functions from being merged with another
3474 semantically equivalent function.
3476 @item nonnull (@var{arg-index}, @dots{})
3477 @cindex @code{nonnull} function attribute
3478 The @code{nonnull} attribute specifies that some function parameters should
3479 be non-null pointers.  For instance, the declaration:
3481 @smallexample
3482 extern void *
3483 my_memcpy (void *dest, const void *src, size_t len)
3484         __attribute__((nonnull (1, 2)));
3485 @end smallexample
3487 @noindent
3488 causes the compiler to check that, in calls to @code{my_memcpy},
3489 arguments @var{dest} and @var{src} are non-null.  If the compiler
3490 determines that a null pointer is passed in an argument slot marked
3491 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3492 is issued.  The compiler may also choose to make optimizations based
3493 on the knowledge that certain function arguments will never be null.
3495 If no argument index list is given to the @code{nonnull} attribute,
3496 all pointer arguments are marked as non-null.  To illustrate, the
3497 following declaration is equivalent to the previous example:
3499 @smallexample
3500 extern void *
3501 my_memcpy (void *dest, const void *src, size_t len)
3502         __attribute__((nonnull));
3503 @end smallexample
3505 @item no_reorder
3506 @cindex @code{no_reorder} function attribute
3507 Do not reorder functions or variables marked @code{no_reorder}
3508 against each other or top level assembler statements the executable.
3509 The actual order in the program will depend on the linker command
3510 line. Static variables marked like this are also not removed.
3511 This has a similar effect
3512 as the @option{-fno-toplevel-reorder} option, but only applies to the
3513 marked symbols.
3515 @item returns_nonnull
3516 @cindex @code{returns_nonnull} function attribute
3517 The @code{returns_nonnull} attribute specifies that the function
3518 return value should be a non-null pointer.  For instance, the declaration:
3520 @smallexample
3521 extern void *
3522 mymalloc (size_t len) __attribute__((returns_nonnull));
3523 @end smallexample
3525 @noindent
3526 lets the compiler optimize callers based on the knowledge
3527 that the return value will never be null.
3529 @item noreturn
3530 @cindex @code{noreturn} function attribute
3531 A few standard library functions, such as @code{abort} and @code{exit},
3532 cannot return.  GCC knows this automatically.  Some programs define
3533 their own functions that never return.  You can declare them
3534 @code{noreturn} to tell the compiler this fact.  For example,
3536 @smallexample
3537 @group
3538 void fatal () __attribute__ ((noreturn));
3540 void
3541 fatal (/* @r{@dots{}} */)
3543   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3544   exit (1);
3546 @end group
3547 @end smallexample
3549 The @code{noreturn} keyword tells the compiler to assume that
3550 @code{fatal} cannot return.  It can then optimize without regard to what
3551 would happen if @code{fatal} ever did return.  This makes slightly
3552 better code.  More importantly, it helps avoid spurious warnings of
3553 uninitialized variables.
3555 The @code{noreturn} keyword does not affect the exceptional path when that
3556 applies: a @code{noreturn}-marked function may still return to the caller
3557 by throwing an exception or calling @code{longjmp}.
3559 Do not assume that registers saved by the calling function are
3560 restored before calling the @code{noreturn} function.
3562 It does not make sense for a @code{noreturn} function to have a return
3563 type other than @code{void}.
3565 @item nothrow
3566 @cindex @code{nothrow} function attribute
3567 The @code{nothrow} attribute is used to inform the compiler that a
3568 function cannot throw an exception.  For example, most functions in
3569 the standard C library can be guaranteed not to throw an exception
3570 with the notable exceptions of @code{qsort} and @code{bsearch} that
3571 take function pointer arguments.
3573 @item nosave_low_regs
3574 @cindex @code{nosave_low_regs} function attribute, SH
3575 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3576 function should not save and restore registers R0..R7.  This can be used on SH3*
3577 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3578 interrupt handlers.
3580 @item optimize
3581 @cindex @code{optimize} function attribute
3582 The @code{optimize} attribute is used to specify that a function is to
3583 be compiled with different optimization options than specified on the
3584 command line.  Arguments can either be numbers or strings.  Numbers
3585 are assumed to be an optimization level.  Strings that begin with
3586 @code{O} are assumed to be an optimization option, while other options
3587 are assumed to be used with a @code{-f} prefix.  You can also use the
3588 @samp{#pragma GCC optimize} pragma to set the optimization options
3589 that affect more than one function.
3590 @xref{Function Specific Option Pragmas}, for details about the
3591 @samp{#pragma GCC optimize} pragma.
3593 This can be used for instance to have frequently-executed functions
3594 compiled with more aggressive optimization options that produce faster
3595 and larger code, while other functions can be compiled with less
3596 aggressive options.
3598 @item OS_main
3599 @itemx OS_task
3600 @cindex @code{OS_main} function attribute, AVR
3601 @cindex @code{OS_task} function attribute, AVR
3602 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3603 do not save/restore any call-saved register in their prologue/epilogue.
3605 The @code{OS_main} attribute can be used when there @emph{is
3606 guarantee} that interrupts are disabled at the time when the function
3607 is entered.  This saves resources when the stack pointer has to be
3608 changed to set up a frame for local variables.
3610 The @code{OS_task} attribute can be used when there is @emph{no
3611 guarantee} that interrupts are disabled at that time when the function
3612 is entered like for, e@.g@. task functions in a multi-threading operating
3613 system. In that case, changing the stack pointer register is
3614 guarded by save/clear/restore of the global interrupt enable flag.
3616 The differences to the @code{naked} function attribute are:
3617 @itemize @bullet
3618 @item @code{naked} functions do not have a return instruction whereas 
3619 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3620 @code{RETI} return instruction.
3621 @item @code{naked} functions do not set up a frame for local variables
3622 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3623 as needed.
3624 @end itemize
3626 @item pcs
3627 @cindex @code{pcs} function attribute, ARM
3629 The @code{pcs} attribute can be used to control the calling convention
3630 used for a function on ARM.  The attribute takes an argument that specifies
3631 the calling convention to use.
3633 When compiling using the AAPCS ABI (or a variant of it) then valid
3634 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3635 order to use a variant other than @code{"aapcs"} then the compiler must
3636 be permitted to use the appropriate co-processor registers (i.e., the
3637 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3638 For example,
3640 @smallexample
3641 /* Argument passed in r0, and result returned in r0+r1.  */
3642 double f2d (float) __attribute__((pcs("aapcs")));
3643 @end smallexample
3645 Variadic functions always use the @code{"aapcs"} calling convention and
3646 the compiler rejects attempts to specify an alternative.
3648 @item pure
3649 @cindex @code{pure} function attribute
3650 Many functions have no effects except the return value and their
3651 return value depends only on the parameters and/or global variables.
3652 Such a function can be subject
3653 to common subexpression elimination and loop optimization just as an
3654 arithmetic operator would be.  These functions should be declared
3655 with the attribute @code{pure}.  For example,
3657 @smallexample
3658 int square (int) __attribute__ ((pure));
3659 @end smallexample
3661 @noindent
3662 says that the hypothetical function @code{square} is safe to call
3663 fewer times than the program says.
3665 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3666 Interesting non-pure functions are functions with infinite loops or those
3667 depending on volatile memory or other system resource, that may change between
3668 two consecutive calls (such as @code{feof} in a multithreading environment).
3670 @item hot
3671 @cindex @code{hot} function attribute
3672 The @code{hot} attribute on a function is used to inform the compiler that
3673 the function is a hot spot of the compiled program.  The function is
3674 optimized more aggressively and on many targets it is placed into a special
3675 subsection of the text section so all hot functions appear close together,
3676 improving locality.
3678 When profile feedback is available, via @option{-fprofile-use}, hot functions
3679 are automatically detected and this attribute is ignored.
3681 @item cold
3682 @cindex @code{cold} function attribute
3683 The @code{cold} attribute on functions is used to inform the compiler that
3684 the function is unlikely to be executed.  The function is optimized for
3685 size rather than speed and on many targets it is placed into a special
3686 subsection of the text section so all cold functions appear close together,
3687 improving code locality of non-cold parts of program.  The paths leading
3688 to calls of cold functions within code are marked as unlikely by the branch
3689 prediction mechanism.  It is thus useful to mark functions used to handle
3690 unlikely conditions, such as @code{perror}, as cold to improve optimization
3691 of hot functions that do call marked functions in rare occasions.
3693 When profile feedback is available, via @option{-fprofile-use}, cold functions
3694 are automatically detected and this attribute is ignored.
3696 @item no_sanitize_address
3697 @itemx no_address_safety_analysis
3698 @cindex @code{no_sanitize_address} function attribute
3699 The @code{no_sanitize_address} attribute on functions is used
3700 to inform the compiler that it should not instrument memory accesses
3701 in the function when compiling with the @option{-fsanitize=address} option.
3702 The @code{no_address_safety_analysis} is a deprecated alias of the
3703 @code{no_sanitize_address} attribute, new code should use
3704 @code{no_sanitize_address}.
3706 @item no_sanitize_thread
3707 @cindex @code{no_sanitize_thread} function attribute
3708 The @code{no_sanitize_thread} attribute on functions is used
3709 to inform the compiler that it should not instrument memory accesses
3710 in the function when compiling with the @option{-fsanitize=thread} option.
3712 @item no_sanitize_undefined
3713 @cindex @code{no_sanitize_undefined} function attribute
3714 The @code{no_sanitize_undefined} attribute on functions is used
3715 to inform the compiler that it should not check for undefined behavior
3716 in the function when compiling with the @option{-fsanitize=undefined} option.
3718 @item bnd_legacy
3719 @cindex @code{bnd_legacy} function attribute
3720 @cindex Pointer Bounds Checker attributes
3721 The @code{bnd_legacy} attribute on functions is used to inform the
3722 compiler that the function should not be instrumented when compiled
3723 with the @option{-fcheck-pointer-bounds} option.
3725 @item bnd_instrument
3726 @cindex @code{bnd_instrument} function attribute
3727 The @code{bnd_instrument} attribute on functions is used to inform the
3728 compiler that the function should be instrumented when compiled
3729 with the @option{-fchkp-instrument-marked-only} option.
3731 @item regparm (@var{number})
3732 @cindex @code{regparm} function attribute, x86
3733 @cindex functions that are passed arguments in registers on x86-32
3734 On x86-32 targets, the @code{regparm} attribute causes the compiler to
3735 pass arguments number one to @var{number} if they are of integral type
3736 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3737 take a variable number of arguments continue to be passed all of their
3738 arguments on the stack.
3740 Beware that on some ELF systems this attribute is unsuitable for
3741 global functions in shared libraries with lazy binding (which is the
3742 default).  Lazy binding sends the first call via resolving code in
3743 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3744 per the standard calling conventions.  Solaris 8 is affected by this.
3745 Systems with the GNU C Library version 2.1 or higher
3746 and FreeBSD are believed to be
3747 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3748 disabled with the linker or the loader if desired, to avoid the
3749 problem.)
3751 @item reset
3752 @cindex @code{reset} function attribute, NDS32
3753 @cindex reset handler functions
3754 Use this attribute on the NDS32 target to indicate that the specified function
3755 is a reset handler.  The compiler will generate corresponding sections
3756 for use in a reset handler.  You can use the following attributes
3757 to provide extra exception handling:
3758 @table @code
3759 @item nmi
3760 @cindex @code{nmi} function attribute, NDS32
3761 Provide a user-defined function to handle NMI exception.
3762 @item warm
3763 @cindex @code{warm} function attribute, NDS32
3764 Provide a user-defined function to handle warm reset exception.
3765 @end table
3767 @item sseregparm
3768 @cindex @code{sseregparm} function attribute, x86
3769 On x86-32 targets with SSE support, the @code{sseregparm} attribute
3770 causes the compiler to pass up to 3 floating-point arguments in
3771 SSE registers instead of on the stack.  Functions that take a
3772 variable number of arguments continue to pass all of their
3773 floating-point arguments on the stack.
3775 @item force_align_arg_pointer
3776 @cindex @code{force_align_arg_pointer} function attribute, x86
3777 On x86 targets, the @code{force_align_arg_pointer} attribute may be
3778 applied to individual function definitions, generating an alternate
3779 prologue and epilogue that realigns the run-time stack if necessary.
3780 This supports mixing legacy codes that run with a 4-byte aligned stack
3781 with modern codes that keep a 16-byte stack for SSE compatibility.
3783 @item renesas
3784 @cindex @code{renesas} function attribute, SH
3785 On SH targets this attribute specifies that the function or struct follows the
3786 Renesas ABI.
3788 @item resbank
3789 @cindex @code{resbank} function attribute, SH
3790 On the SH2A target, this attribute enables the high-speed register
3791 saving and restoration using a register bank for @code{interrupt_handler}
3792 routines.  Saving to the bank is performed automatically after the CPU
3793 accepts an interrupt that uses a register bank.
3795 The nineteen 32-bit registers comprising general register R0 to R14,
3796 control register GBR, and system registers MACH, MACL, and PR and the
3797 vector table address offset are saved into a register bank.  Register
3798 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3799 from the bank is executed by issuing a RESBANK instruction.
3801 @item returns_twice
3802 @cindex @code{returns_twice} function attribute
3803 The @code{returns_twice} attribute tells the compiler that a function may
3804 return more than one time.  The compiler ensures that all registers
3805 are dead before calling such a function and emits a warning about
3806 the variables that may be clobbered after the second return from the
3807 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3808 The @code{longjmp}-like counterpart of such function, if any, might need
3809 to be marked with the @code{noreturn} attribute.
3811 @item saveall
3812 @cindex @code{saveall} function attribute, Blackfin
3813 @cindex @code{saveall} function attribute, H8/300
3814 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3815 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3816 all registers except the stack pointer should be saved in the prologue
3817 regardless of whether they are used or not.
3819 @item save_volatiles
3820 @cindex @code{save_volatiles} function attribute, MicroBlaze
3821 Use this attribute on the MicroBlaze to indicate that the function is
3822 an interrupt handler.  All volatile registers (in addition to non-volatile
3823 registers) are saved in the function prologue.  If the function is a leaf
3824 function, only volatiles used by the function are saved.  A normal function
3825 return is generated instead of a return from interrupt.
3827 @item break_handler
3828 @cindex @code{break_handler} function attribute, MicroBlaze
3829 @cindex break handler functions
3830 Use this attribute on the MicroBlaze ports to indicate that
3831 the specified function is a break handler.  The compiler generates function
3832 entry and exit sequences suitable for use in an break handler when this
3833 attribute is present. The return from @code{break_handler} is done through
3834 the @code{rtbd} instead of @code{rtsd}.
3836 @smallexample
3837 void f () __attribute__ ((break_handler));
3838 @end smallexample
3840 @item section ("@var{section-name}")
3841 @cindex @code{section} function attribute
3842 Normally, the compiler places the code it generates in the @code{text} section.
3843 Sometimes, however, you need additional sections, or you need certain
3844 particular functions to appear in special sections.  The @code{section}
3845 attribute specifies that a function lives in a particular section.
3846 For example, the declaration:
3848 @smallexample
3849 extern void foobar (void) __attribute__ ((section ("bar")));
3850 @end smallexample
3852 @noindent
3853 puts the function @code{foobar} in the @code{bar} section.
3855 Some file formats do not support arbitrary sections so the @code{section}
3856 attribute is not available on all platforms.
3857 If you need to map the entire contents of a module to a particular
3858 section, consider using the facilities of the linker instead.
3860 @item sentinel
3861 @cindex @code{sentinel} function attribute
3862 This function attribute ensures that a parameter in a function call is
3863 an explicit @code{NULL}.  The attribute is only valid on variadic
3864 functions.  By default, the sentinel is located at position zero, the
3865 last parameter of the function call.  If an optional integer position
3866 argument P is supplied to the attribute, the sentinel must be located at
3867 position P counting backwards from the end of the argument list.
3869 @smallexample
3870 __attribute__ ((sentinel))
3871 is equivalent to
3872 __attribute__ ((sentinel(0)))
3873 @end smallexample
3875 The attribute is automatically set with a position of 0 for the built-in
3876 functions @code{execl} and @code{execlp}.  The built-in function
3877 @code{execle} has the attribute set with a position of 1.
3879 A valid @code{NULL} in this context is defined as zero with any pointer
3880 type.  If your system defines the @code{NULL} macro with an integer type
3881 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3882 with a copy that redefines NULL appropriately.
3884 The warnings for missing or incorrect sentinels are enabled with
3885 @option{-Wformat}.
3887 @item short_call
3888 See @code{long_call}.
3890 @item shortcall
3891 See @code{longcall}.
3893 @item signal
3894 @cindex @code{signal} function attribute, AVR
3895 Use this attribute on the AVR to indicate that the specified
3896 function is an interrupt handler.  The compiler generates function
3897 entry and exit sequences suitable for use in an interrupt handler when this
3898 attribute is present.
3900 See also the @code{interrupt} function attribute. 
3902 The AVR hardware globally disables interrupts when an interrupt is executed.
3903 Interrupt handler functions defined with the @code{signal} attribute
3904 do not re-enable interrupts.  It is save to enable interrupts in a
3905 @code{signal} handler.  This ``save'' only applies to the code
3906 generated by the compiler and not to the IRQ layout of the
3907 application which is responsibility of the application.
3909 If both @code{signal} and @code{interrupt} are specified for the same
3910 function, @code{signal} is silently ignored.
3912 @item sp_switch
3913 @cindex @code{sp_switch} function attribute, SH
3914 Use this attribute on the SH to indicate an @code{interrupt_handler}
3915 function should switch to an alternate stack.  It expects a string
3916 argument that names a global variable holding the address of the
3917 alternate stack.
3919 @smallexample
3920 void *alt_stack;
3921 void f () __attribute__ ((interrupt_handler,
3922                           sp_switch ("alt_stack")));
3923 @end smallexample
3925 @item stdcall
3926 @cindex @code{stdcall} function attribute, x86-32
3927 @cindex functions that pop the argument stack on x86-32
3928 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
3929 assume that the called function pops off the stack space used to
3930 pass arguments, unless it takes a variable number of arguments.
3932 @item syscall_linkage
3933 @cindex @code{syscall_linkage} function attribute, IA-64
3934 This attribute is used to modify the IA-64 calling convention by marking
3935 all input registers as live at all function exits.  This makes it possible
3936 to restart a system call after an interrupt without having to save/restore
3937 the input registers.  This also prevents kernel data from leaking into
3938 application code.
3940 @item target
3941 @cindex @code{target} function attribute
3942 The @code{target} attribute is used to specify that a function is to
3943 be compiled with different target options than specified on the
3944 command line.  This can be used for instance to have functions
3945 compiled with a different ISA (instruction set architecture) than the
3946 default.  You can also use the @samp{#pragma GCC target} pragma to set
3947 more than one function to be compiled with specific target options.
3948 @xref{Function Specific Option Pragmas}, for details about the
3949 @samp{#pragma GCC target} pragma.
3951 For instance on an x86, you could compile one function with
3952 @code{target("sse4.1,arch=core2")} and another with
3953 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3954 compiling the first function with @option{-msse4.1} and
3955 @option{-march=core2} options, and the second function with
3956 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3957 user to make sure that a function is only invoked on a machine that
3958 supports the particular ISA it is compiled for (for example by using
3959 @code{cpuid} on x86 to determine what feature bits and architecture
3960 family are used).
3962 @smallexample
3963 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3964 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3965 @end smallexample
3967 You can either use multiple
3968 strings to specify multiple options, or separate the options
3969 with a comma (@samp{,}).
3971 The @code{target} attribute is presently implemented for
3972 x86, PowerPC, and Nios II targets only.
3973 The options supported are specific to each target.
3975 On the x86, the following options are allowed:
3977 @table @samp
3978 @item abm
3979 @itemx no-abm
3980 @cindex @code{target("abm")} function attribute, x86
3981 Enable/disable the generation of the advanced bit instructions.
3983 @item aes
3984 @itemx no-aes
3985 @cindex @code{target("aes")} function attribute, x86
3986 Enable/disable the generation of the AES instructions.
3988 @item default
3989 @cindex @code{target("default")} function attribute, x86
3990 @xref{Function Multiversioning}, where it is used to specify the
3991 default function version.
3993 @item mmx
3994 @itemx no-mmx
3995 @cindex @code{target("mmx")} function attribute, x86
3996 Enable/disable the generation of the MMX instructions.
3998 @item pclmul
3999 @itemx no-pclmul
4000 @cindex @code{target("pclmul")} function attribute, x86
4001 Enable/disable the generation of the PCLMUL instructions.
4003 @item popcnt
4004 @itemx no-popcnt
4005 @cindex @code{target("popcnt")} function attribute, x86
4006 Enable/disable the generation of the POPCNT instruction.
4008 @item sse
4009 @itemx no-sse
4010 @cindex @code{target("sse")} function attribute, x86
4011 Enable/disable the generation of the SSE instructions.
4013 @item sse2
4014 @itemx no-sse2
4015 @cindex @code{target("sse2")} function attribute, x86
4016 Enable/disable the generation of the SSE2 instructions.
4018 @item sse3
4019 @itemx no-sse3
4020 @cindex @code{target("sse3")} function attribute, x86
4021 Enable/disable the generation of the SSE3 instructions.
4023 @item sse4
4024 @itemx no-sse4
4025 @cindex @code{target("sse4")} function attribute, x86
4026 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4027 and SSE4.2).
4029 @item sse4.1
4030 @itemx no-sse4.1
4031 @cindex @code{target("sse4.1")} function attribute, x86
4032 Enable/disable the generation of the sse4.1 instructions.
4034 @item sse4.2
4035 @itemx no-sse4.2
4036 @cindex @code{target("sse4.2")} function attribute, x86
4037 Enable/disable the generation of the sse4.2 instructions.
4039 @item sse4a
4040 @itemx no-sse4a
4041 @cindex @code{target("sse4a")} function attribute, x86
4042 Enable/disable the generation of the SSE4A instructions.
4044 @item fma4
4045 @itemx no-fma4
4046 @cindex @code{target("fma4")} function attribute, x86
4047 Enable/disable the generation of the FMA4 instructions.
4049 @item xop
4050 @itemx no-xop
4051 @cindex @code{target("xop")} function attribute, x86
4052 Enable/disable the generation of the XOP instructions.
4054 @item lwp
4055 @itemx no-lwp
4056 @cindex @code{target("lwp")} function attribute, x86
4057 Enable/disable the generation of the LWP instructions.
4059 @item ssse3
4060 @itemx no-ssse3
4061 @cindex @code{target("ssse3")} function attribute, x86
4062 Enable/disable the generation of the SSSE3 instructions.
4064 @item cld
4065 @itemx no-cld
4066 @cindex @code{target("cld")} function attribute, x86
4067 Enable/disable the generation of the CLD before string moves.
4069 @item fancy-math-387
4070 @itemx no-fancy-math-387
4071 @cindex @code{target("fancy-math-387")} function attribute, x86
4072 Enable/disable the generation of the @code{sin}, @code{cos}, and
4073 @code{sqrt} instructions on the 387 floating-point unit.
4075 @item fused-madd
4076 @itemx no-fused-madd
4077 @cindex @code{target("fused-madd")} function attribute, x86
4078 Enable/disable the generation of the fused multiply/add instructions.
4080 @item ieee-fp
4081 @itemx no-ieee-fp
4082 @cindex @code{target("ieee-fp")} function attribute, x86
4083 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4085 @item inline-all-stringops
4086 @itemx no-inline-all-stringops
4087 @cindex @code{target("inline-all-stringops")} function attribute, x86
4088 Enable/disable inlining of string operations.
4090 @item inline-stringops-dynamically
4091 @itemx no-inline-stringops-dynamically
4092 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
4093 Enable/disable the generation of the inline code to do small string
4094 operations and calling the library routines for large operations.
4096 @item align-stringops
4097 @itemx no-align-stringops
4098 @cindex @code{target("align-stringops")} function attribute, x86
4099 Do/do not align destination of inlined string operations.
4101 @item recip
4102 @itemx no-recip
4103 @cindex @code{target("recip")} function attribute, x86
4104 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4105 instructions followed an additional Newton-Raphson step instead of
4106 doing a floating-point division.
4108 @item arch=@var{ARCH}
4109 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
4110 Specify the architecture to generate code for in compiling the function.
4112 @item tune=@var{TUNE}
4113 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
4114 Specify the architecture to tune for in compiling the function.
4116 @item fpmath=@var{FPMATH}
4117 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
4118 Specify which floating-point unit to use.  The
4119 @code{target("fpmath=sse,387")} option must be specified as
4120 @code{target("fpmath=sse+387")} because the comma would separate
4121 different options.
4122 @end table
4124 On the PowerPC, the following options are allowed:
4126 @table @samp
4127 @item altivec
4128 @itemx no-altivec
4129 @cindex @code{target("altivec")} function attribute, PowerPC
4130 Generate code that uses (does not use) AltiVec instructions.  In
4131 32-bit code, you cannot enable AltiVec instructions unless
4132 @option{-mabi=altivec} is used on the command line.
4134 @item cmpb
4135 @itemx no-cmpb
4136 @cindex @code{target("cmpb")} function attribute, PowerPC
4137 Generate code that uses (does not use) the compare bytes instruction
4138 implemented on the POWER6 processor and other processors that support
4139 the PowerPC V2.05 architecture.
4141 @item dlmzb
4142 @itemx no-dlmzb
4143 @cindex @code{target("dlmzb")} function attribute, PowerPC
4144 Generate code that uses (does not use) the string-search @samp{dlmzb}
4145 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4146 generated by default when targeting those processors.
4148 @item fprnd
4149 @itemx no-fprnd
4150 @cindex @code{target("fprnd")} function attribute, PowerPC
4151 Generate code that uses (does not use) the FP round to integer
4152 instructions implemented on the POWER5+ processor and other processors
4153 that support the PowerPC V2.03 architecture.
4155 @item hard-dfp
4156 @itemx no-hard-dfp
4157 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4158 Generate code that uses (does not use) the decimal floating-point
4159 instructions implemented on some POWER processors.
4161 @item isel
4162 @itemx no-isel
4163 @cindex @code{target("isel")} function attribute, PowerPC
4164 Generate code that uses (does not use) ISEL instruction.
4166 @item mfcrf
4167 @itemx no-mfcrf
4168 @cindex @code{target("mfcrf")} function attribute, PowerPC
4169 Generate code that uses (does not use) the move from condition
4170 register field instruction implemented on the POWER4 processor and
4171 other processors that support the PowerPC V2.01 architecture.
4173 @item mfpgpr
4174 @itemx no-mfpgpr
4175 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4176 Generate code that uses (does not use) the FP move to/from general
4177 purpose register instructions implemented on the POWER6X processor and
4178 other processors that support the extended PowerPC V2.05 architecture.
4180 @item mulhw
4181 @itemx no-mulhw
4182 @cindex @code{target("mulhw")} function attribute, PowerPC
4183 Generate code that uses (does not use) the half-word multiply and
4184 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4185 These instructions are generated by default when targeting those
4186 processors.
4188 @item multiple
4189 @itemx no-multiple
4190 @cindex @code{target("multiple")} function attribute, PowerPC
4191 Generate code that uses (does not use) the load multiple word
4192 instructions and the store multiple word instructions.
4194 @item update
4195 @itemx no-update
4196 @cindex @code{target("update")} function attribute, PowerPC
4197 Generate code that uses (does not use) the load or store instructions
4198 that update the base register to the address of the calculated memory
4199 location.
4201 @item popcntb
4202 @itemx no-popcntb
4203 @cindex @code{target("popcntb")} function attribute, PowerPC
4204 Generate code that uses (does not use) the popcount and double-precision
4205 FP reciprocal estimate instruction implemented on the POWER5
4206 processor and other processors that support the PowerPC V2.02
4207 architecture.
4209 @item popcntd
4210 @itemx no-popcntd
4211 @cindex @code{target("popcntd")} function attribute, PowerPC
4212 Generate code that uses (does not use) the popcount instruction
4213 implemented on the POWER7 processor and other processors that support
4214 the PowerPC V2.06 architecture.
4216 @item powerpc-gfxopt
4217 @itemx no-powerpc-gfxopt
4218 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4219 Generate code that uses (does not use) the optional PowerPC
4220 architecture instructions in the Graphics group, including
4221 floating-point select.
4223 @item powerpc-gpopt
4224 @itemx no-powerpc-gpopt
4225 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4226 Generate code that uses (does not use) the optional PowerPC
4227 architecture instructions in the General Purpose group, including
4228 floating-point square root.
4230 @item recip-precision
4231 @itemx no-recip-precision
4232 @cindex @code{target("recip-precision")} function attribute, PowerPC
4233 Assume (do not assume) that the reciprocal estimate instructions
4234 provide higher-precision estimates than is mandated by the PowerPC
4235 ABI.
4237 @item string
4238 @itemx no-string
4239 @cindex @code{target("string")} function attribute, PowerPC
4240 Generate code that uses (does not use) the load string instructions
4241 and the store string word instructions to save multiple registers and
4242 do small block moves.
4244 @item vsx
4245 @itemx no-vsx
4246 @cindex @code{target("vsx")} function attribute, PowerPC
4247 Generate code that uses (does not use) vector/scalar (VSX)
4248 instructions, and also enable the use of built-in functions that allow
4249 more direct access to the VSX instruction set.  In 32-bit code, you
4250 cannot enable VSX or AltiVec instructions unless
4251 @option{-mabi=altivec} is used on the command line.
4253 @item friz
4254 @itemx no-friz
4255 @cindex @code{target("friz")} function attribute, PowerPC
4256 Generate (do not generate) the @code{friz} instruction when the
4257 @option{-funsafe-math-optimizations} option is used to optimize
4258 rounding a floating-point value to 64-bit integer and back to floating
4259 point.  The @code{friz} instruction does not return the same value if
4260 the floating-point number is too large to fit in an integer.
4262 @item avoid-indexed-addresses
4263 @itemx no-avoid-indexed-addresses
4264 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4265 Generate code that tries to avoid (not avoid) the use of indexed load
4266 or store instructions.
4268 @item paired
4269 @itemx no-paired
4270 @cindex @code{target("paired")} function attribute, PowerPC
4271 Generate code that uses (does not use) the generation of PAIRED simd
4272 instructions.
4274 @item longcall
4275 @itemx no-longcall
4276 @cindex @code{target("longcall")} function attribute, PowerPC
4277 Generate code that assumes (does not assume) that all calls are far
4278 away so that a longer more expensive calling sequence is required.
4280 @item cpu=@var{CPU}
4281 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4282 Specify the architecture to generate code for when compiling the
4283 function.  If you select the @code{target("cpu=power7")} attribute when
4284 generating 32-bit code, VSX and AltiVec instructions are not generated
4285 unless you use the @option{-mabi=altivec} option on the command line.
4287 @item tune=@var{TUNE}
4288 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4289 Specify the architecture to tune for when compiling the function.  If
4290 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4291 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4292 compilation tunes for the @var{CPU} architecture, and not the
4293 default tuning specified on the command line.
4294 @end table
4296 When compiling for Nios II, the following options are allowed:
4298 @table @samp
4299 @item custom-@var{insn}=@var{N}
4300 @itemx no-custom-@var{insn}
4301 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4302 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4303 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4304 custom instruction with encoding @var{N} when generating code that uses 
4305 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4306 the custom instruction @var{insn}.
4307 These target attributes correspond to the
4308 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4309 command-line options, and support the same set of @var{insn} keywords.
4310 @xref{Nios II Options}, for more information.
4312 @item custom-fpu-cfg=@var{name}
4313 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4314 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4315 command-line option, to select a predefined set of custom instructions
4316 named @var{name}.
4317 @xref{Nios II Options}, for more information.
4318 @end table
4320 On the x86 and PowerPC back ends, the inliner does not inline a
4321 function that has different target options than the caller, unless the
4322 callee has a subset of the target options of the caller.  For example
4323 a function declared with @code{target("sse3")} can inline a function
4324 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4326 @item trap_exit
4327 @cindex @code{trap_exit} function attribute, SH
4328 Use this attribute on the SH for an @code{interrupt_handler} to return using
4329 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4330 argument specifying the trap number to be used.
4332 @item trapa_handler
4333 @cindex @code{trapa_handler} function attribute, SH
4334 On SH targets this function attribute is similar to @code{interrupt_handler}
4335 but it does not save and restore all registers.
4337 @item unused
4338 @cindex @code{unused} function attribute
4339 This attribute, attached to a function, means that the function is meant
4340 to be possibly unused.  GCC does not produce a warning for this
4341 function.
4343 @item used
4344 @cindex @code{used} function attribute
4345 This attribute, attached to a function, means that code must be emitted
4346 for the function even if it appears that the function is not referenced.
4347 This is useful, for example, when the function is referenced only in
4348 inline assembly.
4350 When applied to a member function of a C++ class template, the
4351 attribute also means that the function is instantiated if the
4352 class itself is instantiated.
4354 @item vector
4355 @cindex @code{vector} function attribute, RX
4356 This RX attribute is similar to the @code{interrupt} attribute, including its
4357 parameters, but does not make the function an interrupt-handler type
4358 function (i.e. it retains the normal C function calling ABI).  See the
4359 @code{interrupt} attribute for a description of its arguments.
4361 @item version_id
4362 @cindex @code{version_id} function attribute, IA-64
4363 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4364 symbol to contain a version string, thus allowing for function level
4365 versioning.  HP-UX system header files may use function level versioning
4366 for some system calls.
4368 @smallexample
4369 extern int foo () __attribute__((version_id ("20040821")));
4370 @end smallexample
4372 @noindent
4373 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4375 @item visibility ("@var{visibility_type}")
4376 @cindex @code{visibility} function attribute
4377 This attribute affects the linkage of the declaration to which it is attached.
4378 There are four supported @var{visibility_type} values: default,
4379 hidden, protected or internal visibility.
4381 @smallexample
4382 void __attribute__ ((visibility ("protected")))
4383 f () @{ /* @r{Do something.} */; @}
4384 int i __attribute__ ((visibility ("hidden")));
4385 @end smallexample
4387 The possible values of @var{visibility_type} correspond to the
4388 visibility settings in the ELF gABI.
4390 @table @dfn
4391 @c keep this list of visibilities in alphabetical order.
4393 @item default
4394 Default visibility is the normal case for the object file format.
4395 This value is available for the visibility attribute to override other
4396 options that may change the assumed visibility of entities.
4398 On ELF, default visibility means that the declaration is visible to other
4399 modules and, in shared libraries, means that the declared entity may be
4400 overridden.
4402 On Darwin, default visibility means that the declaration is visible to
4403 other modules.
4405 Default visibility corresponds to ``external linkage'' in the language.
4407 @item hidden
4408 Hidden visibility indicates that the entity declared has a new
4409 form of linkage, which we call ``hidden linkage''.  Two
4410 declarations of an object with hidden linkage refer to the same object
4411 if they are in the same shared object.
4413 @item internal
4414 Internal visibility is like hidden visibility, but with additional
4415 processor specific semantics.  Unless otherwise specified by the
4416 psABI, GCC defines internal visibility to mean that a function is
4417 @emph{never} called from another module.  Compare this with hidden
4418 functions which, while they cannot be referenced directly by other
4419 modules, can be referenced indirectly via function pointers.  By
4420 indicating that a function cannot be called from outside the module,
4421 GCC may for instance omit the load of a PIC register since it is known
4422 that the calling function loaded the correct value.
4424 @item protected
4425 Protected visibility is like default visibility except that it
4426 indicates that references within the defining module bind to the
4427 definition in that module.  That is, the declared entity cannot be
4428 overridden by another module.
4430 @end table
4432 All visibilities are supported on many, but not all, ELF targets
4433 (supported when the assembler supports the @samp{.visibility}
4434 pseudo-op).  Default visibility is supported everywhere.  Hidden
4435 visibility is supported on Darwin targets.
4437 The visibility attribute should be applied only to declarations that
4438 would otherwise have external linkage.  The attribute should be applied
4439 consistently, so that the same entity should not be declared with
4440 different settings of the attribute.
4442 In C++, the visibility attribute applies to types as well as functions
4443 and objects, because in C++ types have linkage.  A class must not have
4444 greater visibility than its non-static data member types and bases,
4445 and class members default to the visibility of their class.  Also, a
4446 declaration without explicit visibility is limited to the visibility
4447 of its type.
4449 In C++, you can mark member functions and static member variables of a
4450 class with the visibility attribute.  This is useful if you know a
4451 particular method or static member variable should only be used from
4452 one shared object; then you can mark it hidden while the rest of the
4453 class has default visibility.  Care must be taken to avoid breaking
4454 the One Definition Rule; for example, it is usually not useful to mark
4455 an inline method as hidden without marking the whole class as hidden.
4457 A C++ namespace declaration can also have the visibility attribute.
4459 @smallexample
4460 namespace nspace1 __attribute__ ((visibility ("protected")))
4461 @{ /* @r{Do something.} */; @}
4462 @end smallexample
4464 This attribute applies only to the particular namespace body, not to
4465 other definitions of the same namespace; it is equivalent to using
4466 @samp{#pragma GCC visibility} before and after the namespace
4467 definition (@pxref{Visibility Pragmas}).
4469 In C++, if a template argument has limited visibility, this
4470 restriction is implicitly propagated to the template instantiation.
4471 Otherwise, template instantiations and specializations default to the
4472 visibility of their template.
4474 If both the template and enclosing class have explicit visibility, the
4475 visibility from the template is used.
4477 @item vliw
4478 @cindex @code{vliw} function attribute, MeP
4479 On MeP, the @code{vliw} attribute tells the compiler to emit
4480 instructions in VLIW mode instead of core mode.  Note that this
4481 attribute is not allowed unless a VLIW coprocessor has been configured
4482 and enabled through command-line options.
4484 @item warn_unused_result
4485 @cindex @code{warn_unused_result} function attribute
4486 The @code{warn_unused_result} attribute causes a warning to be emitted
4487 if a caller of the function with this attribute does not use its
4488 return value.  This is useful for functions where not checking
4489 the result is either a security problem or always a bug, such as
4490 @code{realloc}.
4492 @smallexample
4493 int fn () __attribute__ ((warn_unused_result));
4494 int foo ()
4496   if (fn () < 0) return -1;
4497   fn ();
4498   return 0;
4500 @end smallexample
4502 @noindent
4503 results in warning on line 5.
4505 @item weak
4506 @cindex @code{weak} function attribute
4507 The @code{weak} attribute causes the declaration to be emitted as a weak
4508 symbol rather than a global.  This is primarily useful in defining
4509 library functions that can be overridden in user code, though it can
4510 also be used with non-function declarations.  Weak symbols are supported
4511 for ELF targets, and also for a.out targets when using the GNU assembler
4512 and linker.
4514 @item weakref
4515 @itemx weakref ("@var{target}")
4516 @cindex @code{weakref} function attribute
4517 The @code{weakref} attribute marks a declaration as a weak reference.
4518 Without arguments, it should be accompanied by an @code{alias} attribute
4519 naming the target symbol.  Optionally, the @var{target} may be given as
4520 an argument to @code{weakref} itself.  In either case, @code{weakref}
4521 implicitly marks the declaration as @code{weak}.  Without a
4522 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4523 @code{weakref} is equivalent to @code{weak}.
4525 @smallexample
4526 static int x() __attribute__ ((weakref ("y")));
4527 /* is equivalent to... */
4528 static int x() __attribute__ ((weak, weakref, alias ("y")));
4529 /* and to... */
4530 static int x() __attribute__ ((weakref));
4531 static int x() __attribute__ ((alias ("y")));
4532 @end smallexample
4534 A weak reference is an alias that does not by itself require a
4535 definition to be given for the target symbol.  If the target symbol is
4536 only referenced through weak references, then it becomes a @code{weak}
4537 undefined symbol.  If it is directly referenced, however, then such
4538 strong references prevail, and a definition is required for the
4539 symbol, not necessarily in the same translation unit.
4541 The effect is equivalent to moving all references to the alias to a
4542 separate translation unit, renaming the alias to the aliased symbol,
4543 declaring it as weak, compiling the two separate translation units and
4544 performing a reloadable link on them.
4546 At present, a declaration to which @code{weakref} is attached can
4547 only be @code{static}.
4549 @end table
4551 You can specify multiple attributes in a declaration by separating them
4552 by commas within the double parentheses or by immediately following an
4553 attribute declaration with another attribute declaration.
4555 @cindex @code{#pragma}, reason for not using
4556 @cindex pragma, reason for not using
4557 Some people object to the @code{__attribute__} feature, suggesting that
4558 ISO C's @code{#pragma} should be used instead.  At the time
4559 @code{__attribute__} was designed, there were two reasons for not doing
4560 this.
4562 @enumerate
4563 @item
4564 It is impossible to generate @code{#pragma} commands from a macro.
4566 @item
4567 There is no telling what the same @code{#pragma} might mean in another
4568 compiler.
4569 @end enumerate
4571 These two reasons applied to almost any application that might have been
4572 proposed for @code{#pragma}.  It was basically a mistake to use
4573 @code{#pragma} for @emph{anything}.
4575 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4576 to be generated from macros.  In addition, a @code{#pragma GCC}
4577 namespace is now in use for GCC-specific pragmas.  However, it has been
4578 found convenient to use @code{__attribute__} to achieve a natural
4579 attachment of attributes to their corresponding declarations, whereas
4580 @code{#pragma GCC} is of use for constructs that do not naturally form
4581 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4583 @node Label Attributes
4584 @section Label Attributes
4585 @cindex Label Attributes
4587 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4588 details of the exact syntax for using attributes.  Other attributes are 
4589 available for functions (@pxref{Function Attributes}), variables 
4590 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4592 This example uses the @code{cold} label attribute to indicate the 
4593 @code{ErrorHandling} branch is unlikely to be taken and that the
4594 @code{ErrorHandling} label is unused:
4596 @smallexample
4598    asm goto ("some asm" : : : : NoError);
4600 /* This branch (the fall-through from the asm) is less commonly used */
4601 ErrorHandling: 
4602    __attribute__((cold, unused)); /* Semi-colon is required here */
4603    printf("error\n");
4604    return 0;
4606 NoError:
4607    printf("no error\n");
4608    return 1;
4609 @end smallexample
4611 @table @code
4612 @item unused
4613 @cindex @code{unused} label attribute
4614 This feature is intended for program-generated code that may contain 
4615 unused labels, but which is compiled with @option{-Wall}.  It is
4616 not normally appropriate to use in it human-written code, though it
4617 could be useful in cases where the code that jumps to the label is
4618 contained within an @code{#ifdef} conditional.
4620 @item hot
4621 @cindex @code{hot} label attribute
4622 The @code{hot} attribute on a label is used to inform the compiler that
4623 the path following the label is more likely than paths that are not so
4624 annotated.  This attribute is used in cases where @code{__builtin_expect}
4625 cannot be used, for instance with computed goto or @code{asm goto}.
4627 @item cold
4628 @cindex @code{cold} label attribute
4629 The @code{cold} attribute on labels is used to inform the compiler that
4630 the path following the label is unlikely to be executed.  This attribute
4631 is used in cases where @code{__builtin_expect} cannot be used, for instance
4632 with computed goto or @code{asm goto}.
4634 @end table
4636 @node Attribute Syntax
4637 @section Attribute Syntax
4638 @cindex attribute syntax
4640 This section describes the syntax with which @code{__attribute__} may be
4641 used, and the constructs to which attribute specifiers bind, for the C
4642 language.  Some details may vary for C++ and Objective-C@.  Because of
4643 infelicities in the grammar for attributes, some forms described here
4644 may not be successfully parsed in all cases.
4646 There are some problems with the semantics of attributes in C++.  For
4647 example, there are no manglings for attributes, although they may affect
4648 code generation, so problems may arise when attributed types are used in
4649 conjunction with templates or overloading.  Similarly, @code{typeid}
4650 does not distinguish between types with different attributes.  Support
4651 for attributes in C++ may be restricted in future to attributes on
4652 declarations only, but not on nested declarators.
4654 @xref{Function Attributes}, for details of the semantics of attributes
4655 applying to functions.  @xref{Variable Attributes}, for details of the
4656 semantics of attributes applying to variables.  @xref{Type Attributes},
4657 for details of the semantics of attributes applying to structure, union
4658 and enumerated types.
4659 @xref{Label Attributes}, for details of the semantics of attributes 
4660 applying to labels.
4662 An @dfn{attribute specifier} is of the form
4663 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4664 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4665 each attribute is one of the following:
4667 @itemize @bullet
4668 @item
4669 Empty.  Empty attributes are ignored.
4671 @item
4672 A word (which may be an identifier such as @code{unused}, or a reserved
4673 word such as @code{const}).
4675 @item
4676 A word, followed by, in parentheses, parameters for the attribute.
4677 These parameters take one of the following forms:
4679 @itemize @bullet
4680 @item
4681 An identifier.  For example, @code{mode} attributes use this form.
4683 @item
4684 An identifier followed by a comma and a non-empty comma-separated list
4685 of expressions.  For example, @code{format} attributes use this form.
4687 @item
4688 A possibly empty comma-separated list of expressions.  For example,
4689 @code{format_arg} attributes use this form with the list being a single
4690 integer constant expression, and @code{alias} attributes use this form
4691 with the list being a single string constant.
4692 @end itemize
4693 @end itemize
4695 An @dfn{attribute specifier list} is a sequence of one or more attribute
4696 specifiers, not separated by any other tokens.
4698 @subsubheading Label Attributes
4700 In GNU C, an attribute specifier list may appear after the colon following a
4701 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4702 attributes on labels if the attribute specifier is immediately
4703 followed by a semicolon (i.e., the label applies to an empty
4704 statement).  If the semicolon is missing, C++ label attributes are
4705 ambiguous, as it is permissible for a declaration, which could begin
4706 with an attribute list, to be labelled in C++.  Declarations cannot be
4707 labelled in C90 or C99, so the ambiguity does not arise there.
4709 @subsubheading Type Attributes
4711 An attribute specifier list may appear as part of a @code{struct},
4712 @code{union} or @code{enum} specifier.  It may go either immediately
4713 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4714 the closing brace.  The former syntax is preferred.
4715 Where attribute specifiers follow the closing brace, they are considered
4716 to relate to the structure, union or enumerated type defined, not to any
4717 enclosing declaration the type specifier appears in, and the type
4718 defined is not complete until after the attribute specifiers.
4719 @c Otherwise, there would be the following problems: a shift/reduce
4720 @c conflict between attributes binding the struct/union/enum and
4721 @c binding to the list of specifiers/qualifiers; and "aligned"
4722 @c attributes could use sizeof for the structure, but the size could be
4723 @c changed later by "packed" attributes.
4726 @subsubheading All other attributes
4728 Otherwise, an attribute specifier appears as part of a declaration,
4729 counting declarations of unnamed parameters and type names, and relates
4730 to that declaration (which may be nested in another declaration, for
4731 example in the case of a parameter declaration), or to a particular declarator
4732 within a declaration.  Where an
4733 attribute specifier is applied to a parameter declared as a function or
4734 an array, it should apply to the function or array rather than the
4735 pointer to which the parameter is implicitly converted, but this is not
4736 yet correctly implemented.
4738 Any list of specifiers and qualifiers at the start of a declaration may
4739 contain attribute specifiers, whether or not such a list may in that
4740 context contain storage class specifiers.  (Some attributes, however,
4741 are essentially in the nature of storage class specifiers, and only make
4742 sense where storage class specifiers may be used; for example,
4743 @code{section}.)  There is one necessary limitation to this syntax: the
4744 first old-style parameter declaration in a function definition cannot
4745 begin with an attribute specifier, because such an attribute applies to
4746 the function instead by syntax described below (which, however, is not
4747 yet implemented in this case).  In some other cases, attribute
4748 specifiers are permitted by this grammar but not yet supported by the
4749 compiler.  All attribute specifiers in this place relate to the
4750 declaration as a whole.  In the obsolescent usage where a type of
4751 @code{int} is implied by the absence of type specifiers, such a list of
4752 specifiers and qualifiers may be an attribute specifier list with no
4753 other specifiers or qualifiers.
4755 At present, the first parameter in a function prototype must have some
4756 type specifier that is not an attribute specifier; this resolves an
4757 ambiguity in the interpretation of @code{void f(int
4758 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4759 the parentheses of a function declarator contain only attributes then
4760 those attributes are ignored, rather than yielding an error or warning
4761 or implying a single parameter of type int, but this is subject to
4762 change.
4764 An attribute specifier list may appear immediately before a declarator
4765 (other than the first) in a comma-separated list of declarators in a
4766 declaration of more than one identifier using a single list of
4767 specifiers and qualifiers.  Such attribute specifiers apply
4768 only to the identifier before whose declarator they appear.  For
4769 example, in
4771 @smallexample
4772 __attribute__((noreturn)) void d0 (void),
4773     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4774      d2 (void);
4775 @end smallexample
4777 @noindent
4778 the @code{noreturn} attribute applies to all the functions
4779 declared; the @code{format} attribute only applies to @code{d1}.
4781 An attribute specifier list may appear immediately before the comma,
4782 @code{=} or semicolon terminating the declaration of an identifier other
4783 than a function definition.  Such attribute specifiers apply
4784 to the declared object or function.  Where an
4785 assembler name for an object or function is specified (@pxref{Asm
4786 Labels}), the attribute must follow the @code{asm}
4787 specification.
4789 An attribute specifier list may, in future, be permitted to appear after
4790 the declarator in a function definition (before any old-style parameter
4791 declarations or the function body).
4793 Attribute specifiers may be mixed with type qualifiers appearing inside
4794 the @code{[]} of a parameter array declarator, in the C99 construct by
4795 which such qualifiers are applied to the pointer to which the array is
4796 implicitly converted.  Such attribute specifiers apply to the pointer,
4797 not to the array, but at present this is not implemented and they are
4798 ignored.
4800 An attribute specifier list may appear at the start of a nested
4801 declarator.  At present, there are some limitations in this usage: the
4802 attributes correctly apply to the declarator, but for most individual
4803 attributes the semantics this implies are not implemented.
4804 When attribute specifiers follow the @code{*} of a pointer
4805 declarator, they may be mixed with any type qualifiers present.
4806 The following describes the formal semantics of this syntax.  It makes the
4807 most sense if you are familiar with the formal specification of
4808 declarators in the ISO C standard.
4810 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4811 D1}, where @code{T} contains declaration specifiers that specify a type
4812 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4813 contains an identifier @var{ident}.  The type specified for @var{ident}
4814 for derived declarators whose type does not include an attribute
4815 specifier is as in the ISO C standard.
4817 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4818 and the declaration @code{T D} specifies the type
4819 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4820 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4821 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4823 If @code{D1} has the form @code{*
4824 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4825 declaration @code{T D} specifies the type
4826 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4827 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4828 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4829 @var{ident}.
4831 For example,
4833 @smallexample
4834 void (__attribute__((noreturn)) ****f) (void);
4835 @end smallexample
4837 @noindent
4838 specifies the type ``pointer to pointer to pointer to pointer to
4839 non-returning function returning @code{void}''.  As another example,
4841 @smallexample
4842 char *__attribute__((aligned(8))) *f;
4843 @end smallexample
4845 @noindent
4846 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4847 Note again that this does not work with most attributes; for example,
4848 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4849 is not yet supported.
4851 For compatibility with existing code written for compiler versions that
4852 did not implement attributes on nested declarators, some laxity is
4853 allowed in the placing of attributes.  If an attribute that only applies
4854 to types is applied to a declaration, it is treated as applying to
4855 the type of that declaration.  If an attribute that only applies to
4856 declarations is applied to the type of a declaration, it is treated
4857 as applying to that declaration; and, for compatibility with code
4858 placing the attributes immediately before the identifier declared, such
4859 an attribute applied to a function return type is treated as
4860 applying to the function type, and such an attribute applied to an array
4861 element type is treated as applying to the array type.  If an
4862 attribute that only applies to function types is applied to a
4863 pointer-to-function type, it is treated as applying to the pointer
4864 target type; if such an attribute is applied to a function return type
4865 that is not a pointer-to-function type, it is treated as applying
4866 to the function type.
4868 @node Function Prototypes
4869 @section Prototypes and Old-Style Function Definitions
4870 @cindex function prototype declarations
4871 @cindex old-style function definitions
4872 @cindex promotion of formal parameters
4874 GNU C extends ISO C to allow a function prototype to override a later
4875 old-style non-prototype definition.  Consider the following example:
4877 @smallexample
4878 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4879 #ifdef __STDC__
4880 #define P(x) x
4881 #else
4882 #define P(x) ()
4883 #endif
4885 /* @r{Prototype function declaration.}  */
4886 int isroot P((uid_t));
4888 /* @r{Old-style function definition.}  */
4890 isroot (x)   /* @r{??? lossage here ???} */
4891      uid_t x;
4893   return x == 0;
4895 @end smallexample
4897 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4898 not allow this example, because subword arguments in old-style
4899 non-prototype definitions are promoted.  Therefore in this example the
4900 function definition's argument is really an @code{int}, which does not
4901 match the prototype argument type of @code{short}.
4903 This restriction of ISO C makes it hard to write code that is portable
4904 to traditional C compilers, because the programmer does not know
4905 whether the @code{uid_t} type is @code{short}, @code{int}, or
4906 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4907 to override a later old-style definition.  More precisely, in GNU C, a
4908 function prototype argument type overrides the argument type specified
4909 by a later old-style definition if the former type is the same as the
4910 latter type before promotion.  Thus in GNU C the above example is
4911 equivalent to the following:
4913 @smallexample
4914 int isroot (uid_t);
4917 isroot (uid_t x)
4919   return x == 0;
4921 @end smallexample
4923 @noindent
4924 GNU C++ does not support old-style function definitions, so this
4925 extension is irrelevant.
4927 @node C++ Comments
4928 @section C++ Style Comments
4929 @cindex @code{//}
4930 @cindex C++ comments
4931 @cindex comments, C++ style
4933 In GNU C, you may use C++ style comments, which start with @samp{//} and
4934 continue until the end of the line.  Many other C implementations allow
4935 such comments, and they are included in the 1999 C standard.  However,
4936 C++ style comments are not recognized if you specify an @option{-std}
4937 option specifying a version of ISO C before C99, or @option{-ansi}
4938 (equivalent to @option{-std=c90}).
4940 @node Dollar Signs
4941 @section Dollar Signs in Identifier Names
4942 @cindex $
4943 @cindex dollar signs in identifier names
4944 @cindex identifier names, dollar signs in
4946 In GNU C, you may normally use dollar signs in identifier names.
4947 This is because many traditional C implementations allow such identifiers.
4948 However, dollar signs in identifiers are not supported on a few target
4949 machines, typically because the target assembler does not allow them.
4951 @node Character Escapes
4952 @section The Character @key{ESC} in Constants
4954 You can use the sequence @samp{\e} in a string or character constant to
4955 stand for the ASCII character @key{ESC}.
4957 @node Variable Attributes
4958 @section Specifying Attributes of Variables
4959 @cindex attribute of variables
4960 @cindex variable attributes
4962 The keyword @code{__attribute__} allows you to specify special
4963 attributes of variables or structure fields.  This keyword is followed
4964 by an attribute specification inside double parentheses.  Some
4965 attributes are currently defined generically for variables.
4966 Other attributes are defined for variables on particular target
4967 systems.  Other attributes are available for functions
4968 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
4969 types (@pxref{Type Attributes}).
4970 Other front ends might define more attributes
4971 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4973 You may also specify attributes with @samp{__} preceding and following
4974 each keyword.  This allows you to use them in header files without
4975 being concerned about a possible macro of the same name.  For example,
4976 you may use @code{__aligned__} instead of @code{aligned}.
4978 @xref{Attribute Syntax}, for details of the exact syntax for using
4979 attributes.
4981 @table @code
4982 @cindex @code{aligned} variable attribute
4983 @item aligned (@var{alignment})
4984 This attribute specifies a minimum alignment for the variable or
4985 structure field, measured in bytes.  For example, the declaration:
4987 @smallexample
4988 int x __attribute__ ((aligned (16))) = 0;
4989 @end smallexample
4991 @noindent
4992 causes the compiler to allocate the global variable @code{x} on a
4993 16-byte boundary.  On a 68040, this could be used in conjunction with
4994 an @code{asm} expression to access the @code{move16} instruction which
4995 requires 16-byte aligned operands.
4997 You can also specify the alignment of structure fields.  For example, to
4998 create a double-word aligned @code{int} pair, you could write:
5000 @smallexample
5001 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5002 @end smallexample
5004 @noindent
5005 This is an alternative to creating a union with a @code{double} member,
5006 which forces the union to be double-word aligned.
5008 As in the preceding examples, you can explicitly specify the alignment
5009 (in bytes) that you wish the compiler to use for a given variable or
5010 structure field.  Alternatively, you can leave out the alignment factor
5011 and just ask the compiler to align a variable or field to the
5012 default alignment for the target architecture you are compiling for.
5013 The default alignment is sufficient for all scalar types, but may not be
5014 enough for all vector types on a target that supports vector operations.
5015 The default alignment is fixed for a particular target ABI.
5017 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5018 which is the largest alignment ever used for any data type on the
5019 target machine you are compiling for.  For example, you could write:
5021 @smallexample
5022 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5023 @end smallexample
5025 The compiler automatically sets the alignment for the declared
5026 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5027 often make copy operations more efficient, because the compiler can
5028 use whatever instructions copy the biggest chunks of memory when
5029 performing copies to or from the variables or fields that you have
5030 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5031 may change depending on command-line options.
5033 When used on a struct, or struct member, the @code{aligned} attribute can
5034 only increase the alignment; in order to decrease it, the @code{packed}
5035 attribute must be specified as well.  When used as part of a typedef, the
5036 @code{aligned} attribute can both increase and decrease alignment, and
5037 specifying the @code{packed} attribute generates a warning.
5039 Note that the effectiveness of @code{aligned} attributes may be limited
5040 by inherent limitations in your linker.  On many systems, the linker is
5041 only able to arrange for variables to be aligned up to a certain maximum
5042 alignment.  (For some linkers, the maximum supported alignment may
5043 be very very small.)  If your linker is only able to align variables
5044 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5045 in an @code{__attribute__} still only provides you with 8-byte
5046 alignment.  See your linker documentation for further information.
5048 The @code{aligned} attribute can also be used for functions
5049 (@pxref{Function Attributes}.)
5051 @item cleanup (@var{cleanup_function})
5052 @cindex @code{cleanup} variable attribute
5053 The @code{cleanup} attribute runs a function when the variable goes
5054 out of scope.  This attribute can only be applied to auto function
5055 scope variables; it may not be applied to parameters or variables
5056 with static storage duration.  The function must take one parameter,
5057 a pointer to a type compatible with the variable.  The return value
5058 of the function (if any) is ignored.
5060 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5061 is run during the stack unwinding that happens during the
5062 processing of the exception.  Note that the @code{cleanup} attribute
5063 does not allow the exception to be caught, only to perform an action.
5064 It is undefined what happens if @var{cleanup_function} does not
5065 return normally.
5067 @item common
5068 @itemx nocommon
5069 @cindex @code{common} variable attribute
5070 @cindex @code{nocommon} variable attribute
5071 @opindex fcommon
5072 @opindex fno-common
5073 The @code{common} attribute requests GCC to place a variable in
5074 ``common'' storage.  The @code{nocommon} attribute requests the
5075 opposite---to allocate space for it directly.
5077 These attributes override the default chosen by the
5078 @option{-fno-common} and @option{-fcommon} flags respectively.
5080 @item deprecated
5081 @itemx deprecated (@var{msg})
5082 @cindex @code{deprecated} variable attribute
5083 The @code{deprecated} attribute results in a warning if the variable
5084 is used anywhere in the source file.  This is useful when identifying
5085 variables that are expected to be removed in a future version of a
5086 program.  The warning also includes the location of the declaration
5087 of the deprecated variable, to enable users to easily find further
5088 information about why the variable is deprecated, or what they should
5089 do instead.  Note that the warning only occurs for uses:
5091 @smallexample
5092 extern int old_var __attribute__ ((deprecated));
5093 extern int old_var;
5094 int new_fn () @{ return old_var; @}
5095 @end smallexample
5097 @noindent
5098 results in a warning on line 3 but not line 2.  The optional @var{msg}
5099 argument, which must be a string, is printed in the warning if
5100 present.
5102 The @code{deprecated} attribute can also be used for functions and
5103 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5105 @item mode (@var{mode})
5106 @cindex @code{mode} variable attribute
5107 This attribute specifies the data type for the declaration---whichever
5108 type corresponds to the mode @var{mode}.  This in effect lets you
5109 request an integer or floating-point type according to its width.
5111 You may also specify a mode of @code{byte} or @code{__byte__} to
5112 indicate the mode corresponding to a one-byte integer, @code{word} or
5113 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5114 or @code{__pointer__} for the mode used to represent pointers.
5116 @item packed
5117 @cindex @code{packed} variable attribute
5118 The @code{packed} attribute specifies that a variable or structure field
5119 should have the smallest possible alignment---one byte for a variable,
5120 and one bit for a field, unless you specify a larger value with the
5121 @code{aligned} attribute.
5123 Here is a structure in which the field @code{x} is packed, so that it
5124 immediately follows @code{a}:
5126 @smallexample
5127 struct foo
5129   char a;
5130   int x[2] __attribute__ ((packed));
5132 @end smallexample
5134 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5135 @code{packed} attribute on bit-fields of type @code{char}.  This has
5136 been fixed in GCC 4.4 but the change can lead to differences in the
5137 structure layout.  See the documentation of
5138 @option{-Wpacked-bitfield-compat} for more information.
5140 @item section ("@var{section-name}")
5141 @cindex @code{section} variable attribute
5142 Normally, the compiler places the objects it generates in sections like
5143 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5144 or you need certain particular variables to appear in special sections,
5145 for example to map to special hardware.  The @code{section}
5146 attribute specifies that a variable (or function) lives in a particular
5147 section.  For example, this small program uses several specific section names:
5149 @smallexample
5150 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5151 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5152 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5153 int init_data __attribute__ ((section ("INITDATA")));
5155 main()
5157   /* @r{Initialize stack pointer} */
5158   init_sp (stack + sizeof (stack));
5160   /* @r{Initialize initialized data} */
5161   memcpy (&init_data, &data, &edata - &data);
5163   /* @r{Turn on the serial ports} */
5164   init_duart (&a);
5165   init_duart (&b);
5167 @end smallexample
5169 @noindent
5170 Use the @code{section} attribute with
5171 @emph{global} variables and not @emph{local} variables,
5172 as shown in the example.
5174 You may use the @code{section} attribute with initialized or
5175 uninitialized global variables but the linker requires
5176 each object be defined once, with the exception that uninitialized
5177 variables tentatively go in the @code{common} (or @code{bss}) section
5178 and can be multiply ``defined''.  Using the @code{section} attribute
5179 changes what section the variable goes into and may cause the
5180 linker to issue an error if an uninitialized variable has multiple
5181 definitions.  You can force a variable to be initialized with the
5182 @option{-fno-common} flag or the @code{nocommon} attribute.
5184 Some file formats do not support arbitrary sections so the @code{section}
5185 attribute is not available on all platforms.
5186 If you need to map the entire contents of a module to a particular
5187 section, consider using the facilities of the linker instead.
5189 @item shared
5190 @cindex @code{shared} variable attribute
5191 On Microsoft Windows, in addition to putting variable definitions in a named
5192 section, the section can also be shared among all running copies of an
5193 executable or DLL@.  For example, this small program defines shared data
5194 by putting it in a named section @code{shared} and marking the section
5195 shareable:
5197 @smallexample
5198 int foo __attribute__((section ("shared"), shared)) = 0;
5201 main()
5203   /* @r{Read and write foo.  All running
5204      copies see the same value.}  */
5205   return 0;
5207 @end smallexample
5209 @noindent
5210 You may only use the @code{shared} attribute along with @code{section}
5211 attribute with a fully-initialized global definition because of the way
5212 linkers work.  See @code{section} attribute for more information.
5214 The @code{shared} attribute is only available on Microsoft Windows@.
5216 @item tls_model ("@var{tls_model}")
5217 @cindex @code{tls_model} variable attribute
5218 The @code{tls_model} attribute sets thread-local storage model
5219 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5220 overriding @option{-ftls-model=} command-line switch on a per-variable
5221 basis.
5222 The @var{tls_model} argument should be one of @code{global-dynamic},
5223 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5225 Not all targets support this attribute.
5227 @item unused
5228 @cindex @code{unused} variable attribute
5229 This attribute, attached to a variable, means that the variable is meant
5230 to be possibly unused.  GCC does not produce a warning for this
5231 variable.
5233 @item used
5234 @cindex @code{used} variable attribute
5235 This attribute, attached to a variable with static storage, means that
5236 the variable must be emitted even if it appears that the variable is not
5237 referenced.
5239 When applied to a static data member of a C++ class template, the
5240 attribute also means that the member is instantiated if the
5241 class itself is instantiated.
5243 @item vector_size (@var{bytes})
5244 @cindex @code{vector_size} variable attribute
5245 This attribute specifies the vector size for the variable, measured in
5246 bytes.  For example, the declaration:
5248 @smallexample
5249 int foo __attribute__ ((vector_size (16)));
5250 @end smallexample
5252 @noindent
5253 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5254 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5255 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5257 This attribute is only applicable to integral and float scalars,
5258 although arrays, pointers, and function return values are allowed in
5259 conjunction with this construct.
5261 Aggregates with this attribute are invalid, even if they are of the same
5262 size as a corresponding scalar.  For example, the declaration:
5264 @smallexample
5265 struct S @{ int a; @};
5266 struct S  __attribute__ ((vector_size (16))) foo;
5267 @end smallexample
5269 @noindent
5270 is invalid even if the size of the structure is the same as the size of
5271 the @code{int}.
5273 @item selectany
5274 @cindex @code{selectany} variable attribute
5275 The @code{selectany} attribute causes an initialized global variable to
5276 have link-once semantics.  When multiple definitions of the variable are
5277 encountered by the linker, the first is selected and the remainder are
5278 discarded.  Following usage by the Microsoft compiler, the linker is told
5279 @emph{not} to warn about size or content differences of the multiple
5280 definitions.
5282 Although the primary usage of this attribute is for POD types, the
5283 attribute can also be applied to global C++ objects that are initialized
5284 by a constructor.  In this case, the static initialization and destruction
5285 code for the object is emitted in each translation defining the object,
5286 but the calls to the constructor and destructor are protected by a
5287 link-once guard variable.
5289 The @code{selectany} attribute is only available on Microsoft Windows
5290 targets.  You can use @code{__declspec (selectany)} as a synonym for
5291 @code{__attribute__ ((selectany))} for compatibility with other
5292 compilers.
5294 @item weak
5295 @cindex @code{weak} variable attribute
5296 The @code{weak} attribute is described in @ref{Function Attributes}.
5298 @item dllimport
5299 @cindex @code{dllimport} variable attribute
5300 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5302 @item dllexport
5303 @cindex @code{dllexport} variable attribute
5304 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5306 @end table
5308 @anchor{AVR Variable Attributes}
5309 @subsection AVR Variable Attributes
5311 @table @code
5312 @item progmem
5313 @cindex @code{progmem} variable attribute, AVR
5314 The @code{progmem} attribute is used on the AVR to place read-only
5315 data in the non-volatile program memory (flash). The @code{progmem}
5316 attribute accomplishes this by putting respective variables into a
5317 section whose name starts with @code{.progmem}.
5319 This attribute works similar to the @code{section} attribute
5320 but adds additional checking. Notice that just like the
5321 @code{section} attribute, @code{progmem} affects the location
5322 of the data but not how this data is accessed.
5324 In order to read data located with the @code{progmem} attribute
5325 (inline) assembler must be used.
5326 @smallexample
5327 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5328 #include <avr/pgmspace.h> 
5330 /* Locate var in flash memory */
5331 const int var[2] PROGMEM = @{ 1, 2 @};
5333 int read_var (int i)
5335     /* Access var[] by accessor macro from avr/pgmspace.h */
5336     return (int) pgm_read_word (& var[i]);
5338 @end smallexample
5340 AVR is a Harvard architecture processor and data and read-only data
5341 normally resides in the data memory (RAM).
5343 See also the @ref{AVR Named Address Spaces} section for
5344 an alternate way to locate and access data in flash memory.
5346 @item io
5347 @itemx io (@var{addr})
5348 @cindex @code{io} variable attribute, AVR
5349 Variables with the @code{io} attribute are used to address
5350 memory-mapped peripherals in the io address range.
5351 If an address is specified, the variable
5352 is assigned that address, and the value is interpreted as an
5353 address in the data address space.
5354 Example:
5356 @smallexample
5357 volatile int porta __attribute__((io (0x22)));
5358 @end smallexample
5360 The address specified in the address in the data address range.
5362 Otherwise, the variable it is not assigned an address, but the
5363 compiler will still use in/out instructions where applicable,
5364 assuming some other module assigns an address in the io address range.
5365 Example:
5367 @smallexample
5368 extern volatile int porta __attribute__((io));
5369 @end smallexample
5371 @item io_low
5372 @itemx io_low (@var{addr})
5373 @cindex @code{io_low} variable attribute, AVR
5374 This is like the @code{io} attribute, but additionally it informs the
5375 compiler that the object lies in the lower half of the I/O area,
5376 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5377 instructions.
5379 @item address
5380 @itemx address (@var{addr})
5381 @cindex @code{address} variable attribute, AVR
5382 Variables with the @code{address} attribute are used to address
5383 memory-mapped peripherals that may lie outside the io address range.
5385 @smallexample
5386 volatile int porta __attribute__((address (0x600)));
5387 @end smallexample
5389 @end table
5391 @subsection Blackfin Variable Attributes
5393 Three attributes are currently defined for the Blackfin.
5395 @table @code
5396 @item l1_data
5397 @itemx l1_data_A
5398 @itemx l1_data_B
5399 @cindex @code{l1_data} variable attribute, Blackfin
5400 @cindex @code{l1_data_A} variable attribute, Blackfin
5401 @cindex @code{l1_data_B} variable attribute, Blackfin
5402 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5403 Variables with @code{l1_data} attribute are put into the specific section
5404 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5405 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5406 attribute are put into the specific section named @code{.l1.data.B}.
5408 @item l2
5409 @cindex @code{l2} variable attribute, Blackfin
5410 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5411 Variables with @code{l2} attribute are put into the specific section
5412 named @code{.l2.data}.
5413 @end table
5415 @subsection H8/300 Variable Attributes
5417 These variable attributes are available for H8/300 targets:
5419 @table @code
5420 @item eightbit_data
5421 @cindex @code{eightbit_data} variable attribute, H8/300
5422 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5423 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5424 variable should be placed into the eight-bit data section.
5425 The compiler generates more efficient code for certain operations
5426 on data in the eight-bit data area.  Note the eight-bit data area is limited to
5427 256 bytes of data.
5429 You must use GAS and GLD from GNU binutils version 2.7 or later for
5430 this attribute to work correctly.
5432 @item tiny_data
5433 @cindex @code{tiny_data} variable attribute, H8/300
5434 @cindex tiny data section on the H8/300H and H8S
5435 Use this attribute on the H8/300H and H8S to indicate that the specified
5436 variable should be placed into the tiny data section.
5437 The compiler generates more efficient code for loads and stores
5438 on data in the tiny data section.  Note the tiny data area is limited to
5439 slightly under 32KB of data.
5441 @end table
5443 @subsection IA-64 Variable Attributes
5445 The IA-64 back end supports the following variable attribute:
5447 @table @code
5448 @item model (@var{model-name})
5449 @cindex @code{model} variable attribute, IA-64
5451 On IA-64, use this attribute to set the addressability of an object.
5452 At present, the only supported identifier for @var{model-name} is
5453 @code{small}, indicating addressability via ``small'' (22-bit)
5454 addresses (so that their addresses can be loaded with the @code{addl}
5455 instruction).  Caveat: such addressing is by definition not position
5456 independent and hence this attribute must not be used for objects
5457 defined by shared libraries.
5459 @end table
5461 @subsection M32R/D Variable Attributes
5463 One attribute is currently defined for the M32R/D@.
5465 @table @code
5466 @item model (@var{model-name})
5467 @cindex @code{model-name} variable attribute, M32R/D
5468 @cindex variable addressability on the M32R/D
5469 Use this attribute on the M32R/D to set the addressability of an object.
5470 The identifier @var{model-name} is one of @code{small}, @code{medium},
5471 or @code{large}, representing each of the code models.
5473 Small model objects live in the lower 16MB of memory (so that their
5474 addresses can be loaded with the @code{ld24} instruction).
5476 Medium and large model objects may live anywhere in the 32-bit address space
5477 (the compiler generates @code{seth/add3} instructions to load their
5478 addresses).
5479 @end table
5481 @anchor{MeP Variable Attributes}
5482 @subsection MeP Variable Attributes
5484 The MeP target has a number of addressing modes and busses.  The
5485 @code{near} space spans the standard memory space's first 16 megabytes
5486 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5487 The @code{based} space is a 128-byte region in the memory space that
5488 is addressed relative to the @code{$tp} register.  The @code{tiny}
5489 space is a 65536-byte region relative to the @code{$gp} register.  In
5490 addition to these memory regions, the MeP target has a separate 16-bit
5491 control bus which is specified with @code{cb} attributes.
5493 @table @code
5495 @item based
5496 @cindex @code{based} variable attribute, MeP
5497 Any variable with the @code{based} attribute is assigned to the
5498 @code{.based} section, and is accessed with relative to the
5499 @code{$tp} register.
5501 @item tiny
5502 @cindex @code{tiny} variable attribute, MeP
5503 Likewise, the @code{tiny} attribute assigned variables to the
5504 @code{.tiny} section, relative to the @code{$gp} register.
5506 @item near
5507 @cindex @code{near} variable attribute, MeP
5508 Variables with the @code{near} attribute are assumed to have addresses
5509 that fit in a 24-bit addressing mode.  This is the default for large
5510 variables (@code{-mtiny=4} is the default) but this attribute can
5511 override @code{-mtiny=} for small variables, or override @code{-ml}.
5513 @item far
5514 @cindex @code{far} variable attribute, MeP
5515 Variables with the @code{far} attribute are addressed using a full
5516 32-bit address.  Since this covers the entire memory space, this
5517 allows modules to make no assumptions about where variables might be
5518 stored.
5520 @item io
5521 @cindex @code{io} variable attribute, MeP
5522 @itemx io (@var{addr})
5523 Variables with the @code{io} attribute are used to address
5524 memory-mapped peripherals.  If an address is specified, the variable
5525 is assigned that address, else it is not assigned an address (it is
5526 assumed some other module assigns an address).  Example:
5528 @smallexample
5529 int timer_count __attribute__((io(0x123)));
5530 @end smallexample
5532 @item cb
5533 @itemx cb (@var{addr})
5534 @cindex @code{cb} variable attribute, MeP
5535 Variables with the @code{cb} attribute are used to access the control
5536 bus, using special instructions.  @code{addr} indicates the control bus
5537 address.  Example:
5539 @smallexample
5540 int cpu_clock __attribute__((cb(0x123)));
5541 @end smallexample
5543 @end table
5545 @subsection PowerPC Variable Attributes
5547 Three attributes currently are defined for PowerPC configurations:
5548 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5550 @cindex @code{ms_struct} variable attribute, PowerPC
5551 @cindex @code{gcc_struct} variable attribute, PowerPC
5552 For full documentation of the struct attributes please see the
5553 documentation in @ref{x86 Variable Attributes}.
5555 @cindex @code{altivec} variable attribute, PowerPC
5556 For documentation of @code{altivec} attribute please see the
5557 documentation in @ref{PowerPC Type Attributes}.
5559 @subsection SPU Variable Attributes
5561 @cindex @code{spu_vector} variable attribute, SPU
5562 The SPU supports the @code{spu_vector} attribute for variables.  For
5563 documentation of this attribute please see the documentation in
5564 @ref{SPU Type Attributes}.
5566 @anchor{x86 Variable Attributes}
5567 @subsection x86 Variable Attributes
5569 Two attributes are currently defined for x86 configurations:
5570 @code{ms_struct} and @code{gcc_struct}.
5572 @table @code
5573 @item ms_struct
5574 @itemx gcc_struct
5575 @cindex @code{ms_struct} variable attribute, x86
5576 @cindex @code{gcc_struct} variable attribute, x86
5578 If @code{packed} is used on a structure, or if bit-fields are used,
5579 it may be that the Microsoft ABI lays out the structure differently
5580 than the way GCC normally does.  Particularly when moving packed
5581 data between functions compiled with GCC and the native Microsoft compiler
5582 (either via function call or as data in a file), it may be necessary to access
5583 either format.
5585 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5586 compilers to match the native Microsoft compiler.
5588 The Microsoft structure layout algorithm is fairly simple with the exception
5589 of the bit-field packing.  
5590 The padding and alignment of members of structures and whether a bit-field 
5591 can straddle a storage-unit boundary are determine by these rules:
5593 @enumerate
5594 @item Structure members are stored sequentially in the order in which they are
5595 declared: the first member has the lowest memory address and the last member
5596 the highest.
5598 @item Every data object has an alignment requirement.  The alignment requirement
5599 for all data except structures, unions, and arrays is either the size of the
5600 object or the current packing size (specified with either the
5601 @code{aligned} attribute or the @code{pack} pragma),
5602 whichever is less.  For structures, unions, and arrays,
5603 the alignment requirement is the largest alignment requirement of its members.
5604 Every object is allocated an offset so that:
5606 @smallexample
5607 offset % alignment_requirement == 0
5608 @end smallexample
5610 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5611 unit if the integral types are the same size and if the next bit-field fits
5612 into the current allocation unit without crossing the boundary imposed by the
5613 common alignment requirements of the bit-fields.
5614 @end enumerate
5616 MSVC interprets zero-length bit-fields in the following ways:
5618 @enumerate
5619 @item If a zero-length bit-field is inserted between two bit-fields that
5620 are normally coalesced, the bit-fields are not coalesced.
5622 For example:
5624 @smallexample
5625 struct
5626  @{
5627    unsigned long bf_1 : 12;
5628    unsigned long : 0;
5629    unsigned long bf_2 : 12;
5630  @} t1;
5631 @end smallexample
5633 @noindent
5634 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5635 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5637 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5638 alignment of the zero-length bit-field is greater than the member that follows it,
5639 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5641 For example:
5643 @smallexample
5644 struct
5645  @{
5646    char foo : 4;
5647    short : 0;
5648    char bar;
5649  @} t2;
5651 struct
5652  @{
5653    char foo : 4;
5654    short : 0;
5655    double bar;
5656  @} t3;
5657 @end smallexample
5659 @noindent
5660 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5661 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5662 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5663 of the structure.
5665 Taking this into account, it is important to note the following:
5667 @enumerate
5668 @item If a zero-length bit-field follows a normal bit-field, the type of the
5669 zero-length bit-field may affect the alignment of the structure as whole. For
5670 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5671 normal bit-field, and is of type short.
5673 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5674 still affect the alignment of the structure:
5676 @smallexample
5677 struct
5678  @{
5679    char foo : 6;
5680    long : 0;
5681  @} t4;
5682 @end smallexample
5684 @noindent
5685 Here, @code{t4} takes up 4 bytes.
5686 @end enumerate
5688 @item Zero-length bit-fields following non-bit-field members are ignored:
5690 @smallexample
5691 struct
5692  @{
5693    char foo;
5694    long : 0;
5695    char bar;
5696  @} t5;
5697 @end smallexample
5699 @noindent
5700 Here, @code{t5} takes up 2 bytes.
5701 @end enumerate
5702 @end table
5704 @subsection Xstormy16 Variable Attributes
5706 One attribute is currently defined for xstormy16 configurations:
5707 @code{below100}.
5709 @table @code
5710 @item below100
5711 @cindex @code{below100} variable attribute, Xstormy16
5713 If a variable has the @code{below100} attribute (@code{BELOW100} is
5714 allowed also), GCC places the variable in the first 0x100 bytes of
5715 memory and use special opcodes to access it.  Such variables are
5716 placed in either the @code{.bss_below100} section or the
5717 @code{.data_below100} section.
5719 @end table
5721 @node Type Attributes
5722 @section Specifying Attributes of Types
5723 @cindex attribute of types
5724 @cindex type attributes
5726 The keyword @code{__attribute__} allows you to specify special
5727 attributes of @code{struct} and @code{union} types when you define
5728 such types.  This keyword is followed by an attribute specification
5729 inside double parentheses.  Eight attributes are currently defined for
5730 types: @code{aligned}, @code{packed}, @code{transparent_union},
5731 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5732 and @code{bnd_variable_size}.  Other attributes are defined for
5733 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5734 Attributes}) and for variables (@pxref{Variable Attributes}).
5736 You may also specify any one of these attributes with @samp{__}
5737 preceding and following its keyword.  This allows you to use these
5738 attributes in header files without being concerned about a possible
5739 macro of the same name.  For example, you may use @code{__aligned__}
5740 instead of @code{aligned}.
5742 You may specify type attributes in an enum, struct or union type
5743 declaration or definition, or for other types in a @code{typedef}
5744 declaration.
5746 For an enum, struct or union type, you may specify attributes either
5747 between the enum, struct or union tag and the name of the type, or
5748 just past the closing curly brace of the @emph{definition}.  The
5749 former syntax is preferred.
5751 @xref{Attribute Syntax}, for details of the exact syntax for using
5752 attributes.
5754 @table @code
5755 @cindex @code{aligned} type attribute
5756 @item aligned (@var{alignment})
5757 This attribute specifies a minimum alignment (in bytes) for variables
5758 of the specified type.  For example, the declarations:
5760 @smallexample
5761 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5762 typedef int more_aligned_int __attribute__ ((aligned (8)));
5763 @end smallexample
5765 @noindent
5766 force the compiler to ensure (as far as it can) that each variable whose
5767 type is @code{struct S} or @code{more_aligned_int} is allocated and
5768 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5769 variables of type @code{struct S} aligned to 8-byte boundaries allows
5770 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5771 store) instructions when copying one variable of type @code{struct S} to
5772 another, thus improving run-time efficiency.
5774 Note that the alignment of any given @code{struct} or @code{union} type
5775 is required by the ISO C standard to be at least a perfect multiple of
5776 the lowest common multiple of the alignments of all of the members of
5777 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5778 effectively adjust the alignment of a @code{struct} or @code{union}
5779 type by attaching an @code{aligned} attribute to any one of the members
5780 of such a type, but the notation illustrated in the example above is a
5781 more obvious, intuitive, and readable way to request the compiler to
5782 adjust the alignment of an entire @code{struct} or @code{union} type.
5784 As in the preceding example, you can explicitly specify the alignment
5785 (in bytes) that you wish the compiler to use for a given @code{struct}
5786 or @code{union} type.  Alternatively, you can leave out the alignment factor
5787 and just ask the compiler to align a type to the maximum
5788 useful alignment for the target machine you are compiling for.  For
5789 example, you could write:
5791 @smallexample
5792 struct S @{ short f[3]; @} __attribute__ ((aligned));
5793 @end smallexample
5795 Whenever you leave out the alignment factor in an @code{aligned}
5796 attribute specification, the compiler automatically sets the alignment
5797 for the type to the largest alignment that is ever used for any data
5798 type on the target machine you are compiling for.  Doing this can often
5799 make copy operations more efficient, because the compiler can use
5800 whatever instructions copy the biggest chunks of memory when performing
5801 copies to or from the variables that have types that you have aligned
5802 this way.
5804 In the example above, if the size of each @code{short} is 2 bytes, then
5805 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5806 power of two that is greater than or equal to that is 8, so the
5807 compiler sets the alignment for the entire @code{struct S} type to 8
5808 bytes.
5810 Note that although you can ask the compiler to select a time-efficient
5811 alignment for a given type and then declare only individual stand-alone
5812 objects of that type, the compiler's ability to select a time-efficient
5813 alignment is primarily useful only when you plan to create arrays of
5814 variables having the relevant (efficiently aligned) type.  If you
5815 declare or use arrays of variables of an efficiently-aligned type, then
5816 it is likely that your program also does pointer arithmetic (or
5817 subscripting, which amounts to the same thing) on pointers to the
5818 relevant type, and the code that the compiler generates for these
5819 pointer arithmetic operations is often more efficient for
5820 efficiently-aligned types than for other types.
5822 The @code{aligned} attribute can only increase the alignment; but you
5823 can decrease it by specifying @code{packed} as well.  See below.
5825 Note that the effectiveness of @code{aligned} attributes may be limited
5826 by inherent limitations in your linker.  On many systems, the linker is
5827 only able to arrange for variables to be aligned up to a certain maximum
5828 alignment.  (For some linkers, the maximum supported alignment may
5829 be very very small.)  If your linker is only able to align variables
5830 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5831 in an @code{__attribute__} still only provides you with 8-byte
5832 alignment.  See your linker documentation for further information.
5834 @item packed
5835 @cindex @code{packed} type attribute
5836 This attribute, attached to @code{struct} or @code{union} type
5837 definition, specifies that each member (other than zero-width bit-fields)
5838 of the structure or union is placed to minimize the memory required.  When
5839 attached to an @code{enum} definition, it indicates that the smallest
5840 integral type should be used.
5842 @opindex fshort-enums
5843 Specifying this attribute for @code{struct} and @code{union} types is
5844 equivalent to specifying the @code{packed} attribute on each of the
5845 structure or union members.  Specifying the @option{-fshort-enums}
5846 flag on the line is equivalent to specifying the @code{packed}
5847 attribute on all @code{enum} definitions.
5849 In the following example @code{struct my_packed_struct}'s members are
5850 packed closely together, but the internal layout of its @code{s} member
5851 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5852 be packed too.
5854 @smallexample
5855 struct my_unpacked_struct
5856  @{
5857     char c;
5858     int i;
5859  @};
5861 struct __attribute__ ((__packed__)) my_packed_struct
5862   @{
5863      char c;
5864      int  i;
5865      struct my_unpacked_struct s;
5866   @};
5867 @end smallexample
5869 You may only specify this attribute on the definition of an @code{enum},
5870 @code{struct} or @code{union}, not on a @code{typedef} that does not
5871 also define the enumerated type, structure or union.
5873 @item transparent_union
5874 @cindex @code{transparent_union} type attribute
5876 This attribute, attached to a @code{union} type definition, indicates
5877 that any function parameter having that union type causes calls to that
5878 function to be treated in a special way.
5880 First, the argument corresponding to a transparent union type can be of
5881 any type in the union; no cast is required.  Also, if the union contains
5882 a pointer type, the corresponding argument can be a null pointer
5883 constant or a void pointer expression; and if the union contains a void
5884 pointer type, the corresponding argument can be any pointer expression.
5885 If the union member type is a pointer, qualifiers like @code{const} on
5886 the referenced type must be respected, just as with normal pointer
5887 conversions.
5889 Second, the argument is passed to the function using the calling
5890 conventions of the first member of the transparent union, not the calling
5891 conventions of the union itself.  All members of the union must have the
5892 same machine representation; this is necessary for this argument passing
5893 to work properly.
5895 Transparent unions are designed for library functions that have multiple
5896 interfaces for compatibility reasons.  For example, suppose the
5897 @code{wait} function must accept either a value of type @code{int *} to
5898 comply with POSIX, or a value of type @code{union wait *} to comply with
5899 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5900 @code{wait} would accept both kinds of arguments, but it would also
5901 accept any other pointer type and this would make argument type checking
5902 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5903 as follows:
5905 @smallexample
5906 typedef union __attribute__ ((__transparent_union__))
5907   @{
5908     int *__ip;
5909     union wait *__up;
5910   @} wait_status_ptr_t;
5912 pid_t wait (wait_status_ptr_t);
5913 @end smallexample
5915 @noindent
5916 This interface allows either @code{int *} or @code{union wait *}
5917 arguments to be passed, using the @code{int *} calling convention.
5918 The program can call @code{wait} with arguments of either type:
5920 @smallexample
5921 int w1 () @{ int w; return wait (&w); @}
5922 int w2 () @{ union wait w; return wait (&w); @}
5923 @end smallexample
5925 @noindent
5926 With this interface, @code{wait}'s implementation might look like this:
5928 @smallexample
5929 pid_t wait (wait_status_ptr_t p)
5931   return waitpid (-1, p.__ip, 0);
5933 @end smallexample
5935 @item unused
5936 @cindex @code{unused} type attribute
5937 When attached to a type (including a @code{union} or a @code{struct}),
5938 this attribute means that variables of that type are meant to appear
5939 possibly unused.  GCC does not produce a warning for any variables of
5940 that type, even if the variable appears to do nothing.  This is often
5941 the case with lock or thread classes, which are usually defined and then
5942 not referenced, but contain constructors and destructors that have
5943 nontrivial bookkeeping functions.
5945 @item deprecated
5946 @itemx deprecated (@var{msg})
5947 @cindex @code{deprecated} type attribute
5948 The @code{deprecated} attribute results in a warning if the type
5949 is used anywhere in the source file.  This is useful when identifying
5950 types that are expected to be removed in a future version of a program.
5951 If possible, the warning also includes the location of the declaration
5952 of the deprecated type, to enable users to easily find further
5953 information about why the type is deprecated, or what they should do
5954 instead.  Note that the warnings only occur for uses and then only
5955 if the type is being applied to an identifier that itself is not being
5956 declared as deprecated.
5958 @smallexample
5959 typedef int T1 __attribute__ ((deprecated));
5960 T1 x;
5961 typedef T1 T2;
5962 T2 y;
5963 typedef T1 T3 __attribute__ ((deprecated));
5964 T3 z __attribute__ ((deprecated));
5965 @end smallexample
5967 @noindent
5968 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5969 warning is issued for line 4 because T2 is not explicitly
5970 deprecated.  Line 5 has no warning because T3 is explicitly
5971 deprecated.  Similarly for line 6.  The optional @var{msg}
5972 argument, which must be a string, is printed in the warning if
5973 present.
5975 The @code{deprecated} attribute can also be used for functions and
5976 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5978 @item may_alias
5979 @cindex @code{may_alias} type attribute
5980 Accesses through pointers to types with this attribute are not subject
5981 to type-based alias analysis, but are instead assumed to be able to alias
5982 any other type of objects.
5983 In the context of section 6.5 paragraph 7 of the C99 standard,
5984 an lvalue expression
5985 dereferencing such a pointer is treated like having a character type.
5986 See @option{-fstrict-aliasing} for more information on aliasing issues.
5987 This extension exists to support some vector APIs, in which pointers to
5988 one vector type are permitted to alias pointers to a different vector type.
5990 Note that an object of a type with this attribute does not have any
5991 special semantics.
5993 Example of use:
5995 @smallexample
5996 typedef short __attribute__((__may_alias__)) short_a;
5999 main (void)
6001   int a = 0x12345678;
6002   short_a *b = (short_a *) &a;
6004   b[1] = 0;
6006   if (a == 0x12345678)
6007     abort();
6009   exit(0);
6011 @end smallexample
6013 @noindent
6014 If you replaced @code{short_a} with @code{short} in the variable
6015 declaration, the above program would abort when compiled with
6016 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6017 above.
6019 @item visibility
6020 @cindex @code{visibility} type attribute
6021 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6022 applied to class, struct, union and enum types.  Unlike other type
6023 attributes, the attribute must appear between the initial keyword and
6024 the name of the type; it cannot appear after the body of the type.
6026 Note that the type visibility is applied to vague linkage entities
6027 associated with the class (vtable, typeinfo node, etc.).  In
6028 particular, if a class is thrown as an exception in one shared object
6029 and caught in another, the class must have default visibility.
6030 Otherwise the two shared objects are unable to use the same
6031 typeinfo node and exception handling will break.
6033 @item designated_init
6034 @cindex @code{designated_init} type attribute
6035 This attribute may only be applied to structure types.  It indicates
6036 that any initialization of an object of this type must use designated
6037 initializers rather than positional initializers.  The intent of this
6038 attribute is to allow the programmer to indicate that a structure's
6039 layout may change, and that therefore relying on positional
6040 initialization will result in future breakage.
6042 GCC emits warnings based on this attribute by default; use
6043 @option{-Wno-designated-init} to suppress them.
6045 @item bnd_variable_size
6046 @cindex @code{bnd_variable_size} type attribute
6047 @cindex Pointer Bounds Checker attributes
6048 When applied to a structure field, this attribute tells Pointer
6049 Bounds Checker that the size of this field should not be computed
6050 using static type information.  It may be used to mark variably-sized
6051 static array fields placed at the end of a structure.
6053 @smallexample
6054 struct S
6056   int size;
6057   char data[1];
6059 S *p = (S *)malloc (sizeof(S) + 100);
6060 p->data[10] = 0; //Bounds violation
6061 @end smallexample
6063 @noindent
6064 By using an attribute for the field we may avoid unwanted bound
6065 violation checks:
6067 @smallexample
6068 struct S
6070   int size;
6071   char data[1] __attribute__((bnd_variable_size));
6073 S *p = (S *)malloc (sizeof(S) + 100);
6074 p->data[10] = 0; //OK
6075 @end smallexample
6077 @end table
6079 To specify multiple attributes, separate them by commas within the
6080 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6081 packed))}.
6083 @subsection ARM Type Attributes
6085 @cindex @code{notshared} type attribute, ARM
6086 On those ARM targets that support @code{dllimport} (such as Symbian
6087 OS), you can use the @code{notshared} attribute to indicate that the
6088 virtual table and other similar data for a class should not be
6089 exported from a DLL@.  For example:
6091 @smallexample
6092 class __declspec(notshared) C @{
6093 public:
6094   __declspec(dllimport) C();
6095   virtual void f();
6098 __declspec(dllexport)
6099 C::C() @{@}
6100 @end smallexample
6102 @noindent
6103 In this code, @code{C::C} is exported from the current DLL, but the
6104 virtual table for @code{C} is not exported.  (You can use
6105 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6106 most Symbian OS code uses @code{__declspec}.)
6108 @anchor{MeP Type Attributes}
6109 @subsection MeP Type Attributes
6111 @cindex @code{based} type attribute, MeP
6112 @cindex @code{tiny} type attribute, MeP
6113 @cindex @code{near} type attribute, MeP
6114 @cindex @code{far} type attribute, MeP
6115 Many of the MeP variable attributes may be applied to types as well.
6116 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6117 @code{far} attributes may be applied to either.  The @code{io} and
6118 @code{cb} attributes may not be applied to types.
6120 @anchor{PowerPC Type Attributes}
6121 @subsection PowerPC Type Attributes
6123 Three attributes currently are defined for PowerPC configurations:
6124 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6126 @cindex @code{ms_struct} type attribute, PowerPC
6127 @cindex @code{gcc_struct} type attribute, PowerPC
6128 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6129 attributes please see the documentation in @ref{x86 Type Attributes}.
6131 @cindex @code{altivec} type attribute, PowerPC
6132 The @code{altivec} attribute allows one to declare AltiVec vector data
6133 types supported by the AltiVec Programming Interface Manual.  The
6134 attribute requires an argument to specify one of three vector types:
6135 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6136 and @code{bool__} (always followed by unsigned).
6138 @smallexample
6139 __attribute__((altivec(vector__)))
6140 __attribute__((altivec(pixel__))) unsigned short
6141 __attribute__((altivec(bool__))) unsigned
6142 @end smallexample
6144 These attributes mainly are intended to support the @code{__vector},
6145 @code{__pixel}, and @code{__bool} AltiVec keywords.
6147 @anchor{SPU Type Attributes}
6148 @subsection SPU Type Attributes
6150 @cindex @code{spu_vector} type attribute, SPU
6151 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6152 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6153 Language Extensions Specification.  It is intended to support the
6154 @code{__vector} keyword.
6156 @anchor{x86 Type Attributes}
6157 @subsection x86 Type Attributes
6159 Two attributes are currently defined for x86 configurations:
6160 @code{ms_struct} and @code{gcc_struct}.
6162 @table @code
6164 @item ms_struct
6165 @itemx gcc_struct
6166 @cindex @code{ms_struct} type attribute, x86
6167 @cindex @code{gcc_struct} type attribute, x86
6169 If @code{packed} is used on a structure, or if bit-fields are used
6170 it may be that the Microsoft ABI packs them differently
6171 than GCC normally packs them.  Particularly when moving packed
6172 data between functions compiled with GCC and the native Microsoft compiler
6173 (either via function call or as data in a file), it may be necessary to access
6174 either format.
6176 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6177 compilers to match the native Microsoft compiler.
6178 @end table
6180 @node Alignment
6181 @section Inquiring on Alignment of Types or Variables
6182 @cindex alignment
6183 @cindex type alignment
6184 @cindex variable alignment
6186 The keyword @code{__alignof__} allows you to inquire about how an object
6187 is aligned, or the minimum alignment usually required by a type.  Its
6188 syntax is just like @code{sizeof}.
6190 For example, if the target machine requires a @code{double} value to be
6191 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6192 This is true on many RISC machines.  On more traditional machine
6193 designs, @code{__alignof__ (double)} is 4 or even 2.
6195 Some machines never actually require alignment; they allow reference to any
6196 data type even at an odd address.  For these machines, @code{__alignof__}
6197 reports the smallest alignment that GCC gives the data type, usually as
6198 mandated by the target ABI.
6200 If the operand of @code{__alignof__} is an lvalue rather than a type,
6201 its value is the required alignment for its type, taking into account
6202 any minimum alignment specified with GCC's @code{__attribute__}
6203 extension (@pxref{Variable Attributes}).  For example, after this
6204 declaration:
6206 @smallexample
6207 struct foo @{ int x; char y; @} foo1;
6208 @end smallexample
6210 @noindent
6211 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6212 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6214 It is an error to ask for the alignment of an incomplete type.
6217 @node Inline
6218 @section An Inline Function is As Fast As a Macro
6219 @cindex inline functions
6220 @cindex integrating function code
6221 @cindex open coding
6222 @cindex macros, inline alternative
6224 By declaring a function inline, you can direct GCC to make
6225 calls to that function faster.  One way GCC can achieve this is to
6226 integrate that function's code into the code for its callers.  This
6227 makes execution faster by eliminating the function-call overhead; in
6228 addition, if any of the actual argument values are constant, their
6229 known values may permit simplifications at compile time so that not
6230 all of the inline function's code needs to be included.  The effect on
6231 code size is less predictable; object code may be larger or smaller
6232 with function inlining, depending on the particular case.  You can
6233 also direct GCC to try to integrate all ``simple enough'' functions
6234 into their callers with the option @option{-finline-functions}.
6236 GCC implements three different semantics of declaring a function
6237 inline.  One is available with @option{-std=gnu89} or
6238 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6239 on all inline declarations, another when
6240 @option{-std=c99}, @option{-std=c11},
6241 @option{-std=gnu99} or @option{-std=gnu11}
6242 (without @option{-fgnu89-inline}), and the third
6243 is used when compiling C++.
6245 To declare a function inline, use the @code{inline} keyword in its
6246 declaration, like this:
6248 @smallexample
6249 static inline int
6250 inc (int *a)
6252   return (*a)++;
6254 @end smallexample
6256 If you are writing a header file to be included in ISO C90 programs, write
6257 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6259 The three types of inlining behave similarly in two important cases:
6260 when the @code{inline} keyword is used on a @code{static} function,
6261 like the example above, and when a function is first declared without
6262 using the @code{inline} keyword and then is defined with
6263 @code{inline}, like this:
6265 @smallexample
6266 extern int inc (int *a);
6267 inline int
6268 inc (int *a)
6270   return (*a)++;
6272 @end smallexample
6274 In both of these common cases, the program behaves the same as if you
6275 had not used the @code{inline} keyword, except for its speed.
6277 @cindex inline functions, omission of
6278 @opindex fkeep-inline-functions
6279 When a function is both inline and @code{static}, if all calls to the
6280 function are integrated into the caller, and the function's address is
6281 never used, then the function's own assembler code is never referenced.
6282 In this case, GCC does not actually output assembler code for the
6283 function, unless you specify the option @option{-fkeep-inline-functions}.
6284 Some calls cannot be integrated for various reasons (in particular,
6285 calls that precede the function's definition cannot be integrated, and
6286 neither can recursive calls within the definition).  If there is a
6287 nonintegrated call, then the function is compiled to assembler code as
6288 usual.  The function must also be compiled as usual if the program
6289 refers to its address, because that can't be inlined.
6291 @opindex Winline
6292 Note that certain usages in a function definition can make it unsuitable
6293 for inline substitution.  Among these usages are: variadic functions, use of
6294 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6295 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6296 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6297 warns when a function marked @code{inline} could not be substituted,
6298 and gives the reason for the failure.
6300 @cindex automatic @code{inline} for C++ member fns
6301 @cindex @code{inline} automatic for C++ member fns
6302 @cindex member fns, automatically @code{inline}
6303 @cindex C++ member fns, automatically @code{inline}
6304 @opindex fno-default-inline
6305 As required by ISO C++, GCC considers member functions defined within
6306 the body of a class to be marked inline even if they are
6307 not explicitly declared with the @code{inline} keyword.  You can
6308 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6309 Options,,Options Controlling C++ Dialect}.
6311 GCC does not inline any functions when not optimizing unless you specify
6312 the @samp{always_inline} attribute for the function, like this:
6314 @smallexample
6315 /* @r{Prototype.}  */
6316 inline void foo (const char) __attribute__((always_inline));
6317 @end smallexample
6319 The remainder of this section is specific to GNU C90 inlining.
6321 @cindex non-static inline function
6322 When an inline function is not @code{static}, then the compiler must assume
6323 that there may be calls from other source files; since a global symbol can
6324 be defined only once in any program, the function must not be defined in
6325 the other source files, so the calls therein cannot be integrated.
6326 Therefore, a non-@code{static} inline function is always compiled on its
6327 own in the usual fashion.
6329 If you specify both @code{inline} and @code{extern} in the function
6330 definition, then the definition is used only for inlining.  In no case
6331 is the function compiled on its own, not even if you refer to its
6332 address explicitly.  Such an address becomes an external reference, as
6333 if you had only declared the function, and had not defined it.
6335 This combination of @code{inline} and @code{extern} has almost the
6336 effect of a macro.  The way to use it is to put a function definition in
6337 a header file with these keywords, and put another copy of the
6338 definition (lacking @code{inline} and @code{extern}) in a library file.
6339 The definition in the header file causes most calls to the function
6340 to be inlined.  If any uses of the function remain, they refer to
6341 the single copy in the library.
6343 @node Volatiles
6344 @section When is a Volatile Object Accessed?
6345 @cindex accessing volatiles
6346 @cindex volatile read
6347 @cindex volatile write
6348 @cindex volatile access
6350 C has the concept of volatile objects.  These are normally accessed by
6351 pointers and used for accessing hardware or inter-thread
6352 communication.  The standard encourages compilers to refrain from
6353 optimizations concerning accesses to volatile objects, but leaves it
6354 implementation defined as to what constitutes a volatile access.  The
6355 minimum requirement is that at a sequence point all previous accesses
6356 to volatile objects have stabilized and no subsequent accesses have
6357 occurred.  Thus an implementation is free to reorder and combine
6358 volatile accesses that occur between sequence points, but cannot do
6359 so for accesses across a sequence point.  The use of volatile does
6360 not allow you to violate the restriction on updating objects multiple
6361 times between two sequence points.
6363 Accesses to non-volatile objects are not ordered with respect to
6364 volatile accesses.  You cannot use a volatile object as a memory
6365 barrier to order a sequence of writes to non-volatile memory.  For
6366 instance:
6368 @smallexample
6369 int *ptr = @var{something};
6370 volatile int vobj;
6371 *ptr = @var{something};
6372 vobj = 1;
6373 @end smallexample
6375 @noindent
6376 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6377 that the write to @var{*ptr} occurs by the time the update
6378 of @var{vobj} happens.  If you need this guarantee, you must use
6379 a stronger memory barrier such as:
6381 @smallexample
6382 int *ptr = @var{something};
6383 volatile int vobj;
6384 *ptr = @var{something};
6385 asm volatile ("" : : : "memory");
6386 vobj = 1;
6387 @end smallexample
6389 A scalar volatile object is read when it is accessed in a void context:
6391 @smallexample
6392 volatile int *src = @var{somevalue};
6393 *src;
6394 @end smallexample
6396 Such expressions are rvalues, and GCC implements this as a
6397 read of the volatile object being pointed to.
6399 Assignments are also expressions and have an rvalue.  However when
6400 assigning to a scalar volatile, the volatile object is not reread,
6401 regardless of whether the assignment expression's rvalue is used or
6402 not.  If the assignment's rvalue is used, the value is that assigned
6403 to the volatile object.  For instance, there is no read of @var{vobj}
6404 in all the following cases:
6406 @smallexample
6407 int obj;
6408 volatile int vobj;
6409 vobj = @var{something};
6410 obj = vobj = @var{something};
6411 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6412 obj = (@var{something}, vobj = @var{anotherthing});
6413 @end smallexample
6415 If you need to read the volatile object after an assignment has
6416 occurred, you must use a separate expression with an intervening
6417 sequence point.
6419 As bit-fields are not individually addressable, volatile bit-fields may
6420 be implicitly read when written to, or when adjacent bit-fields are
6421 accessed.  Bit-field operations may be optimized such that adjacent
6422 bit-fields are only partially accessed, if they straddle a storage unit
6423 boundary.  For these reasons it is unwise to use volatile bit-fields to
6424 access hardware.
6426 @node Using Assembly Language with C
6427 @section How to Use Inline Assembly Language in C Code
6428 @cindex @code{asm} keyword
6429 @cindex assembly language in C
6430 @cindex inline assembly language
6431 @cindex mixing assembly language and C
6433 The @code{asm} keyword allows you to embed assembler instructions
6434 within C code.  GCC provides two forms of inline @code{asm}
6435 statements.  A @dfn{basic @code{asm}} statement is one with no
6436 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
6437 statement (@pxref{Extended Asm}) includes one or more operands.  
6438 The extended form is preferred for mixing C and assembly language
6439 within a function, but to include assembly language at
6440 top level you must use basic @code{asm}.
6442 You can also use the @code{asm} keyword to override the assembler name
6443 for a C symbol, or to place a C variable in a specific register.
6445 @menu
6446 * Basic Asm::          Inline assembler without operands.
6447 * Extended Asm::       Inline assembler with operands.
6448 * Constraints::        Constraints for @code{asm} operands
6449 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6450 * Explicit Reg Vars::  Defining variables residing in specified registers.
6451 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6452 @end menu
6454 @node Basic Asm
6455 @subsection Basic Asm --- Assembler Instructions Without Operands
6456 @cindex basic @code{asm}
6457 @cindex assembly language in C, basic
6459 A basic @code{asm} statement has the following syntax:
6461 @example
6462 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
6463 @end example
6465 The @code{asm} keyword is a GNU extension.
6466 When writing code that can be compiled with @option{-ansi} and the
6467 various @option{-std} options, use @code{__asm__} instead of 
6468 @code{asm} (@pxref{Alternate Keywords}).
6470 @subsubheading Qualifiers
6471 @table @code
6472 @item volatile
6473 The optional @code{volatile} qualifier has no effect. 
6474 All basic @code{asm} blocks are implicitly volatile.
6475 @end table
6477 @subsubheading Parameters
6478 @table @var
6480 @item AssemblerInstructions
6481 This is a literal string that specifies the assembler code. The string can 
6482 contain any instructions recognized by the assembler, including directives. 
6483 GCC does not parse the assembler instructions themselves and 
6484 does not know what they mean or even whether they are valid assembler input. 
6486 You may place multiple assembler instructions together in a single @code{asm} 
6487 string, separated by the characters normally used in assembly code for the 
6488 system. A combination that works in most places is a newline to break the 
6489 line, plus a tab character (written as @samp{\n\t}).
6490 Some assemblers allow semicolons as a line separator. However, 
6491 note that some assembler dialects use semicolons to start a comment. 
6492 @end table
6494 @subsubheading Remarks
6495 Using extended @code{asm} typically produces smaller, safer, and more
6496 efficient code, and in most cases it is a better solution than basic
6497 @code{asm}.  However, there are two situations where only basic @code{asm}
6498 can be used:
6500 @itemize @bullet
6501 @item
6502 Extended @code{asm} statements have to be inside a C
6503 function, so to write inline assembly language at file scope (``top-level''),
6504 outside of C functions, you must use basic @code{asm}.
6505 You can use this technique to emit assembler directives,
6506 define assembly language macros that can be invoked elsewhere in the file,
6507 or write entire functions in assembly language.
6509 @item
6510 Functions declared
6511 with the @code{naked} attribute also require basic @code{asm}
6512 (@pxref{Function Attributes}).
6513 @end itemize
6515 Safely accessing C data and calling functions from basic @code{asm} is more 
6516 complex than it may appear. To access C data, it is better to use extended 
6517 @code{asm}.
6519 Do not expect a sequence of @code{asm} statements to remain perfectly 
6520 consecutive after compilation. If certain instructions need to remain 
6521 consecutive in the output, put them in a single multi-instruction @code{asm}
6522 statement. Note that GCC's optimizers can move @code{asm} statements 
6523 relative to other code, including across jumps.
6525 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6526 GCC does not know about these jumps, and therefore cannot take 
6527 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6528 labels are only supported in extended @code{asm}.
6530 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6531 assembly code when optimizing. This can lead to unexpected duplicate 
6532 symbol errors during compilation if your assembly code defines symbols or 
6533 labels.
6535 Since GCC does not parse the @var{AssemblerInstructions}, it has no 
6536 visibility of any symbols it references. This may result in GCC discarding 
6537 those symbols as unreferenced.
6539 The compiler copies the assembler instructions in a basic @code{asm} 
6540 verbatim to the assembly language output file, without 
6541 processing dialects or any of the @samp{%} operators that are available with
6542 extended @code{asm}. This results in minor differences between basic 
6543 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
6544 registers you might use @samp{%eax} in basic @code{asm} and
6545 @samp{%%eax} in extended @code{asm}.
6547 On targets such as x86 that support multiple assembler dialects,
6548 all basic @code{asm} blocks use the assembler dialect specified by the 
6549 @option{-masm} command-line option (@pxref{x86 Options}).  
6550 Basic @code{asm} provides no
6551 mechanism to provide different assembler strings for different dialects.
6553 Here is an example of basic @code{asm} for i386:
6555 @example
6556 /* Note that this code will not compile with -masm=intel */
6557 #define DebugBreak() asm("int $3")
6558 @end example
6560 @node Extended Asm
6561 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6562 @cindex extended @code{asm}
6563 @cindex assembly language in C, extended
6565 With extended @code{asm} you can read and write C variables from 
6566 assembler and perform jumps from assembler code to C labels.  
6567 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
6568 the operand parameters after the assembler template:
6570 @example
6571 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
6572                  : @var{OutputOperands} 
6573                  @r{[} : @var{InputOperands}
6574                  @r{[} : @var{Clobbers} @r{]} @r{]})
6576 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
6577                       : 
6578                       : @var{InputOperands}
6579                       : @var{Clobbers}
6580                       : @var{GotoLabels})
6581 @end example
6583 The @code{asm} keyword is a GNU extension.
6584 When writing code that can be compiled with @option{-ansi} and the
6585 various @option{-std} options, use @code{__asm__} instead of 
6586 @code{asm} (@pxref{Alternate Keywords}).
6588 @subsubheading Qualifiers
6589 @table @code
6591 @item volatile
6592 The typical use of extended @code{asm} statements is to manipulate input 
6593 values to produce output values. However, your @code{asm} statements may 
6594 also produce side effects. If so, you may need to use the @code{volatile} 
6595 qualifier to disable certain optimizations. @xref{Volatile}.
6597 @item goto
6598 This qualifier informs the compiler that the @code{asm} statement may 
6599 perform a jump to one of the labels listed in the @var{GotoLabels}.
6600 @xref{GotoLabels}.
6601 @end table
6603 @subsubheading Parameters
6604 @table @var
6605 @item AssemblerTemplate
6606 This is a literal string that is the template for the assembler code. It is a 
6607 combination of fixed text and tokens that refer to the input, output, 
6608 and goto parameters. @xref{AssemblerTemplate}.
6610 @item OutputOperands
6611 A comma-separated list of the C variables modified by the instructions in the 
6612 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
6614 @item InputOperands
6615 A comma-separated list of C expressions read by the instructions in the 
6616 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
6618 @item Clobbers
6619 A comma-separated list of registers or other values changed by the 
6620 @var{AssemblerTemplate}, beyond those listed as outputs.
6621 An empty list is permitted.  @xref{Clobbers}.
6623 @item GotoLabels
6624 When you are using the @code{goto} form of @code{asm}, this section contains 
6625 the list of all C labels to which the code in the 
6626 @var{AssemblerTemplate} may jump. 
6627 @xref{GotoLabels}.
6629 @code{asm} statements may not perform jumps into other @code{asm} statements,
6630 only to the listed @var{GotoLabels}.
6631 GCC's optimizers do not know about other jumps; therefore they cannot take 
6632 account of them when deciding how to optimize.
6633 @end table
6635 The total number of input + output + goto operands is limited to 30.
6637 @subsubheading Remarks
6638 The @code{asm} statement allows you to include assembly instructions directly 
6639 within C code. This may help you to maximize performance in time-sensitive 
6640 code or to access assembly instructions that are not readily available to C 
6641 programs.
6643 Note that extended @code{asm} statements must be inside a function. Only 
6644 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6645 Functions declared with the @code{naked} attribute also require basic 
6646 @code{asm} (@pxref{Function Attributes}).
6648 While the uses of @code{asm} are many and varied, it may help to think of an 
6649 @code{asm} statement as a series of low-level instructions that convert input 
6650 parameters to output parameters. So a simple (if not particularly useful) 
6651 example for i386 using @code{asm} might look like this:
6653 @example
6654 int src = 1;
6655 int dst;   
6657 asm ("mov %1, %0\n\t"
6658     "add $1, %0"
6659     : "=r" (dst) 
6660     : "r" (src));
6662 printf("%d\n", dst);
6663 @end example
6665 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
6667 @anchor{Volatile}
6668 @subsubsection Volatile
6669 @cindex volatile @code{asm}
6670 @cindex @code{asm} volatile
6672 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6673 there is no need for the output variables. Also, the optimizers may move 
6674 code out of loops if they believe that the code will always return the same 
6675 result (i.e. none of its input values change between calls). Using the 
6676 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6677 that have no output operands, including @code{asm goto} statements, 
6678 are implicitly volatile.
6680 This i386 code demonstrates a case that does not use (or require) the 
6681 @code{volatile} qualifier. If it is performing assertion checking, this code 
6682 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
6683 unreferenced by any code. As a result, the optimizers can discard the 
6684 @code{asm} statement, which in turn removes the need for the entire 
6685 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6686 isn't needed you allow the optimizers to produce the most efficient code 
6687 possible.
6689 @example
6690 void DoCheck(uint32_t dwSomeValue)
6692    uint32_t dwRes;
6694    // Assumes dwSomeValue is not zero.
6695    asm ("bsfl %1,%0"
6696      : "=r" (dwRes)
6697      : "r" (dwSomeValue)
6698      : "cc");
6700    assert(dwRes > 3);
6702 @end example
6704 The next example shows a case where the optimizers can recognize that the input 
6705 (@code{dwSomeValue}) never changes during the execution of the function and can 
6706 therefore move the @code{asm} outside the loop to produce more efficient code. 
6707 Again, using @code{volatile} disables this type of optimization.
6709 @example
6710 void do_print(uint32_t dwSomeValue)
6712    uint32_t dwRes;
6714    for (uint32_t x=0; x < 5; x++)
6715    @{
6716       // Assumes dwSomeValue is not zero.
6717       asm ("bsfl %1,%0"
6718         : "=r" (dwRes)
6719         : "r" (dwSomeValue)
6720         : "cc");
6722       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6723    @}
6725 @end example
6727 The following example demonstrates a case where you need to use the 
6728 @code{volatile} qualifier. 
6729 It uses the x86 @code{rdtsc} instruction, which reads 
6730 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6731 the optimizers might assume that the @code{asm} block will always return the 
6732 same value and therefore optimize away the second call.
6734 @example
6735 uint64_t msr;
6737 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6738         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6739         "or %%rdx, %0"        // 'Or' in the lower bits.
6740         : "=a" (msr)
6741         : 
6742         : "rdx");
6744 printf("msr: %llx\n", msr);
6746 // Do other work...
6748 // Reprint the timestamp
6749 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6750         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6751         "or %%rdx, %0"        // 'Or' in the lower bits.
6752         : "=a" (msr)
6753         : 
6754         : "rdx");
6756 printf("msr: %llx\n", msr);
6757 @end example
6759 GCC's optimizers do not treat this code like the non-volatile code in the 
6760 earlier examples. They do not move it out of loops or omit it on the 
6761 assumption that the result from a previous call is still valid.
6763 Note that the compiler can move even volatile @code{asm} instructions relative 
6764 to other code, including across jump instructions. For example, on many 
6765 targets there is a system register that controls the rounding mode of 
6766 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6767 following PowerPC example, does not work reliably.
6769 @example
6770 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6771 sum = x + y;
6772 @end example
6774 The compiler may move the addition back before the volatile @code{asm}. To 
6775 make it work as expected, add an artificial dependency to the @code{asm} by 
6776 referencing a variable in the subsequent code, for example: 
6778 @example
6779 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6780 sum = x + y;
6781 @end example
6783 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6784 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6785 errors during compilation if your asm code defines symbols or labels. 
6786 Using @samp{%=} 
6787 (@pxref{AssemblerTemplate}) may help resolve this problem.
6789 @anchor{AssemblerTemplate}
6790 @subsubsection Assembler Template
6791 @cindex @code{asm} assembler template
6793 An assembler template is a literal string containing assembler instructions.
6794 The compiler replaces tokens in the template that refer 
6795 to inputs, outputs, and goto labels,
6796 and then outputs the resulting string to the assembler. The 
6797 string can contain any instructions recognized by the assembler, including 
6798 directives. GCC does not parse the assembler instructions 
6799 themselves and does not know what they mean or even whether they are valid 
6800 assembler input. However, it does count the statements 
6801 (@pxref{Size of an asm}).
6803 You may place multiple assembler instructions together in a single @code{asm} 
6804 string, separated by the characters normally used in assembly code for the 
6805 system. A combination that works in most places is a newline to break the 
6806 line, plus a tab character to move to the instruction field (written as 
6807 @samp{\n\t}). 
6808 Some assemblers allow semicolons as a line separator. However, note 
6809 that some assembler dialects use semicolons to start a comment. 
6811 Do not expect a sequence of @code{asm} statements to remain perfectly 
6812 consecutive after compilation, even when you are using the @code{volatile} 
6813 qualifier. If certain instructions need to remain consecutive in the output, 
6814 put them in a single multi-instruction asm statement.
6816 Accessing data from C programs without using input/output operands (such as 
6817 by using global symbols directly from the assembler template) may not work as 
6818 expected. Similarly, calling functions directly from an assembler template 
6819 requires a detailed understanding of the target assembler and ABI.
6821 Since GCC does not parse the assembler template,
6822 it has no visibility of any 
6823 symbols it references. This may result in GCC discarding those symbols as 
6824 unreferenced unless they are also listed as input, output, or goto operands.
6826 @subsubheading Special format strings
6828 In addition to the tokens described by the input, output, and goto operands, 
6829 these tokens have special meanings in the assembler template:
6831 @table @samp
6832 @item %% 
6833 Outputs a single @samp{%} into the assembler code.
6835 @item %= 
6836 Outputs a number that is unique to each instance of the @code{asm} 
6837 statement in the entire compilation. This option is useful when creating local 
6838 labels and referring to them multiple times in a single template that 
6839 generates multiple assembler instructions. 
6841 @item %@{
6842 @itemx %|
6843 @itemx %@}
6844 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
6845 into the assembler code.  When unescaped, these characters have special
6846 meaning to indicate multiple assembler dialects, as described below.
6847 @end table
6849 @subsubheading Multiple assembler dialects in @code{asm} templates
6851 On targets such as x86, GCC supports multiple assembler dialects.
6852 The @option{-masm} option controls which dialect GCC uses as its 
6853 default for inline assembler. The target-specific documentation for the 
6854 @option{-masm} option contains the list of supported dialects, as well as the 
6855 default dialect if the option is not specified. This information may be 
6856 important to understand, since assembler code that works correctly when 
6857 compiled using one dialect will likely fail if compiled using another.
6858 @xref{x86 Options}.
6860 If your code needs to support multiple assembler dialects (for example, if 
6861 you are writing public headers that need to support a variety of compilation 
6862 options), use constructs of this form:
6864 @example
6865 @{ dialect0 | dialect1 | dialect2... @}
6866 @end example
6868 This construct outputs @code{dialect0} 
6869 when using dialect #0 to compile the code, 
6870 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
6871 braces than the number of dialects the compiler supports, the construct 
6872 outputs nothing.
6874 For example, if an x86 compiler supports two dialects
6875 (@samp{att}, @samp{intel}), an 
6876 assembler template such as this:
6878 @example
6879 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6880 @end example
6882 @noindent
6883 is equivalent to one of
6885 @example
6886 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
6887 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
6888 @end example
6890 Using that same compiler, this code:
6892 @example
6893 "xchg@{l@}\t@{%%@}ebx, %1"
6894 @end example
6896 @noindent
6897 corresponds to either
6899 @example
6900 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
6901 "xchg\tebx, %1"                    @r{/* intel dialect */}
6902 @end example
6904 There is no support for nesting dialect alternatives.
6906 @anchor{OutputOperands}
6907 @subsubsection Output Operands
6908 @cindex @code{asm} output operands
6910 An @code{asm} statement has zero or more output operands indicating the names
6911 of C variables modified by the assembler code.
6913 In this i386 example, @code{old} (referred to in the template string as 
6914 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
6915 (@code{%2}) is an input:
6917 @example
6918 bool old;
6920 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6921          "sbb %0,%0"      // Use the CF to calculate old.
6922    : "=r" (old), "+rm" (*Base)
6923    : "Ir" (Offset)
6924    : "cc");
6926 return old;
6927 @end example
6929 Operands are separated by commas.  Each operand has this format:
6931 @example
6932 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
6933 @end example
6935 @table @var
6936 @item asmSymbolicName
6937 Specifies a symbolic name for the operand.
6938 Reference the name in the assembler template 
6939 by enclosing it in square brackets 
6940 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
6941 that contains the definition. Any valid C variable name is acceptable, 
6942 including names already defined in the surrounding code. No two operands 
6943 within the same @code{asm} statement can use the same symbolic name.
6945 When not using an @var{asmSymbolicName}, use the (zero-based) position
6946 of the operand 
6947 in the list of operands in the assembler template. For example if there are 
6948 three output operands, use @samp{%0} in the template to refer to the first, 
6949 @samp{%1} for the second, and @samp{%2} for the third. 
6951 @item constraint
6952 A string constant specifying constraints on the placement of the operand; 
6953 @xref{Constraints}, for details.
6955 Output constraints must begin with either @samp{=} (a variable overwriting an 
6956 existing value) or @samp{+} (when reading and writing). When using 
6957 @samp{=}, do not assume the location contains the existing value
6958 on entry to the @code{asm}, except 
6959 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
6961 After the prefix, there must be one or more additional constraints 
6962 (@pxref{Constraints}) that describe where the value resides. Common 
6963 constraints include @samp{r} for register and @samp{m} for memory. 
6964 When you list more than one possible location (for example, @code{"=rm"}),
6965 the compiler chooses the most efficient one based on the current context. 
6966 If you list as many alternates as the @code{asm} statement allows, you permit 
6967 the optimizers to produce the best possible code. 
6968 If you must use a specific register, but your Machine Constraints do not
6969 provide sufficient control to select the specific register you want, 
6970 local register variables may provide a solution (@pxref{Local Reg Vars}).
6972 @item cvariablename
6973 Specifies a C lvalue expression to hold the output, typically a variable name.
6974 The enclosing parentheses are a required part of the syntax.
6976 @end table
6978 When the compiler selects the registers to use to 
6979 represent the output operands, it does not use any of the clobbered registers 
6980 (@pxref{Clobbers}).
6982 Output operand expressions must be lvalues. The compiler cannot check whether 
6983 the operands have data types that are reasonable for the instruction being 
6984 executed. For output expressions that are not directly addressable (for 
6985 example a bit-field), the constraint must allow a register. In that case, GCC 
6986 uses the register as the output of the @code{asm}, and then stores that 
6987 register into the output. 
6989 Operands using the @samp{+} constraint modifier count as two operands 
6990 (that is, both as input and output) towards the total maximum of 30 operands
6991 per @code{asm} statement.
6993 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
6994 operands that must not overlap an input.  Otherwise, 
6995 GCC may allocate the output operand in the same register as an unrelated 
6996 input operand, on the assumption that the assembler code consumes its 
6997 inputs before producing outputs. This assumption may be false if the assembler 
6998 code actually consists of more than one instruction.
7000 The same problem can occur if one output parameter (@var{a}) allows a register 
7001 constraint and another output parameter (@var{b}) allows a memory constraint.
7002 The code generated by GCC to access the memory address in @var{b} can contain
7003 registers which @emph{might} be shared by @var{a}, and GCC considers those 
7004 registers to be inputs to the asm. As above, GCC assumes that such input
7005 registers are consumed before any outputs are written. This assumption may 
7006 result in incorrect behavior if the asm writes to @var{a} before using 
7007 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7008 ensures that modifying @var{a} does not affect the address referenced by 
7009 @var{b}. Otherwise, the location of @var{b} 
7010 is undefined if @var{a} is modified before using @var{b}.
7012 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7013 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7014 dependent. The list of supported modifiers for x86 is found at 
7015 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7017 If the C code that follows the @code{asm} makes no use of any of the output 
7018 operands, use @code{volatile} for the @code{asm} statement to prevent the 
7019 optimizers from discarding the @code{asm} statement as unneeded 
7020 (see @ref{Volatile}).
7022 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
7023 references the first output operand as @code{%0} (were there a second, it 
7024 would be @code{%1}, etc). The number of the first input operand is one greater 
7025 than that of the last output operand. In this i386 example, that makes 
7026 @code{Mask} referenced as @code{%1}:
7028 @example
7029 uint32_t Mask = 1234;
7030 uint32_t Index;
7032   asm ("bsfl %1, %0"
7033      : "=r" (Index)
7034      : "r" (Mask)
7035      : "cc");
7036 @end example
7038 That code overwrites the variable @code{Index} (@samp{=}),
7039 placing the value in a register (@samp{r}).
7040 Using the generic @samp{r} constraint instead of a constraint for a specific 
7041 register allows the compiler to pick the register to use, which can result 
7042 in more efficient code. This may not be possible if an assembler instruction 
7043 requires a specific register.
7045 The following i386 example uses the @var{asmSymbolicName} syntax.
7046 It produces the 
7047 same result as the code above, but some may consider it more readable or more 
7048 maintainable since reordering index numbers is not necessary when adding or 
7049 removing operands. The names @code{aIndex} and @code{aMask}
7050 are only used in this example to emphasize which 
7051 names get used where.
7052 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7054 @example
7055 uint32_t Mask = 1234;
7056 uint32_t Index;
7058   asm ("bsfl %[aMask], %[aIndex]"
7059      : [aIndex] "=r" (Index)
7060      : [aMask] "r" (Mask)
7061      : "cc");
7062 @end example
7064 Here are some more examples of output operands.
7066 @example
7067 uint32_t c = 1;
7068 uint32_t d;
7069 uint32_t *e = &c;
7071 asm ("mov %[e], %[d]"
7072    : [d] "=rm" (d)
7073    : [e] "rm" (*e));
7074 @end example
7076 Here, @code{d} may either be in a register or in memory. Since the compiler 
7077 might already have the current value of the @code{uint32_t} location
7078 pointed to by @code{e}
7079 in a register, you can enable it to choose the best location
7080 for @code{d} by specifying both constraints.
7082 @anchor{InputOperands}
7083 @subsubsection Input Operands
7084 @cindex @code{asm} input operands
7085 @cindex @code{asm} expressions
7087 Input operands make values from C variables and expressions available to the 
7088 assembly code.
7090 Operands are separated by commas.  Each operand has this format:
7092 @example
7093 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
7094 @end example
7096 @table @var
7097 @item asmSymbolicName
7098 Specifies a symbolic name for the operand.
7099 Reference the name in the assembler template 
7100 by enclosing it in square brackets 
7101 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
7102 that contains the definition. Any valid C variable name is acceptable, 
7103 including names already defined in the surrounding code. No two operands 
7104 within the same @code{asm} statement can use the same symbolic name.
7106 When not using an @var{asmSymbolicName}, use the (zero-based) position
7107 of the operand 
7108 in the list of operands in the assembler template. For example if there are
7109 two output operands and three inputs,
7110 use @samp{%2} in the template to refer to the first input operand,
7111 @samp{%3} for the second, and @samp{%4} for the third. 
7113 @item constraint
7114 A string constant specifying constraints on the placement of the operand; 
7115 @xref{Constraints}, for details.
7117 Input constraint strings may not begin with either @samp{=} or @samp{+}.
7118 When you list more than one possible location (for example, @samp{"irm"}), 
7119 the compiler chooses the most efficient one based on the current context.
7120 If you must use a specific register, but your Machine Constraints do not
7121 provide sufficient control to select the specific register you want, 
7122 local register variables may provide a solution (@pxref{Local Reg Vars}).
7124 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7125 that the specified input must be in the same place as the output constraint 
7126 at the (zero-based) index in the output constraint list. 
7127 When using @var{asmSymbolicName} syntax for the output operands,
7128 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
7130 @item cexpression
7131 This is the C variable or expression being passed to the @code{asm} statement 
7132 as input.  The enclosing parentheses are a required part of the syntax.
7134 @end table
7136 When the compiler selects the registers to use to represent the input 
7137 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
7139 If there are no output operands but there are input operands, place two 
7140 consecutive colons where the output operands would go:
7142 @example
7143 __asm__ ("some instructions"
7144    : /* No outputs. */
7145    : "r" (Offset / 8));
7146 @end example
7148 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7149 (except for inputs tied to outputs). The compiler assumes that on exit from 
7150 the @code{asm} statement these operands contain the same values as they 
7151 had before executing the statement. 
7152 It is @emph{not} possible to use clobbers
7153 to inform the compiler that the values in these inputs are changing. One 
7154 common work-around is to tie the changing input variable to an output variable 
7155 that never gets used. Note, however, that if the code that follows the 
7156 @code{asm} statement makes no use of any of the output operands, the GCC 
7157 optimizers may discard the @code{asm} statement as unneeded 
7158 (see @ref{Volatile}).
7160 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
7161 instead of simply @samp{%2}). Typically these qualifiers are hardware 
7162 dependent. The list of supported modifiers for x86 is found at 
7163 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7165 In this example using the fictitious @code{combine} instruction, the 
7166 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7167 location as output operand 0. Only input operands may use numbers in 
7168 constraints, and they must each refer to an output operand. Only a number (or 
7169 the symbolic assembler name) in the constraint can guarantee that one operand 
7170 is in the same place as another. The mere fact that @code{foo} is the value of 
7171 both operands is not enough to guarantee that they are in the same place in 
7172 the generated assembler code.
7174 @example
7175 asm ("combine %2, %0" 
7176    : "=r" (foo) 
7177    : "0" (foo), "g" (bar));
7178 @end example
7180 Here is an example using symbolic names.
7182 @example
7183 asm ("cmoveq %1, %2, %[result]" 
7184    : [result] "=r"(result) 
7185    : "r" (test), "r" (new), "[result]" (old));
7186 @end example
7188 @anchor{Clobbers}
7189 @subsubsection Clobbers
7190 @cindex @code{asm} clobbers
7192 While the compiler is aware of changes to entries listed in the output 
7193 operands, the inline @code{asm} code may modify more than just the outputs. For 
7194 example, calculations may require additional registers, or the processor may 
7195 overwrite a register as a side effect of a particular assembler instruction. 
7196 In order to inform the compiler of these changes, list them in the clobber 
7197 list. Clobber list items are either register names or the special clobbers 
7198 (listed below). Each clobber list item is a string constant 
7199 enclosed in double quotes and separated by commas.
7201 Clobber descriptions may not in any way overlap with an input or output 
7202 operand. For example, you may not have an operand describing a register class 
7203 with one member when listing that register in the clobber list. Variables 
7204 declared to live in specific registers (@pxref{Explicit Reg Vars}) and used 
7205 as @code{asm} input or output operands must have no part mentioned in the 
7206 clobber description. In particular, there is no way to specify that input 
7207 operands get modified without also specifying them as output operands.
7209 When the compiler selects which registers to use to represent input and output 
7210 operands, it does not use any of the clobbered registers. As a result, 
7211 clobbered registers are available for any use in the assembler code.
7213 Here is a realistic example for the VAX showing the use of clobbered 
7214 registers: 
7216 @example
7217 asm volatile ("movc3 %0, %1, %2"
7218                    : /* No outputs. */
7219                    : "g" (from), "g" (to), "g" (count)
7220                    : "r0", "r1", "r2", "r3", "r4", "r5");
7221 @end example
7223 Also, there are two special clobber arguments:
7225 @table @code
7226 @item "cc"
7227 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7228 register. On some machines, GCC represents the condition codes as a specific 
7229 hardware register; @code{"cc"} serves to name this register.
7230 On other machines, condition code handling is different, 
7231 and specifying @code{"cc"} has no effect. But 
7232 it is valid no matter what the target.
7234 @item "memory"
7235 The @code{"memory"} clobber tells the compiler that the assembly code
7236 performs memory 
7237 reads or writes to items other than those listed in the input and output 
7238 operands (for example, accessing the memory pointed to by one of the input 
7239 parameters). To ensure memory contains correct values, GCC may need to flush 
7240 specific register values to memory before executing the @code{asm}. Further, 
7241 the compiler does not assume that any values read from memory before an 
7242 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
7243 needed.  
7244 Using the @code{"memory"} clobber effectively forms a read/write
7245 memory barrier for the compiler.
7247 Note that this clobber does not prevent the @emph{processor} from doing 
7248 speculative reads past the @code{asm} statement. To prevent that, you need 
7249 processor-specific fence instructions.
7251 Flushing registers to memory has performance implications and may be an issue 
7252 for time-sensitive code.  You can use a trick to avoid this if the size of 
7253 the memory being accessed is known at compile time. For example, if accessing 
7254 ten bytes of a string, use a memory input like: 
7256 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7258 @end table
7260 @anchor{GotoLabels}
7261 @subsubsection Goto Labels
7262 @cindex @code{asm} goto labels
7264 @code{asm goto} allows assembly code to jump to one or more C labels.  The
7265 @var{GotoLabels} section in an @code{asm goto} statement contains 
7266 a comma-separated 
7267 list of all C labels to which the assembler code may jump. GCC assumes that 
7268 @code{asm} execution falls through to the next statement (if this is not the 
7269 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7270 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7271 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7272 Attributes}).
7274 An @code{asm goto} statement cannot have outputs.
7275 This is due to an internal restriction of 
7276 the compiler: control transfer instructions cannot have outputs. 
7277 If the assembler code does modify anything, use the @code{"memory"} clobber 
7278 to force the 
7279 optimizers to flush all register values to memory and reload them if 
7280 necessary after the @code{asm} statement.
7282 Also note that an @code{asm goto} statement is always implicitly
7283 considered volatile.
7285 To reference a label in the assembler template,
7286 prefix it with @samp{%l} (lowercase @samp{L}) followed 
7287 by its (zero-based) position in @var{GotoLabels} plus the number of input 
7288 operands.  For example, if the @code{asm} has three inputs and references two 
7289 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
7291 Alternately, you can reference labels using the actual C label name enclosed
7292 in brackets.  For example, to reference a label named @code{carry}, you can
7293 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
7294 section when using this approach.
7296 Here is an example of @code{asm goto} for i386:
7298 @example
7299 asm goto (
7300     "btl %1, %0\n\t"
7301     "jc %l2"
7302     : /* No outputs. */
7303     : "r" (p1), "r" (p2) 
7304     : "cc" 
7305     : carry);
7307 return 0;
7309 carry:
7310 return 1;
7311 @end example
7313 The following example shows an @code{asm goto} that uses a memory clobber.
7315 @example
7316 int frob(int x)
7318   int y;
7319   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7320             : /* No outputs. */
7321             : "r"(x), "r"(&y)
7322             : "r5", "memory" 
7323             : error);
7324   return y;
7325 error:
7326   return -1;
7328 @end example
7330 @anchor{x86Operandmodifiers}
7331 @subsubsection x86 Operand Modifiers
7333 References to input, output, and goto operands in the assembler template
7334 of extended @code{asm} statements can use 
7335 modifiers to affect the way the operands are formatted in 
7336 the code output to the assembler. For example, the 
7337 following code uses the @samp{h} and @samp{b} modifiers for x86:
7339 @example
7340 uint16_t  num;
7341 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7342 @end example
7344 @noindent
7345 These modifiers generate this assembler code:
7347 @example
7348 xchg %ah, %al
7349 @end example
7351 The rest of this discussion uses the following code for illustrative purposes.
7353 @example
7354 int main()
7356    int iInt = 1;
7358 top:
7360    asm volatile goto ("some assembler instructions here"
7361    : /* No outputs. */
7362    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7363    : /* No clobbers. */
7364    : top);
7366 @end example
7368 With no modifiers, this is what the output from the operands would be for the 
7369 @samp{att} and @samp{intel} dialects of assembler:
7371 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7372 @headitem Operand @tab masm=att @tab masm=intel
7373 @item @code{%0}
7374 @tab @code{%eax}
7375 @tab @code{eax}
7376 @item @code{%1}
7377 @tab @code{$2}
7378 @tab @code{2}
7379 @item @code{%2}
7380 @tab @code{$.L2}
7381 @tab @code{OFFSET FLAT:.L2}
7382 @end multitable
7384 The table below shows the list of supported modifiers and their effects.
7386 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7387 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7388 @item @code{z}
7389 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7390 @tab @code{%z0}
7391 @tab @code{l}
7392 @tab 
7393 @item @code{b}
7394 @tab Print the QImode name of the register.
7395 @tab @code{%b0}
7396 @tab @code{%al}
7397 @tab @code{al}
7398 @item @code{h}
7399 @tab Print the QImode name for a ``high'' register.
7400 @tab @code{%h0}
7401 @tab @code{%ah}
7402 @tab @code{ah}
7403 @item @code{w}
7404 @tab Print the HImode name of the register.
7405 @tab @code{%w0}
7406 @tab @code{%ax}
7407 @tab @code{ax}
7408 @item @code{k}
7409 @tab Print the SImode name of the register.
7410 @tab @code{%k0}
7411 @tab @code{%eax}
7412 @tab @code{eax}
7413 @item @code{q}
7414 @tab Print the DImode name of the register.
7415 @tab @code{%q0}
7416 @tab @code{%rax}
7417 @tab @code{rax}
7418 @item @code{l}
7419 @tab Print the label name with no punctuation.
7420 @tab @code{%l2}
7421 @tab @code{.L2}
7422 @tab @code{.L2}
7423 @item @code{c}
7424 @tab Require a constant operand and print the constant expression with no punctuation.
7425 @tab @code{%c1}
7426 @tab @code{2}
7427 @tab @code{2}
7428 @end multitable
7430 @anchor{x86floatingpointasmoperands}
7431 @subsubsection x86 Floating-Point @code{asm} Operands
7433 On x86 targets, there are several rules on the usage of stack-like registers
7434 in the operands of an @code{asm}.  These rules apply only to the operands
7435 that are stack-like registers:
7437 @enumerate
7438 @item
7439 Given a set of input registers that die in an @code{asm}, it is
7440 necessary to know which are implicitly popped by the @code{asm}, and
7441 which must be explicitly popped by GCC@.
7443 An input register that is implicitly popped by the @code{asm} must be
7444 explicitly clobbered, unless it is constrained to match an
7445 output operand.
7447 @item
7448 For any input register that is implicitly popped by an @code{asm}, it is
7449 necessary to know how to adjust the stack to compensate for the pop.
7450 If any non-popped input is closer to the top of the reg-stack than
7451 the implicitly popped register, it would not be possible to know what the
7452 stack looked like---it's not clear how the rest of the stack ``slides
7453 up''.
7455 All implicitly popped input registers must be closer to the top of
7456 the reg-stack than any input that is not implicitly popped.
7458 It is possible that if an input dies in an @code{asm}, the compiler might
7459 use the input register for an output reload.  Consider this example:
7461 @smallexample
7462 asm ("foo" : "=t" (a) : "f" (b));
7463 @end smallexample
7465 @noindent
7466 This code says that input @code{b} is not popped by the @code{asm}, and that
7467 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7468 deeper after the @code{asm} than it was before.  But, it is possible that
7469 reload may think that it can use the same register for both the input and
7470 the output.
7472 To prevent this from happening,
7473 if any input operand uses the @samp{f} constraint, all output register
7474 constraints must use the @samp{&} early-clobber modifier.
7476 The example above is correctly written as:
7478 @smallexample
7479 asm ("foo" : "=&t" (a) : "f" (b));
7480 @end smallexample
7482 @item
7483 Some operands need to be in particular places on the stack.  All
7484 output operands fall in this category---GCC has no other way to
7485 know which registers the outputs appear in unless you indicate
7486 this in the constraints.
7488 Output operands must specifically indicate which register an output
7489 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
7490 constraints must select a class with a single register.
7492 @item
7493 Output operands may not be ``inserted'' between existing stack registers.
7494 Since no 387 opcode uses a read/write operand, all output operands
7495 are dead before the @code{asm}, and are pushed by the @code{asm}.
7496 It makes no sense to push anywhere but the top of the reg-stack.
7498 Output operands must start at the top of the reg-stack: output
7499 operands may not ``skip'' a register.
7501 @item
7502 Some @code{asm} statements may need extra stack space for internal
7503 calculations.  This can be guaranteed by clobbering stack registers
7504 unrelated to the inputs and outputs.
7506 @end enumerate
7508 This @code{asm}
7509 takes one input, which is internally popped, and produces two outputs.
7511 @smallexample
7512 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7513 @end smallexample
7515 @noindent
7516 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7517 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7518 for the compiler to know that @code{fyl2xp1} pops both inputs.
7520 @smallexample
7521 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7522 @end smallexample
7524 @lowersections
7525 @include md.texi
7526 @raisesections
7528 @node Asm Labels
7529 @subsection Controlling Names Used in Assembler Code
7530 @cindex assembler names for identifiers
7531 @cindex names used in assembler code
7532 @cindex identifiers, names in assembler code
7534 You can specify the name to be used in the assembler code for a C
7535 function or variable by writing the @code{asm} (or @code{__asm__})
7536 keyword after the declarator as follows:
7538 @smallexample
7539 int foo asm ("myfoo") = 2;
7540 @end smallexample
7542 @noindent
7543 This specifies that the name to be used for the variable @code{foo} in
7544 the assembler code should be @samp{myfoo} rather than the usual
7545 @samp{_foo}.
7547 On systems where an underscore is normally prepended to the name of a C
7548 function or variable, this feature allows you to define names for the
7549 linker that do not start with an underscore.
7551 It does not make sense to use this feature with a non-static local
7552 variable since such variables do not have assembler names.  If you are
7553 trying to put the variable in a particular register, see @ref{Explicit
7554 Reg Vars}.  GCC presently accepts such code with a warning, but will
7555 probably be changed to issue an error, rather than a warning, in the
7556 future.
7558 You cannot use @code{asm} in this way in a function @emph{definition}; but
7559 you can get the same effect by writing a declaration for the function
7560 before its definition and putting @code{asm} there, like this:
7562 @smallexample
7563 extern func () asm ("FUNC");
7565 func (x, y)
7566      int x, y;
7567 /* @r{@dots{}} */
7568 @end smallexample
7570 It is up to you to make sure that the assembler names you choose do not
7571 conflict with any other assembler symbols.  Also, you must not use a
7572 register name; that would produce completely invalid assembler code.  GCC
7573 does not as yet have the ability to store static variables in registers.
7574 Perhaps that will be added.
7576 @node Explicit Reg Vars
7577 @subsection Variables in Specified Registers
7578 @cindex explicit register variables
7579 @cindex variables in specified registers
7580 @cindex specified registers
7581 @cindex registers, global allocation
7583 GNU C allows you to put a few global variables into specified hardware
7584 registers.  You can also specify the register in which an ordinary
7585 register variable should be allocated.
7587 @itemize @bullet
7588 @item
7589 Global register variables reserve registers throughout the program.
7590 This may be useful in programs such as programming language
7591 interpreters that have a couple of global variables that are accessed
7592 very often.
7594 @item
7595 Local register variables in specific registers do not reserve the
7596 registers, except at the point where they are used as input or output
7597 operands in an @code{asm} statement and the @code{asm} statement itself is
7598 not deleted.  The compiler's data flow analysis is capable of determining
7599 where the specified registers contain live values, and where they are
7600 available for other uses.  Stores into local register variables may be deleted
7601 when they appear to be dead according to dataflow analysis.  References
7602 to local register variables may be deleted or moved or simplified.
7604 These local variables are sometimes convenient for use with the extended
7605 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7606 output of the assembler instruction directly into a particular register.
7607 (This works provided the register you specify fits the constraints
7608 specified for that operand in the @code{asm}.)
7609 @end itemize
7611 @menu
7612 * Global Reg Vars::
7613 * Local Reg Vars::
7614 @end menu
7616 @node Global Reg Vars
7617 @subsubsection Defining Global Register Variables
7618 @cindex global register variables
7619 @cindex registers, global variables in
7621 You can define a global register variable in GNU C like this:
7623 @smallexample
7624 register int *foo asm ("a5");
7625 @end smallexample
7627 @noindent
7628 Here @code{a5} is the name of the register that should be used.  Choose a
7629 register that is normally saved and restored by function calls on your
7630 machine, so that library routines will not clobber it.
7632 Naturally the register name is CPU-dependent, so you need to
7633 conditionalize your program according to CPU type.  The register
7634 @code{a5} is a good choice on a 68000 for a variable of pointer
7635 type.  On machines with register windows, be sure to choose a ``global''
7636 register that is not affected magically by the function call mechanism.
7638 In addition, different operating systems on the same CPU may differ in how they
7639 name the registers; then you need additional conditionals.  For
7640 example, some 68000 operating systems call this register @code{%a5}.
7642 Eventually there may be a way of asking the compiler to choose a register
7643 automatically, but first we need to figure out how it should choose and
7644 how to enable you to guide the choice.  No solution is evident.
7646 Defining a global register variable in a certain register reserves that
7647 register entirely for this use, at least within the current compilation.
7648 The register is not allocated for any other purpose in the functions
7649 in the current compilation, and is not saved and restored by
7650 these functions.  Stores into this register are never deleted even if they
7651 appear to be dead, but references may be deleted or moved or
7652 simplified.
7654 It is not safe to access the global register variables from signal
7655 handlers, or from more than one thread of control, because the system
7656 library routines may temporarily use the register for other things (unless
7657 you recompile them specially for the task at hand).
7659 @cindex @code{qsort}, and global register variables
7660 It is not safe for one function that uses a global register variable to
7661 call another such function @code{foo} by way of a third function
7662 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7663 different source file in which the variable isn't declared).  This is
7664 because @code{lose} might save the register and put some other value there.
7665 For example, you can't expect a global register variable to be available in
7666 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7667 might have put something else in that register.  (If you are prepared to
7668 recompile @code{qsort} with the same global register variable, you can
7669 solve this problem.)
7671 If you want to recompile @code{qsort} or other source files that do not
7672 actually use your global register variable, so that they do not use that
7673 register for any other purpose, then it suffices to specify the compiler
7674 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7675 register declaration to their source code.
7677 A function that can alter the value of a global register variable cannot
7678 safely be called from a function compiled without this variable, because it
7679 could clobber the value the caller expects to find there on return.
7680 Therefore, the function that is the entry point into the part of the
7681 program that uses the global register variable must explicitly save and
7682 restore the value that belongs to its caller.
7684 @cindex register variable after @code{longjmp}
7685 @cindex global register after @code{longjmp}
7686 @cindex value after @code{longjmp}
7687 @findex longjmp
7688 @findex setjmp
7689 On most machines, @code{longjmp} restores to each global register
7690 variable the value it had at the time of the @code{setjmp}.  On some
7691 machines, however, @code{longjmp} does not change the value of global
7692 register variables.  To be portable, the function that called @code{setjmp}
7693 should make other arrangements to save the values of the global register
7694 variables, and to restore them in a @code{longjmp}.  This way, the same
7695 thing happens regardless of what @code{longjmp} does.
7697 All global register variable declarations must precede all function
7698 definitions.  If such a declaration could appear after function
7699 definitions, the declaration would be too late to prevent the register from
7700 being used for other purposes in the preceding functions.
7702 Global register variables may not have initial values, because an
7703 executable file has no means to supply initial contents for a register.
7705 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7706 registers, but certain library functions, such as @code{getwd}, as well
7707 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7708 g2 are local temporaries.
7710 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7711 Of course, it does not do to use more than a few of those.
7713 @node Local Reg Vars
7714 @subsubsection Specifying Registers for Local Variables
7715 @cindex local variables, specifying registers
7716 @cindex specifying registers for local variables
7717 @cindex registers for local variables
7719 You can define a local register variable with a specified register
7720 like this:
7722 @smallexample
7723 register int *foo asm ("a5");
7724 @end smallexample
7726 @noindent
7727 Here @code{a5} is the name of the register that should be used.  Note
7728 that this is the same syntax used for defining global register
7729 variables, but for a local variable it appears within a function.
7731 Naturally the register name is CPU-dependent, but this is not a
7732 problem, since specific registers are most often useful with explicit
7733 assembler instructions (@pxref{Extended Asm}).  Both of these things
7734 generally require that you conditionalize your program according to
7735 CPU type.
7737 In addition, operating systems on one type of CPU may differ in how they
7738 name the registers; then you need additional conditionals.  For
7739 example, some 68000 operating systems call this register @code{%a5}.
7741 Defining such a register variable does not reserve the register; it
7742 remains available for other uses in places where flow control determines
7743 the variable's value is not live.
7745 This option does not guarantee that GCC generates code that has
7746 this variable in the register you specify at all times.  You may not
7747 code an explicit reference to this register in the assembler
7748 instruction template part of an @code{asm} statement and assume it
7749 always refers to this variable.
7750 However, using the variable as an input or output operand to the @code{asm}
7751 guarantees that the specified register is used for that operand.  
7752 @xref{Extended Asm}, for more information.
7754 Stores into local register variables may be deleted when they appear to be dead
7755 according to dataflow analysis.  References to local register variables may
7756 be deleted or moved or simplified.
7758 As with global register variables, it is recommended that you choose a
7759 register that is normally saved and restored by function calls on
7760 your machine, so that library routines will not clobber it.  
7762 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7763 specific register, but there's no matching constraint letter for that 
7764 register. To force the operand into that register, create a local variable 
7765 and specify the register in the variable's declaration. Then use the local 
7766 variable for the asm operand and specify any constraint letter that matches 
7767 the register:
7769 @smallexample
7770 register int *p1 asm ("r0") = @dots{};
7771 register int *p2 asm ("r1") = @dots{};
7772 register int *result asm ("r0");
7773 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7774 @end smallexample
7776 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7777 call-clobbered by subsequent code, including function calls and library calls 
7778 for arithmetic operators on other variables (for example the initialization 
7779 of p2). In this case, use temporary variables for expressions between the 
7780 register assignments:
7782 @smallexample
7783 int t1 = @dots{};
7784 register int *p1 asm ("r0") = @dots{};
7785 register int *p2 asm ("r1") = t1;
7786 register int *result asm ("r0");
7787 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7788 @end smallexample
7790 @node Size of an asm
7791 @subsection Size of an @code{asm}
7793 Some targets require that GCC track the size of each instruction used
7794 in order to generate correct code.  Because the final length of the
7795 code produced by an @code{asm} statement is only known by the
7796 assembler, GCC must make an estimate as to how big it will be.  It
7797 does this by counting the number of instructions in the pattern of the
7798 @code{asm} and multiplying that by the length of the longest
7799 instruction supported by that processor.  (When working out the number
7800 of instructions, it assumes that any occurrence of a newline or of
7801 whatever statement separator character is supported by the assembler --
7802 typically @samp{;} --- indicates the end of an instruction.)
7804 Normally, GCC's estimate is adequate to ensure that correct
7805 code is generated, but it is possible to confuse the compiler if you use
7806 pseudo instructions or assembler macros that expand into multiple real
7807 instructions, or if you use assembler directives that expand to more
7808 space in the object file than is needed for a single instruction.
7809 If this happens then the assembler may produce a diagnostic saying that
7810 a label is unreachable.
7812 @node Alternate Keywords
7813 @section Alternate Keywords
7814 @cindex alternate keywords
7815 @cindex keywords, alternate
7817 @option{-ansi} and the various @option{-std} options disable certain
7818 keywords.  This causes trouble when you want to use GNU C extensions, or
7819 a general-purpose header file that should be usable by all programs,
7820 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7821 @code{inline} are not available in programs compiled with
7822 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7823 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7824 ISO C99 keyword
7825 @code{restrict} is only available when @option{-std=gnu99} (which will
7826 eventually be the default) or @option{-std=c99} (or the equivalent
7827 @option{-std=iso9899:1999}), or an option for a later standard
7828 version, is used.
7830 The way to solve these problems is to put @samp{__} at the beginning and
7831 end of each problematical keyword.  For example, use @code{__asm__}
7832 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7834 Other C compilers won't accept these alternative keywords; if you want to
7835 compile with another compiler, you can define the alternate keywords as
7836 macros to replace them with the customary keywords.  It looks like this:
7838 @smallexample
7839 #ifndef __GNUC__
7840 #define __asm__ asm
7841 #endif
7842 @end smallexample
7844 @findex __extension__
7845 @opindex pedantic
7846 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7847 You can
7848 prevent such warnings within one expression by writing
7849 @code{__extension__} before the expression.  @code{__extension__} has no
7850 effect aside from this.
7852 @node Incomplete Enums
7853 @section Incomplete @code{enum} Types
7855 You can define an @code{enum} tag without specifying its possible values.
7856 This results in an incomplete type, much like what you get if you write
7857 @code{struct foo} without describing the elements.  A later declaration
7858 that does specify the possible values completes the type.
7860 You can't allocate variables or storage using the type while it is
7861 incomplete.  However, you can work with pointers to that type.
7863 This extension may not be very useful, but it makes the handling of
7864 @code{enum} more consistent with the way @code{struct} and @code{union}
7865 are handled.
7867 This extension is not supported by GNU C++.
7869 @node Function Names
7870 @section Function Names as Strings
7871 @cindex @code{__func__} identifier
7872 @cindex @code{__FUNCTION__} identifier
7873 @cindex @code{__PRETTY_FUNCTION__} identifier
7875 GCC provides three magic variables that hold the name of the current
7876 function, as a string.  The first of these is @code{__func__}, which
7877 is part of the C99 standard:
7879 The identifier @code{__func__} is implicitly declared by the translator
7880 as if, immediately following the opening brace of each function
7881 definition, the declaration
7883 @smallexample
7884 static const char __func__[] = "function-name";
7885 @end smallexample
7887 @noindent
7888 appeared, where function-name is the name of the lexically-enclosing
7889 function.  This name is the unadorned name of the function.
7891 @code{__FUNCTION__} is another name for @code{__func__}, provided for
7892 backward compatibility with old versions of GCC.
7894 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7895 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7896 the type signature of the function as well as its bare name.  For
7897 example, this program:
7899 @smallexample
7900 extern "C" @{
7901 extern int printf (char *, ...);
7904 class a @{
7905  public:
7906   void sub (int i)
7907     @{
7908       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7909       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7910     @}
7914 main (void)
7916   a ax;
7917   ax.sub (0);
7918   return 0;
7920 @end smallexample
7922 @noindent
7923 gives this output:
7925 @smallexample
7926 __FUNCTION__ = sub
7927 __PRETTY_FUNCTION__ = void a::sub(int)
7928 @end smallexample
7930 These identifiers are variables, not preprocessor macros, and may not
7931 be used to initialize @code{char} arrays or be concatenated with other string
7932 literals.
7934 @node Return Address
7935 @section Getting the Return or Frame Address of a Function
7937 These functions may be used to get information about the callers of a
7938 function.
7940 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7941 This function returns the return address of the current function, or of
7942 one of its callers.  The @var{level} argument is number of frames to
7943 scan up the call stack.  A value of @code{0} yields the return address
7944 of the current function, a value of @code{1} yields the return address
7945 of the caller of the current function, and so forth.  When inlining
7946 the expected behavior is that the function returns the address of
7947 the function that is returned to.  To work around this behavior use
7948 the @code{noinline} function attribute.
7950 The @var{level} argument must be a constant integer.
7952 On some machines it may be impossible to determine the return address of
7953 any function other than the current one; in such cases, or when the top
7954 of the stack has been reached, this function returns @code{0} or a
7955 random value.  In addition, @code{__builtin_frame_address} may be used
7956 to determine if the top of the stack has been reached.
7958 Additional post-processing of the returned value may be needed, see
7959 @code{__builtin_extract_return_addr}.
7961 This function should only be used with a nonzero argument for debugging
7962 purposes.
7963 @end deftypefn
7965 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7966 The address as returned by @code{__builtin_return_address} may have to be fed
7967 through this function to get the actual encoded address.  For example, on the
7968 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7969 platforms an offset has to be added for the true next instruction to be
7970 executed.
7972 If no fixup is needed, this function simply passes through @var{addr}.
7973 @end deftypefn
7975 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7976 This function does the reverse of @code{__builtin_extract_return_addr}.
7977 @end deftypefn
7979 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7980 This function is similar to @code{__builtin_return_address}, but it
7981 returns the address of the function frame rather than the return address
7982 of the function.  Calling @code{__builtin_frame_address} with a value of
7983 @code{0} yields the frame address of the current function, a value of
7984 @code{1} yields the frame address of the caller of the current function,
7985 and so forth.
7987 The frame is the area on the stack that holds local variables and saved
7988 registers.  The frame address is normally the address of the first word
7989 pushed on to the stack by the function.  However, the exact definition
7990 depends upon the processor and the calling convention.  If the processor
7991 has a dedicated frame pointer register, and the function has a frame,
7992 then @code{__builtin_frame_address} returns the value of the frame
7993 pointer register.
7995 On some machines it may be impossible to determine the frame address of
7996 any function other than the current one; in such cases, or when the top
7997 of the stack has been reached, this function returns @code{0} if
7998 the first frame pointer is properly initialized by the startup code.
8000 This function should only be used with a nonzero argument for debugging
8001 purposes.
8002 @end deftypefn
8004 @node Vector Extensions
8005 @section Using Vector Instructions through Built-in Functions
8007 On some targets, the instruction set contains SIMD vector instructions which
8008 operate on multiple values contained in one large register at the same time.
8009 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8010 this way.
8012 The first step in using these extensions is to provide the necessary data
8013 types.  This should be done using an appropriate @code{typedef}:
8015 @smallexample
8016 typedef int v4si __attribute__ ((vector_size (16)));
8017 @end smallexample
8019 @noindent
8020 The @code{int} type specifies the base type, while the attribute specifies
8021 the vector size for the variable, measured in bytes.  For example, the
8022 declaration above causes the compiler to set the mode for the @code{v4si}
8023 type to be 16 bytes wide and divided into @code{int} sized units.  For
8024 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8025 corresponding mode of @code{foo} is @acronym{V4SI}.
8027 The @code{vector_size} attribute is only applicable to integral and
8028 float scalars, although arrays, pointers, and function return values
8029 are allowed in conjunction with this construct. Only sizes that are
8030 a power of two are currently allowed.
8032 All the basic integer types can be used as base types, both as signed
8033 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8034 @code{long long}.  In addition, @code{float} and @code{double} can be
8035 used to build floating-point vector types.
8037 Specifying a combination that is not valid for the current architecture
8038 causes GCC to synthesize the instructions using a narrower mode.
8039 For example, if you specify a variable of type @code{V4SI} and your
8040 architecture does not allow for this specific SIMD type, GCC
8041 produces code that uses 4 @code{SIs}.
8043 The types defined in this manner can be used with a subset of normal C
8044 operations.  Currently, GCC allows using the following operators
8045 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8047 The operations behave like C++ @code{valarrays}.  Addition is defined as
8048 the addition of the corresponding elements of the operands.  For
8049 example, in the code below, each of the 4 elements in @var{a} is
8050 added to the corresponding 4 elements in @var{b} and the resulting
8051 vector is stored in @var{c}.
8053 @smallexample
8054 typedef int v4si __attribute__ ((vector_size (16)));
8056 v4si a, b, c;
8058 c = a + b;
8059 @end smallexample
8061 Subtraction, multiplication, division, and the logical operations
8062 operate in a similar manner.  Likewise, the result of using the unary
8063 minus or complement operators on a vector type is a vector whose
8064 elements are the negative or complemented values of the corresponding
8065 elements in the operand.
8067 It is possible to use shifting operators @code{<<}, @code{>>} on
8068 integer-type vectors. The operation is defined as following: @code{@{a0,
8069 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8070 @dots{}, an >> bn@}}@. Vector operands must have the same number of
8071 elements. 
8073 For convenience, it is allowed to use a binary vector operation
8074 where one operand is a scalar. In that case the compiler transforms
8075 the scalar operand into a vector where each element is the scalar from
8076 the operation. The transformation happens only if the scalar could be
8077 safely converted to the vector-element type.
8078 Consider the following code.
8080 @smallexample
8081 typedef int v4si __attribute__ ((vector_size (16)));
8083 v4si a, b, c;
8084 long l;
8086 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8087 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8089 a = l + a;    /* Error, cannot convert long to int. */
8090 @end smallexample
8092 Vectors can be subscripted as if the vector were an array with
8093 the same number of elements and base type.  Out of bound accesses
8094 invoke undefined behavior at run time.  Warnings for out of bound
8095 accesses for vector subscription can be enabled with
8096 @option{-Warray-bounds}.
8098 Vector comparison is supported with standard comparison
8099 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8100 vector expressions of integer-type or real-type. Comparison between
8101 integer-type vectors and real-type vectors are not supported.  The
8102 result of the comparison is a vector of the same width and number of
8103 elements as the comparison operands with a signed integral element
8104 type.
8106 Vectors are compared element-wise producing 0 when comparison is false
8107 and -1 (constant of the appropriate type where all bits are set)
8108 otherwise. Consider the following example.
8110 @smallexample
8111 typedef int v4si __attribute__ ((vector_size (16)));
8113 v4si a = @{1,2,3,4@};
8114 v4si b = @{3,2,1,4@};
8115 v4si c;
8117 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8118 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8119 @end smallexample
8121 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8122 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8123 integer vector with the same number of elements of the same size as @code{b}
8124 and @code{c}, computes all three arguments and creates a vector
8125 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8126 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8127 As in the case of binary operations, this syntax is also accepted when
8128 one of @code{b} or @code{c} is a scalar that is then transformed into a
8129 vector. If both @code{b} and @code{c} are scalars and the type of
8130 @code{true?b:c} has the same size as the element type of @code{a}, then
8131 @code{b} and @code{c} are converted to a vector type whose elements have
8132 this type and with the same number of elements as @code{a}.
8134 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8135 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8136 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8137 For mixed operations between a scalar @code{s} and a vector @code{v},
8138 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8139 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8141 Vector shuffling is available using functions
8142 @code{__builtin_shuffle (vec, mask)} and
8143 @code{__builtin_shuffle (vec0, vec1, mask)}.
8144 Both functions construct a permutation of elements from one or two
8145 vectors and return a vector of the same type as the input vector(s).
8146 The @var{mask} is an integral vector with the same width (@var{W})
8147 and element count (@var{N}) as the output vector.
8149 The elements of the input vectors are numbered in memory ordering of
8150 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8151 elements of @var{mask} are considered modulo @var{N} in the single-operand
8152 case and modulo @math{2*@var{N}} in the two-operand case.
8154 Consider the following example,
8156 @smallexample
8157 typedef int v4si __attribute__ ((vector_size (16)));
8159 v4si a = @{1,2,3,4@};
8160 v4si b = @{5,6,7,8@};
8161 v4si mask1 = @{0,1,1,3@};
8162 v4si mask2 = @{0,4,2,5@};
8163 v4si res;
8165 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8166 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8167 @end smallexample
8169 Note that @code{__builtin_shuffle} is intentionally semantically
8170 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8172 You can declare variables and use them in function calls and returns, as
8173 well as in assignments and some casts.  You can specify a vector type as
8174 a return type for a function.  Vector types can also be used as function
8175 arguments.  It is possible to cast from one vector type to another,
8176 provided they are of the same size (in fact, you can also cast vectors
8177 to and from other datatypes of the same size).
8179 You cannot operate between vectors of different lengths or different
8180 signedness without a cast.
8182 @node Offsetof
8183 @section Support for @code{offsetof}
8184 @findex __builtin_offsetof
8186 GCC implements for both C and C++ a syntactic extension to implement
8187 the @code{offsetof} macro.
8189 @smallexample
8190 primary:
8191         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8193 offsetof_member_designator:
8194           @code{identifier}
8195         | offsetof_member_designator "." @code{identifier}
8196         | offsetof_member_designator "[" @code{expr} "]"
8197 @end smallexample
8199 This extension is sufficient such that
8201 @smallexample
8202 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8203 @end smallexample
8205 @noindent
8206 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8207 may be dependent.  In either case, @var{member} may consist of a single
8208 identifier, or a sequence of member accesses and array references.
8210 @node __sync Builtins
8211 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
8213 The following built-in functions
8214 are intended to be compatible with those described
8215 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8216 section 7.4.  As such, they depart from normal GCC practice by not using
8217 the @samp{__builtin_} prefix and also by being overloaded so that they
8218 work on multiple types.
8220 The definition given in the Intel documentation allows only for the use of
8221 the types @code{int}, @code{long}, @code{long long} or their unsigned
8222 counterparts.  GCC allows any integral scalar or pointer type that is
8223 1, 2, 4 or 8 bytes in length.
8225 These functions are implemented in terms of the @samp{__atomic}
8226 builtins (@pxref{__atomic Builtins}).  They should not be used for new
8227 code which should use the @samp{__atomic} builtins instead.
8229 Not all operations are supported by all target processors.  If a particular
8230 operation cannot be implemented on the target processor, a warning is
8231 generated and a call to an external function is generated.  The external
8232 function carries the same name as the built-in version,
8233 with an additional suffix
8234 @samp{_@var{n}} where @var{n} is the size of the data type.
8236 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8237 @c useful for implementing the operation under the control of an external
8238 @c mutex.
8240 In most cases, these built-in functions are considered a @dfn{full barrier}.
8241 That is,
8242 no memory operand is moved across the operation, either forward or
8243 backward.  Further, instructions are issued as necessary to prevent the
8244 processor from speculating loads across the operation and from queuing stores
8245 after the operation.
8247 All of the routines are described in the Intel documentation to take
8248 ``an optional list of variables protected by the memory barrier''.  It's
8249 not clear what is meant by that; it could mean that @emph{only} the
8250 listed variables are protected, or it could mean a list of additional
8251 variables to be protected.  The list is ignored by GCC which treats it as
8252 empty.  GCC interprets an empty list as meaning that all globally
8253 accessible variables should be protected.
8255 @table @code
8256 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8257 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8258 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8259 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8260 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8261 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8262 @findex __sync_fetch_and_add
8263 @findex __sync_fetch_and_sub
8264 @findex __sync_fetch_and_or
8265 @findex __sync_fetch_and_and
8266 @findex __sync_fetch_and_xor
8267 @findex __sync_fetch_and_nand
8268 These built-in functions perform the operation suggested by the name, and
8269 returns the value that had previously been in memory.  That is,
8271 @smallexample
8272 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8273 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8274 @end smallexample
8276 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8277 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8279 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8280 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8281 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8282 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8283 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8284 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8285 @findex __sync_add_and_fetch
8286 @findex __sync_sub_and_fetch
8287 @findex __sync_or_and_fetch
8288 @findex __sync_and_and_fetch
8289 @findex __sync_xor_and_fetch
8290 @findex __sync_nand_and_fetch
8291 These built-in functions perform the operation suggested by the name, and
8292 return the new value.  That is,
8294 @smallexample
8295 @{ *ptr @var{op}= value; return *ptr; @}
8296 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8297 @end smallexample
8299 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8300 as @code{*ptr = ~(*ptr & value)} instead of
8301 @code{*ptr = ~*ptr & value}.
8303 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8304 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8305 @findex __sync_bool_compare_and_swap
8306 @findex __sync_val_compare_and_swap
8307 These built-in functions perform an atomic compare and swap.
8308 That is, if the current
8309 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8310 @code{*@var{ptr}}.
8312 The ``bool'' version returns true if the comparison is successful and
8313 @var{newval} is written.  The ``val'' version returns the contents
8314 of @code{*@var{ptr}} before the operation.
8316 @item __sync_synchronize (...)
8317 @findex __sync_synchronize
8318 This built-in function issues a full memory barrier.
8320 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8321 @findex __sync_lock_test_and_set
8322 This built-in function, as described by Intel, is not a traditional test-and-set
8323 operation, but rather an atomic exchange operation.  It writes @var{value}
8324 into @code{*@var{ptr}}, and returns the previous contents of
8325 @code{*@var{ptr}}.
8327 Many targets have only minimal support for such locks, and do not support
8328 a full exchange operation.  In this case, a target may support reduced
8329 functionality here by which the @emph{only} valid value to store is the
8330 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8331 is implementation defined.
8333 This built-in function is not a full barrier,
8334 but rather an @dfn{acquire barrier}.
8335 This means that references after the operation cannot move to (or be
8336 speculated to) before the operation, but previous memory stores may not
8337 be globally visible yet, and previous memory loads may not yet be
8338 satisfied.
8340 @item void __sync_lock_release (@var{type} *ptr, ...)
8341 @findex __sync_lock_release
8342 This built-in function releases the lock acquired by
8343 @code{__sync_lock_test_and_set}.
8344 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8346 This built-in function is not a full barrier,
8347 but rather a @dfn{release barrier}.
8348 This means that all previous memory stores are globally visible, and all
8349 previous memory loads have been satisfied, but following memory reads
8350 are not prevented from being speculated to before the barrier.
8351 @end table
8353 @node __atomic Builtins
8354 @section Built-in Functions for Memory Model Aware Atomic Operations
8356 The following built-in functions approximately match the requirements for
8357 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8358 functions, but all also have a memory model parameter.  These are all
8359 identified by being prefixed with @samp{__atomic}, and most are overloaded
8360 such that they work with multiple types.
8362 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8363 bytes in length. 16-byte integral types are also allowed if
8364 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8366 Target architectures are encouraged to provide their own patterns for
8367 each of these built-in functions.  If no target is provided, the original 
8368 non-memory model set of @samp{__sync} atomic built-in functions are
8369 utilized, along with any required synchronization fences surrounding it in
8370 order to achieve the proper behavior.  Execution in this case is subject
8371 to the same restrictions as those built-in functions.
8373 If there is no pattern or mechanism to provide a lock free instruction
8374 sequence, a call is made to an external routine with the same parameters
8375 to be resolved at run time.
8377 The four non-arithmetic functions (load, store, exchange, and 
8378 compare_exchange) all have a generic version as well.  This generic
8379 version works on any data type.  If the data type size maps to one
8380 of the integral sizes that may have lock free support, the generic
8381 version utilizes the lock free built-in function.  Otherwise an
8382 external call is left to be resolved at run time.  This external call is
8383 the same format with the addition of a @samp{size_t} parameter inserted
8384 as the first parameter indicating the size of the object being pointed to.
8385 All objects must be the same size.
8387 There are 6 different memory models that can be specified.  These map
8388 to the same names in the C++11 standard.  Refer there or to the
8389 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8390 atomic synchronization} for more detailed definitions.  These memory
8391 models integrate both barriers to code motion as well as synchronization
8392 requirements with other threads. These are listed in approximately
8393 ascending order of strength. It is also possible to use target specific
8394 flags for memory model flags, like Hardware Lock Elision.
8396 @table  @code
8397 @item __ATOMIC_RELAXED
8398 No barriers or synchronization.
8399 @item __ATOMIC_CONSUME
8400 Data dependency only for both barrier and synchronization with another
8401 thread.
8402 @item __ATOMIC_ACQUIRE
8403 Barrier to hoisting of code and synchronizes with release (or stronger)
8404 semantic stores from another thread.
8405 @item __ATOMIC_RELEASE
8406 Barrier to sinking of code and synchronizes with acquire (or stronger)
8407 semantic loads from another thread.
8408 @item __ATOMIC_ACQ_REL
8409 Full barrier in both directions and synchronizes with acquire loads and
8410 release stores in another thread.
8411 @item __ATOMIC_SEQ_CST
8412 Full barrier in both directions and synchronizes with acquire loads and
8413 release stores in all threads.
8414 @end table
8416 When implementing patterns for these built-in functions, the memory model
8417 parameter can be ignored as long as the pattern implements the most
8418 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8419 execute correctly with this memory model but they may not execute as
8420 efficiently as they could with a more appropriate implementation of the
8421 relaxed requirements.
8423 Note that the C++11 standard allows for the memory model parameter to be
8424 determined at run time rather than at compile time.  These built-in
8425 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8426 than invoke a runtime library call or inline a switch statement.  This is
8427 standard compliant, safe, and the simplest approach for now.
8429 The memory model parameter is a signed int, but only the lower 8 bits are
8430 reserved for the memory model.  The remainder of the signed int is reserved
8431 for future use and should be 0.  Use of the predefined atomic values
8432 ensures proper usage.
8434 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8435 This built-in function implements an atomic load operation.  It returns the
8436 contents of @code{*@var{ptr}}.
8438 The valid memory model variants are
8439 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8440 and @code{__ATOMIC_CONSUME}.
8442 @end deftypefn
8444 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8445 This is the generic version of an atomic load.  It returns the
8446 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8448 @end deftypefn
8450 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8451 This built-in function implements an atomic store operation.  It writes 
8452 @code{@var{val}} into @code{*@var{ptr}}.  
8454 The valid memory model variants are
8455 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8457 @end deftypefn
8459 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8460 This is the generic version of an atomic store.  It stores the value
8461 of @code{*@var{val}} into @code{*@var{ptr}}.
8463 @end deftypefn
8465 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8466 This built-in function implements an atomic exchange operation.  It writes
8467 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8468 @code{*@var{ptr}}.
8470 The valid memory model variants are
8471 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8472 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8474 @end deftypefn
8476 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8477 This is the generic version of an atomic exchange.  It stores the
8478 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8479 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8481 @end deftypefn
8483 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memmodel, int failure_memmodel)
8484 This built-in function implements an atomic compare and exchange operation.
8485 This compares the contents of @code{*@var{ptr}} with the contents of
8486 @code{*@var{expected}} and if equal, writes @var{desired} into
8487 @code{*@var{ptr}}.  If they are not equal, the current contents of
8488 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8489 for weak compare_exchange, and false for the strong variation.  Many targets 
8490 only offer the strong variation and ignore the parameter.  When in doubt, use
8491 the strong variation.
8493 True is returned if @var{desired} is written into
8494 @code{*@var{ptr}} and the execution is considered to conform to the
8495 memory model specified by @var{success_memmodel}.  There are no
8496 restrictions on what memory model can be used here.
8498 False is returned otherwise, and the execution is considered to conform
8499 to @var{failure_memmodel}. This memory model cannot be
8500 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8501 stronger model than that specified by @var{success_memmodel}.
8503 @end deftypefn
8505 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memmodel, int failure_memmodel)
8506 This built-in function implements the generic version of
8507 @code{__atomic_compare_exchange}.  The function is virtually identical to
8508 @code{__atomic_compare_exchange_n}, except the desired value is also a
8509 pointer.
8511 @end deftypefn
8513 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8514 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8515 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8516 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8517 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8518 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8519 These built-in functions perform the operation suggested by the name, and
8520 return the result of the operation. That is,
8522 @smallexample
8523 @{ *ptr @var{op}= val; return *ptr; @}
8524 @end smallexample
8526 All memory models are valid.
8528 @end deftypefn
8530 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8531 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8532 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8533 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8534 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8535 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8536 These built-in functions perform the operation suggested by the name, and
8537 return the value that had previously been in @code{*@var{ptr}}.  That is,
8539 @smallexample
8540 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8541 @end smallexample
8543 All memory models are valid.
8545 @end deftypefn
8547 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8549 This built-in function performs an atomic test-and-set operation on
8550 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8551 defined nonzero ``set'' value and the return value is @code{true} if and only
8552 if the previous contents were ``set''.
8553 It should be only used for operands of type @code{bool} or @code{char}. For 
8554 other types only part of the value may be set.
8556 All memory models are valid.
8558 @end deftypefn
8560 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8562 This built-in function performs an atomic clear operation on
8563 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8564 It should be only used for operands of type @code{bool} or @code{char} and 
8565 in conjunction with @code{__atomic_test_and_set}.
8566 For other types it may only clear partially. If the type is not @code{bool}
8567 prefer using @code{__atomic_store}.
8569 The valid memory model variants are
8570 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8571 @code{__ATOMIC_RELEASE}.
8573 @end deftypefn
8575 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8577 This built-in function acts as a synchronization fence between threads
8578 based on the specified memory model.
8580 All memory orders are valid.
8582 @end deftypefn
8584 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8586 This built-in function acts as a synchronization fence between a thread
8587 and signal handlers based in the same thread.
8589 All memory orders are valid.
8591 @end deftypefn
8593 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8595 This built-in function returns true if objects of @var{size} bytes always
8596 generate lock free atomic instructions for the target architecture.  
8597 @var{size} must resolve to a compile-time constant and the result also
8598 resolves to a compile-time constant.
8600 @var{ptr} is an optional pointer to the object that may be used to determine
8601 alignment.  A value of 0 indicates typical alignment should be used.  The 
8602 compiler may also ignore this parameter.
8604 @smallexample
8605 if (_atomic_always_lock_free (sizeof (long long), 0))
8606 @end smallexample
8608 @end deftypefn
8610 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8612 This built-in function returns true if objects of @var{size} bytes always
8613 generate lock free atomic instructions for the target architecture.  If
8614 it is not known to be lock free a call is made to a runtime routine named
8615 @code{__atomic_is_lock_free}.
8617 @var{ptr} is an optional pointer to the object that may be used to determine
8618 alignment.  A value of 0 indicates typical alignment should be used.  The 
8619 compiler may also ignore this parameter.
8620 @end deftypefn
8622 @node Integer Overflow Builtins
8623 @section Built-in Functions to Perform Arithmetic with Overflow Checking
8625 The following built-in functions allow performing simple arithmetic operations
8626 together with checking whether the operations overflowed.
8628 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8629 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8630 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8631 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8632 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8633 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8634 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8636 These built-in functions promote the first two operands into infinite precision signed
8637 type and perform addition on those promoted operands.  The result is then
8638 cast to the type the third pointer argument points to and stored there.
8639 If the stored result is equal to the infinite precision result, the built-in
8640 functions return false, otherwise they return true.  As the addition is
8641 performed in infinite signed precision, these built-in functions have fully defined
8642 behavior for all argument values.
8644 The first built-in function allows arbitrary integral types for operands and
8645 the result type must be pointer to some integer type, the rest of the built-in
8646 functions have explicit integer types.
8648 The compiler will attempt to use hardware instructions to implement
8649 these built-in functions where possible, like conditional jump on overflow
8650 after addition, conditional jump on carry etc.
8652 @end deftypefn
8654 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8655 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8656 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8657 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8658 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8659 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8660 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8662 These built-in functions are similar to the add overflow checking built-in
8663 functions above, except they perform subtraction, subtract the second argument
8664 from the first one, instead of addition.
8666 @end deftypefn
8668 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8669 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8670 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8671 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8672 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8673 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8674 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8676 These built-in functions are similar to the add overflow checking built-in
8677 functions above, except they perform multiplication, instead of addition.
8679 @end deftypefn
8681 @node x86 specific memory model extensions for transactional memory
8682 @section x86-Specific Memory Model Extensions for Transactional Memory
8684 The x86 architecture supports additional memory ordering flags
8685 to mark lock critical sections for hardware lock elision. 
8686 These must be specified in addition to an existing memory model to 
8687 atomic intrinsics.
8689 @table @code
8690 @item __ATOMIC_HLE_ACQUIRE
8691 Start lock elision on a lock variable.
8692 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8693 @item __ATOMIC_HLE_RELEASE
8694 End lock elision on a lock variable.
8695 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8696 @end table
8698 When a lock acquire fails it is required for good performance to abort
8699 the transaction quickly. This can be done with a @code{_mm_pause}
8701 @smallexample
8702 #include <immintrin.h> // For _mm_pause
8704 int lockvar;
8706 /* Acquire lock with lock elision */
8707 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8708     _mm_pause(); /* Abort failed transaction */
8710 /* Free lock with lock elision */
8711 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8712 @end smallexample
8714 @node Object Size Checking
8715 @section Object Size Checking Built-in Functions
8716 @findex __builtin_object_size
8717 @findex __builtin___memcpy_chk
8718 @findex __builtin___mempcpy_chk
8719 @findex __builtin___memmove_chk
8720 @findex __builtin___memset_chk
8721 @findex __builtin___strcpy_chk
8722 @findex __builtin___stpcpy_chk
8723 @findex __builtin___strncpy_chk
8724 @findex __builtin___strcat_chk
8725 @findex __builtin___strncat_chk
8726 @findex __builtin___sprintf_chk
8727 @findex __builtin___snprintf_chk
8728 @findex __builtin___vsprintf_chk
8729 @findex __builtin___vsnprintf_chk
8730 @findex __builtin___printf_chk
8731 @findex __builtin___vprintf_chk
8732 @findex __builtin___fprintf_chk
8733 @findex __builtin___vfprintf_chk
8735 GCC implements a limited buffer overflow protection mechanism
8736 that can prevent some buffer overflow attacks.
8738 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8739 is a built-in construct that returns a constant number of bytes from
8740 @var{ptr} to the end of the object @var{ptr} pointer points to
8741 (if known at compile time).  @code{__builtin_object_size} never evaluates
8742 its arguments for side-effects.  If there are any side-effects in them, it
8743 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8744 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8745 point to and all of them are known at compile time, the returned number
8746 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8747 0 and minimum if nonzero.  If it is not possible to determine which objects
8748 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8749 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8750 for @var{type} 2 or 3.
8752 @var{type} is an integer constant from 0 to 3.  If the least significant
8753 bit is clear, objects are whole variables, if it is set, a closest
8754 surrounding subobject is considered the object a pointer points to.
8755 The second bit determines if maximum or minimum of remaining bytes
8756 is computed.
8758 @smallexample
8759 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8760 char *p = &var.buf1[1], *q = &var.b;
8762 /* Here the object p points to is var.  */
8763 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8764 /* The subobject p points to is var.buf1.  */
8765 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8766 /* The object q points to is var.  */
8767 assert (__builtin_object_size (q, 0)
8768         == (char *) (&var + 1) - (char *) &var.b);
8769 /* The subobject q points to is var.b.  */
8770 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8771 @end smallexample
8772 @end deftypefn
8774 There are built-in functions added for many common string operation
8775 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8776 built-in is provided.  This built-in has an additional last argument,
8777 which is the number of bytes remaining in object the @var{dest}
8778 argument points to or @code{(size_t) -1} if the size is not known.
8780 The built-in functions are optimized into the normal string functions
8781 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8782 it is known at compile time that the destination object will not
8783 be overflown.  If the compiler can determine at compile time the
8784 object will be always overflown, it issues a warning.
8786 The intended use can be e.g.@:
8788 @smallexample
8789 #undef memcpy
8790 #define bos0(dest) __builtin_object_size (dest, 0)
8791 #define memcpy(dest, src, n) \
8792   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8794 char *volatile p;
8795 char buf[10];
8796 /* It is unknown what object p points to, so this is optimized
8797    into plain memcpy - no checking is possible.  */
8798 memcpy (p, "abcde", n);
8799 /* Destination is known and length too.  It is known at compile
8800    time there will be no overflow.  */
8801 memcpy (&buf[5], "abcde", 5);
8802 /* Destination is known, but the length is not known at compile time.
8803    This will result in __memcpy_chk call that can check for overflow
8804    at run time.  */
8805 memcpy (&buf[5], "abcde", n);
8806 /* Destination is known and it is known at compile time there will
8807    be overflow.  There will be a warning and __memcpy_chk call that
8808    will abort the program at run time.  */
8809 memcpy (&buf[6], "abcde", 5);
8810 @end smallexample
8812 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8813 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8814 @code{strcat} and @code{strncat}.
8816 There are also checking built-in functions for formatted output functions.
8817 @smallexample
8818 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8819 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8820                               const char *fmt, ...);
8821 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8822                               va_list ap);
8823 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8824                                const char *fmt, va_list ap);
8825 @end smallexample
8827 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8828 etc.@: functions and can contain implementation specific flags on what
8829 additional security measures the checking function might take, such as
8830 handling @code{%n} differently.
8832 The @var{os} argument is the object size @var{s} points to, like in the
8833 other built-in functions.  There is a small difference in the behavior
8834 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8835 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8836 the checking function is called with @var{os} argument set to
8837 @code{(size_t) -1}.
8839 In addition to this, there are checking built-in functions
8840 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8841 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8842 These have just one additional argument, @var{flag}, right before
8843 format string @var{fmt}.  If the compiler is able to optimize them to
8844 @code{fputc} etc.@: functions, it does, otherwise the checking function
8845 is called and the @var{flag} argument passed to it.
8847 @node Pointer Bounds Checker builtins
8848 @section Pointer Bounds Checker Built-in Functions
8849 @cindex Pointer Bounds Checker builtins
8850 @findex __builtin___bnd_set_ptr_bounds
8851 @findex __builtin___bnd_narrow_ptr_bounds
8852 @findex __builtin___bnd_copy_ptr_bounds
8853 @findex __builtin___bnd_init_ptr_bounds
8854 @findex __builtin___bnd_null_ptr_bounds
8855 @findex __builtin___bnd_store_ptr_bounds
8856 @findex __builtin___bnd_chk_ptr_lbounds
8857 @findex __builtin___bnd_chk_ptr_ubounds
8858 @findex __builtin___bnd_chk_ptr_bounds
8859 @findex __builtin___bnd_get_ptr_lbound
8860 @findex __builtin___bnd_get_ptr_ubound
8862 GCC provides a set of built-in functions to control Pointer Bounds Checker
8863 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
8864 even if you compile with Pointer Bounds Checker off
8865 (@option{-fno-check-pointer-bounds}).
8866 The behavior may differ in such case as documented below.
8868 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
8870 This built-in function returns a new pointer with the value of @var{q}, and
8871 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8872 Bounds Checker off, the built-in function just returns the first argument.
8874 @smallexample
8875 extern void *__wrap_malloc (size_t n)
8877   void *p = (void *)__real_malloc (n);
8878   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8879   return __builtin___bnd_set_ptr_bounds (p, n);
8881 @end smallexample
8883 @end deftypefn
8885 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
8887 This built-in function returns a new pointer with the value of @var{p}
8888 and associates it with the narrowed bounds formed by the intersection
8889 of bounds associated with @var{q} and the bounds
8890 [@var{p}, @var{p} + @var{size} - 1].
8891 With Pointer Bounds Checker off, the built-in function just returns the first
8892 argument.
8894 @smallexample
8895 void init_objects (object *objs, size_t size)
8897   size_t i;
8898   /* Initialize objects one-by-one passing pointers with bounds of 
8899      an object, not the full array of objects.  */
8900   for (i = 0; i < size; i++)
8901     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
8902                                                     sizeof(object)));
8904 @end smallexample
8906 @end deftypefn
8908 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
8910 This built-in function returns a new pointer with the value of @var{q},
8911 and associates it with the bounds already associated with pointer @var{r}.
8912 With Pointer Bounds Checker off, the built-in function just returns the first
8913 argument.
8915 @smallexample
8916 /* Here is a way to get pointer to object's field but
8917    still with the full object's bounds.  */
8918 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
8919                                                   objptr);
8920 @end smallexample
8922 @end deftypefn
8924 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
8926 This built-in function returns a new pointer with the value of @var{q}, and
8927 associates it with INIT (allowing full memory access) bounds. With Pointer
8928 Bounds Checker off, the built-in function just returns the first argument.
8930 @end deftypefn
8932 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
8934 This built-in function returns a new pointer with the value of @var{q}, and
8935 associates it with NULL (allowing no memory access) bounds. With Pointer
8936 Bounds Checker off, the built-in function just returns the first argument.
8938 @end deftypefn
8940 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
8942 This built-in function stores the bounds associated with pointer @var{ptr_val}
8943 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8944 bounds from legacy code without touching the associated pointer's memory when
8945 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
8946 function call is ignored.
8948 @end deftypefn
8950 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
8952 This built-in function checks if the pointer @var{q} is within the lower
8953 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
8954 function call is ignored.
8956 @smallexample
8957 extern void *__wrap_memset (void *dst, int c, size_t len)
8959   if (len > 0)
8960     @{
8961       __builtin___bnd_chk_ptr_lbounds (dst);
8962       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8963       __real_memset (dst, c, len);
8964     @}
8965   return dst;
8967 @end smallexample
8969 @end deftypefn
8971 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
8973 This built-in function checks if the pointer @var{q} is within the upper
8974 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
8975 function call is ignored.
8977 @end deftypefn
8979 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
8981 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8982 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8983 off, the built-in function call is ignored.
8985 @smallexample
8986 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8988   if (n > 0)
8989     @{
8990       __bnd_chk_ptr_bounds (dst, n);
8991       __bnd_chk_ptr_bounds (src, n);
8992       __real_memcpy (dst, src, n);
8993     @}
8994   return dst;
8996 @end smallexample
8998 @end deftypefn
9000 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9002 This built-in function returns the lower bound associated
9003 with the pointer @var{q}, as a pointer value.  
9004 This is useful for debugging using @code{printf}.
9005 With Pointer Bounds Checker off, the built-in function returns 0.
9007 @smallexample
9008 void *lb = __builtin___bnd_get_ptr_lbound (q);
9009 void *ub = __builtin___bnd_get_ptr_ubound (q);
9010 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
9011 @end smallexample
9013 @end deftypefn
9015 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9017 This built-in function returns the upper bound (which is a pointer) associated
9018 with the pointer @var{q}.  With Pointer Bounds Checker off,
9019 the built-in function returns -1.
9021 @end deftypefn
9023 @node Cilk Plus Builtins
9024 @section Cilk Plus C/C++ Language Extension Built-in Functions
9026 GCC provides support for the following built-in reduction functions if Cilk Plus
9027 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9029 @itemize @bullet
9030 @item @code{__sec_implicit_index}
9031 @item @code{__sec_reduce}
9032 @item @code{__sec_reduce_add}
9033 @item @code{__sec_reduce_all_nonzero}
9034 @item @code{__sec_reduce_all_zero}
9035 @item @code{__sec_reduce_any_nonzero}
9036 @item @code{__sec_reduce_any_zero}
9037 @item @code{__sec_reduce_max}
9038 @item @code{__sec_reduce_min}
9039 @item @code{__sec_reduce_max_ind}
9040 @item @code{__sec_reduce_min_ind}
9041 @item @code{__sec_reduce_mul}
9042 @item @code{__sec_reduce_mutating}
9043 @end itemize
9045 Further details and examples about these built-in functions are described 
9046 in the Cilk Plus language manual which can be found at 
9047 @uref{http://www.cilkplus.org}.
9049 @node Other Builtins
9050 @section Other Built-in Functions Provided by GCC
9051 @cindex built-in functions
9052 @findex __builtin_call_with_static_chain
9053 @findex __builtin_fpclassify
9054 @findex __builtin_isfinite
9055 @findex __builtin_isnormal
9056 @findex __builtin_isgreater
9057 @findex __builtin_isgreaterequal
9058 @findex __builtin_isinf_sign
9059 @findex __builtin_isless
9060 @findex __builtin_islessequal
9061 @findex __builtin_islessgreater
9062 @findex __builtin_isunordered
9063 @findex __builtin_powi
9064 @findex __builtin_powif
9065 @findex __builtin_powil
9066 @findex _Exit
9067 @findex _exit
9068 @findex abort
9069 @findex abs
9070 @findex acos
9071 @findex acosf
9072 @findex acosh
9073 @findex acoshf
9074 @findex acoshl
9075 @findex acosl
9076 @findex alloca
9077 @findex asin
9078 @findex asinf
9079 @findex asinh
9080 @findex asinhf
9081 @findex asinhl
9082 @findex asinl
9083 @findex atan
9084 @findex atan2
9085 @findex atan2f
9086 @findex atan2l
9087 @findex atanf
9088 @findex atanh
9089 @findex atanhf
9090 @findex atanhl
9091 @findex atanl
9092 @findex bcmp
9093 @findex bzero
9094 @findex cabs
9095 @findex cabsf
9096 @findex cabsl
9097 @findex cacos
9098 @findex cacosf
9099 @findex cacosh
9100 @findex cacoshf
9101 @findex cacoshl
9102 @findex cacosl
9103 @findex calloc
9104 @findex carg
9105 @findex cargf
9106 @findex cargl
9107 @findex casin
9108 @findex casinf
9109 @findex casinh
9110 @findex casinhf
9111 @findex casinhl
9112 @findex casinl
9113 @findex catan
9114 @findex catanf
9115 @findex catanh
9116 @findex catanhf
9117 @findex catanhl
9118 @findex catanl
9119 @findex cbrt
9120 @findex cbrtf
9121 @findex cbrtl
9122 @findex ccos
9123 @findex ccosf
9124 @findex ccosh
9125 @findex ccoshf
9126 @findex ccoshl
9127 @findex ccosl
9128 @findex ceil
9129 @findex ceilf
9130 @findex ceill
9131 @findex cexp
9132 @findex cexpf
9133 @findex cexpl
9134 @findex cimag
9135 @findex cimagf
9136 @findex cimagl
9137 @findex clog
9138 @findex clogf
9139 @findex clogl
9140 @findex conj
9141 @findex conjf
9142 @findex conjl
9143 @findex copysign
9144 @findex copysignf
9145 @findex copysignl
9146 @findex cos
9147 @findex cosf
9148 @findex cosh
9149 @findex coshf
9150 @findex coshl
9151 @findex cosl
9152 @findex cpow
9153 @findex cpowf
9154 @findex cpowl
9155 @findex cproj
9156 @findex cprojf
9157 @findex cprojl
9158 @findex creal
9159 @findex crealf
9160 @findex creall
9161 @findex csin
9162 @findex csinf
9163 @findex csinh
9164 @findex csinhf
9165 @findex csinhl
9166 @findex csinl
9167 @findex csqrt
9168 @findex csqrtf
9169 @findex csqrtl
9170 @findex ctan
9171 @findex ctanf
9172 @findex ctanh
9173 @findex ctanhf
9174 @findex ctanhl
9175 @findex ctanl
9176 @findex dcgettext
9177 @findex dgettext
9178 @findex drem
9179 @findex dremf
9180 @findex dreml
9181 @findex erf
9182 @findex erfc
9183 @findex erfcf
9184 @findex erfcl
9185 @findex erff
9186 @findex erfl
9187 @findex exit
9188 @findex exp
9189 @findex exp10
9190 @findex exp10f
9191 @findex exp10l
9192 @findex exp2
9193 @findex exp2f
9194 @findex exp2l
9195 @findex expf
9196 @findex expl
9197 @findex expm1
9198 @findex expm1f
9199 @findex expm1l
9200 @findex fabs
9201 @findex fabsf
9202 @findex fabsl
9203 @findex fdim
9204 @findex fdimf
9205 @findex fdiml
9206 @findex ffs
9207 @findex floor
9208 @findex floorf
9209 @findex floorl
9210 @findex fma
9211 @findex fmaf
9212 @findex fmal
9213 @findex fmax
9214 @findex fmaxf
9215 @findex fmaxl
9216 @findex fmin
9217 @findex fminf
9218 @findex fminl
9219 @findex fmod
9220 @findex fmodf
9221 @findex fmodl
9222 @findex fprintf
9223 @findex fprintf_unlocked
9224 @findex fputs
9225 @findex fputs_unlocked
9226 @findex frexp
9227 @findex frexpf
9228 @findex frexpl
9229 @findex fscanf
9230 @findex gamma
9231 @findex gammaf
9232 @findex gammal
9233 @findex gamma_r
9234 @findex gammaf_r
9235 @findex gammal_r
9236 @findex gettext
9237 @findex hypot
9238 @findex hypotf
9239 @findex hypotl
9240 @findex ilogb
9241 @findex ilogbf
9242 @findex ilogbl
9243 @findex imaxabs
9244 @findex index
9245 @findex isalnum
9246 @findex isalpha
9247 @findex isascii
9248 @findex isblank
9249 @findex iscntrl
9250 @findex isdigit
9251 @findex isgraph
9252 @findex islower
9253 @findex isprint
9254 @findex ispunct
9255 @findex isspace
9256 @findex isupper
9257 @findex iswalnum
9258 @findex iswalpha
9259 @findex iswblank
9260 @findex iswcntrl
9261 @findex iswdigit
9262 @findex iswgraph
9263 @findex iswlower
9264 @findex iswprint
9265 @findex iswpunct
9266 @findex iswspace
9267 @findex iswupper
9268 @findex iswxdigit
9269 @findex isxdigit
9270 @findex j0
9271 @findex j0f
9272 @findex j0l
9273 @findex j1
9274 @findex j1f
9275 @findex j1l
9276 @findex jn
9277 @findex jnf
9278 @findex jnl
9279 @findex labs
9280 @findex ldexp
9281 @findex ldexpf
9282 @findex ldexpl
9283 @findex lgamma
9284 @findex lgammaf
9285 @findex lgammal
9286 @findex lgamma_r
9287 @findex lgammaf_r
9288 @findex lgammal_r
9289 @findex llabs
9290 @findex llrint
9291 @findex llrintf
9292 @findex llrintl
9293 @findex llround
9294 @findex llroundf
9295 @findex llroundl
9296 @findex log
9297 @findex log10
9298 @findex log10f
9299 @findex log10l
9300 @findex log1p
9301 @findex log1pf
9302 @findex log1pl
9303 @findex log2
9304 @findex log2f
9305 @findex log2l
9306 @findex logb
9307 @findex logbf
9308 @findex logbl
9309 @findex logf
9310 @findex logl
9311 @findex lrint
9312 @findex lrintf
9313 @findex lrintl
9314 @findex lround
9315 @findex lroundf
9316 @findex lroundl
9317 @findex malloc
9318 @findex memchr
9319 @findex memcmp
9320 @findex memcpy
9321 @findex mempcpy
9322 @findex memset
9323 @findex modf
9324 @findex modff
9325 @findex modfl
9326 @findex nearbyint
9327 @findex nearbyintf
9328 @findex nearbyintl
9329 @findex nextafter
9330 @findex nextafterf
9331 @findex nextafterl
9332 @findex nexttoward
9333 @findex nexttowardf
9334 @findex nexttowardl
9335 @findex pow
9336 @findex pow10
9337 @findex pow10f
9338 @findex pow10l
9339 @findex powf
9340 @findex powl
9341 @findex printf
9342 @findex printf_unlocked
9343 @findex putchar
9344 @findex puts
9345 @findex remainder
9346 @findex remainderf
9347 @findex remainderl
9348 @findex remquo
9349 @findex remquof
9350 @findex remquol
9351 @findex rindex
9352 @findex rint
9353 @findex rintf
9354 @findex rintl
9355 @findex round
9356 @findex roundf
9357 @findex roundl
9358 @findex scalb
9359 @findex scalbf
9360 @findex scalbl
9361 @findex scalbln
9362 @findex scalblnf
9363 @findex scalblnf
9364 @findex scalbn
9365 @findex scalbnf
9366 @findex scanfnl
9367 @findex signbit
9368 @findex signbitf
9369 @findex signbitl
9370 @findex signbitd32
9371 @findex signbitd64
9372 @findex signbitd128
9373 @findex significand
9374 @findex significandf
9375 @findex significandl
9376 @findex sin
9377 @findex sincos
9378 @findex sincosf
9379 @findex sincosl
9380 @findex sinf
9381 @findex sinh
9382 @findex sinhf
9383 @findex sinhl
9384 @findex sinl
9385 @findex snprintf
9386 @findex sprintf
9387 @findex sqrt
9388 @findex sqrtf
9389 @findex sqrtl
9390 @findex sscanf
9391 @findex stpcpy
9392 @findex stpncpy
9393 @findex strcasecmp
9394 @findex strcat
9395 @findex strchr
9396 @findex strcmp
9397 @findex strcpy
9398 @findex strcspn
9399 @findex strdup
9400 @findex strfmon
9401 @findex strftime
9402 @findex strlen
9403 @findex strncasecmp
9404 @findex strncat
9405 @findex strncmp
9406 @findex strncpy
9407 @findex strndup
9408 @findex strpbrk
9409 @findex strrchr
9410 @findex strspn
9411 @findex strstr
9412 @findex tan
9413 @findex tanf
9414 @findex tanh
9415 @findex tanhf
9416 @findex tanhl
9417 @findex tanl
9418 @findex tgamma
9419 @findex tgammaf
9420 @findex tgammal
9421 @findex toascii
9422 @findex tolower
9423 @findex toupper
9424 @findex towlower
9425 @findex towupper
9426 @findex trunc
9427 @findex truncf
9428 @findex truncl
9429 @findex vfprintf
9430 @findex vfscanf
9431 @findex vprintf
9432 @findex vscanf
9433 @findex vsnprintf
9434 @findex vsprintf
9435 @findex vsscanf
9436 @findex y0
9437 @findex y0f
9438 @findex y0l
9439 @findex y1
9440 @findex y1f
9441 @findex y1l
9442 @findex yn
9443 @findex ynf
9444 @findex ynl
9446 GCC provides a large number of built-in functions other than the ones
9447 mentioned above.  Some of these are for internal use in the processing
9448 of exceptions or variable-length argument lists and are not
9449 documented here because they may change from time to time; we do not
9450 recommend general use of these functions.
9452 The remaining functions are provided for optimization purposes.
9454 @opindex fno-builtin
9455 GCC includes built-in versions of many of the functions in the standard
9456 C library.  The versions prefixed with @code{__builtin_} are always
9457 treated as having the same meaning as the C library function even if you
9458 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9459 Many of these functions are only optimized in certain cases; if they are
9460 not optimized in a particular case, a call to the library function is
9461 emitted.
9463 @opindex ansi
9464 @opindex std
9465 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9466 @option{-std=c99} or @option{-std=c11}), the functions
9467 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9468 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9469 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9470 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9471 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9472 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9473 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9474 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9475 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9476 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9477 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9478 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9479 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9480 @code{significandl}, @code{significand}, @code{sincosf},
9481 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9482 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9483 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9484 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9485 @code{yn}
9486 may be handled as built-in functions.
9487 All these functions have corresponding versions
9488 prefixed with @code{__builtin_}, which may be used even in strict C90
9489 mode.
9491 The ISO C99 functions
9492 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9493 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9494 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9495 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9496 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9497 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9498 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9499 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9500 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9501 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9502 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9503 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9504 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9505 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9506 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9507 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9508 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9509 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9510 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9511 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9512 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9513 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9514 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9515 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9516 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9517 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9518 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9519 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9520 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9521 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9522 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9523 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9524 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9525 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9526 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9527 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9528 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9529 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9530 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9531 are handled as built-in functions
9532 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9534 There are also built-in versions of the ISO C99 functions
9535 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9536 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9537 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9538 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9539 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9540 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9541 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9542 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9543 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9544 that are recognized in any mode since ISO C90 reserves these names for
9545 the purpose to which ISO C99 puts them.  All these functions have
9546 corresponding versions prefixed with @code{__builtin_}.
9548 The ISO C94 functions
9549 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9550 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9551 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9552 @code{towupper}
9553 are handled as built-in functions
9554 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9556 The ISO C90 functions
9557 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9558 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9559 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9560 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9561 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9562 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9563 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9564 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9565 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9566 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9567 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9568 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9569 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9570 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9571 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9572 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9573 are all recognized as built-in functions unless
9574 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9575 is specified for an individual function).  All of these functions have
9576 corresponding versions prefixed with @code{__builtin_}.
9578 GCC provides built-in versions of the ISO C99 floating-point comparison
9579 macros that avoid raising exceptions for unordered operands.  They have
9580 the same names as the standard macros ( @code{isgreater},
9581 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9582 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9583 prefixed.  We intend for a library implementor to be able to simply
9584 @code{#define} each standard macro to its built-in equivalent.
9585 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9586 @code{isinf_sign} and @code{isnormal} built-ins used with
9587 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9588 built-in functions appear both with and without the @code{__builtin_} prefix.
9590 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9592 You can use the built-in function @code{__builtin_types_compatible_p} to
9593 determine whether two types are the same.
9595 This built-in function returns 1 if the unqualified versions of the
9596 types @var{type1} and @var{type2} (which are types, not expressions) are
9597 compatible, 0 otherwise.  The result of this built-in function can be
9598 used in integer constant expressions.
9600 This built-in function ignores top level qualifiers (e.g., @code{const},
9601 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9602 int}.
9604 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9605 hand, @code{int} and @code{char *} are not compatible, even if the size
9606 of their types, on the particular architecture are the same.  Also, the
9607 amount of pointer indirection is taken into account when determining
9608 similarity.  Consequently, @code{short *} is not similar to
9609 @code{short **}.  Furthermore, two types that are typedefed are
9610 considered compatible if their underlying types are compatible.
9612 An @code{enum} type is not considered to be compatible with another
9613 @code{enum} type even if both are compatible with the same integer
9614 type; this is what the C standard specifies.
9615 For example, @code{enum @{foo, bar@}} is not similar to
9616 @code{enum @{hot, dog@}}.
9618 You typically use this function in code whose execution varies
9619 depending on the arguments' types.  For example:
9621 @smallexample
9622 #define foo(x)                                                  \
9623   (@{                                                           \
9624     typeof (x) tmp = (x);                                       \
9625     if (__builtin_types_compatible_p (typeof (x), long double)) \
9626       tmp = foo_long_double (tmp);                              \
9627     else if (__builtin_types_compatible_p (typeof (x), double)) \
9628       tmp = foo_double (tmp);                                   \
9629     else if (__builtin_types_compatible_p (typeof (x), float))  \
9630       tmp = foo_float (tmp);                                    \
9631     else                                                        \
9632       abort ();                                                 \
9633     tmp;                                                        \
9634   @})
9635 @end smallexample
9637 @emph{Note:} This construct is only available for C@.
9639 @end deftypefn
9641 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9643 The @var{call_exp} expression must be a function call, and the
9644 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
9645 is passed to the function call in the target's static chain location.
9646 The result of builtin is the result of the function call.
9648 @emph{Note:} This builtin is only available for C@.
9649 This builtin can be used to call Go closures from C.
9651 @end deftypefn
9653 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9655 You can use the built-in function @code{__builtin_choose_expr} to
9656 evaluate code depending on the value of a constant expression.  This
9657 built-in function returns @var{exp1} if @var{const_exp}, which is an
9658 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9660 This built-in function is analogous to the @samp{? :} operator in C,
9661 except that the expression returned has its type unaltered by promotion
9662 rules.  Also, the built-in function does not evaluate the expression
9663 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9664 @var{exp2} is not evaluated even if it has side-effects.
9666 This built-in function can return an lvalue if the chosen argument is an
9667 lvalue.
9669 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9670 type.  Similarly, if @var{exp2} is returned, its return type is the same
9671 as @var{exp2}.
9673 Example:
9675 @smallexample
9676 #define foo(x)                                                    \
9677   __builtin_choose_expr (                                         \
9678     __builtin_types_compatible_p (typeof (x), double),            \
9679     foo_double (x),                                               \
9680     __builtin_choose_expr (                                       \
9681       __builtin_types_compatible_p (typeof (x), float),           \
9682       foo_float (x),                                              \
9683       /* @r{The void expression results in a compile-time error}  \
9684          @r{when assigning the result to something.}  */          \
9685       (void)0))
9686 @end smallexample
9688 @emph{Note:} This construct is only available for C@.  Furthermore, the
9689 unused expression (@var{exp1} or @var{exp2} depending on the value of
9690 @var{const_exp}) may still generate syntax errors.  This may change in
9691 future revisions.
9693 @end deftypefn
9695 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9697 The built-in function @code{__builtin_complex} is provided for use in
9698 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9699 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9700 real binary floating-point type, and the result has the corresponding
9701 complex type with real and imaginary parts @var{real} and @var{imag}.
9702 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9703 infinities, NaNs and negative zeros are involved.
9705 @end deftypefn
9707 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9708 You can use the built-in function @code{__builtin_constant_p} to
9709 determine if a value is known to be constant at compile time and hence
9710 that GCC can perform constant-folding on expressions involving that
9711 value.  The argument of the function is the value to test.  The function
9712 returns the integer 1 if the argument is known to be a compile-time
9713 constant and 0 if it is not known to be a compile-time constant.  A
9714 return of 0 does not indicate that the value is @emph{not} a constant,
9715 but merely that GCC cannot prove it is a constant with the specified
9716 value of the @option{-O} option.
9718 You typically use this function in an embedded application where
9719 memory is a critical resource.  If you have some complex calculation,
9720 you may want it to be folded if it involves constants, but need to call
9721 a function if it does not.  For example:
9723 @smallexample
9724 #define Scale_Value(X)      \
9725   (__builtin_constant_p (X) \
9726   ? ((X) * SCALE + OFFSET) : Scale (X))
9727 @end smallexample
9729 You may use this built-in function in either a macro or an inline
9730 function.  However, if you use it in an inlined function and pass an
9731 argument of the function as the argument to the built-in, GCC 
9732 never returns 1 when you call the inline function with a string constant
9733 or compound literal (@pxref{Compound Literals}) and does not return 1
9734 when you pass a constant numeric value to the inline function unless you
9735 specify the @option{-O} option.
9737 You may also use @code{__builtin_constant_p} in initializers for static
9738 data.  For instance, you can write
9740 @smallexample
9741 static const int table[] = @{
9742    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9743    /* @r{@dots{}} */
9745 @end smallexample
9747 @noindent
9748 This is an acceptable initializer even if @var{EXPRESSION} is not a
9749 constant expression, including the case where
9750 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9751 folded to a constant but @var{EXPRESSION} contains operands that are
9752 not otherwise permitted in a static initializer (for example,
9753 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9754 built-in in this case, because it has no opportunity to perform
9755 optimization.
9756 @end deftypefn
9758 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9759 @opindex fprofile-arcs
9760 You may use @code{__builtin_expect} to provide the compiler with
9761 branch prediction information.  In general, you should prefer to
9762 use actual profile feedback for this (@option{-fprofile-arcs}), as
9763 programmers are notoriously bad at predicting how their programs
9764 actually perform.  However, there are applications in which this
9765 data is hard to collect.
9767 The return value is the value of @var{exp}, which should be an integral
9768 expression.  The semantics of the built-in are that it is expected that
9769 @var{exp} == @var{c}.  For example:
9771 @smallexample
9772 if (__builtin_expect (x, 0))
9773   foo ();
9774 @end smallexample
9776 @noindent
9777 indicates that we do not expect to call @code{foo}, since
9778 we expect @code{x} to be zero.  Since you are limited to integral
9779 expressions for @var{exp}, you should use constructions such as
9781 @smallexample
9782 if (__builtin_expect (ptr != NULL, 1))
9783   foo (*ptr);
9784 @end smallexample
9786 @noindent
9787 when testing pointer or floating-point values.
9788 @end deftypefn
9790 @deftypefn {Built-in Function} void __builtin_trap (void)
9791 This function causes the program to exit abnormally.  GCC implements
9792 this function by using a target-dependent mechanism (such as
9793 intentionally executing an illegal instruction) or by calling
9794 @code{abort}.  The mechanism used may vary from release to release so
9795 you should not rely on any particular implementation.
9796 @end deftypefn
9798 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9799 If control flow reaches the point of the @code{__builtin_unreachable},
9800 the program is undefined.  It is useful in situations where the
9801 compiler cannot deduce the unreachability of the code.
9803 One such case is immediately following an @code{asm} statement that
9804 either never terminates, or one that transfers control elsewhere
9805 and never returns.  In this example, without the
9806 @code{__builtin_unreachable}, GCC issues a warning that control
9807 reaches the end of a non-void function.  It also generates code
9808 to return after the @code{asm}.
9810 @smallexample
9811 int f (int c, int v)
9813   if (c)
9814     @{
9815       return v;
9816     @}
9817   else
9818     @{
9819       asm("jmp error_handler");
9820       __builtin_unreachable ();
9821     @}
9823 @end smallexample
9825 @noindent
9826 Because the @code{asm} statement unconditionally transfers control out
9827 of the function, control never reaches the end of the function
9828 body.  The @code{__builtin_unreachable} is in fact unreachable and
9829 communicates this fact to the compiler.
9831 Another use for @code{__builtin_unreachable} is following a call a
9832 function that never returns but that is not declared
9833 @code{__attribute__((noreturn))}, as in this example:
9835 @smallexample
9836 void function_that_never_returns (void);
9838 int g (int c)
9840   if (c)
9841     @{
9842       return 1;
9843     @}
9844   else
9845     @{
9846       function_that_never_returns ();
9847       __builtin_unreachable ();
9848     @}
9850 @end smallexample
9852 @end deftypefn
9854 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9855 This function returns its first argument, and allows the compiler
9856 to assume that the returned pointer is at least @var{align} bytes
9857 aligned.  This built-in can have either two or three arguments,
9858 if it has three, the third argument should have integer type, and
9859 if it is nonzero means misalignment offset.  For example:
9861 @smallexample
9862 void *x = __builtin_assume_aligned (arg, 16);
9863 @end smallexample
9865 @noindent
9866 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9867 16-byte aligned, while:
9869 @smallexample
9870 void *x = __builtin_assume_aligned (arg, 32, 8);
9871 @end smallexample
9873 @noindent
9874 means that the compiler can assume for @code{x}, set to @code{arg}, that
9875 @code{(char *) x - 8} is 32-byte aligned.
9876 @end deftypefn
9878 @deftypefn {Built-in Function} int __builtin_LINE ()
9879 This function is the equivalent to the preprocessor @code{__LINE__}
9880 macro and returns the line number of the invocation of the built-in.
9881 In a C++ default argument for a function @var{F}, it gets the line number of
9882 the call to @var{F}.
9883 @end deftypefn
9885 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9886 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9887 macro and returns the function name the invocation of the built-in is in.
9888 @end deftypefn
9890 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9891 This function is the equivalent to the preprocessor @code{__FILE__}
9892 macro and returns the file name the invocation of the built-in is in.
9893 In a C++ default argument for a function @var{F}, it gets the file name of
9894 the call to @var{F}.
9895 @end deftypefn
9897 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9898 This function is used to flush the processor's instruction cache for
9899 the region of memory between @var{begin} inclusive and @var{end}
9900 exclusive.  Some targets require that the instruction cache be
9901 flushed, after modifying memory containing code, in order to obtain
9902 deterministic behavior.
9904 If the target does not require instruction cache flushes,
9905 @code{__builtin___clear_cache} has no effect.  Otherwise either
9906 instructions are emitted in-line to clear the instruction cache or a
9907 call to the @code{__clear_cache} function in libgcc is made.
9908 @end deftypefn
9910 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9911 This function is used to minimize cache-miss latency by moving data into
9912 a cache before it is accessed.
9913 You can insert calls to @code{__builtin_prefetch} into code for which
9914 you know addresses of data in memory that is likely to be accessed soon.
9915 If the target supports them, data prefetch instructions are generated.
9916 If the prefetch is done early enough before the access then the data will
9917 be in the cache by the time it is accessed.
9919 The value of @var{addr} is the address of the memory to prefetch.
9920 There are two optional arguments, @var{rw} and @var{locality}.
9921 The value of @var{rw} is a compile-time constant one or zero; one
9922 means that the prefetch is preparing for a write to the memory address
9923 and zero, the default, means that the prefetch is preparing for a read.
9924 The value @var{locality} must be a compile-time constant integer between
9925 zero and three.  A value of zero means that the data has no temporal
9926 locality, so it need not be left in the cache after the access.  A value
9927 of three means that the data has a high degree of temporal locality and
9928 should be left in all levels of cache possible.  Values of one and two
9929 mean, respectively, a low or moderate degree of temporal locality.  The
9930 default is three.
9932 @smallexample
9933 for (i = 0; i < n; i++)
9934   @{
9935     a[i] = a[i] + b[i];
9936     __builtin_prefetch (&a[i+j], 1, 1);
9937     __builtin_prefetch (&b[i+j], 0, 1);
9938     /* @r{@dots{}} */
9939   @}
9940 @end smallexample
9942 Data prefetch does not generate faults if @var{addr} is invalid, but
9943 the address expression itself must be valid.  For example, a prefetch
9944 of @code{p->next} does not fault if @code{p->next} is not a valid
9945 address, but evaluation faults if @code{p} is not a valid address.
9947 If the target does not support data prefetch, the address expression
9948 is evaluated if it includes side effects but no other code is generated
9949 and GCC does not issue a warning.
9950 @end deftypefn
9952 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9953 Returns a positive infinity, if supported by the floating-point format,
9954 else @code{DBL_MAX}.  This function is suitable for implementing the
9955 ISO C macro @code{HUGE_VAL}.
9956 @end deftypefn
9958 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9959 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9960 @end deftypefn
9962 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9963 Similar to @code{__builtin_huge_val}, except the return
9964 type is @code{long double}.
9965 @end deftypefn
9967 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9968 This built-in implements the C99 fpclassify functionality.  The first
9969 five int arguments should be the target library's notion of the
9970 possible FP classes and are used for return values.  They must be
9971 constant values and they must appear in this order: @code{FP_NAN},
9972 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9973 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9974 to classify.  GCC treats the last argument as type-generic, which
9975 means it does not do default promotion from float to double.
9976 @end deftypefn
9978 @deftypefn {Built-in Function} double __builtin_inf (void)
9979 Similar to @code{__builtin_huge_val}, except a warning is generated
9980 if the target floating-point format does not support infinities.
9981 @end deftypefn
9983 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9984 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9985 @end deftypefn
9987 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9988 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9989 @end deftypefn
9991 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9992 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9993 @end deftypefn
9995 @deftypefn {Built-in Function} float __builtin_inff (void)
9996 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9997 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9998 @end deftypefn
10000 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10001 Similar to @code{__builtin_inf}, except the return
10002 type is @code{long double}.
10003 @end deftypefn
10005 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10006 Similar to @code{isinf}, except the return value is -1 for
10007 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10008 Note while the parameter list is an
10009 ellipsis, this function only accepts exactly one floating-point
10010 argument.  GCC treats this parameter as type-generic, which means it
10011 does not do default promotion from float to double.
10012 @end deftypefn
10014 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10015 This is an implementation of the ISO C99 function @code{nan}.
10017 Since ISO C99 defines this function in terms of @code{strtod}, which we
10018 do not implement, a description of the parsing is in order.  The string
10019 is parsed as by @code{strtol}; that is, the base is recognized by
10020 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
10021 in the significand such that the least significant bit of the number
10022 is at the least significant bit of the significand.  The number is
10023 truncated to fit the significand field provided.  The significand is
10024 forced to be a quiet NaN@.
10026 This function, if given a string literal all of which would have been
10027 consumed by @code{strtol}, is evaluated early enough that it is considered a
10028 compile-time constant.
10029 @end deftypefn
10031 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10032 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10033 @end deftypefn
10035 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10036 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10037 @end deftypefn
10039 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
10040 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
10041 @end deftypefn
10043 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
10044 Similar to @code{__builtin_nan}, except the return type is @code{float}.
10045 @end deftypefn
10047 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
10048 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
10049 @end deftypefn
10051 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
10052 Similar to @code{__builtin_nan}, except the significand is forced
10053 to be a signaling NaN@.  The @code{nans} function is proposed by
10054 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
10055 @end deftypefn
10057 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
10058 Similar to @code{__builtin_nans}, except the return type is @code{float}.
10059 @end deftypefn
10061 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
10062 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
10063 @end deftypefn
10065 @deftypefn {Built-in Function} int __builtin_ffs (int x)
10066 Returns one plus the index of the least significant 1-bit of @var{x}, or
10067 if @var{x} is zero, returns zero.
10068 @end deftypefn
10070 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
10071 Returns the number of leading 0-bits in @var{x}, starting at the most
10072 significant bit position.  If @var{x} is 0, the result is undefined.
10073 @end deftypefn
10075 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
10076 Returns the number of trailing 0-bits in @var{x}, starting at the least
10077 significant bit position.  If @var{x} is 0, the result is undefined.
10078 @end deftypefn
10080 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
10081 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
10082 number of bits following the most significant bit that are identical
10083 to it.  There are no special cases for 0 or other values. 
10084 @end deftypefn
10086 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
10087 Returns the number of 1-bits in @var{x}.
10088 @end deftypefn
10090 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10091 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10092 modulo 2.
10093 @end deftypefn
10095 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10096 Similar to @code{__builtin_ffs}, except the argument type is
10097 @code{long}.
10098 @end deftypefn
10100 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10101 Similar to @code{__builtin_clz}, except the argument type is
10102 @code{unsigned long}.
10103 @end deftypefn
10105 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10106 Similar to @code{__builtin_ctz}, except the argument type is
10107 @code{unsigned long}.
10108 @end deftypefn
10110 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10111 Similar to @code{__builtin_clrsb}, except the argument type is
10112 @code{long}.
10113 @end deftypefn
10115 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10116 Similar to @code{__builtin_popcount}, except the argument type is
10117 @code{unsigned long}.
10118 @end deftypefn
10120 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10121 Similar to @code{__builtin_parity}, except the argument type is
10122 @code{unsigned long}.
10123 @end deftypefn
10125 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10126 Similar to @code{__builtin_ffs}, except the argument type is
10127 @code{long long}.
10128 @end deftypefn
10130 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10131 Similar to @code{__builtin_clz}, except the argument type is
10132 @code{unsigned long long}.
10133 @end deftypefn
10135 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10136 Similar to @code{__builtin_ctz}, except the argument type is
10137 @code{unsigned long long}.
10138 @end deftypefn
10140 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10141 Similar to @code{__builtin_clrsb}, except the argument type is
10142 @code{long long}.
10143 @end deftypefn
10145 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10146 Similar to @code{__builtin_popcount}, except the argument type is
10147 @code{unsigned long long}.
10148 @end deftypefn
10150 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10151 Similar to @code{__builtin_parity}, except the argument type is
10152 @code{unsigned long long}.
10153 @end deftypefn
10155 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10156 Returns the first argument raised to the power of the second.  Unlike the
10157 @code{pow} function no guarantees about precision and rounding are made.
10158 @end deftypefn
10160 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10161 Similar to @code{__builtin_powi}, except the argument and return types
10162 are @code{float}.
10163 @end deftypefn
10165 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10166 Similar to @code{__builtin_powi}, except the argument and return types
10167 are @code{long double}.
10168 @end deftypefn
10170 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10171 Returns @var{x} with the order of the bytes reversed; for example,
10172 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10173 exactly 8 bits.
10174 @end deftypefn
10176 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10177 Similar to @code{__builtin_bswap16}, except the argument and return types
10178 are 32 bit.
10179 @end deftypefn
10181 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10182 Similar to @code{__builtin_bswap32}, except the argument and return types
10183 are 64 bit.
10184 @end deftypefn
10186 @node Target Builtins
10187 @section Built-in Functions Specific to Particular Target Machines
10189 On some target machines, GCC supports many built-in functions specific
10190 to those machines.  Generally these generate calls to specific machine
10191 instructions, but allow the compiler to schedule those calls.
10193 @menu
10194 * AArch64 Built-in Functions::
10195 * Alpha Built-in Functions::
10196 * Altera Nios II Built-in Functions::
10197 * ARC Built-in Functions::
10198 * ARC SIMD Built-in Functions::
10199 * ARM iWMMXt Built-in Functions::
10200 * ARM C Language Extensions (ACLE)::
10201 * ARM Floating Point Status and Control Intrinsics::
10202 * AVR Built-in Functions::
10203 * Blackfin Built-in Functions::
10204 * FR-V Built-in Functions::
10205 * MIPS DSP Built-in Functions::
10206 * MIPS Paired-Single Support::
10207 * MIPS Loongson Built-in Functions::
10208 * Other MIPS Built-in Functions::
10209 * MSP430 Built-in Functions::
10210 * NDS32 Built-in Functions::
10211 * picoChip Built-in Functions::
10212 * PowerPC Built-in Functions::
10213 * PowerPC AltiVec/VSX Built-in Functions::
10214 * PowerPC Hardware Transactional Memory Built-in Functions::
10215 * RX Built-in Functions::
10216 * S/390 System z Built-in Functions::
10217 * SH Built-in Functions::
10218 * SPARC VIS Built-in Functions::
10219 * SPU Built-in Functions::
10220 * TI C6X Built-in Functions::
10221 * TILE-Gx Built-in Functions::
10222 * TILEPro Built-in Functions::
10223 * x86 Built-in Functions::
10224 * x86 transactional memory intrinsics::
10225 @end menu
10227 @node AArch64 Built-in Functions
10228 @subsection AArch64 Built-in Functions
10230 These built-in functions are available for the AArch64 family of
10231 processors.
10232 @smallexample
10233 unsigned int __builtin_aarch64_get_fpcr ()
10234 void __builtin_aarch64_set_fpcr (unsigned int)
10235 unsigned int __builtin_aarch64_get_fpsr ()
10236 void __builtin_aarch64_set_fpsr (unsigned int)
10237 @end smallexample
10239 @node Alpha Built-in Functions
10240 @subsection Alpha Built-in Functions
10242 These built-in functions are available for the Alpha family of
10243 processors, depending on the command-line switches used.
10245 The following built-in functions are always available.  They
10246 all generate the machine instruction that is part of the name.
10248 @smallexample
10249 long __builtin_alpha_implver (void)
10250 long __builtin_alpha_rpcc (void)
10251 long __builtin_alpha_amask (long)
10252 long __builtin_alpha_cmpbge (long, long)
10253 long __builtin_alpha_extbl (long, long)
10254 long __builtin_alpha_extwl (long, long)
10255 long __builtin_alpha_extll (long, long)
10256 long __builtin_alpha_extql (long, long)
10257 long __builtin_alpha_extwh (long, long)
10258 long __builtin_alpha_extlh (long, long)
10259 long __builtin_alpha_extqh (long, long)
10260 long __builtin_alpha_insbl (long, long)
10261 long __builtin_alpha_inswl (long, long)
10262 long __builtin_alpha_insll (long, long)
10263 long __builtin_alpha_insql (long, long)
10264 long __builtin_alpha_inswh (long, long)
10265 long __builtin_alpha_inslh (long, long)
10266 long __builtin_alpha_insqh (long, long)
10267 long __builtin_alpha_mskbl (long, long)
10268 long __builtin_alpha_mskwl (long, long)
10269 long __builtin_alpha_mskll (long, long)
10270 long __builtin_alpha_mskql (long, long)
10271 long __builtin_alpha_mskwh (long, long)
10272 long __builtin_alpha_msklh (long, long)
10273 long __builtin_alpha_mskqh (long, long)
10274 long __builtin_alpha_umulh (long, long)
10275 long __builtin_alpha_zap (long, long)
10276 long __builtin_alpha_zapnot (long, long)
10277 @end smallexample
10279 The following built-in functions are always with @option{-mmax}
10280 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10281 later.  They all generate the machine instruction that is part
10282 of the name.
10284 @smallexample
10285 long __builtin_alpha_pklb (long)
10286 long __builtin_alpha_pkwb (long)
10287 long __builtin_alpha_unpkbl (long)
10288 long __builtin_alpha_unpkbw (long)
10289 long __builtin_alpha_minub8 (long, long)
10290 long __builtin_alpha_minsb8 (long, long)
10291 long __builtin_alpha_minuw4 (long, long)
10292 long __builtin_alpha_minsw4 (long, long)
10293 long __builtin_alpha_maxub8 (long, long)
10294 long __builtin_alpha_maxsb8 (long, long)
10295 long __builtin_alpha_maxuw4 (long, long)
10296 long __builtin_alpha_maxsw4 (long, long)
10297 long __builtin_alpha_perr (long, long)
10298 @end smallexample
10300 The following built-in functions are always with @option{-mcix}
10301 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10302 later.  They all generate the machine instruction that is part
10303 of the name.
10305 @smallexample
10306 long __builtin_alpha_cttz (long)
10307 long __builtin_alpha_ctlz (long)
10308 long __builtin_alpha_ctpop (long)
10309 @end smallexample
10311 The following built-in functions are available on systems that use the OSF/1
10312 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10313 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10314 @code{rdval} and @code{wrval}.
10316 @smallexample
10317 void *__builtin_thread_pointer (void)
10318 void __builtin_set_thread_pointer (void *)
10319 @end smallexample
10321 @node Altera Nios II Built-in Functions
10322 @subsection Altera Nios II Built-in Functions
10324 These built-in functions are available for the Altera Nios II
10325 family of processors.
10327 The following built-in functions are always available.  They
10328 all generate the machine instruction that is part of the name.
10330 @example
10331 int __builtin_ldbio (volatile const void *)
10332 int __builtin_ldbuio (volatile const void *)
10333 int __builtin_ldhio (volatile const void *)
10334 int __builtin_ldhuio (volatile const void *)
10335 int __builtin_ldwio (volatile const void *)
10336 void __builtin_stbio (volatile void *, int)
10337 void __builtin_sthio (volatile void *, int)
10338 void __builtin_stwio (volatile void *, int)
10339 void __builtin_sync (void)
10340 int __builtin_rdctl (int) 
10341 void __builtin_wrctl (int, int)
10342 @end example
10344 The following built-in functions are always available.  They
10345 all generate a Nios II Custom Instruction. The name of the
10346 function represents the types that the function takes and
10347 returns. The letter before the @code{n} is the return type
10348 or void if absent. The @code{n} represents the first parameter
10349 to all the custom instructions, the custom instruction number.
10350 The two letters after the @code{n} represent the up to two
10351 parameters to the function.
10353 The letters represent the following data types:
10354 @table @code
10355 @item <no letter>
10356 @code{void} for return type and no parameter for parameter types.
10358 @item i
10359 @code{int} for return type and parameter type
10361 @item f
10362 @code{float} for return type and parameter type
10364 @item p
10365 @code{void *} for return type and parameter type
10367 @end table
10369 And the function names are:
10370 @example
10371 void __builtin_custom_n (void)
10372 void __builtin_custom_ni (int)
10373 void __builtin_custom_nf (float)
10374 void __builtin_custom_np (void *)
10375 void __builtin_custom_nii (int, int)
10376 void __builtin_custom_nif (int, float)
10377 void __builtin_custom_nip (int, void *)
10378 void __builtin_custom_nfi (float, int)
10379 void __builtin_custom_nff (float, float)
10380 void __builtin_custom_nfp (float, void *)
10381 void __builtin_custom_npi (void *, int)
10382 void __builtin_custom_npf (void *, float)
10383 void __builtin_custom_npp (void *, void *)
10384 int __builtin_custom_in (void)
10385 int __builtin_custom_ini (int)
10386 int __builtin_custom_inf (float)
10387 int __builtin_custom_inp (void *)
10388 int __builtin_custom_inii (int, int)
10389 int __builtin_custom_inif (int, float)
10390 int __builtin_custom_inip (int, void *)
10391 int __builtin_custom_infi (float, int)
10392 int __builtin_custom_inff (float, float)
10393 int __builtin_custom_infp (float, void *)
10394 int __builtin_custom_inpi (void *, int)
10395 int __builtin_custom_inpf (void *, float)
10396 int __builtin_custom_inpp (void *, void *)
10397 float __builtin_custom_fn (void)
10398 float __builtin_custom_fni (int)
10399 float __builtin_custom_fnf (float)
10400 float __builtin_custom_fnp (void *)
10401 float __builtin_custom_fnii (int, int)
10402 float __builtin_custom_fnif (int, float)
10403 float __builtin_custom_fnip (int, void *)
10404 float __builtin_custom_fnfi (float, int)
10405 float __builtin_custom_fnff (float, float)
10406 float __builtin_custom_fnfp (float, void *)
10407 float __builtin_custom_fnpi (void *, int)
10408 float __builtin_custom_fnpf (void *, float)
10409 float __builtin_custom_fnpp (void *, void *)
10410 void * __builtin_custom_pn (void)
10411 void * __builtin_custom_pni (int)
10412 void * __builtin_custom_pnf (float)
10413 void * __builtin_custom_pnp (void *)
10414 void * __builtin_custom_pnii (int, int)
10415 void * __builtin_custom_pnif (int, float)
10416 void * __builtin_custom_pnip (int, void *)
10417 void * __builtin_custom_pnfi (float, int)
10418 void * __builtin_custom_pnff (float, float)
10419 void * __builtin_custom_pnfp (float, void *)
10420 void * __builtin_custom_pnpi (void *, int)
10421 void * __builtin_custom_pnpf (void *, float)
10422 void * __builtin_custom_pnpp (void *, void *)
10423 @end example
10425 @node ARC Built-in Functions
10426 @subsection ARC Built-in Functions
10428 The following built-in functions are provided for ARC targets.  The
10429 built-ins generate the corresponding assembly instructions.  In the
10430 examples given below, the generated code often requires an operand or
10431 result to be in a register.  Where necessary further code will be
10432 generated to ensure this is true, but for brevity this is not
10433 described in each case.
10435 @emph{Note:} Using a built-in to generate an instruction not supported
10436 by a target may cause problems. At present the compiler is not
10437 guaranteed to detect such misuse, and as a result an internal compiler
10438 error may be generated.
10440 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10441 Return 1 if @var{val} is known to have the byte alignment given
10442 by @var{alignval}, otherwise return 0.
10443 Note that this is different from
10444 @smallexample
10445 __alignof__(*(char *)@var{val}) >= alignval
10446 @end smallexample
10447 because __alignof__ sees only the type of the dereference, whereas
10448 __builtin_arc_align uses alignment information from the pointer
10449 as well as from the pointed-to type.
10450 The information available will depend on optimization level.
10451 @end deftypefn
10453 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10454 Generates
10455 @example
10457 @end example
10458 @end deftypefn
10460 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10461 The operand is the number of a register to be read.  Generates:
10462 @example
10463 mov  @var{dest}, r@var{regno}
10464 @end example
10465 where the value in @var{dest} will be the result returned from the
10466 built-in.
10467 @end deftypefn
10469 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10470 The first operand is the number of a register to be written, the
10471 second operand is a compile time constant to write into that
10472 register.  Generates:
10473 @example
10474 mov  r@var{regno}, @var{val}
10475 @end example
10476 @end deftypefn
10478 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10479 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10480 Generates:
10481 @example
10482 divaw  @var{dest}, @var{a}, @var{b}
10483 @end example
10484 where the value in @var{dest} will be the result returned from the
10485 built-in.
10486 @end deftypefn
10488 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10489 Generates
10490 @example
10491 flag  @var{a}
10492 @end example
10493 @end deftypefn
10495 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10496 The operand, @var{auxv}, is the address of an auxiliary register and
10497 must be a compile time constant.  Generates:
10498 @example
10499 lr  @var{dest}, [@var{auxr}]
10500 @end example
10501 Where the value in @var{dest} will be the result returned from the
10502 built-in.
10503 @end deftypefn
10505 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10506 Only available with @option{-mmul64}.  Generates:
10507 @example
10508 mul64  @var{a}, @var{b}
10509 @end example
10510 @end deftypefn
10512 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10513 Only available with @option{-mmul64}.  Generates:
10514 @example
10515 mulu64  @var{a}, @var{b}
10516 @end example
10517 @end deftypefn
10519 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10520 Generates:
10521 @example
10523 @end example
10524 @end deftypefn
10526 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10527 Only valid if the @samp{norm} instruction is available through the
10528 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10529 Generates:
10530 @example
10531 norm  @var{dest}, @var{src}
10532 @end example
10533 Where the value in @var{dest} will be the result returned from the
10534 built-in.
10535 @end deftypefn
10537 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10538 Only valid if the @samp{normw} instruction is available through the
10539 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10540 Generates:
10541 @example
10542 normw  @var{dest}, @var{src}
10543 @end example
10544 Where the value in @var{dest} will be the result returned from the
10545 built-in.
10546 @end deftypefn
10548 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10549 Generates:
10550 @example
10551 rtie
10552 @end example
10553 @end deftypefn
10555 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10556 Generates:
10557 @example
10558 sleep  @var{a}
10559 @end example
10560 @end deftypefn
10562 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10563 The first argument, @var{auxv}, is the address of an auxiliary
10564 register, the second argument, @var{val}, is a compile time constant
10565 to be written to the register.  Generates:
10566 @example
10567 sr  @var{auxr}, [@var{val}]
10568 @end example
10569 @end deftypefn
10571 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10572 Only valid with @option{-mswap}.  Generates:
10573 @example
10574 swap  @var{dest}, @var{src}
10575 @end example
10576 Where the value in @var{dest} will be the result returned from the
10577 built-in.
10578 @end deftypefn
10580 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10581 Generates:
10582 @example
10584 @end example
10585 @end deftypefn
10587 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10588 Only available with @option{-mcpu=ARC700}.  Generates:
10589 @example
10590 sync
10591 @end example
10592 @end deftypefn
10594 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10595 Only available with @option{-mcpu=ARC700}.  Generates:
10596 @example
10597 trap_s  @var{c}
10598 @end example
10599 @end deftypefn
10601 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10602 Only available with @option{-mcpu=ARC700}.  Generates:
10603 @example
10604 unimp_s
10605 @end example
10606 @end deftypefn
10608 The instructions generated by the following builtins are not
10609 considered as candidates for scheduling.  They are not moved around by
10610 the compiler during scheduling, and thus can be expected to appear
10611 where they are put in the C code:
10612 @example
10613 __builtin_arc_brk()
10614 __builtin_arc_core_read()
10615 __builtin_arc_core_write()
10616 __builtin_arc_flag()
10617 __builtin_arc_lr()
10618 __builtin_arc_sleep()
10619 __builtin_arc_sr()
10620 __builtin_arc_swi()
10621 @end example
10623 @node ARC SIMD Built-in Functions
10624 @subsection ARC SIMD Built-in Functions
10626 SIMD builtins provided by the compiler can be used to generate the
10627 vector instructions.  This section describes the available builtins
10628 and their usage in programs.  With the @option{-msimd} option, the
10629 compiler provides 128-bit vector types, which can be specified using
10630 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10631 can be included to use the following predefined types:
10632 @example
10633 typedef int __v4si   __attribute__((vector_size(16)));
10634 typedef short __v8hi __attribute__((vector_size(16)));
10635 @end example
10637 These types can be used to define 128-bit variables.  The built-in
10638 functions listed in the following section can be used on these
10639 variables to generate the vector operations.
10641 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10642 @file{arc-simd.h} also provides equivalent macros called
10643 @code{_@var{someinsn}} that can be used for programming ease and
10644 improved readability.  The following macros for DMA control are also
10645 provided:
10646 @example
10647 #define _setup_dma_in_channel_reg _vdiwr
10648 #define _setup_dma_out_channel_reg _vdowr
10649 @end example
10651 The following is a complete list of all the SIMD built-ins provided
10652 for ARC, grouped by calling signature.
10654 The following take two @code{__v8hi} arguments and return a
10655 @code{__v8hi} result:
10656 @example
10657 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10658 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10659 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10660 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10661 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10662 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10663 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10664 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10665 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10666 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10667 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10668 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10669 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10670 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10671 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10672 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10673 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10674 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10675 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10676 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10677 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10678 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10679 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10680 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10681 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10682 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10683 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10684 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10685 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10686 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10687 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10688 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10689 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10690 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10691 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10692 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10693 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10694 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10695 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10696 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10697 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10698 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10699 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10700 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10701 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10702 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10703 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10704 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10705 @end example
10707 The following take one @code{__v8hi} and one @code{int} argument and return a
10708 @code{__v8hi} result:
10710 @example
10711 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10712 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10713 __v8hi __builtin_arc_vbminw (__v8hi, int)
10714 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10715 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10716 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10717 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10718 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10719 @end example
10721 The following take one @code{__v8hi} argument and one @code{int} argument which
10722 must be a 3-bit compile time constant indicating a register number
10723 I0-I7.  They return a @code{__v8hi} result.
10724 @example
10725 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10726 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10727 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10728 @end example
10730 The following take one @code{__v8hi} argument and one @code{int}
10731 argument which must be a 6-bit compile time constant.  They return a
10732 @code{__v8hi} result.
10733 @example
10734 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10735 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10736 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10737 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10738 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10739 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10740 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10741 @end example
10743 The following take one @code{__v8hi} argument and one @code{int} argument which
10744 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10745 result.
10746 @example
10747 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10748 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10749 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10750 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10751 @end example
10753 The following take two @code{int} arguments, the second of which which
10754 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10755 result:
10756 @example
10757 __v8hi __builtin_arc_vmovaw (int, const int)
10758 __v8hi __builtin_arc_vmovw (int, const int)
10759 __v8hi __builtin_arc_vmovzw (int, const int)
10760 @end example
10762 The following take a single @code{__v8hi} argument and return a
10763 @code{__v8hi} result:
10764 @example
10765 __v8hi __builtin_arc_vabsaw (__v8hi)
10766 __v8hi __builtin_arc_vabsw (__v8hi)
10767 __v8hi __builtin_arc_vaddsuw (__v8hi)
10768 __v8hi __builtin_arc_vexch1 (__v8hi)
10769 __v8hi __builtin_arc_vexch2 (__v8hi)
10770 __v8hi __builtin_arc_vexch4 (__v8hi)
10771 __v8hi __builtin_arc_vsignw (__v8hi)
10772 __v8hi __builtin_arc_vupbaw (__v8hi)
10773 __v8hi __builtin_arc_vupbw (__v8hi)
10774 __v8hi __builtin_arc_vupsbaw (__v8hi)
10775 __v8hi __builtin_arc_vupsbw (__v8hi)
10776 @end example
10778 The following take two @code{int} arguments and return no result:
10779 @example
10780 void __builtin_arc_vdirun (int, int)
10781 void __builtin_arc_vdorun (int, int)
10782 @end example
10784 The following take two @code{int} arguments and return no result.  The
10785 first argument must a 3-bit compile time constant indicating one of
10786 the DR0-DR7 DMA setup channels:
10787 @example
10788 void __builtin_arc_vdiwr (const int, int)
10789 void __builtin_arc_vdowr (const int, int)
10790 @end example
10792 The following take an @code{int} argument and return no result:
10793 @example
10794 void __builtin_arc_vendrec (int)
10795 void __builtin_arc_vrec (int)
10796 void __builtin_arc_vrecrun (int)
10797 void __builtin_arc_vrun (int)
10798 @end example
10800 The following take a @code{__v8hi} argument and two @code{int}
10801 arguments and return a @code{__v8hi} result.  The second argument must
10802 be a 3-bit compile time constants, indicating one the registers I0-I7,
10803 and the third argument must be an 8-bit compile time constant.
10805 @emph{Note:} Although the equivalent hardware instructions do not take
10806 an SIMD register as an operand, these builtins overwrite the relevant
10807 bits of the @code{__v8hi} register provided as the first argument with
10808 the value loaded from the @code{[Ib, u8]} location in the SDM.
10810 @example
10811 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10812 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10813 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10814 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10815 @end example
10817 The following take two @code{int} arguments and return a @code{__v8hi}
10818 result.  The first argument must be a 3-bit compile time constants,
10819 indicating one the registers I0-I7, and the second argument must be an
10820 8-bit compile time constant.
10822 @example
10823 __v8hi __builtin_arc_vld128 (const int, const int)
10824 __v8hi __builtin_arc_vld64w (const int, const int)
10825 @end example
10827 The following take a @code{__v8hi} argument and two @code{int}
10828 arguments and return no result.  The second argument must be a 3-bit
10829 compile time constants, indicating one the registers I0-I7, and the
10830 third argument must be an 8-bit compile time constant.
10832 @example
10833 void __builtin_arc_vst128 (__v8hi, const int, const int)
10834 void __builtin_arc_vst64 (__v8hi, const int, const int)
10835 @end example
10837 The following take a @code{__v8hi} argument and three @code{int}
10838 arguments and return no result.  The second argument must be a 3-bit
10839 compile-time constant, identifying the 16-bit sub-register to be
10840 stored, the third argument must be a 3-bit compile time constants,
10841 indicating one the registers I0-I7, and the fourth argument must be an
10842 8-bit compile time constant.
10844 @example
10845 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10846 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10847 @end example
10849 @node ARM iWMMXt Built-in Functions
10850 @subsection ARM iWMMXt Built-in Functions
10852 These built-in functions are available for the ARM family of
10853 processors when the @option{-mcpu=iwmmxt} switch is used:
10855 @smallexample
10856 typedef int v2si __attribute__ ((vector_size (8)));
10857 typedef short v4hi __attribute__ ((vector_size (8)));
10858 typedef char v8qi __attribute__ ((vector_size (8)));
10860 int __builtin_arm_getwcgr0 (void)
10861 void __builtin_arm_setwcgr0 (int)
10862 int __builtin_arm_getwcgr1 (void)
10863 void __builtin_arm_setwcgr1 (int)
10864 int __builtin_arm_getwcgr2 (void)
10865 void __builtin_arm_setwcgr2 (int)
10866 int __builtin_arm_getwcgr3 (void)
10867 void __builtin_arm_setwcgr3 (int)
10868 int __builtin_arm_textrmsb (v8qi, int)
10869 int __builtin_arm_textrmsh (v4hi, int)
10870 int __builtin_arm_textrmsw (v2si, int)
10871 int __builtin_arm_textrmub (v8qi, int)
10872 int __builtin_arm_textrmuh (v4hi, int)
10873 int __builtin_arm_textrmuw (v2si, int)
10874 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10875 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10876 v2si __builtin_arm_tinsrw (v2si, int, int)
10877 long long __builtin_arm_tmia (long long, int, int)
10878 long long __builtin_arm_tmiabb (long long, int, int)
10879 long long __builtin_arm_tmiabt (long long, int, int)
10880 long long __builtin_arm_tmiaph (long long, int, int)
10881 long long __builtin_arm_tmiatb (long long, int, int)
10882 long long __builtin_arm_tmiatt (long long, int, int)
10883 int __builtin_arm_tmovmskb (v8qi)
10884 int __builtin_arm_tmovmskh (v4hi)
10885 int __builtin_arm_tmovmskw (v2si)
10886 long long __builtin_arm_waccb (v8qi)
10887 long long __builtin_arm_wacch (v4hi)
10888 long long __builtin_arm_waccw (v2si)
10889 v8qi __builtin_arm_waddb (v8qi, v8qi)
10890 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10891 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10892 v4hi __builtin_arm_waddh (v4hi, v4hi)
10893 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10894 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10895 v2si __builtin_arm_waddw (v2si, v2si)
10896 v2si __builtin_arm_waddwss (v2si, v2si)
10897 v2si __builtin_arm_waddwus (v2si, v2si)
10898 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10899 long long __builtin_arm_wand(long long, long long)
10900 long long __builtin_arm_wandn (long long, long long)
10901 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10902 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10903 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10904 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10905 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10906 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10907 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10908 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10909 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10910 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10911 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10912 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10913 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10914 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10915 long long __builtin_arm_wmacsz (v4hi, v4hi)
10916 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10917 long long __builtin_arm_wmacuz (v4hi, v4hi)
10918 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10919 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10920 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10921 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10922 v2si __builtin_arm_wmaxsw (v2si, v2si)
10923 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10924 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10925 v2si __builtin_arm_wmaxuw (v2si, v2si)
10926 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10927 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10928 v2si __builtin_arm_wminsw (v2si, v2si)
10929 v8qi __builtin_arm_wminub (v8qi, v8qi)
10930 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10931 v2si __builtin_arm_wminuw (v2si, v2si)
10932 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10933 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10934 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10935 long long __builtin_arm_wor (long long, long long)
10936 v2si __builtin_arm_wpackdss (long long, long long)
10937 v2si __builtin_arm_wpackdus (long long, long long)
10938 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10939 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10940 v4hi __builtin_arm_wpackwss (v2si, v2si)
10941 v4hi __builtin_arm_wpackwus (v2si, v2si)
10942 long long __builtin_arm_wrord (long long, long long)
10943 long long __builtin_arm_wrordi (long long, int)
10944 v4hi __builtin_arm_wrorh (v4hi, long long)
10945 v4hi __builtin_arm_wrorhi (v4hi, int)
10946 v2si __builtin_arm_wrorw (v2si, long long)
10947 v2si __builtin_arm_wrorwi (v2si, int)
10948 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10949 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10950 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10951 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10952 v4hi __builtin_arm_wshufh (v4hi, int)
10953 long long __builtin_arm_wslld (long long, long long)
10954 long long __builtin_arm_wslldi (long long, int)
10955 v4hi __builtin_arm_wsllh (v4hi, long long)
10956 v4hi __builtin_arm_wsllhi (v4hi, int)
10957 v2si __builtin_arm_wsllw (v2si, long long)
10958 v2si __builtin_arm_wsllwi (v2si, int)
10959 long long __builtin_arm_wsrad (long long, long long)
10960 long long __builtin_arm_wsradi (long long, int)
10961 v4hi __builtin_arm_wsrah (v4hi, long long)
10962 v4hi __builtin_arm_wsrahi (v4hi, int)
10963 v2si __builtin_arm_wsraw (v2si, long long)
10964 v2si __builtin_arm_wsrawi (v2si, int)
10965 long long __builtin_arm_wsrld (long long, long long)
10966 long long __builtin_arm_wsrldi (long long, int)
10967 v4hi __builtin_arm_wsrlh (v4hi, long long)
10968 v4hi __builtin_arm_wsrlhi (v4hi, int)
10969 v2si __builtin_arm_wsrlw (v2si, long long)
10970 v2si __builtin_arm_wsrlwi (v2si, int)
10971 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10972 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10973 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10974 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10975 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10976 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10977 v2si __builtin_arm_wsubw (v2si, v2si)
10978 v2si __builtin_arm_wsubwss (v2si, v2si)
10979 v2si __builtin_arm_wsubwus (v2si, v2si)
10980 v4hi __builtin_arm_wunpckehsb (v8qi)
10981 v2si __builtin_arm_wunpckehsh (v4hi)
10982 long long __builtin_arm_wunpckehsw (v2si)
10983 v4hi __builtin_arm_wunpckehub (v8qi)
10984 v2si __builtin_arm_wunpckehuh (v4hi)
10985 long long __builtin_arm_wunpckehuw (v2si)
10986 v4hi __builtin_arm_wunpckelsb (v8qi)
10987 v2si __builtin_arm_wunpckelsh (v4hi)
10988 long long __builtin_arm_wunpckelsw (v2si)
10989 v4hi __builtin_arm_wunpckelub (v8qi)
10990 v2si __builtin_arm_wunpckeluh (v4hi)
10991 long long __builtin_arm_wunpckeluw (v2si)
10992 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10993 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10994 v2si __builtin_arm_wunpckihw (v2si, v2si)
10995 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10996 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10997 v2si __builtin_arm_wunpckilw (v2si, v2si)
10998 long long __builtin_arm_wxor (long long, long long)
10999 long long __builtin_arm_wzero ()
11000 @end smallexample
11003 @node ARM C Language Extensions (ACLE)
11004 @subsection ARM C Language Extensions (ACLE)
11006 GCC implements extensions for C as described in the ARM C Language
11007 Extensions (ACLE) specification, which can be found at
11008 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11010 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11011 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
11012 intrinsics can be found at
11013 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11014 The built-in intrinsics for the Advanced SIMD extension are available when
11015 NEON is enabled.
11017 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
11018 back ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM back end's
11019 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11020 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11021 intrinsics yet.
11023 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11024 availability of extensions.
11026 @node ARM Floating Point Status and Control Intrinsics
11027 @subsection ARM Floating Point Status and Control Intrinsics
11029 These built-in functions are available for the ARM family of
11030 processors with floating-point unit.
11032 @smallexample
11033 unsigned int __builtin_arm_get_fpscr ()
11034 void __builtin_arm_set_fpscr (unsigned int)
11035 @end smallexample
11037 @node AVR Built-in Functions
11038 @subsection AVR Built-in Functions
11040 For each built-in function for AVR, there is an equally named,
11041 uppercase built-in macro defined. That way users can easily query if
11042 or if not a specific built-in is implemented or not. For example, if
11043 @code{__builtin_avr_nop} is available the macro
11044 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
11046 The following built-in functions map to the respective machine
11047 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
11048 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
11049 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
11050 as library call if no hardware multiplier is available.
11052 @smallexample
11053 void __builtin_avr_nop (void)
11054 void __builtin_avr_sei (void)
11055 void __builtin_avr_cli (void)
11056 void __builtin_avr_sleep (void)
11057 void __builtin_avr_wdr (void)
11058 unsigned char __builtin_avr_swap (unsigned char)
11059 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
11060 int __builtin_avr_fmuls (char, char)
11061 int __builtin_avr_fmulsu (char, unsigned char)
11062 @end smallexample
11064 In order to delay execution for a specific number of cycles, GCC
11065 implements
11066 @smallexample
11067 void __builtin_avr_delay_cycles (unsigned long ticks)
11068 @end smallexample
11070 @noindent
11071 @code{ticks} is the number of ticks to delay execution. Note that this
11072 built-in does not take into account the effect of interrupts that
11073 might increase delay time. @code{ticks} must be a compile-time
11074 integer constant; delays with a variable number of cycles are not supported.
11076 @smallexample
11077 char __builtin_avr_flash_segment (const __memx void*)
11078 @end smallexample
11080 @noindent
11081 This built-in takes a byte address to the 24-bit
11082 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
11083 the number of the flash segment (the 64 KiB chunk) where the address
11084 points to.  Counting starts at @code{0}.
11085 If the address does not point to flash memory, return @code{-1}.
11087 @smallexample
11088 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11089 @end smallexample
11091 @noindent
11092 Insert bits from @var{bits} into @var{val} and return the resulting
11093 value. The nibbles of @var{map} determine how the insertion is
11094 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11095 @enumerate
11096 @item If @var{X} is @code{0xf},
11097 then the @var{n}-th bit of @var{val} is returned unaltered.
11099 @item If X is in the range 0@dots{}7,
11100 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11102 @item If X is in the range 8@dots{}@code{0xe},
11103 then the @var{n}-th result bit is undefined.
11104 @end enumerate
11106 @noindent
11107 One typical use case for this built-in is adjusting input and
11108 output values to non-contiguous port layouts. Some examples:
11110 @smallexample
11111 // same as val, bits is unused
11112 __builtin_avr_insert_bits (0xffffffff, bits, val)
11113 @end smallexample
11115 @smallexample
11116 // same as bits, val is unused
11117 __builtin_avr_insert_bits (0x76543210, bits, val)
11118 @end smallexample
11120 @smallexample
11121 // same as rotating bits by 4
11122 __builtin_avr_insert_bits (0x32107654, bits, 0)
11123 @end smallexample
11125 @smallexample
11126 // high nibble of result is the high nibble of val
11127 // low nibble of result is the low nibble of bits
11128 __builtin_avr_insert_bits (0xffff3210, bits, val)
11129 @end smallexample
11131 @smallexample
11132 // reverse the bit order of bits
11133 __builtin_avr_insert_bits (0x01234567, bits, 0)
11134 @end smallexample
11136 @node Blackfin Built-in Functions
11137 @subsection Blackfin Built-in Functions
11139 Currently, there are two Blackfin-specific built-in functions.  These are
11140 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11141 using inline assembly; by using these built-in functions the compiler can
11142 automatically add workarounds for hardware errata involving these
11143 instructions.  These functions are named as follows:
11145 @smallexample
11146 void __builtin_bfin_csync (void)
11147 void __builtin_bfin_ssync (void)
11148 @end smallexample
11150 @node FR-V Built-in Functions
11151 @subsection FR-V Built-in Functions
11153 GCC provides many FR-V-specific built-in functions.  In general,
11154 these functions are intended to be compatible with those described
11155 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11156 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11157 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11158 pointer rather than by value.
11160 Most of the functions are named after specific FR-V instructions.
11161 Such functions are said to be ``directly mapped'' and are summarized
11162 here in tabular form.
11164 @menu
11165 * Argument Types::
11166 * Directly-mapped Integer Functions::
11167 * Directly-mapped Media Functions::
11168 * Raw read/write Functions::
11169 * Other Built-in Functions::
11170 @end menu
11172 @node Argument Types
11173 @subsubsection Argument Types
11175 The arguments to the built-in functions can be divided into three groups:
11176 register numbers, compile-time constants and run-time values.  In order
11177 to make this classification clear at a glance, the arguments and return
11178 values are given the following pseudo types:
11180 @multitable @columnfractions .20 .30 .15 .35
11181 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11182 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11183 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11184 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11185 @item @code{uw2} @tab @code{unsigned long long} @tab No
11186 @tab an unsigned doubleword
11187 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11188 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11189 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11190 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11191 @end multitable
11193 These pseudo types are not defined by GCC, they are simply a notational
11194 convenience used in this manual.
11196 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11197 and @code{sw2} are evaluated at run time.  They correspond to
11198 register operands in the underlying FR-V instructions.
11200 @code{const} arguments represent immediate operands in the underlying
11201 FR-V instructions.  They must be compile-time constants.
11203 @code{acc} arguments are evaluated at compile time and specify the number
11204 of an accumulator register.  For example, an @code{acc} argument of 2
11205 selects the ACC2 register.
11207 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11208 number of an IACC register.  See @pxref{Other Built-in Functions}
11209 for more details.
11211 @node Directly-mapped Integer Functions
11212 @subsubsection Directly-Mapped Integer Functions
11214 The functions listed below map directly to FR-V I-type instructions.
11216 @multitable @columnfractions .45 .32 .23
11217 @item Function prototype @tab Example usage @tab Assembly output
11218 @item @code{sw1 __ADDSS (sw1, sw1)}
11219 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11220 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11221 @item @code{sw1 __SCAN (sw1, sw1)}
11222 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11223 @tab @code{SCAN @var{a},@var{b},@var{c}}
11224 @item @code{sw1 __SCUTSS (sw1)}
11225 @tab @code{@var{b} = __SCUTSS (@var{a})}
11226 @tab @code{SCUTSS @var{a},@var{b}}
11227 @item @code{sw1 __SLASS (sw1, sw1)}
11228 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11229 @tab @code{SLASS @var{a},@var{b},@var{c}}
11230 @item @code{void __SMASS (sw1, sw1)}
11231 @tab @code{__SMASS (@var{a}, @var{b})}
11232 @tab @code{SMASS @var{a},@var{b}}
11233 @item @code{void __SMSSS (sw1, sw1)}
11234 @tab @code{__SMSSS (@var{a}, @var{b})}
11235 @tab @code{SMSSS @var{a},@var{b}}
11236 @item @code{void __SMU (sw1, sw1)}
11237 @tab @code{__SMU (@var{a}, @var{b})}
11238 @tab @code{SMU @var{a},@var{b}}
11239 @item @code{sw2 __SMUL (sw1, sw1)}
11240 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11241 @tab @code{SMUL @var{a},@var{b},@var{c}}
11242 @item @code{sw1 __SUBSS (sw1, sw1)}
11243 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11244 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11245 @item @code{uw2 __UMUL (uw1, uw1)}
11246 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11247 @tab @code{UMUL @var{a},@var{b},@var{c}}
11248 @end multitable
11250 @node Directly-mapped Media Functions
11251 @subsubsection Directly-Mapped Media Functions
11253 The functions listed below map directly to FR-V M-type instructions.
11255 @multitable @columnfractions .45 .32 .23
11256 @item Function prototype @tab Example usage @tab Assembly output
11257 @item @code{uw1 __MABSHS (sw1)}
11258 @tab @code{@var{b} = __MABSHS (@var{a})}
11259 @tab @code{MABSHS @var{a},@var{b}}
11260 @item @code{void __MADDACCS (acc, acc)}
11261 @tab @code{__MADDACCS (@var{b}, @var{a})}
11262 @tab @code{MADDACCS @var{a},@var{b}}
11263 @item @code{sw1 __MADDHSS (sw1, sw1)}
11264 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11265 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11266 @item @code{uw1 __MADDHUS (uw1, uw1)}
11267 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11268 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11269 @item @code{uw1 __MAND (uw1, uw1)}
11270 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11271 @tab @code{MAND @var{a},@var{b},@var{c}}
11272 @item @code{void __MASACCS (acc, acc)}
11273 @tab @code{__MASACCS (@var{b}, @var{a})}
11274 @tab @code{MASACCS @var{a},@var{b}}
11275 @item @code{uw1 __MAVEH (uw1, uw1)}
11276 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11277 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11278 @item @code{uw2 __MBTOH (uw1)}
11279 @tab @code{@var{b} = __MBTOH (@var{a})}
11280 @tab @code{MBTOH @var{a},@var{b}}
11281 @item @code{void __MBTOHE (uw1 *, uw1)}
11282 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11283 @tab @code{MBTOHE @var{a},@var{b}}
11284 @item @code{void __MCLRACC (acc)}
11285 @tab @code{__MCLRACC (@var{a})}
11286 @tab @code{MCLRACC @var{a}}
11287 @item @code{void __MCLRACCA (void)}
11288 @tab @code{__MCLRACCA ()}
11289 @tab @code{MCLRACCA}
11290 @item @code{uw1 __Mcop1 (uw1, uw1)}
11291 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11292 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11293 @item @code{uw1 __Mcop2 (uw1, uw1)}
11294 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11295 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11296 @item @code{uw1 __MCPLHI (uw2, const)}
11297 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11298 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11299 @item @code{uw1 __MCPLI (uw2, const)}
11300 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11301 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11302 @item @code{void __MCPXIS (acc, sw1, sw1)}
11303 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11304 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11305 @item @code{void __MCPXIU (acc, uw1, uw1)}
11306 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11307 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11308 @item @code{void __MCPXRS (acc, sw1, sw1)}
11309 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11310 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11311 @item @code{void __MCPXRU (acc, uw1, uw1)}
11312 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11313 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11314 @item @code{uw1 __MCUT (acc, uw1)}
11315 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11316 @tab @code{MCUT @var{a},@var{b},@var{c}}
11317 @item @code{uw1 __MCUTSS (acc, sw1)}
11318 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11319 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11320 @item @code{void __MDADDACCS (acc, acc)}
11321 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11322 @tab @code{MDADDACCS @var{a},@var{b}}
11323 @item @code{void __MDASACCS (acc, acc)}
11324 @tab @code{__MDASACCS (@var{b}, @var{a})}
11325 @tab @code{MDASACCS @var{a},@var{b}}
11326 @item @code{uw2 __MDCUTSSI (acc, const)}
11327 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11328 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11329 @item @code{uw2 __MDPACKH (uw2, uw2)}
11330 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11331 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11332 @item @code{uw2 __MDROTLI (uw2, const)}
11333 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11334 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11335 @item @code{void __MDSUBACCS (acc, acc)}
11336 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11337 @tab @code{MDSUBACCS @var{a},@var{b}}
11338 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11339 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11340 @tab @code{MDUNPACKH @var{a},@var{b}}
11341 @item @code{uw2 __MEXPDHD (uw1, const)}
11342 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11343 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11344 @item @code{uw1 __MEXPDHW (uw1, const)}
11345 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11346 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11347 @item @code{uw1 __MHDSETH (uw1, const)}
11348 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11349 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11350 @item @code{sw1 __MHDSETS (const)}
11351 @tab @code{@var{b} = __MHDSETS (@var{a})}
11352 @tab @code{MHDSETS #@var{a},@var{b}}
11353 @item @code{uw1 __MHSETHIH (uw1, const)}
11354 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11355 @tab @code{MHSETHIH #@var{a},@var{b}}
11356 @item @code{sw1 __MHSETHIS (sw1, const)}
11357 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11358 @tab @code{MHSETHIS #@var{a},@var{b}}
11359 @item @code{uw1 __MHSETLOH (uw1, const)}
11360 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11361 @tab @code{MHSETLOH #@var{a},@var{b}}
11362 @item @code{sw1 __MHSETLOS (sw1, const)}
11363 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11364 @tab @code{MHSETLOS #@var{a},@var{b}}
11365 @item @code{uw1 __MHTOB (uw2)}
11366 @tab @code{@var{b} = __MHTOB (@var{a})}
11367 @tab @code{MHTOB @var{a},@var{b}}
11368 @item @code{void __MMACHS (acc, sw1, sw1)}
11369 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11370 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11371 @item @code{void __MMACHU (acc, uw1, uw1)}
11372 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11373 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11374 @item @code{void __MMRDHS (acc, sw1, sw1)}
11375 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11376 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11377 @item @code{void __MMRDHU (acc, uw1, uw1)}
11378 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11379 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11380 @item @code{void __MMULHS (acc, sw1, sw1)}
11381 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11382 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11383 @item @code{void __MMULHU (acc, uw1, uw1)}
11384 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11385 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11386 @item @code{void __MMULXHS (acc, sw1, sw1)}
11387 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11388 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11389 @item @code{void __MMULXHU (acc, uw1, uw1)}
11390 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11391 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11392 @item @code{uw1 __MNOT (uw1)}
11393 @tab @code{@var{b} = __MNOT (@var{a})}
11394 @tab @code{MNOT @var{a},@var{b}}
11395 @item @code{uw1 __MOR (uw1, uw1)}
11396 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11397 @tab @code{MOR @var{a},@var{b},@var{c}}
11398 @item @code{uw1 __MPACKH (uh, uh)}
11399 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11400 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11401 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11402 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11403 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11404 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11405 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11406 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11407 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11408 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11409 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11410 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11411 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11412 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11413 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11414 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11415 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11416 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11417 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11418 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11419 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11420 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11421 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11422 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11423 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11424 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11425 @item @code{void __MQMACHS (acc, sw2, sw2)}
11426 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11427 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11428 @item @code{void __MQMACHU (acc, uw2, uw2)}
11429 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11430 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11431 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11432 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11433 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11434 @item @code{void __MQMULHS (acc, sw2, sw2)}
11435 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11436 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11437 @item @code{void __MQMULHU (acc, uw2, uw2)}
11438 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11439 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11440 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11441 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11442 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11443 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11444 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11445 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11446 @item @code{sw2 __MQSATHS (sw2, sw2)}
11447 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11448 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11449 @item @code{uw2 __MQSLLHI (uw2, int)}
11450 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11451 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11452 @item @code{sw2 __MQSRAHI (sw2, int)}
11453 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11454 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11455 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11456 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11457 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11458 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11459 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11460 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11461 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11462 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11463 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11464 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11465 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11466 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11467 @item @code{uw1 __MRDACC (acc)}
11468 @tab @code{@var{b} = __MRDACC (@var{a})}
11469 @tab @code{MRDACC @var{a},@var{b}}
11470 @item @code{uw1 __MRDACCG (acc)}
11471 @tab @code{@var{b} = __MRDACCG (@var{a})}
11472 @tab @code{MRDACCG @var{a},@var{b}}
11473 @item @code{uw1 __MROTLI (uw1, const)}
11474 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11475 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11476 @item @code{uw1 __MROTRI (uw1, const)}
11477 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11478 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11479 @item @code{sw1 __MSATHS (sw1, sw1)}
11480 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11481 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11482 @item @code{uw1 __MSATHU (uw1, uw1)}
11483 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11484 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11485 @item @code{uw1 __MSLLHI (uw1, const)}
11486 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11487 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11488 @item @code{sw1 __MSRAHI (sw1, const)}
11489 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11490 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11491 @item @code{uw1 __MSRLHI (uw1, const)}
11492 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11493 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11494 @item @code{void __MSUBACCS (acc, acc)}
11495 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11496 @tab @code{MSUBACCS @var{a},@var{b}}
11497 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11498 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11499 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11500 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11501 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11502 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11503 @item @code{void __MTRAP (void)}
11504 @tab @code{__MTRAP ()}
11505 @tab @code{MTRAP}
11506 @item @code{uw2 __MUNPACKH (uw1)}
11507 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11508 @tab @code{MUNPACKH @var{a},@var{b}}
11509 @item @code{uw1 __MWCUT (uw2, uw1)}
11510 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11511 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11512 @item @code{void __MWTACC (acc, uw1)}
11513 @tab @code{__MWTACC (@var{b}, @var{a})}
11514 @tab @code{MWTACC @var{a},@var{b}}
11515 @item @code{void __MWTACCG (acc, uw1)}
11516 @tab @code{__MWTACCG (@var{b}, @var{a})}
11517 @tab @code{MWTACCG @var{a},@var{b}}
11518 @item @code{uw1 __MXOR (uw1, uw1)}
11519 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11520 @tab @code{MXOR @var{a},@var{b},@var{c}}
11521 @end multitable
11523 @node Raw read/write Functions
11524 @subsubsection Raw Read/Write Functions
11526 This sections describes built-in functions related to read and write
11527 instructions to access memory.  These functions generate
11528 @code{membar} instructions to flush the I/O load and stores where
11529 appropriate, as described in Fujitsu's manual described above.
11531 @table @code
11533 @item unsigned char __builtin_read8 (void *@var{data})
11534 @item unsigned short __builtin_read16 (void *@var{data})
11535 @item unsigned long __builtin_read32 (void *@var{data})
11536 @item unsigned long long __builtin_read64 (void *@var{data})
11538 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11539 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11540 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11541 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11542 @end table
11544 @node Other Built-in Functions
11545 @subsubsection Other Built-in Functions
11547 This section describes built-in functions that are not named after
11548 a specific FR-V instruction.
11550 @table @code
11551 @item sw2 __IACCreadll (iacc @var{reg})
11552 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11553 for future expansion and must be 0.
11555 @item sw1 __IACCreadl (iacc @var{reg})
11556 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11557 Other values of @var{reg} are rejected as invalid.
11559 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11560 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11561 is reserved for future expansion and must be 0.
11563 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11564 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11565 is 1.  Other values of @var{reg} are rejected as invalid.
11567 @item void __data_prefetch0 (const void *@var{x})
11568 Use the @code{dcpl} instruction to load the contents of address @var{x}
11569 into the data cache.
11571 @item void __data_prefetch (const void *@var{x})
11572 Use the @code{nldub} instruction to load the contents of address @var{x}
11573 into the data cache.  The instruction is issued in slot I1@.
11574 @end table
11576 @node MIPS DSP Built-in Functions
11577 @subsection MIPS DSP Built-in Functions
11579 The MIPS DSP Application-Specific Extension (ASE) includes new
11580 instructions that are designed to improve the performance of DSP and
11581 media applications.  It provides instructions that operate on packed
11582 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11584 GCC supports MIPS DSP operations using both the generic
11585 vector extensions (@pxref{Vector Extensions}) and a collection of
11586 MIPS-specific built-in functions.  Both kinds of support are
11587 enabled by the @option{-mdsp} command-line option.
11589 Revision 2 of the ASE was introduced in the second half of 2006.
11590 This revision adds extra instructions to the original ASE, but is
11591 otherwise backwards-compatible with it.  You can select revision 2
11592 using the command-line option @option{-mdspr2}; this option implies
11593 @option{-mdsp}.
11595 The SCOUNT and POS bits of the DSP control register are global.  The
11596 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11597 POS bits.  During optimization, the compiler does not delete these
11598 instructions and it does not delete calls to functions containing
11599 these instructions.
11601 At present, GCC only provides support for operations on 32-bit
11602 vectors.  The vector type associated with 8-bit integer data is
11603 usually called @code{v4i8}, the vector type associated with Q7
11604 is usually called @code{v4q7}, the vector type associated with 16-bit
11605 integer data is usually called @code{v2i16}, and the vector type
11606 associated with Q15 is usually called @code{v2q15}.  They can be
11607 defined in C as follows:
11609 @smallexample
11610 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11611 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11612 typedef short v2i16 __attribute__ ((vector_size(4)));
11613 typedef short v2q15 __attribute__ ((vector_size(4)));
11614 @end smallexample
11616 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11617 initialized in the same way as aggregates.  For example:
11619 @smallexample
11620 v4i8 a = @{1, 2, 3, 4@};
11621 v4i8 b;
11622 b = (v4i8) @{5, 6, 7, 8@};
11624 v2q15 c = @{0x0fcb, 0x3a75@};
11625 v2q15 d;
11626 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11627 @end smallexample
11629 @emph{Note:} The CPU's endianness determines the order in which values
11630 are packed.  On little-endian targets, the first value is the least
11631 significant and the last value is the most significant.  The opposite
11632 order applies to big-endian targets.  For example, the code above
11633 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11634 and @code{4} on big-endian targets.
11636 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11637 representation.  As shown in this example, the integer representation
11638 of a Q7 value can be obtained by multiplying the fractional value by
11639 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
11640 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
11641 @code{0x1.0p31}.
11643 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11644 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
11645 and @code{c} and @code{d} are @code{v2q15} values.
11647 @multitable @columnfractions .50 .50
11648 @item C code @tab MIPS instruction
11649 @item @code{a + b} @tab @code{addu.qb}
11650 @item @code{c + d} @tab @code{addq.ph}
11651 @item @code{a - b} @tab @code{subu.qb}
11652 @item @code{c - d} @tab @code{subq.ph}
11653 @end multitable
11655 The table below lists the @code{v2i16} operation for which
11656 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
11657 @code{v2i16} values.
11659 @multitable @columnfractions .50 .50
11660 @item C code @tab MIPS instruction
11661 @item @code{e * f} @tab @code{mul.ph}
11662 @end multitable
11664 It is easier to describe the DSP built-in functions if we first define
11665 the following types:
11667 @smallexample
11668 typedef int q31;
11669 typedef int i32;
11670 typedef unsigned int ui32;
11671 typedef long long a64;
11672 @end smallexample
11674 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11675 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11676 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
11677 @code{long long}, but we use @code{a64} to indicate values that are
11678 placed in one of the four DSP accumulators (@code{$ac0},
11679 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11681 Also, some built-in functions prefer or require immediate numbers as
11682 parameters, because the corresponding DSP instructions accept both immediate
11683 numbers and register operands, or accept immediate numbers only.  The
11684 immediate parameters are listed as follows.
11686 @smallexample
11687 imm0_3: 0 to 3.
11688 imm0_7: 0 to 7.
11689 imm0_15: 0 to 15.
11690 imm0_31: 0 to 31.
11691 imm0_63: 0 to 63.
11692 imm0_255: 0 to 255.
11693 imm_n32_31: -32 to 31.
11694 imm_n512_511: -512 to 511.
11695 @end smallexample
11697 The following built-in functions map directly to a particular MIPS DSP
11698 instruction.  Please refer to the architecture specification
11699 for details on what each instruction does.
11701 @smallexample
11702 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11703 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11704 q31 __builtin_mips_addq_s_w (q31, q31)
11705 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11706 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11707 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11708 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11709 q31 __builtin_mips_subq_s_w (q31, q31)
11710 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11711 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11712 i32 __builtin_mips_addsc (i32, i32)
11713 i32 __builtin_mips_addwc (i32, i32)
11714 i32 __builtin_mips_modsub (i32, i32)
11715 i32 __builtin_mips_raddu_w_qb (v4i8)
11716 v2q15 __builtin_mips_absq_s_ph (v2q15)
11717 q31 __builtin_mips_absq_s_w (q31)
11718 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11719 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11720 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11721 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11722 q31 __builtin_mips_preceq_w_phl (v2q15)
11723 q31 __builtin_mips_preceq_w_phr (v2q15)
11724 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11725 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11726 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11727 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11728 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11729 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11730 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11731 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11732 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11733 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11734 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11735 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11736 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11737 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11738 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11739 q31 __builtin_mips_shll_s_w (q31, i32)
11740 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11741 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11742 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11743 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11744 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11745 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11746 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11747 q31 __builtin_mips_shra_r_w (q31, i32)
11748 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11749 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11750 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11751 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11752 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11753 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11754 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11755 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11756 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11757 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11758 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11759 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11760 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11761 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11762 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11763 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11764 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11765 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11766 i32 __builtin_mips_bitrev (i32)
11767 i32 __builtin_mips_insv (i32, i32)
11768 v4i8 __builtin_mips_repl_qb (imm0_255)
11769 v4i8 __builtin_mips_repl_qb (i32)
11770 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11771 v2q15 __builtin_mips_repl_ph (i32)
11772 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11773 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11774 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11775 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11776 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11777 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11778 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11779 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11780 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11781 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11782 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11783 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11784 i32 __builtin_mips_extr_w (a64, imm0_31)
11785 i32 __builtin_mips_extr_w (a64, i32)
11786 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11787 i32 __builtin_mips_extr_s_h (a64, i32)
11788 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11789 i32 __builtin_mips_extr_rs_w (a64, i32)
11790 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11791 i32 __builtin_mips_extr_r_w (a64, i32)
11792 i32 __builtin_mips_extp (a64, imm0_31)
11793 i32 __builtin_mips_extp (a64, i32)
11794 i32 __builtin_mips_extpdp (a64, imm0_31)
11795 i32 __builtin_mips_extpdp (a64, i32)
11796 a64 __builtin_mips_shilo (a64, imm_n32_31)
11797 a64 __builtin_mips_shilo (a64, i32)
11798 a64 __builtin_mips_mthlip (a64, i32)
11799 void __builtin_mips_wrdsp (i32, imm0_63)
11800 i32 __builtin_mips_rddsp (imm0_63)
11801 i32 __builtin_mips_lbux (void *, i32)
11802 i32 __builtin_mips_lhx (void *, i32)
11803 i32 __builtin_mips_lwx (void *, i32)
11804 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11805 i32 __builtin_mips_bposge32 (void)
11806 a64 __builtin_mips_madd (a64, i32, i32);
11807 a64 __builtin_mips_maddu (a64, ui32, ui32);
11808 a64 __builtin_mips_msub (a64, i32, i32);
11809 a64 __builtin_mips_msubu (a64, ui32, ui32);
11810 a64 __builtin_mips_mult (i32, i32);
11811 a64 __builtin_mips_multu (ui32, ui32);
11812 @end smallexample
11814 The following built-in functions map directly to a particular MIPS DSP REV 2
11815 instruction.  Please refer to the architecture specification
11816 for details on what each instruction does.
11818 @smallexample
11819 v4q7 __builtin_mips_absq_s_qb (v4q7);
11820 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11821 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11822 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11823 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11824 i32 __builtin_mips_append (i32, i32, imm0_31);
11825 i32 __builtin_mips_balign (i32, i32, imm0_3);
11826 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11827 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11828 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11829 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11830 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11831 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11832 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11833 q31 __builtin_mips_mulq_rs_w (q31, q31);
11834 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11835 q31 __builtin_mips_mulq_s_w (q31, q31);
11836 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11837 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11838 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11839 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11840 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11841 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11842 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11843 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11844 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11845 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11846 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11847 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11848 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11849 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11850 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11851 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11852 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11853 q31 __builtin_mips_addqh_w (q31, q31);
11854 q31 __builtin_mips_addqh_r_w (q31, q31);
11855 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11856 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11857 q31 __builtin_mips_subqh_w (q31, q31);
11858 q31 __builtin_mips_subqh_r_w (q31, q31);
11859 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11860 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11861 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11862 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11863 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11864 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11865 @end smallexample
11868 @node MIPS Paired-Single Support
11869 @subsection MIPS Paired-Single Support
11871 The MIPS64 architecture includes a number of instructions that
11872 operate on pairs of single-precision floating-point values.
11873 Each pair is packed into a 64-bit floating-point register,
11874 with one element being designated the ``upper half'' and
11875 the other being designated the ``lower half''.
11877 GCC supports paired-single operations using both the generic
11878 vector extensions (@pxref{Vector Extensions}) and a collection of
11879 MIPS-specific built-in functions.  Both kinds of support are
11880 enabled by the @option{-mpaired-single} command-line option.
11882 The vector type associated with paired-single values is usually
11883 called @code{v2sf}.  It can be defined in C as follows:
11885 @smallexample
11886 typedef float v2sf __attribute__ ((vector_size (8)));
11887 @end smallexample
11889 @code{v2sf} values are initialized in the same way as aggregates.
11890 For example:
11892 @smallexample
11893 v2sf a = @{1.5, 9.1@};
11894 v2sf b;
11895 float e, f;
11896 b = (v2sf) @{e, f@};
11897 @end smallexample
11899 @emph{Note:} The CPU's endianness determines which value is stored in
11900 the upper half of a register and which value is stored in the lower half.
11901 On little-endian targets, the first value is the lower one and the second
11902 value is the upper one.  The opposite order applies to big-endian targets.
11903 For example, the code above sets the lower half of @code{a} to
11904 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11906 @node MIPS Loongson Built-in Functions
11907 @subsection MIPS Loongson Built-in Functions
11909 GCC provides intrinsics to access the SIMD instructions provided by the
11910 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
11911 available after inclusion of the @code{loongson.h} header file,
11912 operate on the following 64-bit vector types:
11914 @itemize
11915 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11916 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11917 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11918 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11919 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11920 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11921 @end itemize
11923 The intrinsics provided are listed below; each is named after the
11924 machine instruction to which it corresponds, with suffixes added as
11925 appropriate to distinguish intrinsics that expand to the same machine
11926 instruction yet have different argument types.  Refer to the architecture
11927 documentation for a description of the functionality of each
11928 instruction.
11930 @smallexample
11931 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11932 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11933 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11934 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11935 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11936 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11937 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11938 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11939 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11940 uint64_t paddd_u (uint64_t s, uint64_t t);
11941 int64_t paddd_s (int64_t s, int64_t t);
11942 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11943 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11944 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11945 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11946 uint64_t pandn_ud (uint64_t s, uint64_t t);
11947 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11948 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11949 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11950 int64_t pandn_sd (int64_t s, int64_t t);
11951 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11952 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11953 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11954 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11955 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11956 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11957 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11958 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11959 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11960 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11961 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11962 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11963 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11964 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11965 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11966 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11967 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11968 uint16x4_t pextrh_u (uint16x4_t s, int field);
11969 int16x4_t pextrh_s (int16x4_t s, int field);
11970 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11971 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11972 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11973 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11974 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11975 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11976 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11977 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11978 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11979 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11980 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11981 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11982 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11983 uint8x8_t pmovmskb_u (uint8x8_t s);
11984 int8x8_t pmovmskb_s (int8x8_t s);
11985 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11986 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11987 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11988 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11989 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11990 uint16x4_t biadd (uint8x8_t s);
11991 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11992 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11993 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11994 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11995 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11996 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11997 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11998 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11999 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12000 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12001 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12002 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12003 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12004 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12005 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12006 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12007 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12008 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12009 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12010 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12011 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12012 uint64_t psubd_u (uint64_t s, uint64_t t);
12013 int64_t psubd_s (int64_t s, int64_t t);
12014 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12015 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12016 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12017 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12018 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12019 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12020 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12021 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12022 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12023 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12024 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12025 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12026 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12027 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12028 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12029 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12030 @end smallexample
12032 @menu
12033 * Paired-Single Arithmetic::
12034 * Paired-Single Built-in Functions::
12035 * MIPS-3D Built-in Functions::
12036 @end menu
12038 @node Paired-Single Arithmetic
12039 @subsubsection Paired-Single Arithmetic
12041 The table below lists the @code{v2sf} operations for which hardware
12042 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12043 values and @code{x} is an integral value.
12045 @multitable @columnfractions .50 .50
12046 @item C code @tab MIPS instruction
12047 @item @code{a + b} @tab @code{add.ps}
12048 @item @code{a - b} @tab @code{sub.ps}
12049 @item @code{-a} @tab @code{neg.ps}
12050 @item @code{a * b} @tab @code{mul.ps}
12051 @item @code{a * b + c} @tab @code{madd.ps}
12052 @item @code{a * b - c} @tab @code{msub.ps}
12053 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12054 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12055 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12056 @end multitable
12058 Note that the multiply-accumulate instructions can be disabled
12059 using the command-line option @code{-mno-fused-madd}.
12061 @node Paired-Single Built-in Functions
12062 @subsubsection Paired-Single Built-in Functions
12064 The following paired-single functions map directly to a particular
12065 MIPS instruction.  Please refer to the architecture specification
12066 for details on what each instruction does.
12068 @table @code
12069 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12070 Pair lower lower (@code{pll.ps}).
12072 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12073 Pair upper lower (@code{pul.ps}).
12075 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12076 Pair lower upper (@code{plu.ps}).
12078 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12079 Pair upper upper (@code{puu.ps}).
12081 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12082 Convert pair to paired single (@code{cvt.ps.s}).
12084 @item float __builtin_mips_cvt_s_pl (v2sf)
12085 Convert pair lower to single (@code{cvt.s.pl}).
12087 @item float __builtin_mips_cvt_s_pu (v2sf)
12088 Convert pair upper to single (@code{cvt.s.pu}).
12090 @item v2sf __builtin_mips_abs_ps (v2sf)
12091 Absolute value (@code{abs.ps}).
12093 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12094 Align variable (@code{alnv.ps}).
12096 @emph{Note:} The value of the third parameter must be 0 or 4
12097 modulo 8, otherwise the result is unpredictable.  Please read the
12098 instruction description for details.
12099 @end table
12101 The following multi-instruction functions are also available.
12102 In each case, @var{cond} can be any of the 16 floating-point conditions:
12103 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12104 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12105 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12107 @table @code
12108 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12109 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12110 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12111 @code{movt.ps}/@code{movf.ps}).
12113 The @code{movt} functions return the value @var{x} computed by:
12115 @smallexample
12116 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12117 mov.ps @var{x},@var{c}
12118 movt.ps @var{x},@var{d},@var{cc}
12119 @end smallexample
12121 The @code{movf} functions are similar but use @code{movf.ps} instead
12122 of @code{movt.ps}.
12124 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12125 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12126 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12127 @code{bc1t}/@code{bc1f}).
12129 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12130 and return either the upper or lower half of the result.  For example:
12132 @smallexample
12133 v2sf a, b;
12134 if (__builtin_mips_upper_c_eq_ps (a, b))
12135   upper_halves_are_equal ();
12136 else
12137   upper_halves_are_unequal ();
12139 if (__builtin_mips_lower_c_eq_ps (a, b))
12140   lower_halves_are_equal ();
12141 else
12142   lower_halves_are_unequal ();
12143 @end smallexample
12144 @end table
12146 @node MIPS-3D Built-in Functions
12147 @subsubsection MIPS-3D Built-in Functions
12149 The MIPS-3D Application-Specific Extension (ASE) includes additional
12150 paired-single instructions that are designed to improve the performance
12151 of 3D graphics operations.  Support for these instructions is controlled
12152 by the @option{-mips3d} command-line option.
12154 The functions listed below map directly to a particular MIPS-3D
12155 instruction.  Please refer to the architecture specification for
12156 more details on what each instruction does.
12158 @table @code
12159 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12160 Reduction add (@code{addr.ps}).
12162 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12163 Reduction multiply (@code{mulr.ps}).
12165 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12166 Convert paired single to paired word (@code{cvt.pw.ps}).
12168 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12169 Convert paired word to paired single (@code{cvt.ps.pw}).
12171 @item float __builtin_mips_recip1_s (float)
12172 @itemx double __builtin_mips_recip1_d (double)
12173 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12174 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12176 @item float __builtin_mips_recip2_s (float, float)
12177 @itemx double __builtin_mips_recip2_d (double, double)
12178 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12179 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12181 @item float __builtin_mips_rsqrt1_s (float)
12182 @itemx double __builtin_mips_rsqrt1_d (double)
12183 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12184 Reduced-precision reciprocal square root (sequence step 1)
12185 (@code{rsqrt1.@var{fmt}}).
12187 @item float __builtin_mips_rsqrt2_s (float, float)
12188 @itemx double __builtin_mips_rsqrt2_d (double, double)
12189 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12190 Reduced-precision reciprocal square root (sequence step 2)
12191 (@code{rsqrt2.@var{fmt}}).
12192 @end table
12194 The following multi-instruction functions are also available.
12195 In each case, @var{cond} can be any of the 16 floating-point conditions:
12196 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12197 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12198 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12200 @table @code
12201 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12202 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12203 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12204 @code{bc1t}/@code{bc1f}).
12206 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12207 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12208 For example:
12210 @smallexample
12211 float a, b;
12212 if (__builtin_mips_cabs_eq_s (a, b))
12213   true ();
12214 else
12215   false ();
12216 @end smallexample
12218 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12219 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12220 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12221 @code{bc1t}/@code{bc1f}).
12223 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12224 and return either the upper or lower half of the result.  For example:
12226 @smallexample
12227 v2sf a, b;
12228 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12229   upper_halves_are_equal ();
12230 else
12231   upper_halves_are_unequal ();
12233 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12234   lower_halves_are_equal ();
12235 else
12236   lower_halves_are_unequal ();
12237 @end smallexample
12239 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12240 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12241 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12242 @code{movt.ps}/@code{movf.ps}).
12244 The @code{movt} functions return the value @var{x} computed by:
12246 @smallexample
12247 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12248 mov.ps @var{x},@var{c}
12249 movt.ps @var{x},@var{d},@var{cc}
12250 @end smallexample
12252 The @code{movf} functions are similar but use @code{movf.ps} instead
12253 of @code{movt.ps}.
12255 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12256 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12257 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12258 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12259 Comparison of two paired-single values
12260 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12261 @code{bc1any2t}/@code{bc1any2f}).
12263 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12264 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12265 result is true and the @code{all} forms return true if both results are true.
12266 For example:
12268 @smallexample
12269 v2sf a, b;
12270 if (__builtin_mips_any_c_eq_ps (a, b))
12271   one_is_true ();
12272 else
12273   both_are_false ();
12275 if (__builtin_mips_all_c_eq_ps (a, b))
12276   both_are_true ();
12277 else
12278   one_is_false ();
12279 @end smallexample
12281 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12282 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12283 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12284 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12285 Comparison of four paired-single values
12286 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12287 @code{bc1any4t}/@code{bc1any4f}).
12289 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12290 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12291 The @code{any} forms return true if any of the four results are true
12292 and the @code{all} forms return true if all four results are true.
12293 For example:
12295 @smallexample
12296 v2sf a, b, c, d;
12297 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12298   some_are_true ();
12299 else
12300   all_are_false ();
12302 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12303   all_are_true ();
12304 else
12305   some_are_false ();
12306 @end smallexample
12307 @end table
12309 @node Other MIPS Built-in Functions
12310 @subsection Other MIPS Built-in Functions
12312 GCC provides other MIPS-specific built-in functions:
12314 @table @code
12315 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12316 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12317 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12318 when this function is available.
12320 @item unsigned int __builtin_mips_get_fcsr (void)
12321 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
12322 Get and set the contents of the floating-point control and status register
12323 (FPU control register 31).  These functions are only available in hard-float
12324 code but can be called in both MIPS16 and non-MIPS16 contexts.
12326 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
12327 register except the condition codes, which GCC assumes are preserved.
12328 @end table
12330 @node MSP430 Built-in Functions
12331 @subsection MSP430 Built-in Functions
12333 GCC provides a couple of special builtin functions to aid in the
12334 writing of interrupt handlers in C.
12336 @table @code
12337 @item __bic_SR_register_on_exit (int @var{mask})
12338 This clears the indicated bits in the saved copy of the status register
12339 currently residing on the stack.  This only works inside interrupt
12340 handlers and the changes to the status register will only take affect
12341 once the handler returns.
12343 @item __bis_SR_register_on_exit (int @var{mask})
12344 This sets the indicated bits in the saved copy of the status register
12345 currently residing on the stack.  This only works inside interrupt
12346 handlers and the changes to the status register will only take affect
12347 once the handler returns.
12349 @item __delay_cycles (long long @var{cycles})
12350 This inserts an instruction sequence that takes exactly @var{cycles}
12351 cycles (between 0 and about 17E9) to complete.  The inserted sequence
12352 may use jumps, loops, or no-ops, and does not interfere with any other
12353 instructions.  Note that @var{cycles} must be a compile-time constant
12354 integer - that is, you must pass a number, not a variable that may be
12355 optimized to a constant later.  The number of cycles delayed by this
12356 builtin is exact.
12357 @end table
12359 @node NDS32 Built-in Functions
12360 @subsection NDS32 Built-in Functions
12362 These built-in functions are available for the NDS32 target:
12364 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12365 Insert an ISYNC instruction into the instruction stream where
12366 @var{addr} is an instruction address for serialization.
12367 @end deftypefn
12369 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12370 Insert an ISB instruction into the instruction stream.
12371 @end deftypefn
12373 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12374 Return the content of a system register which is mapped by @var{sr}.
12375 @end deftypefn
12377 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12378 Return the content of a user space register which is mapped by @var{usr}.
12379 @end deftypefn
12381 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12382 Move the @var{value} to a system register which is mapped by @var{sr}.
12383 @end deftypefn
12385 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12386 Move the @var{value} to a user space register which is mapped by @var{usr}.
12387 @end deftypefn
12389 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12390 Enable global interrupt.
12391 @end deftypefn
12393 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12394 Disable global interrupt.
12395 @end deftypefn
12397 @node picoChip Built-in Functions
12398 @subsection picoChip Built-in Functions
12400 GCC provides an interface to selected machine instructions from the
12401 picoChip instruction set.
12403 @table @code
12404 @item int __builtin_sbc (int @var{value})
12405 Sign bit count.  Return the number of consecutive bits in @var{value}
12406 that have the same value as the sign bit.  The result is the number of
12407 leading sign bits minus one, giving the number of redundant sign bits in
12408 @var{value}.
12410 @item int __builtin_byteswap (int @var{value})
12411 Byte swap.  Return the result of swapping the upper and lower bytes of
12412 @var{value}.
12414 @item int __builtin_brev (int @var{value})
12415 Bit reversal.  Return the result of reversing the bits in
12416 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12417 and so on.
12419 @item int __builtin_adds (int @var{x}, int @var{y})
12420 Saturating addition.  Return the result of adding @var{x} and @var{y},
12421 storing the value 32767 if the result overflows.
12423 @item int __builtin_subs (int @var{x}, int @var{y})
12424 Saturating subtraction.  Return the result of subtracting @var{y} from
12425 @var{x}, storing the value @minus{}32768 if the result overflows.
12427 @item void __builtin_halt (void)
12428 Halt.  The processor stops execution.  This built-in is useful for
12429 implementing assertions.
12431 @end table
12433 @node PowerPC Built-in Functions
12434 @subsection PowerPC Built-in Functions
12436 These built-in functions are available for the PowerPC family of
12437 processors:
12438 @smallexample
12439 float __builtin_recipdivf (float, float);
12440 float __builtin_rsqrtf (float);
12441 double __builtin_recipdiv (double, double);
12442 double __builtin_rsqrt (double);
12443 uint64_t __builtin_ppc_get_timebase ();
12444 unsigned long __builtin_ppc_mftb ();
12445 double __builtin_unpack_longdouble (long double, int);
12446 long double __builtin_pack_longdouble (double, double);
12447 @end smallexample
12449 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12450 @code{__builtin_rsqrtf} functions generate multiple instructions to
12451 implement the reciprocal sqrt functionality using reciprocal sqrt
12452 estimate instructions.
12454 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12455 functions generate multiple instructions to implement division using
12456 the reciprocal estimate instructions.
12458 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12459 functions generate instructions to read the Time Base Register.  The
12460 @code{__builtin_ppc_get_timebase} function may generate multiple
12461 instructions and always returns the 64 bits of the Time Base Register.
12462 The @code{__builtin_ppc_mftb} function always generates one instruction and
12463 returns the Time Base Register value as an unsigned long, throwing away
12464 the most significant word on 32-bit environments.
12466 The following built-in functions are available for the PowerPC family
12467 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
12468 or @option{-mpopcntd}):
12469 @smallexample
12470 long __builtin_bpermd (long, long);
12471 int __builtin_divwe (int, int);
12472 int __builtin_divweo (int, int);
12473 unsigned int __builtin_divweu (unsigned int, unsigned int);
12474 unsigned int __builtin_divweuo (unsigned int, unsigned int);
12475 long __builtin_divde (long, long);
12476 long __builtin_divdeo (long, long);
12477 unsigned long __builtin_divdeu (unsigned long, unsigned long);
12478 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
12479 unsigned int cdtbcd (unsigned int);
12480 unsigned int cbcdtd (unsigned int);
12481 unsigned int addg6s (unsigned int, unsigned int);
12482 @end smallexample
12484 The @code{__builtin_divde}, @code{__builtin_divdeo},
12485 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
12486 64-bit environment support ISA 2.06 or later.
12488 The following built-in functions are available for the PowerPC family
12489 of processors when hardware decimal floating point
12490 (@option{-mhard-dfp}) is available:
12491 @smallexample
12492 _Decimal64 __builtin_dxex (_Decimal64);
12493 _Decimal128 __builtin_dxexq (_Decimal128);
12494 _Decimal64 __builtin_ddedpd (int, _Decimal64);
12495 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
12496 _Decimal64 __builtin_denbcd (int, _Decimal64);
12497 _Decimal128 __builtin_denbcdq (int, _Decimal128);
12498 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
12499 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
12500 _Decimal64 __builtin_dscli (_Decimal64, int);
12501 _Decimal128 __builtin_dscliq (_Decimal128, int);
12502 _Decimal64 __builtin_dscri (_Decimal64, int);
12503 _Decimal128 __builtin_dscriq (_Decimal128, int);
12504 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
12505 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
12506 @end smallexample
12508 The following built-in functions are available for the PowerPC family
12509 of processors when the Vector Scalar (vsx) instruction set is
12510 available:
12511 @smallexample
12512 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
12513 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
12514                                                 unsigned long long);
12515 @end smallexample
12517 @node PowerPC AltiVec/VSX Built-in Functions
12518 @subsection PowerPC AltiVec Built-in Functions
12520 GCC provides an interface for the PowerPC family of processors to access
12521 the AltiVec operations described in Motorola's AltiVec Programming
12522 Interface Manual.  The interface is made available by including
12523 @code{<altivec.h>} and using @option{-maltivec} and
12524 @option{-mabi=altivec}.  The interface supports the following vector
12525 types.
12527 @smallexample
12528 vector unsigned char
12529 vector signed char
12530 vector bool char
12532 vector unsigned short
12533 vector signed short
12534 vector bool short
12535 vector pixel
12537 vector unsigned int
12538 vector signed int
12539 vector bool int
12540 vector float
12541 @end smallexample
12543 If @option{-mvsx} is used the following additional vector types are
12544 implemented.
12546 @smallexample
12547 vector unsigned long
12548 vector signed long
12549 vector double
12550 @end smallexample
12552 The long types are only implemented for 64-bit code generation, and
12553 the long type is only used in the floating point/integer conversion
12554 instructions.
12556 GCC's implementation of the high-level language interface available from
12557 C and C++ code differs from Motorola's documentation in several ways.
12559 @itemize @bullet
12561 @item
12562 A vector constant is a list of constant expressions within curly braces.
12564 @item
12565 A vector initializer requires no cast if the vector constant is of the
12566 same type as the variable it is initializing.
12568 @item
12569 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12570 vector type is the default signedness of the base type.  The default
12571 varies depending on the operating system, so a portable program should
12572 always specify the signedness.
12574 @item
12575 Compiling with @option{-maltivec} adds keywords @code{__vector},
12576 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
12577 @code{bool}.  When compiling ISO C, the context-sensitive substitution
12578 of the keywords @code{vector}, @code{pixel} and @code{bool} is
12579 disabled.  To use them, you must include @code{<altivec.h>} instead.
12581 @item
12582 GCC allows using a @code{typedef} name as the type specifier for a
12583 vector type.
12585 @item
12586 For C, overloaded functions are implemented with macros so the following
12587 does not work:
12589 @smallexample
12590   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12591 @end smallexample
12593 @noindent
12594 Since @code{vec_add} is a macro, the vector constant in the example
12595 is treated as four separate arguments.  Wrap the entire argument in
12596 parentheses for this to work.
12597 @end itemize
12599 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
12600 Internally, GCC uses built-in functions to achieve the functionality in
12601 the aforementioned header file, but they are not supported and are
12602 subject to change without notice.
12604 The following interfaces are supported for the generic and specific
12605 AltiVec operations and the AltiVec predicates.  In cases where there
12606 is a direct mapping between generic and specific operations, only the
12607 generic names are shown here, although the specific operations can also
12608 be used.
12610 Arguments that are documented as @code{const int} require literal
12611 integral values within the range required for that operation.
12613 @smallexample
12614 vector signed char vec_abs (vector signed char);
12615 vector signed short vec_abs (vector signed short);
12616 vector signed int vec_abs (vector signed int);
12617 vector float vec_abs (vector float);
12619 vector signed char vec_abss (vector signed char);
12620 vector signed short vec_abss (vector signed short);
12621 vector signed int vec_abss (vector signed int);
12623 vector signed char vec_add (vector bool char, vector signed char);
12624 vector signed char vec_add (vector signed char, vector bool char);
12625 vector signed char vec_add (vector signed char, vector signed char);
12626 vector unsigned char vec_add (vector bool char, vector unsigned char);
12627 vector unsigned char vec_add (vector unsigned char, vector bool char);
12628 vector unsigned char vec_add (vector unsigned char,
12629                               vector unsigned char);
12630 vector signed short vec_add (vector bool short, vector signed short);
12631 vector signed short vec_add (vector signed short, vector bool short);
12632 vector signed short vec_add (vector signed short, vector signed short);
12633 vector unsigned short vec_add (vector bool short,
12634                                vector unsigned short);
12635 vector unsigned short vec_add (vector unsigned short,
12636                                vector bool short);
12637 vector unsigned short vec_add (vector unsigned short,
12638                                vector unsigned short);
12639 vector signed int vec_add (vector bool int, vector signed int);
12640 vector signed int vec_add (vector signed int, vector bool int);
12641 vector signed int vec_add (vector signed int, vector signed int);
12642 vector unsigned int vec_add (vector bool int, vector unsigned int);
12643 vector unsigned int vec_add (vector unsigned int, vector bool int);
12644 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12645 vector float vec_add (vector float, vector float);
12647 vector float vec_vaddfp (vector float, vector float);
12649 vector signed int vec_vadduwm (vector bool int, vector signed int);
12650 vector signed int vec_vadduwm (vector signed int, vector bool int);
12651 vector signed int vec_vadduwm (vector signed int, vector signed int);
12652 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12653 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12654 vector unsigned int vec_vadduwm (vector unsigned int,
12655                                  vector unsigned int);
12657 vector signed short vec_vadduhm (vector bool short,
12658                                  vector signed short);
12659 vector signed short vec_vadduhm (vector signed short,
12660                                  vector bool short);
12661 vector signed short vec_vadduhm (vector signed short,
12662                                  vector signed short);
12663 vector unsigned short vec_vadduhm (vector bool short,
12664                                    vector unsigned short);
12665 vector unsigned short vec_vadduhm (vector unsigned short,
12666                                    vector bool short);
12667 vector unsigned short vec_vadduhm (vector unsigned short,
12668                                    vector unsigned short);
12670 vector signed char vec_vaddubm (vector bool char, vector signed char);
12671 vector signed char vec_vaddubm (vector signed char, vector bool char);
12672 vector signed char vec_vaddubm (vector signed char, vector signed char);
12673 vector unsigned char vec_vaddubm (vector bool char,
12674                                   vector unsigned char);
12675 vector unsigned char vec_vaddubm (vector unsigned char,
12676                                   vector bool char);
12677 vector unsigned char vec_vaddubm (vector unsigned char,
12678                                   vector unsigned char);
12680 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12682 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12683 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12684 vector unsigned char vec_adds (vector unsigned char,
12685                                vector unsigned char);
12686 vector signed char vec_adds (vector bool char, vector signed char);
12687 vector signed char vec_adds (vector signed char, vector bool char);
12688 vector signed char vec_adds (vector signed char, vector signed char);
12689 vector unsigned short vec_adds (vector bool short,
12690                                 vector unsigned short);
12691 vector unsigned short vec_adds (vector unsigned short,
12692                                 vector bool short);
12693 vector unsigned short vec_adds (vector unsigned short,
12694                                 vector unsigned short);
12695 vector signed short vec_adds (vector bool short, vector signed short);
12696 vector signed short vec_adds (vector signed short, vector bool short);
12697 vector signed short vec_adds (vector signed short, vector signed short);
12698 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12699 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12700 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12701 vector signed int vec_adds (vector bool int, vector signed int);
12702 vector signed int vec_adds (vector signed int, vector bool int);
12703 vector signed int vec_adds (vector signed int, vector signed int);
12705 vector signed int vec_vaddsws (vector bool int, vector signed int);
12706 vector signed int vec_vaddsws (vector signed int, vector bool int);
12707 vector signed int vec_vaddsws (vector signed int, vector signed int);
12709 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12710 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12711 vector unsigned int vec_vadduws (vector unsigned int,
12712                                  vector unsigned int);
12714 vector signed short vec_vaddshs (vector bool short,
12715                                  vector signed short);
12716 vector signed short vec_vaddshs (vector signed short,
12717                                  vector bool short);
12718 vector signed short vec_vaddshs (vector signed short,
12719                                  vector signed short);
12721 vector unsigned short vec_vadduhs (vector bool short,
12722                                    vector unsigned short);
12723 vector unsigned short vec_vadduhs (vector unsigned short,
12724                                    vector bool short);
12725 vector unsigned short vec_vadduhs (vector unsigned short,
12726                                    vector unsigned short);
12728 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12729 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12730 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12732 vector unsigned char vec_vaddubs (vector bool char,
12733                                   vector unsigned char);
12734 vector unsigned char vec_vaddubs (vector unsigned char,
12735                                   vector bool char);
12736 vector unsigned char vec_vaddubs (vector unsigned char,
12737                                   vector unsigned char);
12739 vector float vec_and (vector float, vector float);
12740 vector float vec_and (vector float, vector bool int);
12741 vector float vec_and (vector bool int, vector float);
12742 vector bool int vec_and (vector bool int, vector bool int);
12743 vector signed int vec_and (vector bool int, vector signed int);
12744 vector signed int vec_and (vector signed int, vector bool int);
12745 vector signed int vec_and (vector signed int, vector signed int);
12746 vector unsigned int vec_and (vector bool int, vector unsigned int);
12747 vector unsigned int vec_and (vector unsigned int, vector bool int);
12748 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12749 vector bool short vec_and (vector bool short, vector bool short);
12750 vector signed short vec_and (vector bool short, vector signed short);
12751 vector signed short vec_and (vector signed short, vector bool short);
12752 vector signed short vec_and (vector signed short, vector signed short);
12753 vector unsigned short vec_and (vector bool short,
12754                                vector unsigned short);
12755 vector unsigned short vec_and (vector unsigned short,
12756                                vector bool short);
12757 vector unsigned short vec_and (vector unsigned short,
12758                                vector unsigned short);
12759 vector signed char vec_and (vector bool char, vector signed char);
12760 vector bool char vec_and (vector bool char, vector bool char);
12761 vector signed char vec_and (vector signed char, vector bool char);
12762 vector signed char vec_and (vector signed char, vector signed char);
12763 vector unsigned char vec_and (vector bool char, vector unsigned char);
12764 vector unsigned char vec_and (vector unsigned char, vector bool char);
12765 vector unsigned char vec_and (vector unsigned char,
12766                               vector unsigned char);
12768 vector float vec_andc (vector float, vector float);
12769 vector float vec_andc (vector float, vector bool int);
12770 vector float vec_andc (vector bool int, vector float);
12771 vector bool int vec_andc (vector bool int, vector bool int);
12772 vector signed int vec_andc (vector bool int, vector signed int);
12773 vector signed int vec_andc (vector signed int, vector bool int);
12774 vector signed int vec_andc (vector signed int, vector signed int);
12775 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12776 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12777 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12778 vector bool short vec_andc (vector bool short, vector bool short);
12779 vector signed short vec_andc (vector bool short, vector signed short);
12780 vector signed short vec_andc (vector signed short, vector bool short);
12781 vector signed short vec_andc (vector signed short, vector signed short);
12782 vector unsigned short vec_andc (vector bool short,
12783                                 vector unsigned short);
12784 vector unsigned short vec_andc (vector unsigned short,
12785                                 vector bool short);
12786 vector unsigned short vec_andc (vector unsigned short,
12787                                 vector unsigned short);
12788 vector signed char vec_andc (vector bool char, vector signed char);
12789 vector bool char vec_andc (vector bool char, vector bool char);
12790 vector signed char vec_andc (vector signed char, vector bool char);
12791 vector signed char vec_andc (vector signed char, vector signed char);
12792 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12793 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12794 vector unsigned char vec_andc (vector unsigned char,
12795                                vector unsigned char);
12797 vector unsigned char vec_avg (vector unsigned char,
12798                               vector unsigned char);
12799 vector signed char vec_avg (vector signed char, vector signed char);
12800 vector unsigned short vec_avg (vector unsigned short,
12801                                vector unsigned short);
12802 vector signed short vec_avg (vector signed short, vector signed short);
12803 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12804 vector signed int vec_avg (vector signed int, vector signed int);
12806 vector signed int vec_vavgsw (vector signed int, vector signed int);
12808 vector unsigned int vec_vavguw (vector unsigned int,
12809                                 vector unsigned int);
12811 vector signed short vec_vavgsh (vector signed short,
12812                                 vector signed short);
12814 vector unsigned short vec_vavguh (vector unsigned short,
12815                                   vector unsigned short);
12817 vector signed char vec_vavgsb (vector signed char, vector signed char);
12819 vector unsigned char vec_vavgub (vector unsigned char,
12820                                  vector unsigned char);
12822 vector float vec_copysign (vector float);
12824 vector float vec_ceil (vector float);
12826 vector signed int vec_cmpb (vector float, vector float);
12828 vector bool char vec_cmpeq (vector signed char, vector signed char);
12829 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12830 vector bool short vec_cmpeq (vector signed short, vector signed short);
12831 vector bool short vec_cmpeq (vector unsigned short,
12832                              vector unsigned short);
12833 vector bool int vec_cmpeq (vector signed int, vector signed int);
12834 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12835 vector bool int vec_cmpeq (vector float, vector float);
12837 vector bool int vec_vcmpeqfp (vector float, vector float);
12839 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12840 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12842 vector bool short vec_vcmpequh (vector signed short,
12843                                 vector signed short);
12844 vector bool short vec_vcmpequh (vector unsigned short,
12845                                 vector unsigned short);
12847 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12848 vector bool char vec_vcmpequb (vector unsigned char,
12849                                vector unsigned char);
12851 vector bool int vec_cmpge (vector float, vector float);
12853 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12854 vector bool char vec_cmpgt (vector signed char, vector signed char);
12855 vector bool short vec_cmpgt (vector unsigned short,
12856                              vector unsigned short);
12857 vector bool short vec_cmpgt (vector signed short, vector signed short);
12858 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12859 vector bool int vec_cmpgt (vector signed int, vector signed int);
12860 vector bool int vec_cmpgt (vector float, vector float);
12862 vector bool int vec_vcmpgtfp (vector float, vector float);
12864 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12866 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12868 vector bool short vec_vcmpgtsh (vector signed short,
12869                                 vector signed short);
12871 vector bool short vec_vcmpgtuh (vector unsigned short,
12872                                 vector unsigned short);
12874 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12876 vector bool char vec_vcmpgtub (vector unsigned char,
12877                                vector unsigned char);
12879 vector bool int vec_cmple (vector float, vector float);
12881 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12882 vector bool char vec_cmplt (vector signed char, vector signed char);
12883 vector bool short vec_cmplt (vector unsigned short,
12884                              vector unsigned short);
12885 vector bool short vec_cmplt (vector signed short, vector signed short);
12886 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12887 vector bool int vec_cmplt (vector signed int, vector signed int);
12888 vector bool int vec_cmplt (vector float, vector float);
12890 vector float vec_cpsgn (vector float, vector float);
12892 vector float vec_ctf (vector unsigned int, const int);
12893 vector float vec_ctf (vector signed int, const int);
12894 vector double vec_ctf (vector unsigned long, const int);
12895 vector double vec_ctf (vector signed long, const int);
12897 vector float vec_vcfsx (vector signed int, const int);
12899 vector float vec_vcfux (vector unsigned int, const int);
12901 vector signed int vec_cts (vector float, const int);
12902 vector signed long vec_cts (vector double, const int);
12904 vector unsigned int vec_ctu (vector float, const int);
12905 vector unsigned long vec_ctu (vector double, const int);
12907 void vec_dss (const int);
12909 void vec_dssall (void);
12911 void vec_dst (const vector unsigned char *, int, const int);
12912 void vec_dst (const vector signed char *, int, const int);
12913 void vec_dst (const vector bool char *, int, const int);
12914 void vec_dst (const vector unsigned short *, int, const int);
12915 void vec_dst (const vector signed short *, int, const int);
12916 void vec_dst (const vector bool short *, int, const int);
12917 void vec_dst (const vector pixel *, int, const int);
12918 void vec_dst (const vector unsigned int *, int, const int);
12919 void vec_dst (const vector signed int *, int, const int);
12920 void vec_dst (const vector bool int *, int, const int);
12921 void vec_dst (const vector float *, int, const int);
12922 void vec_dst (const unsigned char *, int, const int);
12923 void vec_dst (const signed char *, int, const int);
12924 void vec_dst (const unsigned short *, int, const int);
12925 void vec_dst (const short *, int, const int);
12926 void vec_dst (const unsigned int *, int, const int);
12927 void vec_dst (const int *, int, const int);
12928 void vec_dst (const unsigned long *, int, const int);
12929 void vec_dst (const long *, int, const int);
12930 void vec_dst (const float *, int, const int);
12932 void vec_dstst (const vector unsigned char *, int, const int);
12933 void vec_dstst (const vector signed char *, int, const int);
12934 void vec_dstst (const vector bool char *, int, const int);
12935 void vec_dstst (const vector unsigned short *, int, const int);
12936 void vec_dstst (const vector signed short *, int, const int);
12937 void vec_dstst (const vector bool short *, int, const int);
12938 void vec_dstst (const vector pixel *, int, const int);
12939 void vec_dstst (const vector unsigned int *, int, const int);
12940 void vec_dstst (const vector signed int *, int, const int);
12941 void vec_dstst (const vector bool int *, int, const int);
12942 void vec_dstst (const vector float *, int, const int);
12943 void vec_dstst (const unsigned char *, int, const int);
12944 void vec_dstst (const signed char *, int, const int);
12945 void vec_dstst (const unsigned short *, int, const int);
12946 void vec_dstst (const short *, int, const int);
12947 void vec_dstst (const unsigned int *, int, const int);
12948 void vec_dstst (const int *, int, const int);
12949 void vec_dstst (const unsigned long *, int, const int);
12950 void vec_dstst (const long *, int, const int);
12951 void vec_dstst (const float *, int, const int);
12953 void vec_dststt (const vector unsigned char *, int, const int);
12954 void vec_dststt (const vector signed char *, int, const int);
12955 void vec_dststt (const vector bool char *, int, const int);
12956 void vec_dststt (const vector unsigned short *, int, const int);
12957 void vec_dststt (const vector signed short *, int, const int);
12958 void vec_dststt (const vector bool short *, int, const int);
12959 void vec_dststt (const vector pixel *, int, const int);
12960 void vec_dststt (const vector unsigned int *, int, const int);
12961 void vec_dststt (const vector signed int *, int, const int);
12962 void vec_dststt (const vector bool int *, int, const int);
12963 void vec_dststt (const vector float *, int, const int);
12964 void vec_dststt (const unsigned char *, int, const int);
12965 void vec_dststt (const signed char *, int, const int);
12966 void vec_dststt (const unsigned short *, int, const int);
12967 void vec_dststt (const short *, int, const int);
12968 void vec_dststt (const unsigned int *, int, const int);
12969 void vec_dststt (const int *, int, const int);
12970 void vec_dststt (const unsigned long *, int, const int);
12971 void vec_dststt (const long *, int, const int);
12972 void vec_dststt (const float *, int, const int);
12974 void vec_dstt (const vector unsigned char *, int, const int);
12975 void vec_dstt (const vector signed char *, int, const int);
12976 void vec_dstt (const vector bool char *, int, const int);
12977 void vec_dstt (const vector unsigned short *, int, const int);
12978 void vec_dstt (const vector signed short *, int, const int);
12979 void vec_dstt (const vector bool short *, int, const int);
12980 void vec_dstt (const vector pixel *, int, const int);
12981 void vec_dstt (const vector unsigned int *, int, const int);
12982 void vec_dstt (const vector signed int *, int, const int);
12983 void vec_dstt (const vector bool int *, int, const int);
12984 void vec_dstt (const vector float *, int, const int);
12985 void vec_dstt (const unsigned char *, int, const int);
12986 void vec_dstt (const signed char *, int, const int);
12987 void vec_dstt (const unsigned short *, int, const int);
12988 void vec_dstt (const short *, int, const int);
12989 void vec_dstt (const unsigned int *, int, const int);
12990 void vec_dstt (const int *, int, const int);
12991 void vec_dstt (const unsigned long *, int, const int);
12992 void vec_dstt (const long *, int, const int);
12993 void vec_dstt (const float *, int, const int);
12995 vector float vec_expte (vector float);
12997 vector float vec_floor (vector float);
12999 vector float vec_ld (int, const vector float *);
13000 vector float vec_ld (int, const float *);
13001 vector bool int vec_ld (int, const vector bool int *);
13002 vector signed int vec_ld (int, const vector signed int *);
13003 vector signed int vec_ld (int, const int *);
13004 vector signed int vec_ld (int, const long *);
13005 vector unsigned int vec_ld (int, const vector unsigned int *);
13006 vector unsigned int vec_ld (int, const unsigned int *);
13007 vector unsigned int vec_ld (int, const unsigned long *);
13008 vector bool short vec_ld (int, const vector bool short *);
13009 vector pixel vec_ld (int, const vector pixel *);
13010 vector signed short vec_ld (int, const vector signed short *);
13011 vector signed short vec_ld (int, const short *);
13012 vector unsigned short vec_ld (int, const vector unsigned short *);
13013 vector unsigned short vec_ld (int, const unsigned short *);
13014 vector bool char vec_ld (int, const vector bool char *);
13015 vector signed char vec_ld (int, const vector signed char *);
13016 vector signed char vec_ld (int, const signed char *);
13017 vector unsigned char vec_ld (int, const vector unsigned char *);
13018 vector unsigned char vec_ld (int, const unsigned char *);
13020 vector signed char vec_lde (int, const signed char *);
13021 vector unsigned char vec_lde (int, const unsigned char *);
13022 vector signed short vec_lde (int, const short *);
13023 vector unsigned short vec_lde (int, const unsigned short *);
13024 vector float vec_lde (int, const float *);
13025 vector signed int vec_lde (int, const int *);
13026 vector unsigned int vec_lde (int, const unsigned int *);
13027 vector signed int vec_lde (int, const long *);
13028 vector unsigned int vec_lde (int, const unsigned long *);
13030 vector float vec_lvewx (int, float *);
13031 vector signed int vec_lvewx (int, int *);
13032 vector unsigned int vec_lvewx (int, unsigned int *);
13033 vector signed int vec_lvewx (int, long *);
13034 vector unsigned int vec_lvewx (int, unsigned long *);
13036 vector signed short vec_lvehx (int, short *);
13037 vector unsigned short vec_lvehx (int, unsigned short *);
13039 vector signed char vec_lvebx (int, char *);
13040 vector unsigned char vec_lvebx (int, unsigned char *);
13042 vector float vec_ldl (int, const vector float *);
13043 vector float vec_ldl (int, const float *);
13044 vector bool int vec_ldl (int, const vector bool int *);
13045 vector signed int vec_ldl (int, const vector signed int *);
13046 vector signed int vec_ldl (int, const int *);
13047 vector signed int vec_ldl (int, const long *);
13048 vector unsigned int vec_ldl (int, const vector unsigned int *);
13049 vector unsigned int vec_ldl (int, const unsigned int *);
13050 vector unsigned int vec_ldl (int, const unsigned long *);
13051 vector bool short vec_ldl (int, const vector bool short *);
13052 vector pixel vec_ldl (int, const vector pixel *);
13053 vector signed short vec_ldl (int, const vector signed short *);
13054 vector signed short vec_ldl (int, const short *);
13055 vector unsigned short vec_ldl (int, const vector unsigned short *);
13056 vector unsigned short vec_ldl (int, const unsigned short *);
13057 vector bool char vec_ldl (int, const vector bool char *);
13058 vector signed char vec_ldl (int, const vector signed char *);
13059 vector signed char vec_ldl (int, const signed char *);
13060 vector unsigned char vec_ldl (int, const vector unsigned char *);
13061 vector unsigned char vec_ldl (int, const unsigned char *);
13063 vector float vec_loge (vector float);
13065 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13066 vector unsigned char vec_lvsl (int, const volatile signed char *);
13067 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13068 vector unsigned char vec_lvsl (int, const volatile short *);
13069 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13070 vector unsigned char vec_lvsl (int, const volatile int *);
13071 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13072 vector unsigned char vec_lvsl (int, const volatile long *);
13073 vector unsigned char vec_lvsl (int, const volatile float *);
13075 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13076 vector unsigned char vec_lvsr (int, const volatile signed char *);
13077 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13078 vector unsigned char vec_lvsr (int, const volatile short *);
13079 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13080 vector unsigned char vec_lvsr (int, const volatile int *);
13081 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13082 vector unsigned char vec_lvsr (int, const volatile long *);
13083 vector unsigned char vec_lvsr (int, const volatile float *);
13085 vector float vec_madd (vector float, vector float, vector float);
13087 vector signed short vec_madds (vector signed short,
13088                                vector signed short,
13089                                vector signed short);
13091 vector unsigned char vec_max (vector bool char, vector unsigned char);
13092 vector unsigned char vec_max (vector unsigned char, vector bool char);
13093 vector unsigned char vec_max (vector unsigned char,
13094                               vector unsigned char);
13095 vector signed char vec_max (vector bool char, vector signed char);
13096 vector signed char vec_max (vector signed char, vector bool char);
13097 vector signed char vec_max (vector signed char, vector signed char);
13098 vector unsigned short vec_max (vector bool short,
13099                                vector unsigned short);
13100 vector unsigned short vec_max (vector unsigned short,
13101                                vector bool short);
13102 vector unsigned short vec_max (vector unsigned short,
13103                                vector unsigned short);
13104 vector signed short vec_max (vector bool short, vector signed short);
13105 vector signed short vec_max (vector signed short, vector bool short);
13106 vector signed short vec_max (vector signed short, vector signed short);
13107 vector unsigned int vec_max (vector bool int, vector unsigned int);
13108 vector unsigned int vec_max (vector unsigned int, vector bool int);
13109 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13110 vector signed int vec_max (vector bool int, vector signed int);
13111 vector signed int vec_max (vector signed int, vector bool int);
13112 vector signed int vec_max (vector signed int, vector signed int);
13113 vector float vec_max (vector float, vector float);
13115 vector float vec_vmaxfp (vector float, vector float);
13117 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13118 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13119 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13121 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13122 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13123 vector unsigned int vec_vmaxuw (vector unsigned int,
13124                                 vector unsigned int);
13126 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13127 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13128 vector signed short vec_vmaxsh (vector signed short,
13129                                 vector signed short);
13131 vector unsigned short vec_vmaxuh (vector bool short,
13132                                   vector unsigned short);
13133 vector unsigned short vec_vmaxuh (vector unsigned short,
13134                                   vector bool short);
13135 vector unsigned short vec_vmaxuh (vector unsigned short,
13136                                   vector unsigned short);
13138 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13139 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13140 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13142 vector unsigned char vec_vmaxub (vector bool char,
13143                                  vector unsigned char);
13144 vector unsigned char vec_vmaxub (vector unsigned char,
13145                                  vector bool char);
13146 vector unsigned char vec_vmaxub (vector unsigned char,
13147                                  vector unsigned char);
13149 vector bool char vec_mergeh (vector bool char, vector bool char);
13150 vector signed char vec_mergeh (vector signed char, vector signed char);
13151 vector unsigned char vec_mergeh (vector unsigned char,
13152                                  vector unsigned char);
13153 vector bool short vec_mergeh (vector bool short, vector bool short);
13154 vector pixel vec_mergeh (vector pixel, vector pixel);
13155 vector signed short vec_mergeh (vector signed short,
13156                                 vector signed short);
13157 vector unsigned short vec_mergeh (vector unsigned short,
13158                                   vector unsigned short);
13159 vector float vec_mergeh (vector float, vector float);
13160 vector bool int vec_mergeh (vector bool int, vector bool int);
13161 vector signed int vec_mergeh (vector signed int, vector signed int);
13162 vector unsigned int vec_mergeh (vector unsigned int,
13163                                 vector unsigned int);
13165 vector float vec_vmrghw (vector float, vector float);
13166 vector bool int vec_vmrghw (vector bool int, vector bool int);
13167 vector signed int vec_vmrghw (vector signed int, vector signed int);
13168 vector unsigned int vec_vmrghw (vector unsigned int,
13169                                 vector unsigned int);
13171 vector bool short vec_vmrghh (vector bool short, vector bool short);
13172 vector signed short vec_vmrghh (vector signed short,
13173                                 vector signed short);
13174 vector unsigned short vec_vmrghh (vector unsigned short,
13175                                   vector unsigned short);
13176 vector pixel vec_vmrghh (vector pixel, vector pixel);
13178 vector bool char vec_vmrghb (vector bool char, vector bool char);
13179 vector signed char vec_vmrghb (vector signed char, vector signed char);
13180 vector unsigned char vec_vmrghb (vector unsigned char,
13181                                  vector unsigned char);
13183 vector bool char vec_mergel (vector bool char, vector bool char);
13184 vector signed char vec_mergel (vector signed char, vector signed char);
13185 vector unsigned char vec_mergel (vector unsigned char,
13186                                  vector unsigned char);
13187 vector bool short vec_mergel (vector bool short, vector bool short);
13188 vector pixel vec_mergel (vector pixel, vector pixel);
13189 vector signed short vec_mergel (vector signed short,
13190                                 vector signed short);
13191 vector unsigned short vec_mergel (vector unsigned short,
13192                                   vector unsigned short);
13193 vector float vec_mergel (vector float, vector float);
13194 vector bool int vec_mergel (vector bool int, vector bool int);
13195 vector signed int vec_mergel (vector signed int, vector signed int);
13196 vector unsigned int vec_mergel (vector unsigned int,
13197                                 vector unsigned int);
13199 vector float vec_vmrglw (vector float, vector float);
13200 vector signed int vec_vmrglw (vector signed int, vector signed int);
13201 vector unsigned int vec_vmrglw (vector unsigned int,
13202                                 vector unsigned int);
13203 vector bool int vec_vmrglw (vector bool int, vector bool int);
13205 vector bool short vec_vmrglh (vector bool short, vector bool short);
13206 vector signed short vec_vmrglh (vector signed short,
13207                                 vector signed short);
13208 vector unsigned short vec_vmrglh (vector unsigned short,
13209                                   vector unsigned short);
13210 vector pixel vec_vmrglh (vector pixel, vector pixel);
13212 vector bool char vec_vmrglb (vector bool char, vector bool char);
13213 vector signed char vec_vmrglb (vector signed char, vector signed char);
13214 vector unsigned char vec_vmrglb (vector unsigned char,
13215                                  vector unsigned char);
13217 vector unsigned short vec_mfvscr (void);
13219 vector unsigned char vec_min (vector bool char, vector unsigned char);
13220 vector unsigned char vec_min (vector unsigned char, vector bool char);
13221 vector unsigned char vec_min (vector unsigned char,
13222                               vector unsigned char);
13223 vector signed char vec_min (vector bool char, vector signed char);
13224 vector signed char vec_min (vector signed char, vector bool char);
13225 vector signed char vec_min (vector signed char, vector signed char);
13226 vector unsigned short vec_min (vector bool short,
13227                                vector unsigned short);
13228 vector unsigned short vec_min (vector unsigned short,
13229                                vector bool short);
13230 vector unsigned short vec_min (vector unsigned short,
13231                                vector unsigned short);
13232 vector signed short vec_min (vector bool short, vector signed short);
13233 vector signed short vec_min (vector signed short, vector bool short);
13234 vector signed short vec_min (vector signed short, vector signed short);
13235 vector unsigned int vec_min (vector bool int, vector unsigned int);
13236 vector unsigned int vec_min (vector unsigned int, vector bool int);
13237 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13238 vector signed int vec_min (vector bool int, vector signed int);
13239 vector signed int vec_min (vector signed int, vector bool int);
13240 vector signed int vec_min (vector signed int, vector signed int);
13241 vector float vec_min (vector float, vector float);
13243 vector float vec_vminfp (vector float, vector float);
13245 vector signed int vec_vminsw (vector bool int, vector signed int);
13246 vector signed int vec_vminsw (vector signed int, vector bool int);
13247 vector signed int vec_vminsw (vector signed int, vector signed int);
13249 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13250 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13251 vector unsigned int vec_vminuw (vector unsigned int,
13252                                 vector unsigned int);
13254 vector signed short vec_vminsh (vector bool short, vector signed short);
13255 vector signed short vec_vminsh (vector signed short, vector bool short);
13256 vector signed short vec_vminsh (vector signed short,
13257                                 vector signed short);
13259 vector unsigned short vec_vminuh (vector bool short,
13260                                   vector unsigned short);
13261 vector unsigned short vec_vminuh (vector unsigned short,
13262                                   vector bool short);
13263 vector unsigned short vec_vminuh (vector unsigned short,
13264                                   vector unsigned short);
13266 vector signed char vec_vminsb (vector bool char, vector signed char);
13267 vector signed char vec_vminsb (vector signed char, vector bool char);
13268 vector signed char vec_vminsb (vector signed char, vector signed char);
13270 vector unsigned char vec_vminub (vector bool char,
13271                                  vector unsigned char);
13272 vector unsigned char vec_vminub (vector unsigned char,
13273                                  vector bool char);
13274 vector unsigned char vec_vminub (vector unsigned char,
13275                                  vector unsigned char);
13277 vector signed short vec_mladd (vector signed short,
13278                                vector signed short,
13279                                vector signed short);
13280 vector signed short vec_mladd (vector signed short,
13281                                vector unsigned short,
13282                                vector unsigned short);
13283 vector signed short vec_mladd (vector unsigned short,
13284                                vector signed short,
13285                                vector signed short);
13286 vector unsigned short vec_mladd (vector unsigned short,
13287                                  vector unsigned short,
13288                                  vector unsigned short);
13290 vector signed short vec_mradds (vector signed short,
13291                                 vector signed short,
13292                                 vector signed short);
13294 vector unsigned int vec_msum (vector unsigned char,
13295                               vector unsigned char,
13296                               vector unsigned int);
13297 vector signed int vec_msum (vector signed char,
13298                             vector unsigned char,
13299                             vector signed int);
13300 vector unsigned int vec_msum (vector unsigned short,
13301                               vector unsigned short,
13302                               vector unsigned int);
13303 vector signed int vec_msum (vector signed short,
13304                             vector signed short,
13305                             vector signed int);
13307 vector signed int vec_vmsumshm (vector signed short,
13308                                 vector signed short,
13309                                 vector signed int);
13311 vector unsigned int vec_vmsumuhm (vector unsigned short,
13312                                   vector unsigned short,
13313                                   vector unsigned int);
13315 vector signed int vec_vmsummbm (vector signed char,
13316                                 vector unsigned char,
13317                                 vector signed int);
13319 vector unsigned int vec_vmsumubm (vector unsigned char,
13320                                   vector unsigned char,
13321                                   vector unsigned int);
13323 vector unsigned int vec_msums (vector unsigned short,
13324                                vector unsigned short,
13325                                vector unsigned int);
13326 vector signed int vec_msums (vector signed short,
13327                              vector signed short,
13328                              vector signed int);
13330 vector signed int vec_vmsumshs (vector signed short,
13331                                 vector signed short,
13332                                 vector signed int);
13334 vector unsigned int vec_vmsumuhs (vector unsigned short,
13335                                   vector unsigned short,
13336                                   vector unsigned int);
13338 void vec_mtvscr (vector signed int);
13339 void vec_mtvscr (vector unsigned int);
13340 void vec_mtvscr (vector bool int);
13341 void vec_mtvscr (vector signed short);
13342 void vec_mtvscr (vector unsigned short);
13343 void vec_mtvscr (vector bool short);
13344 void vec_mtvscr (vector pixel);
13345 void vec_mtvscr (vector signed char);
13346 void vec_mtvscr (vector unsigned char);
13347 void vec_mtvscr (vector bool char);
13349 vector unsigned short vec_mule (vector unsigned char,
13350                                 vector unsigned char);
13351 vector signed short vec_mule (vector signed char,
13352                               vector signed char);
13353 vector unsigned int vec_mule (vector unsigned short,
13354                               vector unsigned short);
13355 vector signed int vec_mule (vector signed short, vector signed short);
13357 vector signed int vec_vmulesh (vector signed short,
13358                                vector signed short);
13360 vector unsigned int vec_vmuleuh (vector unsigned short,
13361                                  vector unsigned short);
13363 vector signed short vec_vmulesb (vector signed char,
13364                                  vector signed char);
13366 vector unsigned short vec_vmuleub (vector unsigned char,
13367                                   vector unsigned char);
13369 vector unsigned short vec_mulo (vector unsigned char,
13370                                 vector unsigned char);
13371 vector signed short vec_mulo (vector signed char, vector signed char);
13372 vector unsigned int vec_mulo (vector unsigned short,
13373                               vector unsigned short);
13374 vector signed int vec_mulo (vector signed short, vector signed short);
13376 vector signed int vec_vmulosh (vector signed short,
13377                                vector signed short);
13379 vector unsigned int vec_vmulouh (vector unsigned short,
13380                                  vector unsigned short);
13382 vector signed short vec_vmulosb (vector signed char,
13383                                  vector signed char);
13385 vector unsigned short vec_vmuloub (vector unsigned char,
13386                                    vector unsigned char);
13388 vector float vec_nmsub (vector float, vector float, vector float);
13390 vector float vec_nor (vector float, vector float);
13391 vector signed int vec_nor (vector signed int, vector signed int);
13392 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13393 vector bool int vec_nor (vector bool int, vector bool int);
13394 vector signed short vec_nor (vector signed short, vector signed short);
13395 vector unsigned short vec_nor (vector unsigned short,
13396                                vector unsigned short);
13397 vector bool short vec_nor (vector bool short, vector bool short);
13398 vector signed char vec_nor (vector signed char, vector signed char);
13399 vector unsigned char vec_nor (vector unsigned char,
13400                               vector unsigned char);
13401 vector bool char vec_nor (vector bool char, vector bool char);
13403 vector float vec_or (vector float, vector float);
13404 vector float vec_or (vector float, vector bool int);
13405 vector float vec_or (vector bool int, vector float);
13406 vector bool int vec_or (vector bool int, vector bool int);
13407 vector signed int vec_or (vector bool int, vector signed int);
13408 vector signed int vec_or (vector signed int, vector bool int);
13409 vector signed int vec_or (vector signed int, vector signed int);
13410 vector unsigned int vec_or (vector bool int, vector unsigned int);
13411 vector unsigned int vec_or (vector unsigned int, vector bool int);
13412 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13413 vector bool short vec_or (vector bool short, vector bool short);
13414 vector signed short vec_or (vector bool short, vector signed short);
13415 vector signed short vec_or (vector signed short, vector bool short);
13416 vector signed short vec_or (vector signed short, vector signed short);
13417 vector unsigned short vec_or (vector bool short, vector unsigned short);
13418 vector unsigned short vec_or (vector unsigned short, vector bool short);
13419 vector unsigned short vec_or (vector unsigned short,
13420                               vector unsigned short);
13421 vector signed char vec_or (vector bool char, vector signed char);
13422 vector bool char vec_or (vector bool char, vector bool char);
13423 vector signed char vec_or (vector signed char, vector bool char);
13424 vector signed char vec_or (vector signed char, vector signed char);
13425 vector unsigned char vec_or (vector bool char, vector unsigned char);
13426 vector unsigned char vec_or (vector unsigned char, vector bool char);
13427 vector unsigned char vec_or (vector unsigned char,
13428                              vector unsigned char);
13430 vector signed char vec_pack (vector signed short, vector signed short);
13431 vector unsigned char vec_pack (vector unsigned short,
13432                                vector unsigned short);
13433 vector bool char vec_pack (vector bool short, vector bool short);
13434 vector signed short vec_pack (vector signed int, vector signed int);
13435 vector unsigned short vec_pack (vector unsigned int,
13436                                 vector unsigned int);
13437 vector bool short vec_pack (vector bool int, vector bool int);
13439 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13440 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13441 vector unsigned short vec_vpkuwum (vector unsigned int,
13442                                    vector unsigned int);
13444 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13445 vector signed char vec_vpkuhum (vector signed short,
13446                                 vector signed short);
13447 vector unsigned char vec_vpkuhum (vector unsigned short,
13448                                   vector unsigned short);
13450 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13452 vector unsigned char vec_packs (vector unsigned short,
13453                                 vector unsigned short);
13454 vector signed char vec_packs (vector signed short, vector signed short);
13455 vector unsigned short vec_packs (vector unsigned int,
13456                                  vector unsigned int);
13457 vector signed short vec_packs (vector signed int, vector signed int);
13459 vector signed short vec_vpkswss (vector signed int, vector signed int);
13461 vector unsigned short vec_vpkuwus (vector unsigned int,
13462                                    vector unsigned int);
13464 vector signed char vec_vpkshss (vector signed short,
13465                                 vector signed short);
13467 vector unsigned char vec_vpkuhus (vector unsigned short,
13468                                   vector unsigned short);
13470 vector unsigned char vec_packsu (vector unsigned short,
13471                                  vector unsigned short);
13472 vector unsigned char vec_packsu (vector signed short,
13473                                  vector signed short);
13474 vector unsigned short vec_packsu (vector unsigned int,
13475                                   vector unsigned int);
13476 vector unsigned short vec_packsu (vector signed int, vector signed int);
13478 vector unsigned short vec_vpkswus (vector signed int,
13479                                    vector signed int);
13481 vector unsigned char vec_vpkshus (vector signed short,
13482                                   vector signed short);
13484 vector float vec_perm (vector float,
13485                        vector float,
13486                        vector unsigned char);
13487 vector signed int vec_perm (vector signed int,
13488                             vector signed int,
13489                             vector unsigned char);
13490 vector unsigned int vec_perm (vector unsigned int,
13491                               vector unsigned int,
13492                               vector unsigned char);
13493 vector bool int vec_perm (vector bool int,
13494                           vector bool int,
13495                           vector unsigned char);
13496 vector signed short vec_perm (vector signed short,
13497                               vector signed short,
13498                               vector unsigned char);
13499 vector unsigned short vec_perm (vector unsigned short,
13500                                 vector unsigned short,
13501                                 vector unsigned char);
13502 vector bool short vec_perm (vector bool short,
13503                             vector bool short,
13504                             vector unsigned char);
13505 vector pixel vec_perm (vector pixel,
13506                        vector pixel,
13507                        vector unsigned char);
13508 vector signed char vec_perm (vector signed char,
13509                              vector signed char,
13510                              vector unsigned char);
13511 vector unsigned char vec_perm (vector unsigned char,
13512                                vector unsigned char,
13513                                vector unsigned char);
13514 vector bool char vec_perm (vector bool char,
13515                            vector bool char,
13516                            vector unsigned char);
13518 vector float vec_re (vector float);
13520 vector signed char vec_rl (vector signed char,
13521                            vector unsigned char);
13522 vector unsigned char vec_rl (vector unsigned char,
13523                              vector unsigned char);
13524 vector signed short vec_rl (vector signed short, vector unsigned short);
13525 vector unsigned short vec_rl (vector unsigned short,
13526                               vector unsigned short);
13527 vector signed int vec_rl (vector signed int, vector unsigned int);
13528 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13530 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13531 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
13533 vector signed short vec_vrlh (vector signed short,
13534                               vector unsigned short);
13535 vector unsigned short vec_vrlh (vector unsigned short,
13536                                 vector unsigned short);
13538 vector signed char vec_vrlb (vector signed char, vector unsigned char);
13539 vector unsigned char vec_vrlb (vector unsigned char,
13540                                vector unsigned char);
13542 vector float vec_round (vector float);
13544 vector float vec_recip (vector float, vector float);
13546 vector float vec_rsqrt (vector float);
13548 vector float vec_rsqrte (vector float);
13550 vector float vec_sel (vector float, vector float, vector bool int);
13551 vector float vec_sel (vector float, vector float, vector unsigned int);
13552 vector signed int vec_sel (vector signed int,
13553                            vector signed int,
13554                            vector bool int);
13555 vector signed int vec_sel (vector signed int,
13556                            vector signed int,
13557                            vector unsigned int);
13558 vector unsigned int vec_sel (vector unsigned int,
13559                              vector unsigned int,
13560                              vector bool int);
13561 vector unsigned int vec_sel (vector unsigned int,
13562                              vector unsigned int,
13563                              vector unsigned int);
13564 vector bool int vec_sel (vector bool int,
13565                          vector bool int,
13566                          vector bool int);
13567 vector bool int vec_sel (vector bool int,
13568                          vector bool int,
13569                          vector unsigned int);
13570 vector signed short vec_sel (vector signed short,
13571                              vector signed short,
13572                              vector bool short);
13573 vector signed short vec_sel (vector signed short,
13574                              vector signed short,
13575                              vector unsigned short);
13576 vector unsigned short vec_sel (vector unsigned short,
13577                                vector unsigned short,
13578                                vector bool short);
13579 vector unsigned short vec_sel (vector unsigned short,
13580                                vector unsigned short,
13581                                vector unsigned short);
13582 vector bool short vec_sel (vector bool short,
13583                            vector bool short,
13584                            vector bool short);
13585 vector bool short vec_sel (vector bool short,
13586                            vector bool short,
13587                            vector unsigned short);
13588 vector signed char vec_sel (vector signed char,
13589                             vector signed char,
13590                             vector bool char);
13591 vector signed char vec_sel (vector signed char,
13592                             vector signed char,
13593                             vector unsigned char);
13594 vector unsigned char vec_sel (vector unsigned char,
13595                               vector unsigned char,
13596                               vector bool char);
13597 vector unsigned char vec_sel (vector unsigned char,
13598                               vector unsigned char,
13599                               vector unsigned char);
13600 vector bool char vec_sel (vector bool char,
13601                           vector bool char,
13602                           vector bool char);
13603 vector bool char vec_sel (vector bool char,
13604                           vector bool char,
13605                           vector unsigned char);
13607 vector signed char vec_sl (vector signed char,
13608                            vector unsigned char);
13609 vector unsigned char vec_sl (vector unsigned char,
13610                              vector unsigned char);
13611 vector signed short vec_sl (vector signed short, vector unsigned short);
13612 vector unsigned short vec_sl (vector unsigned short,
13613                               vector unsigned short);
13614 vector signed int vec_sl (vector signed int, vector unsigned int);
13615 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13617 vector signed int vec_vslw (vector signed int, vector unsigned int);
13618 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13620 vector signed short vec_vslh (vector signed short,
13621                               vector unsigned short);
13622 vector unsigned short vec_vslh (vector unsigned short,
13623                                 vector unsigned short);
13625 vector signed char vec_vslb (vector signed char, vector unsigned char);
13626 vector unsigned char vec_vslb (vector unsigned char,
13627                                vector unsigned char);
13629 vector float vec_sld (vector float, vector float, const int);
13630 vector signed int vec_sld (vector signed int,
13631                            vector signed int,
13632                            const int);
13633 vector unsigned int vec_sld (vector unsigned int,
13634                              vector unsigned int,
13635                              const int);
13636 vector bool int vec_sld (vector bool int,
13637                          vector bool int,
13638                          const int);
13639 vector signed short vec_sld (vector signed short,
13640                              vector signed short,
13641                              const int);
13642 vector unsigned short vec_sld (vector unsigned short,
13643                                vector unsigned short,
13644                                const int);
13645 vector bool short vec_sld (vector bool short,
13646                            vector bool short,
13647                            const int);
13648 vector pixel vec_sld (vector pixel,
13649                       vector pixel,
13650                       const int);
13651 vector signed char vec_sld (vector signed char,
13652                             vector signed char,
13653                             const int);
13654 vector unsigned char vec_sld (vector unsigned char,
13655                               vector unsigned char,
13656                               const int);
13657 vector bool char vec_sld (vector bool char,
13658                           vector bool char,
13659                           const int);
13661 vector signed int vec_sll (vector signed int,
13662                            vector unsigned int);
13663 vector signed int vec_sll (vector signed int,
13664                            vector unsigned short);
13665 vector signed int vec_sll (vector signed int,
13666                            vector unsigned char);
13667 vector unsigned int vec_sll (vector unsigned int,
13668                              vector unsigned int);
13669 vector unsigned int vec_sll (vector unsigned int,
13670                              vector unsigned short);
13671 vector unsigned int vec_sll (vector unsigned int,
13672                              vector unsigned char);
13673 vector bool int vec_sll (vector bool int,
13674                          vector unsigned int);
13675 vector bool int vec_sll (vector bool int,
13676                          vector unsigned short);
13677 vector bool int vec_sll (vector bool int,
13678                          vector unsigned char);
13679 vector signed short vec_sll (vector signed short,
13680                              vector unsigned int);
13681 vector signed short vec_sll (vector signed short,
13682                              vector unsigned short);
13683 vector signed short vec_sll (vector signed short,
13684                              vector unsigned char);
13685 vector unsigned short vec_sll (vector unsigned short,
13686                                vector unsigned int);
13687 vector unsigned short vec_sll (vector unsigned short,
13688                                vector unsigned short);
13689 vector unsigned short vec_sll (vector unsigned short,
13690                                vector unsigned char);
13691 vector bool short vec_sll (vector bool short, vector unsigned int);
13692 vector bool short vec_sll (vector bool short, vector unsigned short);
13693 vector bool short vec_sll (vector bool short, vector unsigned char);
13694 vector pixel vec_sll (vector pixel, vector unsigned int);
13695 vector pixel vec_sll (vector pixel, vector unsigned short);
13696 vector pixel vec_sll (vector pixel, vector unsigned char);
13697 vector signed char vec_sll (vector signed char, vector unsigned int);
13698 vector signed char vec_sll (vector signed char, vector unsigned short);
13699 vector signed char vec_sll (vector signed char, vector unsigned char);
13700 vector unsigned char vec_sll (vector unsigned char,
13701                               vector unsigned int);
13702 vector unsigned char vec_sll (vector unsigned char,
13703                               vector unsigned short);
13704 vector unsigned char vec_sll (vector unsigned char,
13705                               vector unsigned char);
13706 vector bool char vec_sll (vector bool char, vector unsigned int);
13707 vector bool char vec_sll (vector bool char, vector unsigned short);
13708 vector bool char vec_sll (vector bool char, vector unsigned char);
13710 vector float vec_slo (vector float, vector signed char);
13711 vector float vec_slo (vector float, vector unsigned char);
13712 vector signed int vec_slo (vector signed int, vector signed char);
13713 vector signed int vec_slo (vector signed int, vector unsigned char);
13714 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13715 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13716 vector signed short vec_slo (vector signed short, vector signed char);
13717 vector signed short vec_slo (vector signed short, vector unsigned char);
13718 vector unsigned short vec_slo (vector unsigned short,
13719                                vector signed char);
13720 vector unsigned short vec_slo (vector unsigned short,
13721                                vector unsigned char);
13722 vector pixel vec_slo (vector pixel, vector signed char);
13723 vector pixel vec_slo (vector pixel, vector unsigned char);
13724 vector signed char vec_slo (vector signed char, vector signed char);
13725 vector signed char vec_slo (vector signed char, vector unsigned char);
13726 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13727 vector unsigned char vec_slo (vector unsigned char,
13728                               vector unsigned char);
13730 vector signed char vec_splat (vector signed char, const int);
13731 vector unsigned char vec_splat (vector unsigned char, const int);
13732 vector bool char vec_splat (vector bool char, const int);
13733 vector signed short vec_splat (vector signed short, const int);
13734 vector unsigned short vec_splat (vector unsigned short, const int);
13735 vector bool short vec_splat (vector bool short, const int);
13736 vector pixel vec_splat (vector pixel, const int);
13737 vector float vec_splat (vector float, const int);
13738 vector signed int vec_splat (vector signed int, const int);
13739 vector unsigned int vec_splat (vector unsigned int, const int);
13740 vector bool int vec_splat (vector bool int, const int);
13741 vector signed long vec_splat (vector signed long, const int);
13742 vector unsigned long vec_splat (vector unsigned long, const int);
13744 vector signed char vec_splats (signed char);
13745 vector unsigned char vec_splats (unsigned char);
13746 vector signed short vec_splats (signed short);
13747 vector unsigned short vec_splats (unsigned short);
13748 vector signed int vec_splats (signed int);
13749 vector unsigned int vec_splats (unsigned int);
13750 vector float vec_splats (float);
13752 vector float vec_vspltw (vector float, const int);
13753 vector signed int vec_vspltw (vector signed int, const int);
13754 vector unsigned int vec_vspltw (vector unsigned int, const int);
13755 vector bool int vec_vspltw (vector bool int, const int);
13757 vector bool short vec_vsplth (vector bool short, const int);
13758 vector signed short vec_vsplth (vector signed short, const int);
13759 vector unsigned short vec_vsplth (vector unsigned short, const int);
13760 vector pixel vec_vsplth (vector pixel, const int);
13762 vector signed char vec_vspltb (vector signed char, const int);
13763 vector unsigned char vec_vspltb (vector unsigned char, const int);
13764 vector bool char vec_vspltb (vector bool char, const int);
13766 vector signed char vec_splat_s8 (const int);
13768 vector signed short vec_splat_s16 (const int);
13770 vector signed int vec_splat_s32 (const int);
13772 vector unsigned char vec_splat_u8 (const int);
13774 vector unsigned short vec_splat_u16 (const int);
13776 vector unsigned int vec_splat_u32 (const int);
13778 vector signed char vec_sr (vector signed char, vector unsigned char);
13779 vector unsigned char vec_sr (vector unsigned char,
13780                              vector unsigned char);
13781 vector signed short vec_sr (vector signed short,
13782                             vector unsigned short);
13783 vector unsigned short vec_sr (vector unsigned short,
13784                               vector unsigned short);
13785 vector signed int vec_sr (vector signed int, vector unsigned int);
13786 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13788 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13789 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13791 vector signed short vec_vsrh (vector signed short,
13792                               vector unsigned short);
13793 vector unsigned short vec_vsrh (vector unsigned short,
13794                                 vector unsigned short);
13796 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13797 vector unsigned char vec_vsrb (vector unsigned char,
13798                                vector unsigned char);
13800 vector signed char vec_sra (vector signed char, vector unsigned char);
13801 vector unsigned char vec_sra (vector unsigned char,
13802                               vector unsigned char);
13803 vector signed short vec_sra (vector signed short,
13804                              vector unsigned short);
13805 vector unsigned short vec_sra (vector unsigned short,
13806                                vector unsigned short);
13807 vector signed int vec_sra (vector signed int, vector unsigned int);
13808 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13810 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13811 vector unsigned int vec_vsraw (vector unsigned int,
13812                                vector unsigned int);
13814 vector signed short vec_vsrah (vector signed short,
13815                                vector unsigned short);
13816 vector unsigned short vec_vsrah (vector unsigned short,
13817                                  vector unsigned short);
13819 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13820 vector unsigned char vec_vsrab (vector unsigned char,
13821                                 vector unsigned char);
13823 vector signed int vec_srl (vector signed int, vector unsigned int);
13824 vector signed int vec_srl (vector signed int, vector unsigned short);
13825 vector signed int vec_srl (vector signed int, vector unsigned char);
13826 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13827 vector unsigned int vec_srl (vector unsigned int,
13828                              vector unsigned short);
13829 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13830 vector bool int vec_srl (vector bool int, vector unsigned int);
13831 vector bool int vec_srl (vector bool int, vector unsigned short);
13832 vector bool int vec_srl (vector bool int, vector unsigned char);
13833 vector signed short vec_srl (vector signed short, vector unsigned int);
13834 vector signed short vec_srl (vector signed short,
13835                              vector unsigned short);
13836 vector signed short vec_srl (vector signed short, vector unsigned char);
13837 vector unsigned short vec_srl (vector unsigned short,
13838                                vector unsigned int);
13839 vector unsigned short vec_srl (vector unsigned short,
13840                                vector unsigned short);
13841 vector unsigned short vec_srl (vector unsigned short,
13842                                vector unsigned char);
13843 vector bool short vec_srl (vector bool short, vector unsigned int);
13844 vector bool short vec_srl (vector bool short, vector unsigned short);
13845 vector bool short vec_srl (vector bool short, vector unsigned char);
13846 vector pixel vec_srl (vector pixel, vector unsigned int);
13847 vector pixel vec_srl (vector pixel, vector unsigned short);
13848 vector pixel vec_srl (vector pixel, vector unsigned char);
13849 vector signed char vec_srl (vector signed char, vector unsigned int);
13850 vector signed char vec_srl (vector signed char, vector unsigned short);
13851 vector signed char vec_srl (vector signed char, vector unsigned char);
13852 vector unsigned char vec_srl (vector unsigned char,
13853                               vector unsigned int);
13854 vector unsigned char vec_srl (vector unsigned char,
13855                               vector unsigned short);
13856 vector unsigned char vec_srl (vector unsigned char,
13857                               vector unsigned char);
13858 vector bool char vec_srl (vector bool char, vector unsigned int);
13859 vector bool char vec_srl (vector bool char, vector unsigned short);
13860 vector bool char vec_srl (vector bool char, vector unsigned char);
13862 vector float vec_sro (vector float, vector signed char);
13863 vector float vec_sro (vector float, vector unsigned char);
13864 vector signed int vec_sro (vector signed int, vector signed char);
13865 vector signed int vec_sro (vector signed int, vector unsigned char);
13866 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13867 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13868 vector signed short vec_sro (vector signed short, vector signed char);
13869 vector signed short vec_sro (vector signed short, vector unsigned char);
13870 vector unsigned short vec_sro (vector unsigned short,
13871                                vector signed char);
13872 vector unsigned short vec_sro (vector unsigned short,
13873                                vector unsigned char);
13874 vector pixel vec_sro (vector pixel, vector signed char);
13875 vector pixel vec_sro (vector pixel, vector unsigned char);
13876 vector signed char vec_sro (vector signed char, vector signed char);
13877 vector signed char vec_sro (vector signed char, vector unsigned char);
13878 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13879 vector unsigned char vec_sro (vector unsigned char,
13880                               vector unsigned char);
13882 void vec_st (vector float, int, vector float *);
13883 void vec_st (vector float, int, float *);
13884 void vec_st (vector signed int, int, vector signed int *);
13885 void vec_st (vector signed int, int, int *);
13886 void vec_st (vector unsigned int, int, vector unsigned int *);
13887 void vec_st (vector unsigned int, int, unsigned int *);
13888 void vec_st (vector bool int, int, vector bool int *);
13889 void vec_st (vector bool int, int, unsigned int *);
13890 void vec_st (vector bool int, int, int *);
13891 void vec_st (vector signed short, int, vector signed short *);
13892 void vec_st (vector signed short, int, short *);
13893 void vec_st (vector unsigned short, int, vector unsigned short *);
13894 void vec_st (vector unsigned short, int, unsigned short *);
13895 void vec_st (vector bool short, int, vector bool short *);
13896 void vec_st (vector bool short, int, unsigned short *);
13897 void vec_st (vector pixel, int, vector pixel *);
13898 void vec_st (vector pixel, int, unsigned short *);
13899 void vec_st (vector pixel, int, short *);
13900 void vec_st (vector bool short, int, short *);
13901 void vec_st (vector signed char, int, vector signed char *);
13902 void vec_st (vector signed char, int, signed char *);
13903 void vec_st (vector unsigned char, int, vector unsigned char *);
13904 void vec_st (vector unsigned char, int, unsigned char *);
13905 void vec_st (vector bool char, int, vector bool char *);
13906 void vec_st (vector bool char, int, unsigned char *);
13907 void vec_st (vector bool char, int, signed char *);
13909 void vec_ste (vector signed char, int, signed char *);
13910 void vec_ste (vector unsigned char, int, unsigned char *);
13911 void vec_ste (vector bool char, int, signed char *);
13912 void vec_ste (vector bool char, int, unsigned char *);
13913 void vec_ste (vector signed short, int, short *);
13914 void vec_ste (vector unsigned short, int, unsigned short *);
13915 void vec_ste (vector bool short, int, short *);
13916 void vec_ste (vector bool short, int, unsigned short *);
13917 void vec_ste (vector pixel, int, short *);
13918 void vec_ste (vector pixel, int, unsigned short *);
13919 void vec_ste (vector float, int, float *);
13920 void vec_ste (vector signed int, int, int *);
13921 void vec_ste (vector unsigned int, int, unsigned int *);
13922 void vec_ste (vector bool int, int, int *);
13923 void vec_ste (vector bool int, int, unsigned int *);
13925 void vec_stvewx (vector float, int, float *);
13926 void vec_stvewx (vector signed int, int, int *);
13927 void vec_stvewx (vector unsigned int, int, unsigned int *);
13928 void vec_stvewx (vector bool int, int, int *);
13929 void vec_stvewx (vector bool int, int, unsigned int *);
13931 void vec_stvehx (vector signed short, int, short *);
13932 void vec_stvehx (vector unsigned short, int, unsigned short *);
13933 void vec_stvehx (vector bool short, int, short *);
13934 void vec_stvehx (vector bool short, int, unsigned short *);
13935 void vec_stvehx (vector pixel, int, short *);
13936 void vec_stvehx (vector pixel, int, unsigned short *);
13938 void vec_stvebx (vector signed char, int, signed char *);
13939 void vec_stvebx (vector unsigned char, int, unsigned char *);
13940 void vec_stvebx (vector bool char, int, signed char *);
13941 void vec_stvebx (vector bool char, int, unsigned char *);
13943 void vec_stl (vector float, int, vector float *);
13944 void vec_stl (vector float, int, float *);
13945 void vec_stl (vector signed int, int, vector signed int *);
13946 void vec_stl (vector signed int, int, int *);
13947 void vec_stl (vector unsigned int, int, vector unsigned int *);
13948 void vec_stl (vector unsigned int, int, unsigned int *);
13949 void vec_stl (vector bool int, int, vector bool int *);
13950 void vec_stl (vector bool int, int, unsigned int *);
13951 void vec_stl (vector bool int, int, int *);
13952 void vec_stl (vector signed short, int, vector signed short *);
13953 void vec_stl (vector signed short, int, short *);
13954 void vec_stl (vector unsigned short, int, vector unsigned short *);
13955 void vec_stl (vector unsigned short, int, unsigned short *);
13956 void vec_stl (vector bool short, int, vector bool short *);
13957 void vec_stl (vector bool short, int, unsigned short *);
13958 void vec_stl (vector bool short, int, short *);
13959 void vec_stl (vector pixel, int, vector pixel *);
13960 void vec_stl (vector pixel, int, unsigned short *);
13961 void vec_stl (vector pixel, int, short *);
13962 void vec_stl (vector signed char, int, vector signed char *);
13963 void vec_stl (vector signed char, int, signed char *);
13964 void vec_stl (vector unsigned char, int, vector unsigned char *);
13965 void vec_stl (vector unsigned char, int, unsigned char *);
13966 void vec_stl (vector bool char, int, vector bool char *);
13967 void vec_stl (vector bool char, int, unsigned char *);
13968 void vec_stl (vector bool char, int, signed char *);
13970 vector signed char vec_sub (vector bool char, vector signed char);
13971 vector signed char vec_sub (vector signed char, vector bool char);
13972 vector signed char vec_sub (vector signed char, vector signed char);
13973 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13974 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13975 vector unsigned char vec_sub (vector unsigned char,
13976                               vector unsigned char);
13977 vector signed short vec_sub (vector bool short, vector signed short);
13978 vector signed short vec_sub (vector signed short, vector bool short);
13979 vector signed short vec_sub (vector signed short, vector signed short);
13980 vector unsigned short vec_sub (vector bool short,
13981                                vector unsigned short);
13982 vector unsigned short vec_sub (vector unsigned short,
13983                                vector bool short);
13984 vector unsigned short vec_sub (vector unsigned short,
13985                                vector unsigned short);
13986 vector signed int vec_sub (vector bool int, vector signed int);
13987 vector signed int vec_sub (vector signed int, vector bool int);
13988 vector signed int vec_sub (vector signed int, vector signed int);
13989 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13990 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13991 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13992 vector float vec_sub (vector float, vector float);
13994 vector float vec_vsubfp (vector float, vector float);
13996 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13997 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13998 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13999 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14000 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14001 vector unsigned int vec_vsubuwm (vector unsigned int,
14002                                  vector unsigned int);
14004 vector signed short vec_vsubuhm (vector bool short,
14005                                  vector signed short);
14006 vector signed short vec_vsubuhm (vector signed short,
14007                                  vector bool short);
14008 vector signed short vec_vsubuhm (vector signed short,
14009                                  vector signed short);
14010 vector unsigned short vec_vsubuhm (vector bool short,
14011                                    vector unsigned short);
14012 vector unsigned short vec_vsubuhm (vector unsigned short,
14013                                    vector bool short);
14014 vector unsigned short vec_vsubuhm (vector unsigned short,
14015                                    vector unsigned short);
14017 vector signed char vec_vsububm (vector bool char, vector signed char);
14018 vector signed char vec_vsububm (vector signed char, vector bool char);
14019 vector signed char vec_vsububm (vector signed char, vector signed char);
14020 vector unsigned char vec_vsububm (vector bool char,
14021                                   vector unsigned char);
14022 vector unsigned char vec_vsububm (vector unsigned char,
14023                                   vector bool char);
14024 vector unsigned char vec_vsububm (vector unsigned char,
14025                                   vector unsigned char);
14027 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14029 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14030 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14031 vector unsigned char vec_subs (vector unsigned char,
14032                                vector unsigned char);
14033 vector signed char vec_subs (vector bool char, vector signed char);
14034 vector signed char vec_subs (vector signed char, vector bool char);
14035 vector signed char vec_subs (vector signed char, vector signed char);
14036 vector unsigned short vec_subs (vector bool short,
14037                                 vector unsigned short);
14038 vector unsigned short vec_subs (vector unsigned short,
14039                                 vector bool short);
14040 vector unsigned short vec_subs (vector unsigned short,
14041                                 vector unsigned short);
14042 vector signed short vec_subs (vector bool short, vector signed short);
14043 vector signed short vec_subs (vector signed short, vector bool short);
14044 vector signed short vec_subs (vector signed short, vector signed short);
14045 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14046 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14047 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14048 vector signed int vec_subs (vector bool int, vector signed int);
14049 vector signed int vec_subs (vector signed int, vector bool int);
14050 vector signed int vec_subs (vector signed int, vector signed int);
14052 vector signed int vec_vsubsws (vector bool int, vector signed int);
14053 vector signed int vec_vsubsws (vector signed int, vector bool int);
14054 vector signed int vec_vsubsws (vector signed int, vector signed int);
14056 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14057 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14058 vector unsigned int vec_vsubuws (vector unsigned int,
14059                                  vector unsigned int);
14061 vector signed short vec_vsubshs (vector bool short,
14062                                  vector signed short);
14063 vector signed short vec_vsubshs (vector signed short,
14064                                  vector bool short);
14065 vector signed short vec_vsubshs (vector signed short,
14066                                  vector signed short);
14068 vector unsigned short vec_vsubuhs (vector bool short,
14069                                    vector unsigned short);
14070 vector unsigned short vec_vsubuhs (vector unsigned short,
14071                                    vector bool short);
14072 vector unsigned short vec_vsubuhs (vector unsigned short,
14073                                    vector unsigned short);
14075 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14076 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14077 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14079 vector unsigned char vec_vsububs (vector bool char,
14080                                   vector unsigned char);
14081 vector unsigned char vec_vsububs (vector unsigned char,
14082                                   vector bool char);
14083 vector unsigned char vec_vsububs (vector unsigned char,
14084                                   vector unsigned char);
14086 vector unsigned int vec_sum4s (vector unsigned char,
14087                                vector unsigned int);
14088 vector signed int vec_sum4s (vector signed char, vector signed int);
14089 vector signed int vec_sum4s (vector signed short, vector signed int);
14091 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14093 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14095 vector unsigned int vec_vsum4ubs (vector unsigned char,
14096                                   vector unsigned int);
14098 vector signed int vec_sum2s (vector signed int, vector signed int);
14100 vector signed int vec_sums (vector signed int, vector signed int);
14102 vector float vec_trunc (vector float);
14104 vector signed short vec_unpackh (vector signed char);
14105 vector bool short vec_unpackh (vector bool char);
14106 vector signed int vec_unpackh (vector signed short);
14107 vector bool int vec_unpackh (vector bool short);
14108 vector unsigned int vec_unpackh (vector pixel);
14110 vector bool int vec_vupkhsh (vector bool short);
14111 vector signed int vec_vupkhsh (vector signed short);
14113 vector unsigned int vec_vupkhpx (vector pixel);
14115 vector bool short vec_vupkhsb (vector bool char);
14116 vector signed short vec_vupkhsb (vector signed char);
14118 vector signed short vec_unpackl (vector signed char);
14119 vector bool short vec_unpackl (vector bool char);
14120 vector unsigned int vec_unpackl (vector pixel);
14121 vector signed int vec_unpackl (vector signed short);
14122 vector bool int vec_unpackl (vector bool short);
14124 vector unsigned int vec_vupklpx (vector pixel);
14126 vector bool int vec_vupklsh (vector bool short);
14127 vector signed int vec_vupklsh (vector signed short);
14129 vector bool short vec_vupklsb (vector bool char);
14130 vector signed short vec_vupklsb (vector signed char);
14132 vector float vec_xor (vector float, vector float);
14133 vector float vec_xor (vector float, vector bool int);
14134 vector float vec_xor (vector bool int, vector float);
14135 vector bool int vec_xor (vector bool int, vector bool int);
14136 vector signed int vec_xor (vector bool int, vector signed int);
14137 vector signed int vec_xor (vector signed int, vector bool int);
14138 vector signed int vec_xor (vector signed int, vector signed int);
14139 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14140 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14141 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14142 vector bool short vec_xor (vector bool short, vector bool short);
14143 vector signed short vec_xor (vector bool short, vector signed short);
14144 vector signed short vec_xor (vector signed short, vector bool short);
14145 vector signed short vec_xor (vector signed short, vector signed short);
14146 vector unsigned short vec_xor (vector bool short,
14147                                vector unsigned short);
14148 vector unsigned short vec_xor (vector unsigned short,
14149                                vector bool short);
14150 vector unsigned short vec_xor (vector unsigned short,
14151                                vector unsigned short);
14152 vector signed char vec_xor (vector bool char, vector signed char);
14153 vector bool char vec_xor (vector bool char, vector bool char);
14154 vector signed char vec_xor (vector signed char, vector bool char);
14155 vector signed char vec_xor (vector signed char, vector signed char);
14156 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14157 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14158 vector unsigned char vec_xor (vector unsigned char,
14159                               vector unsigned char);
14161 int vec_all_eq (vector signed char, vector bool char);
14162 int vec_all_eq (vector signed char, vector signed char);
14163 int vec_all_eq (vector unsigned char, vector bool char);
14164 int vec_all_eq (vector unsigned char, vector unsigned char);
14165 int vec_all_eq (vector bool char, vector bool char);
14166 int vec_all_eq (vector bool char, vector unsigned char);
14167 int vec_all_eq (vector bool char, vector signed char);
14168 int vec_all_eq (vector signed short, vector bool short);
14169 int vec_all_eq (vector signed short, vector signed short);
14170 int vec_all_eq (vector unsigned short, vector bool short);
14171 int vec_all_eq (vector unsigned short, vector unsigned short);
14172 int vec_all_eq (vector bool short, vector bool short);
14173 int vec_all_eq (vector bool short, vector unsigned short);
14174 int vec_all_eq (vector bool short, vector signed short);
14175 int vec_all_eq (vector pixel, vector pixel);
14176 int vec_all_eq (vector signed int, vector bool int);
14177 int vec_all_eq (vector signed int, vector signed int);
14178 int vec_all_eq (vector unsigned int, vector bool int);
14179 int vec_all_eq (vector unsigned int, vector unsigned int);
14180 int vec_all_eq (vector bool int, vector bool int);
14181 int vec_all_eq (vector bool int, vector unsigned int);
14182 int vec_all_eq (vector bool int, vector signed int);
14183 int vec_all_eq (vector float, vector float);
14185 int vec_all_ge (vector bool char, vector unsigned char);
14186 int vec_all_ge (vector unsigned char, vector bool char);
14187 int vec_all_ge (vector unsigned char, vector unsigned char);
14188 int vec_all_ge (vector bool char, vector signed char);
14189 int vec_all_ge (vector signed char, vector bool char);
14190 int vec_all_ge (vector signed char, vector signed char);
14191 int vec_all_ge (vector bool short, vector unsigned short);
14192 int vec_all_ge (vector unsigned short, vector bool short);
14193 int vec_all_ge (vector unsigned short, vector unsigned short);
14194 int vec_all_ge (vector signed short, vector signed short);
14195 int vec_all_ge (vector bool short, vector signed short);
14196 int vec_all_ge (vector signed short, vector bool short);
14197 int vec_all_ge (vector bool int, vector unsigned int);
14198 int vec_all_ge (vector unsigned int, vector bool int);
14199 int vec_all_ge (vector unsigned int, vector unsigned int);
14200 int vec_all_ge (vector bool int, vector signed int);
14201 int vec_all_ge (vector signed int, vector bool int);
14202 int vec_all_ge (vector signed int, vector signed int);
14203 int vec_all_ge (vector float, vector float);
14205 int vec_all_gt (vector bool char, vector unsigned char);
14206 int vec_all_gt (vector unsigned char, vector bool char);
14207 int vec_all_gt (vector unsigned char, vector unsigned char);
14208 int vec_all_gt (vector bool char, vector signed char);
14209 int vec_all_gt (vector signed char, vector bool char);
14210 int vec_all_gt (vector signed char, vector signed char);
14211 int vec_all_gt (vector bool short, vector unsigned short);
14212 int vec_all_gt (vector unsigned short, vector bool short);
14213 int vec_all_gt (vector unsigned short, vector unsigned short);
14214 int vec_all_gt (vector bool short, vector signed short);
14215 int vec_all_gt (vector signed short, vector bool short);
14216 int vec_all_gt (vector signed short, vector signed short);
14217 int vec_all_gt (vector bool int, vector unsigned int);
14218 int vec_all_gt (vector unsigned int, vector bool int);
14219 int vec_all_gt (vector unsigned int, vector unsigned int);
14220 int vec_all_gt (vector bool int, vector signed int);
14221 int vec_all_gt (vector signed int, vector bool int);
14222 int vec_all_gt (vector signed int, vector signed int);
14223 int vec_all_gt (vector float, vector float);
14225 int vec_all_in (vector float, vector float);
14227 int vec_all_le (vector bool char, vector unsigned char);
14228 int vec_all_le (vector unsigned char, vector bool char);
14229 int vec_all_le (vector unsigned char, vector unsigned char);
14230 int vec_all_le (vector bool char, vector signed char);
14231 int vec_all_le (vector signed char, vector bool char);
14232 int vec_all_le (vector signed char, vector signed char);
14233 int vec_all_le (vector bool short, vector unsigned short);
14234 int vec_all_le (vector unsigned short, vector bool short);
14235 int vec_all_le (vector unsigned short, vector unsigned short);
14236 int vec_all_le (vector bool short, vector signed short);
14237 int vec_all_le (vector signed short, vector bool short);
14238 int vec_all_le (vector signed short, vector signed short);
14239 int vec_all_le (vector bool int, vector unsigned int);
14240 int vec_all_le (vector unsigned int, vector bool int);
14241 int vec_all_le (vector unsigned int, vector unsigned int);
14242 int vec_all_le (vector bool int, vector signed int);
14243 int vec_all_le (vector signed int, vector bool int);
14244 int vec_all_le (vector signed int, vector signed int);
14245 int vec_all_le (vector float, vector float);
14247 int vec_all_lt (vector bool char, vector unsigned char);
14248 int vec_all_lt (vector unsigned char, vector bool char);
14249 int vec_all_lt (vector unsigned char, vector unsigned char);
14250 int vec_all_lt (vector bool char, vector signed char);
14251 int vec_all_lt (vector signed char, vector bool char);
14252 int vec_all_lt (vector signed char, vector signed char);
14253 int vec_all_lt (vector bool short, vector unsigned short);
14254 int vec_all_lt (vector unsigned short, vector bool short);
14255 int vec_all_lt (vector unsigned short, vector unsigned short);
14256 int vec_all_lt (vector bool short, vector signed short);
14257 int vec_all_lt (vector signed short, vector bool short);
14258 int vec_all_lt (vector signed short, vector signed short);
14259 int vec_all_lt (vector bool int, vector unsigned int);
14260 int vec_all_lt (vector unsigned int, vector bool int);
14261 int vec_all_lt (vector unsigned int, vector unsigned int);
14262 int vec_all_lt (vector bool int, vector signed int);
14263 int vec_all_lt (vector signed int, vector bool int);
14264 int vec_all_lt (vector signed int, vector signed int);
14265 int vec_all_lt (vector float, vector float);
14267 int vec_all_nan (vector float);
14269 int vec_all_ne (vector signed char, vector bool char);
14270 int vec_all_ne (vector signed char, vector signed char);
14271 int vec_all_ne (vector unsigned char, vector bool char);
14272 int vec_all_ne (vector unsigned char, vector unsigned char);
14273 int vec_all_ne (vector bool char, vector bool char);
14274 int vec_all_ne (vector bool char, vector unsigned char);
14275 int vec_all_ne (vector bool char, vector signed char);
14276 int vec_all_ne (vector signed short, vector bool short);
14277 int vec_all_ne (vector signed short, vector signed short);
14278 int vec_all_ne (vector unsigned short, vector bool short);
14279 int vec_all_ne (vector unsigned short, vector unsigned short);
14280 int vec_all_ne (vector bool short, vector bool short);
14281 int vec_all_ne (vector bool short, vector unsigned short);
14282 int vec_all_ne (vector bool short, vector signed short);
14283 int vec_all_ne (vector pixel, vector pixel);
14284 int vec_all_ne (vector signed int, vector bool int);
14285 int vec_all_ne (vector signed int, vector signed int);
14286 int vec_all_ne (vector unsigned int, vector bool int);
14287 int vec_all_ne (vector unsigned int, vector unsigned int);
14288 int vec_all_ne (vector bool int, vector bool int);
14289 int vec_all_ne (vector bool int, vector unsigned int);
14290 int vec_all_ne (vector bool int, vector signed int);
14291 int vec_all_ne (vector float, vector float);
14293 int vec_all_nge (vector float, vector float);
14295 int vec_all_ngt (vector float, vector float);
14297 int vec_all_nle (vector float, vector float);
14299 int vec_all_nlt (vector float, vector float);
14301 int vec_all_numeric (vector float);
14303 int vec_any_eq (vector signed char, vector bool char);
14304 int vec_any_eq (vector signed char, vector signed char);
14305 int vec_any_eq (vector unsigned char, vector bool char);
14306 int vec_any_eq (vector unsigned char, vector unsigned char);
14307 int vec_any_eq (vector bool char, vector bool char);
14308 int vec_any_eq (vector bool char, vector unsigned char);
14309 int vec_any_eq (vector bool char, vector signed char);
14310 int vec_any_eq (vector signed short, vector bool short);
14311 int vec_any_eq (vector signed short, vector signed short);
14312 int vec_any_eq (vector unsigned short, vector bool short);
14313 int vec_any_eq (vector unsigned short, vector unsigned short);
14314 int vec_any_eq (vector bool short, vector bool short);
14315 int vec_any_eq (vector bool short, vector unsigned short);
14316 int vec_any_eq (vector bool short, vector signed short);
14317 int vec_any_eq (vector pixel, vector pixel);
14318 int vec_any_eq (vector signed int, vector bool int);
14319 int vec_any_eq (vector signed int, vector signed int);
14320 int vec_any_eq (vector unsigned int, vector bool int);
14321 int vec_any_eq (vector unsigned int, vector unsigned int);
14322 int vec_any_eq (vector bool int, vector bool int);
14323 int vec_any_eq (vector bool int, vector unsigned int);
14324 int vec_any_eq (vector bool int, vector signed int);
14325 int vec_any_eq (vector float, vector float);
14327 int vec_any_ge (vector signed char, vector bool char);
14328 int vec_any_ge (vector unsigned char, vector bool char);
14329 int vec_any_ge (vector unsigned char, vector unsigned char);
14330 int vec_any_ge (vector signed char, vector signed char);
14331 int vec_any_ge (vector bool char, vector unsigned char);
14332 int vec_any_ge (vector bool char, vector signed char);
14333 int vec_any_ge (vector unsigned short, vector bool short);
14334 int vec_any_ge (vector unsigned short, vector unsigned short);
14335 int vec_any_ge (vector signed short, vector signed short);
14336 int vec_any_ge (vector signed short, vector bool short);
14337 int vec_any_ge (vector bool short, vector unsigned short);
14338 int vec_any_ge (vector bool short, vector signed short);
14339 int vec_any_ge (vector signed int, vector bool int);
14340 int vec_any_ge (vector unsigned int, vector bool int);
14341 int vec_any_ge (vector unsigned int, vector unsigned int);
14342 int vec_any_ge (vector signed int, vector signed int);
14343 int vec_any_ge (vector bool int, vector unsigned int);
14344 int vec_any_ge (vector bool int, vector signed int);
14345 int vec_any_ge (vector float, vector float);
14347 int vec_any_gt (vector bool char, vector unsigned char);
14348 int vec_any_gt (vector unsigned char, vector bool char);
14349 int vec_any_gt (vector unsigned char, vector unsigned char);
14350 int vec_any_gt (vector bool char, vector signed char);
14351 int vec_any_gt (vector signed char, vector bool char);
14352 int vec_any_gt (vector signed char, vector signed char);
14353 int vec_any_gt (vector bool short, vector unsigned short);
14354 int vec_any_gt (vector unsigned short, vector bool short);
14355 int vec_any_gt (vector unsigned short, vector unsigned short);
14356 int vec_any_gt (vector bool short, vector signed short);
14357 int vec_any_gt (vector signed short, vector bool short);
14358 int vec_any_gt (vector signed short, vector signed short);
14359 int vec_any_gt (vector bool int, vector unsigned int);
14360 int vec_any_gt (vector unsigned int, vector bool int);
14361 int vec_any_gt (vector unsigned int, vector unsigned int);
14362 int vec_any_gt (vector bool int, vector signed int);
14363 int vec_any_gt (vector signed int, vector bool int);
14364 int vec_any_gt (vector signed int, vector signed int);
14365 int vec_any_gt (vector float, vector float);
14367 int vec_any_le (vector bool char, vector unsigned char);
14368 int vec_any_le (vector unsigned char, vector bool char);
14369 int vec_any_le (vector unsigned char, vector unsigned char);
14370 int vec_any_le (vector bool char, vector signed char);
14371 int vec_any_le (vector signed char, vector bool char);
14372 int vec_any_le (vector signed char, vector signed char);
14373 int vec_any_le (vector bool short, vector unsigned short);
14374 int vec_any_le (vector unsigned short, vector bool short);
14375 int vec_any_le (vector unsigned short, vector unsigned short);
14376 int vec_any_le (vector bool short, vector signed short);
14377 int vec_any_le (vector signed short, vector bool short);
14378 int vec_any_le (vector signed short, vector signed short);
14379 int vec_any_le (vector bool int, vector unsigned int);
14380 int vec_any_le (vector unsigned int, vector bool int);
14381 int vec_any_le (vector unsigned int, vector unsigned int);
14382 int vec_any_le (vector bool int, vector signed int);
14383 int vec_any_le (vector signed int, vector bool int);
14384 int vec_any_le (vector signed int, vector signed int);
14385 int vec_any_le (vector float, vector float);
14387 int vec_any_lt (vector bool char, vector unsigned char);
14388 int vec_any_lt (vector unsigned char, vector bool char);
14389 int vec_any_lt (vector unsigned char, vector unsigned char);
14390 int vec_any_lt (vector bool char, vector signed char);
14391 int vec_any_lt (vector signed char, vector bool char);
14392 int vec_any_lt (vector signed char, vector signed char);
14393 int vec_any_lt (vector bool short, vector unsigned short);
14394 int vec_any_lt (vector unsigned short, vector bool short);
14395 int vec_any_lt (vector unsigned short, vector unsigned short);
14396 int vec_any_lt (vector bool short, vector signed short);
14397 int vec_any_lt (vector signed short, vector bool short);
14398 int vec_any_lt (vector signed short, vector signed short);
14399 int vec_any_lt (vector bool int, vector unsigned int);
14400 int vec_any_lt (vector unsigned int, vector bool int);
14401 int vec_any_lt (vector unsigned int, vector unsigned int);
14402 int vec_any_lt (vector bool int, vector signed int);
14403 int vec_any_lt (vector signed int, vector bool int);
14404 int vec_any_lt (vector signed int, vector signed int);
14405 int vec_any_lt (vector float, vector float);
14407 int vec_any_nan (vector float);
14409 int vec_any_ne (vector signed char, vector bool char);
14410 int vec_any_ne (vector signed char, vector signed char);
14411 int vec_any_ne (vector unsigned char, vector bool char);
14412 int vec_any_ne (vector unsigned char, vector unsigned char);
14413 int vec_any_ne (vector bool char, vector bool char);
14414 int vec_any_ne (vector bool char, vector unsigned char);
14415 int vec_any_ne (vector bool char, vector signed char);
14416 int vec_any_ne (vector signed short, vector bool short);
14417 int vec_any_ne (vector signed short, vector signed short);
14418 int vec_any_ne (vector unsigned short, vector bool short);
14419 int vec_any_ne (vector unsigned short, vector unsigned short);
14420 int vec_any_ne (vector bool short, vector bool short);
14421 int vec_any_ne (vector bool short, vector unsigned short);
14422 int vec_any_ne (vector bool short, vector signed short);
14423 int vec_any_ne (vector pixel, vector pixel);
14424 int vec_any_ne (vector signed int, vector bool int);
14425 int vec_any_ne (vector signed int, vector signed int);
14426 int vec_any_ne (vector unsigned int, vector bool int);
14427 int vec_any_ne (vector unsigned int, vector unsigned int);
14428 int vec_any_ne (vector bool int, vector bool int);
14429 int vec_any_ne (vector bool int, vector unsigned int);
14430 int vec_any_ne (vector bool int, vector signed int);
14431 int vec_any_ne (vector float, vector float);
14433 int vec_any_nge (vector float, vector float);
14435 int vec_any_ngt (vector float, vector float);
14437 int vec_any_nle (vector float, vector float);
14439 int vec_any_nlt (vector float, vector float);
14441 int vec_any_numeric (vector float);
14443 int vec_any_out (vector float, vector float);
14444 @end smallexample
14446 If the vector/scalar (VSX) instruction set is available, the following
14447 additional functions are available:
14449 @smallexample
14450 vector double vec_abs (vector double);
14451 vector double vec_add (vector double, vector double);
14452 vector double vec_and (vector double, vector double);
14453 vector double vec_and (vector double, vector bool long);
14454 vector double vec_and (vector bool long, vector double);
14455 vector long vec_and (vector long, vector long);
14456 vector long vec_and (vector long, vector bool long);
14457 vector long vec_and (vector bool long, vector long);
14458 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
14459 vector unsigned long vec_and (vector unsigned long, vector bool long);
14460 vector unsigned long vec_and (vector bool long, vector unsigned long);
14461 vector double vec_andc (vector double, vector double);
14462 vector double vec_andc (vector double, vector bool long);
14463 vector double vec_andc (vector bool long, vector double);
14464 vector long vec_andc (vector long, vector long);
14465 vector long vec_andc (vector long, vector bool long);
14466 vector long vec_andc (vector bool long, vector long);
14467 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
14468 vector unsigned long vec_andc (vector unsigned long, vector bool long);
14469 vector unsigned long vec_andc (vector bool long, vector unsigned long);
14470 vector double vec_ceil (vector double);
14471 vector bool long vec_cmpeq (vector double, vector double);
14472 vector bool long vec_cmpge (vector double, vector double);
14473 vector bool long vec_cmpgt (vector double, vector double);
14474 vector bool long vec_cmple (vector double, vector double);
14475 vector bool long vec_cmplt (vector double, vector double);
14476 vector double vec_cpsgn (vector double, vector double);
14477 vector float vec_div (vector float, vector float);
14478 vector double vec_div (vector double, vector double);
14479 vector long vec_div (vector long, vector long);
14480 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
14481 vector double vec_floor (vector double);
14482 vector double vec_ld (int, const vector double *);
14483 vector double vec_ld (int, const double *);
14484 vector double vec_ldl (int, const vector double *);
14485 vector double vec_ldl (int, const double *);
14486 vector unsigned char vec_lvsl (int, const volatile double *);
14487 vector unsigned char vec_lvsr (int, const volatile double *);
14488 vector double vec_madd (vector double, vector double, vector double);
14489 vector double vec_max (vector double, vector double);
14490 vector signed long vec_mergeh (vector signed long, vector signed long);
14491 vector signed long vec_mergeh (vector signed long, vector bool long);
14492 vector signed long vec_mergeh (vector bool long, vector signed long);
14493 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
14494 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
14495 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
14496 vector signed long vec_mergel (vector signed long, vector signed long);
14497 vector signed long vec_mergel (vector signed long, vector bool long);
14498 vector signed long vec_mergel (vector bool long, vector signed long);
14499 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
14500 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
14501 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
14502 vector double vec_min (vector double, vector double);
14503 vector float vec_msub (vector float, vector float, vector float);
14504 vector double vec_msub (vector double, vector double, vector double);
14505 vector float vec_mul (vector float, vector float);
14506 vector double vec_mul (vector double, vector double);
14507 vector long vec_mul (vector long, vector long);
14508 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
14509 vector float vec_nearbyint (vector float);
14510 vector double vec_nearbyint (vector double);
14511 vector float vec_nmadd (vector float, vector float, vector float);
14512 vector double vec_nmadd (vector double, vector double, vector double);
14513 vector double vec_nmsub (vector double, vector double, vector double);
14514 vector double vec_nor (vector double, vector double);
14515 vector long vec_nor (vector long, vector long);
14516 vector long vec_nor (vector long, vector bool long);
14517 vector long vec_nor (vector bool long, vector long);
14518 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
14519 vector unsigned long vec_nor (vector unsigned long, vector bool long);
14520 vector unsigned long vec_nor (vector bool long, vector unsigned long);
14521 vector double vec_or (vector double, vector double);
14522 vector double vec_or (vector double, vector bool long);
14523 vector double vec_or (vector bool long, vector double);
14524 vector long vec_or (vector long, vector long);
14525 vector long vec_or (vector long, vector bool long);
14526 vector long vec_or (vector bool long, vector long);
14527 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
14528 vector unsigned long vec_or (vector unsigned long, vector bool long);
14529 vector unsigned long vec_or (vector bool long, vector unsigned long);
14530 vector double vec_perm (vector double, vector double, vector unsigned char);
14531 vector long vec_perm (vector long, vector long, vector unsigned char);
14532 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
14533                                vector unsigned char);
14534 vector double vec_rint (vector double);
14535 vector double vec_recip (vector double, vector double);
14536 vector double vec_rsqrt (vector double);
14537 vector double vec_rsqrte (vector double);
14538 vector double vec_sel (vector double, vector double, vector bool long);
14539 vector double vec_sel (vector double, vector double, vector unsigned long);
14540 vector long vec_sel (vector long, vector long, vector long);
14541 vector long vec_sel (vector long, vector long, vector unsigned long);
14542 vector long vec_sel (vector long, vector long, vector bool long);
14543 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14544                               vector long);
14545 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14546                               vector unsigned long);
14547 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14548                               vector bool long);
14549 vector double vec_splats (double);
14550 vector signed long vec_splats (signed long);
14551 vector unsigned long vec_splats (unsigned long);
14552 vector float vec_sqrt (vector float);
14553 vector double vec_sqrt (vector double);
14554 void vec_st (vector double, int, vector double *);
14555 void vec_st (vector double, int, double *);
14556 vector double vec_sub (vector double, vector double);
14557 vector double vec_trunc (vector double);
14558 vector double vec_xor (vector double, vector double);
14559 vector double vec_xor (vector double, vector bool long);
14560 vector double vec_xor (vector bool long, vector double);
14561 vector long vec_xor (vector long, vector long);
14562 vector long vec_xor (vector long, vector bool long);
14563 vector long vec_xor (vector bool long, vector long);
14564 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
14565 vector unsigned long vec_xor (vector unsigned long, vector bool long);
14566 vector unsigned long vec_xor (vector bool long, vector unsigned long);
14567 int vec_all_eq (vector double, vector double);
14568 int vec_all_ge (vector double, vector double);
14569 int vec_all_gt (vector double, vector double);
14570 int vec_all_le (vector double, vector double);
14571 int vec_all_lt (vector double, vector double);
14572 int vec_all_nan (vector double);
14573 int vec_all_ne (vector double, vector double);
14574 int vec_all_nge (vector double, vector double);
14575 int vec_all_ngt (vector double, vector double);
14576 int vec_all_nle (vector double, vector double);
14577 int vec_all_nlt (vector double, vector double);
14578 int vec_all_numeric (vector double);
14579 int vec_any_eq (vector double, vector double);
14580 int vec_any_ge (vector double, vector double);
14581 int vec_any_gt (vector double, vector double);
14582 int vec_any_le (vector double, vector double);
14583 int vec_any_lt (vector double, vector double);
14584 int vec_any_nan (vector double);
14585 int vec_any_ne (vector double, vector double);
14586 int vec_any_nge (vector double, vector double);
14587 int vec_any_ngt (vector double, vector double);
14588 int vec_any_nle (vector double, vector double);
14589 int vec_any_nlt (vector double, vector double);
14590 int vec_any_numeric (vector double);
14592 vector double vec_vsx_ld (int, const vector double *);
14593 vector double vec_vsx_ld (int, const double *);
14594 vector float vec_vsx_ld (int, const vector float *);
14595 vector float vec_vsx_ld (int, const float *);
14596 vector bool int vec_vsx_ld (int, const vector bool int *);
14597 vector signed int vec_vsx_ld (int, const vector signed int *);
14598 vector signed int vec_vsx_ld (int, const int *);
14599 vector signed int vec_vsx_ld (int, const long *);
14600 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
14601 vector unsigned int vec_vsx_ld (int, const unsigned int *);
14602 vector unsigned int vec_vsx_ld (int, const unsigned long *);
14603 vector bool short vec_vsx_ld (int, const vector bool short *);
14604 vector pixel vec_vsx_ld (int, const vector pixel *);
14605 vector signed short vec_vsx_ld (int, const vector signed short *);
14606 vector signed short vec_vsx_ld (int, const short *);
14607 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
14608 vector unsigned short vec_vsx_ld (int, const unsigned short *);
14609 vector bool char vec_vsx_ld (int, const vector bool char *);
14610 vector signed char vec_vsx_ld (int, const vector signed char *);
14611 vector signed char vec_vsx_ld (int, const signed char *);
14612 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
14613 vector unsigned char vec_vsx_ld (int, const unsigned char *);
14615 void vec_vsx_st (vector double, int, vector double *);
14616 void vec_vsx_st (vector double, int, double *);
14617 void vec_vsx_st (vector float, int, vector float *);
14618 void vec_vsx_st (vector float, int, float *);
14619 void vec_vsx_st (vector signed int, int, vector signed int *);
14620 void vec_vsx_st (vector signed int, int, int *);
14621 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
14622 void vec_vsx_st (vector unsigned int, int, unsigned int *);
14623 void vec_vsx_st (vector bool int, int, vector bool int *);
14624 void vec_vsx_st (vector bool int, int, unsigned int *);
14625 void vec_vsx_st (vector bool int, int, int *);
14626 void vec_vsx_st (vector signed short, int, vector signed short *);
14627 void vec_vsx_st (vector signed short, int, short *);
14628 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
14629 void vec_vsx_st (vector unsigned short, int, unsigned short *);
14630 void vec_vsx_st (vector bool short, int, vector bool short *);
14631 void vec_vsx_st (vector bool short, int, unsigned short *);
14632 void vec_vsx_st (vector pixel, int, vector pixel *);
14633 void vec_vsx_st (vector pixel, int, unsigned short *);
14634 void vec_vsx_st (vector pixel, int, short *);
14635 void vec_vsx_st (vector bool short, int, short *);
14636 void vec_vsx_st (vector signed char, int, vector signed char *);
14637 void vec_vsx_st (vector signed char, int, signed char *);
14638 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
14639 void vec_vsx_st (vector unsigned char, int, unsigned char *);
14640 void vec_vsx_st (vector bool char, int, vector bool char *);
14641 void vec_vsx_st (vector bool char, int, unsigned char *);
14642 void vec_vsx_st (vector bool char, int, signed char *);
14644 vector double vec_xxpermdi (vector double, vector double, int);
14645 vector float vec_xxpermdi (vector float, vector float, int);
14646 vector long long vec_xxpermdi (vector long long, vector long long, int);
14647 vector unsigned long long vec_xxpermdi (vector unsigned long long,
14648                                         vector unsigned long long, int);
14649 vector int vec_xxpermdi (vector int, vector int, int);
14650 vector unsigned int vec_xxpermdi (vector unsigned int,
14651                                   vector unsigned int, int);
14652 vector short vec_xxpermdi (vector short, vector short, int);
14653 vector unsigned short vec_xxpermdi (vector unsigned short,
14654                                     vector unsigned short, int);
14655 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
14656 vector unsigned char vec_xxpermdi (vector unsigned char,
14657                                    vector unsigned char, int);
14659 vector double vec_xxsldi (vector double, vector double, int);
14660 vector float vec_xxsldi (vector float, vector float, int);
14661 vector long long vec_xxsldi (vector long long, vector long long, int);
14662 vector unsigned long long vec_xxsldi (vector unsigned long long,
14663                                       vector unsigned long long, int);
14664 vector int vec_xxsldi (vector int, vector int, int);
14665 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
14666 vector short vec_xxsldi (vector short, vector short, int);
14667 vector unsigned short vec_xxsldi (vector unsigned short,
14668                                   vector unsigned short, int);
14669 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
14670 vector unsigned char vec_xxsldi (vector unsigned char,
14671                                  vector unsigned char, int);
14672 @end smallexample
14674 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
14675 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
14676 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
14677 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
14678 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
14680 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14681 instruction set is available, the following additional functions are
14682 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
14683 can use @var{vector long} instead of @var{vector long long},
14684 @var{vector bool long} instead of @var{vector bool long long}, and
14685 @var{vector unsigned long} instead of @var{vector unsigned long long}.
14687 @smallexample
14688 vector long long vec_abs (vector long long);
14690 vector long long vec_add (vector long long, vector long long);
14691 vector unsigned long long vec_add (vector unsigned long long,
14692                                    vector unsigned long long);
14694 int vec_all_eq (vector long long, vector long long);
14695 int vec_all_eq (vector unsigned long long, vector unsigned long long);
14696 int vec_all_ge (vector long long, vector long long);
14697 int vec_all_ge (vector unsigned long long, vector unsigned long long);
14698 int vec_all_gt (vector long long, vector long long);
14699 int vec_all_gt (vector unsigned long long, vector unsigned long long);
14700 int vec_all_le (vector long long, vector long long);
14701 int vec_all_le (vector unsigned long long, vector unsigned long long);
14702 int vec_all_lt (vector long long, vector long long);
14703 int vec_all_lt (vector unsigned long long, vector unsigned long long);
14704 int vec_all_ne (vector long long, vector long long);
14705 int vec_all_ne (vector unsigned long long, vector unsigned long long);
14707 int vec_any_eq (vector long long, vector long long);
14708 int vec_any_eq (vector unsigned long long, vector unsigned long long);
14709 int vec_any_ge (vector long long, vector long long);
14710 int vec_any_ge (vector unsigned long long, vector unsigned long long);
14711 int vec_any_gt (vector long long, vector long long);
14712 int vec_any_gt (vector unsigned long long, vector unsigned long long);
14713 int vec_any_le (vector long long, vector long long);
14714 int vec_any_le (vector unsigned long long, vector unsigned long long);
14715 int vec_any_lt (vector long long, vector long long);
14716 int vec_any_lt (vector unsigned long long, vector unsigned long long);
14717 int vec_any_ne (vector long long, vector long long);
14718 int vec_any_ne (vector unsigned long long, vector unsigned long long);
14720 vector long long vec_eqv (vector long long, vector long long);
14721 vector long long vec_eqv (vector bool long long, vector long long);
14722 vector long long vec_eqv (vector long long, vector bool long long);
14723 vector unsigned long long vec_eqv (vector unsigned long long,
14724                                    vector unsigned long long);
14725 vector unsigned long long vec_eqv (vector bool long long,
14726                                    vector unsigned long long);
14727 vector unsigned long long vec_eqv (vector unsigned long long,
14728                                    vector bool long long);
14729 vector int vec_eqv (vector int, vector int);
14730 vector int vec_eqv (vector bool int, vector int);
14731 vector int vec_eqv (vector int, vector bool int);
14732 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14733 vector unsigned int vec_eqv (vector bool unsigned int,
14734                              vector unsigned int);
14735 vector unsigned int vec_eqv (vector unsigned int,
14736                              vector bool unsigned int);
14737 vector short vec_eqv (vector short, vector short);
14738 vector short vec_eqv (vector bool short, vector short);
14739 vector short vec_eqv (vector short, vector bool short);
14740 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14741 vector unsigned short vec_eqv (vector bool unsigned short,
14742                                vector unsigned short);
14743 vector unsigned short vec_eqv (vector unsigned short,
14744                                vector bool unsigned short);
14745 vector signed char vec_eqv (vector signed char, vector signed char);
14746 vector signed char vec_eqv (vector bool signed char, vector signed char);
14747 vector signed char vec_eqv (vector signed char, vector bool signed char);
14748 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14749 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14750 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14752 vector long long vec_max (vector long long, vector long long);
14753 vector unsigned long long vec_max (vector unsigned long long,
14754                                    vector unsigned long long);
14756 vector signed int vec_mergee (vector signed int, vector signed int);
14757 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
14758 vector bool int vec_mergee (vector bool int, vector bool int);
14760 vector signed int vec_mergeo (vector signed int, vector signed int);
14761 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
14762 vector bool int vec_mergeo (vector bool int, vector bool int);
14764 vector long long vec_min (vector long long, vector long long);
14765 vector unsigned long long vec_min (vector unsigned long long,
14766                                    vector unsigned long long);
14768 vector long long vec_nand (vector long long, vector long long);
14769 vector long long vec_nand (vector bool long long, vector long long);
14770 vector long long vec_nand (vector long long, vector bool long long);
14771 vector unsigned long long vec_nand (vector unsigned long long,
14772                                     vector unsigned long long);
14773 vector unsigned long long vec_nand (vector bool long long,
14774                                    vector unsigned long long);
14775 vector unsigned long long vec_nand (vector unsigned long long,
14776                                     vector bool long long);
14777 vector int vec_nand (vector int, vector int);
14778 vector int vec_nand (vector bool int, vector int);
14779 vector int vec_nand (vector int, vector bool int);
14780 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14781 vector unsigned int vec_nand (vector bool unsigned int,
14782                               vector unsigned int);
14783 vector unsigned int vec_nand (vector unsigned int,
14784                               vector bool unsigned int);
14785 vector short vec_nand (vector short, vector short);
14786 vector short vec_nand (vector bool short, vector short);
14787 vector short vec_nand (vector short, vector bool short);
14788 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14789 vector unsigned short vec_nand (vector bool unsigned short,
14790                                 vector unsigned short);
14791 vector unsigned short vec_nand (vector unsigned short,
14792                                 vector bool unsigned short);
14793 vector signed char vec_nand (vector signed char, vector signed char);
14794 vector signed char vec_nand (vector bool signed char, vector signed char);
14795 vector signed char vec_nand (vector signed char, vector bool signed char);
14796 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14797 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14798 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14800 vector long long vec_orc (vector long long, vector long long);
14801 vector long long vec_orc (vector bool long long, vector long long);
14802 vector long long vec_orc (vector long long, vector bool long long);
14803 vector unsigned long long vec_orc (vector unsigned long long,
14804                                    vector unsigned long long);
14805 vector unsigned long long vec_orc (vector bool long long,
14806                                    vector unsigned long long);
14807 vector unsigned long long vec_orc (vector unsigned long long,
14808                                    vector bool long long);
14809 vector int vec_orc (vector int, vector int);
14810 vector int vec_orc (vector bool int, vector int);
14811 vector int vec_orc (vector int, vector bool int);
14812 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14813 vector unsigned int vec_orc (vector bool unsigned int,
14814                              vector unsigned int);
14815 vector unsigned int vec_orc (vector unsigned int,
14816                              vector bool unsigned int);
14817 vector short vec_orc (vector short, vector short);
14818 vector short vec_orc (vector bool short, vector short);
14819 vector short vec_orc (vector short, vector bool short);
14820 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14821 vector unsigned short vec_orc (vector bool unsigned short,
14822                                vector unsigned short);
14823 vector unsigned short vec_orc (vector unsigned short,
14824                                vector bool unsigned short);
14825 vector signed char vec_orc (vector signed char, vector signed char);
14826 vector signed char vec_orc (vector bool signed char, vector signed char);
14827 vector signed char vec_orc (vector signed char, vector bool signed char);
14828 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14829 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14830 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14832 vector int vec_pack (vector long long, vector long long);
14833 vector unsigned int vec_pack (vector unsigned long long,
14834                               vector unsigned long long);
14835 vector bool int vec_pack (vector bool long long, vector bool long long);
14837 vector int vec_packs (vector long long, vector long long);
14838 vector unsigned int vec_packs (vector unsigned long long,
14839                                vector unsigned long long);
14841 vector unsigned int vec_packsu (vector long long, vector long long);
14842 vector unsigned int vec_packsu (vector unsigned long long,
14843                                 vector unsigned long long);
14845 vector long long vec_rl (vector long long,
14846                          vector unsigned long long);
14847 vector long long vec_rl (vector unsigned long long,
14848                          vector unsigned long long);
14850 vector long long vec_sl (vector long long, vector unsigned long long);
14851 vector long long vec_sl (vector unsigned long long,
14852                          vector unsigned long long);
14854 vector long long vec_sr (vector long long, vector unsigned long long);
14855 vector unsigned long long char vec_sr (vector unsigned long long,
14856                                        vector unsigned long long);
14858 vector long long vec_sra (vector long long, vector unsigned long long);
14859 vector unsigned long long vec_sra (vector unsigned long long,
14860                                    vector unsigned long long);
14862 vector long long vec_sub (vector long long, vector long long);
14863 vector unsigned long long vec_sub (vector unsigned long long,
14864                                    vector unsigned long long);
14866 vector long long vec_unpackh (vector int);
14867 vector unsigned long long vec_unpackh (vector unsigned int);
14869 vector long long vec_unpackl (vector int);
14870 vector unsigned long long vec_unpackl (vector unsigned int);
14872 vector long long vec_vaddudm (vector long long, vector long long);
14873 vector long long vec_vaddudm (vector bool long long, vector long long);
14874 vector long long vec_vaddudm (vector long long, vector bool long long);
14875 vector unsigned long long vec_vaddudm (vector unsigned long long,
14876                                        vector unsigned long long);
14877 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14878                                        vector unsigned long long);
14879 vector unsigned long long vec_vaddudm (vector unsigned long long,
14880                                        vector bool unsigned long long);
14882 vector long long vec_vbpermq (vector signed char, vector signed char);
14883 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
14885 vector long long vec_cntlz (vector long long);
14886 vector unsigned long long vec_cntlz (vector unsigned long long);
14887 vector int vec_cntlz (vector int);
14888 vector unsigned int vec_cntlz (vector int);
14889 vector short vec_cntlz (vector short);
14890 vector unsigned short vec_cntlz (vector unsigned short);
14891 vector signed char vec_cntlz (vector signed char);
14892 vector unsigned char vec_cntlz (vector unsigned char);
14894 vector long long vec_vclz (vector long long);
14895 vector unsigned long long vec_vclz (vector unsigned long long);
14896 vector int vec_vclz (vector int);
14897 vector unsigned int vec_vclz (vector int);
14898 vector short vec_vclz (vector short);
14899 vector unsigned short vec_vclz (vector unsigned short);
14900 vector signed char vec_vclz (vector signed char);
14901 vector unsigned char vec_vclz (vector unsigned char);
14903 vector signed char vec_vclzb (vector signed char);
14904 vector unsigned char vec_vclzb (vector unsigned char);
14906 vector long long vec_vclzd (vector long long);
14907 vector unsigned long long vec_vclzd (vector unsigned long long);
14909 vector short vec_vclzh (vector short);
14910 vector unsigned short vec_vclzh (vector unsigned short);
14912 vector int vec_vclzw (vector int);
14913 vector unsigned int vec_vclzw (vector int);
14915 vector signed char vec_vgbbd (vector signed char);
14916 vector unsigned char vec_vgbbd (vector unsigned char);
14918 vector long long vec_vmaxsd (vector long long, vector long long);
14920 vector unsigned long long vec_vmaxud (vector unsigned long long,
14921                                       unsigned vector long long);
14923 vector long long vec_vminsd (vector long long, vector long long);
14925 vector unsigned long long vec_vminud (vector long long,
14926                                       vector long long);
14928 vector int vec_vpksdss (vector long long, vector long long);
14929 vector unsigned int vec_vpksdss (vector long long, vector long long);
14931 vector unsigned int vec_vpkudus (vector unsigned long long,
14932                                  vector unsigned long long);
14934 vector int vec_vpkudum (vector long long, vector long long);
14935 vector unsigned int vec_vpkudum (vector unsigned long long,
14936                                  vector unsigned long long);
14937 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
14939 vector long long vec_vpopcnt (vector long long);
14940 vector unsigned long long vec_vpopcnt (vector unsigned long long);
14941 vector int vec_vpopcnt (vector int);
14942 vector unsigned int vec_vpopcnt (vector int);
14943 vector short vec_vpopcnt (vector short);
14944 vector unsigned short vec_vpopcnt (vector unsigned short);
14945 vector signed char vec_vpopcnt (vector signed char);
14946 vector unsigned char vec_vpopcnt (vector unsigned char);
14948 vector signed char vec_vpopcntb (vector signed char);
14949 vector unsigned char vec_vpopcntb (vector unsigned char);
14951 vector long long vec_vpopcntd (vector long long);
14952 vector unsigned long long vec_vpopcntd (vector unsigned long long);
14954 vector short vec_vpopcnth (vector short);
14955 vector unsigned short vec_vpopcnth (vector unsigned short);
14957 vector int vec_vpopcntw (vector int);
14958 vector unsigned int vec_vpopcntw (vector int);
14960 vector long long vec_vrld (vector long long, vector unsigned long long);
14961 vector unsigned long long vec_vrld (vector unsigned long long,
14962                                     vector unsigned long long);
14964 vector long long vec_vsld (vector long long, vector unsigned long long);
14965 vector long long vec_vsld (vector unsigned long long,
14966                            vector unsigned long long);
14968 vector long long vec_vsrad (vector long long, vector unsigned long long);
14969 vector unsigned long long vec_vsrad (vector unsigned long long,
14970                                      vector unsigned long long);
14972 vector long long vec_vsrd (vector long long, vector unsigned long long);
14973 vector unsigned long long char vec_vsrd (vector unsigned long long,
14974                                          vector unsigned long long);
14976 vector long long vec_vsubudm (vector long long, vector long long);
14977 vector long long vec_vsubudm (vector bool long long, vector long long);
14978 vector long long vec_vsubudm (vector long long, vector bool long long);
14979 vector unsigned long long vec_vsubudm (vector unsigned long long,
14980                                        vector unsigned long long);
14981 vector unsigned long long vec_vsubudm (vector bool long long,
14982                                        vector unsigned long long);
14983 vector unsigned long long vec_vsubudm (vector unsigned long long,
14984                                        vector bool long long);
14986 vector long long vec_vupkhsw (vector int);
14987 vector unsigned long long vec_vupkhsw (vector unsigned int);
14989 vector long long vec_vupklsw (vector int);
14990 vector unsigned long long vec_vupklsw (vector int);
14991 @end smallexample
14993 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14994 instruction set is available, the following additional functions are
14995 available for 64-bit targets.  New vector types
14996 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
14997 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
14998 builtins.
15000 The normal vector extract, and set operations work on
15001 @var{vector __int128_t} and @var{vector __uint128_t} types,
15002 but the index value must be 0.
15004 @smallexample
15005 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15006 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15008 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15009 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15011 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15012                                 vector __int128_t);
15013 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
15014                                  vector __uint128_t);
15016 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15017                                 vector __int128_t);
15018 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
15019                                  vector __uint128_t);
15021 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15022                                 vector __int128_t);
15023 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
15024                                  vector __uint128_t);
15026 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15027                                 vector __int128_t);
15028 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
15029                                  vector __uint128_t);
15031 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
15032 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
15034 __int128_t vec_vsubuqm (__int128_t, __int128_t);
15035 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
15037 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
15038 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
15039 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
15040 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
15041 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
15042 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
15043 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
15044 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
15045 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
15046 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
15047 @end smallexample
15049 If the cryptographic instructions are enabled (@option{-mcrypto} or
15050 @option{-mcpu=power8}), the following builtins are enabled.
15052 @smallexample
15053 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
15055 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
15056                                                     vector unsigned long long);
15058 vector unsigned long long __builtin_crypto_vcipherlast
15059                                      (vector unsigned long long,
15060                                       vector unsigned long long);
15062 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
15063                                                      vector unsigned long long);
15065 vector unsigned long long __builtin_crypto_vncipherlast
15066                                      (vector unsigned long long,
15067                                       vector unsigned long long);
15069 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
15070                                                 vector unsigned char,
15071                                                 vector unsigned char);
15073 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
15074                                                  vector unsigned short,
15075                                                  vector unsigned short);
15077 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
15078                                                vector unsigned int,
15079                                                vector unsigned int);
15081 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
15082                                                      vector unsigned long long,
15083                                                      vector unsigned long long);
15085 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
15086                                                vector unsigned char);
15088 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15089                                                 vector unsigned short);
15091 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15092                                               vector unsigned int);
15094 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15095                                                     vector unsigned long long);
15097 vector unsigned long long __builtin_crypto_vshasigmad
15098                                (vector unsigned long long, int, int);
15100 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15101                                                  int, int);
15102 @end smallexample
15104 The second argument to the @var{__builtin_crypto_vshasigmad} and
15105 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15106 integer that is 0 or 1.  The third argument to these builtin functions
15107 must be a constant integer in the range of 0 to 15.
15109 @node PowerPC Hardware Transactional Memory Built-in Functions
15110 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15111 GCC provides two interfaces for accessing the Hardware Transactional
15112 Memory (HTM) instructions available on some of the PowerPC family
15113 of processors (eg, POWER8).  The two interfaces come in a low level
15114 interface, consisting of built-in functions specific to PowerPC and a
15115 higher level interface consisting of inline functions that are common
15116 between PowerPC and S/390.
15118 @subsubsection PowerPC HTM Low Level Built-in Functions
15120 The following low level built-in functions are available with
15121 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15122 They all generate the machine instruction that is part of the name.
15124 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
15125 the full 4-bit condition register value set by their associated hardware
15126 instruction.  The header file @code{htmintrin.h} defines some macros that can
15127 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
15128 returns a simple true or false value depending on whether a transaction was
15129 successfully started or not.  The arguments of the builtins match exactly the
15130 type and order of the associated hardware instruction's operands, except for
15131 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
15132 Refer to the ISA manual for a description of each instruction's operands.
15134 @smallexample
15135 unsigned int __builtin_tbegin (unsigned int)
15136 unsigned int __builtin_tend (unsigned int)
15138 unsigned int __builtin_tabort (unsigned int)
15139 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15140 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15141 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15142 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15144 unsigned int __builtin_tcheck (void)
15145 unsigned int __builtin_treclaim (unsigned int)
15146 unsigned int __builtin_trechkpt (void)
15147 unsigned int __builtin_tsr (unsigned int)
15148 @end smallexample
15150 In addition to the above HTM built-ins, we have added built-ins for
15151 some common extended mnemonics of the HTM instructions:
15153 @smallexample
15154 unsigned int __builtin_tendall (void)
15155 unsigned int __builtin_tresume (void)
15156 unsigned int __builtin_tsuspend (void)
15157 @end smallexample
15159 The following set of built-in functions are available to gain access
15160 to the HTM specific special purpose registers.
15162 @smallexample
15163 unsigned long __builtin_get_texasr (void)
15164 unsigned long __builtin_get_texasru (void)
15165 unsigned long __builtin_get_tfhar (void)
15166 unsigned long __builtin_get_tfiar (void)
15168 void __builtin_set_texasr (unsigned long);
15169 void __builtin_set_texasru (unsigned long);
15170 void __builtin_set_tfhar (unsigned long);
15171 void __builtin_set_tfiar (unsigned long);
15172 @end smallexample
15174 Example usage of these low level built-in functions may look like:
15176 @smallexample
15177 #include <htmintrin.h>
15179 int num_retries = 10;
15181 while (1)
15182   @{
15183     if (__builtin_tbegin (0))
15184       @{
15185         /* Transaction State Initiated.  */
15186         if (is_locked (lock))
15187           __builtin_tabort (0);
15188         ... transaction code...
15189         __builtin_tend (0);
15190         break;
15191       @}
15192     else
15193       @{
15194         /* Transaction State Failed.  Use locks if the transaction
15195            failure is "persistent" or we've tried too many times.  */
15196         if (num_retries-- <= 0
15197             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15198           @{
15199             acquire_lock (lock);
15200             ... non transactional fallback path...
15201             release_lock (lock);
15202             break;
15203           @}
15204       @}
15205   @}
15206 @end smallexample
15208 One final built-in function has been added that returns the value of
15209 the 2-bit Transaction State field of the Machine Status Register (MSR)
15210 as stored in @code{CR0}.
15212 @smallexample
15213 unsigned long __builtin_ttest (void)
15214 @end smallexample
15216 This built-in can be used to determine the current transaction state
15217 using the following code example:
15219 @smallexample
15220 #include <htmintrin.h>
15222 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15224 if (tx_state == _HTM_TRANSACTIONAL)
15225   @{
15226     /* Code to use in transactional state.  */
15227   @}
15228 else if (tx_state == _HTM_NONTRANSACTIONAL)
15229   @{
15230     /* Code to use in non-transactional state.  */
15231   @}
15232 else if (tx_state == _HTM_SUSPENDED)
15233   @{
15234     /* Code to use in transaction suspended state.  */
15235   @}
15236 @end smallexample
15238 @subsubsection PowerPC HTM High Level Inline Functions
15240 The following high level HTM interface is made available by including
15241 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15242 where CPU is `power8' or later.  This interface is common between PowerPC
15243 and S/390, allowing users to write one HTM source implementation that
15244 can be compiled and executed on either system.
15246 @smallexample
15247 long __TM_simple_begin (void)
15248 long __TM_begin (void* const TM_buff)
15249 long __TM_end (void)
15250 void __TM_abort (void)
15251 void __TM_named_abort (unsigned char const code)
15252 void __TM_resume (void)
15253 void __TM_suspend (void)
15255 long __TM_is_user_abort (void* const TM_buff)
15256 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15257 long __TM_is_illegal (void* const TM_buff)
15258 long __TM_is_footprint_exceeded (void* const TM_buff)
15259 long __TM_nesting_depth (void* const TM_buff)
15260 long __TM_is_nested_too_deep(void* const TM_buff)
15261 long __TM_is_conflict(void* const TM_buff)
15262 long __TM_is_failure_persistent(void* const TM_buff)
15263 long __TM_failure_address(void* const TM_buff)
15264 long long __TM_failure_code(void* const TM_buff)
15265 @end smallexample
15267 Using these common set of HTM inline functions, we can create
15268 a more portable version of the HTM example in the previous
15269 section that will work on either PowerPC or S/390:
15271 @smallexample
15272 #include <htmxlintrin.h>
15274 int num_retries = 10;
15275 TM_buff_type TM_buff;
15277 while (1)
15278   @{
15279     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
15280       @{
15281         /* Transaction State Initiated.  */
15282         if (is_locked (lock))
15283           __TM_abort ();
15284         ... transaction code...
15285         __TM_end ();
15286         break;
15287       @}
15288     else
15289       @{
15290         /* Transaction State Failed.  Use locks if the transaction
15291            failure is "persistent" or we've tried too many times.  */
15292         if (num_retries-- <= 0
15293             || __TM_is_failure_persistent (TM_buff))
15294           @{
15295             acquire_lock (lock);
15296             ... non transactional fallback path...
15297             release_lock (lock);
15298             break;
15299           @}
15300       @}
15301   @}
15302 @end smallexample
15304 @node RX Built-in Functions
15305 @subsection RX Built-in Functions
15306 GCC supports some of the RX instructions which cannot be expressed in
15307 the C programming language via the use of built-in functions.  The
15308 following functions are supported:
15310 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
15311 Generates the @code{brk} machine instruction.
15312 @end deftypefn
15314 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
15315 Generates the @code{clrpsw} machine instruction to clear the specified
15316 bit in the processor status word.
15317 @end deftypefn
15319 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
15320 Generates the @code{int} machine instruction to generate an interrupt
15321 with the specified value.
15322 @end deftypefn
15324 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
15325 Generates the @code{machi} machine instruction to add the result of
15326 multiplying the top 16 bits of the two arguments into the
15327 accumulator.
15328 @end deftypefn
15330 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
15331 Generates the @code{maclo} machine instruction to add the result of
15332 multiplying the bottom 16 bits of the two arguments into the
15333 accumulator.
15334 @end deftypefn
15336 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
15337 Generates the @code{mulhi} machine instruction to place the result of
15338 multiplying the top 16 bits of the two arguments into the
15339 accumulator.
15340 @end deftypefn
15342 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
15343 Generates the @code{mullo} machine instruction to place the result of
15344 multiplying the bottom 16 bits of the two arguments into the
15345 accumulator.
15346 @end deftypefn
15348 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
15349 Generates the @code{mvfachi} machine instruction to read the top
15350 32 bits of the accumulator.
15351 @end deftypefn
15353 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
15354 Generates the @code{mvfacmi} machine instruction to read the middle
15355 32 bits of the accumulator.
15356 @end deftypefn
15358 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
15359 Generates the @code{mvfc} machine instruction which reads the control
15360 register specified in its argument and returns its value.
15361 @end deftypefn
15363 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
15364 Generates the @code{mvtachi} machine instruction to set the top
15365 32 bits of the accumulator.
15366 @end deftypefn
15368 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
15369 Generates the @code{mvtaclo} machine instruction to set the bottom
15370 32 bits of the accumulator.
15371 @end deftypefn
15373 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
15374 Generates the @code{mvtc} machine instruction which sets control
15375 register number @code{reg} to @code{val}.
15376 @end deftypefn
15378 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
15379 Generates the @code{mvtipl} machine instruction set the interrupt
15380 priority level.
15381 @end deftypefn
15383 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
15384 Generates the @code{racw} machine instruction to round the accumulator
15385 according to the specified mode.
15386 @end deftypefn
15388 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
15389 Generates the @code{revw} machine instruction which swaps the bytes in
15390 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15391 and also bits 16--23 occupy bits 24--31 and vice versa.
15392 @end deftypefn
15394 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
15395 Generates the @code{rmpa} machine instruction which initiates a
15396 repeated multiply and accumulate sequence.
15397 @end deftypefn
15399 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
15400 Generates the @code{round} machine instruction which returns the
15401 floating-point argument rounded according to the current rounding mode
15402 set in the floating-point status word register.
15403 @end deftypefn
15405 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
15406 Generates the @code{sat} machine instruction which returns the
15407 saturated value of the argument.
15408 @end deftypefn
15410 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
15411 Generates the @code{setpsw} machine instruction to set the specified
15412 bit in the processor status word.
15413 @end deftypefn
15415 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
15416 Generates the @code{wait} machine instruction.
15417 @end deftypefn
15419 @node S/390 System z Built-in Functions
15420 @subsection S/390 System z Built-in Functions
15421 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15422 Generates the @code{tbegin} machine instruction starting a
15423 non-constraint hardware transaction.  If the parameter is non-NULL the
15424 memory area is used to store the transaction diagnostic buffer and
15425 will be passed as first operand to @code{tbegin}.  This buffer can be
15426 defined using the @code{struct __htm_tdb} C struct defined in
15427 @code{htmintrin.h} and must reside on a double-word boundary.  The
15428 second tbegin operand is set to @code{0xff0c}. This enables
15429 save/restore of all GPRs and disables aborts for FPR and AR
15430 manipulations inside the transaction body.  The condition code set by
15431 the tbegin instruction is returned as integer value.  The tbegin
15432 instruction by definition overwrites the content of all FPRs.  The
15433 compiler will generate code which saves and restores the FPRs.  For
15434 soft-float code it is recommended to used the @code{*_nofloat}
15435 variant.  In order to prevent a TDB from being written it is required
15436 to pass an constant zero value as parameter.  Passing the zero value
15437 through a variable is not sufficient.  Although modifications of
15438 access registers inside the transaction will not trigger an
15439 transaction abort it is not supported to actually modify them.  Access
15440 registers do not get saved when entering a transaction. They will have
15441 undefined state when reaching the abort code.
15442 @end deftypefn
15444 Macros for the possible return codes of tbegin are defined in the
15445 @code{htmintrin.h} header file:
15447 @table @code
15448 @item _HTM_TBEGIN_STARTED
15449 @code{tbegin} has been executed as part of normal processing.  The
15450 transaction body is supposed to be executed.
15451 @item _HTM_TBEGIN_INDETERMINATE
15452 The transaction was aborted due to an indeterminate condition which
15453 might be persistent.
15454 @item _HTM_TBEGIN_TRANSIENT
15455 The transaction aborted due to a transient failure.  The transaction
15456 should be re-executed in that case.
15457 @item _HTM_TBEGIN_PERSISTENT
15458 The transaction aborted due to a persistent failure.  Re-execution
15459 under same circumstances will not be productive.
15460 @end table
15462 @defmac _HTM_FIRST_USER_ABORT_CODE
15463 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15464 specifies the first abort code which can be used for
15465 @code{__builtin_tabort}.  Values below this threshold are reserved for
15466 machine use.
15467 @end defmac
15469 @deftp {Data type} {struct __htm_tdb}
15470 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15471 the structure of the transaction diagnostic block as specified in the
15472 Principles of Operation manual chapter 5-91.
15473 @end deftp
15475 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15476 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15477 Using this variant in code making use of FPRs will leave the FPRs in
15478 undefined state when entering the transaction abort handler code.
15479 @end deftypefn
15481 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15482 In addition to @code{__builtin_tbegin} a loop for transient failures
15483 is generated.  If tbegin returns a condition code of 2 the transaction
15484 will be retried as often as specified in the second argument.  The
15485 perform processor assist instruction is used to tell the CPU about the
15486 number of fails so far.
15487 @end deftypefn
15489 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15490 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15491 restores.  Using this variant in code making use of FPRs will leave
15492 the FPRs in undefined state when entering the transaction abort
15493 handler code.
15494 @end deftypefn
15496 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15497 Generates the @code{tbeginc} machine instruction starting a constraint
15498 hardware transaction.  The second operand is set to @code{0xff08}.
15499 @end deftypefn
15501 @deftypefn {Built-in Function} int __builtin_tend (void)
15502 Generates the @code{tend} machine instruction finishing a transaction
15503 and making the changes visible to other threads.  The condition code
15504 generated by tend is returned as integer value.
15505 @end deftypefn
15507 @deftypefn {Built-in Function} void __builtin_tabort (int)
15508 Generates the @code{tabort} machine instruction with the specified
15509 abort code.  Abort codes from 0 through 255 are reserved and will
15510 result in an error message.
15511 @end deftypefn
15513 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15514 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
15515 integer parameter is loaded into rX and a value of zero is loaded into
15516 rY.  The integer parameter specifies the number of times the
15517 transaction repeatedly aborted.
15518 @end deftypefn
15520 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15521 Generates the @code{etnd} machine instruction.  The current nesting
15522 depth is returned as integer value.  For a nesting depth of 0 the code
15523 is not executed as part of an transaction.
15524 @end deftypefn
15526 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15528 Generates the @code{ntstg} machine instruction.  The second argument
15529 is written to the first arguments location.  The store operation will
15530 not be rolled-back in case of an transaction abort.
15531 @end deftypefn
15533 @node SH Built-in Functions
15534 @subsection SH Built-in Functions
15535 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
15536 families of processors:
15538 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
15539 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
15540 used by system code that manages threads and execution contexts.  The compiler
15541 normally does not generate code that modifies the contents of @samp{GBR} and
15542 thus the value is preserved across function calls.  Changing the @samp{GBR}
15543 value in user code must be done with caution, since the compiler might use
15544 @samp{GBR} in order to access thread local variables.
15546 @end deftypefn
15548 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
15549 Returns the value that is currently set in the @samp{GBR} register.
15550 Memory loads and stores that use the thread pointer as a base address are
15551 turned into @samp{GBR} based displacement loads and stores, if possible.
15552 For example:
15553 @smallexample
15554 struct my_tcb
15556    int a, b, c, d, e;
15559 int get_tcb_value (void)
15561   // Generate @samp{mov.l @@(8,gbr),r0} instruction
15562   return ((my_tcb*)__builtin_thread_pointer ())->c;
15565 @end smallexample
15566 @end deftypefn
15568 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
15569 Returns the value that is currently set in the @samp{FPSCR} register.
15570 @end deftypefn
15572 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
15573 Sets the @samp{FPSCR} register to the specified value @var{val}, while
15574 preserving the current values of the FR, SZ and PR bits.
15575 @end deftypefn
15577 @node SPARC VIS Built-in Functions
15578 @subsection SPARC VIS Built-in Functions
15580 GCC supports SIMD operations on the SPARC using both the generic vector
15581 extensions (@pxref{Vector Extensions}) as well as built-in functions for
15582 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
15583 switch, the VIS extension is exposed as the following built-in functions:
15585 @smallexample
15586 typedef int v1si __attribute__ ((vector_size (4)));
15587 typedef int v2si __attribute__ ((vector_size (8)));
15588 typedef short v4hi __attribute__ ((vector_size (8)));
15589 typedef short v2hi __attribute__ ((vector_size (4)));
15590 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
15591 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
15593 void __builtin_vis_write_gsr (int64_t);
15594 int64_t __builtin_vis_read_gsr (void);
15596 void * __builtin_vis_alignaddr (void *, long);
15597 void * __builtin_vis_alignaddrl (void *, long);
15598 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
15599 v2si __builtin_vis_faligndatav2si (v2si, v2si);
15600 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
15601 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
15603 v4hi __builtin_vis_fexpand (v4qi);
15605 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
15606 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
15607 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
15608 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
15609 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
15610 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
15611 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
15613 v4qi __builtin_vis_fpack16 (v4hi);
15614 v8qi __builtin_vis_fpack32 (v2si, v8qi);
15615 v2hi __builtin_vis_fpackfix (v2si);
15616 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
15618 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
15620 long __builtin_vis_edge8 (void *, void *);
15621 long __builtin_vis_edge8l (void *, void *);
15622 long __builtin_vis_edge16 (void *, void *);
15623 long __builtin_vis_edge16l (void *, void *);
15624 long __builtin_vis_edge32 (void *, void *);
15625 long __builtin_vis_edge32l (void *, void *);
15627 long __builtin_vis_fcmple16 (v4hi, v4hi);
15628 long __builtin_vis_fcmple32 (v2si, v2si);
15629 long __builtin_vis_fcmpne16 (v4hi, v4hi);
15630 long __builtin_vis_fcmpne32 (v2si, v2si);
15631 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
15632 long __builtin_vis_fcmpgt32 (v2si, v2si);
15633 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
15634 long __builtin_vis_fcmpeq32 (v2si, v2si);
15636 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
15637 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
15638 v2si __builtin_vis_fpadd32 (v2si, v2si);
15639 v1si __builtin_vis_fpadd32s (v1si, v1si);
15640 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
15641 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
15642 v2si __builtin_vis_fpsub32 (v2si, v2si);
15643 v1si __builtin_vis_fpsub32s (v1si, v1si);
15645 long __builtin_vis_array8 (long, long);
15646 long __builtin_vis_array16 (long, long);
15647 long __builtin_vis_array32 (long, long);
15648 @end smallexample
15650 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
15651 functions also become available:
15653 @smallexample
15654 long __builtin_vis_bmask (long, long);
15655 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
15656 v2si __builtin_vis_bshufflev2si (v2si, v2si);
15657 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
15658 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
15660 long __builtin_vis_edge8n (void *, void *);
15661 long __builtin_vis_edge8ln (void *, void *);
15662 long __builtin_vis_edge16n (void *, void *);
15663 long __builtin_vis_edge16ln (void *, void *);
15664 long __builtin_vis_edge32n (void *, void *);
15665 long __builtin_vis_edge32ln (void *, void *);
15666 @end smallexample
15668 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
15669 functions also become available:
15671 @smallexample
15672 void __builtin_vis_cmask8 (long);
15673 void __builtin_vis_cmask16 (long);
15674 void __builtin_vis_cmask32 (long);
15676 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
15678 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
15679 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
15680 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
15681 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
15682 v2si __builtin_vis_fsll16 (v2si, v2si);
15683 v2si __builtin_vis_fslas16 (v2si, v2si);
15684 v2si __builtin_vis_fsrl16 (v2si, v2si);
15685 v2si __builtin_vis_fsra16 (v2si, v2si);
15687 long __builtin_vis_pdistn (v8qi, v8qi);
15689 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
15691 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
15692 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
15694 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
15695 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
15696 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
15697 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
15698 v2si __builtin_vis_fpadds32 (v2si, v2si);
15699 v1si __builtin_vis_fpadds32s (v1si, v1si);
15700 v2si __builtin_vis_fpsubs32 (v2si, v2si);
15701 v1si __builtin_vis_fpsubs32s (v1si, v1si);
15703 long __builtin_vis_fucmple8 (v8qi, v8qi);
15704 long __builtin_vis_fucmpne8 (v8qi, v8qi);
15705 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
15706 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
15708 float __builtin_vis_fhadds (float, float);
15709 double __builtin_vis_fhaddd (double, double);
15710 float __builtin_vis_fhsubs (float, float);
15711 double __builtin_vis_fhsubd (double, double);
15712 float __builtin_vis_fnhadds (float, float);
15713 double __builtin_vis_fnhaddd (double, double);
15715 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
15716 int64_t __builtin_vis_xmulx (int64_t, int64_t);
15717 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
15718 @end smallexample
15720 @node SPU Built-in Functions
15721 @subsection SPU Built-in Functions
15723 GCC provides extensions for the SPU processor as described in the
15724 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
15725 found at @uref{http://cell.scei.co.jp/} or
15726 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
15727 implementation differs in several ways.
15729 @itemize @bullet
15731 @item
15732 The optional extension of specifying vector constants in parentheses is
15733 not supported.
15735 @item
15736 A vector initializer requires no cast if the vector constant is of the
15737 same type as the variable it is initializing.
15739 @item
15740 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15741 vector type is the default signedness of the base type.  The default
15742 varies depending on the operating system, so a portable program should
15743 always specify the signedness.
15745 @item
15746 By default, the keyword @code{__vector} is added. The macro
15747 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
15748 undefined.
15750 @item
15751 GCC allows using a @code{typedef} name as the type specifier for a
15752 vector type.
15754 @item
15755 For C, overloaded functions are implemented with macros so the following
15756 does not work:
15758 @smallexample
15759   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15760 @end smallexample
15762 @noindent
15763 Since @code{spu_add} is a macro, the vector constant in the example
15764 is treated as four separate arguments.  Wrap the entire argument in
15765 parentheses for this to work.
15767 @item
15768 The extended version of @code{__builtin_expect} is not supported.
15770 @end itemize
15772 @emph{Note:} Only the interface described in the aforementioned
15773 specification is supported. Internally, GCC uses built-in functions to
15774 implement the required functionality, but these are not supported and
15775 are subject to change without notice.
15777 @node TI C6X Built-in Functions
15778 @subsection TI C6X Built-in Functions
15780 GCC provides intrinsics to access certain instructions of the TI C6X
15781 processors.  These intrinsics, listed below, are available after
15782 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
15783 to C6X instructions.
15785 @smallexample
15787 int _sadd (int, int)
15788 int _ssub (int, int)
15789 int _sadd2 (int, int)
15790 int _ssub2 (int, int)
15791 long long _mpy2 (int, int)
15792 long long _smpy2 (int, int)
15793 int _add4 (int, int)
15794 int _sub4 (int, int)
15795 int _saddu4 (int, int)
15797 int _smpy (int, int)
15798 int _smpyh (int, int)
15799 int _smpyhl (int, int)
15800 int _smpylh (int, int)
15802 int _sshl (int, int)
15803 int _subc (int, int)
15805 int _avg2 (int, int)
15806 int _avgu4 (int, int)
15808 int _clrr (int, int)
15809 int _extr (int, int)
15810 int _extru (int, int)
15811 int _abs (int)
15812 int _abs2 (int)
15814 @end smallexample
15816 @node TILE-Gx Built-in Functions
15817 @subsection TILE-Gx Built-in Functions
15819 GCC provides intrinsics to access every instruction of the TILE-Gx
15820 processor.  The intrinsics are of the form:
15822 @smallexample
15824 unsigned long long __insn_@var{op} (...)
15826 @end smallexample
15828 Where @var{op} is the name of the instruction.  Refer to the ISA manual
15829 for the complete list of instructions.
15831 GCC also provides intrinsics to directly access the network registers.
15832 The intrinsics are:
15834 @smallexample
15836 unsigned long long __tile_idn0_receive (void)
15837 unsigned long long __tile_idn1_receive (void)
15838 unsigned long long __tile_udn0_receive (void)
15839 unsigned long long __tile_udn1_receive (void)
15840 unsigned long long __tile_udn2_receive (void)
15841 unsigned long long __tile_udn3_receive (void)
15842 void __tile_idn_send (unsigned long long)
15843 void __tile_udn_send (unsigned long long)
15845 @end smallexample
15847 The intrinsic @code{void __tile_network_barrier (void)} is used to
15848 guarantee that no network operations before it are reordered with
15849 those after it.
15851 @node TILEPro Built-in Functions
15852 @subsection TILEPro Built-in Functions
15854 GCC provides intrinsics to access every instruction of the TILEPro
15855 processor.  The intrinsics are of the form:
15857 @smallexample
15859 unsigned __insn_@var{op} (...)
15861 @end smallexample
15863 @noindent
15864 where @var{op} is the name of the instruction.  Refer to the ISA manual
15865 for the complete list of instructions.
15867 GCC also provides intrinsics to directly access the network registers.
15868 The intrinsics are:
15870 @smallexample
15872 unsigned __tile_idn0_receive (void)
15873 unsigned __tile_idn1_receive (void)
15874 unsigned __tile_sn_receive (void)
15875 unsigned __tile_udn0_receive (void)
15876 unsigned __tile_udn1_receive (void)
15877 unsigned __tile_udn2_receive (void)
15878 unsigned __tile_udn3_receive (void)
15879 void __tile_idn_send (unsigned)
15880 void __tile_sn_send (unsigned)
15881 void __tile_udn_send (unsigned)
15883 @end smallexample
15885 The intrinsic @code{void __tile_network_barrier (void)} is used to
15886 guarantee that no network operations before it are reordered with
15887 those after it.
15889 @node x86 Built-in Functions
15890 @subsection x86 Built-in Functions
15892 These built-in functions are available for the x86-32 and x86-64 family
15893 of computers, depending on the command-line switches used.
15895 If you specify command-line switches such as @option{-msse},
15896 the compiler could use the extended instruction sets even if the built-ins
15897 are not used explicitly in the program.  For this reason, applications
15898 that perform run-time CPU detection must compile separate files for each
15899 supported architecture, using the appropriate flags.  In particular,
15900 the file containing the CPU detection code should be compiled without
15901 these options.
15903 The following machine modes are available for use with MMX built-in functions
15904 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
15905 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
15906 vector of eight 8-bit integers.  Some of the built-in functions operate on
15907 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
15909 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
15910 of two 32-bit floating-point values.
15912 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
15913 floating-point values.  Some instructions use a vector of four 32-bit
15914 integers, these use @code{V4SI}.  Finally, some instructions operate on an
15915 entire vector register, interpreting it as a 128-bit integer, these use mode
15916 @code{TI}.
15918 In 64-bit mode, the x86-64 family of processors uses additional built-in
15919 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
15920 floating point and @code{TC} 128-bit complex floating-point values.
15922 The following floating-point built-in functions are available in 64-bit
15923 mode.  All of them implement the function that is part of the name.
15925 @smallexample
15926 __float128 __builtin_fabsq (__float128)
15927 __float128 __builtin_copysignq (__float128, __float128)
15928 @end smallexample
15930 The following built-in function is always available.
15932 @table @code
15933 @item void __builtin_ia32_pause (void)
15934 Generates the @code{pause} machine instruction with a compiler memory
15935 barrier.
15936 @end table
15938 The following floating-point built-in functions are made available in the
15939 64-bit mode.
15941 @table @code
15942 @item __float128 __builtin_infq (void)
15943 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15944 @findex __builtin_infq
15946 @item __float128 __builtin_huge_valq (void)
15947 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15948 @findex __builtin_huge_valq
15949 @end table
15951 The following built-in functions are always available and can be used to
15952 check the target platform type.
15954 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15955 This function runs the CPU detection code to check the type of CPU and the
15956 features supported.  This built-in function needs to be invoked along with the built-in functions
15957 to check CPU type and features, @code{__builtin_cpu_is} and
15958 @code{__builtin_cpu_supports}, only when used in a function that is
15959 executed before any constructors are called.  The CPU detection code is
15960 automatically executed in a very high priority constructor.
15962 For example, this function has to be used in @code{ifunc} resolvers that
15963 check for CPU type using the built-in functions @code{__builtin_cpu_is}
15964 and @code{__builtin_cpu_supports}, or in constructors on targets that
15965 don't support constructor priority.
15966 @smallexample
15968 static void (*resolve_memcpy (void)) (void)
15970   // ifunc resolvers fire before constructors, explicitly call the init
15971   // function.
15972   __builtin_cpu_init ();
15973   if (__builtin_cpu_supports ("ssse3"))
15974     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
15975   else
15976     return default_memcpy;
15979 void *memcpy (void *, const void *, size_t)
15980      __attribute__ ((ifunc ("resolve_memcpy")));
15981 @end smallexample
15983 @end deftypefn
15985 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15986 This function returns a positive integer if the run-time CPU
15987 is of type @var{cpuname}
15988 and returns @code{0} otherwise. The following CPU names can be detected:
15990 @table @samp
15991 @item intel
15992 Intel CPU.
15994 @item atom
15995 Intel Atom CPU.
15997 @item core2
15998 Intel Core 2 CPU.
16000 @item corei7
16001 Intel Core i7 CPU.
16003 @item nehalem
16004 Intel Core i7 Nehalem CPU.
16006 @item westmere
16007 Intel Core i7 Westmere CPU.
16009 @item sandybridge
16010 Intel Core i7 Sandy Bridge CPU.
16012 @item amd
16013 AMD CPU.
16015 @item amdfam10h
16016 AMD Family 10h CPU.
16018 @item barcelona
16019 AMD Family 10h Barcelona CPU.
16021 @item shanghai
16022 AMD Family 10h Shanghai CPU.
16024 @item istanbul
16025 AMD Family 10h Istanbul CPU.
16027 @item btver1
16028 AMD Family 14h CPU.
16030 @item amdfam15h
16031 AMD Family 15h CPU.
16033 @item bdver1
16034 AMD Family 15h Bulldozer version 1.
16036 @item bdver2
16037 AMD Family 15h Bulldozer version 2.
16039 @item bdver3
16040 AMD Family 15h Bulldozer version 3.
16042 @item bdver4
16043 AMD Family 15h Bulldozer version 4.
16045 @item btver2
16046 AMD Family 16h CPU.
16047 @end table
16049 Here is an example:
16050 @smallexample
16051 if (__builtin_cpu_is ("corei7"))
16052   @{
16053      do_corei7 (); // Core i7 specific implementation.
16054   @}
16055 else
16056   @{
16057      do_generic (); // Generic implementation.
16058   @}
16059 @end smallexample
16060 @end deftypefn
16062 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16063 This function returns a positive integer if the run-time CPU
16064 supports @var{feature}
16065 and returns @code{0} otherwise. The following features can be detected:
16067 @table @samp
16068 @item cmov
16069 CMOV instruction.
16070 @item mmx
16071 MMX instructions.
16072 @item popcnt
16073 POPCNT instruction.
16074 @item sse
16075 SSE instructions.
16076 @item sse2
16077 SSE2 instructions.
16078 @item sse3
16079 SSE3 instructions.
16080 @item ssse3
16081 SSSE3 instructions.
16082 @item sse4.1
16083 SSE4.1 instructions.
16084 @item sse4.2
16085 SSE4.2 instructions.
16086 @item avx
16087 AVX instructions.
16088 @item avx2
16089 AVX2 instructions.
16090 @item avx512f
16091 AVX512F instructions.
16092 @end table
16094 Here is an example:
16095 @smallexample
16096 if (__builtin_cpu_supports ("popcnt"))
16097   @{
16098      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16099   @}
16100 else
16101   @{
16102      count = generic_countbits (n); //generic implementation.
16103   @}
16104 @end smallexample
16105 @end deftypefn
16108 The following built-in functions are made available by @option{-mmmx}.
16109 All of them generate the machine instruction that is part of the name.
16111 @smallexample
16112 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16113 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16114 v2si __builtin_ia32_paddd (v2si, v2si)
16115 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16116 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16117 v2si __builtin_ia32_psubd (v2si, v2si)
16118 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16119 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16120 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16121 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16122 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16123 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16124 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16125 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
16126 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
16127 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
16128 di __builtin_ia32_pand (di, di)
16129 di __builtin_ia32_pandn (di,di)
16130 di __builtin_ia32_por (di, di)
16131 di __builtin_ia32_pxor (di, di)
16132 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
16133 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
16134 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
16135 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
16136 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
16137 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
16138 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
16139 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
16140 v2si __builtin_ia32_punpckhdq (v2si, v2si)
16141 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
16142 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
16143 v2si __builtin_ia32_punpckldq (v2si, v2si)
16144 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
16145 v4hi __builtin_ia32_packssdw (v2si, v2si)
16146 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
16148 v4hi __builtin_ia32_psllw (v4hi, v4hi)
16149 v2si __builtin_ia32_pslld (v2si, v2si)
16150 v1di __builtin_ia32_psllq (v1di, v1di)
16151 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
16152 v2si __builtin_ia32_psrld (v2si, v2si)
16153 v1di __builtin_ia32_psrlq (v1di, v1di)
16154 v4hi __builtin_ia32_psraw (v4hi, v4hi)
16155 v2si __builtin_ia32_psrad (v2si, v2si)
16156 v4hi __builtin_ia32_psllwi (v4hi, int)
16157 v2si __builtin_ia32_pslldi (v2si, int)
16158 v1di __builtin_ia32_psllqi (v1di, int)
16159 v4hi __builtin_ia32_psrlwi (v4hi, int)
16160 v2si __builtin_ia32_psrldi (v2si, int)
16161 v1di __builtin_ia32_psrlqi (v1di, int)
16162 v4hi __builtin_ia32_psrawi (v4hi, int)
16163 v2si __builtin_ia32_psradi (v2si, int)
16165 @end smallexample
16167 The following built-in functions are made available either with
16168 @option{-msse}, or with a combination of @option{-m3dnow} and
16169 @option{-march=athlon}.  All of them generate the machine
16170 instruction that is part of the name.
16172 @smallexample
16173 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
16174 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
16175 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
16176 v1di __builtin_ia32_psadbw (v8qi, v8qi)
16177 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
16178 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
16179 v8qi __builtin_ia32_pminub (v8qi, v8qi)
16180 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
16181 int __builtin_ia32_pmovmskb (v8qi)
16182 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
16183 void __builtin_ia32_movntq (di *, di)
16184 void __builtin_ia32_sfence (void)
16185 @end smallexample
16187 The following built-in functions are available when @option{-msse} is used.
16188 All of them generate the machine instruction that is part of the name.
16190 @smallexample
16191 int __builtin_ia32_comieq (v4sf, v4sf)
16192 int __builtin_ia32_comineq (v4sf, v4sf)
16193 int __builtin_ia32_comilt (v4sf, v4sf)
16194 int __builtin_ia32_comile (v4sf, v4sf)
16195 int __builtin_ia32_comigt (v4sf, v4sf)
16196 int __builtin_ia32_comige (v4sf, v4sf)
16197 int __builtin_ia32_ucomieq (v4sf, v4sf)
16198 int __builtin_ia32_ucomineq (v4sf, v4sf)
16199 int __builtin_ia32_ucomilt (v4sf, v4sf)
16200 int __builtin_ia32_ucomile (v4sf, v4sf)
16201 int __builtin_ia32_ucomigt (v4sf, v4sf)
16202 int __builtin_ia32_ucomige (v4sf, v4sf)
16203 v4sf __builtin_ia32_addps (v4sf, v4sf)
16204 v4sf __builtin_ia32_subps (v4sf, v4sf)
16205 v4sf __builtin_ia32_mulps (v4sf, v4sf)
16206 v4sf __builtin_ia32_divps (v4sf, v4sf)
16207 v4sf __builtin_ia32_addss (v4sf, v4sf)
16208 v4sf __builtin_ia32_subss (v4sf, v4sf)
16209 v4sf __builtin_ia32_mulss (v4sf, v4sf)
16210 v4sf __builtin_ia32_divss (v4sf, v4sf)
16211 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
16212 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
16213 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
16214 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
16215 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
16216 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
16217 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
16218 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
16219 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
16220 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
16221 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
16222 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
16223 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
16224 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
16225 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
16226 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
16227 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
16228 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
16229 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
16230 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
16231 v4sf __builtin_ia32_maxps (v4sf, v4sf)
16232 v4sf __builtin_ia32_maxss (v4sf, v4sf)
16233 v4sf __builtin_ia32_minps (v4sf, v4sf)
16234 v4sf __builtin_ia32_minss (v4sf, v4sf)
16235 v4sf __builtin_ia32_andps (v4sf, v4sf)
16236 v4sf __builtin_ia32_andnps (v4sf, v4sf)
16237 v4sf __builtin_ia32_orps (v4sf, v4sf)
16238 v4sf __builtin_ia32_xorps (v4sf, v4sf)
16239 v4sf __builtin_ia32_movss (v4sf, v4sf)
16240 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
16241 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
16242 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
16243 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
16244 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
16245 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
16246 v2si __builtin_ia32_cvtps2pi (v4sf)
16247 int __builtin_ia32_cvtss2si (v4sf)
16248 v2si __builtin_ia32_cvttps2pi (v4sf)
16249 int __builtin_ia32_cvttss2si (v4sf)
16250 v4sf __builtin_ia32_rcpps (v4sf)
16251 v4sf __builtin_ia32_rsqrtps (v4sf)
16252 v4sf __builtin_ia32_sqrtps (v4sf)
16253 v4sf __builtin_ia32_rcpss (v4sf)
16254 v4sf __builtin_ia32_rsqrtss (v4sf)
16255 v4sf __builtin_ia32_sqrtss (v4sf)
16256 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
16257 void __builtin_ia32_movntps (float *, v4sf)
16258 int __builtin_ia32_movmskps (v4sf)
16259 @end smallexample
16261 The following built-in functions are available when @option{-msse} is used.
16263 @table @code
16264 @item v4sf __builtin_ia32_loadups (float *)
16265 Generates the @code{movups} machine instruction as a load from memory.
16266 @item void __builtin_ia32_storeups (float *, v4sf)
16267 Generates the @code{movups} machine instruction as a store to memory.
16268 @item v4sf __builtin_ia32_loadss (float *)
16269 Generates the @code{movss} machine instruction as a load from memory.
16270 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
16271 Generates the @code{movhps} machine instruction as a load from memory.
16272 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
16273 Generates the @code{movlps} machine instruction as a load from memory
16274 @item void __builtin_ia32_storehps (v2sf *, v4sf)
16275 Generates the @code{movhps} machine instruction as a store to memory.
16276 @item void __builtin_ia32_storelps (v2sf *, v4sf)
16277 Generates the @code{movlps} machine instruction as a store to memory.
16278 @end table
16280 The following built-in functions are available when @option{-msse2} is used.
16281 All of them generate the machine instruction that is part of the name.
16283 @smallexample
16284 int __builtin_ia32_comisdeq (v2df, v2df)
16285 int __builtin_ia32_comisdlt (v2df, v2df)
16286 int __builtin_ia32_comisdle (v2df, v2df)
16287 int __builtin_ia32_comisdgt (v2df, v2df)
16288 int __builtin_ia32_comisdge (v2df, v2df)
16289 int __builtin_ia32_comisdneq (v2df, v2df)
16290 int __builtin_ia32_ucomisdeq (v2df, v2df)
16291 int __builtin_ia32_ucomisdlt (v2df, v2df)
16292 int __builtin_ia32_ucomisdle (v2df, v2df)
16293 int __builtin_ia32_ucomisdgt (v2df, v2df)
16294 int __builtin_ia32_ucomisdge (v2df, v2df)
16295 int __builtin_ia32_ucomisdneq (v2df, v2df)
16296 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
16297 v2df __builtin_ia32_cmpltpd (v2df, v2df)
16298 v2df __builtin_ia32_cmplepd (v2df, v2df)
16299 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
16300 v2df __builtin_ia32_cmpgepd (v2df, v2df)
16301 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
16302 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
16303 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
16304 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
16305 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
16306 v2df __builtin_ia32_cmpngepd (v2df, v2df)
16307 v2df __builtin_ia32_cmpordpd (v2df, v2df)
16308 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
16309 v2df __builtin_ia32_cmpltsd (v2df, v2df)
16310 v2df __builtin_ia32_cmplesd (v2df, v2df)
16311 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
16312 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
16313 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
16314 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
16315 v2df __builtin_ia32_cmpordsd (v2df, v2df)
16316 v2di __builtin_ia32_paddq (v2di, v2di)
16317 v2di __builtin_ia32_psubq (v2di, v2di)
16318 v2df __builtin_ia32_addpd (v2df, v2df)
16319 v2df __builtin_ia32_subpd (v2df, v2df)
16320 v2df __builtin_ia32_mulpd (v2df, v2df)
16321 v2df __builtin_ia32_divpd (v2df, v2df)
16322 v2df __builtin_ia32_addsd (v2df, v2df)
16323 v2df __builtin_ia32_subsd (v2df, v2df)
16324 v2df __builtin_ia32_mulsd (v2df, v2df)
16325 v2df __builtin_ia32_divsd (v2df, v2df)
16326 v2df __builtin_ia32_minpd (v2df, v2df)
16327 v2df __builtin_ia32_maxpd (v2df, v2df)
16328 v2df __builtin_ia32_minsd (v2df, v2df)
16329 v2df __builtin_ia32_maxsd (v2df, v2df)
16330 v2df __builtin_ia32_andpd (v2df, v2df)
16331 v2df __builtin_ia32_andnpd (v2df, v2df)
16332 v2df __builtin_ia32_orpd (v2df, v2df)
16333 v2df __builtin_ia32_xorpd (v2df, v2df)
16334 v2df __builtin_ia32_movsd (v2df, v2df)
16335 v2df __builtin_ia32_unpckhpd (v2df, v2df)
16336 v2df __builtin_ia32_unpcklpd (v2df, v2df)
16337 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
16338 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
16339 v4si __builtin_ia32_paddd128 (v4si, v4si)
16340 v2di __builtin_ia32_paddq128 (v2di, v2di)
16341 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
16342 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
16343 v4si __builtin_ia32_psubd128 (v4si, v4si)
16344 v2di __builtin_ia32_psubq128 (v2di, v2di)
16345 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
16346 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
16347 v2di __builtin_ia32_pand128 (v2di, v2di)
16348 v2di __builtin_ia32_pandn128 (v2di, v2di)
16349 v2di __builtin_ia32_por128 (v2di, v2di)
16350 v2di __builtin_ia32_pxor128 (v2di, v2di)
16351 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
16352 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
16353 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
16354 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
16355 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
16356 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
16357 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
16358 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
16359 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
16360 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
16361 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
16362 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
16363 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
16364 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
16365 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
16366 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
16367 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
16368 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
16369 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
16370 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
16371 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
16372 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
16373 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
16374 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
16375 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
16376 v2df __builtin_ia32_loadupd (double *)
16377 void __builtin_ia32_storeupd (double *, v2df)
16378 v2df __builtin_ia32_loadhpd (v2df, double const *)
16379 v2df __builtin_ia32_loadlpd (v2df, double const *)
16380 int __builtin_ia32_movmskpd (v2df)
16381 int __builtin_ia32_pmovmskb128 (v16qi)
16382 void __builtin_ia32_movnti (int *, int)
16383 void __builtin_ia32_movnti64 (long long int *, long long int)
16384 void __builtin_ia32_movntpd (double *, v2df)
16385 void __builtin_ia32_movntdq (v2df *, v2df)
16386 v4si __builtin_ia32_pshufd (v4si, int)
16387 v8hi __builtin_ia32_pshuflw (v8hi, int)
16388 v8hi __builtin_ia32_pshufhw (v8hi, int)
16389 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
16390 v2df __builtin_ia32_sqrtpd (v2df)
16391 v2df __builtin_ia32_sqrtsd (v2df)
16392 v2df __builtin_ia32_shufpd (v2df, v2df, int)
16393 v2df __builtin_ia32_cvtdq2pd (v4si)
16394 v4sf __builtin_ia32_cvtdq2ps (v4si)
16395 v4si __builtin_ia32_cvtpd2dq (v2df)
16396 v2si __builtin_ia32_cvtpd2pi (v2df)
16397 v4sf __builtin_ia32_cvtpd2ps (v2df)
16398 v4si __builtin_ia32_cvttpd2dq (v2df)
16399 v2si __builtin_ia32_cvttpd2pi (v2df)
16400 v2df __builtin_ia32_cvtpi2pd (v2si)
16401 int __builtin_ia32_cvtsd2si (v2df)
16402 int __builtin_ia32_cvttsd2si (v2df)
16403 long long __builtin_ia32_cvtsd2si64 (v2df)
16404 long long __builtin_ia32_cvttsd2si64 (v2df)
16405 v4si __builtin_ia32_cvtps2dq (v4sf)
16406 v2df __builtin_ia32_cvtps2pd (v4sf)
16407 v4si __builtin_ia32_cvttps2dq (v4sf)
16408 v2df __builtin_ia32_cvtsi2sd (v2df, int)
16409 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
16410 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
16411 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
16412 void __builtin_ia32_clflush (const void *)
16413 void __builtin_ia32_lfence (void)
16414 void __builtin_ia32_mfence (void)
16415 v16qi __builtin_ia32_loaddqu (const char *)
16416 void __builtin_ia32_storedqu (char *, v16qi)
16417 v1di __builtin_ia32_pmuludq (v2si, v2si)
16418 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
16419 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
16420 v4si __builtin_ia32_pslld128 (v4si, v4si)
16421 v2di __builtin_ia32_psllq128 (v2di, v2di)
16422 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
16423 v4si __builtin_ia32_psrld128 (v4si, v4si)
16424 v2di __builtin_ia32_psrlq128 (v2di, v2di)
16425 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
16426 v4si __builtin_ia32_psrad128 (v4si, v4si)
16427 v2di __builtin_ia32_pslldqi128 (v2di, int)
16428 v8hi __builtin_ia32_psllwi128 (v8hi, int)
16429 v4si __builtin_ia32_pslldi128 (v4si, int)
16430 v2di __builtin_ia32_psllqi128 (v2di, int)
16431 v2di __builtin_ia32_psrldqi128 (v2di, int)
16432 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
16433 v4si __builtin_ia32_psrldi128 (v4si, int)
16434 v2di __builtin_ia32_psrlqi128 (v2di, int)
16435 v8hi __builtin_ia32_psrawi128 (v8hi, int)
16436 v4si __builtin_ia32_psradi128 (v4si, int)
16437 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
16438 v2di __builtin_ia32_movq128 (v2di)
16439 @end smallexample
16441 The following built-in functions are available when @option{-msse3} is used.
16442 All of them generate the machine instruction that is part of the name.
16444 @smallexample
16445 v2df __builtin_ia32_addsubpd (v2df, v2df)
16446 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
16447 v2df __builtin_ia32_haddpd (v2df, v2df)
16448 v4sf __builtin_ia32_haddps (v4sf, v4sf)
16449 v2df __builtin_ia32_hsubpd (v2df, v2df)
16450 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
16451 v16qi __builtin_ia32_lddqu (char const *)
16452 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
16453 v4sf __builtin_ia32_movshdup (v4sf)
16454 v4sf __builtin_ia32_movsldup (v4sf)
16455 void __builtin_ia32_mwait (unsigned int, unsigned int)
16456 @end smallexample
16458 The following built-in functions are available when @option{-mssse3} is used.
16459 All of them generate the machine instruction that is part of the name.
16461 @smallexample
16462 v2si __builtin_ia32_phaddd (v2si, v2si)
16463 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
16464 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
16465 v2si __builtin_ia32_phsubd (v2si, v2si)
16466 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
16467 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
16468 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
16469 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
16470 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
16471 v8qi __builtin_ia32_psignb (v8qi, v8qi)
16472 v2si __builtin_ia32_psignd (v2si, v2si)
16473 v4hi __builtin_ia32_psignw (v4hi, v4hi)
16474 v1di __builtin_ia32_palignr (v1di, v1di, int)
16475 v8qi __builtin_ia32_pabsb (v8qi)
16476 v2si __builtin_ia32_pabsd (v2si)
16477 v4hi __builtin_ia32_pabsw (v4hi)
16478 @end smallexample
16480 The following built-in functions are available when @option{-mssse3} is used.
16481 All of them generate the machine instruction that is part of the name.
16483 @smallexample
16484 v4si __builtin_ia32_phaddd128 (v4si, v4si)
16485 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
16486 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
16487 v4si __builtin_ia32_phsubd128 (v4si, v4si)
16488 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
16489 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
16490 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
16491 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
16492 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
16493 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
16494 v4si __builtin_ia32_psignd128 (v4si, v4si)
16495 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
16496 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
16497 v16qi __builtin_ia32_pabsb128 (v16qi)
16498 v4si __builtin_ia32_pabsd128 (v4si)
16499 v8hi __builtin_ia32_pabsw128 (v8hi)
16500 @end smallexample
16502 The following built-in functions are available when @option{-msse4.1} is
16503 used.  All of them generate the machine instruction that is part of the
16504 name.
16506 @smallexample
16507 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
16508 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
16509 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
16510 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
16511 v2df __builtin_ia32_dppd (v2df, v2df, const int)
16512 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
16513 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
16514 v2di __builtin_ia32_movntdqa (v2di *);
16515 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
16516 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
16517 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
16518 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
16519 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
16520 v8hi __builtin_ia32_phminposuw128 (v8hi)
16521 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
16522 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
16523 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
16524 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
16525 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
16526 v4si __builtin_ia32_pminsd128 (v4si, v4si)
16527 v4si __builtin_ia32_pminud128 (v4si, v4si)
16528 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
16529 v4si __builtin_ia32_pmovsxbd128 (v16qi)
16530 v2di __builtin_ia32_pmovsxbq128 (v16qi)
16531 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
16532 v2di __builtin_ia32_pmovsxdq128 (v4si)
16533 v4si __builtin_ia32_pmovsxwd128 (v8hi)
16534 v2di __builtin_ia32_pmovsxwq128 (v8hi)
16535 v4si __builtin_ia32_pmovzxbd128 (v16qi)
16536 v2di __builtin_ia32_pmovzxbq128 (v16qi)
16537 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
16538 v2di __builtin_ia32_pmovzxdq128 (v4si)
16539 v4si __builtin_ia32_pmovzxwd128 (v8hi)
16540 v2di __builtin_ia32_pmovzxwq128 (v8hi)
16541 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
16542 v4si __builtin_ia32_pmulld128 (v4si, v4si)
16543 int __builtin_ia32_ptestc128 (v2di, v2di)
16544 int __builtin_ia32_ptestnzc128 (v2di, v2di)
16545 int __builtin_ia32_ptestz128 (v2di, v2di)
16546 v2df __builtin_ia32_roundpd (v2df, const int)
16547 v4sf __builtin_ia32_roundps (v4sf, const int)
16548 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
16549 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
16550 @end smallexample
16552 The following built-in functions are available when @option{-msse4.1} is
16553 used.
16555 @table @code
16556 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
16557 Generates the @code{insertps} machine instruction.
16558 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
16559 Generates the @code{pextrb} machine instruction.
16560 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
16561 Generates the @code{pinsrb} machine instruction.
16562 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
16563 Generates the @code{pinsrd} machine instruction.
16564 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
16565 Generates the @code{pinsrq} machine instruction in 64bit mode.
16566 @end table
16568 The following built-in functions are changed to generate new SSE4.1
16569 instructions when @option{-msse4.1} is used.
16571 @table @code
16572 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
16573 Generates the @code{extractps} machine instruction.
16574 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
16575 Generates the @code{pextrd} machine instruction.
16576 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
16577 Generates the @code{pextrq} machine instruction in 64bit mode.
16578 @end table
16580 The following built-in functions are available when @option{-msse4.2} is
16581 used.  All of them generate the machine instruction that is part of the
16582 name.
16584 @smallexample
16585 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
16586 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
16587 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
16588 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
16589 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
16590 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
16591 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
16592 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
16593 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
16594 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
16595 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
16596 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
16597 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
16598 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
16599 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
16600 @end smallexample
16602 The following built-in functions are available when @option{-msse4.2} is
16603 used.
16605 @table @code
16606 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
16607 Generates the @code{crc32b} machine instruction.
16608 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
16609 Generates the @code{crc32w} machine instruction.
16610 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
16611 Generates the @code{crc32l} machine instruction.
16612 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
16613 Generates the @code{crc32q} machine instruction.
16614 @end table
16616 The following built-in functions are changed to generate new SSE4.2
16617 instructions when @option{-msse4.2} is used.
16619 @table @code
16620 @item int __builtin_popcount (unsigned int)
16621 Generates the @code{popcntl} machine instruction.
16622 @item int __builtin_popcountl (unsigned long)
16623 Generates the @code{popcntl} or @code{popcntq} machine instruction,
16624 depending on the size of @code{unsigned long}.
16625 @item int __builtin_popcountll (unsigned long long)
16626 Generates the @code{popcntq} machine instruction.
16627 @end table
16629 The following built-in functions are available when @option{-mavx} is
16630 used. All of them generate the machine instruction that is part of the
16631 name.
16633 @smallexample
16634 v4df __builtin_ia32_addpd256 (v4df,v4df)
16635 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
16636 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
16637 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
16638 v4df __builtin_ia32_andnpd256 (v4df,v4df)
16639 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
16640 v4df __builtin_ia32_andpd256 (v4df,v4df)
16641 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
16642 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
16643 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
16644 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
16645 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
16646 v2df __builtin_ia32_cmppd (v2df,v2df,int)
16647 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
16648 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
16649 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
16650 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
16651 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
16652 v4df __builtin_ia32_cvtdq2pd256 (v4si)
16653 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
16654 v4si __builtin_ia32_cvtpd2dq256 (v4df)
16655 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
16656 v8si __builtin_ia32_cvtps2dq256 (v8sf)
16657 v4df __builtin_ia32_cvtps2pd256 (v4sf)
16658 v4si __builtin_ia32_cvttpd2dq256 (v4df)
16659 v8si __builtin_ia32_cvttps2dq256 (v8sf)
16660 v4df __builtin_ia32_divpd256 (v4df,v4df)
16661 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
16662 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
16663 v4df __builtin_ia32_haddpd256 (v4df,v4df)
16664 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
16665 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
16666 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
16667 v32qi __builtin_ia32_lddqu256 (pcchar)
16668 v32qi __builtin_ia32_loaddqu256 (pcchar)
16669 v4df __builtin_ia32_loadupd256 (pcdouble)
16670 v8sf __builtin_ia32_loadups256 (pcfloat)
16671 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
16672 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
16673 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
16674 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
16675 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
16676 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
16677 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
16678 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
16679 v4df __builtin_ia32_maxpd256 (v4df,v4df)
16680 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
16681 v4df __builtin_ia32_minpd256 (v4df,v4df)
16682 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
16683 v4df __builtin_ia32_movddup256 (v4df)
16684 int __builtin_ia32_movmskpd256 (v4df)
16685 int __builtin_ia32_movmskps256 (v8sf)
16686 v8sf __builtin_ia32_movshdup256 (v8sf)
16687 v8sf __builtin_ia32_movsldup256 (v8sf)
16688 v4df __builtin_ia32_mulpd256 (v4df,v4df)
16689 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
16690 v4df __builtin_ia32_orpd256 (v4df,v4df)
16691 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
16692 v2df __builtin_ia32_pd_pd256 (v4df)
16693 v4df __builtin_ia32_pd256_pd (v2df)
16694 v4sf __builtin_ia32_ps_ps256 (v8sf)
16695 v8sf __builtin_ia32_ps256_ps (v4sf)
16696 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
16697 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
16698 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
16699 v8sf __builtin_ia32_rcpps256 (v8sf)
16700 v4df __builtin_ia32_roundpd256 (v4df,int)
16701 v8sf __builtin_ia32_roundps256 (v8sf,int)
16702 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
16703 v8sf __builtin_ia32_rsqrtps256 (v8sf)
16704 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
16705 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
16706 v4si __builtin_ia32_si_si256 (v8si)
16707 v8si __builtin_ia32_si256_si (v4si)
16708 v4df __builtin_ia32_sqrtpd256 (v4df)
16709 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
16710 v8sf __builtin_ia32_sqrtps256 (v8sf)
16711 void __builtin_ia32_storedqu256 (pchar,v32qi)
16712 void __builtin_ia32_storeupd256 (pdouble,v4df)
16713 void __builtin_ia32_storeups256 (pfloat,v8sf)
16714 v4df __builtin_ia32_subpd256 (v4df,v4df)
16715 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
16716 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
16717 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
16718 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
16719 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
16720 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
16721 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
16722 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
16723 v4sf __builtin_ia32_vbroadcastss (pcfloat)
16724 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
16725 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
16726 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
16727 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
16728 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
16729 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
16730 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
16731 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
16732 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
16733 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
16734 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
16735 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
16736 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
16737 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
16738 v2df __builtin_ia32_vpermilpd (v2df,int)
16739 v4df __builtin_ia32_vpermilpd256 (v4df,int)
16740 v4sf __builtin_ia32_vpermilps (v4sf,int)
16741 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
16742 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
16743 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
16744 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
16745 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
16746 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
16747 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
16748 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
16749 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
16750 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
16751 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
16752 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
16753 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
16754 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
16755 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
16756 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
16757 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
16758 void __builtin_ia32_vzeroall (void)
16759 void __builtin_ia32_vzeroupper (void)
16760 v4df __builtin_ia32_xorpd256 (v4df,v4df)
16761 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
16762 @end smallexample
16764 The following built-in functions are available when @option{-mavx2} is
16765 used. All of them generate the machine instruction that is part of the
16766 name.
16768 @smallexample
16769 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
16770 v32qi __builtin_ia32_pabsb256 (v32qi)
16771 v16hi __builtin_ia32_pabsw256 (v16hi)
16772 v8si __builtin_ia32_pabsd256 (v8si)
16773 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
16774 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
16775 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
16776 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
16777 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
16778 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
16779 v8si __builtin_ia32_paddd256 (v8si,v8si)
16780 v4di __builtin_ia32_paddq256 (v4di,v4di)
16781 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
16782 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
16783 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
16784 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
16785 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
16786 v4di __builtin_ia32_andsi256 (v4di,v4di)
16787 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
16788 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
16789 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
16790 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
16791 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
16792 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
16793 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
16794 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
16795 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
16796 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
16797 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
16798 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
16799 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
16800 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
16801 v8si __builtin_ia32_phaddd256 (v8si,v8si)
16802 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
16803 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
16804 v8si __builtin_ia32_phsubd256 (v8si,v8si)
16805 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
16806 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
16807 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
16808 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
16809 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
16810 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
16811 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
16812 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
16813 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
16814 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
16815 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
16816 v8si __builtin_ia32_pminsd256 (v8si,v8si)
16817 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
16818 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
16819 v8si __builtin_ia32_pminud256 (v8si,v8si)
16820 int __builtin_ia32_pmovmskb256 (v32qi)
16821 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
16822 v8si __builtin_ia32_pmovsxbd256 (v16qi)
16823 v4di __builtin_ia32_pmovsxbq256 (v16qi)
16824 v8si __builtin_ia32_pmovsxwd256 (v8hi)
16825 v4di __builtin_ia32_pmovsxwq256 (v8hi)
16826 v4di __builtin_ia32_pmovsxdq256 (v4si)
16827 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
16828 v8si __builtin_ia32_pmovzxbd256 (v16qi)
16829 v4di __builtin_ia32_pmovzxbq256 (v16qi)
16830 v8si __builtin_ia32_pmovzxwd256 (v8hi)
16831 v4di __builtin_ia32_pmovzxwq256 (v8hi)
16832 v4di __builtin_ia32_pmovzxdq256 (v4si)
16833 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
16834 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
16835 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
16836 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
16837 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
16838 v8si __builtin_ia32_pmulld256 (v8si,v8si)
16839 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
16840 v4di __builtin_ia32_por256 (v4di,v4di)
16841 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
16842 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
16843 v8si __builtin_ia32_pshufd256 (v8si,int)
16844 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
16845 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
16846 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
16847 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
16848 v8si __builtin_ia32_psignd256 (v8si,v8si)
16849 v4di __builtin_ia32_pslldqi256 (v4di,int)
16850 v16hi __builtin_ia32_psllwi256 (16hi,int)
16851 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
16852 v8si __builtin_ia32_pslldi256 (v8si,int)
16853 v8si __builtin_ia32_pslld256(v8si,v4si)
16854 v4di __builtin_ia32_psllqi256 (v4di,int)
16855 v4di __builtin_ia32_psllq256(v4di,v2di)
16856 v16hi __builtin_ia32_psrawi256 (v16hi,int)
16857 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
16858 v8si __builtin_ia32_psradi256 (v8si,int)
16859 v8si __builtin_ia32_psrad256 (v8si,v4si)
16860 v4di __builtin_ia32_psrldqi256 (v4di, int)
16861 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
16862 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
16863 v8si __builtin_ia32_psrldi256 (v8si,int)
16864 v8si __builtin_ia32_psrld256 (v8si,v4si)
16865 v4di __builtin_ia32_psrlqi256 (v4di,int)
16866 v4di __builtin_ia32_psrlq256(v4di,v2di)
16867 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
16868 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
16869 v8si __builtin_ia32_psubd256 (v8si,v8si)
16870 v4di __builtin_ia32_psubq256 (v4di,v4di)
16871 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
16872 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
16873 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
16874 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
16875 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
16876 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
16877 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
16878 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
16879 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
16880 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
16881 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
16882 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
16883 v4di __builtin_ia32_pxor256 (v4di,v4di)
16884 v4di __builtin_ia32_movntdqa256 (pv4di)
16885 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
16886 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
16887 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
16888 v4di __builtin_ia32_vbroadcastsi256 (v2di)
16889 v4si __builtin_ia32_pblendd128 (v4si,v4si)
16890 v8si __builtin_ia32_pblendd256 (v8si,v8si)
16891 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
16892 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
16893 v8si __builtin_ia32_pbroadcastd256 (v4si)
16894 v4di __builtin_ia32_pbroadcastq256 (v2di)
16895 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
16896 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
16897 v4si __builtin_ia32_pbroadcastd128 (v4si)
16898 v2di __builtin_ia32_pbroadcastq128 (v2di)
16899 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
16900 v4df __builtin_ia32_permdf256 (v4df,int)
16901 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
16902 v4di __builtin_ia32_permdi256 (v4di,int)
16903 v4di __builtin_ia32_permti256 (v4di,v4di,int)
16904 v4di __builtin_ia32_extract128i256 (v4di,int)
16905 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
16906 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
16907 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
16908 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
16909 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
16910 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
16911 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
16912 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
16913 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
16914 v8si __builtin_ia32_psllv8si (v8si,v8si)
16915 v4si __builtin_ia32_psllv4si (v4si,v4si)
16916 v4di __builtin_ia32_psllv4di (v4di,v4di)
16917 v2di __builtin_ia32_psllv2di (v2di,v2di)
16918 v8si __builtin_ia32_psrav8si (v8si,v8si)
16919 v4si __builtin_ia32_psrav4si (v4si,v4si)
16920 v8si __builtin_ia32_psrlv8si (v8si,v8si)
16921 v4si __builtin_ia32_psrlv4si (v4si,v4si)
16922 v4di __builtin_ia32_psrlv4di (v4di,v4di)
16923 v2di __builtin_ia32_psrlv2di (v2di,v2di)
16924 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
16925 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
16926 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
16927 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
16928 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
16929 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
16930 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
16931 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
16932 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
16933 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
16934 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
16935 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
16936 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
16937 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
16938 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
16939 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
16940 @end smallexample
16942 The following built-in functions are available when @option{-maes} is
16943 used.  All of them generate the machine instruction that is part of the
16944 name.
16946 @smallexample
16947 v2di __builtin_ia32_aesenc128 (v2di, v2di)
16948 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
16949 v2di __builtin_ia32_aesdec128 (v2di, v2di)
16950 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
16951 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
16952 v2di __builtin_ia32_aesimc128 (v2di)
16953 @end smallexample
16955 The following built-in function is available when @option{-mpclmul} is
16956 used.
16958 @table @code
16959 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
16960 Generates the @code{pclmulqdq} machine instruction.
16961 @end table
16963 The following built-in function is available when @option{-mfsgsbase} is
16964 used.  All of them generate the machine instruction that is part of the
16965 name.
16967 @smallexample
16968 unsigned int __builtin_ia32_rdfsbase32 (void)
16969 unsigned long long __builtin_ia32_rdfsbase64 (void)
16970 unsigned int __builtin_ia32_rdgsbase32 (void)
16971 unsigned long long __builtin_ia32_rdgsbase64 (void)
16972 void _writefsbase_u32 (unsigned int)
16973 void _writefsbase_u64 (unsigned long long)
16974 void _writegsbase_u32 (unsigned int)
16975 void _writegsbase_u64 (unsigned long long)
16976 @end smallexample
16978 The following built-in function is available when @option{-mrdrnd} is
16979 used.  All of them generate the machine instruction that is part of the
16980 name.
16982 @smallexample
16983 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
16984 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
16985 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
16986 @end smallexample
16988 The following built-in functions are available when @option{-msse4a} is used.
16989 All of them generate the machine instruction that is part of the name.
16991 @smallexample
16992 void __builtin_ia32_movntsd (double *, v2df)
16993 void __builtin_ia32_movntss (float *, v4sf)
16994 v2di __builtin_ia32_extrq  (v2di, v16qi)
16995 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
16996 v2di __builtin_ia32_insertq (v2di, v2di)
16997 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
16998 @end smallexample
17000 The following built-in functions are available when @option{-mxop} is used.
17001 @smallexample
17002 v2df __builtin_ia32_vfrczpd (v2df)
17003 v4sf __builtin_ia32_vfrczps (v4sf)
17004 v2df __builtin_ia32_vfrczsd (v2df)
17005 v4sf __builtin_ia32_vfrczss (v4sf)
17006 v4df __builtin_ia32_vfrczpd256 (v4df)
17007 v8sf __builtin_ia32_vfrczps256 (v8sf)
17008 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
17009 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
17010 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
17011 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
17012 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
17013 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
17014 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
17015 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
17016 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
17017 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
17018 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
17019 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
17020 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
17021 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
17022 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17023 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
17024 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
17025 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
17026 v4si __builtin_ia32_vpcomequd (v4si, v4si)
17027 v2di __builtin_ia32_vpcomequq (v2di, v2di)
17028 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
17029 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
17030 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
17031 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
17032 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
17033 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
17034 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
17035 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
17036 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
17037 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
17038 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
17039 v4si __builtin_ia32_vpcomged (v4si, v4si)
17040 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
17041 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
17042 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
17043 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
17044 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
17045 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
17046 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
17047 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
17048 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
17049 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
17050 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
17051 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
17052 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
17053 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
17054 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
17055 v4si __builtin_ia32_vpcomled (v4si, v4si)
17056 v2di __builtin_ia32_vpcomleq (v2di, v2di)
17057 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
17058 v4si __builtin_ia32_vpcomleud (v4si, v4si)
17059 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
17060 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
17061 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
17062 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
17063 v4si __builtin_ia32_vpcomltd (v4si, v4si)
17064 v2di __builtin_ia32_vpcomltq (v2di, v2di)
17065 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
17066 v4si __builtin_ia32_vpcomltud (v4si, v4si)
17067 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
17068 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
17069 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
17070 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
17071 v4si __builtin_ia32_vpcomned (v4si, v4si)
17072 v2di __builtin_ia32_vpcomneq (v2di, v2di)
17073 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
17074 v4si __builtin_ia32_vpcomneud (v4si, v4si)
17075 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
17076 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
17077 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
17078 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
17079 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
17080 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
17081 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
17082 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
17083 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
17084 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
17085 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
17086 v4si __builtin_ia32_vphaddbd (v16qi)
17087 v2di __builtin_ia32_vphaddbq (v16qi)
17088 v8hi __builtin_ia32_vphaddbw (v16qi)
17089 v2di __builtin_ia32_vphadddq (v4si)
17090 v4si __builtin_ia32_vphaddubd (v16qi)
17091 v2di __builtin_ia32_vphaddubq (v16qi)
17092 v8hi __builtin_ia32_vphaddubw (v16qi)
17093 v2di __builtin_ia32_vphaddudq (v4si)
17094 v4si __builtin_ia32_vphadduwd (v8hi)
17095 v2di __builtin_ia32_vphadduwq (v8hi)
17096 v4si __builtin_ia32_vphaddwd (v8hi)
17097 v2di __builtin_ia32_vphaddwq (v8hi)
17098 v8hi __builtin_ia32_vphsubbw (v16qi)
17099 v2di __builtin_ia32_vphsubdq (v4si)
17100 v4si __builtin_ia32_vphsubwd (v8hi)
17101 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17102 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17103 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17104 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17105 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17106 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17107 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17108 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17109 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17110 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17111 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17112 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17113 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17114 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17115 v4si __builtin_ia32_vprotd (v4si, v4si)
17116 v2di __builtin_ia32_vprotq (v2di, v2di)
17117 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17118 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17119 v4si __builtin_ia32_vpshad (v4si, v4si)
17120 v2di __builtin_ia32_vpshaq (v2di, v2di)
17121 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17122 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17123 v4si __builtin_ia32_vpshld (v4si, v4si)
17124 v2di __builtin_ia32_vpshlq (v2di, v2di)
17125 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
17126 @end smallexample
17128 The following built-in functions are available when @option{-mfma4} is used.
17129 All of them generate the machine instruction that is part of the name.
17131 @smallexample
17132 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
17133 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
17134 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
17135 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
17136 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
17137 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
17138 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
17139 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
17140 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
17141 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
17142 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
17143 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
17144 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
17145 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
17146 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
17147 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
17148 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
17149 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
17150 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
17151 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
17152 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
17153 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
17154 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
17155 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
17156 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
17157 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
17158 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
17159 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
17160 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
17161 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
17162 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
17163 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
17165 @end smallexample
17167 The following built-in functions are available when @option{-mlwp} is used.
17169 @smallexample
17170 void __builtin_ia32_llwpcb16 (void *);
17171 void __builtin_ia32_llwpcb32 (void *);
17172 void __builtin_ia32_llwpcb64 (void *);
17173 void * __builtin_ia32_llwpcb16 (void);
17174 void * __builtin_ia32_llwpcb32 (void);
17175 void * __builtin_ia32_llwpcb64 (void);
17176 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
17177 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
17178 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
17179 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
17180 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
17181 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
17182 @end smallexample
17184 The following built-in functions are available when @option{-mbmi} is used.
17185 All of them generate the machine instruction that is part of the name.
17186 @smallexample
17187 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
17188 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
17189 @end smallexample
17191 The following built-in functions are available when @option{-mbmi2} is used.
17192 All of them generate the machine instruction that is part of the name.
17193 @smallexample
17194 unsigned int _bzhi_u32 (unsigned int, unsigned int)
17195 unsigned int _pdep_u32 (unsigned int, unsigned int)
17196 unsigned int _pext_u32 (unsigned int, unsigned int)
17197 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
17198 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
17199 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
17200 @end smallexample
17202 The following built-in functions are available when @option{-mlzcnt} is used.
17203 All of them generate the machine instruction that is part of the name.
17204 @smallexample
17205 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
17206 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
17207 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
17208 @end smallexample
17210 The following built-in functions are available when @option{-mfxsr} is used.
17211 All of them generate the machine instruction that is part of the name.
17212 @smallexample
17213 void __builtin_ia32_fxsave (void *)
17214 void __builtin_ia32_fxrstor (void *)
17215 void __builtin_ia32_fxsave64 (void *)
17216 void __builtin_ia32_fxrstor64 (void *)
17217 @end smallexample
17219 The following built-in functions are available when @option{-mxsave} is used.
17220 All of them generate the machine instruction that is part of the name.
17221 @smallexample
17222 void __builtin_ia32_xsave (void *, long long)
17223 void __builtin_ia32_xrstor (void *, long long)
17224 void __builtin_ia32_xsave64 (void *, long long)
17225 void __builtin_ia32_xrstor64 (void *, long long)
17226 @end smallexample
17228 The following built-in functions are available when @option{-mxsaveopt} is used.
17229 All of them generate the machine instruction that is part of the name.
17230 @smallexample
17231 void __builtin_ia32_xsaveopt (void *, long long)
17232 void __builtin_ia32_xsaveopt64 (void *, long long)
17233 @end smallexample
17235 The following built-in functions are available when @option{-mtbm} is used.
17236 Both of them generate the immediate form of the bextr machine instruction.
17237 @smallexample
17238 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
17239 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
17240 @end smallexample
17243 The following built-in functions are available when @option{-m3dnow} is used.
17244 All of them generate the machine instruction that is part of the name.
17246 @smallexample
17247 void __builtin_ia32_femms (void)
17248 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
17249 v2si __builtin_ia32_pf2id (v2sf)
17250 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
17251 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
17252 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
17253 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
17254 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
17255 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
17256 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
17257 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
17258 v2sf __builtin_ia32_pfrcp (v2sf)
17259 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
17260 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
17261 v2sf __builtin_ia32_pfrsqrt (v2sf)
17262 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
17263 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
17264 v2sf __builtin_ia32_pi2fd (v2si)
17265 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
17266 @end smallexample
17268 The following built-in functions are available when both @option{-m3dnow}
17269 and @option{-march=athlon} are used.  All of them generate the machine
17270 instruction that is part of the name.
17272 @smallexample
17273 v2si __builtin_ia32_pf2iw (v2sf)
17274 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
17275 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
17276 v2sf __builtin_ia32_pi2fw (v2si)
17277 v2sf __builtin_ia32_pswapdsf (v2sf)
17278 v2si __builtin_ia32_pswapdsi (v2si)
17279 @end smallexample
17281 The following built-in functions are available when @option{-mrtm} is used
17282 They are used for restricted transactional memory. These are the internal
17283 low level functions. Normally the functions in 
17284 @ref{x86 transactional memory intrinsics} should be used instead.
17286 @smallexample
17287 int __builtin_ia32_xbegin ()
17288 void __builtin_ia32_xend ()
17289 void __builtin_ia32_xabort (status)
17290 int __builtin_ia32_xtest ()
17291 @end smallexample
17293 @node x86 transactional memory intrinsics
17294 @subsection x86 Transactional Memory Intrinsics
17296 These hardware transactional memory intrinsics for x86 allow you to use
17297 memory transactions with RTM (Restricted Transactional Memory).
17298 This support is enabled with the @option{-mrtm} option.
17299 For using HLE (Hardware Lock Elision) see 
17300 @ref{x86 specific memory model extensions for transactional memory} instead.
17302 A memory transaction commits all changes to memory in an atomic way,
17303 as visible to other threads. If the transaction fails it is rolled back
17304 and all side effects discarded.
17306 Generally there is no guarantee that a memory transaction ever succeeds
17307 and suitable fallback code always needs to be supplied.
17309 @deftypefn {RTM Function} {unsigned} _xbegin ()
17310 Start a RTM (Restricted Transactional Memory) transaction. 
17311 Returns @code{_XBEGIN_STARTED} when the transaction
17312 started successfully (note this is not 0, so the constant has to be 
17313 explicitly tested).  
17315 If the transaction aborts, all side-effects 
17316 are undone and an abort code encoded as a bit mask is returned.
17317 The following macros are defined:
17319 @table @code
17320 @item _XABORT_EXPLICIT
17321 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
17322 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
17323 @item _XABORT_RETRY
17324 Transaction retry is possible.
17325 @item _XABORT_CONFLICT
17326 Transaction abort due to a memory conflict with another thread.
17327 @item _XABORT_CAPACITY
17328 Transaction abort due to the transaction using too much memory.
17329 @item _XABORT_DEBUG
17330 Transaction abort due to a debug trap.
17331 @item _XABORT_NESTED
17332 Transaction abort in an inner nested transaction.
17333 @end table
17335 There is no guarantee
17336 any transaction ever succeeds, so there always needs to be a valid
17337 fallback path.
17338 @end deftypefn
17340 @deftypefn {RTM Function} {void} _xend ()
17341 Commit the current transaction. When no transaction is active this faults.
17342 All memory side-effects of the transaction become visible
17343 to other threads in an atomic manner.
17344 @end deftypefn
17346 @deftypefn {RTM Function} {int} _xtest ()
17347 Return a nonzero value if a transaction is currently active, otherwise 0.
17348 @end deftypefn
17350 @deftypefn {RTM Function} {void} _xabort (status)
17351 Abort the current transaction. When no transaction is active this is a no-op.
17352 The @var{status} is an 8-bit constant; its value is encoded in the return 
17353 value from @code{_xbegin}.
17354 @end deftypefn
17356 Here is an example showing handling for @code{_XABORT_RETRY}
17357 and a fallback path for other failures:
17359 @smallexample
17360 #include <immintrin.h>
17362 int n_tries, max_tries;
17363 unsigned status = _XABORT_EXPLICIT;
17366 for (n_tries = 0; n_tries < max_tries; n_tries++) 
17367   @{
17368     status = _xbegin ();
17369     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
17370       break;
17371   @}
17372 if (status == _XBEGIN_STARTED) 
17373   @{
17374     ... transaction code...
17375     _xend ();
17376   @} 
17377 else 
17378   @{
17379     ... non-transactional fallback path...
17380   @}
17381 @end smallexample
17383 @noindent
17384 Note that, in most cases, the transactional and non-transactional code
17385 must synchronize together to ensure consistency.
17387 @node Target Format Checks
17388 @section Format Checks Specific to Particular Target Machines
17390 For some target machines, GCC supports additional options to the
17391 format attribute
17392 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17394 @menu
17395 * Solaris Format Checks::
17396 * Darwin Format Checks::
17397 @end menu
17399 @node Solaris Format Checks
17400 @subsection Solaris Format Checks
17402 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17403 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17404 conversions, and the two-argument @code{%b} conversion for displaying
17405 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17407 @node Darwin Format Checks
17408 @subsection Darwin Format Checks
17410 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17411 attribute context.  Declarations made with such attribution are parsed for correct syntax
17412 and format argument types.  However, parsing of the format string itself is currently undefined
17413 and is not carried out by this version of the compiler.
17415 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17416 also be used as format arguments.  Note that the relevant headers are only likely to be
17417 available on Darwin (OSX) installations.  On such installations, the XCode and system
17418 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17419 associated functions.
17421 @node Pragmas
17422 @section Pragmas Accepted by GCC
17423 @cindex pragmas
17424 @cindex @code{#pragma}
17426 GCC supports several types of pragmas, primarily in order to compile
17427 code originally written for other compilers.  Note that in general
17428 we do not recommend the use of pragmas; @xref{Function Attributes},
17429 for further explanation.
17431 @menu
17432 * ARM Pragmas::
17433 * M32C Pragmas::
17434 * MeP Pragmas::
17435 * RS/6000 and PowerPC Pragmas::
17436 * Darwin Pragmas::
17437 * Solaris Pragmas::
17438 * Symbol-Renaming Pragmas::
17439 * Structure-Packing Pragmas::
17440 * Weak Pragmas::
17441 * Diagnostic Pragmas::
17442 * Visibility Pragmas::
17443 * Push/Pop Macro Pragmas::
17444 * Function Specific Option Pragmas::
17445 * Loop-Specific Pragmas::
17446 @end menu
17448 @node ARM Pragmas
17449 @subsection ARM Pragmas
17451 The ARM target defines pragmas for controlling the default addition of
17452 @code{long_call} and @code{short_call} attributes to functions.
17453 @xref{Function Attributes}, for information about the effects of these
17454 attributes.
17456 @table @code
17457 @item long_calls
17458 @cindex pragma, long_calls
17459 Set all subsequent functions to have the @code{long_call} attribute.
17461 @item no_long_calls
17462 @cindex pragma, no_long_calls
17463 Set all subsequent functions to have the @code{short_call} attribute.
17465 @item long_calls_off
17466 @cindex pragma, long_calls_off
17467 Do not affect the @code{long_call} or @code{short_call} attributes of
17468 subsequent functions.
17469 @end table
17471 @node M32C Pragmas
17472 @subsection M32C Pragmas
17474 @table @code
17475 @item GCC memregs @var{number}
17476 @cindex pragma, memregs
17477 Overrides the command-line option @code{-memregs=} for the current
17478 file.  Use with care!  This pragma must be before any function in the
17479 file, and mixing different memregs values in different objects may
17480 make them incompatible.  This pragma is useful when a
17481 performance-critical function uses a memreg for temporary values,
17482 as it may allow you to reduce the number of memregs used.
17484 @item ADDRESS @var{name} @var{address}
17485 @cindex pragma, address
17486 For any declared symbols matching @var{name}, this does three things
17487 to that symbol: it forces the symbol to be located at the given
17488 address (a number), it forces the symbol to be volatile, and it
17489 changes the symbol's scope to be static.  This pragma exists for
17490 compatibility with other compilers, but note that the common
17491 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17492 instead).  Example:
17494 @smallexample
17495 #pragma ADDRESS port3 0x103
17496 char port3;
17497 @end smallexample
17499 @end table
17501 @node MeP Pragmas
17502 @subsection MeP Pragmas
17504 @table @code
17506 @item custom io_volatile (on|off)
17507 @cindex pragma, custom io_volatile
17508 Overrides the command-line option @code{-mio-volatile} for the current
17509 file.  Note that for compatibility with future GCC releases, this
17510 option should only be used once before any @code{io} variables in each
17511 file.
17513 @item GCC coprocessor available @var{registers}
17514 @cindex pragma, coprocessor available
17515 Specifies which coprocessor registers are available to the register
17516 allocator.  @var{registers} may be a single register, register range
17517 separated by ellipses, or comma-separated list of those.  Example:
17519 @smallexample
17520 #pragma GCC coprocessor available $c0...$c10, $c28
17521 @end smallexample
17523 @item GCC coprocessor call_saved @var{registers}
17524 @cindex pragma, coprocessor call_saved
17525 Specifies which coprocessor registers are to be saved and restored by
17526 any function using them.  @var{registers} may be a single register,
17527 register range separated by ellipses, or comma-separated list of
17528 those.  Example:
17530 @smallexample
17531 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17532 @end smallexample
17534 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17535 @cindex pragma, coprocessor subclass
17536 Creates and defines a register class.  These register classes can be
17537 used by inline @code{asm} constructs.  @var{registers} may be a single
17538 register, register range separated by ellipses, or comma-separated
17539 list of those.  Example:
17541 @smallexample
17542 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17544 asm ("cpfoo %0" : "=B" (x));
17545 @end smallexample
17547 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17548 @cindex pragma, disinterrupt
17549 For the named functions, the compiler adds code to disable interrupts
17550 for the duration of those functions.  If any functions so named 
17551 are not encountered in the source, a warning is emitted that the pragma is
17552 not used.  Examples:
17554 @smallexample
17555 #pragma disinterrupt foo
17556 #pragma disinterrupt bar, grill
17557 int foo () @{ @dots{} @}
17558 @end smallexample
17560 @item GCC call @var{name} , @var{name} @dots{}
17561 @cindex pragma, call
17562 For the named functions, the compiler always uses a register-indirect
17563 call model when calling the named functions.  Examples:
17565 @smallexample
17566 extern int foo ();
17567 #pragma call foo
17568 @end smallexample
17570 @end table
17572 @node RS/6000 and PowerPC Pragmas
17573 @subsection RS/6000 and PowerPC Pragmas
17575 The RS/6000 and PowerPC targets define one pragma for controlling
17576 whether or not the @code{longcall} attribute is added to function
17577 declarations by default.  This pragma overrides the @option{-mlongcall}
17578 option, but not the @code{longcall} and @code{shortcall} attributes.
17579 @xref{RS/6000 and PowerPC Options}, for more information about when long
17580 calls are and are not necessary.
17582 @table @code
17583 @item longcall (1)
17584 @cindex pragma, longcall
17585 Apply the @code{longcall} attribute to all subsequent function
17586 declarations.
17588 @item longcall (0)
17589 Do not apply the @code{longcall} attribute to subsequent function
17590 declarations.
17591 @end table
17593 @c Describe h8300 pragmas here.
17594 @c Describe sh pragmas here.
17595 @c Describe v850 pragmas here.
17597 @node Darwin Pragmas
17598 @subsection Darwin Pragmas
17600 The following pragmas are available for all architectures running the
17601 Darwin operating system.  These are useful for compatibility with other
17602 Mac OS compilers.
17604 @table @code
17605 @item mark @var{tokens}@dots{}
17606 @cindex pragma, mark
17607 This pragma is accepted, but has no effect.
17609 @item options align=@var{alignment}
17610 @cindex pragma, options align
17611 This pragma sets the alignment of fields in structures.  The values of
17612 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17613 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17614 properly; to restore the previous setting, use @code{reset} for the
17615 @var{alignment}.
17617 @item segment @var{tokens}@dots{}
17618 @cindex pragma, segment
17619 This pragma is accepted, but has no effect.
17621 @item unused (@var{var} [, @var{var}]@dots{})
17622 @cindex pragma, unused
17623 This pragma declares variables to be possibly unused.  GCC does not
17624 produce warnings for the listed variables.  The effect is similar to
17625 that of the @code{unused} attribute, except that this pragma may appear
17626 anywhere within the variables' scopes.
17627 @end table
17629 @node Solaris Pragmas
17630 @subsection Solaris Pragmas
17632 The Solaris target supports @code{#pragma redefine_extname}
17633 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17634 @code{#pragma} directives for compatibility with the system compiler.
17636 @table @code
17637 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17638 @cindex pragma, align
17640 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17641 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17642 Attributes}).  Macro expansion occurs on the arguments to this pragma
17643 when compiling C and Objective-C@.  It does not currently occur when
17644 compiling C++, but this is a bug which may be fixed in a future
17645 release.
17647 @item fini (@var{function} [, @var{function}]...)
17648 @cindex pragma, fini
17650 This pragma causes each listed @var{function} to be called after
17651 main, or during shared module unloading, by adding a call to the
17652 @code{.fini} section.
17654 @item init (@var{function} [, @var{function}]...)
17655 @cindex pragma, init
17657 This pragma causes each listed @var{function} to be called during
17658 initialization (before @code{main}) or during shared module loading, by
17659 adding a call to the @code{.init} section.
17661 @end table
17663 @node Symbol-Renaming Pragmas
17664 @subsection Symbol-Renaming Pragmas
17666 GCC supports a @code{#pragma} directive that changes the name used in
17667 assembly for a given declaration. While this pragma is supported on all
17668 platforms, it is intended primarily to provide compatibility with the
17669 Solaris system headers. This effect can also be achieved using the asm
17670 labels extension (@pxref{Asm Labels}).
17672 @table @code
17673 @item redefine_extname @var{oldname} @var{newname}
17674 @cindex pragma, redefine_extname
17676 This pragma gives the C function @var{oldname} the assembly symbol
17677 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17678 is defined if this pragma is available (currently on all platforms).
17679 @end table
17681 This pragma and the asm labels extension interact in a complicated
17682 manner.  Here are some corner cases you may want to be aware of:
17684 @enumerate
17685 @item This pragma silently applies only to declarations with external
17686 linkage.  Asm labels do not have this restriction.
17688 @item In C++, this pragma silently applies only to declarations with
17689 ``C'' linkage.  Again, asm labels do not have this restriction.
17691 @item If either of the ways of changing the assembly name of a
17692 declaration are applied to a declaration whose assembly name has
17693 already been determined (either by a previous use of one of these
17694 features, or because the compiler needed the assembly name in order to
17695 generate code), and the new name is different, a warning issues and
17696 the name does not change.
17698 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17699 always the C-language name.
17700 @end enumerate
17702 @node Structure-Packing Pragmas
17703 @subsection Structure-Packing Pragmas
17705 For compatibility with Microsoft Windows compilers, GCC supports a
17706 set of @code{#pragma} directives that change the maximum alignment of
17707 members of structures (other than zero-width bit-fields), unions, and
17708 classes subsequently defined. The @var{n} value below always is required
17709 to be a small power of two and specifies the new alignment in bytes.
17711 @enumerate
17712 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17713 @item @code{#pragma pack()} sets the alignment to the one that was in
17714 effect when compilation started (see also command-line option
17715 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17716 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17717 setting on an internal stack and then optionally sets the new alignment.
17718 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17719 saved at the top of the internal stack (and removes that stack entry).
17720 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17721 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17722 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17723 @code{#pragma pack(pop)}.
17724 @end enumerate
17726 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
17727 @code{#pragma} which lays out a structure as the documented
17728 @code{__attribute__ ((ms_struct))}.
17729 @enumerate
17730 @item @code{#pragma ms_struct on} turns on the layout for structures
17731 declared.
17732 @item @code{#pragma ms_struct off} turns off the layout for structures
17733 declared.
17734 @item @code{#pragma ms_struct reset} goes back to the default layout.
17735 @end enumerate
17737 @node Weak Pragmas
17738 @subsection Weak Pragmas
17740 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17741 directives for declaring symbols to be weak, and defining weak
17742 aliases.
17744 @table @code
17745 @item #pragma weak @var{symbol}
17746 @cindex pragma, weak
17747 This pragma declares @var{symbol} to be weak, as if the declaration
17748 had the attribute of the same name.  The pragma may appear before
17749 or after the declaration of @var{symbol}.  It is not an error for
17750 @var{symbol} to never be defined at all.
17752 @item #pragma weak @var{symbol1} = @var{symbol2}
17753 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17754 It is an error if @var{symbol2} is not defined in the current
17755 translation unit.
17756 @end table
17758 @node Diagnostic Pragmas
17759 @subsection Diagnostic Pragmas
17761 GCC allows the user to selectively enable or disable certain types of
17762 diagnostics, and change the kind of the diagnostic.  For example, a
17763 project's policy might require that all sources compile with
17764 @option{-Werror} but certain files might have exceptions allowing
17765 specific types of warnings.  Or, a project might selectively enable
17766 diagnostics and treat them as errors depending on which preprocessor
17767 macros are defined.
17769 @table @code
17770 @item #pragma GCC diagnostic @var{kind} @var{option}
17771 @cindex pragma, diagnostic
17773 Modifies the disposition of a diagnostic.  Note that not all
17774 diagnostics are modifiable; at the moment only warnings (normally
17775 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17776 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17777 are controllable and which option controls them.
17779 @var{kind} is @samp{error} to treat this diagnostic as an error,
17780 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17781 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17782 @var{option} is a double quoted string that matches the command-line
17783 option.
17785 @smallexample
17786 #pragma GCC diagnostic warning "-Wformat"
17787 #pragma GCC diagnostic error "-Wformat"
17788 #pragma GCC diagnostic ignored "-Wformat"
17789 @end smallexample
17791 Note that these pragmas override any command-line options.  GCC keeps
17792 track of the location of each pragma, and issues diagnostics according
17793 to the state as of that point in the source file.  Thus, pragmas occurring
17794 after a line do not affect diagnostics caused by that line.
17796 @item #pragma GCC diagnostic push
17797 @itemx #pragma GCC diagnostic pop
17799 Causes GCC to remember the state of the diagnostics as of each
17800 @code{push}, and restore to that point at each @code{pop}.  If a
17801 @code{pop} has no matching @code{push}, the command-line options are
17802 restored.
17804 @smallexample
17805 #pragma GCC diagnostic error "-Wuninitialized"
17806   foo(a);                       /* error is given for this one */
17807 #pragma GCC diagnostic push
17808 #pragma GCC diagnostic ignored "-Wuninitialized"
17809   foo(b);                       /* no diagnostic for this one */
17810 #pragma GCC diagnostic pop
17811   foo(c);                       /* error is given for this one */
17812 #pragma GCC diagnostic pop
17813   foo(d);                       /* depends on command-line options */
17814 @end smallexample
17816 @end table
17818 GCC also offers a simple mechanism for printing messages during
17819 compilation.
17821 @table @code
17822 @item #pragma message @var{string}
17823 @cindex pragma, diagnostic
17825 Prints @var{string} as a compiler message on compilation.  The message
17826 is informational only, and is neither a compilation warning nor an error.
17828 @smallexample
17829 #pragma message "Compiling " __FILE__ "..."
17830 @end smallexample
17832 @var{string} may be parenthesized, and is printed with location
17833 information.  For example,
17835 @smallexample
17836 #define DO_PRAGMA(x) _Pragma (#x)
17837 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17839 TODO(Remember to fix this)
17840 @end smallexample
17842 @noindent
17843 prints @samp{/tmp/file.c:4: note: #pragma message:
17844 TODO - Remember to fix this}.
17846 @end table
17848 @node Visibility Pragmas
17849 @subsection Visibility Pragmas
17851 @table @code
17852 @item #pragma GCC visibility push(@var{visibility})
17853 @itemx #pragma GCC visibility pop
17854 @cindex pragma, visibility
17856 This pragma allows the user to set the visibility for multiple
17857 declarations without having to give each a visibility attribute
17858 (@pxref{Function Attributes}).
17860 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17861 declarations.  Class members and template specializations are not
17862 affected; if you want to override the visibility for a particular
17863 member or instantiation, you must use an attribute.
17865 @end table
17868 @node Push/Pop Macro Pragmas
17869 @subsection Push/Pop Macro Pragmas
17871 For compatibility with Microsoft Windows compilers, GCC supports
17872 @samp{#pragma push_macro(@var{"macro_name"})}
17873 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17875 @table @code
17876 @item #pragma push_macro(@var{"macro_name"})
17877 @cindex pragma, push_macro
17878 This pragma saves the value of the macro named as @var{macro_name} to
17879 the top of the stack for this macro.
17881 @item #pragma pop_macro(@var{"macro_name"})
17882 @cindex pragma, pop_macro
17883 This pragma sets the value of the macro named as @var{macro_name} to
17884 the value on top of the stack for this macro. If the stack for
17885 @var{macro_name} is empty, the value of the macro remains unchanged.
17886 @end table
17888 For example:
17890 @smallexample
17891 #define X  1
17892 #pragma push_macro("X")
17893 #undef X
17894 #define X -1
17895 #pragma pop_macro("X")
17896 int x [X];
17897 @end smallexample
17899 @noindent
17900 In this example, the definition of X as 1 is saved by @code{#pragma
17901 push_macro} and restored by @code{#pragma pop_macro}.
17903 @node Function Specific Option Pragmas
17904 @subsection Function Specific Option Pragmas
17906 @table @code
17907 @item #pragma GCC target (@var{"string"}...)
17908 @cindex pragma GCC target
17910 This pragma allows you to set target specific options for functions
17911 defined later in the source file.  One or more strings can be
17912 specified.  Each function that is defined after this point is as
17913 if @code{attribute((target("STRING")))} was specified for that
17914 function.  The parenthesis around the options is optional.
17915 @xref{Function Attributes}, for more information about the
17916 @code{target} attribute and the attribute syntax.
17918 The @code{#pragma GCC target} pragma is presently implemented for
17919 x86, PowerPC, and Nios II targets only.
17920 @end table
17922 @table @code
17923 @item #pragma GCC optimize (@var{"string"}...)
17924 @cindex pragma GCC optimize
17926 This pragma allows you to set global optimization options for functions
17927 defined later in the source file.  One or more strings can be
17928 specified.  Each function that is defined after this point is as
17929 if @code{attribute((optimize("STRING")))} was specified for that
17930 function.  The parenthesis around the options is optional.
17931 @xref{Function Attributes}, for more information about the
17932 @code{optimize} attribute and the attribute syntax.
17933 @end table
17935 @table @code
17936 @item #pragma GCC push_options
17937 @itemx #pragma GCC pop_options
17938 @cindex pragma GCC push_options
17939 @cindex pragma GCC pop_options
17941 These pragmas maintain a stack of the current target and optimization
17942 options.  It is intended for include files where you temporarily want
17943 to switch to using a different @samp{#pragma GCC target} or
17944 @samp{#pragma GCC optimize} and then to pop back to the previous
17945 options.
17946 @end table
17948 @table @code
17949 @item #pragma GCC reset_options
17950 @cindex pragma GCC reset_options
17952 This pragma clears the current @code{#pragma GCC target} and
17953 @code{#pragma GCC optimize} to use the default switches as specified
17954 on the command line.
17955 @end table
17957 @node Loop-Specific Pragmas
17958 @subsection Loop-Specific Pragmas
17960 @table @code
17961 @item #pragma GCC ivdep
17962 @cindex pragma GCC ivdep
17963 @end table
17965 With this pragma, the programmer asserts that there are no loop-carried
17966 dependencies which would prevent consecutive iterations of
17967 the following loop from executing concurrently with SIMD
17968 (single instruction multiple data) instructions.
17970 For example, the compiler can only unconditionally vectorize the following
17971 loop with the pragma:
17973 @smallexample
17974 void foo (int n, int *a, int *b, int *c)
17976   int i, j;
17977 #pragma GCC ivdep
17978   for (i = 0; i < n; ++i)
17979     a[i] = b[i] + c[i];
17981 @end smallexample
17983 @noindent
17984 In this example, using the @code{restrict} qualifier had the same
17985 effect. In the following example, that would not be possible. Assume
17986 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17987 that it can unconditionally vectorize the following loop:
17989 @smallexample
17990 void ignore_vec_dep (int *a, int k, int c, int m)
17992 #pragma GCC ivdep
17993   for (int i = 0; i < m; i++)
17994     a[i] = a[i + k] * c;
17996 @end smallexample
17999 @node Unnamed Fields
18000 @section Unnamed Structure and Union Fields
18001 @cindex @code{struct}
18002 @cindex @code{union}
18004 As permitted by ISO C11 and for compatibility with other compilers,
18005 GCC allows you to define
18006 a structure or union that contains, as fields, structures and unions
18007 without names.  For example:
18009 @smallexample
18010 struct @{
18011   int a;
18012   union @{
18013     int b;
18014     float c;
18015   @};
18016   int d;
18017 @} foo;
18018 @end smallexample
18020 @noindent
18021 In this example, you are able to access members of the unnamed
18022 union with code like @samp{foo.b}.  Note that only unnamed structs and
18023 unions are allowed, you may not have, for example, an unnamed
18024 @code{int}.
18026 You must never create such structures that cause ambiguous field definitions.
18027 For example, in this structure:
18029 @smallexample
18030 struct @{
18031   int a;
18032   struct @{
18033     int a;
18034   @};
18035 @} foo;
18036 @end smallexample
18038 @noindent
18039 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
18040 The compiler gives errors for such constructs.
18042 @opindex fms-extensions
18043 Unless @option{-fms-extensions} is used, the unnamed field must be a
18044 structure or union definition without a tag (for example, @samp{struct
18045 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
18046 also be a definition with a tag such as @samp{struct foo @{ int a;
18047 @};}, a reference to a previously defined structure or union such as
18048 @samp{struct foo;}, or a reference to a @code{typedef} name for a
18049 previously defined structure or union type.
18051 @opindex fplan9-extensions
18052 The option @option{-fplan9-extensions} enables
18053 @option{-fms-extensions} as well as two other extensions.  First, a
18054 pointer to a structure is automatically converted to a pointer to an
18055 anonymous field for assignments and function calls.  For example:
18057 @smallexample
18058 struct s1 @{ int a; @};
18059 struct s2 @{ struct s1; @};
18060 extern void f1 (struct s1 *);
18061 void f2 (struct s2 *p) @{ f1 (p); @}
18062 @end smallexample
18064 @noindent
18065 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
18066 converted into a pointer to the anonymous field.
18068 Second, when the type of an anonymous field is a @code{typedef} for a
18069 @code{struct} or @code{union}, code may refer to the field using the
18070 name of the @code{typedef}.
18072 @smallexample
18073 typedef struct @{ int a; @} s1;
18074 struct s2 @{ s1; @};
18075 s1 f1 (struct s2 *p) @{ return p->s1; @}
18076 @end smallexample
18078 These usages are only permitted when they are not ambiguous.
18080 @node Thread-Local
18081 @section Thread-Local Storage
18082 @cindex Thread-Local Storage
18083 @cindex @acronym{TLS}
18084 @cindex @code{__thread}
18086 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
18087 are allocated such that there is one instance of the variable per extant
18088 thread.  The runtime model GCC uses to implement this originates
18089 in the IA-64 processor-specific ABI, but has since been migrated
18090 to other processors as well.  It requires significant support from
18091 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
18092 system libraries (@file{libc.so} and @file{libpthread.so}), so it
18093 is not available everywhere.
18095 At the user level, the extension is visible with a new storage
18096 class keyword: @code{__thread}.  For example:
18098 @smallexample
18099 __thread int i;
18100 extern __thread struct state s;
18101 static __thread char *p;
18102 @end smallexample
18104 The @code{__thread} specifier may be used alone, with the @code{extern}
18105 or @code{static} specifiers, but with no other storage class specifier.
18106 When used with @code{extern} or @code{static}, @code{__thread} must appear
18107 immediately after the other storage class specifier.
18109 The @code{__thread} specifier may be applied to any global, file-scoped
18110 static, function-scoped static, or static data member of a class.  It may
18111 not be applied to block-scoped automatic or non-static data member.
18113 When the address-of operator is applied to a thread-local variable, it is
18114 evaluated at run time and returns the address of the current thread's
18115 instance of that variable.  An address so obtained may be used by any
18116 thread.  When a thread terminates, any pointers to thread-local variables
18117 in that thread become invalid.
18119 No static initialization may refer to the address of a thread-local variable.
18121 In C++, if an initializer is present for a thread-local variable, it must
18122 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18123 standard.
18125 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18126 ELF Handling For Thread-Local Storage} for a detailed explanation of
18127 the four thread-local storage addressing models, and how the runtime
18128 is expected to function.
18130 @menu
18131 * C99 Thread-Local Edits::
18132 * C++98 Thread-Local Edits::
18133 @end menu
18135 @node C99 Thread-Local Edits
18136 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18138 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18139 that document the exact semantics of the language extension.
18141 @itemize @bullet
18142 @item
18143 @cite{5.1.2  Execution environments}
18145 Add new text after paragraph 1
18147 @quotation
18148 Within either execution environment, a @dfn{thread} is a flow of
18149 control within a program.  It is implementation defined whether
18150 or not there may be more than one thread associated with a program.
18151 It is implementation defined how threads beyond the first are
18152 created, the name and type of the function called at thread
18153 startup, and how threads may be terminated.  However, objects
18154 with thread storage duration shall be initialized before thread
18155 startup.
18156 @end quotation
18158 @item
18159 @cite{6.2.4  Storage durations of objects}
18161 Add new text before paragraph 3
18163 @quotation
18164 An object whose identifier is declared with the storage-class
18165 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18166 Its lifetime is the entire execution of the thread, and its
18167 stored value is initialized only once, prior to thread startup.
18168 @end quotation
18170 @item
18171 @cite{6.4.1  Keywords}
18173 Add @code{__thread}.
18175 @item
18176 @cite{6.7.1  Storage-class specifiers}
18178 Add @code{__thread} to the list of storage class specifiers in
18179 paragraph 1.
18181 Change paragraph 2 to
18183 @quotation
18184 With the exception of @code{__thread}, at most one storage-class
18185 specifier may be given [@dots{}].  The @code{__thread} specifier may
18186 be used alone, or immediately following @code{extern} or
18187 @code{static}.
18188 @end quotation
18190 Add new text after paragraph 6
18192 @quotation
18193 The declaration of an identifier for a variable that has
18194 block scope that specifies @code{__thread} shall also
18195 specify either @code{extern} or @code{static}.
18197 The @code{__thread} specifier shall be used only with
18198 variables.
18199 @end quotation
18200 @end itemize
18202 @node C++98 Thread-Local Edits
18203 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18205 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18206 that document the exact semantics of the language extension.
18208 @itemize @bullet
18209 @item
18210 @b{[intro.execution]}
18212 New text after paragraph 4
18214 @quotation
18215 A @dfn{thread} is a flow of control within the abstract machine.
18216 It is implementation defined whether or not there may be more than
18217 one thread.
18218 @end quotation
18220 New text after paragraph 7
18222 @quotation
18223 It is unspecified whether additional action must be taken to
18224 ensure when and whether side effects are visible to other threads.
18225 @end quotation
18227 @item
18228 @b{[lex.key]}
18230 Add @code{__thread}.
18232 @item
18233 @b{[basic.start.main]}
18235 Add after paragraph 5
18237 @quotation
18238 The thread that begins execution at the @code{main} function is called
18239 the @dfn{main thread}.  It is implementation defined how functions
18240 beginning threads other than the main thread are designated or typed.
18241 A function so designated, as well as the @code{main} function, is called
18242 a @dfn{thread startup function}.  It is implementation defined what
18243 happens if a thread startup function returns.  It is implementation
18244 defined what happens to other threads when any thread calls @code{exit}.
18245 @end quotation
18247 @item
18248 @b{[basic.start.init]}
18250 Add after paragraph 4
18252 @quotation
18253 The storage for an object of thread storage duration shall be
18254 statically initialized before the first statement of the thread startup
18255 function.  An object of thread storage duration shall not require
18256 dynamic initialization.
18257 @end quotation
18259 @item
18260 @b{[basic.start.term]}
18262 Add after paragraph 3
18264 @quotation
18265 The type of an object with thread storage duration shall not have a
18266 non-trivial destructor, nor shall it be an array type whose elements
18267 (directly or indirectly) have non-trivial destructors.
18268 @end quotation
18270 @item
18271 @b{[basic.stc]}
18273 Add ``thread storage duration'' to the list in paragraph 1.
18275 Change paragraph 2
18277 @quotation
18278 Thread, static, and automatic storage durations are associated with
18279 objects introduced by declarations [@dots{}].
18280 @end quotation
18282 Add @code{__thread} to the list of specifiers in paragraph 3.
18284 @item
18285 @b{[basic.stc.thread]}
18287 New section before @b{[basic.stc.static]}
18289 @quotation
18290 The keyword @code{__thread} applied to a non-local object gives the
18291 object thread storage duration.
18293 A local variable or class data member declared both @code{static}
18294 and @code{__thread} gives the variable or member thread storage
18295 duration.
18296 @end quotation
18298 @item
18299 @b{[basic.stc.static]}
18301 Change paragraph 1
18303 @quotation
18304 All objects that have neither thread storage duration, dynamic
18305 storage duration nor are local [@dots{}].
18306 @end quotation
18308 @item
18309 @b{[dcl.stc]}
18311 Add @code{__thread} to the list in paragraph 1.
18313 Change paragraph 1
18315 @quotation
18316 With the exception of @code{__thread}, at most one
18317 @var{storage-class-specifier} shall appear in a given
18318 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18319 be used alone, or immediately following the @code{extern} or
18320 @code{static} specifiers.  [@dots{}]
18321 @end quotation
18323 Add after paragraph 5
18325 @quotation
18326 The @code{__thread} specifier can be applied only to the names of objects
18327 and to anonymous unions.
18328 @end quotation
18330 @item
18331 @b{[class.mem]}
18333 Add after paragraph 6
18335 @quotation
18336 Non-@code{static} members shall not be @code{__thread}.
18337 @end quotation
18338 @end itemize
18340 @node Binary constants
18341 @section Binary Constants using the @samp{0b} Prefix
18342 @cindex Binary constants using the @samp{0b} prefix
18344 Integer constants can be written as binary constants, consisting of a
18345 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18346 @samp{0B}.  This is particularly useful in environments that operate a
18347 lot on the bit level (like microcontrollers).
18349 The following statements are identical:
18351 @smallexample
18352 i =       42;
18353 i =     0x2a;
18354 i =      052;
18355 i = 0b101010;
18356 @end smallexample
18358 The type of these constants follows the same rules as for octal or
18359 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18360 can be applied.
18362 @node C++ Extensions
18363 @chapter Extensions to the C++ Language
18364 @cindex extensions, C++ language
18365 @cindex C++ language extensions
18367 The GNU compiler provides these extensions to the C++ language (and you
18368 can also use most of the C language extensions in your C++ programs).  If you
18369 want to write code that checks whether these features are available, you can
18370 test for the GNU compiler the same way as for C programs: check for a
18371 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18372 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18373 Predefined Macros,cpp,The GNU C Preprocessor}).
18375 @menu
18376 * C++ Volatiles::       What constitutes an access to a volatile object.
18377 * Restricted Pointers:: C99 restricted pointers and references.
18378 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18379 * C++ Interface::       You can use a single C++ header file for both
18380                         declarations and definitions.
18381 * Template Instantiation:: Methods for ensuring that exactly one copy of
18382                         each needed template instantiation is emitted.
18383 * Bound member functions:: You can extract a function pointer to the
18384                         method denoted by a @samp{->*} or @samp{.*} expression.
18385 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18386 * Function Multiversioning::   Declaring multiple function versions.
18387 * Namespace Association:: Strong using-directives for namespace association.
18388 * Type Traits::         Compiler support for type traits
18389 * Java Exceptions::     Tweaking exception handling to work with Java.
18390 * Deprecated Features:: Things will disappear from G++.
18391 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18392 @end menu
18394 @node C++ Volatiles
18395 @section When is a Volatile C++ Object Accessed?
18396 @cindex accessing volatiles
18397 @cindex volatile read
18398 @cindex volatile write
18399 @cindex volatile access
18401 The C++ standard differs from the C standard in its treatment of
18402 volatile objects.  It fails to specify what constitutes a volatile
18403 access, except to say that C++ should behave in a similar manner to C
18404 with respect to volatiles, where possible.  However, the different
18405 lvalueness of expressions between C and C++ complicate the behavior.
18406 G++ behaves the same as GCC for volatile access, @xref{C
18407 Extensions,,Volatiles}, for a description of GCC's behavior.
18409 The C and C++ language specifications differ when an object is
18410 accessed in a void context:
18412 @smallexample
18413 volatile int *src = @var{somevalue};
18414 *src;
18415 @end smallexample
18417 The C++ standard specifies that such expressions do not undergo lvalue
18418 to rvalue conversion, and that the type of the dereferenced object may
18419 be incomplete.  The C++ standard does not specify explicitly that it
18420 is lvalue to rvalue conversion that is responsible for causing an
18421 access.  There is reason to believe that it is, because otherwise
18422 certain simple expressions become undefined.  However, because it
18423 would surprise most programmers, G++ treats dereferencing a pointer to
18424 volatile object of complete type as GCC would do for an equivalent
18425 type in C@.  When the object has incomplete type, G++ issues a
18426 warning; if you wish to force an error, you must force a conversion to
18427 rvalue with, for instance, a static cast.
18429 When using a reference to volatile, G++ does not treat equivalent
18430 expressions as accesses to volatiles, but instead issues a warning that
18431 no volatile is accessed.  The rationale for this is that otherwise it
18432 becomes difficult to determine where volatile access occur, and not
18433 possible to ignore the return value from functions returning volatile
18434 references.  Again, if you wish to force a read, cast the reference to
18435 an rvalue.
18437 G++ implements the same behavior as GCC does when assigning to a
18438 volatile object---there is no reread of the assigned-to object, the
18439 assigned rvalue is reused.  Note that in C++ assignment expressions
18440 are lvalues, and if used as an lvalue, the volatile object is
18441 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18442 expected, in the following example:
18444 @smallexample
18445 volatile int vobj;
18446 volatile int &vref = vobj = @var{something};
18447 @end smallexample
18449 @node Restricted Pointers
18450 @section Restricting Pointer Aliasing
18451 @cindex restricted pointers
18452 @cindex restricted references
18453 @cindex restricted this pointer
18455 As with the C front end, G++ understands the C99 feature of restricted pointers,
18456 specified with the @code{__restrict__}, or @code{__restrict} type
18457 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18458 language flag, @code{restrict} is not a keyword in C++.
18460 In addition to allowing restricted pointers, you can specify restricted
18461 references, which indicate that the reference is not aliased in the local
18462 context.
18464 @smallexample
18465 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18467   /* @r{@dots{}} */
18469 @end smallexample
18471 @noindent
18472 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18473 @var{rref} refers to a (different) unaliased integer.
18475 You may also specify whether a member function's @var{this} pointer is
18476 unaliased by using @code{__restrict__} as a member function qualifier.
18478 @smallexample
18479 void T::fn () __restrict__
18481   /* @r{@dots{}} */
18483 @end smallexample
18485 @noindent
18486 Within the body of @code{T::fn}, @var{this} has the effective
18487 definition @code{T *__restrict__ const this}.  Notice that the
18488 interpretation of a @code{__restrict__} member function qualifier is
18489 different to that of @code{const} or @code{volatile} qualifier, in that it
18490 is applied to the pointer rather than the object.  This is consistent with
18491 other compilers that implement restricted pointers.
18493 As with all outermost parameter qualifiers, @code{__restrict__} is
18494 ignored in function definition matching.  This means you only need to
18495 specify @code{__restrict__} in a function definition, rather than
18496 in a function prototype as well.
18498 @node Vague Linkage
18499 @section Vague Linkage
18500 @cindex vague linkage
18502 There are several constructs in C++ that require space in the object
18503 file but are not clearly tied to a single translation unit.  We say that
18504 these constructs have ``vague linkage''.  Typically such constructs are
18505 emitted wherever they are needed, though sometimes we can be more
18506 clever.
18508 @table @asis
18509 @item Inline Functions
18510 Inline functions are typically defined in a header file which can be
18511 included in many different compilations.  Hopefully they can usually be
18512 inlined, but sometimes an out-of-line copy is necessary, if the address
18513 of the function is taken or if inlining fails.  In general, we emit an
18514 out-of-line copy in all translation units where one is needed.  As an
18515 exception, we only emit inline virtual functions with the vtable, since
18516 it always requires a copy.
18518 Local static variables and string constants used in an inline function
18519 are also considered to have vague linkage, since they must be shared
18520 between all inlined and out-of-line instances of the function.
18522 @item VTables
18523 @cindex vtable
18524 C++ virtual functions are implemented in most compilers using a lookup
18525 table, known as a vtable.  The vtable contains pointers to the virtual
18526 functions provided by a class, and each object of the class contains a
18527 pointer to its vtable (or vtables, in some multiple-inheritance
18528 situations).  If the class declares any non-inline, non-pure virtual
18529 functions, the first one is chosen as the ``key method'' for the class,
18530 and the vtable is only emitted in the translation unit where the key
18531 method is defined.
18533 @emph{Note:} If the chosen key method is later defined as inline, the
18534 vtable is still emitted in every translation unit that defines it.
18535 Make sure that any inline virtuals are declared inline in the class
18536 body, even if they are not defined there.
18538 @item @code{type_info} objects
18539 @cindex @code{type_info}
18540 @cindex RTTI
18541 C++ requires information about types to be written out in order to
18542 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18543 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18544 object is written out along with the vtable so that @samp{dynamic_cast}
18545 can determine the dynamic type of a class object at run time.  For all
18546 other types, we write out the @samp{type_info} object when it is used: when
18547 applying @samp{typeid} to an expression, throwing an object, or
18548 referring to a type in a catch clause or exception specification.
18550 @item Template Instantiations
18551 Most everything in this section also applies to template instantiations,
18552 but there are other options as well.
18553 @xref{Template Instantiation,,Where's the Template?}.
18555 @end table
18557 When used with GNU ld version 2.8 or later on an ELF system such as
18558 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18559 these constructs will be discarded at link time.  This is known as
18560 COMDAT support.
18562 On targets that don't support COMDAT, but do support weak symbols, GCC
18563 uses them.  This way one copy overrides all the others, but
18564 the unused copies still take up space in the executable.
18566 For targets that do not support either COMDAT or weak symbols,
18567 most entities with vague linkage are emitted as local symbols to
18568 avoid duplicate definition errors from the linker.  This does not happen
18569 for local statics in inlines, however, as having multiple copies
18570 almost certainly breaks things.
18572 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18573 another way to control placement of these constructs.
18575 @node C++ Interface
18576 @section C++ Interface and Implementation Pragmas
18578 @cindex interface and implementation headers, C++
18579 @cindex C++ interface and implementation headers
18580 @cindex pragmas, interface and implementation
18582 @code{#pragma interface} and @code{#pragma implementation} provide the
18583 user with a way of explicitly directing the compiler to emit entities
18584 with vague linkage (and debugging information) in a particular
18585 translation unit.
18587 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
18588 by COMDAT support and the ``key method'' heuristic
18589 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18590 program to grow due to unnecessary out-of-line copies of inline
18591 functions.
18593 @table @code
18594 @item #pragma interface
18595 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18596 @kindex #pragma interface
18597 Use this directive in @emph{header files} that define object classes, to save
18598 space in most of the object files that use those classes.  Normally,
18599 local copies of certain information (backup copies of inline member
18600 functions, debugging information, and the internal tables that implement
18601 virtual functions) must be kept in each object file that includes class
18602 definitions.  You can use this pragma to avoid such duplication.  When a
18603 header file containing @samp{#pragma interface} is included in a
18604 compilation, this auxiliary information is not generated (unless
18605 the main input source file itself uses @samp{#pragma implementation}).
18606 Instead, the object files contain references to be resolved at link
18607 time.
18609 The second form of this directive is useful for the case where you have
18610 multiple headers with the same name in different directories.  If you
18611 use this form, you must specify the same string to @samp{#pragma
18612 implementation}.
18614 @item #pragma implementation
18615 @itemx #pragma implementation "@var{objects}.h"
18616 @kindex #pragma implementation
18617 Use this pragma in a @emph{main input file}, when you want full output from
18618 included header files to be generated (and made globally visible).  The
18619 included header file, in turn, should use @samp{#pragma interface}.
18620 Backup copies of inline member functions, debugging information, and the
18621 internal tables used to implement virtual functions are all generated in
18622 implementation files.
18624 @cindex implied @code{#pragma implementation}
18625 @cindex @code{#pragma implementation}, implied
18626 @cindex naming convention, implementation headers
18627 If you use @samp{#pragma implementation} with no argument, it applies to
18628 an include file with the same basename@footnote{A file's @dfn{basename}
18629 is the name stripped of all leading path information and of trailing
18630 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18631 file.  For example, in @file{allclass.cc}, giving just
18632 @samp{#pragma implementation}
18633 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18635 Use the string argument if you want a single implementation file to
18636 include code from multiple header files.  (You must also use
18637 @samp{#include} to include the header file; @samp{#pragma
18638 implementation} only specifies how to use the file---it doesn't actually
18639 include it.)
18641 There is no way to split up the contents of a single header file into
18642 multiple implementation files.
18643 @end table
18645 @cindex inlining and C++ pragmas
18646 @cindex C++ pragmas, effect on inlining
18647 @cindex pragmas in C++, effect on inlining
18648 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18649 effect on function inlining.
18651 If you define a class in a header file marked with @samp{#pragma
18652 interface}, the effect on an inline function defined in that class is
18653 similar to an explicit @code{extern} declaration---the compiler emits
18654 no code at all to define an independent version of the function.  Its
18655 definition is used only for inlining with its callers.
18657 @opindex fno-implement-inlines
18658 Conversely, when you include the same header file in a main source file
18659 that declares it as @samp{#pragma implementation}, the compiler emits
18660 code for the function itself; this defines a version of the function
18661 that can be found via pointers (or by callers compiled without
18662 inlining).  If all calls to the function can be inlined, you can avoid
18663 emitting the function by compiling with @option{-fno-implement-inlines}.
18664 If any calls are not inlined, you will get linker errors.
18666 @node Template Instantiation
18667 @section Where's the Template?
18668 @cindex template instantiation
18670 C++ templates are the first language feature to require more
18671 intelligence from the environment than one usually finds on a UNIX
18672 system.  Somehow the compiler and linker have to make sure that each
18673 template instance occurs exactly once in the executable if it is needed,
18674 and not at all otherwise.  There are two basic approaches to this
18675 problem, which are referred to as the Borland model and the Cfront model.
18677 @table @asis
18678 @item Borland model
18679 Borland C++ solved the template instantiation problem by adding the code
18680 equivalent of common blocks to their linker; the compiler emits template
18681 instances in each translation unit that uses them, and the linker
18682 collapses them together.  The advantage of this model is that the linker
18683 only has to consider the object files themselves; there is no external
18684 complexity to worry about.  This disadvantage is that compilation time
18685 is increased because the template code is being compiled repeatedly.
18686 Code written for this model tends to include definitions of all
18687 templates in the header file, since they must be seen to be
18688 instantiated.
18690 @item Cfront model
18691 The AT&T C++ translator, Cfront, solved the template instantiation
18692 problem by creating the notion of a template repository, an
18693 automatically maintained place where template instances are stored.  A
18694 more modern version of the repository works as follows: As individual
18695 object files are built, the compiler places any template definitions and
18696 instantiations encountered in the repository.  At link time, the link
18697 wrapper adds in the objects in the repository and compiles any needed
18698 instances that were not previously emitted.  The advantages of this
18699 model are more optimal compilation speed and the ability to use the
18700 system linker; to implement the Borland model a compiler vendor also
18701 needs to replace the linker.  The disadvantages are vastly increased
18702 complexity, and thus potential for error; for some code this can be
18703 just as transparent, but in practice it can been very difficult to build
18704 multiple programs in one directory and one program in multiple
18705 directories.  Code written for this model tends to separate definitions
18706 of non-inline member templates into a separate file, which should be
18707 compiled separately.
18708 @end table
18710 When used with GNU ld version 2.8 or later on an ELF system such as
18711 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18712 Borland model.  On other systems, G++ implements neither automatic
18713 model.
18715 You have the following options for dealing with template instantiations:
18717 @enumerate
18718 @item
18719 @opindex frepo
18720 Compile your template-using code with @option{-frepo}.  The compiler
18721 generates files with the extension @samp{.rpo} listing all of the
18722 template instantiations used in the corresponding object files that
18723 could be instantiated there; the link wrapper, @samp{collect2},
18724 then updates the @samp{.rpo} files to tell the compiler where to place
18725 those instantiations and rebuild any affected object files.  The
18726 link-time overhead is negligible after the first pass, as the compiler
18727 continues to place the instantiations in the same files.
18729 This is your best option for application code written for the Borland
18730 model, as it just works.  Code written for the Cfront model 
18731 needs to be modified so that the template definitions are available at
18732 one or more points of instantiation; usually this is as simple as adding
18733 @code{#include <tmethods.cc>} to the end of each template header.
18735 For library code, if you want the library to provide all of the template
18736 instantiations it needs, just try to link all of its object files
18737 together; the link will fail, but cause the instantiations to be
18738 generated as a side effect.  Be warned, however, that this may cause
18739 conflicts if multiple libraries try to provide the same instantiations.
18740 For greater control, use explicit instantiation as described in the next
18741 option.
18743 @item
18744 @opindex fno-implicit-templates
18745 Compile your code with @option{-fno-implicit-templates} to disable the
18746 implicit generation of template instances, and explicitly instantiate
18747 all the ones you use.  This approach requires more knowledge of exactly
18748 which instances you need than do the others, but it's less
18749 mysterious and allows greater control.  You can scatter the explicit
18750 instantiations throughout your program, perhaps putting them in the
18751 translation units where the instances are used or the translation units
18752 that define the templates themselves; you can put all of the explicit
18753 instantiations you need into one big file; or you can create small files
18754 like
18756 @smallexample
18757 #include "Foo.h"
18758 #include "Foo.cc"
18760 template class Foo<int>;
18761 template ostream& operator <<
18762                 (ostream&, const Foo<int>&);
18763 @end smallexample
18765 @noindent
18766 for each of the instances you need, and create a template instantiation
18767 library from those.
18769 If you are using Cfront-model code, you can probably get away with not
18770 using @option{-fno-implicit-templates} when compiling files that don't
18771 @samp{#include} the member template definitions.
18773 If you use one big file to do the instantiations, you may want to
18774 compile it without @option{-fno-implicit-templates} so you get all of the
18775 instances required by your explicit instantiations (but not by any
18776 other files) without having to specify them as well.
18778 The ISO C++ 2011 standard allows forward declaration of explicit
18779 instantiations (with @code{extern}). G++ supports explicit instantiation
18780 declarations in C++98 mode and has extended the template instantiation
18781 syntax to support instantiation of the compiler support data for a
18782 template class (i.e.@: the vtable) without instantiating any of its
18783 members (with @code{inline}), and instantiation of only the static data
18784 members of a template class, without the support data or member
18785 functions (with @code{static}):
18787 @smallexample
18788 extern template int max (int, int);
18789 inline template class Foo<int>;
18790 static template class Foo<int>;
18791 @end smallexample
18793 @item
18794 Do nothing.  Pretend G++ does implement automatic instantiation
18795 management.  Code written for the Borland model works fine, but
18796 each translation unit contains instances of each of the templates it
18797 uses.  In a large program, this can lead to an unacceptable amount of code
18798 duplication.
18799 @end enumerate
18801 @node Bound member functions
18802 @section Extracting the Function Pointer from a Bound Pointer to Member Function
18803 @cindex pmf
18804 @cindex pointer to member function
18805 @cindex bound pointer to member function
18807 In C++, pointer to member functions (PMFs) are implemented using a wide
18808 pointer of sorts to handle all the possible call mechanisms; the PMF
18809 needs to store information about how to adjust the @samp{this} pointer,
18810 and if the function pointed to is virtual, where to find the vtable, and
18811 where in the vtable to look for the member function.  If you are using
18812 PMFs in an inner loop, you should really reconsider that decision.  If
18813 that is not an option, you can extract the pointer to the function that
18814 would be called for a given object/PMF pair and call it directly inside
18815 the inner loop, to save a bit of time.
18817 Note that you still pay the penalty for the call through a
18818 function pointer; on most modern architectures, such a call defeats the
18819 branch prediction features of the CPU@.  This is also true of normal
18820 virtual function calls.
18822 The syntax for this extension is
18824 @smallexample
18825 extern A a;
18826 extern int (A::*fp)();
18827 typedef int (*fptr)(A *);
18829 fptr p = (fptr)(a.*fp);
18830 @end smallexample
18832 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18833 no object is needed to obtain the address of the function.  They can be
18834 converted to function pointers directly:
18836 @smallexample
18837 fptr p1 = (fptr)(&A::foo);
18838 @end smallexample
18840 @opindex Wno-pmf-conversions
18841 You must specify @option{-Wno-pmf-conversions} to use this extension.
18843 @node C++ Attributes
18844 @section C++-Specific Variable, Function, and Type Attributes
18846 Some attributes only make sense for C++ programs.
18848 @table @code
18849 @item abi_tag ("@var{tag}", ...)
18850 @cindex @code{abi_tag} function attribute
18851 @cindex @code{abi_tag} variable attribute
18852 @cindex @code{abi_tag} type attribute
18853 The @code{abi_tag} attribute can be applied to a function, variable, or class
18854 declaration.  It modifies the mangled name of the entity to
18855 incorporate the tag name, in order to distinguish the function or
18856 class from an earlier version with a different ABI; perhaps the class
18857 has changed size, or the function has a different return type that is
18858 not encoded in the mangled name.
18860 The attribute can also be applied to an inline namespace, but does not
18861 affect the mangled name of the namespace; in this case it is only used
18862 for @option{-Wabi-tag} warnings and automatic tagging of functions and
18863 variables.  Tagging inline namespaces is generally preferable to
18864 tagging individual declarations, but the latter is sometimes
18865 necessary, such as when only certain members of a class need to be
18866 tagged.
18868 The argument can be a list of strings of arbitrary length.  The
18869 strings are sorted on output, so the order of the list is
18870 unimportant.
18872 A redeclaration of an entity must not add new ABI tags,
18873 since doing so would change the mangled name.
18875 The ABI tags apply to a name, so all instantiations and
18876 specializations of a template have the same tags.  The attribute will
18877 be ignored if applied to an explicit specialization or instantiation.
18879 The @option{-Wabi-tag} flag enables a warning about a class which does
18880 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18881 that needs to coexist with an earlier ABI, using this option can help
18882 to find all affected types that need to be tagged.
18884 When a type involving an ABI tag is used as the type of a variable or
18885 return type of a function where that tag is not already present in the
18886 signature of the function, the tag is automatically applied to the
18887 variable or function.  @option{-Wabi-tag} also warns about this
18888 situation; this warning can be avoided by explicitly tagging the
18889 variable or function or moving it into a tagged inline namespace.
18891 @item init_priority (@var{priority})
18892 @cindex @code{init_priority} variable attribute
18894 In Standard C++, objects defined at namespace scope are guaranteed to be
18895 initialized in an order in strict accordance with that of their definitions
18896 @emph{in a given translation unit}.  No guarantee is made for initializations
18897 across translation units.  However, GNU C++ allows users to control the
18898 order of initialization of objects defined at namespace scope with the
18899 @code{init_priority} attribute by specifying a relative @var{priority},
18900 a constant integral expression currently bounded between 101 and 65535
18901 inclusive.  Lower numbers indicate a higher priority.
18903 In the following example, @code{A} would normally be created before
18904 @code{B}, but the @code{init_priority} attribute reverses that order:
18906 @smallexample
18907 Some_Class  A  __attribute__ ((init_priority (2000)));
18908 Some_Class  B  __attribute__ ((init_priority (543)));
18909 @end smallexample
18911 @noindent
18912 Note that the particular values of @var{priority} do not matter; only their
18913 relative ordering.
18915 @item java_interface
18916 @cindex @code{java_interface} type attribute
18918 This type attribute informs C++ that the class is a Java interface.  It may
18919 only be applied to classes declared within an @code{extern "Java"} block.
18920 Calls to methods declared in this interface are dispatched using GCJ's
18921 interface table mechanism, instead of regular virtual table dispatch.
18923 @item warn_unused
18924 @cindex @code{warn_unused} type attribute
18926 For C++ types with non-trivial constructors and/or destructors it is
18927 impossible for the compiler to determine whether a variable of this
18928 type is truly unused if it is not referenced. This type attribute
18929 informs the compiler that variables of this type should be warned
18930 about if they appear to be unused, just like variables of fundamental
18931 types.
18933 This attribute is appropriate for types which just represent a value,
18934 such as @code{std::string}; it is not appropriate for types which
18935 control a resource, such as @code{std::mutex}.
18937 This attribute is also accepted in C, but it is unnecessary because C
18938 does not have constructors or destructors.
18940 @end table
18942 See also @ref{Namespace Association}.
18944 @node Function Multiversioning
18945 @section Function Multiversioning
18946 @cindex function versions
18948 With the GNU C++ front end, for x86 targets, you may specify multiple
18949 versions of a function, where each function is specialized for a
18950 specific target feature.  At runtime, the appropriate version of the
18951 function is automatically executed depending on the characteristics of
18952 the execution platform.  Here is an example.
18954 @smallexample
18955 __attribute__ ((target ("default")))
18956 int foo ()
18958   // The default version of foo.
18959   return 0;
18962 __attribute__ ((target ("sse4.2")))
18963 int foo ()
18965   // foo version for SSE4.2
18966   return 1;
18969 __attribute__ ((target ("arch=atom")))
18970 int foo ()
18972   // foo version for the Intel ATOM processor
18973   return 2;
18976 __attribute__ ((target ("arch=amdfam10")))
18977 int foo ()
18979   // foo version for the AMD Family 0x10 processors.
18980   return 3;
18983 int main ()
18985   int (*p)() = &foo;
18986   assert ((*p) () == foo ());
18987   return 0;
18989 @end smallexample
18991 In the above example, four versions of function foo are created. The
18992 first version of foo with the target attribute "default" is the default
18993 version.  This version gets executed when no other target specific
18994 version qualifies for execution on a particular platform. A new version
18995 of foo is created by using the same function signature but with a
18996 different target string.  Function foo is called or a pointer to it is
18997 taken just like a regular function.  GCC takes care of doing the
18998 dispatching to call the right version at runtime.  Refer to the
18999 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
19000 Function Multiversioning} for more details.
19002 @node Namespace Association
19003 @section Namespace Association
19005 @strong{Caution:} The semantics of this extension are equivalent
19006 to C++ 2011 inline namespaces.  Users should use inline namespaces
19007 instead as this extension will be removed in future versions of G++.
19009 A using-directive with @code{__attribute ((strong))} is stronger
19010 than a normal using-directive in two ways:
19012 @itemize @bullet
19013 @item
19014 Templates from the used namespace can be specialized and explicitly
19015 instantiated as though they were members of the using namespace.
19017 @item
19018 The using namespace is considered an associated namespace of all
19019 templates in the used namespace for purposes of argument-dependent
19020 name lookup.
19021 @end itemize
19023 The used namespace must be nested within the using namespace so that
19024 normal unqualified lookup works properly.
19026 This is useful for composing a namespace transparently from
19027 implementation namespaces.  For example:
19029 @smallexample
19030 namespace std @{
19031   namespace debug @{
19032     template <class T> struct A @{ @};
19033   @}
19034   using namespace debug __attribute ((__strong__));
19035   template <> struct A<int> @{ @};   // @r{OK to specialize}
19037   template <class T> void f (A<T>);
19040 int main()
19042   f (std::A<float>());             // @r{lookup finds} std::f
19043   f (std::A<int>());
19045 @end smallexample
19047 @node Type Traits
19048 @section Type Traits
19050 The C++ front end implements syntactic extensions that allow
19051 compile-time determination of 
19052 various characteristics of a type (or of a
19053 pair of types).
19055 @table @code
19056 @item __has_nothrow_assign (type)
19057 If @code{type} is const qualified or is a reference type then the trait is
19058 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
19059 is true, else if @code{type} is a cv class or union type with copy assignment
19060 operators that are known not to throw an exception then the trait is true,
19061 else it is false.  Requires: @code{type} shall be a complete type,
19062 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19064 @item __has_nothrow_copy (type)
19065 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
19066 @code{type} is a cv class or union type with copy constructors that
19067 are known not to throw an exception then the trait is true, else it is false.
19068 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
19069 @code{void}, or an array of unknown bound.
19071 @item __has_nothrow_constructor (type)
19072 If @code{__has_trivial_constructor (type)} is true then the trait is
19073 true, else if @code{type} is a cv class or union type (or array
19074 thereof) with a default constructor that is known not to throw an
19075 exception then the trait is true, else it is false.  Requires:
19076 @code{type} shall be a complete type, (possibly cv-qualified)
19077 @code{void}, or an array of unknown bound.
19079 @item __has_trivial_assign (type)
19080 If @code{type} is const qualified or is a reference type then the trait is
19081 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
19082 true, else if @code{type} is a cv class or union type with a trivial
19083 copy assignment ([class.copy]) then the trait is true, else it is
19084 false.  Requires: @code{type} shall be a complete type, (possibly
19085 cv-qualified) @code{void}, or an array of unknown bound.
19087 @item __has_trivial_copy (type)
19088 If @code{__is_pod (type)} is true or @code{type} is a reference type
19089 then the trait is true, else if @code{type} is a cv class or union type
19090 with a trivial copy constructor ([class.copy]) then the trait
19091 is true, else it is false.  Requires: @code{type} shall be a complete
19092 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19094 @item __has_trivial_constructor (type)
19095 If @code{__is_pod (type)} is true then the trait is true, else if
19096 @code{type} is a cv class or union type (or array thereof) with a
19097 trivial default constructor ([class.ctor]) then the trait is true,
19098 else it is false.  Requires: @code{type} shall be a complete
19099 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19101 @item __has_trivial_destructor (type)
19102 If @code{__is_pod (type)} is true or @code{type} is a reference type then
19103 the trait is true, else if @code{type} is a cv class or union type (or
19104 array thereof) with a trivial destructor ([class.dtor]) then the trait
19105 is true, else it is false.  Requires: @code{type} shall be a complete
19106 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19108 @item __has_virtual_destructor (type)
19109 If @code{type} is a class type with a virtual destructor
19110 ([class.dtor]) then the trait is true, else it is false.  Requires:
19111 @code{type} shall be a complete type, (possibly cv-qualified)
19112 @code{void}, or an array of unknown bound.
19114 @item __is_abstract (type)
19115 If @code{type} is an abstract class ([class.abstract]) then the trait
19116 is true, else it is false.  Requires: @code{type} shall be a complete
19117 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19119 @item __is_base_of (base_type, derived_type)
19120 If @code{base_type} is a base class of @code{derived_type}
19121 ([class.derived]) then the trait is true, otherwise it is false.
19122 Top-level cv qualifications of @code{base_type} and
19123 @code{derived_type} are ignored.  For the purposes of this trait, a
19124 class type is considered is own base.  Requires: if @code{__is_class
19125 (base_type)} and @code{__is_class (derived_type)} are true and
19126 @code{base_type} and @code{derived_type} are not the same type
19127 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19128 type.  Diagnostic is produced if this requirement is not met.
19130 @item __is_class (type)
19131 If @code{type} is a cv class type, and not a union type
19132 ([basic.compound]) the trait is true, else it is false.
19134 @item __is_empty (type)
19135 If @code{__is_class (type)} is false then the trait is false.
19136 Otherwise @code{type} is considered empty if and only if: @code{type}
19137 has no non-static data members, or all non-static data members, if
19138 any, are bit-fields of length 0, and @code{type} has no virtual
19139 members, and @code{type} has no virtual base classes, and @code{type}
19140 has no base classes @code{base_type} for which
19141 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19142 be a complete type, (possibly cv-qualified) @code{void}, or an array
19143 of unknown bound.
19145 @item __is_enum (type)
19146 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19147 true, else it is false.
19149 @item __is_literal_type (type)
19150 If @code{type} is a literal type ([basic.types]) the trait is
19151 true, else it is false.  Requires: @code{type} shall be a complete type,
19152 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19154 @item __is_pod (type)
19155 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19156 else it is false.  Requires: @code{type} shall be a complete type,
19157 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19159 @item __is_polymorphic (type)
19160 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19161 is true, else it is false.  Requires: @code{type} shall be a complete
19162 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19164 @item __is_standard_layout (type)
19165 If @code{type} is a standard-layout type ([basic.types]) the trait is
19166 true, else it is false.  Requires: @code{type} shall be a complete
19167 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19169 @item __is_trivial (type)
19170 If @code{type} is a trivial type ([basic.types]) the trait is
19171 true, else it is false.  Requires: @code{type} shall be a complete
19172 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19174 @item __is_union (type)
19175 If @code{type} is a cv union type ([basic.compound]) the trait is
19176 true, else it is false.
19178 @item __underlying_type (type)
19179 The underlying type of @code{type}.  Requires: @code{type} shall be
19180 an enumeration type ([dcl.enum]).
19182 @end table
19184 @node Java Exceptions
19185 @section Java Exceptions
19187 The Java language uses a slightly different exception handling model
19188 from C++.  Normally, GNU C++ automatically detects when you are
19189 writing C++ code that uses Java exceptions, and handle them
19190 appropriately.  However, if C++ code only needs to execute destructors
19191 when Java exceptions are thrown through it, GCC guesses incorrectly.
19192 Sample problematic code is:
19194 @smallexample
19195   struct S @{ ~S(); @};
19196   extern void bar();    // @r{is written in Java, and may throw exceptions}
19197   void foo()
19198   @{
19199     S s;
19200     bar();
19201   @}
19202 @end smallexample
19204 @noindent
19205 The usual effect of an incorrect guess is a link failure, complaining of
19206 a missing routine called @samp{__gxx_personality_v0}.
19208 You can inform the compiler that Java exceptions are to be used in a
19209 translation unit, irrespective of what it might think, by writing
19210 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19211 @samp{#pragma} must appear before any functions that throw or catch
19212 exceptions, or run destructors when exceptions are thrown through them.
19214 You cannot mix Java and C++ exceptions in the same translation unit.  It
19215 is believed to be safe to throw a C++ exception from one file through
19216 another file compiled for the Java exception model, or vice versa, but
19217 there may be bugs in this area.
19219 @node Deprecated Features
19220 @section Deprecated Features
19222 In the past, the GNU C++ compiler was extended to experiment with new
19223 features, at a time when the C++ language was still evolving.  Now that
19224 the C++ standard is complete, some of those features are superseded by
19225 superior alternatives.  Using the old features might cause a warning in
19226 some cases that the feature will be dropped in the future.  In other
19227 cases, the feature might be gone already.
19229 While the list below is not exhaustive, it documents some of the options
19230 that are now deprecated:
19232 @table @code
19233 @item -fexternal-templates
19234 @itemx -falt-external-templates
19235 These are two of the many ways for G++ to implement template
19236 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19237 defines how template definitions have to be organized across
19238 implementation units.  G++ has an implicit instantiation mechanism that
19239 should work just fine for standard-conforming code.
19241 @item -fstrict-prototype
19242 @itemx -fno-strict-prototype
19243 Previously it was possible to use an empty prototype parameter list to
19244 indicate an unspecified number of parameters (like C), rather than no
19245 parameters, as C++ demands.  This feature has been removed, except where
19246 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19247 @end table
19249 G++ allows a virtual function returning @samp{void *} to be overridden
19250 by one returning a different pointer type.  This extension to the
19251 covariant return type rules is now deprecated and will be removed from a
19252 future version.
19254 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19255 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19256 and are now removed from G++.  Code using these operators should be
19257 modified to use @code{std::min} and @code{std::max} instead.
19259 The named return value extension has been deprecated, and is now
19260 removed from G++.
19262 The use of initializer lists with new expressions has been deprecated,
19263 and is now removed from G++.
19265 Floating and complex non-type template parameters have been deprecated,
19266 and are now removed from G++.
19268 The implicit typename extension has been deprecated and is now
19269 removed from G++.
19271 The use of default arguments in function pointers, function typedefs
19272 and other places where they are not permitted by the standard is
19273 deprecated and will be removed from a future version of G++.
19275 G++ allows floating-point literals to appear in integral constant expressions,
19276 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19277 This extension is deprecated and will be removed from a future version.
19279 G++ allows static data members of const floating-point type to be declared
19280 with an initializer in a class definition. The standard only allows
19281 initializers for static members of const integral types and const
19282 enumeration types so this extension has been deprecated and will be removed
19283 from a future version.
19285 @node Backwards Compatibility
19286 @section Backwards Compatibility
19287 @cindex Backwards Compatibility
19288 @cindex ARM [Annotated C++ Reference Manual]
19290 Now that there is a definitive ISO standard C++, G++ has a specification
19291 to adhere to.  The C++ language evolved over time, and features that
19292 used to be acceptable in previous drafts of the standard, such as the ARM
19293 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19294 compilation of C++ written to such drafts, G++ contains some backwards
19295 compatibilities.  @emph{All such backwards compatibility features are
19296 liable to disappear in future versions of G++.} They should be considered
19297 deprecated.   @xref{Deprecated Features}.
19299 @table @code
19300 @item For scope
19301 If a variable is declared at for scope, it used to remain in scope until
19302 the end of the scope that contained the for statement (rather than just
19303 within the for scope).  G++ retains this, but issues a warning, if such a
19304 variable is accessed outside the for scope.
19306 @item Implicit C language
19307 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19308 scope to set the language.  On such systems, all header files are
19309 implicitly scoped inside a C language scope.  Also, an empty prototype
19310 @code{()} is treated as an unspecified number of arguments, rather
19311 than no arguments, as C++ demands.
19312 @end table
19314 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19315 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr