Fix comment in gcc/config/arm/predicates.md
[official-gcc.git] / gcc / doc / extend.texi
blob2ce00989bcbab0a21766619628816834494ba628
1 @c Copyright (C) 1988-2013 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers::        Non-constant initializers.
50 * Compound Literals::   Compound literals give structures, unions
51                         or arrays as values.
52 * Designated Inits::    Labeling elements of initializers.
53 * Case Ranges::         `case 1 ... 9' and such.
54 * Cast to Union::       Casting to union type from any member of the union.
55 * Mixed Declarations::  Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57                         or that they can never return.
58 * Attribute Syntax::    Formal syntax for attributes.
59 * Function Prototypes:: Prototype declarations and old-style definitions.
60 * C++ Comments::        C++ comments are recognized.
61 * Dollar Signs::        Dollar sign is allowed in identifiers.
62 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes::     Specifying attributes of types.
65 * Alignment::           Inquiring about the alignment of a type or variable.
66 * Inline::              Defining inline functions (as fast as macros).
67 * Volatiles::           What constitutes an access to a volatile object.
68 * Extended Asm::        Assembler instructions with C expressions as operands.
69                         (With them you can define ``built-in'' functions.)
70 * Constraints::         Constraints for asm operands
71 * Asm Labels::          Specifying the assembler name to use for a C symbol.
72 * Explicit Reg Vars::   Defining variables residing in specified registers.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84                         checking.
85 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
86 * Other Builtins::      Other built-in functions.
87 * Target Builtins::     Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas::             Pragmas accepted by GCC.
90 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
91 * Thread-Local::        Per-thread variables.
92 * Binary constants::    Binary constants using the @samp{0b} prefix.
93 @end menu
95 @node Statement Exprs
96 @section Statements and Declarations in Expressions
97 @cindex statements inside expressions
98 @cindex declarations inside expressions
99 @cindex expressions containing statements
100 @cindex macros, statements in expressions
102 @c the above section title wrapped and causes an underfull hbox.. i
103 @c changed it from "within" to "in". --mew 4feb93
104 A compound statement enclosed in parentheses may appear as an expression
105 in GNU C@.  This allows you to use loops, switches, and local variables
106 within an expression.
108 Recall that a compound statement is a sequence of statements surrounded
109 by braces; in this construct, parentheses go around the braces.  For
110 example:
112 @smallexample
113 (@{ int y = foo (); int z;
114    if (y > 0) z = y;
115    else z = - y;
116    z; @})
117 @end smallexample
119 @noindent
120 is a valid (though slightly more complex than necessary) expression
121 for the absolute value of @code{foo ()}.
123 The last thing in the compound statement should be an expression
124 followed by a semicolon; the value of this subexpression serves as the
125 value of the entire construct.  (If you use some other kind of statement
126 last within the braces, the construct has type @code{void}, and thus
127 effectively no value.)
129 This feature is especially useful in making macro definitions ``safe'' (so
130 that they evaluate each operand exactly once).  For example, the
131 ``maximum'' function is commonly defined as a macro in standard C as
132 follows:
134 @smallexample
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 @end smallexample
138 @noindent
139 @cindex side effects, macro argument
140 But this definition computes either @var{a} or @var{b} twice, with bad
141 results if the operand has side effects.  In GNU C, if you know the
142 type of the operands (here taken as @code{int}), you can define
143 the macro safely as follows:
145 @smallexample
146 #define maxint(a,b) \
147   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
148 @end smallexample
150 Embedded statements are not allowed in constant expressions, such as
151 the value of an enumeration constant, the width of a bit-field, or
152 the initial value of a static variable.
154 If you don't know the type of the operand, you can still do this, but you
155 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
157 In G++, the result value of a statement expression undergoes array and
158 function pointer decay, and is returned by value to the enclosing
159 expression.  For instance, if @code{A} is a class, then
161 @smallexample
162         A a;
164         (@{a;@}).Foo ()
165 @end smallexample
167 @noindent
168 constructs a temporary @code{A} object to hold the result of the
169 statement expression, and that is used to invoke @code{Foo}.
170 Therefore the @code{this} pointer observed by @code{Foo} is not the
171 address of @code{a}.
173 In a statement expression, any temporaries created within a statement
174 are destroyed at that statement's end.  This makes statement
175 expressions inside macros slightly different from function calls.  In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call.  In the statement expression case they are destroyed during
179 the statement expression.  For instance,
181 @smallexample
182 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
183 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
185 void foo ()
187   macro (X ());
188   function (X ());
190 @end smallexample
192 @noindent
193 has different places where temporaries are destroyed.  For the
194 @code{macro} case, the temporary @code{X} is destroyed just after
195 the initialization of @code{b}.  In the @code{function} case that
196 temporary is destroyed when the function returns.
198 These considerations mean that it is probably a bad idea to use
199 statement expressions of this form in header files that are designed to
200 work with C++.  (Note that some versions of the GNU C Library contained
201 header files using statement expressions that lead to precisely this
202 bug.)
204 Jumping into a statement expression with @code{goto} or using a
205 @code{switch} statement outside the statement expression with a
206 @code{case} or @code{default} label inside the statement expression is
207 not permitted.  Jumping into a statement expression with a computed
208 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression.  In any case, as with a function call, the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression.  For example,
218 @smallexample
219   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}.  If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope.  A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
237 A local label declaration looks like this:
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
243 @noindent
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself.  You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
257 The local label feature is useful for complex macros.  If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them.  However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function.  A
262 local label avoids this problem.  For example:
264 @smallexample
265 #define SEARCH(value, array, target)              \
266 do @{                                              \
267   __label__ found;                                \
268   typeof (target) _SEARCH_target = (target);      \
269   typeof (*(array)) *_SEARCH_array = (array);     \
270   int i, j;                                       \
271   int value;                                      \
272   for (i = 0; i < max; i++)                       \
273     for (j = 0; j < max; j++)                     \
274       if (_SEARCH_array[i][j] == _SEARCH_target)  \
275         @{ (value) = i; goto found; @}              \
276   (value) = -1;                                   \
277  found:;                                          \
278 @} while (0)
279 @end smallexample
281 This could also be written using a statement expression:
283 @smallexample
284 #define SEARCH(array, target)                     \
285 (@{                                                \
286   __label__ found;                                \
287   typeof (target) _SEARCH_target = (target);      \
288   typeof (*(array)) *_SEARCH_array = (array);     \
289   int i, j;                                       \
290   int value;                                      \
291   for (i = 0; i < max; i++)                       \
292     for (j = 0; j < max; j++)                     \
293       if (_SEARCH_array[i][j] == _SEARCH_target)  \
294         @{ value = i; goto found; @}                \
295   value = -1;                                     \
296  found:                                           \
297   value;                                          \
299 @end smallexample
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any.  @xref{Nested Functions}, for details.
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}.  The
313 value has type @code{void *}.  This value is a constant and can be used
314 wherever a constant of that type is valid.  For example:
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
322 To use these values, you need to be able to jump to one.  This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}.  For example,
328 @smallexample
329 goto *ptr;
330 @end smallexample
332 @noindent
333 Any expression of type @code{void *} is allowed.
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
342 @noindent
343 Then you can select a label with indexing, like this:
345 @smallexample
346 goto *array[i];
347 @end smallexample
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement.  The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen.  The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
367 An alternate way to write the above example is
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371                              &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
380 The @code{&&foo} expressions for the same label might have different
381 values if the containing function is inlined or cloned.  If a program
382 relies on them being always the same,
383 @code{__attribute__((__noinline__,__noclone__))} should be used to
384 prevent inlining and cloning.  If @code{&&foo} is used in a static
385 variable initializer, inlining and cloning is forbidden.
387 @node Nested Functions
388 @section Nested Functions
389 @cindex nested functions
390 @cindex downward funargs
391 @cindex thunks
393 A @dfn{nested function} is a function defined inside another function.
394 Nested functions are supported as an extension in GNU C, but are not
395 supported by GNU C++.
397 The nested function's name is local to the block where it is defined.
398 For example, here we define a nested function named @code{square}, and
399 call it twice:
401 @smallexample
402 @group
403 foo (double a, double b)
405   double square (double z) @{ return z * z; @}
407   return square (a) + square (b);
409 @end group
410 @end smallexample
412 The nested function can access all the variables of the containing
413 function that are visible at the point of its definition.  This is
414 called @dfn{lexical scoping}.  For example, here we show a nested
415 function which uses an inherited variable named @code{offset}:
417 @smallexample
418 @group
419 bar (int *array, int offset, int size)
421   int access (int *array, int index)
422     @{ return array[index + offset]; @}
423   int i;
424   /* @r{@dots{}} */
425   for (i = 0; i < size; i++)
426     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
428 @end group
429 @end smallexample
431 Nested function definitions are permitted within functions in the places
432 where variable definitions are allowed; that is, in any block, mixed
433 with the other declarations and statements in the block.
435 It is possible to call the nested function from outside the scope of its
436 name by storing its address or passing the address to another function:
438 @smallexample
439 hack (int *array, int size)
441   void store (int index, int value)
442     @{ array[index] = value; @}
444   intermediate (store, size);
446 @end smallexample
448 Here, the function @code{intermediate} receives the address of
449 @code{store} as an argument.  If @code{intermediate} calls @code{store},
450 the arguments given to @code{store} are used to store into @code{array}.
451 But this technique works only so long as the containing function
452 (@code{hack}, in this example) does not exit.
454 If you try to call the nested function through its address after the
455 containing function exits, all hell breaks loose.  If you try
456 to call it after a containing scope level exits, and if it refers
457 to some of the variables that are no longer in scope, you may be lucky,
458 but it's not wise to take the risk.  If, however, the nested function
459 does not refer to anything that has gone out of scope, you should be
460 safe.
462 GCC implements taking the address of a nested function using a technique
463 called @dfn{trampolines}.  This technique was described in
464 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
465 C++ Conference Proceedings, October 17-21, 1988).
467 A nested function can jump to a label inherited from a containing
468 function, provided the label is explicitly declared in the containing
469 function (@pxref{Local Labels}).  Such a jump returns instantly to the
470 containing function, exiting the nested function that did the
471 @code{goto} and any intermediate functions as well.  Here is an example:
473 @smallexample
474 @group
475 bar (int *array, int offset, int size)
477   __label__ failure;
478   int access (int *array, int index)
479     @{
480       if (index > size)
481         goto failure;
482       return array[index + offset];
483     @}
484   int i;
485   /* @r{@dots{}} */
486   for (i = 0; i < size; i++)
487     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
488   /* @r{@dots{}} */
489   return 0;
491  /* @r{Control comes here from @code{access}
492     if it detects an error.}  */
493  failure:
494   return -1;
496 @end group
497 @end smallexample
499 A nested function always has no linkage.  Declaring one with
500 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
501 before its definition, use @code{auto} (which is otherwise meaningless
502 for function declarations).
504 @smallexample
505 bar (int *array, int offset, int size)
507   __label__ failure;
508   auto int access (int *, int);
509   /* @r{@dots{}} */
510   int access (int *array, int index)
511     @{
512       if (index > size)
513         goto failure;
514       return array[index + offset];
515     @}
516   /* @r{@dots{}} */
518 @end smallexample
520 @node Constructing Calls
521 @section Constructing Function Calls
522 @cindex constructing calls
523 @cindex forwarding calls
525 Using the built-in functions described below, you can record
526 the arguments a function received, and call another function
527 with the same arguments, without knowing the number or types
528 of the arguments.
530 You can also record the return value of that function call,
531 and later return that value, without knowing what data type
532 the function tried to return (as long as your caller expects
533 that data type).
535 However, these built-in functions may interact badly with some
536 sophisticated features or other extensions of the language.  It
537 is, therefore, not recommended to use them outside very simple
538 functions acting as mere forwarders for their arguments.
540 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
541 This built-in function returns a pointer to data
542 describing how to perform a call with the same arguments as are passed
543 to the current function.
545 The function saves the arg pointer register, structure value address,
546 and all registers that might be used to pass arguments to a function
547 into a block of memory allocated on the stack.  Then it returns the
548 address of that block.
549 @end deftypefn
551 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
552 This built-in function invokes @var{function}
553 with a copy of the parameters described by @var{arguments}
554 and @var{size}.
556 The value of @var{arguments} should be the value returned by
557 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
558 of the stack argument data, in bytes.
560 This function returns a pointer to data describing
561 how to return whatever value is returned by @var{function}.  The data
562 is saved in a block of memory allocated on the stack.
564 It is not always simple to compute the proper value for @var{size}.  The
565 value is used by @code{__builtin_apply} to compute the amount of data
566 that should be pushed on the stack and copied from the incoming argument
567 area.
568 @end deftypefn
570 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
571 This built-in function returns the value described by @var{result} from
572 the containing function.  You should specify, for @var{result}, a value
573 returned by @code{__builtin_apply}.
574 @end deftypefn
576 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
577 This built-in function represents all anonymous arguments of an inline
578 function.  It can be used only in inline functions that are always
579 inlined, never compiled as a separate function, such as those using
580 @code{__attribute__ ((__always_inline__))} or
581 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
582 It must be only passed as last argument to some other function
583 with variable arguments.  This is useful for writing small wrapper
584 inlines for variable argument functions, when using preprocessor
585 macros is undesirable.  For example:
586 @smallexample
587 extern int myprintf (FILE *f, const char *format, ...);
588 extern inline __attribute__ ((__gnu_inline__)) int
589 myprintf (FILE *f, const char *format, ...)
591   int r = fprintf (f, "myprintf: ");
592   if (r < 0)
593     return r;
594   int s = fprintf (f, format, __builtin_va_arg_pack ());
595   if (s < 0)
596     return s;
597   return r + s;
599 @end smallexample
600 @end deftypefn
602 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
603 This built-in function returns the number of anonymous arguments of
604 an inline function.  It can be used only in inline functions that
605 are always inlined, never compiled as a separate function, such
606 as those using @code{__attribute__ ((__always_inline__))} or
607 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
608 For example following does link- or run-time checking of open
609 arguments for optimized code:
610 @smallexample
611 #ifdef __OPTIMIZE__
612 extern inline __attribute__((__gnu_inline__)) int
613 myopen (const char *path, int oflag, ...)
615   if (__builtin_va_arg_pack_len () > 1)
616     warn_open_too_many_arguments ();
618   if (__builtin_constant_p (oflag))
619     @{
620       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
621         @{
622           warn_open_missing_mode ();
623           return __open_2 (path, oflag);
624         @}
625       return open (path, oflag, __builtin_va_arg_pack ());
626     @}
628   if (__builtin_va_arg_pack_len () < 1)
629     return __open_2 (path, oflag);
631   return open (path, oflag, __builtin_va_arg_pack ());
633 #endif
634 @end smallexample
635 @end deftypefn
637 @node Typeof
638 @section Referring to a Type with @code{typeof}
639 @findex typeof
640 @findex sizeof
641 @cindex macros, types of arguments
643 Another way to refer to the type of an expression is with @code{typeof}.
644 The syntax of using of this keyword looks like @code{sizeof}, but the
645 construct acts semantically like a type name defined with @code{typedef}.
647 There are two ways of writing the argument to @code{typeof}: with an
648 expression or with a type.  Here is an example with an expression:
650 @smallexample
651 typeof (x[0](1))
652 @end smallexample
654 @noindent
655 This assumes that @code{x} is an array of pointers to functions;
656 the type described is that of the values of the functions.
658 Here is an example with a typename as the argument:
660 @smallexample
661 typeof (int *)
662 @end smallexample
664 @noindent
665 Here the type described is that of pointers to @code{int}.
667 If you are writing a header file that must work when included in ISO C
668 programs, write @code{__typeof__} instead of @code{typeof}.
669 @xref{Alternate Keywords}.
671 A @code{typeof} construct can be used anywhere a typedef name can be
672 used.  For example, you can use it in a declaration, in a cast, or inside
673 of @code{sizeof} or @code{typeof}.
675 The operand of @code{typeof} is evaluated for its side effects if and
676 only if it is an expression of variably modified type or the name of
677 such a type.
679 @code{typeof} is often useful in conjunction with
680 statement expressions (@pxref{Statement Exprs}).
681 Here is how the two together can
682 be used to define a safe ``maximum'' macro which operates on any
683 arithmetic type and evaluates each of its arguments exactly once:
685 @smallexample
686 #define max(a,b) \
687   (@{ typeof (a) _a = (a); \
688       typeof (b) _b = (b); \
689     _a > _b ? _a : _b; @})
690 @end smallexample
692 @cindex underscores in variables in macros
693 @cindex @samp{_} in variables in macros
694 @cindex local variables in macros
695 @cindex variables, local, in macros
696 @cindex macros, local variables in
698 The reason for using names that start with underscores for the local
699 variables is to avoid conflicts with variable names that occur within the
700 expressions that are substituted for @code{a} and @code{b}.  Eventually we
701 hope to design a new form of declaration syntax that allows you to declare
702 variables whose scopes start only after their initializers; this will be a
703 more reliable way to prevent such conflicts.
705 @noindent
706 Some more examples of the use of @code{typeof}:
708 @itemize @bullet
709 @item
710 This declares @code{y} with the type of what @code{x} points to.
712 @smallexample
713 typeof (*x) y;
714 @end smallexample
716 @item
717 This declares @code{y} as an array of such values.
719 @smallexample
720 typeof (*x) y[4];
721 @end smallexample
723 @item
724 This declares @code{y} as an array of pointers to characters:
726 @smallexample
727 typeof (typeof (char *)[4]) y;
728 @end smallexample
730 @noindent
731 It is equivalent to the following traditional C declaration:
733 @smallexample
734 char *y[4];
735 @end smallexample
737 To see the meaning of the declaration using @code{typeof}, and why it
738 might be a useful way to write, rewrite it with these macros:
740 @smallexample
741 #define pointer(T)  typeof(T *)
742 #define array(T, N) typeof(T [N])
743 @end smallexample
745 @noindent
746 Now the declaration can be rewritten this way:
748 @smallexample
749 array (pointer (char), 4) y;
750 @end smallexample
752 @noindent
753 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
754 pointers to @code{char}.
755 @end itemize
757 In GNU C, but not GNU C++, you may also declare the type of a variable
758 as @code{__auto_type}.  In that case, the declaration must declare
759 only one variable, whose declarator must just be an identifier, the
760 declaration must be initialized, and the type of the variable is
761 determined by the initializer; the name of the variable is not in
762 scope until after the initializer.  (In C++, you should use C++11
763 @code{auto} for this purpose.)  Using @code{__auto_type}, the
764 ``maximum'' macro above could be written as:
766 @smallexample
767 #define max(a,b) \
768   (@{ __auto_type _a = (a); \
769       __auto_type _b = (b); \
770     _a > _b ? _a : _b; @})
771 @end smallexample
773 Using @code{__auto_type} instead of @code{typeof} has two advantages:
775 @itemize @bullet
776 @item Each argument to the macro appears only once in the expansion of
777 the macro.  This prevents the size of the macro expansion growing
778 exponentially when calls to such macros are nested inside arguments of
779 such macros.
781 @item If the argument to the macro has variably modified type, it is
782 evaluated only once when using @code{__auto_type}, but twice if
783 @code{typeof} is used.
784 @end itemize
786 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
787 a more limited extension that permitted one to write
789 @smallexample
790 typedef @var{T} = @var{expr};
791 @end smallexample
793 @noindent
794 with the effect of declaring @var{T} to have the type of the expression
795 @var{expr}.  This extension does not work with GCC 3 (versions between
796 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
797 relies on it should be rewritten to use @code{typeof}:
799 @smallexample
800 typedef typeof(@var{expr}) @var{T};
801 @end smallexample
803 @noindent
804 This works with all versions of GCC@.
806 @node Conditionals
807 @section Conditionals with Omitted Operands
808 @cindex conditional expressions, extensions
809 @cindex omitted middle-operands
810 @cindex middle-operands, omitted
811 @cindex extensions, @code{?:}
812 @cindex @code{?:} extensions
814 The middle operand in a conditional expression may be omitted.  Then
815 if the first operand is nonzero, its value is the value of the conditional
816 expression.
818 Therefore, the expression
820 @smallexample
821 x ? : y
822 @end smallexample
824 @noindent
825 has the value of @code{x} if that is nonzero; otherwise, the value of
826 @code{y}.
828 This example is perfectly equivalent to
830 @smallexample
831 x ? x : y
832 @end smallexample
834 @cindex side effect in @code{?:}
835 @cindex @code{?:} side effect
836 @noindent
837 In this simple case, the ability to omit the middle operand is not
838 especially useful.  When it becomes useful is when the first operand does,
839 or may (if it is a macro argument), contain a side effect.  Then repeating
840 the operand in the middle would perform the side effect twice.  Omitting
841 the middle operand uses the value already computed without the undesirable
842 effects of recomputing it.
844 @node __int128
845 @section 128-bit integers
846 @cindex @code{__int128} data types
848 As an extension the integer scalar type @code{__int128} is supported for
849 targets which have an integer mode wide enough to hold 128 bits.
850 Simply write @code{__int128} for a signed 128-bit integer, or
851 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
852 support in GCC for expressing an integer constant of type @code{__int128}
853 for targets with @code{long long} integer less than 128 bits wide.
855 @node Long Long
856 @section Double-Word Integers
857 @cindex @code{long long} data types
858 @cindex double-word arithmetic
859 @cindex multiprecision arithmetic
860 @cindex @code{LL} integer suffix
861 @cindex @code{ULL} integer suffix
863 ISO C99 supports data types for integers that are at least 64 bits wide,
864 and as an extension GCC supports them in C90 mode and in C++.
865 Simply write @code{long long int} for a signed integer, or
866 @code{unsigned long long int} for an unsigned integer.  To make an
867 integer constant of type @code{long long int}, add the suffix @samp{LL}
868 to the integer.  To make an integer constant of type @code{unsigned long
869 long int}, add the suffix @samp{ULL} to the integer.
871 You can use these types in arithmetic like any other integer types.
872 Addition, subtraction, and bitwise boolean operations on these types
873 are open-coded on all types of machines.  Multiplication is open-coded
874 if the machine supports a fullword-to-doubleword widening multiply
875 instruction.  Division and shifts are open-coded only on machines that
876 provide special support.  The operations that are not open-coded use
877 special library routines that come with GCC@.
879 There may be pitfalls when you use @code{long long} types for function
880 arguments without function prototypes.  If a function
881 expects type @code{int} for its argument, and you pass a value of type
882 @code{long long int}, confusion results because the caller and the
883 subroutine disagree about the number of bytes for the argument.
884 Likewise, if the function expects @code{long long int} and you pass
885 @code{int}.  The best way to avoid such problems is to use prototypes.
887 @node Complex
888 @section Complex Numbers
889 @cindex complex numbers
890 @cindex @code{_Complex} keyword
891 @cindex @code{__complex__} keyword
893 ISO C99 supports complex floating data types, and as an extension GCC
894 supports them in C90 mode and in C++.  GCC also supports complex integer data
895 types which are not part of ISO C99.  You can declare complex types
896 using the keyword @code{_Complex}.  As an extension, the older GNU
897 keyword @code{__complex__} is also supported.
899 For example, @samp{_Complex double x;} declares @code{x} as a
900 variable whose real part and imaginary part are both of type
901 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
902 have real and imaginary parts of type @code{short int}; this is not
903 likely to be useful, but it shows that the set of complex types is
904 complete.
906 To write a constant with a complex data type, use the suffix @samp{i} or
907 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
908 has type @code{_Complex float} and @code{3i} has type
909 @code{_Complex int}.  Such a constant always has a pure imaginary
910 value, but you can form any complex value you like by adding one to a
911 real constant.  This is a GNU extension; if you have an ISO C99
912 conforming C library (such as the GNU C Library), and want to construct complex
913 constants of floating type, you should include @code{<complex.h>} and
914 use the macros @code{I} or @code{_Complex_I} instead.
916 @cindex @code{__real__} keyword
917 @cindex @code{__imag__} keyword
918 To extract the real part of a complex-valued expression @var{exp}, write
919 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
920 extract the imaginary part.  This is a GNU extension; for values of
921 floating type, you should use the ISO C99 functions @code{crealf},
922 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
923 @code{cimagl}, declared in @code{<complex.h>} and also provided as
924 built-in functions by GCC@.
926 @cindex complex conjugation
927 The operator @samp{~} performs complex conjugation when used on a value
928 with a complex type.  This is a GNU extension; for values of
929 floating type, you should use the ISO C99 functions @code{conjf},
930 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
931 provided as built-in functions by GCC@.
933 GCC can allocate complex automatic variables in a noncontiguous
934 fashion; it's even possible for the real part to be in a register while
935 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
936 debug info format can represent this, so use of DWARF 2 is recommended.
937 If you are using the stabs debug info format, GCC describes a noncontiguous
938 complex variable as if it were two separate variables of noncomplex type.
939 If the variable's actual name is @code{foo}, the two fictitious
940 variables are named @code{foo$real} and @code{foo$imag}.  You can
941 examine and set these two fictitious variables with your debugger.
943 @node Floating Types
944 @section Additional Floating Types
945 @cindex additional floating types
946 @cindex @code{__float80} data type
947 @cindex @code{__float128} data type
948 @cindex @code{w} floating point suffix
949 @cindex @code{q} floating point suffix
950 @cindex @code{W} floating point suffix
951 @cindex @code{Q} floating point suffix
953 As an extension, GNU C supports additional floating
954 types, @code{__float80} and @code{__float128} to support 80-bit
955 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
956 Support for additional types includes the arithmetic operators:
957 add, subtract, multiply, divide; unary arithmetic operators;
958 relational operators; equality operators; and conversions to and from
959 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
960 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
961 for @code{_float128}.  You can declare complex types using the
962 corresponding internal complex type, @code{XCmode} for @code{__float80}
963 type and @code{TCmode} for @code{__float128} type:
965 @smallexample
966 typedef _Complex float __attribute__((mode(TC))) _Complex128;
967 typedef _Complex float __attribute__((mode(XC))) _Complex80;
968 @end smallexample
970 Not all targets support additional floating-point types.  @code{__float80}
971 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
972 The @code{__float128} type is supported on hppa HP-UX targets.
974 @node Half-Precision
975 @section Half-Precision Floating Point
976 @cindex half-precision floating point
977 @cindex @code{__fp16} data type
979 On ARM targets, GCC supports half-precision (16-bit) floating point via
980 the @code{__fp16} type.  You must enable this type explicitly
981 with the @option{-mfp16-format} command-line option in order to use it.
983 ARM supports two incompatible representations for half-precision
984 floating-point values.  You must choose one of the representations and
985 use it consistently in your program.
987 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
988 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
989 There are 11 bits of significand precision, approximately 3
990 decimal digits.
992 Specifying @option{-mfp16-format=alternative} selects the ARM
993 alternative format.  This representation is similar to the IEEE
994 format, but does not support infinities or NaNs.  Instead, the range
995 of exponents is extended, so that this format can represent normalized
996 values in the range of @math{2^{-14}} to 131008.
998 The @code{__fp16} type is a storage format only.  For purposes
999 of arithmetic and other operations, @code{__fp16} values in C or C++
1000 expressions are automatically promoted to @code{float}.  In addition,
1001 you cannot declare a function with a return value or parameters
1002 of type @code{__fp16}.
1004 Note that conversions from @code{double} to @code{__fp16}
1005 involve an intermediate conversion to @code{float}.  Because
1006 of rounding, this can sometimes produce a different result than a
1007 direct conversion.
1009 ARM provides hardware support for conversions between
1010 @code{__fp16} and @code{float} values
1011 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1012 code using these hardware instructions if you compile with
1013 options to select an FPU that provides them;
1014 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1015 in addition to the @option{-mfp16-format} option to select
1016 a half-precision format.
1018 Language-level support for the @code{__fp16} data type is
1019 independent of whether GCC generates code using hardware floating-point
1020 instructions.  In cases where hardware support is not specified, GCC
1021 implements conversions between @code{__fp16} and @code{float} values
1022 as library calls.
1024 @node Decimal Float
1025 @section Decimal Floating Types
1026 @cindex decimal floating types
1027 @cindex @code{_Decimal32} data type
1028 @cindex @code{_Decimal64} data type
1029 @cindex @code{_Decimal128} data type
1030 @cindex @code{df} integer suffix
1031 @cindex @code{dd} integer suffix
1032 @cindex @code{dl} integer suffix
1033 @cindex @code{DF} integer suffix
1034 @cindex @code{DD} integer suffix
1035 @cindex @code{DL} integer suffix
1037 As an extension, GNU C supports decimal floating types as
1038 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1039 floating types in GCC will evolve as the draft technical report changes.
1040 Calling conventions for any target might also change.  Not all targets
1041 support decimal floating types.
1043 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1044 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1045 @code{float}, @code{double}, and @code{long double} whose radix is not
1046 specified by the C standard but is usually two.
1048 Support for decimal floating types includes the arithmetic operators
1049 add, subtract, multiply, divide; unary arithmetic operators;
1050 relational operators; equality operators; and conversions to and from
1051 integer and other floating types.  Use a suffix @samp{df} or
1052 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1053 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1054 @code{_Decimal128}.
1056 GCC support of decimal float as specified by the draft technical report
1057 is incomplete:
1059 @itemize @bullet
1060 @item
1061 When the value of a decimal floating type cannot be represented in the
1062 integer type to which it is being converted, the result is undefined
1063 rather than the result value specified by the draft technical report.
1065 @item
1066 GCC does not provide the C library functionality associated with
1067 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1068 @file{wchar.h}, which must come from a separate C library implementation.
1069 Because of this the GNU C compiler does not define macro
1070 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1071 the technical report.
1072 @end itemize
1074 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1075 are supported by the DWARF 2 debug information format.
1077 @node Hex Floats
1078 @section Hex Floats
1079 @cindex hex floats
1081 ISO C99 supports floating-point numbers written not only in the usual
1082 decimal notation, such as @code{1.55e1}, but also numbers such as
1083 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1084 supports this in C90 mode (except in some cases when strictly
1085 conforming) and in C++.  In that format the
1086 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1087 mandatory.  The exponent is a decimal number that indicates the power of
1088 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1089 @tex
1090 $1 {15\over16}$,
1091 @end tex
1092 @ifnottex
1093 1 15/16,
1094 @end ifnottex
1095 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1096 is the same as @code{1.55e1}.
1098 Unlike for floating-point numbers in the decimal notation the exponent
1099 is always required in the hexadecimal notation.  Otherwise the compiler
1100 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1101 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1102 extension for floating-point constants of type @code{float}.
1104 @node Fixed-Point
1105 @section Fixed-Point Types
1106 @cindex fixed-point types
1107 @cindex @code{_Fract} data type
1108 @cindex @code{_Accum} data type
1109 @cindex @code{_Sat} data type
1110 @cindex @code{hr} fixed-suffix
1111 @cindex @code{r} fixed-suffix
1112 @cindex @code{lr} fixed-suffix
1113 @cindex @code{llr} fixed-suffix
1114 @cindex @code{uhr} fixed-suffix
1115 @cindex @code{ur} fixed-suffix
1116 @cindex @code{ulr} fixed-suffix
1117 @cindex @code{ullr} fixed-suffix
1118 @cindex @code{hk} fixed-suffix
1119 @cindex @code{k} fixed-suffix
1120 @cindex @code{lk} fixed-suffix
1121 @cindex @code{llk} fixed-suffix
1122 @cindex @code{uhk} fixed-suffix
1123 @cindex @code{uk} fixed-suffix
1124 @cindex @code{ulk} fixed-suffix
1125 @cindex @code{ullk} fixed-suffix
1126 @cindex @code{HR} fixed-suffix
1127 @cindex @code{R} fixed-suffix
1128 @cindex @code{LR} fixed-suffix
1129 @cindex @code{LLR} fixed-suffix
1130 @cindex @code{UHR} fixed-suffix
1131 @cindex @code{UR} fixed-suffix
1132 @cindex @code{ULR} fixed-suffix
1133 @cindex @code{ULLR} fixed-suffix
1134 @cindex @code{HK} fixed-suffix
1135 @cindex @code{K} fixed-suffix
1136 @cindex @code{LK} fixed-suffix
1137 @cindex @code{LLK} fixed-suffix
1138 @cindex @code{UHK} fixed-suffix
1139 @cindex @code{UK} fixed-suffix
1140 @cindex @code{ULK} fixed-suffix
1141 @cindex @code{ULLK} fixed-suffix
1143 As an extension, GNU C supports fixed-point types as
1144 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1145 types in GCC will evolve as the draft technical report changes.
1146 Calling conventions for any target might also change.  Not all targets
1147 support fixed-point types.
1149 The fixed-point types are
1150 @code{short _Fract},
1151 @code{_Fract},
1152 @code{long _Fract},
1153 @code{long long _Fract},
1154 @code{unsigned short _Fract},
1155 @code{unsigned _Fract},
1156 @code{unsigned long _Fract},
1157 @code{unsigned long long _Fract},
1158 @code{_Sat short _Fract},
1159 @code{_Sat _Fract},
1160 @code{_Sat long _Fract},
1161 @code{_Sat long long _Fract},
1162 @code{_Sat unsigned short _Fract},
1163 @code{_Sat unsigned _Fract},
1164 @code{_Sat unsigned long _Fract},
1165 @code{_Sat unsigned long long _Fract},
1166 @code{short _Accum},
1167 @code{_Accum},
1168 @code{long _Accum},
1169 @code{long long _Accum},
1170 @code{unsigned short _Accum},
1171 @code{unsigned _Accum},
1172 @code{unsigned long _Accum},
1173 @code{unsigned long long _Accum},
1174 @code{_Sat short _Accum},
1175 @code{_Sat _Accum},
1176 @code{_Sat long _Accum},
1177 @code{_Sat long long _Accum},
1178 @code{_Sat unsigned short _Accum},
1179 @code{_Sat unsigned _Accum},
1180 @code{_Sat unsigned long _Accum},
1181 @code{_Sat unsigned long long _Accum}.
1183 Fixed-point data values contain fractional and optional integral parts.
1184 The format of fixed-point data varies and depends on the target machine.
1186 Support for fixed-point types includes:
1187 @itemize @bullet
1188 @item
1189 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1190 @item
1191 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1192 @item
1193 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1194 @item
1195 binary shift operators (@code{<<}, @code{>>})
1196 @item
1197 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1198 @item
1199 equality operators (@code{==}, @code{!=})
1200 @item
1201 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1202 @code{<<=}, @code{>>=})
1203 @item
1204 conversions to and from integer, floating-point, or fixed-point types
1205 @end itemize
1207 Use a suffix in a fixed-point literal constant:
1208 @itemize
1209 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1210 @code{_Sat short _Fract}
1211 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1212 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1213 @code{_Sat long _Fract}
1214 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1215 @code{_Sat long long _Fract}
1216 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1217 @code{_Sat unsigned short _Fract}
1218 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1219 @code{_Sat unsigned _Fract}
1220 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1221 @code{_Sat unsigned long _Fract}
1222 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1223 and @code{_Sat unsigned long long _Fract}
1224 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1225 @code{_Sat short _Accum}
1226 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1227 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1228 @code{_Sat long _Accum}
1229 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1230 @code{_Sat long long _Accum}
1231 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1232 @code{_Sat unsigned short _Accum}
1233 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1234 @code{_Sat unsigned _Accum}
1235 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1236 @code{_Sat unsigned long _Accum}
1237 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1238 and @code{_Sat unsigned long long _Accum}
1239 @end itemize
1241 GCC support of fixed-point types as specified by the draft technical report
1242 is incomplete:
1244 @itemize @bullet
1245 @item
1246 Pragmas to control overflow and rounding behaviors are not implemented.
1247 @end itemize
1249 Fixed-point types are supported by the DWARF 2 debug information format.
1251 @node Named Address Spaces
1252 @section Named Address Spaces
1253 @cindex Named Address Spaces
1255 As an extension, GNU C supports named address spaces as
1256 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1257 address spaces in GCC will evolve as the draft technical report
1258 changes.  Calling conventions for any target might also change.  At
1259 present, only the AVR, SPU, M32C, and RL78 targets support address
1260 spaces other than the generic address space.
1262 Address space identifiers may be used exactly like any other C type
1263 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1264 document for more details.
1266 @anchor{AVR Named Address Spaces}
1267 @subsection AVR Named Address Spaces
1269 On the AVR target, there are several address spaces that can be used
1270 in order to put read-only data into the flash memory and access that
1271 data by means of the special instructions @code{LPM} or @code{ELPM}
1272 needed to read from flash.
1274 Per default, any data including read-only data is located in RAM
1275 (the generic address space) so that non-generic address spaces are
1276 needed to locate read-only data in flash memory
1277 @emph{and} to generate the right instructions to access this data
1278 without using (inline) assembler code.
1280 @table @code
1281 @item __flash
1282 @cindex @code{__flash} AVR Named Address Spaces
1283 The @code{__flash} qualifier locates data in the
1284 @code{.progmem.data} section. Data is read using the @code{LPM}
1285 instruction. Pointers to this address space are 16 bits wide.
1287 @item __flash1
1288 @itemx __flash2
1289 @itemx __flash3
1290 @itemx __flash4
1291 @itemx __flash5
1292 @cindex @code{__flash1} AVR Named Address Spaces
1293 @cindex @code{__flash2} AVR Named Address Spaces
1294 @cindex @code{__flash3} AVR Named Address Spaces
1295 @cindex @code{__flash4} AVR Named Address Spaces
1296 @cindex @code{__flash5} AVR Named Address Spaces
1297 These are 16-bit address spaces locating data in section
1298 @code{.progmem@var{N}.data} where @var{N} refers to
1299 address space @code{__flash@var{N}}.
1300 The compiler sets the @code{RAMPZ} segment register appropriately 
1301 before reading data by means of the @code{ELPM} instruction.
1303 @item __memx
1304 @cindex @code{__memx} AVR Named Address Spaces
1305 This is a 24-bit address space that linearizes flash and RAM:
1306 If the high bit of the address is set, data is read from
1307 RAM using the lower two bytes as RAM address.
1308 If the high bit of the address is clear, data is read from flash
1309 with @code{RAMPZ} set according to the high byte of the address.
1310 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1312 Objects in this address space are located in @code{.progmemx.data}.
1313 @end table
1315 @b{Example}
1317 @smallexample
1318 char my_read (const __flash char ** p)
1320     /* p is a pointer to RAM that points to a pointer to flash.
1321        The first indirection of p reads that flash pointer
1322        from RAM and the second indirection reads a char from this
1323        flash address.  */
1325     return **p;
1328 /* Locate array[] in flash memory */
1329 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1331 int i = 1;
1333 int main (void)
1335    /* Return 17 by reading from flash memory */
1336    return array[array[i]];
1338 @end smallexample
1340 @noindent
1341 For each named address space supported by avr-gcc there is an equally
1342 named but uppercase built-in macro defined. 
1343 The purpose is to facilitate testing if respective address space
1344 support is available or not:
1346 @smallexample
1347 #ifdef __FLASH
1348 const __flash int var = 1;
1350 int read_var (void)
1352     return var;
1354 #else
1355 #include <avr/pgmspace.h> /* From AVR-LibC */
1357 const int var PROGMEM = 1;
1359 int read_var (void)
1361     return (int) pgm_read_word (&var);
1363 #endif /* __FLASH */
1364 @end smallexample
1366 @noindent
1367 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1368 locates data in flash but
1369 accesses to these data read from generic address space, i.e.@:
1370 from RAM,
1371 so that you need special accessors like @code{pgm_read_byte}
1372 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1373 together with attribute @code{progmem}.
1375 @noindent
1376 @b{Limitations and caveats}
1378 @itemize
1379 @item
1380 Reading across the 64@tie{}KiB section boundary of
1381 the @code{__flash} or @code{__flash@var{N}} address spaces
1382 shows undefined behavior. The only address space that
1383 supports reading across the 64@tie{}KiB flash segment boundaries is
1384 @code{__memx}.
1386 @item
1387 If you use one of the @code{__flash@var{N}} address spaces
1388 you must arrange your linker script to locate the
1389 @code{.progmem@var{N}.data} sections according to your needs.
1391 @item
1392 Any data or pointers to the non-generic address spaces must
1393 be qualified as @code{const}, i.e.@: as read-only data.
1394 This still applies if the data in one of these address
1395 spaces like software version number or calibration lookup table are intended to
1396 be changed after load time by, say, a boot loader. In this case
1397 the right qualification is @code{const} @code{volatile} so that the compiler
1398 must not optimize away known values or insert them
1399 as immediates into operands of instructions.
1401 @item
1402 The following code initializes a variable @code{pfoo}
1403 located in static storage with a 24-bit address:
1404 @smallexample
1405 extern const __memx char foo;
1406 const __memx void *pfoo = &foo;
1407 @end smallexample
1409 @noindent
1410 Such code requires at least binutils 2.23, see
1411 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1413 @end itemize
1415 @subsection M32C Named Address Spaces
1416 @cindex @code{__far} M32C Named Address Spaces
1418 On the M32C target, with the R8C and M16C CPU variants, variables
1419 qualified with @code{__far} are accessed using 32-bit addresses in
1420 order to access memory beyond the first 64@tie{}Ki bytes.  If
1421 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1422 effect.
1424 @subsection RL78 Named Address Spaces
1425 @cindex @code{__far} RL78 Named Address Spaces
1427 On the RL78 target, variables qualified with @code{__far} are accessed
1428 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1429 addresses.  Non-far variables are assumed to appear in the topmost
1430 64@tie{}KiB of the address space.
1432 @subsection SPU Named Address Spaces
1433 @cindex @code{__ea} SPU Named Address Spaces
1435 On the SPU target variables may be declared as
1436 belonging to another address space by qualifying the type with the
1437 @code{__ea} address space identifier:
1439 @smallexample
1440 extern int __ea i;
1441 @end smallexample
1443 @noindent 
1444 The compiler generates special code to access the variable @code{i}.
1445 It may use runtime library
1446 support, or generate special machine instructions to access that address
1447 space.
1449 @node Zero Length
1450 @section Arrays of Length Zero
1451 @cindex arrays of length zero
1452 @cindex zero-length arrays
1453 @cindex length-zero arrays
1454 @cindex flexible array members
1456 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1457 last element of a structure that is really a header for a variable-length
1458 object:
1460 @smallexample
1461 struct line @{
1462   int length;
1463   char contents[0];
1466 struct line *thisline = (struct line *)
1467   malloc (sizeof (struct line) + this_length);
1468 thisline->length = this_length;
1469 @end smallexample
1471 In ISO C90, you would have to give @code{contents} a length of 1, which
1472 means either you waste space or complicate the argument to @code{malloc}.
1474 In ISO C99, you would use a @dfn{flexible array member}, which is
1475 slightly different in syntax and semantics:
1477 @itemize @bullet
1478 @item
1479 Flexible array members are written as @code{contents[]} without
1480 the @code{0}.
1482 @item
1483 Flexible array members have incomplete type, and so the @code{sizeof}
1484 operator may not be applied.  As a quirk of the original implementation
1485 of zero-length arrays, @code{sizeof} evaluates to zero.
1487 @item
1488 Flexible array members may only appear as the last member of a
1489 @code{struct} that is otherwise non-empty.
1491 @item
1492 A structure containing a flexible array member, or a union containing
1493 such a structure (possibly recursively), may not be a member of a
1494 structure or an element of an array.  (However, these uses are
1495 permitted by GCC as extensions.)
1496 @end itemize
1498 GCC versions before 3.0 allowed zero-length arrays to be statically
1499 initialized, as if they were flexible arrays.  In addition to those
1500 cases that were useful, it also allowed initializations in situations
1501 that would corrupt later data.  Non-empty initialization of zero-length
1502 arrays is now treated like any case where there are more initializer
1503 elements than the array holds, in that a suitable warning about ``excess
1504 elements in array'' is given, and the excess elements (all of them, in
1505 this case) are ignored.
1507 Instead GCC allows static initialization of flexible array members.
1508 This is equivalent to defining a new structure containing the original
1509 structure followed by an array of sufficient size to contain the data.
1510 E.g.@: in the following, @code{f1} is constructed as if it were declared
1511 like @code{f2}.
1513 @smallexample
1514 struct f1 @{
1515   int x; int y[];
1516 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1518 struct f2 @{
1519   struct f1 f1; int data[3];
1520 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1521 @end smallexample
1523 @noindent
1524 The convenience of this extension is that @code{f1} has the desired
1525 type, eliminating the need to consistently refer to @code{f2.f1}.
1527 This has symmetry with normal static arrays, in that an array of
1528 unknown size is also written with @code{[]}.
1530 Of course, this extension only makes sense if the extra data comes at
1531 the end of a top-level object, as otherwise we would be overwriting
1532 data at subsequent offsets.  To avoid undue complication and confusion
1533 with initialization of deeply nested arrays, we simply disallow any
1534 non-empty initialization except when the structure is the top-level
1535 object.  For example:
1537 @smallexample
1538 struct foo @{ int x; int y[]; @};
1539 struct bar @{ struct foo z; @};
1541 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1542 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1543 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1544 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1545 @end smallexample
1547 @node Empty Structures
1548 @section Structures With No Members
1549 @cindex empty structures
1550 @cindex zero-size structures
1552 GCC permits a C structure to have no members:
1554 @smallexample
1555 struct empty @{
1557 @end smallexample
1559 The structure has size zero.  In C++, empty structures are part
1560 of the language.  G++ treats empty structures as if they had a single
1561 member of type @code{char}.
1563 @node Variable Length
1564 @section Arrays of Variable Length
1565 @cindex variable-length arrays
1566 @cindex arrays of variable length
1567 @cindex VLAs
1569 Variable-length automatic arrays are allowed in ISO C99, and as an
1570 extension GCC accepts them in C90 mode and in C++.  These arrays are
1571 declared like any other automatic arrays, but with a length that is not
1572 a constant expression.  The storage is allocated at the point of
1573 declaration and deallocated when the block scope containing the declaration
1574 exits.  For
1575 example:
1577 @smallexample
1578 FILE *
1579 concat_fopen (char *s1, char *s2, char *mode)
1581   char str[strlen (s1) + strlen (s2) + 1];
1582   strcpy (str, s1);
1583   strcat (str, s2);
1584   return fopen (str, mode);
1586 @end smallexample
1588 @cindex scope of a variable length array
1589 @cindex variable-length array scope
1590 @cindex deallocating variable length arrays
1591 Jumping or breaking out of the scope of the array name deallocates the
1592 storage.  Jumping into the scope is not allowed; you get an error
1593 message for it.
1595 @cindex @code{alloca} vs variable-length arrays
1596 You can use the function @code{alloca} to get an effect much like
1597 variable-length arrays.  The function @code{alloca} is available in
1598 many other C implementations (but not in all).  On the other hand,
1599 variable-length arrays are more elegant.
1601 There are other differences between these two methods.  Space allocated
1602 with @code{alloca} exists until the containing @emph{function} returns.
1603 The space for a variable-length array is deallocated as soon as the array
1604 name's scope ends.  (If you use both variable-length arrays and
1605 @code{alloca} in the same function, deallocation of a variable-length array
1606 also deallocates anything more recently allocated with @code{alloca}.)
1608 You can also use variable-length arrays as arguments to functions:
1610 @smallexample
1611 struct entry
1612 tester (int len, char data[len][len])
1614   /* @r{@dots{}} */
1616 @end smallexample
1618 The length of an array is computed once when the storage is allocated
1619 and is remembered for the scope of the array in case you access it with
1620 @code{sizeof}.
1622 If you want to pass the array first and the length afterward, you can
1623 use a forward declaration in the parameter list---another GNU extension.
1625 @smallexample
1626 struct entry
1627 tester (int len; char data[len][len], int len)
1629   /* @r{@dots{}} */
1631 @end smallexample
1633 @cindex parameter forward declaration
1634 The @samp{int len} before the semicolon is a @dfn{parameter forward
1635 declaration}, and it serves the purpose of making the name @code{len}
1636 known when the declaration of @code{data} is parsed.
1638 You can write any number of such parameter forward declarations in the
1639 parameter list.  They can be separated by commas or semicolons, but the
1640 last one must end with a semicolon, which is followed by the ``real''
1641 parameter declarations.  Each forward declaration must match a ``real''
1642 declaration in parameter name and data type.  ISO C99 does not support
1643 parameter forward declarations.
1645 @node Variadic Macros
1646 @section Macros with a Variable Number of Arguments.
1647 @cindex variable number of arguments
1648 @cindex macro with variable arguments
1649 @cindex rest argument (in macro)
1650 @cindex variadic macros
1652 In the ISO C standard of 1999, a macro can be declared to accept a
1653 variable number of arguments much as a function can.  The syntax for
1654 defining the macro is similar to that of a function.  Here is an
1655 example:
1657 @smallexample
1658 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1659 @end smallexample
1661 @noindent
1662 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1663 such a macro, it represents the zero or more tokens until the closing
1664 parenthesis that ends the invocation, including any commas.  This set of
1665 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1666 wherever it appears.  See the CPP manual for more information.
1668 GCC has long supported variadic macros, and used a different syntax that
1669 allowed you to give a name to the variable arguments just like any other
1670 argument.  Here is an example:
1672 @smallexample
1673 #define debug(format, args...) fprintf (stderr, format, args)
1674 @end smallexample
1676 @noindent
1677 This is in all ways equivalent to the ISO C example above, but arguably
1678 more readable and descriptive.
1680 GNU CPP has two further variadic macro extensions, and permits them to
1681 be used with either of the above forms of macro definition.
1683 In standard C, you are not allowed to leave the variable argument out
1684 entirely; but you are allowed to pass an empty argument.  For example,
1685 this invocation is invalid in ISO C, because there is no comma after
1686 the string:
1688 @smallexample
1689 debug ("A message")
1690 @end smallexample
1692 GNU CPP permits you to completely omit the variable arguments in this
1693 way.  In the above examples, the compiler would complain, though since
1694 the expansion of the macro still has the extra comma after the format
1695 string.
1697 To help solve this problem, CPP behaves specially for variable arguments
1698 used with the token paste operator, @samp{##}.  If instead you write
1700 @smallexample
1701 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1702 @end smallexample
1704 @noindent
1705 and if the variable arguments are omitted or empty, the @samp{##}
1706 operator causes the preprocessor to remove the comma before it.  If you
1707 do provide some variable arguments in your macro invocation, GNU CPP
1708 does not complain about the paste operation and instead places the
1709 variable arguments after the comma.  Just like any other pasted macro
1710 argument, these arguments are not macro expanded.
1712 @node Escaped Newlines
1713 @section Slightly Looser Rules for Escaped Newlines
1714 @cindex escaped newlines
1715 @cindex newlines (escaped)
1717 Recently, the preprocessor has relaxed its treatment of escaped
1718 newlines.  Previously, the newline had to immediately follow a
1719 backslash.  The current implementation allows whitespace in the form
1720 of spaces, horizontal and vertical tabs, and form feeds between the
1721 backslash and the subsequent newline.  The preprocessor issues a
1722 warning, but treats it as a valid escaped newline and combines the two
1723 lines to form a single logical line.  This works within comments and
1724 tokens, as well as between tokens.  Comments are @emph{not} treated as
1725 whitespace for the purposes of this relaxation, since they have not
1726 yet been replaced with spaces.
1728 @node Subscripting
1729 @section Non-Lvalue Arrays May Have Subscripts
1730 @cindex subscripting
1731 @cindex arrays, non-lvalue
1733 @cindex subscripting and function values
1734 In ISO C99, arrays that are not lvalues still decay to pointers, and
1735 may be subscripted, although they may not be modified or used after
1736 the next sequence point and the unary @samp{&} operator may not be
1737 applied to them.  As an extension, GNU C allows such arrays to be
1738 subscripted in C90 mode, though otherwise they do not decay to
1739 pointers outside C99 mode.  For example,
1740 this is valid in GNU C though not valid in C90:
1742 @smallexample
1743 @group
1744 struct foo @{int a[4];@};
1746 struct foo f();
1748 bar (int index)
1750   return f().a[index];
1752 @end group
1753 @end smallexample
1755 @node Pointer Arith
1756 @section Arithmetic on @code{void}- and Function-Pointers
1757 @cindex void pointers, arithmetic
1758 @cindex void, size of pointer to
1759 @cindex function pointers, arithmetic
1760 @cindex function, size of pointer to
1762 In GNU C, addition and subtraction operations are supported on pointers to
1763 @code{void} and on pointers to functions.  This is done by treating the
1764 size of a @code{void} or of a function as 1.
1766 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1767 and on function types, and returns 1.
1769 @opindex Wpointer-arith
1770 The option @option{-Wpointer-arith} requests a warning if these extensions
1771 are used.
1773 @node Initializers
1774 @section Non-Constant Initializers
1775 @cindex initializers, non-constant
1776 @cindex non-constant initializers
1778 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1779 automatic variable are not required to be constant expressions in GNU C@.
1780 Here is an example of an initializer with run-time varying elements:
1782 @smallexample
1783 foo (float f, float g)
1785   float beat_freqs[2] = @{ f-g, f+g @};
1786   /* @r{@dots{}} */
1788 @end smallexample
1790 @node Compound Literals
1791 @section Compound Literals
1792 @cindex constructor expressions
1793 @cindex initializations in expressions
1794 @cindex structures, constructor expression
1795 @cindex expressions, constructor
1796 @cindex compound literals
1797 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1799 ISO C99 supports compound literals.  A compound literal looks like
1800 a cast containing an initializer.  Its value is an object of the
1801 type specified in the cast, containing the elements specified in
1802 the initializer; it is an lvalue.  As an extension, GCC supports
1803 compound literals in C90 mode and in C++, though the semantics are
1804 somewhat different in C++.
1806 Usually, the specified type is a structure.  Assume that
1807 @code{struct foo} and @code{structure} are declared as shown:
1809 @smallexample
1810 struct foo @{int a; char b[2];@} structure;
1811 @end smallexample
1813 @noindent
1814 Here is an example of constructing a @code{struct foo} with a compound literal:
1816 @smallexample
1817 structure = ((struct foo) @{x + y, 'a', 0@});
1818 @end smallexample
1820 @noindent
1821 This is equivalent to writing the following:
1823 @smallexample
1825   struct foo temp = @{x + y, 'a', 0@};
1826   structure = temp;
1828 @end smallexample
1830 You can also construct an array, though this is dangerous in C++, as
1831 explained below.  If all the elements of the compound literal are
1832 (made up of) simple constant expressions, suitable for use in
1833 initializers of objects of static storage duration, then the compound
1834 literal can be coerced to a pointer to its first element and used in
1835 such an initializer, as shown here:
1837 @smallexample
1838 char **foo = (char *[]) @{ "x", "y", "z" @};
1839 @end smallexample
1841 Compound literals for scalar types and union types are
1842 also allowed, but then the compound literal is equivalent
1843 to a cast.
1845 As a GNU extension, GCC allows initialization of objects with static storage
1846 duration by compound literals (which is not possible in ISO C99, because
1847 the initializer is not a constant).
1848 It is handled as if the object is initialized only with the bracket
1849 enclosed list if the types of the compound literal and the object match.
1850 The initializer list of the compound literal must be constant.
1851 If the object being initialized has array type of unknown size, the size is
1852 determined by compound literal size.
1854 @smallexample
1855 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1856 static int y[] = (int []) @{1, 2, 3@};
1857 static int z[] = (int [3]) @{1@};
1858 @end smallexample
1860 @noindent
1861 The above lines are equivalent to the following:
1862 @smallexample
1863 static struct foo x = @{1, 'a', 'b'@};
1864 static int y[] = @{1, 2, 3@};
1865 static int z[] = @{1, 0, 0@};
1866 @end smallexample
1868 In C, a compound literal designates an unnamed object with static or
1869 automatic storage duration.  In C++, a compound literal designates a
1870 temporary object, which only lives until the end of its
1871 full-expression.  As a result, well-defined C code that takes the
1872 address of a subobject of a compound literal can be undefined in C++.
1873 For instance, if the array compound literal example above appeared
1874 inside a function, any subsequent use of @samp{foo} in C++ has
1875 undefined behavior because the lifetime of the array ends after the
1876 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1877 the conversion of a temporary array to a pointer.
1879 As an optimization, the C++ compiler sometimes gives array compound
1880 literals longer lifetimes: when the array either appears outside a
1881 function or has const-qualified type.  If @samp{foo} and its
1882 initializer had elements of @samp{char *const} type rather than
1883 @samp{char *}, or if @samp{foo} were a global variable, the array
1884 would have static storage duration.  But it is probably safest just to
1885 avoid the use of array compound literals in code compiled as C++.
1887 @node Designated Inits
1888 @section Designated Initializers
1889 @cindex initializers with labeled elements
1890 @cindex labeled elements in initializers
1891 @cindex case labels in initializers
1892 @cindex designated initializers
1894 Standard C90 requires the elements of an initializer to appear in a fixed
1895 order, the same as the order of the elements in the array or structure
1896 being initialized.
1898 In ISO C99 you can give the elements in any order, specifying the array
1899 indices or structure field names they apply to, and GNU C allows this as
1900 an extension in C90 mode as well.  This extension is not
1901 implemented in GNU C++.
1903 To specify an array index, write
1904 @samp{[@var{index}] =} before the element value.  For example,
1906 @smallexample
1907 int a[6] = @{ [4] = 29, [2] = 15 @};
1908 @end smallexample
1910 @noindent
1911 is equivalent to
1913 @smallexample
1914 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1915 @end smallexample
1917 @noindent
1918 The index values must be constant expressions, even if the array being
1919 initialized is automatic.
1921 An alternative syntax for this that has been obsolete since GCC 2.5 but
1922 GCC still accepts is to write @samp{[@var{index}]} before the element
1923 value, with no @samp{=}.
1925 To initialize a range of elements to the same value, write
1926 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1927 extension.  For example,
1929 @smallexample
1930 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1931 @end smallexample
1933 @noindent
1934 If the value in it has side-effects, the side-effects happen only once,
1935 not for each initialized field by the range initializer.
1937 @noindent
1938 Note that the length of the array is the highest value specified
1939 plus one.
1941 In a structure initializer, specify the name of a field to initialize
1942 with @samp{.@var{fieldname} =} before the element value.  For example,
1943 given the following structure,
1945 @smallexample
1946 struct point @{ int x, y; @};
1947 @end smallexample
1949 @noindent
1950 the following initialization
1952 @smallexample
1953 struct point p = @{ .y = yvalue, .x = xvalue @};
1954 @end smallexample
1956 @noindent
1957 is equivalent to
1959 @smallexample
1960 struct point p = @{ xvalue, yvalue @};
1961 @end smallexample
1963 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1964 @samp{@var{fieldname}:}, as shown here:
1966 @smallexample
1967 struct point p = @{ y: yvalue, x: xvalue @};
1968 @end smallexample
1970 @cindex designators
1971 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1972 @dfn{designator}.  You can also use a designator (or the obsolete colon
1973 syntax) when initializing a union, to specify which element of the union
1974 should be used.  For example,
1976 @smallexample
1977 union foo @{ int i; double d; @};
1979 union foo f = @{ .d = 4 @};
1980 @end smallexample
1982 @noindent
1983 converts 4 to a @code{double} to store it in the union using
1984 the second element.  By contrast, casting 4 to type @code{union foo}
1985 stores it into the union as the integer @code{i}, since it is
1986 an integer.  (@xref{Cast to Union}.)
1988 You can combine this technique of naming elements with ordinary C
1989 initialization of successive elements.  Each initializer element that
1990 does not have a designator applies to the next consecutive element of the
1991 array or structure.  For example,
1993 @smallexample
1994 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1995 @end smallexample
1997 @noindent
1998 is equivalent to
2000 @smallexample
2001 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2002 @end smallexample
2004 Labeling the elements of an array initializer is especially useful
2005 when the indices are characters or belong to an @code{enum} type.
2006 For example:
2008 @smallexample
2009 int whitespace[256]
2010   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2011       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2012 @end smallexample
2014 @cindex designator lists
2015 You can also write a series of @samp{.@var{fieldname}} and
2016 @samp{[@var{index}]} designators before an @samp{=} to specify a
2017 nested subobject to initialize; the list is taken relative to the
2018 subobject corresponding to the closest surrounding brace pair.  For
2019 example, with the @samp{struct point} declaration above:
2021 @smallexample
2022 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2023 @end smallexample
2025 @noindent
2026 If the same field is initialized multiple times, it has the value from
2027 the last initialization.  If any such overridden initialization has
2028 side-effect, it is unspecified whether the side-effect happens or not.
2029 Currently, GCC discards them and issues a warning.
2031 @node Case Ranges
2032 @section Case Ranges
2033 @cindex case ranges
2034 @cindex ranges in case statements
2036 You can specify a range of consecutive values in a single @code{case} label,
2037 like this:
2039 @smallexample
2040 case @var{low} ... @var{high}:
2041 @end smallexample
2043 @noindent
2044 This has the same effect as the proper number of individual @code{case}
2045 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2047 This feature is especially useful for ranges of ASCII character codes:
2049 @smallexample
2050 case 'A' ... 'Z':
2051 @end smallexample
2053 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2054 it may be parsed wrong when you use it with integer values.  For example,
2055 write this:
2057 @smallexample
2058 case 1 ... 5:
2059 @end smallexample
2061 @noindent
2062 rather than this:
2064 @smallexample
2065 case 1...5:
2066 @end smallexample
2068 @node Cast to Union
2069 @section Cast to a Union Type
2070 @cindex cast to a union
2071 @cindex union, casting to a
2073 A cast to union type is similar to other casts, except that the type
2074 specified is a union type.  You can specify the type either with
2075 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2076 a constructor, not a cast, and hence does not yield an lvalue like
2077 normal casts.  (@xref{Compound Literals}.)
2079 The types that may be cast to the union type are those of the members
2080 of the union.  Thus, given the following union and variables:
2082 @smallexample
2083 union foo @{ int i; double d; @};
2084 int x;
2085 double y;
2086 @end smallexample
2088 @noindent
2089 both @code{x} and @code{y} can be cast to type @code{union foo}.
2091 Using the cast as the right-hand side of an assignment to a variable of
2092 union type is equivalent to storing in a member of the union:
2094 @smallexample
2095 union foo u;
2096 /* @r{@dots{}} */
2097 u = (union foo) x  @equiv{}  u.i = x
2098 u = (union foo) y  @equiv{}  u.d = y
2099 @end smallexample
2101 You can also use the union cast as a function argument:
2103 @smallexample
2104 void hack (union foo);
2105 /* @r{@dots{}} */
2106 hack ((union foo) x);
2107 @end smallexample
2109 @node Mixed Declarations
2110 @section Mixed Declarations and Code
2111 @cindex mixed declarations and code
2112 @cindex declarations, mixed with code
2113 @cindex code, mixed with declarations
2115 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2116 within compound statements.  As an extension, GNU C also allows this in
2117 C90 mode.  For example, you could do:
2119 @smallexample
2120 int i;
2121 /* @r{@dots{}} */
2122 i++;
2123 int j = i + 2;
2124 @end smallexample
2126 Each identifier is visible from where it is declared until the end of
2127 the enclosing block.
2129 @node Function Attributes
2130 @section Declaring Attributes of Functions
2131 @cindex function attributes
2132 @cindex declaring attributes of functions
2133 @cindex functions that never return
2134 @cindex functions that return more than once
2135 @cindex functions that have no side effects
2136 @cindex functions in arbitrary sections
2137 @cindex functions that behave like malloc
2138 @cindex @code{volatile} applied to function
2139 @cindex @code{const} applied to function
2140 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2141 @cindex functions with non-null pointer arguments
2142 @cindex functions that are passed arguments in registers on the 386
2143 @cindex functions that pop the argument stack on the 386
2144 @cindex functions that do not pop the argument stack on the 386
2145 @cindex functions that have different compilation options on the 386
2146 @cindex functions that have different optimization options
2147 @cindex functions that are dynamically resolved
2149 In GNU C, you declare certain things about functions called in your program
2150 which help the compiler optimize function calls and check your code more
2151 carefully.
2153 The keyword @code{__attribute__} allows you to specify special
2154 attributes when making a declaration.  This keyword is followed by an
2155 attribute specification inside double parentheses.  The following
2156 attributes are currently defined for functions on all targets:
2157 @code{aligned}, @code{alloc_size}, @code{noreturn},
2158 @code{returns_twice}, @code{noinline}, @code{noclone},
2159 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2160 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2161 @code{no_instrument_function}, @code{no_split_stack},
2162 @code{section}, @code{constructor},
2163 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2164 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2165 @code{warn_unused_result}, @code{nonnull},
2166 @code{returns_nonnull}, @code{gnu_inline},
2167 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2168 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2169 @code{no_sanitize_undefined},
2170 @code{error} and @code{warning}.
2171 Several other attributes are defined for functions on particular
2172 target systems.  Other attributes, including @code{section} are
2173 supported for variables declarations (@pxref{Variable Attributes})
2174 and for types (@pxref{Type Attributes}).
2176 GCC plugins may provide their own attributes.
2178 You may also specify attributes with @samp{__} preceding and following
2179 each keyword.  This allows you to use them in header files without
2180 being concerned about a possible macro of the same name.  For example,
2181 you may use @code{__noreturn__} instead of @code{noreturn}.
2183 @xref{Attribute Syntax}, for details of the exact syntax for using
2184 attributes.
2186 @table @code
2187 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2189 @item alias ("@var{target}")
2190 @cindex @code{alias} attribute
2191 The @code{alias} attribute causes the declaration to be emitted as an
2192 alias for another symbol, which must be specified.  For instance,
2194 @smallexample
2195 void __f () @{ /* @r{Do something.} */; @}
2196 void f () __attribute__ ((weak, alias ("__f")));
2197 @end smallexample
2199 @noindent
2200 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2201 mangled name for the target must be used.  It is an error if @samp{__f}
2202 is not defined in the same translation unit.
2204 Not all target machines support this attribute.
2206 @item aligned (@var{alignment})
2207 @cindex @code{aligned} attribute
2208 This attribute specifies a minimum alignment for the function,
2209 measured in bytes.
2211 You cannot use this attribute to decrease the alignment of a function,
2212 only to increase it.  However, when you explicitly specify a function
2213 alignment this overrides the effect of the
2214 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2215 function.
2217 Note that the effectiveness of @code{aligned} attributes may be
2218 limited by inherent limitations in your linker.  On many systems, the
2219 linker is only able to arrange for functions to be aligned up to a
2220 certain maximum alignment.  (For some linkers, the maximum supported
2221 alignment may be very very small.)  See your linker documentation for
2222 further information.
2224 The @code{aligned} attribute can also be used for variables and fields
2225 (@pxref{Variable Attributes}.)
2227 @item alloc_size
2228 @cindex @code{alloc_size} attribute
2229 The @code{alloc_size} attribute is used to tell the compiler that the
2230 function return value points to memory, where the size is given by
2231 one or two of the functions parameters.  GCC uses this
2232 information to improve the correctness of @code{__builtin_object_size}.
2234 The function parameter(s) denoting the allocated size are specified by
2235 one or two integer arguments supplied to the attribute.  The allocated size
2236 is either the value of the single function argument specified or the product
2237 of the two function arguments specified.  Argument numbering starts at
2238 one.
2240 For instance,
2242 @smallexample
2243 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2244 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2245 @end smallexample
2247 @noindent
2248 declares that @code{my_calloc} returns memory of the size given by
2249 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2250 of the size given by parameter 2.
2252 @item always_inline
2253 @cindex @code{always_inline} function attribute
2254 Generally, functions are not inlined unless optimization is specified.
2255 For functions declared inline, this attribute inlines the function even
2256 if no optimization level is specified.
2258 @item gnu_inline
2259 @cindex @code{gnu_inline} function attribute
2260 This attribute should be used with a function that is also declared
2261 with the @code{inline} keyword.  It directs GCC to treat the function
2262 as if it were defined in gnu90 mode even when compiling in C99 or
2263 gnu99 mode.
2265 If the function is declared @code{extern}, then this definition of the
2266 function is used only for inlining.  In no case is the function
2267 compiled as a standalone function, not even if you take its address
2268 explicitly.  Such an address becomes an external reference, as if you
2269 had only declared the function, and had not defined it.  This has
2270 almost the effect of a macro.  The way to use this is to put a
2271 function definition in a header file with this attribute, and put
2272 another copy of the function, without @code{extern}, in a library
2273 file.  The definition in the header file causes most calls to the
2274 function to be inlined.  If any uses of the function remain, they
2275 refer to the single copy in the library.  Note that the two
2276 definitions of the functions need not be precisely the same, although
2277 if they do not have the same effect your program may behave oddly.
2279 In C, if the function is neither @code{extern} nor @code{static}, then
2280 the function is compiled as a standalone function, as well as being
2281 inlined where possible.
2283 This is how GCC traditionally handled functions declared
2284 @code{inline}.  Since ISO C99 specifies a different semantics for
2285 @code{inline}, this function attribute is provided as a transition
2286 measure and as a useful feature in its own right.  This attribute is
2287 available in GCC 4.1.3 and later.  It is available if either of the
2288 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2289 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2290 Function is As Fast As a Macro}.
2292 In C++, this attribute does not depend on @code{extern} in any way,
2293 but it still requires the @code{inline} keyword to enable its special
2294 behavior.
2296 @item artificial
2297 @cindex @code{artificial} function attribute
2298 This attribute is useful for small inline wrappers that if possible
2299 should appear during debugging as a unit.  Depending on the debug
2300 info format it either means marking the function as artificial
2301 or using the caller location for all instructions within the inlined
2302 body.
2304 @item bank_switch
2305 @cindex interrupt handler functions
2306 When added to an interrupt handler with the M32C port, causes the
2307 prologue and epilogue to use bank switching to preserve the registers
2308 rather than saving them on the stack.
2310 @item flatten
2311 @cindex @code{flatten} function attribute
2312 Generally, inlining into a function is limited.  For a function marked with
2313 this attribute, every call inside this function is inlined, if possible.
2314 Whether the function itself is considered for inlining depends on its size and
2315 the current inlining parameters.
2317 @item error ("@var{message}")
2318 @cindex @code{error} function attribute
2319 If this attribute is used on a function declaration and a call to such a function
2320 is not eliminated through dead code elimination or other optimizations, an error
2321 that includes @var{message} is diagnosed.  This is useful
2322 for compile-time checking, especially together with @code{__builtin_constant_p}
2323 and inline functions where checking the inline function arguments is not
2324 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2325 While it is possible to leave the function undefined and thus invoke
2326 a link failure, when using this attribute the problem is diagnosed
2327 earlier and with exact location of the call even in presence of inline
2328 functions or when not emitting debugging information.
2330 @item warning ("@var{message}")
2331 @cindex @code{warning} function attribute
2332 If this attribute is used on a function declaration and a call to such a function
2333 is not eliminated through dead code elimination or other optimizations, a warning
2334 that includes @var{message} is diagnosed.  This is useful
2335 for compile-time checking, especially together with @code{__builtin_constant_p}
2336 and inline functions.  While it is possible to define the function with
2337 a message in @code{.gnu.warning*} section, when using this attribute the problem
2338 is diagnosed earlier and with exact location of the call even in presence
2339 of inline functions or when not emitting debugging information.
2341 @item cdecl
2342 @cindex functions that do pop the argument stack on the 386
2343 @opindex mrtd
2344 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2345 assume that the calling function pops off the stack space used to
2346 pass arguments.  This is
2347 useful to override the effects of the @option{-mrtd} switch.
2349 @item const
2350 @cindex @code{const} function attribute
2351 Many functions do not examine any values except their arguments, and
2352 have no effects except the return value.  Basically this is just slightly
2353 more strict class than the @code{pure} attribute below, since function is not
2354 allowed to read global memory.
2356 @cindex pointer arguments
2357 Note that a function that has pointer arguments and examines the data
2358 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2359 function that calls a non-@code{const} function usually must not be
2360 @code{const}.  It does not make sense for a @code{const} function to
2361 return @code{void}.
2363 The attribute @code{const} is not implemented in GCC versions earlier
2364 than 2.5.  An alternative way to declare that a function has no side
2365 effects, which works in the current version and in some older versions,
2366 is as follows:
2368 @smallexample
2369 typedef int intfn ();
2371 extern const intfn square;
2372 @end smallexample
2374 @noindent
2375 This approach does not work in GNU C++ from 2.6.0 on, since the language
2376 specifies that the @samp{const} must be attached to the return value.
2378 @item constructor
2379 @itemx destructor
2380 @itemx constructor (@var{priority})
2381 @itemx destructor (@var{priority})
2382 @cindex @code{constructor} function attribute
2383 @cindex @code{destructor} function attribute
2384 The @code{constructor} attribute causes the function to be called
2385 automatically before execution enters @code{main ()}.  Similarly, the
2386 @code{destructor} attribute causes the function to be called
2387 automatically after @code{main ()} completes or @code{exit ()} is
2388 called.  Functions with these attributes are useful for
2389 initializing data that is used implicitly during the execution of
2390 the program.
2392 You may provide an optional integer priority to control the order in
2393 which constructor and destructor functions are run.  A constructor
2394 with a smaller priority number runs before a constructor with a larger
2395 priority number; the opposite relationship holds for destructors.  So,
2396 if you have a constructor that allocates a resource and a destructor
2397 that deallocates the same resource, both functions typically have the
2398 same priority.  The priorities for constructor and destructor
2399 functions are the same as those specified for namespace-scope C++
2400 objects (@pxref{C++ Attributes}).
2402 These attributes are not currently implemented for Objective-C@.
2404 @item deprecated
2405 @itemx deprecated (@var{msg})
2406 @cindex @code{deprecated} attribute.
2407 The @code{deprecated} attribute results in a warning if the function
2408 is used anywhere in the source file.  This is useful when identifying
2409 functions that are expected to be removed in a future version of a
2410 program.  The warning also includes the location of the declaration
2411 of the deprecated function, to enable users to easily find further
2412 information about why the function is deprecated, or what they should
2413 do instead.  Note that the warnings only occurs for uses:
2415 @smallexample
2416 int old_fn () __attribute__ ((deprecated));
2417 int old_fn ();
2418 int (*fn_ptr)() = old_fn;
2419 @end smallexample
2421 @noindent
2422 results in a warning on line 3 but not line 2.  The optional @var{msg}
2423 argument, which must be a string, is printed in the warning if
2424 present.
2426 The @code{deprecated} attribute can also be used for variables and
2427 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2429 @item disinterrupt
2430 @cindex @code{disinterrupt} attribute
2431 On Epiphany and MeP targets, this attribute causes the compiler to emit
2432 instructions to disable interrupts for the duration of the given
2433 function.
2435 @item dllexport
2436 @cindex @code{__declspec(dllexport)}
2437 On Microsoft Windows targets and Symbian OS targets the
2438 @code{dllexport} attribute causes the compiler to provide a global
2439 pointer to a pointer in a DLL, so that it can be referenced with the
2440 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2441 name is formed by combining @code{_imp__} and the function or variable
2442 name.
2444 You can use @code{__declspec(dllexport)} as a synonym for
2445 @code{__attribute__ ((dllexport))} for compatibility with other
2446 compilers.
2448 On systems that support the @code{visibility} attribute, this
2449 attribute also implies ``default'' visibility.  It is an error to
2450 explicitly specify any other visibility.
2452 In previous versions of GCC, the @code{dllexport} attribute was ignored
2453 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2454 had been used.  The default behavior now is to emit all dllexported
2455 inline functions; however, this can cause object file-size bloat, in
2456 which case the old behavior can be restored by using
2457 @option{-fno-keep-inline-dllexport}.
2459 The attribute is also ignored for undefined symbols.
2461 When applied to C++ classes, the attribute marks defined non-inlined
2462 member functions and static data members as exports.  Static consts
2463 initialized in-class are not marked unless they are also defined
2464 out-of-class.
2466 For Microsoft Windows targets there are alternative methods for
2467 including the symbol in the DLL's export table such as using a
2468 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2469 the @option{--export-all} linker flag.
2471 @item dllimport
2472 @cindex @code{__declspec(dllimport)}
2473 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2474 attribute causes the compiler to reference a function or variable via
2475 a global pointer to a pointer that is set up by the DLL exporting the
2476 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2477 targets, the pointer name is formed by combining @code{_imp__} and the
2478 function or variable name.
2480 You can use @code{__declspec(dllimport)} as a synonym for
2481 @code{__attribute__ ((dllimport))} for compatibility with other
2482 compilers.
2484 On systems that support the @code{visibility} attribute, this
2485 attribute also implies ``default'' visibility.  It is an error to
2486 explicitly specify any other visibility.
2488 Currently, the attribute is ignored for inlined functions.  If the
2489 attribute is applied to a symbol @emph{definition}, an error is reported.
2490 If a symbol previously declared @code{dllimport} is later defined, the
2491 attribute is ignored in subsequent references, and a warning is emitted.
2492 The attribute is also overridden by a subsequent declaration as
2493 @code{dllexport}.
2495 When applied to C++ classes, the attribute marks non-inlined
2496 member functions and static data members as imports.  However, the
2497 attribute is ignored for virtual methods to allow creation of vtables
2498 using thunks.
2500 On the SH Symbian OS target the @code{dllimport} attribute also has
2501 another affect---it can cause the vtable and run-time type information
2502 for a class to be exported.  This happens when the class has a
2503 dllimported constructor or a non-inline, non-pure virtual function
2504 and, for either of those two conditions, the class also has an inline
2505 constructor or destructor and has a key function that is defined in
2506 the current translation unit.
2508 For Microsoft Windows targets the use of the @code{dllimport}
2509 attribute on functions is not necessary, but provides a small
2510 performance benefit by eliminating a thunk in the DLL@.  The use of the
2511 @code{dllimport} attribute on imported variables was required on older
2512 versions of the GNU linker, but can now be avoided by passing the
2513 @option{--enable-auto-import} switch to the GNU linker.  As with
2514 functions, using the attribute for a variable eliminates a thunk in
2515 the DLL@.
2517 One drawback to using this attribute is that a pointer to a
2518 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2519 address. However, a pointer to a @emph{function} with the
2520 @code{dllimport} attribute can be used as a constant initializer; in
2521 this case, the address of a stub function in the import lib is
2522 referenced.  On Microsoft Windows targets, the attribute can be disabled
2523 for functions by setting the @option{-mnop-fun-dllimport} flag.
2525 @item eightbit_data
2526 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2527 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2528 variable should be placed into the eight-bit data section.
2529 The compiler generates more efficient code for certain operations
2530 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2531 256 bytes of data.
2533 You must use GAS and GLD from GNU binutils version 2.7 or later for
2534 this attribute to work correctly.
2536 @item exception
2537 @cindex exception handler functions
2538 Use this attribute on the NDS32 target to indicate that the specified function
2539 is an exception handler.  The compiler will generate corresponding sections
2540 for use in an exception handler.
2542 @item exception_handler
2543 @cindex exception handler functions on the Blackfin processor
2544 Use this attribute on the Blackfin to indicate that the specified function
2545 is an exception handler.  The compiler generates function entry and
2546 exit sequences suitable for use in an exception handler when this
2547 attribute is present.
2549 @item externally_visible
2550 @cindex @code{externally_visible} attribute.
2551 This attribute, attached to a global variable or function, nullifies
2552 the effect of the @option{-fwhole-program} command-line option, so the
2553 object remains visible outside the current compilation unit.
2555 If @option{-fwhole-program} is used together with @option{-flto} and 
2556 @command{gold} is used as the linker plugin, 
2557 @code{externally_visible} attributes are automatically added to functions 
2558 (not variable yet due to a current @command{gold} issue) 
2559 that are accessed outside of LTO objects according to resolution file
2560 produced by @command{gold}.
2561 For other linkers that cannot generate resolution file,
2562 explicit @code{externally_visible} attributes are still necessary.
2564 @item far
2565 @cindex functions that handle memory bank switching
2566 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2567 use a calling convention that takes care of switching memory banks when
2568 entering and leaving a function.  This calling convention is also the
2569 default when using the @option{-mlong-calls} option.
2571 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2572 to call and return from a function.
2574 On 68HC11 the compiler generates a sequence of instructions
2575 to invoke a board-specific routine to switch the memory bank and call the
2576 real function.  The board-specific routine simulates a @code{call}.
2577 At the end of a function, it jumps to a board-specific routine
2578 instead of using @code{rts}.  The board-specific return routine simulates
2579 the @code{rtc}.
2581 On MeP targets this causes the compiler to use a calling convention
2582 that assumes the called function is too far away for the built-in
2583 addressing modes.
2585 @item fast_interrupt
2586 @cindex interrupt handler functions
2587 Use this attribute on the M32C and RX ports to indicate that the specified
2588 function is a fast interrupt handler.  This is just like the
2589 @code{interrupt} attribute, except that @code{freit} is used to return
2590 instead of @code{reit}.
2592 @item fastcall
2593 @cindex functions that pop the argument stack on the 386
2594 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2595 pass the first argument (if of integral type) in the register ECX and
2596 the second argument (if of integral type) in the register EDX@.  Subsequent
2597 and other typed arguments are passed on the stack.  The called function
2598 pops the arguments off the stack.  If the number of arguments is variable all
2599 arguments are pushed on the stack.
2601 @item thiscall
2602 @cindex functions that pop the argument stack on the 386
2603 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2604 pass the first argument (if of integral type) in the register ECX.
2605 Subsequent and other typed arguments are passed on the stack. The called
2606 function pops the arguments off the stack.
2607 If the number of arguments is variable all arguments are pushed on the
2608 stack.
2609 The @code{thiscall} attribute is intended for C++ non-static member functions.
2610 As a GCC extension, this calling convention can be used for C functions
2611 and for static member methods.
2613 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2614 @cindex @code{format} function attribute
2615 @opindex Wformat
2616 The @code{format} attribute specifies that a function takes @code{printf},
2617 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2618 should be type-checked against a format string.  For example, the
2619 declaration:
2621 @smallexample
2622 extern int
2623 my_printf (void *my_object, const char *my_format, ...)
2624       __attribute__ ((format (printf, 2, 3)));
2625 @end smallexample
2627 @noindent
2628 causes the compiler to check the arguments in calls to @code{my_printf}
2629 for consistency with the @code{printf} style format string argument
2630 @code{my_format}.
2632 The parameter @var{archetype} determines how the format string is
2633 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2634 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2635 @code{strfmon}.  (You can also use @code{__printf__},
2636 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2637 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2638 @code{ms_strftime} are also present.
2639 @var{archetype} values such as @code{printf} refer to the formats accepted
2640 by the system's C runtime library,
2641 while values prefixed with @samp{gnu_} always refer
2642 to the formats accepted by the GNU C Library.  On Microsoft Windows
2643 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2644 @file{msvcrt.dll} library.
2645 The parameter @var{string-index}
2646 specifies which argument is the format string argument (starting
2647 from 1), while @var{first-to-check} is the number of the first
2648 argument to check against the format string.  For functions
2649 where the arguments are not available to be checked (such as
2650 @code{vprintf}), specify the third parameter as zero.  In this case the
2651 compiler only checks the format string for consistency.  For
2652 @code{strftime} formats, the third parameter is required to be zero.
2653 Since non-static C++ methods have an implicit @code{this} argument, the
2654 arguments of such methods should be counted from two, not one, when
2655 giving values for @var{string-index} and @var{first-to-check}.
2657 In the example above, the format string (@code{my_format}) is the second
2658 argument of the function @code{my_print}, and the arguments to check
2659 start with the third argument, so the correct parameters for the format
2660 attribute are 2 and 3.
2662 @opindex ffreestanding
2663 @opindex fno-builtin
2664 The @code{format} attribute allows you to identify your own functions
2665 that take format strings as arguments, so that GCC can check the
2666 calls to these functions for errors.  The compiler always (unless
2667 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2668 for the standard library functions @code{printf}, @code{fprintf},
2669 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2670 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2671 warnings are requested (using @option{-Wformat}), so there is no need to
2672 modify the header file @file{stdio.h}.  In C99 mode, the functions
2673 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2674 @code{vsscanf} are also checked.  Except in strictly conforming C
2675 standard modes, the X/Open function @code{strfmon} is also checked as
2676 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2677 @xref{C Dialect Options,,Options Controlling C Dialect}.
2679 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2680 recognized in the same context.  Declarations including these format attributes
2681 are parsed for correct syntax, however the result of checking of such format
2682 strings is not yet defined, and is not carried out by this version of the
2683 compiler.
2685 The target may also provide additional types of format checks.
2686 @xref{Target Format Checks,,Format Checks Specific to Particular
2687 Target Machines}.
2689 @item format_arg (@var{string-index})
2690 @cindex @code{format_arg} function attribute
2691 @opindex Wformat-nonliteral
2692 The @code{format_arg} attribute specifies that a function takes a format
2693 string for a @code{printf}, @code{scanf}, @code{strftime} or
2694 @code{strfmon} style function and modifies it (for example, to translate
2695 it into another language), so the result can be passed to a
2696 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2697 function (with the remaining arguments to the format function the same
2698 as they would have been for the unmodified string).  For example, the
2699 declaration:
2701 @smallexample
2702 extern char *
2703 my_dgettext (char *my_domain, const char *my_format)
2704       __attribute__ ((format_arg (2)));
2705 @end smallexample
2707 @noindent
2708 causes the compiler to check the arguments in calls to a @code{printf},
2709 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2710 format string argument is a call to the @code{my_dgettext} function, for
2711 consistency with the format string argument @code{my_format}.  If the
2712 @code{format_arg} attribute had not been specified, all the compiler
2713 could tell in such calls to format functions would be that the format
2714 string argument is not constant; this would generate a warning when
2715 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2716 without the attribute.
2718 The parameter @var{string-index} specifies which argument is the format
2719 string argument (starting from one).  Since non-static C++ methods have
2720 an implicit @code{this} argument, the arguments of such methods should
2721 be counted from two.
2723 The @code{format_arg} attribute allows you to identify your own
2724 functions that modify format strings, so that GCC can check the
2725 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2726 type function whose operands are a call to one of your own function.
2727 The compiler always treats @code{gettext}, @code{dgettext}, and
2728 @code{dcgettext} in this manner except when strict ISO C support is
2729 requested by @option{-ansi} or an appropriate @option{-std} option, or
2730 @option{-ffreestanding} or @option{-fno-builtin}
2731 is used.  @xref{C Dialect Options,,Options
2732 Controlling C Dialect}.
2734 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2735 @code{NSString} reference for compatibility with the @code{format} attribute
2736 above.
2738 The target may also allow additional types in @code{format-arg} attributes.
2739 @xref{Target Format Checks,,Format Checks Specific to Particular
2740 Target Machines}.
2742 @item function_vector
2743 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2744 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2745 function should be called through the function vector.  Calling a
2746 function through the function vector reduces code size, however;
2747 the function vector has a limited size (maximum 128 entries on the H8/300
2748 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2750 On SH2A targets, this attribute declares a function to be called using the
2751 TBR relative addressing mode.  The argument to this attribute is the entry
2752 number of the same function in a vector table containing all the TBR
2753 relative addressable functions.  For correct operation the TBR must be setup
2754 accordingly to point to the start of the vector table before any functions with
2755 this attribute are invoked.  Usually a good place to do the initialization is
2756 the startup routine.  The TBR relative vector table can have at max 256 function
2757 entries.  The jumps to these functions are generated using a SH2A specific,
2758 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2759 from GNU binutils version 2.7 or later for this attribute to work correctly.
2761 Please refer the example of M16C target, to see the use of this
2762 attribute while declaring a function,
2764 In an application, for a function being called once, this attribute
2765 saves at least 8 bytes of code; and if other successive calls are being
2766 made to the same function, it saves 2 bytes of code per each of these
2767 calls.
2769 On M16C/M32C targets, the @code{function_vector} attribute declares a
2770 special page subroutine call function. Use of this attribute reduces
2771 the code size by 2 bytes for each call generated to the
2772 subroutine. The argument to the attribute is the vector number entry
2773 from the special page vector table which contains the 16 low-order
2774 bits of the subroutine's entry address. Each vector table has special
2775 page number (18 to 255) that is used in @code{jsrs} instructions.
2776 Jump addresses of the routines are generated by adding 0x0F0000 (in
2777 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2778 2-byte addresses set in the vector table. Therefore you need to ensure
2779 that all the special page vector routines should get mapped within the
2780 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2781 (for M32C).
2783 In the following example 2 bytes are saved for each call to
2784 function @code{foo}.
2786 @smallexample
2787 void foo (void) __attribute__((function_vector(0x18)));
2788 void foo (void)
2792 void bar (void)
2794     foo();
2796 @end smallexample
2798 If functions are defined in one file and are called in another file,
2799 then be sure to write this declaration in both files.
2801 This attribute is ignored for R8C target.
2803 @item ifunc ("@var{resolver}")
2804 @cindex @code{ifunc} attribute
2805 The @code{ifunc} attribute is used to mark a function as an indirect
2806 function using the STT_GNU_IFUNC symbol type extension to the ELF
2807 standard.  This allows the resolution of the symbol value to be
2808 determined dynamically at load time, and an optimized version of the
2809 routine can be selected for the particular processor or other system
2810 characteristics determined then.  To use this attribute, first define
2811 the implementation functions available, and a resolver function that
2812 returns a pointer to the selected implementation function.  The
2813 implementation functions' declarations must match the API of the
2814 function being implemented, the resolver's declaration is be a
2815 function returning pointer to void function returning void:
2817 @smallexample
2818 void *my_memcpy (void *dst, const void *src, size_t len)
2820   @dots{}
2823 static void (*resolve_memcpy (void)) (void)
2825   return my_memcpy; // we'll just always select this routine
2827 @end smallexample
2829 @noindent
2830 The exported header file declaring the function the user calls would
2831 contain:
2833 @smallexample
2834 extern void *memcpy (void *, const void *, size_t);
2835 @end smallexample
2837 @noindent
2838 allowing the user to call this as a regular function, unaware of the
2839 implementation.  Finally, the indirect function needs to be defined in
2840 the same translation unit as the resolver function:
2842 @smallexample
2843 void *memcpy (void *, const void *, size_t)
2844      __attribute__ ((ifunc ("resolve_memcpy")));
2845 @end smallexample
2847 Indirect functions cannot be weak, and require a recent binutils (at
2848 least version 2.20.1), and GNU C library (at least version 2.11.1).
2850 @item interrupt
2851 @cindex interrupt handler functions
2852 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2853 m68k, MeP, MIPS, MSP430, RL78, RX and Xstormy16 ports to indicate that
2854 the specified function is an
2855 interrupt handler.  The compiler generates function entry and exit
2856 sequences suitable for use in an interrupt handler when this attribute
2857 is present.  With Epiphany targets it may also generate a special section with
2858 code to initialize the interrupt vector table.
2860 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2861 and SH processors can be specified via the @code{interrupt_handler} attribute.
2863 Note, on the ARC, you must specify the kind of interrupt to be handled
2864 in a parameter to the interrupt attribute like this:
2866 @smallexample
2867 void f () __attribute__ ((interrupt ("ilink1")));
2868 @end smallexample
2870 Permissible values for this parameter are: @w{@code{ilink1}} and
2871 @w{@code{ilink2}}.
2873 Note, on the AVR, the hardware globally disables interrupts when an
2874 interrupt is executed.  The first instruction of an interrupt handler
2875 declared with this attribute is a @code{SEI} instruction to
2876 re-enable interrupts.  See also the @code{signal} function attribute
2877 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2878 @code{interrupt} are specified for the same function, @code{signal}
2879 is silently ignored.
2881 Note, for the ARM, you can specify the kind of interrupt to be handled by
2882 adding an optional parameter to the interrupt attribute like this:
2884 @smallexample
2885 void f () __attribute__ ((interrupt ("IRQ")));
2886 @end smallexample
2888 @noindent
2889 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2890 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2892 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2893 may be called with a word-aligned stack pointer.
2895 Note, for the MSP430 you can provide an argument to the interrupt
2896 attribute which specifies a name or number.  If the argument is a
2897 number it indicates the slot in the interrupt vector table (0 - 31) to
2898 which this handler should be assigned.  If the argument is a name it
2899 is treated as a symbolic name for the vector slot.  These names should
2900 match up with appropriate entries in the linker script.  By default
2901 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2902 @code{reset} for vector 31 are recognised.
2904 You can also use the following function attributes to modify how
2905 normal functions interact with interrupt functions:
2907 @table @code
2908 @item critical
2909 @cindex @code{critical} attribute
2910 Critical functions disable interrupts upon entry and restore the
2911 previous interrupt state upon exit.  Critical functions cannot also
2912 have the @code{naked} or @code{reentrant} attributes.  They can have
2913 the @code{interrupt} attribute.
2915 @item reentrant
2916 @cindex @code{reentrant} attribute
2917 Reentrant functions disable interrupts upon entry and enable them
2918 upon exit.  Reentrant functions cannot also have the @code{naked}
2919 or @code{critical} attributes.  They can have the @code{interrupt}
2920 attribute.
2922 @item wakeup
2923 @cindex @code{wakeup} attribute
2924 This attribute only applies to interrupt functions.  It is silently
2925 ignored if applied to a non-interrupt function.  A wakeup interrupt
2926 function will rouse the processor from any low-power state that it
2927 might be in when the function exits.
2929 @end table
2931 On Epiphany targets one or more optional parameters can be added like this:
2933 @smallexample
2934 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2935 @end smallexample
2937 Permissible values for these parameters are: @w{@code{reset}},
2938 @w{@code{software_exception}}, @w{@code{page_miss}},
2939 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2940 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2941 Multiple parameters indicate that multiple entries in the interrupt
2942 vector table should be initialized for this function, i.e.@: for each
2943 parameter @w{@var{name}}, a jump to the function is emitted in
2944 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
2945 entirely, in which case no interrupt vector table entry is provided.
2947 Note, on Epiphany targets, interrupts are enabled inside the function
2948 unless the @code{disinterrupt} attribute is also specified.
2950 On Epiphany targets, you can also use the following attribute to
2951 modify the behavior of an interrupt handler:
2952 @table @code
2953 @item forwarder_section
2954 @cindex @code{forwarder_section} attribute
2955 The interrupt handler may be in external memory which cannot be
2956 reached by a branch instruction, so generate a local memory trampoline
2957 to transfer control.  The single parameter identifies the section where
2958 the trampoline is placed.
2959 @end table
2961 The following examples are all valid uses of these attributes on
2962 Epiphany targets:
2963 @smallexample
2964 void __attribute__ ((interrupt)) universal_handler ();
2965 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2966 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2967 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2968   fast_timer_handler ();
2969 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2970   external_dma_handler ();
2971 @end smallexample
2973 On MIPS targets, you can use the following attributes to modify the behavior
2974 of an interrupt handler:
2975 @table @code
2976 @item use_shadow_register_set
2977 @cindex @code{use_shadow_register_set} attribute
2978 Assume that the handler uses a shadow register set, instead of
2979 the main general-purpose registers.
2981 @item keep_interrupts_masked
2982 @cindex @code{keep_interrupts_masked} attribute
2983 Keep interrupts masked for the whole function.  Without this attribute,
2984 GCC tries to reenable interrupts for as much of the function as it can.
2986 @item use_debug_exception_return
2987 @cindex @code{use_debug_exception_return} attribute
2988 Return using the @code{deret} instruction.  Interrupt handlers that don't
2989 have this attribute return using @code{eret} instead.
2990 @end table
2992 You can use any combination of these attributes, as shown below:
2993 @smallexample
2994 void __attribute__ ((interrupt)) v0 ();
2995 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2996 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2997 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2998 void __attribute__ ((interrupt, use_shadow_register_set,
2999                      keep_interrupts_masked)) v4 ();
3000 void __attribute__ ((interrupt, use_shadow_register_set,
3001                      use_debug_exception_return)) v5 ();
3002 void __attribute__ ((interrupt, keep_interrupts_masked,
3003                      use_debug_exception_return)) v6 ();
3004 void __attribute__ ((interrupt, use_shadow_register_set,
3005                      keep_interrupts_masked,
3006                      use_debug_exception_return)) v7 ();
3007 @end smallexample
3009 On NDS32 target, this attribute is to indicate that the specified function
3010 is an interrupt handler.  The compiler will generate corresponding sections
3011 for use in an interrupt handler.  You can use the following attributes
3012 to modify the behavior:
3013 @table @code
3014 @item nested
3015 @cindex @code{nested} attribute
3016 This interrupt service routine is interruptible.
3017 @item not_nested
3018 @cindex @code{not_nested} attribute
3019 This interrupt service routine is not interruptible.
3020 @item nested_ready
3021 @cindex @code{nested_ready} attribute
3022 This interrupt service routine is interruptible after @code{PSW.GIE}
3023 (global interrupt enable) is set.  This allows interrupt service routine to
3024 finish some short critical code before enabling interrupts.
3025 @item save_all
3026 @cindex @code{save_all} attribute
3027 The system will help save all registers into stack before entering
3028 interrupt handler.
3029 @item partial_save
3030 @cindex @code{partial_save} attribute
3031 The system will help save caller registers into stack before entering
3032 interrupt handler.
3033 @end table
3035 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3036 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3037 that must end with @code{RETB} instead of @code{RETI}).
3039 @item interrupt_handler
3040 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3041 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3042 indicate that the specified function is an interrupt handler.  The compiler
3043 generates function entry and exit sequences suitable for use in an
3044 interrupt handler when this attribute is present.
3046 @item interrupt_thread
3047 @cindex interrupt thread functions on fido
3048 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3049 that the specified function is an interrupt handler that is designed
3050 to run as a thread.  The compiler omits generate prologue/epilogue
3051 sequences and replaces the return instruction with a @code{sleep}
3052 instruction.  This attribute is available only on fido.
3054 @item isr
3055 @cindex interrupt service routines on ARM
3056 Use this attribute on ARM to write Interrupt Service Routines. This is an
3057 alias to the @code{interrupt} attribute above.
3059 @item kspisusp
3060 @cindex User stack pointer in interrupts on the Blackfin
3061 When used together with @code{interrupt_handler}, @code{exception_handler}
3062 or @code{nmi_handler}, code is generated to load the stack pointer
3063 from the USP register in the function prologue.
3065 @item l1_text
3066 @cindex @code{l1_text} function attribute
3067 This attribute specifies a function to be placed into L1 Instruction
3068 SRAM@. The function is put into a specific section named @code{.l1.text}.
3069 With @option{-mfdpic}, function calls with a such function as the callee
3070 or caller uses inlined PLT.
3072 @item l2
3073 @cindex @code{l2} function attribute
3074 On the Blackfin, this attribute specifies a function to be placed into L2
3075 SRAM. The function is put into a specific section named
3076 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3077 an inlined PLT.
3079 @item leaf
3080 @cindex @code{leaf} function attribute
3081 Calls to external functions with this attribute must return to the current
3082 compilation unit only by return or by exception handling.  In particular, leaf
3083 functions are not allowed to call callback function passed to it from the current
3084 compilation unit or directly call functions exported by the unit or longjmp
3085 into the unit.  Leaf function might still call functions from other compilation
3086 units and thus they are not necessarily leaf in the sense that they contain no
3087 function calls at all.
3089 The attribute is intended for library functions to improve dataflow analysis.
3090 The compiler takes the hint that any data not escaping the current compilation unit can
3091 not be used or modified by the leaf function.  For example, the @code{sin} function
3092 is a leaf function, but @code{qsort} is not.
3094 Note that leaf functions might invoke signals and signal handlers might be
3095 defined in the current compilation unit and use static variables.  The only
3096 compliant way to write such a signal handler is to declare such variables
3097 @code{volatile}.
3099 The attribute has no effect on functions defined within the current compilation
3100 unit.  This is to allow easy merging of multiple compilation units into one,
3101 for example, by using the link-time optimization.  For this reason the
3102 attribute is not allowed on types to annotate indirect calls.
3104 @item long_call/medium_call/short_call
3105 @cindex indirect calls on ARC
3106 @cindex indirect calls on ARM
3107 @cindex indirect calls on Epiphany
3108 These attributes specify how a particular function is called on
3109 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3110 These attributes override the
3111 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3112 and @option{-mmedium-calls} (@pxref{ARC Options})
3113 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3114 @code{long_call} attribute indicates that the function might be far
3115 away from the call site and require a different (more expensive)
3116 calling sequence.   The @code{short_call} attribute always places
3117 the offset to the function from the call site into the @samp{BL}
3118 instruction directly.
3120 For ARC, a function marked with the @code{long_call} attribute is
3121 always called using register-indirect jump-and-link instructions,
3122 thereby enabling the called function to be placed anywhere within the
3123 32-bit address space.  A function marked with the @code{medium_call}
3124 attribute will always be close enough to be called with an unconditional
3125 branch-and-link instruction, which has a 25-bit offset from
3126 the call site.  A function marked with the @code{short_call}
3127 attribute will always be close enough to be called with a conditional
3128 branch-and-link instruction, which has a 21-bit offset from
3129 the call site.
3131 @item longcall/shortcall
3132 @cindex functions called via pointer on the RS/6000 and PowerPC
3133 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3134 indicates that the function might be far away from the call site and
3135 require a different (more expensive) calling sequence.  The
3136 @code{shortcall} attribute indicates that the function is always close
3137 enough for the shorter calling sequence to be used.  These attributes
3138 override both the @option{-mlongcall} switch and, on the RS/6000 and
3139 PowerPC, the @code{#pragma longcall} setting.
3141 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3142 calls are necessary.
3144 @item long_call/near/far
3145 @cindex indirect calls on MIPS
3146 These attributes specify how a particular function is called on MIPS@.
3147 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3148 command-line switch.  The @code{long_call} and @code{far} attributes are
3149 synonyms, and cause the compiler to always call
3150 the function by first loading its address into a register, and then using
3151 the contents of that register.  The @code{near} attribute has the opposite
3152 effect; it specifies that non-PIC calls should be made using the more
3153 efficient @code{jal} instruction.
3155 @item malloc
3156 @cindex @code{malloc} attribute
3157 The @code{malloc} attribute is used to tell the compiler that a function
3158 may be treated as if any non-@code{NULL} pointer it returns cannot
3159 alias any other pointer valid when the function returns and that the memory
3160 has undefined content.
3161 This often improves optimization.
3162 Standard functions with this property include @code{malloc} and
3163 @code{calloc}.  @code{realloc}-like functions do not have this
3164 property as the memory pointed to does not have undefined content.
3166 @item mips16/nomips16
3167 @cindex @code{mips16} attribute
3168 @cindex @code{nomips16} attribute
3170 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3171 function attributes to locally select or turn off MIPS16 code generation.
3172 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3173 while MIPS16 code generation is disabled for functions with the
3174 @code{nomips16} attribute.  These attributes override the
3175 @option{-mips16} and @option{-mno-mips16} options on the command line
3176 (@pxref{MIPS Options}).
3178 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3179 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3180 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3181 may interact badly with some GCC extensions such as @code{__builtin_apply}
3182 (@pxref{Constructing Calls}).
3184 @item micromips/nomicromips
3185 @cindex @code{micromips} attribute
3186 @cindex @code{nomicromips} attribute
3188 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3189 function attributes to locally select or turn off microMIPS code generation.
3190 A function with the @code{micromips} attribute is emitted as microMIPS code,
3191 while microMIPS code generation is disabled for functions with the
3192 @code{nomicromips} attribute.  These attributes override the
3193 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3194 (@pxref{MIPS Options}).
3196 When compiling files containing mixed microMIPS and non-microMIPS code, the
3197 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3198 command line,
3199 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3200 may interact badly with some GCC extensions such as @code{__builtin_apply}
3201 (@pxref{Constructing Calls}).
3203 @item model (@var{model-name})
3204 @cindex function addressability on the M32R/D
3205 @cindex variable addressability on the IA-64
3207 On the M32R/D, use this attribute to set the addressability of an
3208 object, and of the code generated for a function.  The identifier
3209 @var{model-name} is one of @code{small}, @code{medium}, or
3210 @code{large}, representing each of the code models.
3212 Small model objects live in the lower 16MB of memory (so that their
3213 addresses can be loaded with the @code{ld24} instruction), and are
3214 callable with the @code{bl} instruction.
3216 Medium model objects may live anywhere in the 32-bit address space (the
3217 compiler generates @code{seth/add3} instructions to load their addresses),
3218 and are callable with the @code{bl} instruction.
3220 Large model objects may live anywhere in the 32-bit address space (the
3221 compiler generates @code{seth/add3} instructions to load their addresses),
3222 and may not be reachable with the @code{bl} instruction (the compiler
3223 generates the much slower @code{seth/add3/jl} instruction sequence).
3225 On IA-64, use this attribute to set the addressability of an object.
3226 At present, the only supported identifier for @var{model-name} is
3227 @code{small}, indicating addressability via ``small'' (22-bit)
3228 addresses (so that their addresses can be loaded with the @code{addl}
3229 instruction).  Caveat: such addressing is by definition not position
3230 independent and hence this attribute must not be used for objects
3231 defined by shared libraries.
3233 @item ms_abi/sysv_abi
3234 @cindex @code{ms_abi} attribute
3235 @cindex @code{sysv_abi} attribute
3237 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3238 to indicate which calling convention should be used for a function.  The
3239 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3240 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3241 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3242 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3244 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3245 requires the @option{-maccumulate-outgoing-args} option.
3247 @item callee_pop_aggregate_return (@var{number})
3248 @cindex @code{callee_pop_aggregate_return} attribute
3250 On 32-bit i?86-*-* targets, you can use this attribute to control how
3251 aggregates are returned in memory.  If the caller is responsible for
3252 popping the hidden pointer together with the rest of the arguments, specify
3253 @var{number} equal to zero.  If callee is responsible for popping the
3254 hidden pointer, specify @var{number} equal to one.  
3256 The default i386 ABI assumes that the callee pops the
3257 stack for hidden pointer.  However, on 32-bit i386 Microsoft Windows targets,
3258 the compiler assumes that the
3259 caller pops the stack for hidden pointer.
3261 @item ms_hook_prologue
3262 @cindex @code{ms_hook_prologue} attribute
3264 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3265 this function attribute to make GCC generate the ``hot-patching'' function
3266 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3267 and newer.
3269 @item hotpatch [(@var{prologue-halfwords})]
3270 @cindex @code{hotpatch} attribute
3272 On S/390 System z targets, you can use this function attribute to
3273 make GCC generate a ``hot-patching'' function prologue.  The
3274 @code{hotpatch} has no effect on funtions that are explicitly
3275 inline.  If the @option{-mhotpatch} or @option{-mno-hotpatch}
3276 command-line option is used at the same time, the @code{hotpatch}
3277 attribute takes precedence.  If an argument is given, the maximum
3278 allowed value is 1000000.
3280 @item naked
3281 @cindex function without a prologue/epilogue code
3282 Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
3283 ports to indicate that the specified function does not need prologue/epilogue
3284 sequences generated by the compiler.
3285 It is up to the programmer to provide these sequences. The
3286 only statements that can be safely included in naked functions are
3287 @code{asm} statements that do not have operands.  All other statements,
3288 including declarations of local variables, @code{if} statements, and so
3289 forth, should be avoided.  Naked functions should be used to implement the
3290 body of an assembly function, while allowing the compiler to construct
3291 the requisite function declaration for the assembler.
3293 @item near
3294 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3295 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3296 use the normal calling convention based on @code{jsr} and @code{rts}.
3297 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3298 option.
3300 On MeP targets this attribute causes the compiler to assume the called
3301 function is close enough to use the normal calling convention,
3302 overriding the @option{-mtf} command-line option.
3304 @item nesting
3305 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3306 Use this attribute together with @code{interrupt_handler},
3307 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3308 entry code should enable nested interrupts or exceptions.
3310 @item nmi_handler
3311 @cindex NMI handler functions on the Blackfin processor
3312 Use this attribute on the Blackfin to indicate that the specified function
3313 is an NMI handler.  The compiler generates function entry and
3314 exit sequences suitable for use in an NMI handler when this
3315 attribute is present.
3317 @item nocompression
3318 @cindex @code{nocompression} attribute
3319 On MIPS targets, you can use the @code{nocompression} function attribute
3320 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3321 overrides the @option{-mips16} and @option{-mmicromips} options on the
3322 command line (@pxref{MIPS Options}).
3324 @item no_instrument_function
3325 @cindex @code{no_instrument_function} function attribute
3326 @opindex finstrument-functions
3327 If @option{-finstrument-functions} is given, profiling function calls are
3328 generated at entry and exit of most user-compiled functions.
3329 Functions with this attribute are not so instrumented.
3331 @item no_split_stack
3332 @cindex @code{no_split_stack} function attribute
3333 @opindex fsplit-stack
3334 If @option{-fsplit-stack} is given, functions have a small
3335 prologue which decides whether to split the stack.  Functions with the
3336 @code{no_split_stack} attribute do not have that prologue, and thus
3337 may run with only a small amount of stack space available.
3339 @item noinline
3340 @cindex @code{noinline} function attribute
3341 This function attribute prevents a function from being considered for
3342 inlining.
3343 @c Don't enumerate the optimizations by name here; we try to be
3344 @c future-compatible with this mechanism.
3345 If the function does not have side-effects, there are optimizations
3346 other than inlining that cause function calls to be optimized away,
3347 although the function call is live.  To keep such calls from being
3348 optimized away, put
3349 @smallexample
3350 asm ("");
3351 @end smallexample
3353 @noindent
3354 (@pxref{Extended Asm}) in the called function, to serve as a special
3355 side-effect.
3357 @item noclone
3358 @cindex @code{noclone} function attribute
3359 This function attribute prevents a function from being considered for
3360 cloning---a mechanism that produces specialized copies of functions
3361 and which is (currently) performed by interprocedural constant
3362 propagation.
3364 @item nonnull (@var{arg-index}, @dots{})
3365 @cindex @code{nonnull} function attribute
3366 The @code{nonnull} attribute specifies that some function parameters should
3367 be non-null pointers.  For instance, the declaration:
3369 @smallexample
3370 extern void *
3371 my_memcpy (void *dest, const void *src, size_t len)
3372         __attribute__((nonnull (1, 2)));
3373 @end smallexample
3375 @noindent
3376 causes the compiler to check that, in calls to @code{my_memcpy},
3377 arguments @var{dest} and @var{src} are non-null.  If the compiler
3378 determines that a null pointer is passed in an argument slot marked
3379 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3380 is issued.  The compiler may also choose to make optimizations based
3381 on the knowledge that certain function arguments will never be null.
3383 If no argument index list is given to the @code{nonnull} attribute,
3384 all pointer arguments are marked as non-null.  To illustrate, the
3385 following declaration is equivalent to the previous example:
3387 @smallexample
3388 extern void *
3389 my_memcpy (void *dest, const void *src, size_t len)
3390         __attribute__((nonnull));
3391 @end smallexample
3393 @item returns_nonnull
3394 @cindex @code{returns_nonnull} function attribute
3395 The @code{returns_nonnull} attribute specifies that the function
3396 return value should be a non-null pointer.  For instance, the declaration:
3398 @smallexample
3399 extern void *
3400 mymalloc (size_t len) __attribute__((returns_nonnull));
3401 @end smallexample
3403 @noindent
3404 lets the compiler optimize callers based on the knowledge
3405 that the return value will never be null.
3407 @item noreturn
3408 @cindex @code{noreturn} function attribute
3409 A few standard library functions, such as @code{abort} and @code{exit},
3410 cannot return.  GCC knows this automatically.  Some programs define
3411 their own functions that never return.  You can declare them
3412 @code{noreturn} to tell the compiler this fact.  For example,
3414 @smallexample
3415 @group
3416 void fatal () __attribute__ ((noreturn));
3418 void
3419 fatal (/* @r{@dots{}} */)
3421   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3422   exit (1);
3424 @end group
3425 @end smallexample
3427 The @code{noreturn} keyword tells the compiler to assume that
3428 @code{fatal} cannot return.  It can then optimize without regard to what
3429 would happen if @code{fatal} ever did return.  This makes slightly
3430 better code.  More importantly, it helps avoid spurious warnings of
3431 uninitialized variables.
3433 The @code{noreturn} keyword does not affect the exceptional path when that
3434 applies: a @code{noreturn}-marked function may still return to the caller
3435 by throwing an exception or calling @code{longjmp}.
3437 Do not assume that registers saved by the calling function are
3438 restored before calling the @code{noreturn} function.
3440 It does not make sense for a @code{noreturn} function to have a return
3441 type other than @code{void}.
3443 The attribute @code{noreturn} is not implemented in GCC versions
3444 earlier than 2.5.  An alternative way to declare that a function does
3445 not return, which works in the current version and in some older
3446 versions, is as follows:
3448 @smallexample
3449 typedef void voidfn ();
3451 volatile voidfn fatal;
3452 @end smallexample
3454 @noindent
3455 This approach does not work in GNU C++.
3457 @item nothrow
3458 @cindex @code{nothrow} function attribute
3459 The @code{nothrow} attribute is used to inform the compiler that a
3460 function cannot throw an exception.  For example, most functions in
3461 the standard C library can be guaranteed not to throw an exception
3462 with the notable exceptions of @code{qsort} and @code{bsearch} that
3463 take function pointer arguments.  The @code{nothrow} attribute is not
3464 implemented in GCC versions earlier than 3.3.
3466 @item nosave_low_regs
3467 @cindex @code{nosave_low_regs} attribute
3468 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3469 function should not save and restore registers R0..R7.  This can be used on SH3*
3470 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3471 interrupt handlers.
3473 @item optimize
3474 @cindex @code{optimize} function attribute
3475 The @code{optimize} attribute is used to specify that a function is to
3476 be compiled with different optimization options than specified on the
3477 command line.  Arguments can either be numbers or strings.  Numbers
3478 are assumed to be an optimization level.  Strings that begin with
3479 @code{O} are assumed to be an optimization option, while other options
3480 are assumed to be used with a @code{-f} prefix.  You can also use the
3481 @samp{#pragma GCC optimize} pragma to set the optimization options
3482 that affect more than one function.
3483 @xref{Function Specific Option Pragmas}, for details about the
3484 @samp{#pragma GCC optimize} pragma.
3486 This can be used for instance to have frequently-executed functions
3487 compiled with more aggressive optimization options that produce faster
3488 and larger code, while other functions can be compiled with less
3489 aggressive options.
3491 @item OS_main/OS_task
3492 @cindex @code{OS_main} AVR function attribute
3493 @cindex @code{OS_task} AVR function attribute
3494 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3495 do not save/restore any call-saved register in their prologue/epilogue.
3497 The @code{OS_main} attribute can be used when there @emph{is
3498 guarantee} that interrupts are disabled at the time when the function
3499 is entered.  This saves resources when the stack pointer has to be
3500 changed to set up a frame for local variables.
3502 The @code{OS_task} attribute can be used when there is @emph{no
3503 guarantee} that interrupts are disabled at that time when the function
3504 is entered like for, e@.g@. task functions in a multi-threading operating
3505 system. In that case, changing the stack pointer register is
3506 guarded by save/clear/restore of the global interrupt enable flag.
3508 The differences to the @code{naked} function attribute are:
3509 @itemize @bullet
3510 @item @code{naked} functions do not have a return instruction whereas 
3511 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3512 @code{RETI} return instruction.
3513 @item @code{naked} functions do not set up a frame for local variables
3514 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3515 as needed.
3516 @end itemize
3518 @item pcs
3519 @cindex @code{pcs} function attribute
3521 The @code{pcs} attribute can be used to control the calling convention
3522 used for a function on ARM.  The attribute takes an argument that specifies
3523 the calling convention to use.
3525 When compiling using the AAPCS ABI (or a variant of it) then valid
3526 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3527 order to use a variant other than @code{"aapcs"} then the compiler must
3528 be permitted to use the appropriate co-processor registers (i.e., the
3529 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3530 For example,
3532 @smallexample
3533 /* Argument passed in r0, and result returned in r0+r1.  */
3534 double f2d (float) __attribute__((pcs("aapcs")));
3535 @end smallexample
3537 Variadic functions always use the @code{"aapcs"} calling convention and
3538 the compiler rejects attempts to specify an alternative.
3540 @item pure
3541 @cindex @code{pure} function attribute
3542 Many functions have no effects except the return value and their
3543 return value depends only on the parameters and/or global variables.
3544 Such a function can be subject
3545 to common subexpression elimination and loop optimization just as an
3546 arithmetic operator would be.  These functions should be declared
3547 with the attribute @code{pure}.  For example,
3549 @smallexample
3550 int square (int) __attribute__ ((pure));
3551 @end smallexample
3553 @noindent
3554 says that the hypothetical function @code{square} is safe to call
3555 fewer times than the program says.
3557 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3558 Interesting non-pure functions are functions with infinite loops or those
3559 depending on volatile memory or other system resource, that may change between
3560 two consecutive calls (such as @code{feof} in a multithreading environment).
3562 The attribute @code{pure} is not implemented in GCC versions earlier
3563 than 2.96.
3565 @item hot
3566 @cindex @code{hot} function attribute
3567 The @code{hot} attribute on a function is used to inform the compiler that
3568 the function is a hot spot of the compiled program.  The function is
3569 optimized more aggressively and on many target it is placed into special
3570 subsection of the text section so all hot functions appears close together
3571 improving locality.
3573 When profile feedback is available, via @option{-fprofile-use}, hot functions
3574 are automatically detected and this attribute is ignored.
3576 The @code{hot} attribute on functions is not implemented in GCC versions
3577 earlier than 4.3.
3579 @cindex @code{hot} label attribute
3580 The @code{hot} attribute on a label is used to inform the compiler that
3581 path following the label are more likely than paths that are not so
3582 annotated.  This attribute is used in cases where @code{__builtin_expect}
3583 cannot be used, for instance with computed goto or @code{asm goto}.
3585 The @code{hot} attribute on labels is not implemented in GCC versions
3586 earlier than 4.8.
3588 @item cold
3589 @cindex @code{cold} function attribute
3590 The @code{cold} attribute on functions is used to inform the compiler that
3591 the function is unlikely to be executed.  The function is optimized for
3592 size rather than speed and on many targets it is placed into special
3593 subsection of the text section so all cold functions appears close together
3594 improving code locality of non-cold parts of program.  The paths leading
3595 to call of cold functions within code are marked as unlikely by the branch
3596 prediction mechanism.  It is thus useful to mark functions used to handle
3597 unlikely conditions, such as @code{perror}, as cold to improve optimization
3598 of hot functions that do call marked functions in rare occasions.
3600 When profile feedback is available, via @option{-fprofile-use}, cold functions
3601 are automatically detected and this attribute is ignored.
3603 The @code{cold} attribute on functions is not implemented in GCC versions
3604 earlier than 4.3.
3606 @cindex @code{cold} label attribute
3607 The @code{cold} attribute on labels is used to inform the compiler that
3608 the path following the label is unlikely to be executed.  This attribute
3609 is used in cases where @code{__builtin_expect} cannot be used, for instance
3610 with computed goto or @code{asm goto}.
3612 The @code{cold} attribute on labels is not implemented in GCC versions
3613 earlier than 4.8.
3615 @item no_sanitize_address
3616 @itemx no_address_safety_analysis
3617 @cindex @code{no_sanitize_address} function attribute
3618 The @code{no_sanitize_address} attribute on functions is used
3619 to inform the compiler that it should not instrument memory accesses
3620 in the function when compiling with the @option{-fsanitize=address} option.
3621 The @code{no_address_safety_analysis} is a deprecated alias of the
3622 @code{no_sanitize_address} attribute, new code should use
3623 @code{no_sanitize_address}.
3625 @item no_sanitize_undefined
3626 @cindex @code{no_sanitize_undefined} function attribute
3627 The @code{no_sanitize_undefined} attribute on functions is used
3628 to inform the compiler that it should not check for undefined behavior
3629 in the function when compiling with the @option{-fsanitize=undefined} option.
3631 @item regparm (@var{number})
3632 @cindex @code{regparm} attribute
3633 @cindex functions that are passed arguments in registers on the 386
3634 On the Intel 386, the @code{regparm} attribute causes the compiler to
3635 pass arguments number one to @var{number} if they are of integral type
3636 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3637 take a variable number of arguments continue to be passed all of their
3638 arguments on the stack.
3640 Beware that on some ELF systems this attribute is unsuitable for
3641 global functions in shared libraries with lazy binding (which is the
3642 default).  Lazy binding sends the first call via resolving code in
3643 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3644 per the standard calling conventions.  Solaris 8 is affected by this.
3645 Systems with the GNU C Library version 2.1 or higher
3646 and FreeBSD are believed to be
3647 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3648 disabled with the linker or the loader if desired, to avoid the
3649 problem.)
3651 @item reset
3652 @cindex reset handler functions
3653 Use this attribute on the NDS32 target to indicate that the specified function
3654 is a reset handler.  The compiler will generate corresponding sections
3655 for use in a reset handler.  You can use the following attributes
3656 to provide extra exception handling:
3657 @table @code
3658 @item nmi
3659 @cindex @code{nmi} attribute
3660 Provide a user-defined function to handle NMI exception.
3661 @item warm
3662 @cindex @code{warm} attribute
3663 Provide a user-defined function to handle warm reset exception.
3664 @end table
3666 @item sseregparm
3667 @cindex @code{sseregparm} attribute
3668 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3669 causes the compiler to pass up to 3 floating-point arguments in
3670 SSE registers instead of on the stack.  Functions that take a
3671 variable number of arguments continue to pass all of their
3672 floating-point arguments on the stack.
3674 @item force_align_arg_pointer
3675 @cindex @code{force_align_arg_pointer} attribute
3676 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3677 applied to individual function definitions, generating an alternate
3678 prologue and epilogue that realigns the run-time stack if necessary.
3679 This supports mixing legacy codes that run with a 4-byte aligned stack
3680 with modern codes that keep a 16-byte stack for SSE compatibility.
3682 @item renesas
3683 @cindex @code{renesas} attribute
3684 On SH targets this attribute specifies that the function or struct follows the
3685 Renesas ABI.
3687 @item resbank
3688 @cindex @code{resbank} attribute
3689 On the SH2A target, this attribute enables the high-speed register
3690 saving and restoration using a register bank for @code{interrupt_handler}
3691 routines.  Saving to the bank is performed automatically after the CPU
3692 accepts an interrupt that uses a register bank.
3694 The nineteen 32-bit registers comprising general register R0 to R14,
3695 control register GBR, and system registers MACH, MACL, and PR and the
3696 vector table address offset are saved into a register bank.  Register
3697 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3698 from the bank is executed by issuing a RESBANK instruction.
3700 @item returns_twice
3701 @cindex @code{returns_twice} attribute
3702 The @code{returns_twice} attribute tells the compiler that a function may
3703 return more than one time.  The compiler ensures that all registers
3704 are dead before calling such a function and emits a warning about
3705 the variables that may be clobbered after the second return from the
3706 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3707 The @code{longjmp}-like counterpart of such function, if any, might need
3708 to be marked with the @code{noreturn} attribute.
3710 @item saveall
3711 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3712 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3713 all registers except the stack pointer should be saved in the prologue
3714 regardless of whether they are used or not.
3716 @item save_volatiles
3717 @cindex save volatile registers on the MicroBlaze
3718 Use this attribute on the MicroBlaze to indicate that the function is
3719 an interrupt handler.  All volatile registers (in addition to non-volatile
3720 registers) are saved in the function prologue.  If the function is a leaf
3721 function, only volatiles used by the function are saved.  A normal function
3722 return is generated instead of a return from interrupt.
3724 @item section ("@var{section-name}")
3725 @cindex @code{section} function attribute
3726 Normally, the compiler places the code it generates in the @code{text} section.
3727 Sometimes, however, you need additional sections, or you need certain
3728 particular functions to appear in special sections.  The @code{section}
3729 attribute specifies that a function lives in a particular section.
3730 For example, the declaration:
3732 @smallexample
3733 extern void foobar (void) __attribute__ ((section ("bar")));
3734 @end smallexample
3736 @noindent
3737 puts the function @code{foobar} in the @code{bar} section.
3739 Some file formats do not support arbitrary sections so the @code{section}
3740 attribute is not available on all platforms.
3741 If you need to map the entire contents of a module to a particular
3742 section, consider using the facilities of the linker instead.
3744 @item sentinel
3745 @cindex @code{sentinel} function attribute
3746 This function attribute ensures that a parameter in a function call is
3747 an explicit @code{NULL}.  The attribute is only valid on variadic
3748 functions.  By default, the sentinel is located at position zero, the
3749 last parameter of the function call.  If an optional integer position
3750 argument P is supplied to the attribute, the sentinel must be located at
3751 position P counting backwards from the end of the argument list.
3753 @smallexample
3754 __attribute__ ((sentinel))
3755 is equivalent to
3756 __attribute__ ((sentinel(0)))
3757 @end smallexample
3759 The attribute is automatically set with a position of 0 for the built-in
3760 functions @code{execl} and @code{execlp}.  The built-in function
3761 @code{execle} has the attribute set with a position of 1.
3763 A valid @code{NULL} in this context is defined as zero with any pointer
3764 type.  If your system defines the @code{NULL} macro with an integer type
3765 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3766 with a copy that redefines NULL appropriately.
3768 The warnings for missing or incorrect sentinels are enabled with
3769 @option{-Wformat}.
3771 @item short_call
3772 See @code{long_call/short_call}.
3774 @item shortcall
3775 See @code{longcall/shortcall}.
3777 @item signal
3778 @cindex interrupt handler functions on the AVR processors
3779 Use this attribute on the AVR to indicate that the specified
3780 function is an interrupt handler.  The compiler generates function
3781 entry and exit sequences suitable for use in an interrupt handler when this
3782 attribute is present.
3784 See also the @code{interrupt} function attribute. 
3786 The AVR hardware globally disables interrupts when an interrupt is executed.
3787 Interrupt handler functions defined with the @code{signal} attribute
3788 do not re-enable interrupts.  It is save to enable interrupts in a
3789 @code{signal} handler.  This ``save'' only applies to the code
3790 generated by the compiler and not to the IRQ layout of the
3791 application which is responsibility of the application.
3793 If both @code{signal} and @code{interrupt} are specified for the same
3794 function, @code{signal} is silently ignored.
3796 @item sp_switch
3797 @cindex @code{sp_switch} attribute
3798 Use this attribute on the SH to indicate an @code{interrupt_handler}
3799 function should switch to an alternate stack.  It expects a string
3800 argument that names a global variable holding the address of the
3801 alternate stack.
3803 @smallexample
3804 void *alt_stack;
3805 void f () __attribute__ ((interrupt_handler,
3806                           sp_switch ("alt_stack")));
3807 @end smallexample
3809 @item stdcall
3810 @cindex functions that pop the argument stack on the 386
3811 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3812 assume that the called function pops off the stack space used to
3813 pass arguments, unless it takes a variable number of arguments.
3815 @item syscall_linkage
3816 @cindex @code{syscall_linkage} attribute
3817 This attribute is used to modify the IA-64 calling convention by marking
3818 all input registers as live at all function exits.  This makes it possible
3819 to restart a system call after an interrupt without having to save/restore
3820 the input registers.  This also prevents kernel data from leaking into
3821 application code.
3823 @item target
3824 @cindex @code{target} function attribute
3825 The @code{target} attribute is used to specify that a function is to
3826 be compiled with different target options than specified on the
3827 command line.  This can be used for instance to have functions
3828 compiled with a different ISA (instruction set architecture) than the
3829 default.  You can also use the @samp{#pragma GCC target} pragma to set
3830 more than one function to be compiled with specific target options.
3831 @xref{Function Specific Option Pragmas}, for details about the
3832 @samp{#pragma GCC target} pragma.
3834 For instance on a 386, you could compile one function with
3835 @code{target("sse4.1,arch=core2")} and another with
3836 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3837 compiling the first function with @option{-msse4.1} and
3838 @option{-march=core2} options, and the second function with
3839 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3840 user to make sure that a function is only invoked on a machine that
3841 supports the particular ISA it is compiled for (for example by using
3842 @code{cpuid} on 386 to determine what feature bits and architecture
3843 family are used).
3845 @smallexample
3846 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3847 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3848 @end smallexample
3850 On the 386, the following options are allowed:
3852 @table @samp
3853 @item abm
3854 @itemx no-abm
3855 @cindex @code{target("abm")} attribute
3856 Enable/disable the generation of the advanced bit instructions.
3858 @item aes
3859 @itemx no-aes
3860 @cindex @code{target("aes")} attribute
3861 Enable/disable the generation of the AES instructions.
3863 @item default
3864 @cindex @code{target("default")} attribute
3865 @xref{Function Multiversioning}, where it is used to specify the
3866 default function version.
3868 @item mmx
3869 @itemx no-mmx
3870 @cindex @code{target("mmx")} attribute
3871 Enable/disable the generation of the MMX instructions.
3873 @item pclmul
3874 @itemx no-pclmul
3875 @cindex @code{target("pclmul")} attribute
3876 Enable/disable the generation of the PCLMUL instructions.
3878 @item popcnt
3879 @itemx no-popcnt
3880 @cindex @code{target("popcnt")} attribute
3881 Enable/disable the generation of the POPCNT instruction.
3883 @item sse
3884 @itemx no-sse
3885 @cindex @code{target("sse")} attribute
3886 Enable/disable the generation of the SSE instructions.
3888 @item sse2
3889 @itemx no-sse2
3890 @cindex @code{target("sse2")} attribute
3891 Enable/disable the generation of the SSE2 instructions.
3893 @item sse3
3894 @itemx no-sse3
3895 @cindex @code{target("sse3")} attribute
3896 Enable/disable the generation of the SSE3 instructions.
3898 @item sse4
3899 @itemx no-sse4
3900 @cindex @code{target("sse4")} attribute
3901 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3902 and SSE4.2).
3904 @item sse4.1
3905 @itemx no-sse4.1
3906 @cindex @code{target("sse4.1")} attribute
3907 Enable/disable the generation of the sse4.1 instructions.
3909 @item sse4.2
3910 @itemx no-sse4.2
3911 @cindex @code{target("sse4.2")} attribute
3912 Enable/disable the generation of the sse4.2 instructions.
3914 @item sse4a
3915 @itemx no-sse4a
3916 @cindex @code{target("sse4a")} attribute
3917 Enable/disable the generation of the SSE4A instructions.
3919 @item fma4
3920 @itemx no-fma4
3921 @cindex @code{target("fma4")} attribute
3922 Enable/disable the generation of the FMA4 instructions.
3924 @item xop
3925 @itemx no-xop
3926 @cindex @code{target("xop")} attribute
3927 Enable/disable the generation of the XOP instructions.
3929 @item lwp
3930 @itemx no-lwp
3931 @cindex @code{target("lwp")} attribute
3932 Enable/disable the generation of the LWP instructions.
3934 @item ssse3
3935 @itemx no-ssse3
3936 @cindex @code{target("ssse3")} attribute
3937 Enable/disable the generation of the SSSE3 instructions.
3939 @item cld
3940 @itemx no-cld
3941 @cindex @code{target("cld")} attribute
3942 Enable/disable the generation of the CLD before string moves.
3944 @item fancy-math-387
3945 @itemx no-fancy-math-387
3946 @cindex @code{target("fancy-math-387")} attribute
3947 Enable/disable the generation of the @code{sin}, @code{cos}, and
3948 @code{sqrt} instructions on the 387 floating-point unit.
3950 @item fused-madd
3951 @itemx no-fused-madd
3952 @cindex @code{target("fused-madd")} attribute
3953 Enable/disable the generation of the fused multiply/add instructions.
3955 @item ieee-fp
3956 @itemx no-ieee-fp
3957 @cindex @code{target("ieee-fp")} attribute
3958 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3960 @item inline-all-stringops
3961 @itemx no-inline-all-stringops
3962 @cindex @code{target("inline-all-stringops")} attribute
3963 Enable/disable inlining of string operations.
3965 @item inline-stringops-dynamically
3966 @itemx no-inline-stringops-dynamically
3967 @cindex @code{target("inline-stringops-dynamically")} attribute
3968 Enable/disable the generation of the inline code to do small string
3969 operations and calling the library routines for large operations.
3971 @item align-stringops
3972 @itemx no-align-stringops
3973 @cindex @code{target("align-stringops")} attribute
3974 Do/do not align destination of inlined string operations.
3976 @item recip
3977 @itemx no-recip
3978 @cindex @code{target("recip")} attribute
3979 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3980 instructions followed an additional Newton-Raphson step instead of
3981 doing a floating-point division.
3983 @item arch=@var{ARCH}
3984 @cindex @code{target("arch=@var{ARCH}")} attribute
3985 Specify the architecture to generate code for in compiling the function.
3987 @item tune=@var{TUNE}
3988 @cindex @code{target("tune=@var{TUNE}")} attribute
3989 Specify the architecture to tune for in compiling the function.
3991 @item fpmath=@var{FPMATH}
3992 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3993 Specify which floating-point unit to use.  The
3994 @code{target("fpmath=sse,387")} option must be specified as
3995 @code{target("fpmath=sse+387")} because the comma would separate
3996 different options.
3997 @end table
3999 On the PowerPC, the following options are allowed:
4001 @table @samp
4002 @item altivec
4003 @itemx no-altivec
4004 @cindex @code{target("altivec")} attribute
4005 Generate code that uses (does not use) AltiVec instructions.  In
4006 32-bit code, you cannot enable AltiVec instructions unless
4007 @option{-mabi=altivec} is used on the command line.
4009 @item cmpb
4010 @itemx no-cmpb
4011 @cindex @code{target("cmpb")} attribute
4012 Generate code that uses (does not use) the compare bytes instruction
4013 implemented on the POWER6 processor and other processors that support
4014 the PowerPC V2.05 architecture.
4016 @item dlmzb
4017 @itemx no-dlmzb
4018 @cindex @code{target("dlmzb")} attribute
4019 Generate code that uses (does not use) the string-search @samp{dlmzb}
4020 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4021 generated by default when targeting those processors.
4023 @item fprnd
4024 @itemx no-fprnd
4025 @cindex @code{target("fprnd")} attribute
4026 Generate code that uses (does not use) the FP round to integer
4027 instructions implemented on the POWER5+ processor and other processors
4028 that support the PowerPC V2.03 architecture.
4030 @item hard-dfp
4031 @itemx no-hard-dfp
4032 @cindex @code{target("hard-dfp")} attribute
4033 Generate code that uses (does not use) the decimal floating-point
4034 instructions implemented on some POWER processors.
4036 @item isel
4037 @itemx no-isel
4038 @cindex @code{target("isel")} attribute
4039 Generate code that uses (does not use) ISEL instruction.
4041 @item mfcrf
4042 @itemx no-mfcrf
4043 @cindex @code{target("mfcrf")} attribute
4044 Generate code that uses (does not use) the move from condition
4045 register field instruction implemented on the POWER4 processor and
4046 other processors that support the PowerPC V2.01 architecture.
4048 @item mfpgpr
4049 @itemx no-mfpgpr
4050 @cindex @code{target("mfpgpr")} attribute
4051 Generate code that uses (does not use) the FP move to/from general
4052 purpose register instructions implemented on the POWER6X processor and
4053 other processors that support the extended PowerPC V2.05 architecture.
4055 @item mulhw
4056 @itemx no-mulhw
4057 @cindex @code{target("mulhw")} attribute
4058 Generate code that uses (does not use) the half-word multiply and
4059 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4060 These instructions are generated by default when targeting those
4061 processors.
4063 @item multiple
4064 @itemx no-multiple
4065 @cindex @code{target("multiple")} attribute
4066 Generate code that uses (does not use) the load multiple word
4067 instructions and the store multiple word instructions.
4069 @item update
4070 @itemx no-update
4071 @cindex @code{target("update")} attribute
4072 Generate code that uses (does not use) the load or store instructions
4073 that update the base register to the address of the calculated memory
4074 location.
4076 @item popcntb
4077 @itemx no-popcntb
4078 @cindex @code{target("popcntb")} attribute
4079 Generate code that uses (does not use) the popcount and double-precision
4080 FP reciprocal estimate instruction implemented on the POWER5
4081 processor and other processors that support the PowerPC V2.02
4082 architecture.
4084 @item popcntd
4085 @itemx no-popcntd
4086 @cindex @code{target("popcntd")} attribute
4087 Generate code that uses (does not use) the popcount instruction
4088 implemented on the POWER7 processor and other processors that support
4089 the PowerPC V2.06 architecture.
4091 @item powerpc-gfxopt
4092 @itemx no-powerpc-gfxopt
4093 @cindex @code{target("powerpc-gfxopt")} attribute
4094 Generate code that uses (does not use) the optional PowerPC
4095 architecture instructions in the Graphics group, including
4096 floating-point select.
4098 @item powerpc-gpopt
4099 @itemx no-powerpc-gpopt
4100 @cindex @code{target("powerpc-gpopt")} attribute
4101 Generate code that uses (does not use) the optional PowerPC
4102 architecture instructions in the General Purpose group, including
4103 floating-point square root.
4105 @item recip-precision
4106 @itemx no-recip-precision
4107 @cindex @code{target("recip-precision")} attribute
4108 Assume (do not assume) that the reciprocal estimate instructions
4109 provide higher-precision estimates than is mandated by the powerpc
4110 ABI.
4112 @item string
4113 @itemx no-string
4114 @cindex @code{target("string")} attribute
4115 Generate code that uses (does not use) the load string instructions
4116 and the store string word instructions to save multiple registers and
4117 do small block moves.
4119 @item vsx
4120 @itemx no-vsx
4121 @cindex @code{target("vsx")} attribute
4122 Generate code that uses (does not use) vector/scalar (VSX)
4123 instructions, and also enable the use of built-in functions that allow
4124 more direct access to the VSX instruction set.  In 32-bit code, you
4125 cannot enable VSX or AltiVec instructions unless
4126 @option{-mabi=altivec} is used on the command line.
4128 @item friz
4129 @itemx no-friz
4130 @cindex @code{target("friz")} attribute
4131 Generate (do not generate) the @code{friz} instruction when the
4132 @option{-funsafe-math-optimizations} option is used to optimize
4133 rounding a floating-point value to 64-bit integer and back to floating
4134 point.  The @code{friz} instruction does not return the same value if
4135 the floating-point number is too large to fit in an integer.
4137 @item avoid-indexed-addresses
4138 @itemx no-avoid-indexed-addresses
4139 @cindex @code{target("avoid-indexed-addresses")} attribute
4140 Generate code that tries to avoid (not avoid) the use of indexed load
4141 or store instructions.
4143 @item paired
4144 @itemx no-paired
4145 @cindex @code{target("paired")} attribute
4146 Generate code that uses (does not use) the generation of PAIRED simd
4147 instructions.
4149 @item longcall
4150 @itemx no-longcall
4151 @cindex @code{target("longcall")} attribute
4152 Generate code that assumes (does not assume) that all calls are far
4153 away so that a longer more expensive calling sequence is required.
4155 @item cpu=@var{CPU}
4156 @cindex @code{target("cpu=@var{CPU}")} attribute
4157 Specify the architecture to generate code for when compiling the
4158 function.  If you select the @code{target("cpu=power7")} attribute when
4159 generating 32-bit code, VSX and AltiVec instructions are not generated
4160 unless you use the @option{-mabi=altivec} option on the command line.
4162 @item tune=@var{TUNE}
4163 @cindex @code{target("tune=@var{TUNE}")} attribute
4164 Specify the architecture to tune for when compiling the function.  If
4165 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4166 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4167 compilation tunes for the @var{CPU} architecture, and not the
4168 default tuning specified on the command line.
4169 @end table
4171 On the 386/x86_64 and PowerPC back ends, you can use either multiple
4172 strings to specify multiple options, or you can separate the option
4173 with a comma (@code{,}).
4175 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4176 function that has different target options than the caller, unless the
4177 callee has a subset of the target options of the caller.  For example
4178 a function declared with @code{target("sse3")} can inline a function
4179 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4181 The @code{target} attribute is not implemented in GCC versions earlier
4182 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends.  It is
4183 not currently implemented for other back ends.
4185 @item tiny_data
4186 @cindex tiny data section on the H8/300H and H8S
4187 Use this attribute on the H8/300H and H8S to indicate that the specified
4188 variable should be placed into the tiny data section.
4189 The compiler generates more efficient code for loads and stores
4190 on data in the tiny data section.  Note the tiny data area is limited to
4191 slightly under 32KB of data.
4193 @item trap_exit
4194 @cindex @code{trap_exit} attribute
4195 Use this attribute on the SH for an @code{interrupt_handler} to return using
4196 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4197 argument specifying the trap number to be used.
4199 @item trapa_handler
4200 @cindex @code{trapa_handler} attribute
4201 On SH targets this function attribute is similar to @code{interrupt_handler}
4202 but it does not save and restore all registers.
4204 @item unused
4205 @cindex @code{unused} attribute.
4206 This attribute, attached to a function, means that the function is meant
4207 to be possibly unused.  GCC does not produce a warning for this
4208 function.
4210 @item used
4211 @cindex @code{used} attribute.
4212 This attribute, attached to a function, means that code must be emitted
4213 for the function even if it appears that the function is not referenced.
4214 This is useful, for example, when the function is referenced only in
4215 inline assembly.
4217 When applied to a member function of a C++ class template, the
4218 attribute also means that the function is instantiated if the
4219 class itself is instantiated.
4221 @item version_id
4222 @cindex @code{version_id} attribute
4223 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4224 symbol to contain a version string, thus allowing for function level
4225 versioning.  HP-UX system header files may use function level versioning
4226 for some system calls.
4228 @smallexample
4229 extern int foo () __attribute__((version_id ("20040821")));
4230 @end smallexample
4232 @noindent
4233 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4235 @item visibility ("@var{visibility_type}")
4236 @cindex @code{visibility} attribute
4237 This attribute affects the linkage of the declaration to which it is attached.
4238 There are four supported @var{visibility_type} values: default,
4239 hidden, protected or internal visibility.
4241 @smallexample
4242 void __attribute__ ((visibility ("protected")))
4243 f () @{ /* @r{Do something.} */; @}
4244 int i __attribute__ ((visibility ("hidden")));
4245 @end smallexample
4247 The possible values of @var{visibility_type} correspond to the
4248 visibility settings in the ELF gABI.
4250 @table @dfn
4251 @c keep this list of visibilities in alphabetical order.
4253 @item default
4254 Default visibility is the normal case for the object file format.
4255 This value is available for the visibility attribute to override other
4256 options that may change the assumed visibility of entities.
4258 On ELF, default visibility means that the declaration is visible to other
4259 modules and, in shared libraries, means that the declared entity may be
4260 overridden.
4262 On Darwin, default visibility means that the declaration is visible to
4263 other modules.
4265 Default visibility corresponds to ``external linkage'' in the language.
4267 @item hidden
4268 Hidden visibility indicates that the entity declared has a new
4269 form of linkage, which we call ``hidden linkage''.  Two
4270 declarations of an object with hidden linkage refer to the same object
4271 if they are in the same shared object.
4273 @item internal
4274 Internal visibility is like hidden visibility, but with additional
4275 processor specific semantics.  Unless otherwise specified by the
4276 psABI, GCC defines internal visibility to mean that a function is
4277 @emph{never} called from another module.  Compare this with hidden
4278 functions which, while they cannot be referenced directly by other
4279 modules, can be referenced indirectly via function pointers.  By
4280 indicating that a function cannot be called from outside the module,
4281 GCC may for instance omit the load of a PIC register since it is known
4282 that the calling function loaded the correct value.
4284 @item protected
4285 Protected visibility is like default visibility except that it
4286 indicates that references within the defining module bind to the
4287 definition in that module.  That is, the declared entity cannot be
4288 overridden by another module.
4290 @end table
4292 All visibilities are supported on many, but not all, ELF targets
4293 (supported when the assembler supports the @samp{.visibility}
4294 pseudo-op).  Default visibility is supported everywhere.  Hidden
4295 visibility is supported on Darwin targets.
4297 The visibility attribute should be applied only to declarations that
4298 would otherwise have external linkage.  The attribute should be applied
4299 consistently, so that the same entity should not be declared with
4300 different settings of the attribute.
4302 In C++, the visibility attribute applies to types as well as functions
4303 and objects, because in C++ types have linkage.  A class must not have
4304 greater visibility than its non-static data member types and bases,
4305 and class members default to the visibility of their class.  Also, a
4306 declaration without explicit visibility is limited to the visibility
4307 of its type.
4309 In C++, you can mark member functions and static member variables of a
4310 class with the visibility attribute.  This is useful if you know a
4311 particular method or static member variable should only be used from
4312 one shared object; then you can mark it hidden while the rest of the
4313 class has default visibility.  Care must be taken to avoid breaking
4314 the One Definition Rule; for example, it is usually not useful to mark
4315 an inline method as hidden without marking the whole class as hidden.
4317 A C++ namespace declaration can also have the visibility attribute.
4319 @smallexample
4320 namespace nspace1 __attribute__ ((visibility ("protected")))
4321 @{ /* @r{Do something.} */; @}
4322 @end smallexample
4324 This attribute applies only to the particular namespace body, not to
4325 other definitions of the same namespace; it is equivalent to using
4326 @samp{#pragma GCC visibility} before and after the namespace
4327 definition (@pxref{Visibility Pragmas}).
4329 In C++, if a template argument has limited visibility, this
4330 restriction is implicitly propagated to the template instantiation.
4331 Otherwise, template instantiations and specializations default to the
4332 visibility of their template.
4334 If both the template and enclosing class have explicit visibility, the
4335 visibility from the template is used.
4337 @item vliw
4338 @cindex @code{vliw} attribute
4339 On MeP, the @code{vliw} attribute tells the compiler to emit
4340 instructions in VLIW mode instead of core mode.  Note that this
4341 attribute is not allowed unless a VLIW coprocessor has been configured
4342 and enabled through command-line options.
4344 @item warn_unused_result
4345 @cindex @code{warn_unused_result} attribute
4346 The @code{warn_unused_result} attribute causes a warning to be emitted
4347 if a caller of the function with this attribute does not use its
4348 return value.  This is useful for functions where not checking
4349 the result is either a security problem or always a bug, such as
4350 @code{realloc}.
4352 @smallexample
4353 int fn () __attribute__ ((warn_unused_result));
4354 int foo ()
4356   if (fn () < 0) return -1;
4357   fn ();
4358   return 0;
4360 @end smallexample
4362 @noindent
4363 results in warning on line 5.
4365 @item weak
4366 @cindex @code{weak} attribute
4367 The @code{weak} attribute causes the declaration to be emitted as a weak
4368 symbol rather than a global.  This is primarily useful in defining
4369 library functions that can be overridden in user code, though it can
4370 also be used with non-function declarations.  Weak symbols are supported
4371 for ELF targets, and also for a.out targets when using the GNU assembler
4372 and linker.
4374 @item weakref
4375 @itemx weakref ("@var{target}")
4376 @cindex @code{weakref} attribute
4377 The @code{weakref} attribute marks a declaration as a weak reference.
4378 Without arguments, it should be accompanied by an @code{alias} attribute
4379 naming the target symbol.  Optionally, the @var{target} may be given as
4380 an argument to @code{weakref} itself.  In either case, @code{weakref}
4381 implicitly marks the declaration as @code{weak}.  Without a
4382 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4383 @code{weakref} is equivalent to @code{weak}.
4385 @smallexample
4386 static int x() __attribute__ ((weakref ("y")));
4387 /* is equivalent to... */
4388 static int x() __attribute__ ((weak, weakref, alias ("y")));
4389 /* and to... */
4390 static int x() __attribute__ ((weakref));
4391 static int x() __attribute__ ((alias ("y")));
4392 @end smallexample
4394 A weak reference is an alias that does not by itself require a
4395 definition to be given for the target symbol.  If the target symbol is
4396 only referenced through weak references, then it becomes a @code{weak}
4397 undefined symbol.  If it is directly referenced, however, then such
4398 strong references prevail, and a definition is required for the
4399 symbol, not necessarily in the same translation unit.
4401 The effect is equivalent to moving all references to the alias to a
4402 separate translation unit, renaming the alias to the aliased symbol,
4403 declaring it as weak, compiling the two separate translation units and
4404 performing a reloadable link on them.
4406 At present, a declaration to which @code{weakref} is attached can
4407 only be @code{static}.
4409 @end table
4411 You can specify multiple attributes in a declaration by separating them
4412 by commas within the double parentheses or by immediately following an
4413 attribute declaration with another attribute declaration.
4415 @cindex @code{#pragma}, reason for not using
4416 @cindex pragma, reason for not using
4417 Some people object to the @code{__attribute__} feature, suggesting that
4418 ISO C's @code{#pragma} should be used instead.  At the time
4419 @code{__attribute__} was designed, there were two reasons for not doing
4420 this.
4422 @enumerate
4423 @item
4424 It is impossible to generate @code{#pragma} commands from a macro.
4426 @item
4427 There is no telling what the same @code{#pragma} might mean in another
4428 compiler.
4429 @end enumerate
4431 These two reasons applied to almost any application that might have been
4432 proposed for @code{#pragma}.  It was basically a mistake to use
4433 @code{#pragma} for @emph{anything}.
4435 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4436 to be generated from macros.  In addition, a @code{#pragma GCC}
4437 namespace is now in use for GCC-specific pragmas.  However, it has been
4438 found convenient to use @code{__attribute__} to achieve a natural
4439 attachment of attributes to their corresponding declarations, whereas
4440 @code{#pragma GCC} is of use for constructs that do not naturally form
4441 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4443 @node Attribute Syntax
4444 @section Attribute Syntax
4445 @cindex attribute syntax
4447 This section describes the syntax with which @code{__attribute__} may be
4448 used, and the constructs to which attribute specifiers bind, for the C
4449 language.  Some details may vary for C++ and Objective-C@.  Because of
4450 infelicities in the grammar for attributes, some forms described here
4451 may not be successfully parsed in all cases.
4453 There are some problems with the semantics of attributes in C++.  For
4454 example, there are no manglings for attributes, although they may affect
4455 code generation, so problems may arise when attributed types are used in
4456 conjunction with templates or overloading.  Similarly, @code{typeid}
4457 does not distinguish between types with different attributes.  Support
4458 for attributes in C++ may be restricted in future to attributes on
4459 declarations only, but not on nested declarators.
4461 @xref{Function Attributes}, for details of the semantics of attributes
4462 applying to functions.  @xref{Variable Attributes}, for details of the
4463 semantics of attributes applying to variables.  @xref{Type Attributes},
4464 for details of the semantics of attributes applying to structure, union
4465 and enumerated types.
4467 An @dfn{attribute specifier} is of the form
4468 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4469 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4470 each attribute is one of the following:
4472 @itemize @bullet
4473 @item
4474 Empty.  Empty attributes are ignored.
4476 @item
4477 A word (which may be an identifier such as @code{unused}, or a reserved
4478 word such as @code{const}).
4480 @item
4481 A word, followed by, in parentheses, parameters for the attribute.
4482 These parameters take one of the following forms:
4484 @itemize @bullet
4485 @item
4486 An identifier.  For example, @code{mode} attributes use this form.
4488 @item
4489 An identifier followed by a comma and a non-empty comma-separated list
4490 of expressions.  For example, @code{format} attributes use this form.
4492 @item
4493 A possibly empty comma-separated list of expressions.  For example,
4494 @code{format_arg} attributes use this form with the list being a single
4495 integer constant expression, and @code{alias} attributes use this form
4496 with the list being a single string constant.
4497 @end itemize
4498 @end itemize
4500 An @dfn{attribute specifier list} is a sequence of one or more attribute
4501 specifiers, not separated by any other tokens.
4503 In GNU C, an attribute specifier list may appear after the colon following a
4504 label, other than a @code{case} or @code{default} label.  The only
4505 attribute it makes sense to use after a label is @code{unused}.  This
4506 feature is intended for program-generated code that may contain unused labels,
4507 but which is compiled with @option{-Wall}.  It is
4508 not normally appropriate to use in it human-written code, though it
4509 could be useful in cases where the code that jumps to the label is
4510 contained within an @code{#ifdef} conditional.  GNU C++ only permits
4511 attributes on labels if the attribute specifier is immediately
4512 followed by a semicolon (i.e., the label applies to an empty
4513 statement).  If the semicolon is missing, C++ label attributes are
4514 ambiguous, as it is permissible for a declaration, which could begin
4515 with an attribute list, to be labelled in C++.  Declarations cannot be
4516 labelled in C90 or C99, so the ambiguity does not arise there.
4518 An attribute specifier list may appear as part of a @code{struct},
4519 @code{union} or @code{enum} specifier.  It may go either immediately
4520 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4521 the closing brace.  The former syntax is preferred.
4522 Where attribute specifiers follow the closing brace, they are considered
4523 to relate to the structure, union or enumerated type defined, not to any
4524 enclosing declaration the type specifier appears in, and the type
4525 defined is not complete until after the attribute specifiers.
4526 @c Otherwise, there would be the following problems: a shift/reduce
4527 @c conflict between attributes binding the struct/union/enum and
4528 @c binding to the list of specifiers/qualifiers; and "aligned"
4529 @c attributes could use sizeof for the structure, but the size could be
4530 @c changed later by "packed" attributes.
4532 Otherwise, an attribute specifier appears as part of a declaration,
4533 counting declarations of unnamed parameters and type names, and relates
4534 to that declaration (which may be nested in another declaration, for
4535 example in the case of a parameter declaration), or to a particular declarator
4536 within a declaration.  Where an
4537 attribute specifier is applied to a parameter declared as a function or
4538 an array, it should apply to the function or array rather than the
4539 pointer to which the parameter is implicitly converted, but this is not
4540 yet correctly implemented.
4542 Any list of specifiers and qualifiers at the start of a declaration may
4543 contain attribute specifiers, whether or not such a list may in that
4544 context contain storage class specifiers.  (Some attributes, however,
4545 are essentially in the nature of storage class specifiers, and only make
4546 sense where storage class specifiers may be used; for example,
4547 @code{section}.)  There is one necessary limitation to this syntax: the
4548 first old-style parameter declaration in a function definition cannot
4549 begin with an attribute specifier, because such an attribute applies to
4550 the function instead by syntax described below (which, however, is not
4551 yet implemented in this case).  In some other cases, attribute
4552 specifiers are permitted by this grammar but not yet supported by the
4553 compiler.  All attribute specifiers in this place relate to the
4554 declaration as a whole.  In the obsolescent usage where a type of
4555 @code{int} is implied by the absence of type specifiers, such a list of
4556 specifiers and qualifiers may be an attribute specifier list with no
4557 other specifiers or qualifiers.
4559 At present, the first parameter in a function prototype must have some
4560 type specifier that is not an attribute specifier; this resolves an
4561 ambiguity in the interpretation of @code{void f(int
4562 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4563 the parentheses of a function declarator contain only attributes then
4564 those attributes are ignored, rather than yielding an error or warning
4565 or implying a single parameter of type int, but this is subject to
4566 change.
4568 An attribute specifier list may appear immediately before a declarator
4569 (other than the first) in a comma-separated list of declarators in a
4570 declaration of more than one identifier using a single list of
4571 specifiers and qualifiers.  Such attribute specifiers apply
4572 only to the identifier before whose declarator they appear.  For
4573 example, in
4575 @smallexample
4576 __attribute__((noreturn)) void d0 (void),
4577     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4578      d2 (void)
4579 @end smallexample
4581 @noindent
4582 the @code{noreturn} attribute applies to all the functions
4583 declared; the @code{format} attribute only applies to @code{d1}.
4585 An attribute specifier list may appear immediately before the comma,
4586 @code{=} or semicolon terminating the declaration of an identifier other
4587 than a function definition.  Such attribute specifiers apply
4588 to the declared object or function.  Where an
4589 assembler name for an object or function is specified (@pxref{Asm
4590 Labels}), the attribute must follow the @code{asm}
4591 specification.
4593 An attribute specifier list may, in future, be permitted to appear after
4594 the declarator in a function definition (before any old-style parameter
4595 declarations or the function body).
4597 Attribute specifiers may be mixed with type qualifiers appearing inside
4598 the @code{[]} of a parameter array declarator, in the C99 construct by
4599 which such qualifiers are applied to the pointer to which the array is
4600 implicitly converted.  Such attribute specifiers apply to the pointer,
4601 not to the array, but at present this is not implemented and they are
4602 ignored.
4604 An attribute specifier list may appear at the start of a nested
4605 declarator.  At present, there are some limitations in this usage: the
4606 attributes correctly apply to the declarator, but for most individual
4607 attributes the semantics this implies are not implemented.
4608 When attribute specifiers follow the @code{*} of a pointer
4609 declarator, they may be mixed with any type qualifiers present.
4610 The following describes the formal semantics of this syntax.  It makes the
4611 most sense if you are familiar with the formal specification of
4612 declarators in the ISO C standard.
4614 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4615 D1}, where @code{T} contains declaration specifiers that specify a type
4616 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4617 contains an identifier @var{ident}.  The type specified for @var{ident}
4618 for derived declarators whose type does not include an attribute
4619 specifier is as in the ISO C standard.
4621 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4622 and the declaration @code{T D} specifies the type
4623 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4624 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4625 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4627 If @code{D1} has the form @code{*
4628 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4629 declaration @code{T D} specifies the type
4630 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4631 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4632 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4633 @var{ident}.
4635 For example,
4637 @smallexample
4638 void (__attribute__((noreturn)) ****f) (void);
4639 @end smallexample
4641 @noindent
4642 specifies the type ``pointer to pointer to pointer to pointer to
4643 non-returning function returning @code{void}''.  As another example,
4645 @smallexample
4646 char *__attribute__((aligned(8))) *f;
4647 @end smallexample
4649 @noindent
4650 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4651 Note again that this does not work with most attributes; for example,
4652 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4653 is not yet supported.
4655 For compatibility with existing code written for compiler versions that
4656 did not implement attributes on nested declarators, some laxity is
4657 allowed in the placing of attributes.  If an attribute that only applies
4658 to types is applied to a declaration, it is treated as applying to
4659 the type of that declaration.  If an attribute that only applies to
4660 declarations is applied to the type of a declaration, it is treated
4661 as applying to that declaration; and, for compatibility with code
4662 placing the attributes immediately before the identifier declared, such
4663 an attribute applied to a function return type is treated as
4664 applying to the function type, and such an attribute applied to an array
4665 element type is treated as applying to the array type.  If an
4666 attribute that only applies to function types is applied to a
4667 pointer-to-function type, it is treated as applying to the pointer
4668 target type; if such an attribute is applied to a function return type
4669 that is not a pointer-to-function type, it is treated as applying
4670 to the function type.
4672 @node Function Prototypes
4673 @section Prototypes and Old-Style Function Definitions
4674 @cindex function prototype declarations
4675 @cindex old-style function definitions
4676 @cindex promotion of formal parameters
4678 GNU C extends ISO C to allow a function prototype to override a later
4679 old-style non-prototype definition.  Consider the following example:
4681 @smallexample
4682 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4683 #ifdef __STDC__
4684 #define P(x) x
4685 #else
4686 #define P(x) ()
4687 #endif
4689 /* @r{Prototype function declaration.}  */
4690 int isroot P((uid_t));
4692 /* @r{Old-style function definition.}  */
4694 isroot (x)   /* @r{??? lossage here ???} */
4695      uid_t x;
4697   return x == 0;
4699 @end smallexample
4701 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4702 not allow this example, because subword arguments in old-style
4703 non-prototype definitions are promoted.  Therefore in this example the
4704 function definition's argument is really an @code{int}, which does not
4705 match the prototype argument type of @code{short}.
4707 This restriction of ISO C makes it hard to write code that is portable
4708 to traditional C compilers, because the programmer does not know
4709 whether the @code{uid_t} type is @code{short}, @code{int}, or
4710 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4711 to override a later old-style definition.  More precisely, in GNU C, a
4712 function prototype argument type overrides the argument type specified
4713 by a later old-style definition if the former type is the same as the
4714 latter type before promotion.  Thus in GNU C the above example is
4715 equivalent to the following:
4717 @smallexample
4718 int isroot (uid_t);
4721 isroot (uid_t x)
4723   return x == 0;
4725 @end smallexample
4727 @noindent
4728 GNU C++ does not support old-style function definitions, so this
4729 extension is irrelevant.
4731 @node C++ Comments
4732 @section C++ Style Comments
4733 @cindex @code{//}
4734 @cindex C++ comments
4735 @cindex comments, C++ style
4737 In GNU C, you may use C++ style comments, which start with @samp{//} and
4738 continue until the end of the line.  Many other C implementations allow
4739 such comments, and they are included in the 1999 C standard.  However,
4740 C++ style comments are not recognized if you specify an @option{-std}
4741 option specifying a version of ISO C before C99, or @option{-ansi}
4742 (equivalent to @option{-std=c90}).
4744 @node Dollar Signs
4745 @section Dollar Signs in Identifier Names
4746 @cindex $
4747 @cindex dollar signs in identifier names
4748 @cindex identifier names, dollar signs in
4750 In GNU C, you may normally use dollar signs in identifier names.
4751 This is because many traditional C implementations allow such identifiers.
4752 However, dollar signs in identifiers are not supported on a few target
4753 machines, typically because the target assembler does not allow them.
4755 @node Character Escapes
4756 @section The Character @key{ESC} in Constants
4758 You can use the sequence @samp{\e} in a string or character constant to
4759 stand for the ASCII character @key{ESC}.
4761 @node Variable Attributes
4762 @section Specifying Attributes of Variables
4763 @cindex attribute of variables
4764 @cindex variable attributes
4766 The keyword @code{__attribute__} allows you to specify special
4767 attributes of variables or structure fields.  This keyword is followed
4768 by an attribute specification inside double parentheses.  Some
4769 attributes are currently defined generically for variables.
4770 Other attributes are defined for variables on particular target
4771 systems.  Other attributes are available for functions
4772 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4773 Other front ends might define more attributes
4774 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4776 You may also specify attributes with @samp{__} preceding and following
4777 each keyword.  This allows you to use them in header files without
4778 being concerned about a possible macro of the same name.  For example,
4779 you may use @code{__aligned__} instead of @code{aligned}.
4781 @xref{Attribute Syntax}, for details of the exact syntax for using
4782 attributes.
4784 @table @code
4785 @cindex @code{aligned} attribute
4786 @item aligned (@var{alignment})
4787 This attribute specifies a minimum alignment for the variable or
4788 structure field, measured in bytes.  For example, the declaration:
4790 @smallexample
4791 int x __attribute__ ((aligned (16))) = 0;
4792 @end smallexample
4794 @noindent
4795 causes the compiler to allocate the global variable @code{x} on a
4796 16-byte boundary.  On a 68040, this could be used in conjunction with
4797 an @code{asm} expression to access the @code{move16} instruction which
4798 requires 16-byte aligned operands.
4800 You can also specify the alignment of structure fields.  For example, to
4801 create a double-word aligned @code{int} pair, you could write:
4803 @smallexample
4804 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4805 @end smallexample
4807 @noindent
4808 This is an alternative to creating a union with a @code{double} member,
4809 which forces the union to be double-word aligned.
4811 As in the preceding examples, you can explicitly specify the alignment
4812 (in bytes) that you wish the compiler to use for a given variable or
4813 structure field.  Alternatively, you can leave out the alignment factor
4814 and just ask the compiler to align a variable or field to the
4815 default alignment for the target architecture you are compiling for.
4816 The default alignment is sufficient for all scalar types, but may not be
4817 enough for all vector types on a target that supports vector operations.
4818 The default alignment is fixed for a particular target ABI.
4820 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4821 which is the largest alignment ever used for any data type on the
4822 target machine you are compiling for.  For example, you could write:
4824 @smallexample
4825 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4826 @end smallexample
4828 The compiler automatically sets the alignment for the declared
4829 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
4830 often make copy operations more efficient, because the compiler can
4831 use whatever instructions copy the biggest chunks of memory when
4832 performing copies to or from the variables or fields that you have
4833 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
4834 may change depending on command-line options.
4836 When used on a struct, or struct member, the @code{aligned} attribute can
4837 only increase the alignment; in order to decrease it, the @code{packed}
4838 attribute must be specified as well.  When used as part of a typedef, the
4839 @code{aligned} attribute can both increase and decrease alignment, and
4840 specifying the @code{packed} attribute generates a warning.
4842 Note that the effectiveness of @code{aligned} attributes may be limited
4843 by inherent limitations in your linker.  On many systems, the linker is
4844 only able to arrange for variables to be aligned up to a certain maximum
4845 alignment.  (For some linkers, the maximum supported alignment may
4846 be very very small.)  If your linker is only able to align variables
4847 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4848 in an @code{__attribute__} still only provides you with 8-byte
4849 alignment.  See your linker documentation for further information.
4851 The @code{aligned} attribute can also be used for functions
4852 (@pxref{Function Attributes}.)
4854 @item cleanup (@var{cleanup_function})
4855 @cindex @code{cleanup} attribute
4856 The @code{cleanup} attribute runs a function when the variable goes
4857 out of scope.  This attribute can only be applied to auto function
4858 scope variables; it may not be applied to parameters or variables
4859 with static storage duration.  The function must take one parameter,
4860 a pointer to a type compatible with the variable.  The return value
4861 of the function (if any) is ignored.
4863 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4864 is run during the stack unwinding that happens during the
4865 processing of the exception.  Note that the @code{cleanup} attribute
4866 does not allow the exception to be caught, only to perform an action.
4867 It is undefined what happens if @var{cleanup_function} does not
4868 return normally.
4870 @item common
4871 @itemx nocommon
4872 @cindex @code{common} attribute
4873 @cindex @code{nocommon} attribute
4874 @opindex fcommon
4875 @opindex fno-common
4876 The @code{common} attribute requests GCC to place a variable in
4877 ``common'' storage.  The @code{nocommon} attribute requests the
4878 opposite---to allocate space for it directly.
4880 These attributes override the default chosen by the
4881 @option{-fno-common} and @option{-fcommon} flags respectively.
4883 @item deprecated
4884 @itemx deprecated (@var{msg})
4885 @cindex @code{deprecated} attribute
4886 The @code{deprecated} attribute results in a warning if the variable
4887 is used anywhere in the source file.  This is useful when identifying
4888 variables that are expected to be removed in a future version of a
4889 program.  The warning also includes the location of the declaration
4890 of the deprecated variable, to enable users to easily find further
4891 information about why the variable is deprecated, or what they should
4892 do instead.  Note that the warning only occurs for uses:
4894 @smallexample
4895 extern int old_var __attribute__ ((deprecated));
4896 extern int old_var;
4897 int new_fn () @{ return old_var; @}
4898 @end smallexample
4900 @noindent
4901 results in a warning on line 3 but not line 2.  The optional @var{msg}
4902 argument, which must be a string, is printed in the warning if
4903 present.
4905 The @code{deprecated} attribute can also be used for functions and
4906 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4908 @item mode (@var{mode})
4909 @cindex @code{mode} attribute
4910 This attribute specifies the data type for the declaration---whichever
4911 type corresponds to the mode @var{mode}.  This in effect lets you
4912 request an integer or floating-point type according to its width.
4914 You may also specify a mode of @code{byte} or @code{__byte__} to
4915 indicate the mode corresponding to a one-byte integer, @code{word} or
4916 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4917 or @code{__pointer__} for the mode used to represent pointers.
4919 @item packed
4920 @cindex @code{packed} attribute
4921 The @code{packed} attribute specifies that a variable or structure field
4922 should have the smallest possible alignment---one byte for a variable,
4923 and one bit for a field, unless you specify a larger value with the
4924 @code{aligned} attribute.
4926 Here is a structure in which the field @code{x} is packed, so that it
4927 immediately follows @code{a}:
4929 @smallexample
4930 struct foo
4932   char a;
4933   int x[2] __attribute__ ((packed));
4935 @end smallexample
4937 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4938 @code{packed} attribute on bit-fields of type @code{char}.  This has
4939 been fixed in GCC 4.4 but the change can lead to differences in the
4940 structure layout.  See the documentation of
4941 @option{-Wpacked-bitfield-compat} for more information.
4943 @item section ("@var{section-name}")
4944 @cindex @code{section} variable attribute
4945 Normally, the compiler places the objects it generates in sections like
4946 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
4947 or you need certain particular variables to appear in special sections,
4948 for example to map to special hardware.  The @code{section}
4949 attribute specifies that a variable (or function) lives in a particular
4950 section.  For example, this small program uses several specific section names:
4952 @smallexample
4953 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4954 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4955 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4956 int init_data __attribute__ ((section ("INITDATA")));
4958 main()
4960   /* @r{Initialize stack pointer} */
4961   init_sp (stack + sizeof (stack));
4963   /* @r{Initialize initialized data} */
4964   memcpy (&init_data, &data, &edata - &data);
4966   /* @r{Turn on the serial ports} */
4967   init_duart (&a);
4968   init_duart (&b);
4970 @end smallexample
4972 @noindent
4973 Use the @code{section} attribute with
4974 @emph{global} variables and not @emph{local} variables,
4975 as shown in the example.
4977 You may use the @code{section} attribute with initialized or
4978 uninitialized global variables but the linker requires
4979 each object be defined once, with the exception that uninitialized
4980 variables tentatively go in the @code{common} (or @code{bss}) section
4981 and can be multiply ``defined''.  Using the @code{section} attribute
4982 changes what section the variable goes into and may cause the
4983 linker to issue an error if an uninitialized variable has multiple
4984 definitions.  You can force a variable to be initialized with the
4985 @option{-fno-common} flag or the @code{nocommon} attribute.
4987 Some file formats do not support arbitrary sections so the @code{section}
4988 attribute is not available on all platforms.
4989 If you need to map the entire contents of a module to a particular
4990 section, consider using the facilities of the linker instead.
4992 @item shared
4993 @cindex @code{shared} variable attribute
4994 On Microsoft Windows, in addition to putting variable definitions in a named
4995 section, the section can also be shared among all running copies of an
4996 executable or DLL@.  For example, this small program defines shared data
4997 by putting it in a named section @code{shared} and marking the section
4998 shareable:
5000 @smallexample
5001 int foo __attribute__((section ("shared"), shared)) = 0;
5004 main()
5006   /* @r{Read and write foo.  All running
5007      copies see the same value.}  */
5008   return 0;
5010 @end smallexample
5012 @noindent
5013 You may only use the @code{shared} attribute along with @code{section}
5014 attribute with a fully-initialized global definition because of the way
5015 linkers work.  See @code{section} attribute for more information.
5017 The @code{shared} attribute is only available on Microsoft Windows@.
5019 @item tls_model ("@var{tls_model}")
5020 @cindex @code{tls_model} attribute
5021 The @code{tls_model} attribute sets thread-local storage model
5022 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5023 overriding @option{-ftls-model=} command-line switch on a per-variable
5024 basis.
5025 The @var{tls_model} argument should be one of @code{global-dynamic},
5026 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5028 Not all targets support this attribute.
5030 @item unused
5031 This attribute, attached to a variable, means that the variable is meant
5032 to be possibly unused.  GCC does not produce a warning for this
5033 variable.
5035 @item used
5036 This attribute, attached to a variable with the static storage, means that
5037 the variable must be emitted even if it appears that the variable is not
5038 referenced.
5040 When applied to a static data member of a C++ class template, the
5041 attribute also means that the member is instantiated if the
5042 class itself is instantiated.
5044 @item vector_size (@var{bytes})
5045 This attribute specifies the vector size for the variable, measured in
5046 bytes.  For example, the declaration:
5048 @smallexample
5049 int foo __attribute__ ((vector_size (16)));
5050 @end smallexample
5052 @noindent
5053 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5054 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5055 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5057 This attribute is only applicable to integral and float scalars,
5058 although arrays, pointers, and function return values are allowed in
5059 conjunction with this construct.
5061 Aggregates with this attribute are invalid, even if they are of the same
5062 size as a corresponding scalar.  For example, the declaration:
5064 @smallexample
5065 struct S @{ int a; @};
5066 struct S  __attribute__ ((vector_size (16))) foo;
5067 @end smallexample
5069 @noindent
5070 is invalid even if the size of the structure is the same as the size of
5071 the @code{int}.
5073 @item selectany
5074 The @code{selectany} attribute causes an initialized global variable to
5075 have link-once semantics.  When multiple definitions of the variable are
5076 encountered by the linker, the first is selected and the remainder are
5077 discarded.  Following usage by the Microsoft compiler, the linker is told
5078 @emph{not} to warn about size or content differences of the multiple
5079 definitions.
5081 Although the primary usage of this attribute is for POD types, the
5082 attribute can also be applied to global C++ objects that are initialized
5083 by a constructor.  In this case, the static initialization and destruction
5084 code for the object is emitted in each translation defining the object,
5085 but the calls to the constructor and destructor are protected by a
5086 link-once guard variable.
5088 The @code{selectany} attribute is only available on Microsoft Windows
5089 targets.  You can use @code{__declspec (selectany)} as a synonym for
5090 @code{__attribute__ ((selectany))} for compatibility with other
5091 compilers.
5093 @item weak
5094 The @code{weak} attribute is described in @ref{Function Attributes}.
5096 @item dllimport
5097 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5099 @item dllexport
5100 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5102 @end table
5104 @anchor{AVR Variable Attributes}
5105 @subsection AVR Variable Attributes
5107 @table @code
5108 @item progmem
5109 @cindex @code{progmem} AVR variable attribute
5110 The @code{progmem} attribute is used on the AVR to place read-only
5111 data in the non-volatile program memory (flash). The @code{progmem}
5112 attribute accomplishes this by putting respective variables into a
5113 section whose name starts with @code{.progmem}.
5115 This attribute works similar to the @code{section} attribute
5116 but adds additional checking. Notice that just like the
5117 @code{section} attribute, @code{progmem} affects the location
5118 of the data but not how this data is accessed.
5120 In order to read data located with the @code{progmem} attribute
5121 (inline) assembler must be used.
5122 @smallexample
5123 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5124 #include <avr/pgmspace.h> 
5126 /* Locate var in flash memory */
5127 const int var[2] PROGMEM = @{ 1, 2 @};
5129 int read_var (int i)
5131     /* Access var[] by accessor macro from avr/pgmspace.h */
5132     return (int) pgm_read_word (& var[i]);
5134 @end smallexample
5136 AVR is a Harvard architecture processor and data and read-only data
5137 normally resides in the data memory (RAM).
5139 See also the @ref{AVR Named Address Spaces} section for
5140 an alternate way to locate and access data in flash memory.
5141 @end table
5143 @subsection Blackfin Variable Attributes
5145 Three attributes are currently defined for the Blackfin.
5147 @table @code
5148 @item l1_data
5149 @itemx l1_data_A
5150 @itemx l1_data_B
5151 @cindex @code{l1_data} variable attribute
5152 @cindex @code{l1_data_A} variable attribute
5153 @cindex @code{l1_data_B} variable attribute
5154 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5155 Variables with @code{l1_data} attribute are put into the specific section
5156 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5157 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5158 attribute are put into the specific section named @code{.l1.data.B}.
5160 @item l2
5161 @cindex @code{l2} variable attribute
5162 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5163 Variables with @code{l2} attribute are put into the specific section
5164 named @code{.l2.data}.
5165 @end table
5167 @subsection M32R/D Variable Attributes
5169 One attribute is currently defined for the M32R/D@.
5171 @table @code
5172 @item model (@var{model-name})
5173 @cindex variable addressability on the M32R/D
5174 Use this attribute on the M32R/D to set the addressability of an object.
5175 The identifier @var{model-name} is one of @code{small}, @code{medium},
5176 or @code{large}, representing each of the code models.
5178 Small model objects live in the lower 16MB of memory (so that their
5179 addresses can be loaded with the @code{ld24} instruction).
5181 Medium and large model objects may live anywhere in the 32-bit address space
5182 (the compiler generates @code{seth/add3} instructions to load their
5183 addresses).
5184 @end table
5186 @anchor{MeP Variable Attributes}
5187 @subsection MeP Variable Attributes
5189 The MeP target has a number of addressing modes and busses.  The
5190 @code{near} space spans the standard memory space's first 16 megabytes
5191 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5192 The @code{based} space is a 128-byte region in the memory space that
5193 is addressed relative to the @code{$tp} register.  The @code{tiny}
5194 space is a 65536-byte region relative to the @code{$gp} register.  In
5195 addition to these memory regions, the MeP target has a separate 16-bit
5196 control bus which is specified with @code{cb} attributes.
5198 @table @code
5200 @item based
5201 Any variable with the @code{based} attribute is assigned to the
5202 @code{.based} section, and is accessed with relative to the
5203 @code{$tp} register.
5205 @item tiny
5206 Likewise, the @code{tiny} attribute assigned variables to the
5207 @code{.tiny} section, relative to the @code{$gp} register.
5209 @item near
5210 Variables with the @code{near} attribute are assumed to have addresses
5211 that fit in a 24-bit addressing mode.  This is the default for large
5212 variables (@code{-mtiny=4} is the default) but this attribute can
5213 override @code{-mtiny=} for small variables, or override @code{-ml}.
5215 @item far
5216 Variables with the @code{far} attribute are addressed using a full
5217 32-bit address.  Since this covers the entire memory space, this
5218 allows modules to make no assumptions about where variables might be
5219 stored.
5221 @item io
5222 @itemx io (@var{addr})
5223 Variables with the @code{io} attribute are used to address
5224 memory-mapped peripherals.  If an address is specified, the variable
5225 is assigned that address, else it is not assigned an address (it is
5226 assumed some other module assigns an address).  Example:
5228 @smallexample
5229 int timer_count __attribute__((io(0x123)));
5230 @end smallexample
5232 @item cb
5233 @itemx cb (@var{addr})
5234 Variables with the @code{cb} attribute are used to access the control
5235 bus, using special instructions.  @code{addr} indicates the control bus
5236 address.  Example:
5238 @smallexample
5239 int cpu_clock __attribute__((cb(0x123)));
5240 @end smallexample
5242 @end table
5244 @anchor{i386 Variable Attributes}
5245 @subsection i386 Variable Attributes
5247 Two attributes are currently defined for i386 configurations:
5248 @code{ms_struct} and @code{gcc_struct}
5250 @table @code
5251 @item ms_struct
5252 @itemx gcc_struct
5253 @cindex @code{ms_struct} attribute
5254 @cindex @code{gcc_struct} attribute
5256 If @code{packed} is used on a structure, or if bit-fields are used,
5257 it may be that the Microsoft ABI lays out the structure differently
5258 than the way GCC normally does.  Particularly when moving packed
5259 data between functions compiled with GCC and the native Microsoft compiler
5260 (either via function call or as data in a file), it may be necessary to access
5261 either format.
5263 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5264 compilers to match the native Microsoft compiler.
5266 The Microsoft structure layout algorithm is fairly simple with the exception
5267 of the bit-field packing.  
5268 The padding and alignment of members of structures and whether a bit-field 
5269 can straddle a storage-unit boundary are determine by these rules:
5271 @enumerate
5272 @item Structure members are stored sequentially in the order in which they are
5273 declared: the first member has the lowest memory address and the last member
5274 the highest.
5276 @item Every data object has an alignment requirement.  The alignment requirement
5277 for all data except structures, unions, and arrays is either the size of the
5278 object or the current packing size (specified with either the
5279 @code{aligned} attribute or the @code{pack} pragma),
5280 whichever is less.  For structures, unions, and arrays,
5281 the alignment requirement is the largest alignment requirement of its members.
5282 Every object is allocated an offset so that:
5284 @smallexample
5285 offset % alignment_requirement == 0
5286 @end smallexample
5288 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5289 unit if the integral types are the same size and if the next bit-field fits
5290 into the current allocation unit without crossing the boundary imposed by the
5291 common alignment requirements of the bit-fields.
5292 @end enumerate
5294 MSVC interprets zero-length bit-fields in the following ways:
5296 @enumerate
5297 @item If a zero-length bit-field is inserted between two bit-fields that
5298 are normally coalesced, the bit-fields are not coalesced.
5300 For example:
5302 @smallexample
5303 struct
5304  @{
5305    unsigned long bf_1 : 12;
5306    unsigned long : 0;
5307    unsigned long bf_2 : 12;
5308  @} t1;
5309 @end smallexample
5311 @noindent
5312 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5313 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5315 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5316 alignment of the zero-length bit-field is greater than the member that follows it,
5317 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5319 For example:
5321 @smallexample
5322 struct
5323  @{
5324    char foo : 4;
5325    short : 0;
5326    char bar;
5327  @} t2;
5329 struct
5330  @{
5331    char foo : 4;
5332    short : 0;
5333    double bar;
5334  @} t3;
5335 @end smallexample
5337 @noindent
5338 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5339 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5340 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5341 of the structure.
5343 Taking this into account, it is important to note the following:
5345 @enumerate
5346 @item If a zero-length bit-field follows a normal bit-field, the type of the
5347 zero-length bit-field may affect the alignment of the structure as whole. For
5348 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5349 normal bit-field, and is of type short.
5351 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5352 still affect the alignment of the structure:
5354 @smallexample
5355 struct
5356  @{
5357    char foo : 6;
5358    long : 0;
5359  @} t4;
5360 @end smallexample
5362 @noindent
5363 Here, @code{t4} takes up 4 bytes.
5364 @end enumerate
5366 @item Zero-length bit-fields following non-bit-field members are ignored:
5368 @smallexample
5369 struct
5370  @{
5371    char foo;
5372    long : 0;
5373    char bar;
5374  @} t5;
5375 @end smallexample
5377 @noindent
5378 Here, @code{t5} takes up 2 bytes.
5379 @end enumerate
5380 @end table
5382 @subsection PowerPC Variable Attributes
5384 Three attributes currently are defined for PowerPC configurations:
5385 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5387 For full documentation of the struct attributes please see the
5388 documentation in @ref{i386 Variable Attributes}.
5390 For documentation of @code{altivec} attribute please see the
5391 documentation in @ref{PowerPC Type Attributes}.
5393 @subsection SPU Variable Attributes
5395 The SPU supports the @code{spu_vector} attribute for variables.  For
5396 documentation of this attribute please see the documentation in
5397 @ref{SPU Type Attributes}.
5399 @subsection Xstormy16 Variable Attributes
5401 One attribute is currently defined for xstormy16 configurations:
5402 @code{below100}.
5404 @table @code
5405 @item below100
5406 @cindex @code{below100} attribute
5408 If a variable has the @code{below100} attribute (@code{BELOW100} is
5409 allowed also), GCC places the variable in the first 0x100 bytes of
5410 memory and use special opcodes to access it.  Such variables are
5411 placed in either the @code{.bss_below100} section or the
5412 @code{.data_below100} section.
5414 @end table
5416 @node Type Attributes
5417 @section Specifying Attributes of Types
5418 @cindex attribute of types
5419 @cindex type attributes
5421 The keyword @code{__attribute__} allows you to specify special
5422 attributes of @code{struct} and @code{union} types when you define
5423 such types.  This keyword is followed by an attribute specification
5424 inside double parentheses.  Seven attributes are currently defined for
5425 types: @code{aligned}, @code{packed}, @code{transparent_union},
5426 @code{unused}, @code{deprecated}, @code{visibility}, and
5427 @code{may_alias}.  Other attributes are defined for functions
5428 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5429 Attributes}).
5431 You may also specify any one of these attributes with @samp{__}
5432 preceding and following its keyword.  This allows you to use these
5433 attributes in header files without being concerned about a possible
5434 macro of the same name.  For example, you may use @code{__aligned__}
5435 instead of @code{aligned}.
5437 You may specify type attributes in an enum, struct or union type
5438 declaration or definition, or for other types in a @code{typedef}
5439 declaration.
5441 For an enum, struct or union type, you may specify attributes either
5442 between the enum, struct or union tag and the name of the type, or
5443 just past the closing curly brace of the @emph{definition}.  The
5444 former syntax is preferred.
5446 @xref{Attribute Syntax}, for details of the exact syntax for using
5447 attributes.
5449 @table @code
5450 @cindex @code{aligned} attribute
5451 @item aligned (@var{alignment})
5452 This attribute specifies a minimum alignment (in bytes) for variables
5453 of the specified type.  For example, the declarations:
5455 @smallexample
5456 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5457 typedef int more_aligned_int __attribute__ ((aligned (8)));
5458 @end smallexample
5460 @noindent
5461 force the compiler to ensure (as far as it can) that each variable whose
5462 type is @code{struct S} or @code{more_aligned_int} is allocated and
5463 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5464 variables of type @code{struct S} aligned to 8-byte boundaries allows
5465 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5466 store) instructions when copying one variable of type @code{struct S} to
5467 another, thus improving run-time efficiency.
5469 Note that the alignment of any given @code{struct} or @code{union} type
5470 is required by the ISO C standard to be at least a perfect multiple of
5471 the lowest common multiple of the alignments of all of the members of
5472 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5473 effectively adjust the alignment of a @code{struct} or @code{union}
5474 type by attaching an @code{aligned} attribute to any one of the members
5475 of such a type, but the notation illustrated in the example above is a
5476 more obvious, intuitive, and readable way to request the compiler to
5477 adjust the alignment of an entire @code{struct} or @code{union} type.
5479 As in the preceding example, you can explicitly specify the alignment
5480 (in bytes) that you wish the compiler to use for a given @code{struct}
5481 or @code{union} type.  Alternatively, you can leave out the alignment factor
5482 and just ask the compiler to align a type to the maximum
5483 useful alignment for the target machine you are compiling for.  For
5484 example, you could write:
5486 @smallexample
5487 struct S @{ short f[3]; @} __attribute__ ((aligned));
5488 @end smallexample
5490 Whenever you leave out the alignment factor in an @code{aligned}
5491 attribute specification, the compiler automatically sets the alignment
5492 for the type to the largest alignment that is ever used for any data
5493 type on the target machine you are compiling for.  Doing this can often
5494 make copy operations more efficient, because the compiler can use
5495 whatever instructions copy the biggest chunks of memory when performing
5496 copies to or from the variables that have types that you have aligned
5497 this way.
5499 In the example above, if the size of each @code{short} is 2 bytes, then
5500 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5501 power of two that is greater than or equal to that is 8, so the
5502 compiler sets the alignment for the entire @code{struct S} type to 8
5503 bytes.
5505 Note that although you can ask the compiler to select a time-efficient
5506 alignment for a given type and then declare only individual stand-alone
5507 objects of that type, the compiler's ability to select a time-efficient
5508 alignment is primarily useful only when you plan to create arrays of
5509 variables having the relevant (efficiently aligned) type.  If you
5510 declare or use arrays of variables of an efficiently-aligned type, then
5511 it is likely that your program also does pointer arithmetic (or
5512 subscripting, which amounts to the same thing) on pointers to the
5513 relevant type, and the code that the compiler generates for these
5514 pointer arithmetic operations is often more efficient for
5515 efficiently-aligned types than for other types.
5517 The @code{aligned} attribute can only increase the alignment; but you
5518 can decrease it by specifying @code{packed} as well.  See below.
5520 Note that the effectiveness of @code{aligned} attributes may be limited
5521 by inherent limitations in your linker.  On many systems, the linker is
5522 only able to arrange for variables to be aligned up to a certain maximum
5523 alignment.  (For some linkers, the maximum supported alignment may
5524 be very very small.)  If your linker is only able to align variables
5525 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5526 in an @code{__attribute__} still only provides you with 8-byte
5527 alignment.  See your linker documentation for further information.
5529 @item packed
5530 This attribute, attached to @code{struct} or @code{union} type
5531 definition, specifies that each member (other than zero-width bit-fields)
5532 of the structure or union is placed to minimize the memory required.  When
5533 attached to an @code{enum} definition, it indicates that the smallest
5534 integral type should be used.
5536 @opindex fshort-enums
5537 Specifying this attribute for @code{struct} and @code{union} types is
5538 equivalent to specifying the @code{packed} attribute on each of the
5539 structure or union members.  Specifying the @option{-fshort-enums}
5540 flag on the line is equivalent to specifying the @code{packed}
5541 attribute on all @code{enum} definitions.
5543 In the following example @code{struct my_packed_struct}'s members are
5544 packed closely together, but the internal layout of its @code{s} member
5545 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5546 be packed too.
5548 @smallexample
5549 struct my_unpacked_struct
5550  @{
5551     char c;
5552     int i;
5553  @};
5555 struct __attribute__ ((__packed__)) my_packed_struct
5556   @{
5557      char c;
5558      int  i;
5559      struct my_unpacked_struct s;
5560   @};
5561 @end smallexample
5563 You may only specify this attribute on the definition of an @code{enum},
5564 @code{struct} or @code{union}, not on a @code{typedef} that does not
5565 also define the enumerated type, structure or union.
5567 @item transparent_union
5568 This attribute, attached to a @code{union} type definition, indicates
5569 that any function parameter having that union type causes calls to that
5570 function to be treated in a special way.
5572 First, the argument corresponding to a transparent union type can be of
5573 any type in the union; no cast is required.  Also, if the union contains
5574 a pointer type, the corresponding argument can be a null pointer
5575 constant or a void pointer expression; and if the union contains a void
5576 pointer type, the corresponding argument can be any pointer expression.
5577 If the union member type is a pointer, qualifiers like @code{const} on
5578 the referenced type must be respected, just as with normal pointer
5579 conversions.
5581 Second, the argument is passed to the function using the calling
5582 conventions of the first member of the transparent union, not the calling
5583 conventions of the union itself.  All members of the union must have the
5584 same machine representation; this is necessary for this argument passing
5585 to work properly.
5587 Transparent unions are designed for library functions that have multiple
5588 interfaces for compatibility reasons.  For example, suppose the
5589 @code{wait} function must accept either a value of type @code{int *} to
5590 comply with POSIX, or a value of type @code{union wait *} to comply with
5591 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5592 @code{wait} would accept both kinds of arguments, but it would also
5593 accept any other pointer type and this would make argument type checking
5594 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5595 as follows:
5597 @smallexample
5598 typedef union __attribute__ ((__transparent_union__))
5599   @{
5600     int *__ip;
5601     union wait *__up;
5602   @} wait_status_ptr_t;
5604 pid_t wait (wait_status_ptr_t);
5605 @end smallexample
5607 @noindent
5608 This interface allows either @code{int *} or @code{union wait *}
5609 arguments to be passed, using the @code{int *} calling convention.
5610 The program can call @code{wait} with arguments of either type:
5612 @smallexample
5613 int w1 () @{ int w; return wait (&w); @}
5614 int w2 () @{ union wait w; return wait (&w); @}
5615 @end smallexample
5617 @noindent
5618 With this interface, @code{wait}'s implementation might look like this:
5620 @smallexample
5621 pid_t wait (wait_status_ptr_t p)
5623   return waitpid (-1, p.__ip, 0);
5625 @end smallexample
5627 @item unused
5628 When attached to a type (including a @code{union} or a @code{struct}),
5629 this attribute means that variables of that type are meant to appear
5630 possibly unused.  GCC does not produce a warning for any variables of
5631 that type, even if the variable appears to do nothing.  This is often
5632 the case with lock or thread classes, which are usually defined and then
5633 not referenced, but contain constructors and destructors that have
5634 nontrivial bookkeeping functions.
5636 @item deprecated
5637 @itemx deprecated (@var{msg})
5638 The @code{deprecated} attribute results in a warning if the type
5639 is used anywhere in the source file.  This is useful when identifying
5640 types that are expected to be removed in a future version of a program.
5641 If possible, the warning also includes the location of the declaration
5642 of the deprecated type, to enable users to easily find further
5643 information about why the type is deprecated, or what they should do
5644 instead.  Note that the warnings only occur for uses and then only
5645 if the type is being applied to an identifier that itself is not being
5646 declared as deprecated.
5648 @smallexample
5649 typedef int T1 __attribute__ ((deprecated));
5650 T1 x;
5651 typedef T1 T2;
5652 T2 y;
5653 typedef T1 T3 __attribute__ ((deprecated));
5654 T3 z __attribute__ ((deprecated));
5655 @end smallexample
5657 @noindent
5658 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5659 warning is issued for line 4 because T2 is not explicitly
5660 deprecated.  Line 5 has no warning because T3 is explicitly
5661 deprecated.  Similarly for line 6.  The optional @var{msg}
5662 argument, which must be a string, is printed in the warning if
5663 present.
5665 The @code{deprecated} attribute can also be used for functions and
5666 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5668 @item may_alias
5669 Accesses through pointers to types with this attribute are not subject
5670 to type-based alias analysis, but are instead assumed to be able to alias
5671 any other type of objects.
5672 In the context of section 6.5 paragraph 7 of the C99 standard,
5673 an lvalue expression
5674 dereferencing such a pointer is treated like having a character type.
5675 See @option{-fstrict-aliasing} for more information on aliasing issues.
5676 This extension exists to support some vector APIs, in which pointers to
5677 one vector type are permitted to alias pointers to a different vector type.
5679 Note that an object of a type with this attribute does not have any
5680 special semantics.
5682 Example of use:
5684 @smallexample
5685 typedef short __attribute__((__may_alias__)) short_a;
5688 main (void)
5690   int a = 0x12345678;
5691   short_a *b = (short_a *) &a;
5693   b[1] = 0;
5695   if (a == 0x12345678)
5696     abort();
5698   exit(0);
5700 @end smallexample
5702 @noindent
5703 If you replaced @code{short_a} with @code{short} in the variable
5704 declaration, the above program would abort when compiled with
5705 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5706 above in recent GCC versions.
5708 @item visibility
5709 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5710 applied to class, struct, union and enum types.  Unlike other type
5711 attributes, the attribute must appear between the initial keyword and
5712 the name of the type; it cannot appear after the body of the type.
5714 Note that the type visibility is applied to vague linkage entities
5715 associated with the class (vtable, typeinfo node, etc.).  In
5716 particular, if a class is thrown as an exception in one shared object
5717 and caught in another, the class must have default visibility.
5718 Otherwise the two shared objects are unable to use the same
5719 typeinfo node and exception handling will break.
5721 @end table
5723 To specify multiple attributes, separate them by commas within the
5724 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5725 packed))}.
5727 @subsection ARM Type Attributes
5729 On those ARM targets that support @code{dllimport} (such as Symbian
5730 OS), you can use the @code{notshared} attribute to indicate that the
5731 virtual table and other similar data for a class should not be
5732 exported from a DLL@.  For example:
5734 @smallexample
5735 class __declspec(notshared) C @{
5736 public:
5737   __declspec(dllimport) C();
5738   virtual void f();
5741 __declspec(dllexport)
5742 C::C() @{@}
5743 @end smallexample
5745 @noindent
5746 In this code, @code{C::C} is exported from the current DLL, but the
5747 virtual table for @code{C} is not exported.  (You can use
5748 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5749 most Symbian OS code uses @code{__declspec}.)
5751 @anchor{MeP Type Attributes}
5752 @subsection MeP Type Attributes
5754 Many of the MeP variable attributes may be applied to types as well.
5755 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5756 @code{far} attributes may be applied to either.  The @code{io} and
5757 @code{cb} attributes may not be applied to types.
5759 @anchor{i386 Type Attributes}
5760 @subsection i386 Type Attributes
5762 Two attributes are currently defined for i386 configurations:
5763 @code{ms_struct} and @code{gcc_struct}.
5765 @table @code
5767 @item ms_struct
5768 @itemx gcc_struct
5769 @cindex @code{ms_struct}
5770 @cindex @code{gcc_struct}
5772 If @code{packed} is used on a structure, or if bit-fields are used
5773 it may be that the Microsoft ABI packs them differently
5774 than GCC normally packs them.  Particularly when moving packed
5775 data between functions compiled with GCC and the native Microsoft compiler
5776 (either via function call or as data in a file), it may be necessary to access
5777 either format.
5779 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5780 compilers to match the native Microsoft compiler.
5781 @end table
5783 @anchor{PowerPC Type Attributes}
5784 @subsection PowerPC Type Attributes
5786 Three attributes currently are defined for PowerPC configurations:
5787 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5789 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5790 attributes please see the documentation in @ref{i386 Type Attributes}.
5792 The @code{altivec} attribute allows one to declare AltiVec vector data
5793 types supported by the AltiVec Programming Interface Manual.  The
5794 attribute requires an argument to specify one of three vector types:
5795 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5796 and @code{bool__} (always followed by unsigned).
5798 @smallexample
5799 __attribute__((altivec(vector__)))
5800 __attribute__((altivec(pixel__))) unsigned short
5801 __attribute__((altivec(bool__))) unsigned
5802 @end smallexample
5804 These attributes mainly are intended to support the @code{__vector},
5805 @code{__pixel}, and @code{__bool} AltiVec keywords.
5807 @anchor{SPU Type Attributes}
5808 @subsection SPU Type Attributes
5810 The SPU supports the @code{spu_vector} attribute for types.  This attribute
5811 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5812 Language Extensions Specification.  It is intended to support the
5813 @code{__vector} keyword.
5815 @node Alignment
5816 @section Inquiring on Alignment of Types or Variables
5817 @cindex alignment
5818 @cindex type alignment
5819 @cindex variable alignment
5821 The keyword @code{__alignof__} allows you to inquire about how an object
5822 is aligned, or the minimum alignment usually required by a type.  Its
5823 syntax is just like @code{sizeof}.
5825 For example, if the target machine requires a @code{double} value to be
5826 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5827 This is true on many RISC machines.  On more traditional machine
5828 designs, @code{__alignof__ (double)} is 4 or even 2.
5830 Some machines never actually require alignment; they allow reference to any
5831 data type even at an odd address.  For these machines, @code{__alignof__}
5832 reports the smallest alignment that GCC gives the data type, usually as
5833 mandated by the target ABI.
5835 If the operand of @code{__alignof__} is an lvalue rather than a type,
5836 its value is the required alignment for its type, taking into account
5837 any minimum alignment specified with GCC's @code{__attribute__}
5838 extension (@pxref{Variable Attributes}).  For example, after this
5839 declaration:
5841 @smallexample
5842 struct foo @{ int x; char y; @} foo1;
5843 @end smallexample
5845 @noindent
5846 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5847 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5849 It is an error to ask for the alignment of an incomplete type.
5852 @node Inline
5853 @section An Inline Function is As Fast As a Macro
5854 @cindex inline functions
5855 @cindex integrating function code
5856 @cindex open coding
5857 @cindex macros, inline alternative
5859 By declaring a function inline, you can direct GCC to make
5860 calls to that function faster.  One way GCC can achieve this is to
5861 integrate that function's code into the code for its callers.  This
5862 makes execution faster by eliminating the function-call overhead; in
5863 addition, if any of the actual argument values are constant, their
5864 known values may permit simplifications at compile time so that not
5865 all of the inline function's code needs to be included.  The effect on
5866 code size is less predictable; object code may be larger or smaller
5867 with function inlining, depending on the particular case.  You can
5868 also direct GCC to try to integrate all ``simple enough'' functions
5869 into their callers with the option @option{-finline-functions}.
5871 GCC implements three different semantics of declaring a function
5872 inline.  One is available with @option{-std=gnu89} or
5873 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5874 on all inline declarations, another when
5875 @option{-std=c99}, @option{-std=c11},
5876 @option{-std=gnu99} or @option{-std=gnu11}
5877 (without @option{-fgnu89-inline}), and the third
5878 is used when compiling C++.
5880 To declare a function inline, use the @code{inline} keyword in its
5881 declaration, like this:
5883 @smallexample
5884 static inline int
5885 inc (int *a)
5887   return (*a)++;
5889 @end smallexample
5891 If you are writing a header file to be included in ISO C90 programs, write
5892 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
5894 The three types of inlining behave similarly in two important cases:
5895 when the @code{inline} keyword is used on a @code{static} function,
5896 like the example above, and when a function is first declared without
5897 using the @code{inline} keyword and then is defined with
5898 @code{inline}, like this:
5900 @smallexample
5901 extern int inc (int *a);
5902 inline int
5903 inc (int *a)
5905   return (*a)++;
5907 @end smallexample
5909 In both of these common cases, the program behaves the same as if you
5910 had not used the @code{inline} keyword, except for its speed.
5912 @cindex inline functions, omission of
5913 @opindex fkeep-inline-functions
5914 When a function is both inline and @code{static}, if all calls to the
5915 function are integrated into the caller, and the function's address is
5916 never used, then the function's own assembler code is never referenced.
5917 In this case, GCC does not actually output assembler code for the
5918 function, unless you specify the option @option{-fkeep-inline-functions}.
5919 Some calls cannot be integrated for various reasons (in particular,
5920 calls that precede the function's definition cannot be integrated, and
5921 neither can recursive calls within the definition).  If there is a
5922 nonintegrated call, then the function is compiled to assembler code as
5923 usual.  The function must also be compiled as usual if the program
5924 refers to its address, because that can't be inlined.
5926 @opindex Winline
5927 Note that certain usages in a function definition can make it unsuitable
5928 for inline substitution.  Among these usages are: variadic functions, use of
5929 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
5930 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5931 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
5932 warns when a function marked @code{inline} could not be substituted,
5933 and gives the reason for the failure.
5935 @cindex automatic @code{inline} for C++ member fns
5936 @cindex @code{inline} automatic for C++ member fns
5937 @cindex member fns, automatically @code{inline}
5938 @cindex C++ member fns, automatically @code{inline}
5939 @opindex fno-default-inline
5940 As required by ISO C++, GCC considers member functions defined within
5941 the body of a class to be marked inline even if they are
5942 not explicitly declared with the @code{inline} keyword.  You can
5943 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5944 Options,,Options Controlling C++ Dialect}.
5946 GCC does not inline any functions when not optimizing unless you specify
5947 the @samp{always_inline} attribute for the function, like this:
5949 @smallexample
5950 /* @r{Prototype.}  */
5951 inline void foo (const char) __attribute__((always_inline));
5952 @end smallexample
5954 The remainder of this section is specific to GNU C90 inlining.
5956 @cindex non-static inline function
5957 When an inline function is not @code{static}, then the compiler must assume
5958 that there may be calls from other source files; since a global symbol can
5959 be defined only once in any program, the function must not be defined in
5960 the other source files, so the calls therein cannot be integrated.
5961 Therefore, a non-@code{static} inline function is always compiled on its
5962 own in the usual fashion.
5964 If you specify both @code{inline} and @code{extern} in the function
5965 definition, then the definition is used only for inlining.  In no case
5966 is the function compiled on its own, not even if you refer to its
5967 address explicitly.  Such an address becomes an external reference, as
5968 if you had only declared the function, and had not defined it.
5970 This combination of @code{inline} and @code{extern} has almost the
5971 effect of a macro.  The way to use it is to put a function definition in
5972 a header file with these keywords, and put another copy of the
5973 definition (lacking @code{inline} and @code{extern}) in a library file.
5974 The definition in the header file causes most calls to the function
5975 to be inlined.  If any uses of the function remain, they refer to
5976 the single copy in the library.
5978 @node Volatiles
5979 @section When is a Volatile Object Accessed?
5980 @cindex accessing volatiles
5981 @cindex volatile read
5982 @cindex volatile write
5983 @cindex volatile access
5985 C has the concept of volatile objects.  These are normally accessed by
5986 pointers and used for accessing hardware or inter-thread
5987 communication.  The standard encourages compilers to refrain from
5988 optimizations concerning accesses to volatile objects, but leaves it
5989 implementation defined as to what constitutes a volatile access.  The
5990 minimum requirement is that at a sequence point all previous accesses
5991 to volatile objects have stabilized and no subsequent accesses have
5992 occurred.  Thus an implementation is free to reorder and combine
5993 volatile accesses that occur between sequence points, but cannot do
5994 so for accesses across a sequence point.  The use of volatile does
5995 not allow you to violate the restriction on updating objects multiple
5996 times between two sequence points.
5998 Accesses to non-volatile objects are not ordered with respect to
5999 volatile accesses.  You cannot use a volatile object as a memory
6000 barrier to order a sequence of writes to non-volatile memory.  For
6001 instance:
6003 @smallexample
6004 int *ptr = @var{something};
6005 volatile int vobj;
6006 *ptr = @var{something};
6007 vobj = 1;
6008 @end smallexample
6010 @noindent
6011 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6012 that the write to @var{*ptr} occurs by the time the update
6013 of @var{vobj} happens.  If you need this guarantee, you must use
6014 a stronger memory barrier such as:
6016 @smallexample
6017 int *ptr = @var{something};
6018 volatile int vobj;
6019 *ptr = @var{something};
6020 asm volatile ("" : : : "memory");
6021 vobj = 1;
6022 @end smallexample
6024 A scalar volatile object is read when it is accessed in a void context:
6026 @smallexample
6027 volatile int *src = @var{somevalue};
6028 *src;
6029 @end smallexample
6031 Such expressions are rvalues, and GCC implements this as a
6032 read of the volatile object being pointed to.
6034 Assignments are also expressions and have an rvalue.  However when
6035 assigning to a scalar volatile, the volatile object is not reread,
6036 regardless of whether the assignment expression's rvalue is used or
6037 not.  If the assignment's rvalue is used, the value is that assigned
6038 to the volatile object.  For instance, there is no read of @var{vobj}
6039 in all the following cases:
6041 @smallexample
6042 int obj;
6043 volatile int vobj;
6044 vobj = @var{something};
6045 obj = vobj = @var{something};
6046 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6047 obj = (@var{something}, vobj = @var{anotherthing});
6048 @end smallexample
6050 If you need to read the volatile object after an assignment has
6051 occurred, you must use a separate expression with an intervening
6052 sequence point.
6054 As bit-fields are not individually addressable, volatile bit-fields may
6055 be implicitly read when written to, or when adjacent bit-fields are
6056 accessed.  Bit-field operations may be optimized such that adjacent
6057 bit-fields are only partially accessed, if they straddle a storage unit
6058 boundary.  For these reasons it is unwise to use volatile bit-fields to
6059 access hardware.
6061 @node Extended Asm
6062 @section Assembler Instructions with C Expression Operands
6063 @cindex extended @code{asm}
6064 @cindex @code{asm} expressions
6065 @cindex assembler instructions
6066 @cindex registers
6068 In an assembler instruction using @code{asm}, you can specify the
6069 operands of the instruction using C expressions.  This means you need not
6070 guess which registers or memory locations contain the data you want
6071 to use.
6073 You must specify an assembler instruction template much like what
6074 appears in a machine description, plus an operand constraint string for
6075 each operand.
6077 For example, here is how to use the 68881's @code{fsinx} instruction:
6079 @smallexample
6080 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
6081 @end smallexample
6083 @noindent
6084 Here @code{angle} is the C expression for the input operand while
6085 @code{result} is that of the output operand.  Each has @samp{"f"} as its
6086 operand constraint, saying that a floating-point register is required.
6087 The @samp{=} in @samp{=f} indicates that the operand is an output; all
6088 output operands' constraints must use @samp{=}.  The constraints use the
6089 same language used in the machine description (@pxref{Constraints}).
6091 Each operand is described by an operand-constraint string followed by
6092 the C expression in parentheses.  A colon separates the assembler
6093 template from the first output operand and another separates the last
6094 output operand from the first input, if any.  Commas separate the
6095 operands within each group.  The total number of operands is currently
6096 limited to 30; this limitation may be lifted in some future version of
6097 GCC@.
6099 If there are no output operands but there are input operands, you must
6100 place two consecutive colons surrounding the place where the output
6101 operands would go.
6103 As of GCC version 3.1, it is also possible to specify input and output
6104 operands using symbolic names which can be referenced within the
6105 assembler code.  These names are specified inside square brackets
6106 preceding the constraint string, and can be referenced inside the
6107 assembler code using @code{%[@var{name}]} instead of a percentage sign
6108 followed by the operand number.  Using named operands the above example
6109 could look like:
6111 @smallexample
6112 asm ("fsinx %[angle],%[output]"
6113      : [output] "=f" (result)
6114      : [angle] "f" (angle));
6115 @end smallexample
6117 @noindent
6118 Note that the symbolic operand names have no relation whatsoever to
6119 other C identifiers.  You may use any name you like, even those of
6120 existing C symbols, but you must ensure that no two operands within the same
6121 assembler construct use the same symbolic name.
6123 Output operand expressions must be lvalues; the compiler can check this.
6124 The input operands need not be lvalues.  The compiler cannot check
6125 whether the operands have data types that are reasonable for the
6126 instruction being executed.  It does not parse the assembler instruction
6127 template and does not know what it means or even whether it is valid
6128 assembler input.  The extended @code{asm} feature is most often used for
6129 machine instructions the compiler itself does not know exist.  If
6130 the output expression cannot be directly addressed (for example, it is a
6131 bit-field), your constraint must allow a register.  In that case, GCC
6132 uses the register as the output of the @code{asm}, and then stores
6133 that register into the output.
6135 The ordinary output operands must be write-only; GCC assumes that
6136 the values in these operands before the instruction are dead and need
6137 not be generated.  Extended asm supports input-output or read-write
6138 operands.  Use the constraint character @samp{+} to indicate such an
6139 operand and list it with the output operands.
6141 You may, as an alternative, logically split its function into two
6142 separate operands, one input operand and one write-only output
6143 operand.  The connection between them is expressed by constraints
6144 that say they need to be in the same location when the instruction
6145 executes.  You can use the same C expression for both operands, or
6146 different expressions.  For example, here we write the (fictitious)
6147 @samp{combine} instruction with @code{bar} as its read-only source
6148 operand and @code{foo} as its read-write destination:
6150 @smallexample
6151 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
6152 @end smallexample
6154 @noindent
6155 The constraint @samp{"0"} for operand 1 says that it must occupy the
6156 same location as operand 0.  A number in constraint is allowed only in
6157 an input operand and it must refer to an output operand.
6159 Only a number in the constraint can guarantee that one operand is in
6160 the same place as another.  The mere fact that @code{foo} is the value
6161 of both operands is not enough to guarantee that they are in the
6162 same place in the generated assembler code.  The following does not
6163 work reliably:
6165 @smallexample
6166 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
6167 @end smallexample
6169 Various optimizations or reloading could cause operands 0 and 1 to be in
6170 different registers; GCC knows no reason not to do so.  For example, the
6171 compiler might find a copy of the value of @code{foo} in one register and
6172 use it for operand 1, but generate the output operand 0 in a different
6173 register (copying it afterward to @code{foo}'s own address).  Of course,
6174 since the register for operand 1 is not even mentioned in the assembler
6175 code, the result will not work, but GCC can't tell that.
6177 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
6178 the operand number for a matching constraint.  For example:
6180 @smallexample
6181 asm ("cmoveq %1,%2,%[result]"
6182      : [result] "=r"(result)
6183      : "r" (test), "r"(new), "[result]"(old));
6184 @end smallexample
6186 Sometimes you need to make an @code{asm} operand be a specific register,
6187 but there's no matching constraint letter for that register @emph{by
6188 itself}.  To force the operand into that register, use a local variable
6189 for the operand and specify the register in the variable declaration.
6190 @xref{Explicit Reg Vars}.  Then for the @code{asm} operand, use any
6191 register constraint letter that matches the register:
6193 @smallexample
6194 register int *p1 asm ("r0") = @dots{};
6195 register int *p2 asm ("r1") = @dots{};
6196 register int *result asm ("r0");
6197 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6198 @end smallexample
6200 @anchor{Example of asm with clobbered asm reg}
6201 In the above example, beware that a register that is call-clobbered by
6202 the target ABI will be overwritten by any function call in the
6203 assignment, including library calls for arithmetic operators.
6204 Also a register may be clobbered when generating some operations,
6205 like variable shift, memory copy or memory move on x86.
6206 Assuming it is a call-clobbered register, this may happen to @code{r0}
6207 above by the assignment to @code{p2}.  If you have to use such a
6208 register, use temporary variables for expressions between the register
6209 assignment and use:
6211 @smallexample
6212 int t1 = @dots{};
6213 register int *p1 asm ("r0") = @dots{};
6214 register int *p2 asm ("r1") = t1;
6215 register int *result asm ("r0");
6216 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6217 @end smallexample
6219 Some instructions clobber specific hard registers.  To describe this,
6220 write a third colon after the input operands, followed by the names of
6221 the clobbered hard registers (given as strings).  Here is a realistic
6222 example for the VAX:
6224 @smallexample
6225 asm volatile ("movc3 %0,%1,%2"
6226               : /* @r{no outputs} */
6227               : "g" (from), "g" (to), "g" (count)
6228               : "r0", "r1", "r2", "r3", "r4", "r5");
6229 @end smallexample
6231 You may not write a clobber description in a way that overlaps with an
6232 input or output operand.  For example, you may not have an operand
6233 describing a register class with one member if you mention that register
6234 in the clobber list.  Variables declared to live in specific registers
6235 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6236 have no part mentioned in the clobber description.
6237 There is no way for you to specify that an input
6238 operand is modified without also specifying it as an output
6239 operand.  Note that if all the output operands you specify are for this
6240 purpose (and hence unused), you then also need to specify
6241 @code{volatile} for the @code{asm} construct, as described below, to
6242 prevent GCC from deleting the @code{asm} statement as unused.
6244 If you refer to a particular hardware register from the assembler code,
6245 you probably have to list the register after the third colon to
6246 tell the compiler the register's value is modified.  In some assemblers,
6247 the register names begin with @samp{%}; to produce one @samp{%} in the
6248 assembler code, you must write @samp{%%} in the input.
6250 If your assembler instruction can alter the condition code register, add
6251 @samp{cc} to the list of clobbered registers.  GCC on some machines
6252 represents the condition codes as a specific hardware register;
6253 @samp{cc} serves to name this register.  On other machines, the
6254 condition code is handled differently, and specifying @samp{cc} has no
6255 effect.  But it is valid no matter what the machine.
6257 If your assembler instructions access memory in an unpredictable
6258 fashion, add @samp{memory} to the list of clobbered registers.  This
6259 causes GCC to not keep memory values cached in registers across the
6260 assembler instruction and not optimize stores or loads to that memory.
6261 You also should add the @code{volatile} keyword if the memory
6262 affected is not listed in the inputs or outputs of the @code{asm}, as
6263 the @samp{memory} clobber does not count as a side-effect of the
6264 @code{asm}.  If you know how large the accessed memory is, you can add
6265 it as input or output but if this is not known, you should add
6266 @samp{memory}.  As an example, if you access ten bytes of a string, you
6267 can use a memory input like:
6269 @smallexample
6270 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6271 @end smallexample
6273 Note that in the following example the memory input is necessary,
6274 otherwise GCC might optimize the store to @code{x} away:
6275 @smallexample
6276 int foo ()
6278   int x = 42;
6279   int *y = &x;
6280   int result;
6281   asm ("magic stuff accessing an 'int' pointed to by '%1'"
6282        : "=&d" (r) : "a" (y), "m" (*y));
6283   return result;
6285 @end smallexample
6287 You can put multiple assembler instructions together in a single
6288 @code{asm} template, separated by the characters normally used in assembly
6289 code for the system.  A combination that works in most places is a newline
6290 to break the line, plus a tab character to move to the instruction field
6291 (written as @samp{\n\t}).  Sometimes semicolons can be used, if the
6292 assembler allows semicolons as a line-breaking character.  Note that some
6293 assembler dialects use semicolons to start a comment.
6294 The input operands are guaranteed not to use any of the clobbered
6295 registers, and neither do the output operands' addresses, so you can
6296 read and write the clobbered registers as many times as you like.  Here
6297 is an example of multiple instructions in a template; it assumes the
6298 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6300 @smallexample
6301 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6302      : /* no outputs */
6303      : "g" (from), "g" (to)
6304      : "r9", "r10");
6305 @end smallexample
6307 Unless an output operand has the @samp{&} constraint modifier, GCC
6308 may allocate it in the same register as an unrelated input operand, on
6309 the assumption the inputs are consumed before the outputs are produced.
6310 This assumption may be false if the assembler code actually consists of
6311 more than one instruction.  In such a case, use @samp{&} for each output
6312 operand that may not overlap an input.  @xref{Modifiers}.
6314 If you want to test the condition code produced by an assembler
6315 instruction, you must include a branch and a label in the @code{asm}
6316 construct, as follows:
6318 @smallexample
6319 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6320      : "g" (result)
6321      : "g" (input));
6322 @end smallexample
6324 @noindent
6325 This assumes your assembler supports local labels, as the GNU assembler
6326 and most Unix assemblers do.
6328 Speaking of labels, jumps from one @code{asm} to another are not
6329 supported.  The compiler's optimizers do not know about these jumps, and
6330 therefore they cannot take account of them when deciding how to
6331 optimize.  @xref{Extended asm with goto}.
6333 @cindex macros containing @code{asm}
6334 Usually the most convenient way to use these @code{asm} instructions is to
6335 encapsulate them in macros that look like functions.  For example,
6337 @smallexample
6338 #define sin(x)       \
6339 (@{ double __value, __arg = (x);   \
6340    asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
6341    __value; @})
6342 @end smallexample
6344 @noindent
6345 Here the variable @code{__arg} is used to make sure that the instruction
6346 operates on a proper @code{double} value, and to accept only those
6347 arguments @code{x} that can convert automatically to a @code{double}.
6349 Another way to make sure the instruction operates on the correct data
6350 type is to use a cast in the @code{asm}.  This is different from using a
6351 variable @code{__arg} in that it converts more different types.  For
6352 example, if the desired type is @code{int}, casting the argument to
6353 @code{int} accepts a pointer with no complaint, while assigning the
6354 argument to an @code{int} variable named @code{__arg} warns about
6355 using a pointer unless the caller explicitly casts it.
6357 If an @code{asm} has output operands, GCC assumes for optimization
6358 purposes the instruction has no side effects except to change the output
6359 operands.  This does not mean instructions with a side effect cannot be
6360 used, but you must be careful, because the compiler may eliminate them
6361 if the output operands aren't used, or move them out of loops, or
6362 replace two with one if they constitute a common subexpression.  Also,
6363 if your instruction does have a side effect on a variable that otherwise
6364 appears not to change, the old value of the variable may be reused later
6365 if it happens to be found in a register.
6367 You can prevent an @code{asm} instruction from being deleted
6368 by writing the keyword @code{volatile} after
6369 the @code{asm}.  For example:
6371 @smallexample
6372 #define get_and_set_priority(new)              \
6373 (@{ int __old;                                  \
6374    asm volatile ("get_and_set_priority %0, %1" \
6375                  : "=g" (__old) : "g" (new));  \
6376    __old; @})
6377 @end smallexample
6379 @noindent
6380 The @code{volatile} keyword indicates that the instruction has
6381 important side-effects.  GCC does not delete a volatile @code{asm} if
6382 it is reachable.  (The instruction can still be deleted if GCC can
6383 prove that control flow never reaches the location of the
6384 instruction.)  Note that even a volatile @code{asm} instruction
6385 can be moved relative to other code, including across jump
6386 instructions.  For example, on many targets there is a system
6387 register that can be set to control the rounding mode of
6388 floating-point operations.  You might try
6389 setting it with a volatile @code{asm}, like this PowerPC example:
6391 @smallexample
6392        asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6393        sum = x + y;
6394 @end smallexample
6396 @noindent
6397 This does not work reliably, as the compiler may move the addition back
6398 before the volatile @code{asm}.  To make it work you need to add an
6399 artificial dependency to the @code{asm} referencing a variable in the code
6400 you don't want moved, for example:
6402 @smallexample
6403     asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6404     sum = x + y;
6405 @end smallexample
6407 Similarly, you can't expect a
6408 sequence of volatile @code{asm} instructions to remain perfectly
6409 consecutive.  If you want consecutive output, use a single @code{asm}.
6410 Also, GCC performs some optimizations across a volatile @code{asm}
6411 instruction; GCC does not ``forget everything'' when it encounters
6412 a volatile @code{asm} instruction the way some other compilers do.
6414 An @code{asm} instruction without any output operands is treated
6415 identically to a volatile @code{asm} instruction.
6417 It is a natural idea to look for a way to give access to the condition
6418 code left by the assembler instruction.  However, when we attempted to
6419 implement this, we found no way to make it work reliably.  The problem
6420 is that output operands might need reloading, which result in
6421 additional following ``store'' instructions.  On most machines, these
6422 instructions alter the condition code before there is time to
6423 test it.  This problem doesn't arise for ordinary ``test'' and
6424 ``compare'' instructions because they don't have any output operands.
6426 For reasons similar to those described above, it is not possible to give
6427 an assembler instruction access to the condition code left by previous
6428 instructions.
6430 @anchor{Extended asm with goto}
6431 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6432 jump to one or more C labels.  In this form, a fifth section after the
6433 clobber list contains a list of all C labels to which the assembly may jump.
6434 Each label operand is implicitly self-named.  The @code{asm} is also assumed
6435 to fall through to the next statement.
6437 This form of @code{asm} is restricted to not have outputs.  This is due
6438 to a internal restriction in the compiler that control transfer instructions
6439 cannot have outputs.  This restriction on @code{asm goto} may be lifted
6440 in some future version of the compiler.  In the meantime, @code{asm goto}
6441 may include a memory clobber, and so leave outputs in memory.
6443 @smallexample
6444 int frob(int x)
6446   int y;
6447   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6448             : : "r"(x), "r"(&y) : "r5", "memory" : error);
6449   return y;
6450  error:
6451   return -1;
6453 @end smallexample
6455 @noindent
6456 In this (inefficient) example, the @code{frob} instruction sets the
6457 carry bit to indicate an error.  The @code{jc} instruction detects
6458 this and branches to the @code{error} label.  Finally, the output
6459 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6460 for variable @code{y}, which is later read by the @code{return} statement.
6462 @smallexample
6463 void doit(void)
6465   int i = 0;
6466   asm goto ("mfsr %%r1, 123; jmp %%r1;"
6467             ".pushsection doit_table;"
6468             ".long %l0, %l1, %l2, %l3;"
6469             ".popsection"
6470             : : : "r1" : label1, label2, label3, label4);
6471   __builtin_unreachable ();
6473  label1:
6474   f1();
6475   return;
6476  label2:
6477   f2();
6478   return;
6479  label3:
6480   i = 1;
6481  label4:
6482   f3(i);
6484 @end smallexample
6486 @noindent
6487 In this (also inefficient) example, the @code{mfsr} instruction reads
6488 an address from some out-of-band machine register, and the following
6489 @code{jmp} instruction branches to that address.  The address read by
6490 the @code{mfsr} instruction is assumed to have been previously set via
6491 some application-specific mechanism to be one of the four values stored
6492 in the @code{doit_table} section.  Finally, the @code{asm} is followed
6493 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6494 does not in fact fall through.
6496 @smallexample
6497 #define TRACE1(NUM)                         \
6498   do @{                                      \
6499     asm goto ("0: nop;"                     \
6500               ".pushsection trace_table;"   \
6501               ".long 0b, %l0;"              \
6502               ".popsection"                 \
6503               : : : : trace#NUM);           \
6504     if (0) @{ trace#NUM: trace(); @}          \
6505   @} while (0)
6506 #define TRACE  TRACE1(__COUNTER__)
6507 @end smallexample
6509 @noindent
6510 In this example (which in fact inspired the @code{asm goto} feature)
6511 we want on rare occasions to call the @code{trace} function; on other
6512 occasions we'd like to keep the overhead to the absolute minimum.
6513 The normal code path consists of a single @code{nop} instruction.
6514 However, we record the address of this @code{nop} together with the
6515 address of a label that calls the @code{trace} function.  This allows
6516 the @code{nop} instruction to be patched at run time to be an
6517 unconditional branch to the stored label.  It is assumed that an
6518 optimizing compiler moves the labeled block out of line, to
6519 optimize the fall through path from the @code{asm}.
6521 If you are writing a header file that should be includable in ISO C
6522 programs, write @code{__asm__} instead of @code{asm}.  @xref{Alternate
6523 Keywords}.
6525 @subsection Size of an @code{asm}
6527 Some targets require that GCC track the size of each instruction used in
6528 order to generate correct code.  Because the final length of an
6529 @code{asm} is only known by the assembler, GCC must make an estimate as
6530 to how big it will be.  The estimate is formed by counting the number of
6531 statements in the pattern of the @code{asm} and multiplying that by the
6532 length of the longest instruction on that processor.  Statements in the
6533 @code{asm} are identified by newline characters and whatever statement
6534 separator characters are supported by the assembler; on most processors
6535 this is the @samp{;} character.
6537 Normally, GCC's estimate is perfectly adequate to ensure that correct
6538 code is generated, but it is possible to confuse the compiler if you use
6539 pseudo instructions or assembler macros that expand into multiple real
6540 instructions or if you use assembler directives that expand to more
6541 space in the object file than is needed for a single instruction.
6542 If this happens then the assembler produces a diagnostic saying that
6543 a label is unreachable.
6545 @subsection i386 floating-point asm operands
6547 On i386 targets, there are several rules on the usage of stack-like registers
6548 in the operands of an @code{asm}.  These rules apply only to the operands
6549 that are stack-like registers:
6551 @enumerate
6552 @item
6553 Given a set of input registers that die in an @code{asm}, it is
6554 necessary to know which are implicitly popped by the @code{asm}, and
6555 which must be explicitly popped by GCC@.
6557 An input register that is implicitly popped by the @code{asm} must be
6558 explicitly clobbered, unless it is constrained to match an
6559 output operand.
6561 @item
6562 For any input register that is implicitly popped by an @code{asm}, it is
6563 necessary to know how to adjust the stack to compensate for the pop.
6564 If any non-popped input is closer to the top of the reg-stack than
6565 the implicitly popped register, it would not be possible to know what the
6566 stack looked like---it's not clear how the rest of the stack ``slides
6567 up''.
6569 All implicitly popped input registers must be closer to the top of
6570 the reg-stack than any input that is not implicitly popped.
6572 It is possible that if an input dies in an @code{asm}, the compiler might
6573 use the input register for an output reload.  Consider this example:
6575 @smallexample
6576 asm ("foo" : "=t" (a) : "f" (b));
6577 @end smallexample
6579 @noindent
6580 This code says that input @code{b} is not popped by the @code{asm}, and that
6581 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
6582 deeper after the @code{asm} than it was before.  But, it is possible that
6583 reload may think that it can use the same register for both the input and
6584 the output.
6586 To prevent this from happening,
6587 if any input operand uses the @code{f} constraint, all output register
6588 constraints must use the @code{&} early-clobber modifier.
6590 The example above would be correctly written as:
6592 @smallexample
6593 asm ("foo" : "=&t" (a) : "f" (b));
6594 @end smallexample
6596 @item
6597 Some operands need to be in particular places on the stack.  All
6598 output operands fall in this category---GCC has no other way to
6599 know which registers the outputs appear in unless you indicate
6600 this in the constraints.
6602 Output operands must specifically indicate which register an output
6603 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
6604 constraints must select a class with a single register.
6606 @item
6607 Output operands may not be ``inserted'' between existing stack registers.
6608 Since no 387 opcode uses a read/write operand, all output operands
6609 are dead before the @code{asm}, and are pushed by the @code{asm}.
6610 It makes no sense to push anywhere but the top of the reg-stack.
6612 Output operands must start at the top of the reg-stack: output
6613 operands may not ``skip'' a register.
6615 @item
6616 Some @code{asm} statements may need extra stack space for internal
6617 calculations.  This can be guaranteed by clobbering stack registers
6618 unrelated to the inputs and outputs.
6620 @end enumerate
6622 Here are a couple of reasonable @code{asm}s to want to write.  This
6623 @code{asm}
6624 takes one input, which is internally popped, and produces two outputs.
6626 @smallexample
6627 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6628 @end smallexample
6630 @noindent
6631 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6632 and replaces them with one output.  The @code{st(1)} clobber is necessary 
6633 for the compiler to know that @code{fyl2xp1} pops both inputs.
6635 @smallexample
6636 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6637 @end smallexample
6639 @include md.texi
6641 @node Asm Labels
6642 @section Controlling Names Used in Assembler Code
6643 @cindex assembler names for identifiers
6644 @cindex names used in assembler code
6645 @cindex identifiers, names in assembler code
6647 You can specify the name to be used in the assembler code for a C
6648 function or variable by writing the @code{asm} (or @code{__asm__})
6649 keyword after the declarator as follows:
6651 @smallexample
6652 int foo asm ("myfoo") = 2;
6653 @end smallexample
6655 @noindent
6656 This specifies that the name to be used for the variable @code{foo} in
6657 the assembler code should be @samp{myfoo} rather than the usual
6658 @samp{_foo}.
6660 On systems where an underscore is normally prepended to the name of a C
6661 function or variable, this feature allows you to define names for the
6662 linker that do not start with an underscore.
6664 It does not make sense to use this feature with a non-static local
6665 variable since such variables do not have assembler names.  If you are
6666 trying to put the variable in a particular register, see @ref{Explicit
6667 Reg Vars}.  GCC presently accepts such code with a warning, but will
6668 probably be changed to issue an error, rather than a warning, in the
6669 future.
6671 You cannot use @code{asm} in this way in a function @emph{definition}; but
6672 you can get the same effect by writing a declaration for the function
6673 before its definition and putting @code{asm} there, like this:
6675 @smallexample
6676 extern func () asm ("FUNC");
6678 func (x, y)
6679      int x, y;
6680 /* @r{@dots{}} */
6681 @end smallexample
6683 It is up to you to make sure that the assembler names you choose do not
6684 conflict with any other assembler symbols.  Also, you must not use a
6685 register name; that would produce completely invalid assembler code.  GCC
6686 does not as yet have the ability to store static variables in registers.
6687 Perhaps that will be added.
6689 @node Explicit Reg Vars
6690 @section Variables in Specified Registers
6691 @cindex explicit register variables
6692 @cindex variables in specified registers
6693 @cindex specified registers
6694 @cindex registers, global allocation
6696 GNU C allows you to put a few global variables into specified hardware
6697 registers.  You can also specify the register in which an ordinary
6698 register variable should be allocated.
6700 @itemize @bullet
6701 @item
6702 Global register variables reserve registers throughout the program.
6703 This may be useful in programs such as programming language
6704 interpreters that have a couple of global variables that are accessed
6705 very often.
6707 @item
6708 Local register variables in specific registers do not reserve the
6709 registers, except at the point where they are used as input or output
6710 operands in an @code{asm} statement and the @code{asm} statement itself is
6711 not deleted.  The compiler's data flow analysis is capable of determining
6712 where the specified registers contain live values, and where they are
6713 available for other uses.  Stores into local register variables may be deleted
6714 when they appear to be dead according to dataflow analysis.  References
6715 to local register variables may be deleted or moved or simplified.
6717 These local variables are sometimes convenient for use with the extended
6718 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6719 output of the assembler instruction directly into a particular register.
6720 (This works provided the register you specify fits the constraints
6721 specified for that operand in the @code{asm}.)
6722 @end itemize
6724 @menu
6725 * Global Reg Vars::
6726 * Local Reg Vars::
6727 @end menu
6729 @node Global Reg Vars
6730 @subsection Defining Global Register Variables
6731 @cindex global register variables
6732 @cindex registers, global variables in
6734 You can define a global register variable in GNU C like this:
6736 @smallexample
6737 register int *foo asm ("a5");
6738 @end smallexample
6740 @noindent
6741 Here @code{a5} is the name of the register that should be used.  Choose a
6742 register that is normally saved and restored by function calls on your
6743 machine, so that library routines will not clobber it.
6745 Naturally the register name is cpu-dependent, so you need to
6746 conditionalize your program according to cpu type.  The register
6747 @code{a5} is a good choice on a 68000 for a variable of pointer
6748 type.  On machines with register windows, be sure to choose a ``global''
6749 register that is not affected magically by the function call mechanism.
6751 In addition, different operating systems on the same CPU may differ in how they
6752 name the registers; then you need additional conditionals.  For
6753 example, some 68000 operating systems call this register @code{%a5}.
6755 Eventually there may be a way of asking the compiler to choose a register
6756 automatically, but first we need to figure out how it should choose and
6757 how to enable you to guide the choice.  No solution is evident.
6759 Defining a global register variable in a certain register reserves that
6760 register entirely for this use, at least within the current compilation.
6761 The register is not allocated for any other purpose in the functions
6762 in the current compilation, and is not saved and restored by
6763 these functions.  Stores into this register are never deleted even if they
6764 appear to be dead, but references may be deleted or moved or
6765 simplified.
6767 It is not safe to access the global register variables from signal
6768 handlers, or from more than one thread of control, because the system
6769 library routines may temporarily use the register for other things (unless
6770 you recompile them specially for the task at hand).
6772 @cindex @code{qsort}, and global register variables
6773 It is not safe for one function that uses a global register variable to
6774 call another such function @code{foo} by way of a third function
6775 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6776 different source file in which the variable isn't declared).  This is
6777 because @code{lose} might save the register and put some other value there.
6778 For example, you can't expect a global register variable to be available in
6779 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6780 might have put something else in that register.  (If you are prepared to
6781 recompile @code{qsort} with the same global register variable, you can
6782 solve this problem.)
6784 If you want to recompile @code{qsort} or other source files that do not
6785 actually use your global register variable, so that they do not use that
6786 register for any other purpose, then it suffices to specify the compiler
6787 option @option{-ffixed-@var{reg}}.  You need not actually add a global
6788 register declaration to their source code.
6790 A function that can alter the value of a global register variable cannot
6791 safely be called from a function compiled without this variable, because it
6792 could clobber the value the caller expects to find there on return.
6793 Therefore, the function that is the entry point into the part of the
6794 program that uses the global register variable must explicitly save and
6795 restore the value that belongs to its caller.
6797 @cindex register variable after @code{longjmp}
6798 @cindex global register after @code{longjmp}
6799 @cindex value after @code{longjmp}
6800 @findex longjmp
6801 @findex setjmp
6802 On most machines, @code{longjmp} restores to each global register
6803 variable the value it had at the time of the @code{setjmp}.  On some
6804 machines, however, @code{longjmp} does not change the value of global
6805 register variables.  To be portable, the function that called @code{setjmp}
6806 should make other arrangements to save the values of the global register
6807 variables, and to restore them in a @code{longjmp}.  This way, the same
6808 thing happens regardless of what @code{longjmp} does.
6810 All global register variable declarations must precede all function
6811 definitions.  If such a declaration could appear after function
6812 definitions, the declaration would be too late to prevent the register from
6813 being used for other purposes in the preceding functions.
6815 Global register variables may not have initial values, because an
6816 executable file has no means to supply initial contents for a register.
6818 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6819 registers, but certain library functions, such as @code{getwd}, as well
6820 as the subroutines for division and remainder, modify g3 and g4.  g1 and
6821 g2 are local temporaries.
6823 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6824 Of course, it does not do to use more than a few of those.
6826 @node Local Reg Vars
6827 @subsection Specifying Registers for Local Variables
6828 @cindex local variables, specifying registers
6829 @cindex specifying registers for local variables
6830 @cindex registers for local variables
6832 You can define a local register variable with a specified register
6833 like this:
6835 @smallexample
6836 register int *foo asm ("a5");
6837 @end smallexample
6839 @noindent
6840 Here @code{a5} is the name of the register that should be used.  Note
6841 that this is the same syntax used for defining global register
6842 variables, but for a local variable it appears within a function.
6844 Naturally the register name is cpu-dependent, but this is not a
6845 problem, since specific registers are most often useful with explicit
6846 assembler instructions (@pxref{Extended Asm}).  Both of these things
6847 generally require that you conditionalize your program according to
6848 cpu type.
6850 In addition, operating systems on one type of cpu may differ in how they
6851 name the registers; then you need additional conditionals.  For
6852 example, some 68000 operating systems call this register @code{%a5}.
6854 Defining such a register variable does not reserve the register; it
6855 remains available for other uses in places where flow control determines
6856 the variable's value is not live.
6858 This option does not guarantee that GCC generates code that has
6859 this variable in the register you specify at all times.  You may not
6860 code an explicit reference to this register in the @emph{assembler
6861 instruction template} part of an @code{asm} statement and assume it
6862 always refers to this variable.  However, using the variable as an
6863 @code{asm} @emph{operand} guarantees that the specified register is used
6864 for the operand.
6866 Stores into local register variables may be deleted when they appear to be dead
6867 according to dataflow analysis.  References to local register variables may
6868 be deleted or moved or simplified.
6870 As for global register variables, it's recommended that you choose a
6871 register that is normally saved and restored by function calls on
6872 your machine, so that library routines will not clobber it.  A common
6873 pitfall is to initialize multiple call-clobbered registers with
6874 arbitrary expressions, where a function call or library call for an
6875 arithmetic operator overwrites a register value from a previous
6876 assignment, for example @code{r0} below:
6877 @smallexample
6878 register int *p1 asm ("r0") = @dots{};
6879 register int *p2 asm ("r1") = @dots{};
6880 @end smallexample
6882 @noindent
6883 In those cases, a solution is to use a temporary variable for
6884 each arbitrary expression.   @xref{Example of asm with clobbered asm reg}.
6886 @node Alternate Keywords
6887 @section Alternate Keywords
6888 @cindex alternate keywords
6889 @cindex keywords, alternate
6891 @option{-ansi} and the various @option{-std} options disable certain
6892 keywords.  This causes trouble when you want to use GNU C extensions, or
6893 a general-purpose header file that should be usable by all programs,
6894 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
6895 @code{inline} are not available in programs compiled with
6896 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6897 program compiled with @option{-std=c99} or @option{-std=c11}).  The
6898 ISO C99 keyword
6899 @code{restrict} is only available when @option{-std=gnu99} (which will
6900 eventually be the default) or @option{-std=c99} (or the equivalent
6901 @option{-std=iso9899:1999}), or an option for a later standard
6902 version, is used.
6904 The way to solve these problems is to put @samp{__} at the beginning and
6905 end of each problematical keyword.  For example, use @code{__asm__}
6906 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6908 Other C compilers won't accept these alternative keywords; if you want to
6909 compile with another compiler, you can define the alternate keywords as
6910 macros to replace them with the customary keywords.  It looks like this:
6912 @smallexample
6913 #ifndef __GNUC__
6914 #define __asm__ asm
6915 #endif
6916 @end smallexample
6918 @findex __extension__
6919 @opindex pedantic
6920 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6921 You can
6922 prevent such warnings within one expression by writing
6923 @code{__extension__} before the expression.  @code{__extension__} has no
6924 effect aside from this.
6926 @node Incomplete Enums
6927 @section Incomplete @code{enum} Types
6929 You can define an @code{enum} tag without specifying its possible values.
6930 This results in an incomplete type, much like what you get if you write
6931 @code{struct foo} without describing the elements.  A later declaration
6932 that does specify the possible values completes the type.
6934 You can't allocate variables or storage using the type while it is
6935 incomplete.  However, you can work with pointers to that type.
6937 This extension may not be very useful, but it makes the handling of
6938 @code{enum} more consistent with the way @code{struct} and @code{union}
6939 are handled.
6941 This extension is not supported by GNU C++.
6943 @node Function Names
6944 @section Function Names as Strings
6945 @cindex @code{__func__} identifier
6946 @cindex @code{__FUNCTION__} identifier
6947 @cindex @code{__PRETTY_FUNCTION__} identifier
6949 GCC provides three magic variables that hold the name of the current
6950 function, as a string.  The first of these is @code{__func__}, which
6951 is part of the C99 standard:
6953 The identifier @code{__func__} is implicitly declared by the translator
6954 as if, immediately following the opening brace of each function
6955 definition, the declaration
6957 @smallexample
6958 static const char __func__[] = "function-name";
6959 @end smallexample
6961 @noindent
6962 appeared, where function-name is the name of the lexically-enclosing
6963 function.  This name is the unadorned name of the function.
6965 @code{__FUNCTION__} is another name for @code{__func__}.  Older
6966 versions of GCC recognize only this name.  However, it is not
6967 standardized.  For maximum portability, we recommend you use
6968 @code{__func__}, but provide a fallback definition with the
6969 preprocessor:
6971 @smallexample
6972 #if __STDC_VERSION__ < 199901L
6973 # if __GNUC__ >= 2
6974 #  define __func__ __FUNCTION__
6975 # else
6976 #  define __func__ "<unknown>"
6977 # endif
6978 #endif
6979 @end smallexample
6981 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6982 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
6983 the type signature of the function as well as its bare name.  For
6984 example, this program:
6986 @smallexample
6987 extern "C" @{
6988 extern int printf (char *, ...);
6991 class a @{
6992  public:
6993   void sub (int i)
6994     @{
6995       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6996       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6997     @}
7001 main (void)
7003   a ax;
7004   ax.sub (0);
7005   return 0;
7007 @end smallexample
7009 @noindent
7010 gives this output:
7012 @smallexample
7013 __FUNCTION__ = sub
7014 __PRETTY_FUNCTION__ = void a::sub(int)
7015 @end smallexample
7017 These identifiers are not preprocessor macros.  In GCC 3.3 and
7018 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7019 were treated as string literals; they could be used to initialize
7020 @code{char} arrays, and they could be concatenated with other string
7021 literals.  GCC 3.4 and later treat them as variables, like
7022 @code{__func__}.  In C++, @code{__FUNCTION__} and
7023 @code{__PRETTY_FUNCTION__} have always been variables.
7025 @node Return Address
7026 @section Getting the Return or Frame Address of a Function
7028 These functions may be used to get information about the callers of a
7029 function.
7031 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7032 This function returns the return address of the current function, or of
7033 one of its callers.  The @var{level} argument is number of frames to
7034 scan up the call stack.  A value of @code{0} yields the return address
7035 of the current function, a value of @code{1} yields the return address
7036 of the caller of the current function, and so forth.  When inlining
7037 the expected behavior is that the function returns the address of
7038 the function that is returned to.  To work around this behavior use
7039 the @code{noinline} function attribute.
7041 The @var{level} argument must be a constant integer.
7043 On some machines it may be impossible to determine the return address of
7044 any function other than the current one; in such cases, or when the top
7045 of the stack has been reached, this function returns @code{0} or a
7046 random value.  In addition, @code{__builtin_frame_address} may be used
7047 to determine if the top of the stack has been reached.
7049 Additional post-processing of the returned value may be needed, see
7050 @code{__builtin_extract_return_addr}.
7052 This function should only be used with a nonzero argument for debugging
7053 purposes.
7054 @end deftypefn
7056 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7057 The address as returned by @code{__builtin_return_address} may have to be fed
7058 through this function to get the actual encoded address.  For example, on the
7059 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7060 platforms an offset has to be added for the true next instruction to be
7061 executed.
7063 If no fixup is needed, this function simply passes through @var{addr}.
7064 @end deftypefn
7066 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7067 This function does the reverse of @code{__builtin_extract_return_addr}.
7068 @end deftypefn
7070 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7071 This function is similar to @code{__builtin_return_address}, but it
7072 returns the address of the function frame rather than the return address
7073 of the function.  Calling @code{__builtin_frame_address} with a value of
7074 @code{0} yields the frame address of the current function, a value of
7075 @code{1} yields the frame address of the caller of the current function,
7076 and so forth.
7078 The frame is the area on the stack that holds local variables and saved
7079 registers.  The frame address is normally the address of the first word
7080 pushed on to the stack by the function.  However, the exact definition
7081 depends upon the processor and the calling convention.  If the processor
7082 has a dedicated frame pointer register, and the function has a frame,
7083 then @code{__builtin_frame_address} returns the value of the frame
7084 pointer register.
7086 On some machines it may be impossible to determine the frame address of
7087 any function other than the current one; in such cases, or when the top
7088 of the stack has been reached, this function returns @code{0} if
7089 the first frame pointer is properly initialized by the startup code.
7091 This function should only be used with a nonzero argument for debugging
7092 purposes.
7093 @end deftypefn
7095 @node Vector Extensions
7096 @section Using Vector Instructions through Built-in Functions
7098 On some targets, the instruction set contains SIMD vector instructions which
7099 operate on multiple values contained in one large register at the same time.
7100 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
7101 this way.
7103 The first step in using these extensions is to provide the necessary data
7104 types.  This should be done using an appropriate @code{typedef}:
7106 @smallexample
7107 typedef int v4si __attribute__ ((vector_size (16)));
7108 @end smallexample
7110 @noindent
7111 The @code{int} type specifies the base type, while the attribute specifies
7112 the vector size for the variable, measured in bytes.  For example, the
7113 declaration above causes the compiler to set the mode for the @code{v4si}
7114 type to be 16 bytes wide and divided into @code{int} sized units.  For
7115 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7116 corresponding mode of @code{foo} is @acronym{V4SI}.
7118 The @code{vector_size} attribute is only applicable to integral and
7119 float scalars, although arrays, pointers, and function return values
7120 are allowed in conjunction with this construct. Only sizes that are
7121 a power of two are currently allowed.
7123 All the basic integer types can be used as base types, both as signed
7124 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7125 @code{long long}.  In addition, @code{float} and @code{double} can be
7126 used to build floating-point vector types.
7128 Specifying a combination that is not valid for the current architecture
7129 causes GCC to synthesize the instructions using a narrower mode.
7130 For example, if you specify a variable of type @code{V4SI} and your
7131 architecture does not allow for this specific SIMD type, GCC
7132 produces code that uses 4 @code{SIs}.
7134 The types defined in this manner can be used with a subset of normal C
7135 operations.  Currently, GCC allows using the following operators
7136 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7138 The operations behave like C++ @code{valarrays}.  Addition is defined as
7139 the addition of the corresponding elements of the operands.  For
7140 example, in the code below, each of the 4 elements in @var{a} is
7141 added to the corresponding 4 elements in @var{b} and the resulting
7142 vector is stored in @var{c}.
7144 @smallexample
7145 typedef int v4si __attribute__ ((vector_size (16)));
7147 v4si a, b, c;
7149 c = a + b;
7150 @end smallexample
7152 Subtraction, multiplication, division, and the logical operations
7153 operate in a similar manner.  Likewise, the result of using the unary
7154 minus or complement operators on a vector type is a vector whose
7155 elements are the negative or complemented values of the corresponding
7156 elements in the operand.
7158 It is possible to use shifting operators @code{<<}, @code{>>} on
7159 integer-type vectors. The operation is defined as following: @code{@{a0,
7160 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7161 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7162 elements. 
7164 For convenience, it is allowed to use a binary vector operation
7165 where one operand is a scalar. In that case the compiler transforms
7166 the scalar operand into a vector where each element is the scalar from
7167 the operation. The transformation happens only if the scalar could be
7168 safely converted to the vector-element type.
7169 Consider the following code.
7171 @smallexample
7172 typedef int v4si __attribute__ ((vector_size (16)));
7174 v4si a, b, c;
7175 long l;
7177 a = b + 1;    /* a = b + @{1,1,1,1@}; */
7178 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
7180 a = l + a;    /* Error, cannot convert long to int. */
7181 @end smallexample
7183 Vectors can be subscripted as if the vector were an array with
7184 the same number of elements and base type.  Out of bound accesses
7185 invoke undefined behavior at run time.  Warnings for out of bound
7186 accesses for vector subscription can be enabled with
7187 @option{-Warray-bounds}.
7189 Vector comparison is supported with standard comparison
7190 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7191 vector expressions of integer-type or real-type. Comparison between
7192 integer-type vectors and real-type vectors are not supported.  The
7193 result of the comparison is a vector of the same width and number of
7194 elements as the comparison operands with a signed integral element
7195 type.
7197 Vectors are compared element-wise producing 0 when comparison is false
7198 and -1 (constant of the appropriate type where all bits are set)
7199 otherwise. Consider the following example.
7201 @smallexample
7202 typedef int v4si __attribute__ ((vector_size (16)));
7204 v4si a = @{1,2,3,4@};
7205 v4si b = @{3,2,1,4@};
7206 v4si c;
7208 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
7209 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
7210 @end smallexample
7212 Vector shuffling is available using functions
7213 @code{__builtin_shuffle (vec, mask)} and
7214 @code{__builtin_shuffle (vec0, vec1, mask)}.
7215 Both functions construct a permutation of elements from one or two
7216 vectors and return a vector of the same type as the input vector(s).
7217 The @var{mask} is an integral vector with the same width (@var{W})
7218 and element count (@var{N}) as the output vector.
7220 The elements of the input vectors are numbered in memory ordering of
7221 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
7222 elements of @var{mask} are considered modulo @var{N} in the single-operand
7223 case and modulo @math{2*@var{N}} in the two-operand case.
7225 Consider the following example,
7227 @smallexample
7228 typedef int v4si __attribute__ ((vector_size (16)));
7230 v4si a = @{1,2,3,4@};
7231 v4si b = @{5,6,7,8@};
7232 v4si mask1 = @{0,1,1,3@};
7233 v4si mask2 = @{0,4,2,5@};
7234 v4si res;
7236 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
7237 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
7238 @end smallexample
7240 Note that @code{__builtin_shuffle} is intentionally semantically
7241 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7243 You can declare variables and use them in function calls and returns, as
7244 well as in assignments and some casts.  You can specify a vector type as
7245 a return type for a function.  Vector types can also be used as function
7246 arguments.  It is possible to cast from one vector type to another,
7247 provided they are of the same size (in fact, you can also cast vectors
7248 to and from other datatypes of the same size).
7250 You cannot operate between vectors of different lengths or different
7251 signedness without a cast.
7253 @node Offsetof
7254 @section Offsetof
7255 @findex __builtin_offsetof
7257 GCC implements for both C and C++ a syntactic extension to implement
7258 the @code{offsetof} macro.
7260 @smallexample
7261 primary:
7262         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7264 offsetof_member_designator:
7265           @code{identifier}
7266         | offsetof_member_designator "." @code{identifier}
7267         | offsetof_member_designator "[" @code{expr} "]"
7268 @end smallexample
7270 This extension is sufficient such that
7272 @smallexample
7273 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
7274 @end smallexample
7276 @noindent
7277 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
7278 may be dependent.  In either case, @var{member} may consist of a single
7279 identifier, or a sequence of member accesses and array references.
7281 @node __sync Builtins
7282 @section Legacy __sync Built-in Functions for Atomic Memory Access
7284 The following built-in functions
7285 are intended to be compatible with those described
7286 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7287 section 7.4.  As such, they depart from the normal GCC practice of using
7288 the @samp{__builtin_} prefix, and further that they are overloaded such that
7289 they work on multiple types.
7291 The definition given in the Intel documentation allows only for the use of
7292 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7293 counterparts.  GCC allows any integral scalar or pointer type that is
7294 1, 2, 4 or 8 bytes in length.
7296 Not all operations are supported by all target processors.  If a particular
7297 operation cannot be implemented on the target processor, a warning is
7298 generated and a call an external function is generated.  The external
7299 function carries the same name as the built-in version,
7300 with an additional suffix
7301 @samp{_@var{n}} where @var{n} is the size of the data type.
7303 @c ??? Should we have a mechanism to suppress this warning?  This is almost
7304 @c useful for implementing the operation under the control of an external
7305 @c mutex.
7307 In most cases, these built-in functions are considered a @dfn{full barrier}.
7308 That is,
7309 no memory operand is moved across the operation, either forward or
7310 backward.  Further, instructions are issued as necessary to prevent the
7311 processor from speculating loads across the operation and from queuing stores
7312 after the operation.
7314 All of the routines are described in the Intel documentation to take
7315 ``an optional list of variables protected by the memory barrier''.  It's
7316 not clear what is meant by that; it could mean that @emph{only} the
7317 following variables are protected, or it could mean that these variables
7318 should in addition be protected.  At present GCC ignores this list and
7319 protects all variables that are globally accessible.  If in the future
7320 we make some use of this list, an empty list will continue to mean all
7321 globally accessible variables.
7323 @table @code
7324 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7325 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7326 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7327 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7328 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7329 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7330 @findex __sync_fetch_and_add
7331 @findex __sync_fetch_and_sub
7332 @findex __sync_fetch_and_or
7333 @findex __sync_fetch_and_and
7334 @findex __sync_fetch_and_xor
7335 @findex __sync_fetch_and_nand
7336 These built-in functions perform the operation suggested by the name, and
7337 returns the value that had previously been in memory.  That is,
7339 @smallexample
7340 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7341 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
7342 @end smallexample
7344 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7345 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7347 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7348 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7349 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7350 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7351 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7352 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7353 @findex __sync_add_and_fetch
7354 @findex __sync_sub_and_fetch
7355 @findex __sync_or_and_fetch
7356 @findex __sync_and_and_fetch
7357 @findex __sync_xor_and_fetch
7358 @findex __sync_nand_and_fetch
7359 These built-in functions perform the operation suggested by the name, and
7360 return the new value.  That is,
7362 @smallexample
7363 @{ *ptr @var{op}= value; return *ptr; @}
7364 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
7365 @end smallexample
7367 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7368 as @code{*ptr = ~(*ptr & value)} instead of
7369 @code{*ptr = ~*ptr & value}.
7371 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7372 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7373 @findex __sync_bool_compare_and_swap
7374 @findex __sync_val_compare_and_swap
7375 These built-in functions perform an atomic compare and swap.
7376 That is, if the current
7377 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7378 @code{*@var{ptr}}.
7380 The ``bool'' version returns true if the comparison is successful and
7381 @var{newval} is written.  The ``val'' version returns the contents
7382 of @code{*@var{ptr}} before the operation.
7384 @item __sync_synchronize (...)
7385 @findex __sync_synchronize
7386 This built-in function issues a full memory barrier.
7388 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7389 @findex __sync_lock_test_and_set
7390 This built-in function, as described by Intel, is not a traditional test-and-set
7391 operation, but rather an atomic exchange operation.  It writes @var{value}
7392 into @code{*@var{ptr}}, and returns the previous contents of
7393 @code{*@var{ptr}}.
7395 Many targets have only minimal support for such locks, and do not support
7396 a full exchange operation.  In this case, a target may support reduced
7397 functionality here by which the @emph{only} valid value to store is the
7398 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
7399 is implementation defined.
7401 This built-in function is not a full barrier,
7402 but rather an @dfn{acquire barrier}.
7403 This means that references after the operation cannot move to (or be
7404 speculated to) before the operation, but previous memory stores may not
7405 be globally visible yet, and previous memory loads may not yet be
7406 satisfied.
7408 @item void __sync_lock_release (@var{type} *ptr, ...)
7409 @findex __sync_lock_release
7410 This built-in function releases the lock acquired by
7411 @code{__sync_lock_test_and_set}.
7412 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7414 This built-in function is not a full barrier,
7415 but rather a @dfn{release barrier}.
7416 This means that all previous memory stores are globally visible, and all
7417 previous memory loads have been satisfied, but following memory reads
7418 are not prevented from being speculated to before the barrier.
7419 @end table
7421 @node __atomic Builtins
7422 @section Built-in functions for memory model aware atomic operations
7424 The following built-in functions approximately match the requirements for
7425 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7426 functions, but all also have a memory model parameter.  These are all
7427 identified by being prefixed with @samp{__atomic}, and most are overloaded
7428 such that they work with multiple types.
7430 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7431 bytes in length. 16-byte integral types are also allowed if
7432 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7434 Target architectures are encouraged to provide their own patterns for
7435 each of these built-in functions.  If no target is provided, the original 
7436 non-memory model set of @samp{__sync} atomic built-in functions are
7437 utilized, along with any required synchronization fences surrounding it in
7438 order to achieve the proper behavior.  Execution in this case is subject
7439 to the same restrictions as those built-in functions.
7441 If there is no pattern or mechanism to provide a lock free instruction
7442 sequence, a call is made to an external routine with the same parameters
7443 to be resolved at run time.
7445 The four non-arithmetic functions (load, store, exchange, and 
7446 compare_exchange) all have a generic version as well.  This generic
7447 version works on any data type.  If the data type size maps to one
7448 of the integral sizes that may have lock free support, the generic
7449 version utilizes the lock free built-in function.  Otherwise an
7450 external call is left to be resolved at run time.  This external call is
7451 the same format with the addition of a @samp{size_t} parameter inserted
7452 as the first parameter indicating the size of the object being pointed to.
7453 All objects must be the same size.
7455 There are 6 different memory models that can be specified.  These map
7456 to the same names in the C++11 standard.  Refer there or to the
7457 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7458 atomic synchronization} for more detailed definitions.  These memory
7459 models integrate both barriers to code motion as well as synchronization
7460 requirements with other threads. These are listed in approximately
7461 ascending order of strength. It is also possible to use target specific
7462 flags for memory model flags, like Hardware Lock Elision.
7464 @table  @code
7465 @item __ATOMIC_RELAXED
7466 No barriers or synchronization.
7467 @item __ATOMIC_CONSUME
7468 Data dependency only for both barrier and synchronization with another
7469 thread.
7470 @item __ATOMIC_ACQUIRE
7471 Barrier to hoisting of code and synchronizes with release (or stronger)
7472 semantic stores from another thread.
7473 @item __ATOMIC_RELEASE
7474 Barrier to sinking of code and synchronizes with acquire (or stronger)
7475 semantic loads from another thread.
7476 @item __ATOMIC_ACQ_REL
7477 Full barrier in both directions and synchronizes with acquire loads and
7478 release stores in another thread.
7479 @item __ATOMIC_SEQ_CST
7480 Full barrier in both directions and synchronizes with acquire loads and
7481 release stores in all threads.
7482 @end table
7484 When implementing patterns for these built-in functions, the memory model
7485 parameter can be ignored as long as the pattern implements the most
7486 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
7487 execute correctly with this memory model but they may not execute as
7488 efficiently as they could with a more appropriate implementation of the
7489 relaxed requirements.
7491 Note that the C++11 standard allows for the memory model parameter to be
7492 determined at run time rather than at compile time.  These built-in
7493 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7494 than invoke a runtime library call or inline a switch statement.  This is
7495 standard compliant, safe, and the simplest approach for now.
7497 The memory model parameter is a signed int, but only the lower 8 bits are
7498 reserved for the memory model.  The remainder of the signed int is reserved
7499 for future use and should be 0.  Use of the predefined atomic values
7500 ensures proper usage.
7502 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7503 This built-in function implements an atomic load operation.  It returns the
7504 contents of @code{*@var{ptr}}.
7506 The valid memory model variants are
7507 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7508 and @code{__ATOMIC_CONSUME}.
7510 @end deftypefn
7512 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7513 This is the generic version of an atomic load.  It returns the
7514 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7516 @end deftypefn
7518 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7519 This built-in function implements an atomic store operation.  It writes 
7520 @code{@var{val}} into @code{*@var{ptr}}.  
7522 The valid memory model variants are
7523 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7525 @end deftypefn
7527 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7528 This is the generic version of an atomic store.  It stores the value
7529 of @code{*@var{val}} into @code{*@var{ptr}}.
7531 @end deftypefn
7533 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7534 This built-in function implements an atomic exchange operation.  It writes
7535 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7536 @code{*@var{ptr}}.
7538 The valid memory model variants are
7539 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7540 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7542 @end deftypefn
7544 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7545 This is the generic version of an atomic exchange.  It stores the
7546 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7547 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7549 @end deftypefn
7551 @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)
7552 This built-in function implements an atomic compare and exchange operation.
7553 This compares the contents of @code{*@var{ptr}} with the contents of
7554 @code{*@var{expected}} and if equal, writes @var{desired} into
7555 @code{*@var{ptr}}.  If they are not equal, the current contents of
7556 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
7557 for weak compare_exchange, and false for the strong variation.  Many targets 
7558 only offer the strong variation and ignore the parameter.  When in doubt, use
7559 the strong variation.
7561 True is returned if @var{desired} is written into
7562 @code{*@var{ptr}} and the execution is considered to conform to the
7563 memory model specified by @var{success_memmodel}.  There are no
7564 restrictions on what memory model can be used here.
7566 False is returned otherwise, and the execution is considered to conform
7567 to @var{failure_memmodel}. This memory model cannot be
7568 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
7569 stronger model than that specified by @var{success_memmodel}.
7571 @end deftypefn
7573 @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)
7574 This built-in function implements the generic version of
7575 @code{__atomic_compare_exchange}.  The function is virtually identical to
7576 @code{__atomic_compare_exchange_n}, except the desired value is also a
7577 pointer.
7579 @end deftypefn
7581 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7582 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7583 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7584 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7585 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7586 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7587 These built-in functions perform the operation suggested by the name, and
7588 return the result of the operation. That is,
7590 @smallexample
7591 @{ *ptr @var{op}= val; return *ptr; @}
7592 @end smallexample
7594 All memory models are valid.
7596 @end deftypefn
7598 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7599 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7600 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7601 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7602 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7603 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7604 These built-in functions perform the operation suggested by the name, and
7605 return the value that had previously been in @code{*@var{ptr}}.  That is,
7607 @smallexample
7608 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7609 @end smallexample
7611 All memory models are valid.
7613 @end deftypefn
7615 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7617 This built-in function performs an atomic test-and-set operation on
7618 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
7619 defined nonzero ``set'' value and the return value is @code{true} if and only
7620 if the previous contents were ``set''.
7621 It should be only used for operands of type @code{bool} or @code{char}. For 
7622 other types only part of the value may be set.
7624 All memory models are valid.
7626 @end deftypefn
7628 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7630 This built-in function performs an atomic clear operation on
7631 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
7632 It should be only used for operands of type @code{bool} or @code{char} and 
7633 in conjunction with @code{__atomic_test_and_set}.
7634 For other types it may only clear partially. If the type is not @code{bool}
7635 prefer using @code{__atomic_store}.
7637 The valid memory model variants are
7638 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7639 @code{__ATOMIC_RELEASE}.
7641 @end deftypefn
7643 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7645 This built-in function acts as a synchronization fence between threads
7646 based on the specified memory model.
7648 All memory orders are valid.
7650 @end deftypefn
7652 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7654 This built-in function acts as a synchronization fence between a thread
7655 and signal handlers based in the same thread.
7657 All memory orders are valid.
7659 @end deftypefn
7661 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
7663 This built-in function returns true if objects of @var{size} bytes always
7664 generate lock free atomic instructions for the target architecture.  
7665 @var{size} must resolve to a compile-time constant and the result also
7666 resolves to a compile-time constant.
7668 @var{ptr} is an optional pointer to the object that may be used to determine
7669 alignment.  A value of 0 indicates typical alignment should be used.  The 
7670 compiler may also ignore this parameter.
7672 @smallexample
7673 if (_atomic_always_lock_free (sizeof (long long), 0))
7674 @end smallexample
7676 @end deftypefn
7678 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7680 This built-in function returns true if objects of @var{size} bytes always
7681 generate lock free atomic instructions for the target architecture.  If
7682 it is not known to be lock free a call is made to a runtime routine named
7683 @code{__atomic_is_lock_free}.
7685 @var{ptr} is an optional pointer to the object that may be used to determine
7686 alignment.  A value of 0 indicates typical alignment should be used.  The 
7687 compiler may also ignore this parameter.
7688 @end deftypefn
7690 @node x86 specific memory model extensions for transactional memory
7691 @section x86 specific memory model extensions for transactional memory
7693 The i386 architecture supports additional memory ordering flags
7694 to mark lock critical sections for hardware lock elision. 
7695 These must be specified in addition to an existing memory model to 
7696 atomic intrinsics.
7698 @table @code
7699 @item __ATOMIC_HLE_ACQUIRE
7700 Start lock elision on a lock variable.
7701 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
7702 @item __ATOMIC_HLE_RELEASE
7703 End lock elision on a lock variable.
7704 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
7705 @end table
7707 When a lock acquire fails it is required for good performance to abort
7708 the transaction quickly. This can be done with a @code{_mm_pause}
7710 @smallexample
7711 #include <immintrin.h> // For _mm_pause
7713 int lockvar;
7715 /* Acquire lock with lock elision */
7716 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
7717     _mm_pause(); /* Abort failed transaction */
7719 /* Free lock with lock elision */
7720 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
7721 @end smallexample
7723 @node Object Size Checking
7724 @section Object Size Checking Built-in Functions
7725 @findex __builtin_object_size
7726 @findex __builtin___memcpy_chk
7727 @findex __builtin___mempcpy_chk
7728 @findex __builtin___memmove_chk
7729 @findex __builtin___memset_chk
7730 @findex __builtin___strcpy_chk
7731 @findex __builtin___stpcpy_chk
7732 @findex __builtin___strncpy_chk
7733 @findex __builtin___strcat_chk
7734 @findex __builtin___strncat_chk
7735 @findex __builtin___sprintf_chk
7736 @findex __builtin___snprintf_chk
7737 @findex __builtin___vsprintf_chk
7738 @findex __builtin___vsnprintf_chk
7739 @findex __builtin___printf_chk
7740 @findex __builtin___vprintf_chk
7741 @findex __builtin___fprintf_chk
7742 @findex __builtin___vfprintf_chk
7744 GCC implements a limited buffer overflow protection mechanism
7745 that can prevent some buffer overflow attacks.
7747 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7748 is a built-in construct that returns a constant number of bytes from
7749 @var{ptr} to the end of the object @var{ptr} pointer points to
7750 (if known at compile time).  @code{__builtin_object_size} never evaluates
7751 its arguments for side-effects.  If there are any side-effects in them, it
7752 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7753 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
7754 point to and all of them are known at compile time, the returned number
7755 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7756 0 and minimum if nonzero.  If it is not possible to determine which objects
7757 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7758 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7759 for @var{type} 2 or 3.
7761 @var{type} is an integer constant from 0 to 3.  If the least significant
7762 bit is clear, objects are whole variables, if it is set, a closest
7763 surrounding subobject is considered the object a pointer points to.
7764 The second bit determines if maximum or minimum of remaining bytes
7765 is computed.
7767 @smallexample
7768 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7769 char *p = &var.buf1[1], *q = &var.b;
7771 /* Here the object p points to is var.  */
7772 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7773 /* The subobject p points to is var.buf1.  */
7774 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7775 /* The object q points to is var.  */
7776 assert (__builtin_object_size (q, 0)
7777         == (char *) (&var + 1) - (char *) &var.b);
7778 /* The subobject q points to is var.b.  */
7779 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7780 @end smallexample
7781 @end deftypefn
7783 There are built-in functions added for many common string operation
7784 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7785 built-in is provided.  This built-in has an additional last argument,
7786 which is the number of bytes remaining in object the @var{dest}
7787 argument points to or @code{(size_t) -1} if the size is not known.
7789 The built-in functions are optimized into the normal string functions
7790 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7791 it is known at compile time that the destination object will not
7792 be overflown.  If the compiler can determine at compile time the
7793 object will be always overflown, it issues a warning.
7795 The intended use can be e.g.@:
7797 @smallexample
7798 #undef memcpy
7799 #define bos0(dest) __builtin_object_size (dest, 0)
7800 #define memcpy(dest, src, n) \
7801   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7803 char *volatile p;
7804 char buf[10];
7805 /* It is unknown what object p points to, so this is optimized
7806    into plain memcpy - no checking is possible.  */
7807 memcpy (p, "abcde", n);
7808 /* Destination is known and length too.  It is known at compile
7809    time there will be no overflow.  */
7810 memcpy (&buf[5], "abcde", 5);
7811 /* Destination is known, but the length is not known at compile time.
7812    This will result in __memcpy_chk call that can check for overflow
7813    at run time.  */
7814 memcpy (&buf[5], "abcde", n);
7815 /* Destination is known and it is known at compile time there will
7816    be overflow.  There will be a warning and __memcpy_chk call that
7817    will abort the program at run time.  */
7818 memcpy (&buf[6], "abcde", 5);
7819 @end smallexample
7821 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7822 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7823 @code{strcat} and @code{strncat}.
7825 There are also checking built-in functions for formatted output functions.
7826 @smallexample
7827 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7828 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7829                               const char *fmt, ...);
7830 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7831                               va_list ap);
7832 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7833                                const char *fmt, va_list ap);
7834 @end smallexample
7836 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7837 etc.@: functions and can contain implementation specific flags on what
7838 additional security measures the checking function might take, such as
7839 handling @code{%n} differently.
7841 The @var{os} argument is the object size @var{s} points to, like in the
7842 other built-in functions.  There is a small difference in the behavior
7843 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7844 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7845 the checking function is called with @var{os} argument set to
7846 @code{(size_t) -1}.
7848 In addition to this, there are checking built-in functions
7849 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7850 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7851 These have just one additional argument, @var{flag}, right before
7852 format string @var{fmt}.  If the compiler is able to optimize them to
7853 @code{fputc} etc.@: functions, it does, otherwise the checking function
7854 is called and the @var{flag} argument passed to it.
7856 @node Cilk Plus Builtins
7857 @section Cilk Plus C/C++ language extension Built-in Functions.
7859 GCC provides support for the following built-in reduction funtions if Cilk Plus
7860 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
7862 @itemize @bullet
7863 @item __sec_implicit_index
7864 @item __sec_reduce
7865 @item __sec_reduce_add
7866 @item __sec_reduce_all_nonzero
7867 @item __sec_reduce_all_zero
7868 @item __sec_reduce_any_nonzero
7869 @item __sec_reduce_any_zero
7870 @item __sec_reduce_max
7871 @item __sec_reduce_min
7872 @item __sec_reduce_max_ind
7873 @item __sec_reduce_min_ind
7874 @item __sec_reduce_mul
7875 @item __sec_reduce_mutating
7876 @end itemize
7878 Further details and examples about these built-in functions are described 
7879 in the Cilk Plus language manual which can be found at 
7880 @uref{http://www.cilkplus.org}.
7882 @node Other Builtins
7883 @section Other Built-in Functions Provided by GCC
7884 @cindex built-in functions
7885 @findex __builtin_fpclassify
7886 @findex __builtin_isfinite
7887 @findex __builtin_isnormal
7888 @findex __builtin_isgreater
7889 @findex __builtin_isgreaterequal
7890 @findex __builtin_isinf_sign
7891 @findex __builtin_isless
7892 @findex __builtin_islessequal
7893 @findex __builtin_islessgreater
7894 @findex __builtin_isunordered
7895 @findex __builtin_powi
7896 @findex __builtin_powif
7897 @findex __builtin_powil
7898 @findex _Exit
7899 @findex _exit
7900 @findex abort
7901 @findex abs
7902 @findex acos
7903 @findex acosf
7904 @findex acosh
7905 @findex acoshf
7906 @findex acoshl
7907 @findex acosl
7908 @findex alloca
7909 @findex asin
7910 @findex asinf
7911 @findex asinh
7912 @findex asinhf
7913 @findex asinhl
7914 @findex asinl
7915 @findex atan
7916 @findex atan2
7917 @findex atan2f
7918 @findex atan2l
7919 @findex atanf
7920 @findex atanh
7921 @findex atanhf
7922 @findex atanhl
7923 @findex atanl
7924 @findex bcmp
7925 @findex bzero
7926 @findex cabs
7927 @findex cabsf
7928 @findex cabsl
7929 @findex cacos
7930 @findex cacosf
7931 @findex cacosh
7932 @findex cacoshf
7933 @findex cacoshl
7934 @findex cacosl
7935 @findex calloc
7936 @findex carg
7937 @findex cargf
7938 @findex cargl
7939 @findex casin
7940 @findex casinf
7941 @findex casinh
7942 @findex casinhf
7943 @findex casinhl
7944 @findex casinl
7945 @findex catan
7946 @findex catanf
7947 @findex catanh
7948 @findex catanhf
7949 @findex catanhl
7950 @findex catanl
7951 @findex cbrt
7952 @findex cbrtf
7953 @findex cbrtl
7954 @findex ccos
7955 @findex ccosf
7956 @findex ccosh
7957 @findex ccoshf
7958 @findex ccoshl
7959 @findex ccosl
7960 @findex ceil
7961 @findex ceilf
7962 @findex ceill
7963 @findex cexp
7964 @findex cexpf
7965 @findex cexpl
7966 @findex cimag
7967 @findex cimagf
7968 @findex cimagl
7969 @findex clog
7970 @findex clogf
7971 @findex clogl
7972 @findex conj
7973 @findex conjf
7974 @findex conjl
7975 @findex copysign
7976 @findex copysignf
7977 @findex copysignl
7978 @findex cos
7979 @findex cosf
7980 @findex cosh
7981 @findex coshf
7982 @findex coshl
7983 @findex cosl
7984 @findex cpow
7985 @findex cpowf
7986 @findex cpowl
7987 @findex cproj
7988 @findex cprojf
7989 @findex cprojl
7990 @findex creal
7991 @findex crealf
7992 @findex creall
7993 @findex csin
7994 @findex csinf
7995 @findex csinh
7996 @findex csinhf
7997 @findex csinhl
7998 @findex csinl
7999 @findex csqrt
8000 @findex csqrtf
8001 @findex csqrtl
8002 @findex ctan
8003 @findex ctanf
8004 @findex ctanh
8005 @findex ctanhf
8006 @findex ctanhl
8007 @findex ctanl
8008 @findex dcgettext
8009 @findex dgettext
8010 @findex drem
8011 @findex dremf
8012 @findex dreml
8013 @findex erf
8014 @findex erfc
8015 @findex erfcf
8016 @findex erfcl
8017 @findex erff
8018 @findex erfl
8019 @findex exit
8020 @findex exp
8021 @findex exp10
8022 @findex exp10f
8023 @findex exp10l
8024 @findex exp2
8025 @findex exp2f
8026 @findex exp2l
8027 @findex expf
8028 @findex expl
8029 @findex expm1
8030 @findex expm1f
8031 @findex expm1l
8032 @findex fabs
8033 @findex fabsf
8034 @findex fabsl
8035 @findex fdim
8036 @findex fdimf
8037 @findex fdiml
8038 @findex ffs
8039 @findex floor
8040 @findex floorf
8041 @findex floorl
8042 @findex fma
8043 @findex fmaf
8044 @findex fmal
8045 @findex fmax
8046 @findex fmaxf
8047 @findex fmaxl
8048 @findex fmin
8049 @findex fminf
8050 @findex fminl
8051 @findex fmod
8052 @findex fmodf
8053 @findex fmodl
8054 @findex fprintf
8055 @findex fprintf_unlocked
8056 @findex fputs
8057 @findex fputs_unlocked
8058 @findex frexp
8059 @findex frexpf
8060 @findex frexpl
8061 @findex fscanf
8062 @findex gamma
8063 @findex gammaf
8064 @findex gammal
8065 @findex gamma_r
8066 @findex gammaf_r
8067 @findex gammal_r
8068 @findex gettext
8069 @findex hypot
8070 @findex hypotf
8071 @findex hypotl
8072 @findex ilogb
8073 @findex ilogbf
8074 @findex ilogbl
8075 @findex imaxabs
8076 @findex index
8077 @findex isalnum
8078 @findex isalpha
8079 @findex isascii
8080 @findex isblank
8081 @findex iscntrl
8082 @findex isdigit
8083 @findex isgraph
8084 @findex islower
8085 @findex isprint
8086 @findex ispunct
8087 @findex isspace
8088 @findex isupper
8089 @findex iswalnum
8090 @findex iswalpha
8091 @findex iswblank
8092 @findex iswcntrl
8093 @findex iswdigit
8094 @findex iswgraph
8095 @findex iswlower
8096 @findex iswprint
8097 @findex iswpunct
8098 @findex iswspace
8099 @findex iswupper
8100 @findex iswxdigit
8101 @findex isxdigit
8102 @findex j0
8103 @findex j0f
8104 @findex j0l
8105 @findex j1
8106 @findex j1f
8107 @findex j1l
8108 @findex jn
8109 @findex jnf
8110 @findex jnl
8111 @findex labs
8112 @findex ldexp
8113 @findex ldexpf
8114 @findex ldexpl
8115 @findex lgamma
8116 @findex lgammaf
8117 @findex lgammal
8118 @findex lgamma_r
8119 @findex lgammaf_r
8120 @findex lgammal_r
8121 @findex llabs
8122 @findex llrint
8123 @findex llrintf
8124 @findex llrintl
8125 @findex llround
8126 @findex llroundf
8127 @findex llroundl
8128 @findex log
8129 @findex log10
8130 @findex log10f
8131 @findex log10l
8132 @findex log1p
8133 @findex log1pf
8134 @findex log1pl
8135 @findex log2
8136 @findex log2f
8137 @findex log2l
8138 @findex logb
8139 @findex logbf
8140 @findex logbl
8141 @findex logf
8142 @findex logl
8143 @findex lrint
8144 @findex lrintf
8145 @findex lrintl
8146 @findex lround
8147 @findex lroundf
8148 @findex lroundl
8149 @findex malloc
8150 @findex memchr
8151 @findex memcmp
8152 @findex memcpy
8153 @findex mempcpy
8154 @findex memset
8155 @findex modf
8156 @findex modff
8157 @findex modfl
8158 @findex nearbyint
8159 @findex nearbyintf
8160 @findex nearbyintl
8161 @findex nextafter
8162 @findex nextafterf
8163 @findex nextafterl
8164 @findex nexttoward
8165 @findex nexttowardf
8166 @findex nexttowardl
8167 @findex pow
8168 @findex pow10
8169 @findex pow10f
8170 @findex pow10l
8171 @findex powf
8172 @findex powl
8173 @findex printf
8174 @findex printf_unlocked
8175 @findex putchar
8176 @findex puts
8177 @findex remainder
8178 @findex remainderf
8179 @findex remainderl
8180 @findex remquo
8181 @findex remquof
8182 @findex remquol
8183 @findex rindex
8184 @findex rint
8185 @findex rintf
8186 @findex rintl
8187 @findex round
8188 @findex roundf
8189 @findex roundl
8190 @findex scalb
8191 @findex scalbf
8192 @findex scalbl
8193 @findex scalbln
8194 @findex scalblnf
8195 @findex scalblnf
8196 @findex scalbn
8197 @findex scalbnf
8198 @findex scanfnl
8199 @findex signbit
8200 @findex signbitf
8201 @findex signbitl
8202 @findex signbitd32
8203 @findex signbitd64
8204 @findex signbitd128
8205 @findex significand
8206 @findex significandf
8207 @findex significandl
8208 @findex sin
8209 @findex sincos
8210 @findex sincosf
8211 @findex sincosl
8212 @findex sinf
8213 @findex sinh
8214 @findex sinhf
8215 @findex sinhl
8216 @findex sinl
8217 @findex snprintf
8218 @findex sprintf
8219 @findex sqrt
8220 @findex sqrtf
8221 @findex sqrtl
8222 @findex sscanf
8223 @findex stpcpy
8224 @findex stpncpy
8225 @findex strcasecmp
8226 @findex strcat
8227 @findex strchr
8228 @findex strcmp
8229 @findex strcpy
8230 @findex strcspn
8231 @findex strdup
8232 @findex strfmon
8233 @findex strftime
8234 @findex strlen
8235 @findex strncasecmp
8236 @findex strncat
8237 @findex strncmp
8238 @findex strncpy
8239 @findex strndup
8240 @findex strpbrk
8241 @findex strrchr
8242 @findex strspn
8243 @findex strstr
8244 @findex tan
8245 @findex tanf
8246 @findex tanh
8247 @findex tanhf
8248 @findex tanhl
8249 @findex tanl
8250 @findex tgamma
8251 @findex tgammaf
8252 @findex tgammal
8253 @findex toascii
8254 @findex tolower
8255 @findex toupper
8256 @findex towlower
8257 @findex towupper
8258 @findex trunc
8259 @findex truncf
8260 @findex truncl
8261 @findex vfprintf
8262 @findex vfscanf
8263 @findex vprintf
8264 @findex vscanf
8265 @findex vsnprintf
8266 @findex vsprintf
8267 @findex vsscanf
8268 @findex y0
8269 @findex y0f
8270 @findex y0l
8271 @findex y1
8272 @findex y1f
8273 @findex y1l
8274 @findex yn
8275 @findex ynf
8276 @findex ynl
8278 GCC provides a large number of built-in functions other than the ones
8279 mentioned above.  Some of these are for internal use in the processing
8280 of exceptions or variable-length argument lists and are not
8281 documented here because they may change from time to time; we do not
8282 recommend general use of these functions.
8284 The remaining functions are provided for optimization purposes.
8286 @opindex fno-builtin
8287 GCC includes built-in versions of many of the functions in the standard
8288 C library.  The versions prefixed with @code{__builtin_} are always
8289 treated as having the same meaning as the C library function even if you
8290 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
8291 Many of these functions are only optimized in certain cases; if they are
8292 not optimized in a particular case, a call to the library function is
8293 emitted.
8295 @opindex ansi
8296 @opindex std
8297 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8298 @option{-std=c99} or @option{-std=c11}), the functions
8299 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8300 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8301 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8302 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8303 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8304 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8305 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8306 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8307 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8308 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8309 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8310 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8311 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8312 @code{significandl}, @code{significand}, @code{sincosf},
8313 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8314 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8315 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8316 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8317 @code{yn}
8318 may be handled as built-in functions.
8319 All these functions have corresponding versions
8320 prefixed with @code{__builtin_}, which may be used even in strict C90
8321 mode.
8323 The ISO C99 functions
8324 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8325 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8326 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8327 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8328 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8329 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8330 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8331 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8332 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8333 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8334 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8335 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8336 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8337 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8338 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8339 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8340 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8341 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8342 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8343 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8344 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8345 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8346 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8347 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8348 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8349 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8350 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8351 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8352 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8353 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8354 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8355 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8356 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8357 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8358 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8359 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8360 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8361 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8362 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8363 are handled as built-in functions
8364 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8366 There are also built-in versions of the ISO C99 functions
8367 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8368 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8369 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8370 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8371 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8372 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8373 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8374 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8375 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8376 that are recognized in any mode since ISO C90 reserves these names for
8377 the purpose to which ISO C99 puts them.  All these functions have
8378 corresponding versions prefixed with @code{__builtin_}.
8380 The ISO C94 functions
8381 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8382 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8383 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8384 @code{towupper}
8385 are handled as built-in functions
8386 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8388 The ISO C90 functions
8389 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8390 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8391 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8392 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8393 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8394 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8395 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8396 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8397 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8398 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8399 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8400 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8401 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8402 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8403 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8404 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8405 are all recognized as built-in functions unless
8406 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8407 is specified for an individual function).  All of these functions have
8408 corresponding versions prefixed with @code{__builtin_}.
8410 GCC provides built-in versions of the ISO C99 floating-point comparison
8411 macros that avoid raising exceptions for unordered operands.  They have
8412 the same names as the standard macros ( @code{isgreater},
8413 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8414 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8415 prefixed.  We intend for a library implementor to be able to simply
8416 @code{#define} each standard macro to its built-in equivalent.
8417 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8418 @code{isinf_sign} and @code{isnormal} built-ins used with
8419 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
8420 built-in functions appear both with and without the @code{__builtin_} prefix.
8422 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8424 You can use the built-in function @code{__builtin_types_compatible_p} to
8425 determine whether two types are the same.
8427 This built-in function returns 1 if the unqualified versions of the
8428 types @var{type1} and @var{type2} (which are types, not expressions) are
8429 compatible, 0 otherwise.  The result of this built-in function can be
8430 used in integer constant expressions.
8432 This built-in function ignores top level qualifiers (e.g., @code{const},
8433 @code{volatile}).  For example, @code{int} is equivalent to @code{const
8434 int}.
8436 The type @code{int[]} and @code{int[5]} are compatible.  On the other
8437 hand, @code{int} and @code{char *} are not compatible, even if the size
8438 of their types, on the particular architecture are the same.  Also, the
8439 amount of pointer indirection is taken into account when determining
8440 similarity.  Consequently, @code{short *} is not similar to
8441 @code{short **}.  Furthermore, two types that are typedefed are
8442 considered compatible if their underlying types are compatible.
8444 An @code{enum} type is not considered to be compatible with another
8445 @code{enum} type even if both are compatible with the same integer
8446 type; this is what the C standard specifies.
8447 For example, @code{enum @{foo, bar@}} is not similar to
8448 @code{enum @{hot, dog@}}.
8450 You typically use this function in code whose execution varies
8451 depending on the arguments' types.  For example:
8453 @smallexample
8454 #define foo(x)                                                  \
8455   (@{                                                           \
8456     typeof (x) tmp = (x);                                       \
8457     if (__builtin_types_compatible_p (typeof (x), long double)) \
8458       tmp = foo_long_double (tmp);                              \
8459     else if (__builtin_types_compatible_p (typeof (x), double)) \
8460       tmp = foo_double (tmp);                                   \
8461     else if (__builtin_types_compatible_p (typeof (x), float))  \
8462       tmp = foo_float (tmp);                                    \
8463     else                                                        \
8464       abort ();                                                 \
8465     tmp;                                                        \
8466   @})
8467 @end smallexample
8469 @emph{Note:} This construct is only available for C@.
8471 @end deftypefn
8473 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8475 You can use the built-in function @code{__builtin_choose_expr} to
8476 evaluate code depending on the value of a constant expression.  This
8477 built-in function returns @var{exp1} if @var{const_exp}, which is an
8478 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
8480 This built-in function is analogous to the @samp{? :} operator in C,
8481 except that the expression returned has its type unaltered by promotion
8482 rules.  Also, the built-in function does not evaluate the expression
8483 that is not chosen.  For example, if @var{const_exp} evaluates to true,
8484 @var{exp2} is not evaluated even if it has side-effects.
8486 This built-in function can return an lvalue if the chosen argument is an
8487 lvalue.
8489 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8490 type.  Similarly, if @var{exp2} is returned, its return type is the same
8491 as @var{exp2}.
8493 Example:
8495 @smallexample
8496 #define foo(x)                                                    \
8497   __builtin_choose_expr (                                         \
8498     __builtin_types_compatible_p (typeof (x), double),            \
8499     foo_double (x),                                               \
8500     __builtin_choose_expr (                                       \
8501       __builtin_types_compatible_p (typeof (x), float),           \
8502       foo_float (x),                                              \
8503       /* @r{The void expression results in a compile-time error}  \
8504          @r{when assigning the result to something.}  */          \
8505       (void)0))
8506 @end smallexample
8508 @emph{Note:} This construct is only available for C@.  Furthermore, the
8509 unused expression (@var{exp1} or @var{exp2} depending on the value of
8510 @var{const_exp}) may still generate syntax errors.  This may change in
8511 future revisions.
8513 @end deftypefn
8515 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8517 The built-in function @code{__builtin_complex} is provided for use in
8518 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8519 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
8520 real binary floating-point type, and the result has the corresponding
8521 complex type with real and imaginary parts @var{real} and @var{imag}.
8522 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8523 infinities, NaNs and negative zeros are involved.
8525 @end deftypefn
8527 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8528 You can use the built-in function @code{__builtin_constant_p} to
8529 determine if a value is known to be constant at compile time and hence
8530 that GCC can perform constant-folding on expressions involving that
8531 value.  The argument of the function is the value to test.  The function
8532 returns the integer 1 if the argument is known to be a compile-time
8533 constant and 0 if it is not known to be a compile-time constant.  A
8534 return of 0 does not indicate that the value is @emph{not} a constant,
8535 but merely that GCC cannot prove it is a constant with the specified
8536 value of the @option{-O} option.
8538 You typically use this function in an embedded application where
8539 memory is a critical resource.  If you have some complex calculation,
8540 you may want it to be folded if it involves constants, but need to call
8541 a function if it does not.  For example:
8543 @smallexample
8544 #define Scale_Value(X)      \
8545   (__builtin_constant_p (X) \
8546   ? ((X) * SCALE + OFFSET) : Scale (X))
8547 @end smallexample
8549 You may use this built-in function in either a macro or an inline
8550 function.  However, if you use it in an inlined function and pass an
8551 argument of the function as the argument to the built-in, GCC 
8552 never returns 1 when you call the inline function with a string constant
8553 or compound literal (@pxref{Compound Literals}) and does not return 1
8554 when you pass a constant numeric value to the inline function unless you
8555 specify the @option{-O} option.
8557 You may also use @code{__builtin_constant_p} in initializers for static
8558 data.  For instance, you can write
8560 @smallexample
8561 static const int table[] = @{
8562    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8563    /* @r{@dots{}} */
8565 @end smallexample
8567 @noindent
8568 This is an acceptable initializer even if @var{EXPRESSION} is not a
8569 constant expression, including the case where
8570 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8571 folded to a constant but @var{EXPRESSION} contains operands that are
8572 not otherwise permitted in a static initializer (for example,
8573 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
8574 built-in in this case, because it has no opportunity to perform
8575 optimization.
8577 Previous versions of GCC did not accept this built-in in data
8578 initializers.  The earliest version where it is completely safe is
8579 3.0.1.
8580 @end deftypefn
8582 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8583 @opindex fprofile-arcs
8584 You may use @code{__builtin_expect} to provide the compiler with
8585 branch prediction information.  In general, you should prefer to
8586 use actual profile feedback for this (@option{-fprofile-arcs}), as
8587 programmers are notoriously bad at predicting how their programs
8588 actually perform.  However, there are applications in which this
8589 data is hard to collect.
8591 The return value is the value of @var{exp}, which should be an integral
8592 expression.  The semantics of the built-in are that it is expected that
8593 @var{exp} == @var{c}.  For example:
8595 @smallexample
8596 if (__builtin_expect (x, 0))
8597   foo ();
8598 @end smallexample
8600 @noindent
8601 indicates that we do not expect to call @code{foo}, since
8602 we expect @code{x} to be zero.  Since you are limited to integral
8603 expressions for @var{exp}, you should use constructions such as
8605 @smallexample
8606 if (__builtin_expect (ptr != NULL, 1))
8607   foo (*ptr);
8608 @end smallexample
8610 @noindent
8611 when testing pointer or floating-point values.
8612 @end deftypefn
8614 @deftypefn {Built-in Function} void __builtin_trap (void)
8615 This function causes the program to exit abnormally.  GCC implements
8616 this function by using a target-dependent mechanism (such as
8617 intentionally executing an illegal instruction) or by calling
8618 @code{abort}.  The mechanism used may vary from release to release so
8619 you should not rely on any particular implementation.
8620 @end deftypefn
8622 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8623 If control flow reaches the point of the @code{__builtin_unreachable},
8624 the program is undefined.  It is useful in situations where the
8625 compiler cannot deduce the unreachability of the code.
8627 One such case is immediately following an @code{asm} statement that
8628 either never terminates, or one that transfers control elsewhere
8629 and never returns.  In this example, without the
8630 @code{__builtin_unreachable}, GCC issues a warning that control
8631 reaches the end of a non-void function.  It also generates code
8632 to return after the @code{asm}.
8634 @smallexample
8635 int f (int c, int v)
8637   if (c)
8638     @{
8639       return v;
8640     @}
8641   else
8642     @{
8643       asm("jmp error_handler");
8644       __builtin_unreachable ();
8645     @}
8647 @end smallexample
8649 @noindent
8650 Because the @code{asm} statement unconditionally transfers control out
8651 of the function, control never reaches the end of the function
8652 body.  The @code{__builtin_unreachable} is in fact unreachable and
8653 communicates this fact to the compiler.
8655 Another use for @code{__builtin_unreachable} is following a call a
8656 function that never returns but that is not declared
8657 @code{__attribute__((noreturn))}, as in this example:
8659 @smallexample
8660 void function_that_never_returns (void);
8662 int g (int c)
8664   if (c)
8665     @{
8666       return 1;
8667     @}
8668   else
8669     @{
8670       function_that_never_returns ();
8671       __builtin_unreachable ();
8672     @}
8674 @end smallexample
8676 @end deftypefn
8678 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8679 This function returns its first argument, and allows the compiler
8680 to assume that the returned pointer is at least @var{align} bytes
8681 aligned.  This built-in can have either two or three arguments,
8682 if it has three, the third argument should have integer type, and
8683 if it is nonzero means misalignment offset.  For example:
8685 @smallexample
8686 void *x = __builtin_assume_aligned (arg, 16);
8687 @end smallexample
8689 @noindent
8690 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8691 16-byte aligned, while:
8693 @smallexample
8694 void *x = __builtin_assume_aligned (arg, 32, 8);
8695 @end smallexample
8697 @noindent
8698 means that the compiler can assume for @code{x}, set to @code{arg}, that
8699 @code{(char *) x - 8} is 32-byte aligned.
8700 @end deftypefn
8702 @deftypefn {Built-in Function} int __builtin_LINE ()
8703 This function is the equivalent to the preprocessor @code{__LINE__}
8704 macro and returns the line number of the invocation of the built-in.
8705 @end deftypefn
8707 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8708 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8709 macro and returns the function name the invocation of the built-in is in.
8710 @end deftypefn
8712 @deftypefn {Built-in Function} int __builtin_FILE ()
8713 This function is the equivalent to the preprocessor @code{__FILE__}
8714 macro and returns the file name the invocation of the built-in is in.
8715 @end deftypefn
8717 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8718 This function is used to flush the processor's instruction cache for
8719 the region of memory between @var{begin} inclusive and @var{end}
8720 exclusive.  Some targets require that the instruction cache be
8721 flushed, after modifying memory containing code, in order to obtain
8722 deterministic behavior.
8724 If the target does not require instruction cache flushes,
8725 @code{__builtin___clear_cache} has no effect.  Otherwise either
8726 instructions are emitted in-line to clear the instruction cache or a
8727 call to the @code{__clear_cache} function in libgcc is made.
8728 @end deftypefn
8730 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8731 This function is used to minimize cache-miss latency by moving data into
8732 a cache before it is accessed.
8733 You can insert calls to @code{__builtin_prefetch} into code for which
8734 you know addresses of data in memory that is likely to be accessed soon.
8735 If the target supports them, data prefetch instructions are generated.
8736 If the prefetch is done early enough before the access then the data will
8737 be in the cache by the time it is accessed.
8739 The value of @var{addr} is the address of the memory to prefetch.
8740 There are two optional arguments, @var{rw} and @var{locality}.
8741 The value of @var{rw} is a compile-time constant one or zero; one
8742 means that the prefetch is preparing for a write to the memory address
8743 and zero, the default, means that the prefetch is preparing for a read.
8744 The value @var{locality} must be a compile-time constant integer between
8745 zero and three.  A value of zero means that the data has no temporal
8746 locality, so it need not be left in the cache after the access.  A value
8747 of three means that the data has a high degree of temporal locality and
8748 should be left in all levels of cache possible.  Values of one and two
8749 mean, respectively, a low or moderate degree of temporal locality.  The
8750 default is three.
8752 @smallexample
8753 for (i = 0; i < n; i++)
8754   @{
8755     a[i] = a[i] + b[i];
8756     __builtin_prefetch (&a[i+j], 1, 1);
8757     __builtin_prefetch (&b[i+j], 0, 1);
8758     /* @r{@dots{}} */
8759   @}
8760 @end smallexample
8762 Data prefetch does not generate faults if @var{addr} is invalid, but
8763 the address expression itself must be valid.  For example, a prefetch
8764 of @code{p->next} does not fault if @code{p->next} is not a valid
8765 address, but evaluation faults if @code{p} is not a valid address.
8767 If the target does not support data prefetch, the address expression
8768 is evaluated if it includes side effects but no other code is generated
8769 and GCC does not issue a warning.
8770 @end deftypefn
8772 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8773 Returns a positive infinity, if supported by the floating-point format,
8774 else @code{DBL_MAX}.  This function is suitable for implementing the
8775 ISO C macro @code{HUGE_VAL}.
8776 @end deftypefn
8778 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8779 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8780 @end deftypefn
8782 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8783 Similar to @code{__builtin_huge_val}, except the return
8784 type is @code{long double}.
8785 @end deftypefn
8787 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8788 This built-in implements the C99 fpclassify functionality.  The first
8789 five int arguments should be the target library's notion of the
8790 possible FP classes and are used for return values.  They must be
8791 constant values and they must appear in this order: @code{FP_NAN},
8792 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8793 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
8794 to classify.  GCC treats the last argument as type-generic, which
8795 means it does not do default promotion from float to double.
8796 @end deftypefn
8798 @deftypefn {Built-in Function} double __builtin_inf (void)
8799 Similar to @code{__builtin_huge_val}, except a warning is generated
8800 if the target floating-point format does not support infinities.
8801 @end deftypefn
8803 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8804 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8805 @end deftypefn
8807 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8808 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8809 @end deftypefn
8811 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8812 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8813 @end deftypefn
8815 @deftypefn {Built-in Function} float __builtin_inff (void)
8816 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8817 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8818 @end deftypefn
8820 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8821 Similar to @code{__builtin_inf}, except the return
8822 type is @code{long double}.
8823 @end deftypefn
8825 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8826 Similar to @code{isinf}, except the return value is -1 for
8827 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
8828 Note while the parameter list is an
8829 ellipsis, this function only accepts exactly one floating-point
8830 argument.  GCC treats this parameter as type-generic, which means it
8831 does not do default promotion from float to double.
8832 @end deftypefn
8834 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8835 This is an implementation of the ISO C99 function @code{nan}.
8837 Since ISO C99 defines this function in terms of @code{strtod}, which we
8838 do not implement, a description of the parsing is in order.  The string
8839 is parsed as by @code{strtol}; that is, the base is recognized by
8840 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
8841 in the significand such that the least significant bit of the number
8842 is at the least significant bit of the significand.  The number is
8843 truncated to fit the significand field provided.  The significand is
8844 forced to be a quiet NaN@.
8846 This function, if given a string literal all of which would have been
8847 consumed by @code{strtol}, is evaluated early enough that it is considered a
8848 compile-time constant.
8849 @end deftypefn
8851 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8852 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8853 @end deftypefn
8855 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8856 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8857 @end deftypefn
8859 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8860 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8861 @end deftypefn
8863 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8864 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8865 @end deftypefn
8867 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8868 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8869 @end deftypefn
8871 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8872 Similar to @code{__builtin_nan}, except the significand is forced
8873 to be a signaling NaN@.  The @code{nans} function is proposed by
8874 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8875 @end deftypefn
8877 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8878 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8879 @end deftypefn
8881 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8882 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8883 @end deftypefn
8885 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8886 Returns one plus the index of the least significant 1-bit of @var{x}, or
8887 if @var{x} is zero, returns zero.
8888 @end deftypefn
8890 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8891 Returns the number of leading 0-bits in @var{x}, starting at the most
8892 significant bit position.  If @var{x} is 0, the result is undefined.
8893 @end deftypefn
8895 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8896 Returns the number of trailing 0-bits in @var{x}, starting at the least
8897 significant bit position.  If @var{x} is 0, the result is undefined.
8898 @end deftypefn
8900 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8901 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
8902 number of bits following the most significant bit that are identical
8903 to it.  There are no special cases for 0 or other values. 
8904 @end deftypefn
8906 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8907 Returns the number of 1-bits in @var{x}.
8908 @end deftypefn
8910 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8911 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8912 modulo 2.
8913 @end deftypefn
8915 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8916 Similar to @code{__builtin_ffs}, except the argument type is
8917 @code{unsigned long}.
8918 @end deftypefn
8920 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8921 Similar to @code{__builtin_clz}, except the argument type is
8922 @code{unsigned long}.
8923 @end deftypefn
8925 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8926 Similar to @code{__builtin_ctz}, except the argument type is
8927 @code{unsigned long}.
8928 @end deftypefn
8930 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8931 Similar to @code{__builtin_clrsb}, except the argument type is
8932 @code{long}.
8933 @end deftypefn
8935 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8936 Similar to @code{__builtin_popcount}, except the argument type is
8937 @code{unsigned long}.
8938 @end deftypefn
8940 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8941 Similar to @code{__builtin_parity}, except the argument type is
8942 @code{unsigned long}.
8943 @end deftypefn
8945 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8946 Similar to @code{__builtin_ffs}, except the argument type is
8947 @code{unsigned long long}.
8948 @end deftypefn
8950 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8951 Similar to @code{__builtin_clz}, except the argument type is
8952 @code{unsigned long long}.
8953 @end deftypefn
8955 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8956 Similar to @code{__builtin_ctz}, except the argument type is
8957 @code{unsigned long long}.
8958 @end deftypefn
8960 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8961 Similar to @code{__builtin_clrsb}, except the argument type is
8962 @code{long long}.
8963 @end deftypefn
8965 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8966 Similar to @code{__builtin_popcount}, except the argument type is
8967 @code{unsigned long long}.
8968 @end deftypefn
8970 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8971 Similar to @code{__builtin_parity}, except the argument type is
8972 @code{unsigned long long}.
8973 @end deftypefn
8975 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8976 Returns the first argument raised to the power of the second.  Unlike the
8977 @code{pow} function no guarantees about precision and rounding are made.
8978 @end deftypefn
8980 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8981 Similar to @code{__builtin_powi}, except the argument and return types
8982 are @code{float}.
8983 @end deftypefn
8985 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8986 Similar to @code{__builtin_powi}, except the argument and return types
8987 are @code{long double}.
8988 @end deftypefn
8990 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8991 Returns @var{x} with the order of the bytes reversed; for example,
8992 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
8993 exactly 8 bits.
8994 @end deftypefn
8996 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8997 Similar to @code{__builtin_bswap16}, except the argument and return types
8998 are 32 bit.
8999 @end deftypefn
9001 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
9002 Similar to @code{__builtin_bswap32}, except the argument and return types
9003 are 64 bit.
9004 @end deftypefn
9006 @node Target Builtins
9007 @section Built-in Functions Specific to Particular Target Machines
9009 On some target machines, GCC supports many built-in functions specific
9010 to those machines.  Generally these generate calls to specific machine
9011 instructions, but allow the compiler to schedule those calls.
9013 @menu
9014 * Alpha Built-in Functions::
9015 * ARC Built-in Functions::
9016 * ARC SIMD Built-in Functions::
9017 * ARM iWMMXt Built-in Functions::
9018 * ARM NEON Intrinsics::
9019 * AVR Built-in Functions::
9020 * Blackfin Built-in Functions::
9021 * FR-V Built-in Functions::
9022 * X86 Built-in Functions::
9023 * X86 transactional memory intrinsics::
9024 * MIPS DSP Built-in Functions::
9025 * MIPS Paired-Single Support::
9026 * MIPS Loongson Built-in Functions::
9027 * Other MIPS Built-in Functions::
9028 * MSP430 Built-in Functions::
9029 * NDS32 Built-in Functions::
9030 * picoChip Built-in Functions::
9031 * PowerPC Built-in Functions::
9032 * PowerPC AltiVec/VSX Built-in Functions::
9033 * PowerPC Hardware Transactional Memory Built-in Functions::
9034 * RX Built-in Functions::
9035 * S/390 System z Built-in Functions::
9036 * SH Built-in Functions::
9037 * SPARC VIS Built-in Functions::
9038 * SPU Built-in Functions::
9039 * TI C6X Built-in Functions::
9040 * TILE-Gx Built-in Functions::
9041 * TILEPro Built-in Functions::
9042 @end menu
9044 @node Alpha Built-in Functions
9045 @subsection Alpha Built-in Functions
9047 These built-in functions are available for the Alpha family of
9048 processors, depending on the command-line switches used.
9050 The following built-in functions are always available.  They
9051 all generate the machine instruction that is part of the name.
9053 @smallexample
9054 long __builtin_alpha_implver (void)
9055 long __builtin_alpha_rpcc (void)
9056 long __builtin_alpha_amask (long)
9057 long __builtin_alpha_cmpbge (long, long)
9058 long __builtin_alpha_extbl (long, long)
9059 long __builtin_alpha_extwl (long, long)
9060 long __builtin_alpha_extll (long, long)
9061 long __builtin_alpha_extql (long, long)
9062 long __builtin_alpha_extwh (long, long)
9063 long __builtin_alpha_extlh (long, long)
9064 long __builtin_alpha_extqh (long, long)
9065 long __builtin_alpha_insbl (long, long)
9066 long __builtin_alpha_inswl (long, long)
9067 long __builtin_alpha_insll (long, long)
9068 long __builtin_alpha_insql (long, long)
9069 long __builtin_alpha_inswh (long, long)
9070 long __builtin_alpha_inslh (long, long)
9071 long __builtin_alpha_insqh (long, long)
9072 long __builtin_alpha_mskbl (long, long)
9073 long __builtin_alpha_mskwl (long, long)
9074 long __builtin_alpha_mskll (long, long)
9075 long __builtin_alpha_mskql (long, long)
9076 long __builtin_alpha_mskwh (long, long)
9077 long __builtin_alpha_msklh (long, long)
9078 long __builtin_alpha_mskqh (long, long)
9079 long __builtin_alpha_umulh (long, long)
9080 long __builtin_alpha_zap (long, long)
9081 long __builtin_alpha_zapnot (long, long)
9082 @end smallexample
9084 The following built-in functions are always with @option{-mmax}
9085 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
9086 later.  They all generate the machine instruction that is part
9087 of the name.
9089 @smallexample
9090 long __builtin_alpha_pklb (long)
9091 long __builtin_alpha_pkwb (long)
9092 long __builtin_alpha_unpkbl (long)
9093 long __builtin_alpha_unpkbw (long)
9094 long __builtin_alpha_minub8 (long, long)
9095 long __builtin_alpha_minsb8 (long, long)
9096 long __builtin_alpha_minuw4 (long, long)
9097 long __builtin_alpha_minsw4 (long, long)
9098 long __builtin_alpha_maxub8 (long, long)
9099 long __builtin_alpha_maxsb8 (long, long)
9100 long __builtin_alpha_maxuw4 (long, long)
9101 long __builtin_alpha_maxsw4 (long, long)
9102 long __builtin_alpha_perr (long, long)
9103 @end smallexample
9105 The following built-in functions are always with @option{-mcix}
9106 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
9107 later.  They all generate the machine instruction that is part
9108 of the name.
9110 @smallexample
9111 long __builtin_alpha_cttz (long)
9112 long __builtin_alpha_ctlz (long)
9113 long __builtin_alpha_ctpop (long)
9114 @end smallexample
9116 The following built-in functions are available on systems that use the OSF/1
9117 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
9118 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
9119 @code{rdval} and @code{wrval}.
9121 @smallexample
9122 void *__builtin_thread_pointer (void)
9123 void __builtin_set_thread_pointer (void *)
9124 @end smallexample
9126 @node ARC Built-in Functions
9127 @subsection ARC Built-in Functions
9129 The following built-in functions are provided for ARC targets.  The
9130 built-ins generate the corresponding assembly instructions.  In the
9131 examples given below, the generated code often requires an operand or
9132 result to be in a register.  Where necessary further code will be
9133 generated to ensure this is true, but for brevity this is not
9134 described in each case.
9136 @emph{Note:} Using a built-in to generate an instruction not supported
9137 by a target may cause problems. At present the compiler is not
9138 guaranteed to detect such misuse, and as a result an internal compiler
9139 error may be generated.
9141 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
9142 Return 1 if @var{val} is known to have the byte alignment given
9143 by @var{alignval}, otherwise return 0.
9144 Note that this is different from
9145 @smallexample
9146 __alignof__(*(char *)@var{val}) >= alignval
9147 @end smallexample
9148 because __alignof__ sees only the type of the dereference, whereas
9149 __builtin_arc_align uses alignment information from the pointer
9150 as well as from the pointed-to type.
9151 The information available will depend on optimization level.
9152 @end deftypefn
9154 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
9155 Generates
9156 @example
9158 @end example
9159 @end deftypefn
9161 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
9162 The operand is the number of a register to be read.  Generates:
9163 @example
9164 mov  @var{dest}, r@var{regno}
9165 @end example
9166 where the value in @var{dest} will be the result returned from the
9167 built-in.
9168 @end deftypefn
9170 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
9171 The first operand is the number of a register to be written, the
9172 second operand is a compile time constant to write into that
9173 register.  Generates:
9174 @example
9175 mov  r@var{regno}, @var{val}
9176 @end example
9177 @end deftypefn
9179 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
9180 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
9181 Generates:
9182 @example
9183 divaw  @var{dest}, @var{a}, @var{b}
9184 @end example
9185 where the value in @var{dest} will be the result returned from the
9186 built-in.
9187 @end deftypefn
9189 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
9190 Generates
9191 @example
9192 flag  @var{a}
9193 @end example
9194 @end deftypefn
9196 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
9197 The operand, @var{auxv}, is the address of an auxiliary register and
9198 must be a compile time constant.  Generates:
9199 @example
9200 lr  @var{dest}, [@var{auxr}]
9201 @end example
9202 Where the value in @var{dest} will be the result returned from the
9203 built-in.
9204 @end deftypefn
9206 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
9207 Only available with @option{-mmul64}.  Generates:
9208 @example
9209 mul64  @var{a}, @var{b}
9210 @end example
9211 @end deftypefn
9213 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
9214 Only available with @option{-mmul64}.  Generates:
9215 @example
9216 mulu64  @var{a}, @var{b}
9217 @end example
9218 @end deftypefn
9220 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
9221 Generates:
9222 @example
9224 @end example
9225 @end deftypefn
9227 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
9228 Only valid if the @samp{norm} instruction is available through the
9229 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9230 Generates:
9231 @example
9232 norm  @var{dest}, @var{src}
9233 @end example
9234 Where the value in @var{dest} will be the result returned from the
9235 built-in.
9236 @end deftypefn
9238 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
9239 Only valid if the @samp{normw} instruction is available through the
9240 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
9241 Generates:
9242 @example
9243 normw  @var{dest}, @var{src}
9244 @end example
9245 Where the value in @var{dest} will be the result returned from the
9246 built-in.
9247 @end deftypefn
9249 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
9250 Generates:
9251 @example
9252 rtie
9253 @end example
9254 @end deftypefn
9256 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
9257 Generates:
9258 @example
9259 sleep  @var{a}
9260 @end example
9261 @end deftypefn
9263 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
9264 The first argument, @var{auxv}, is the address of an auxiliary
9265 register, the second argument, @var{val}, is a compile time constant
9266 to be written to the register.  Generates:
9267 @example
9268 sr  @var{auxr}, [@var{val}]
9269 @end example
9270 @end deftypefn
9272 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
9273 Only valid with @option{-mswap}.  Generates:
9274 @example
9275 swap  @var{dest}, @var{src}
9276 @end example
9277 Where the value in @var{dest} will be the result returned from the
9278 built-in.
9279 @end deftypefn
9281 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
9282 Generates:
9283 @example
9285 @end example
9286 @end deftypefn
9288 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
9289 Only available with @option{-mcpu=ARC700}.  Generates:
9290 @example
9291 sync
9292 @end example
9293 @end deftypefn
9295 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
9296 Only available with @option{-mcpu=ARC700}.  Generates:
9297 @example
9298 trap_s  @var{c}
9299 @end example
9300 @end deftypefn
9302 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
9303 Only available with @option{-mcpu=ARC700}.  Generates:
9304 @example
9305 unimp_s
9306 @end example
9307 @end deftypefn
9309 The instructions generated by the following builtins are not
9310 considered as candidates for scheduling.  They are not moved around by
9311 the compiler during scheduling, and thus can be expected to appear
9312 where they are put in the C code:
9313 @example
9314 __builtin_arc_brk()
9315 __builtin_arc_core_read()
9316 __builtin_arc_core_write()
9317 __builtin_arc_flag()
9318 __builtin_arc_lr()
9319 __builtin_arc_sleep()
9320 __builtin_arc_sr()
9321 __builtin_arc_swi()
9322 @end example
9324 @node ARC SIMD Built-in Functions
9325 @subsection ARC SIMD Built-in Functions
9327 SIMD builtins provided by the compiler can be used to generate the
9328 vector instructions.  This section describes the available builtins
9329 and their usage in programs.  With the @option{-msimd} option, the
9330 compiler provides 128-bit vector types, which can be specified using
9331 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
9332 can be included to use the following predefined types:
9333 @example
9334 typedef int __v4si   __attribute__((vector_size(16)));
9335 typedef short __v8hi __attribute__((vector_size(16)));
9336 @end example
9338 These types can be used to define 128-bit variables.  The built-in
9339 functions listed in the following section can be used on these
9340 variables to generate the vector operations.
9342 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
9343 @file{arc-simd.h} also provides equivalent macros called
9344 @code{_@var{someinsn}} that can be used for programming ease and
9345 improved readability.  The following macros for DMA control are also
9346 provided:
9347 @example
9348 #define _setup_dma_in_channel_reg _vdiwr
9349 #define _setup_dma_out_channel_reg _vdowr
9350 @end example
9352 The following is a complete list of all the SIMD built-ins provided
9353 for ARC, grouped by calling signature.
9355 The following take two @code{__v8hi} arguments and return a
9356 @code{__v8hi} result:
9357 @example
9358 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
9359 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
9360 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
9361 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
9362 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
9363 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
9364 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
9365 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
9366 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
9367 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
9368 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
9369 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
9370 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
9371 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
9372 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
9373 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
9374 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
9375 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
9376 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
9377 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
9378 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
9379 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
9380 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
9381 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
9382 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
9383 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
9384 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
9385 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
9386 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
9387 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
9388 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
9389 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
9390 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
9391 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
9392 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
9393 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
9394 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
9395 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
9396 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
9397 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
9398 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
9399 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
9400 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
9401 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
9402 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
9403 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
9404 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
9405 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
9406 @end example
9408 The following take one @code{__v8hi} and one @code{int} argument and return a
9409 @code{__v8hi} result:
9411 @example
9412 __v8hi __builtin_arc_vbaddw (__v8hi, int)
9413 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
9414 __v8hi __builtin_arc_vbminw (__v8hi, int)
9415 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
9416 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
9417 __v8hi __builtin_arc_vbmulw (__v8hi, int)
9418 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
9419 __v8hi __builtin_arc_vbsubw (__v8hi, int)
9420 @end example
9422 The following take one @code{__v8hi} argument and one @code{int} argument which
9423 must be a 3-bit compile time constant indicating a register number
9424 I0-I7.  They return a @code{__v8hi} result.
9425 @example
9426 __v8hi __builtin_arc_vasrw (__v8hi, const int)
9427 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
9428 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
9429 @end example
9431 The following take one @code{__v8hi} argument and one @code{int}
9432 argument which must be a 6-bit compile time constant.  They return a
9433 @code{__v8hi} result.
9434 @example
9435 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
9436 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
9437 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
9438 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
9439 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
9440 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
9441 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
9442 @end example
9444 The following take one @code{__v8hi} argument and one @code{int} argument which
9445 must be a 8-bit compile time constant.  They return a @code{__v8hi}
9446 result.
9447 @example
9448 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
9449 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
9450 __v8hi __builtin_arc_vmvw (__v8hi, const int)
9451 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
9452 @end example
9454 The following take two @code{int} arguments, the second of which which
9455 must be a 8-bit compile time constant.  They return a @code{__v8hi}
9456 result:
9457 @example
9458 __v8hi __builtin_arc_vmovaw (int, const int)
9459 __v8hi __builtin_arc_vmovw (int, const int)
9460 __v8hi __builtin_arc_vmovzw (int, const int)
9461 @end example
9463 The following take a single @code{__v8hi} argument and return a
9464 @code{__v8hi} result:
9465 @example
9466 __v8hi __builtin_arc_vabsaw (__v8hi)
9467 __v8hi __builtin_arc_vabsw (__v8hi)
9468 __v8hi __builtin_arc_vaddsuw (__v8hi)
9469 __v8hi __builtin_arc_vexch1 (__v8hi)
9470 __v8hi __builtin_arc_vexch2 (__v8hi)
9471 __v8hi __builtin_arc_vexch4 (__v8hi)
9472 __v8hi __builtin_arc_vsignw (__v8hi)
9473 __v8hi __builtin_arc_vupbaw (__v8hi)
9474 __v8hi __builtin_arc_vupbw (__v8hi)
9475 __v8hi __builtin_arc_vupsbaw (__v8hi)
9476 __v8hi __builtin_arc_vupsbw (__v8hi)
9477 @end example
9479 The followign take two @code{int} arguments and return no result:
9480 @example
9481 void __builtin_arc_vdirun (int, int)
9482 void __builtin_arc_vdorun (int, int)
9483 @end example
9485 The following take two @code{int} arguments and return no result.  The
9486 first argument must a 3-bit compile time constant indicating one of
9487 the DR0-DR7 DMA setup channels:
9488 @example
9489 void __builtin_arc_vdiwr (const int, int)
9490 void __builtin_arc_vdowr (const int, int)
9491 @end example
9493 The following take an @code{int} argument and return no result:
9494 @example
9495 void __builtin_arc_vendrec (int)
9496 void __builtin_arc_vrec (int)
9497 void __builtin_arc_vrecrun (int)
9498 void __builtin_arc_vrun (int)
9499 @end example
9501 The following take a @code{__v8hi} argument and two @code{int}
9502 arguments and return a @code{__v8hi} result.  The second argument must
9503 be a 3-bit compile time constants, indicating one the registers I0-I7,
9504 and the third argument must be an 8-bit compile time constant.
9506 @emph{Note:} Although the equivalent hardware instructions do not take
9507 an SIMD register as an operand, these builtins overwrite the relevant
9508 bits of the @code{__v8hi} register provided as the first argument with
9509 the value loaded from the @code{[Ib, u8]} location in the SDM.
9511 @example
9512 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
9513 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
9514 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
9515 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
9516 @end example
9518 The following take two @code{int} arguments and return a @code{__v8hi}
9519 result.  The first argument must be a 3-bit compile time constants,
9520 indicating one the registers I0-I7, and the second argument must be an
9521 8-bit compile time constant.
9523 @example
9524 __v8hi __builtin_arc_vld128 (const int, const int)
9525 __v8hi __builtin_arc_vld64w (const int, const int)
9526 @end example
9528 The following take a @code{__v8hi} argument and two @code{int}
9529 arguments and return no result.  The second argument must be a 3-bit
9530 compile time constants, indicating one the registers I0-I7, and the
9531 third argument must be an 8-bit compile time constant.
9533 @example
9534 void __builtin_arc_vst128 (__v8hi, const int, const int)
9535 void __builtin_arc_vst64 (__v8hi, const int, const int)
9536 @end example
9538 The following take a @code{__v8hi} argument and three @code{int}
9539 arguments and return no result.  The second argument must be a 3-bit
9540 compile-time constant, identifying the 16-bit sub-register to be
9541 stored, the third argument must be a 3-bit compile time constants,
9542 indicating one the registers I0-I7, and the fourth argument must be an
9543 8-bit compile time constant.
9545 @example
9546 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
9547 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
9548 @end example
9550 @node ARM iWMMXt Built-in Functions
9551 @subsection ARM iWMMXt Built-in Functions
9553 These built-in functions are available for the ARM family of
9554 processors when the @option{-mcpu=iwmmxt} switch is used:
9556 @smallexample
9557 typedef int v2si __attribute__ ((vector_size (8)));
9558 typedef short v4hi __attribute__ ((vector_size (8)));
9559 typedef char v8qi __attribute__ ((vector_size (8)));
9561 int __builtin_arm_getwcgr0 (void)
9562 void __builtin_arm_setwcgr0 (int)
9563 int __builtin_arm_getwcgr1 (void)
9564 void __builtin_arm_setwcgr1 (int)
9565 int __builtin_arm_getwcgr2 (void)
9566 void __builtin_arm_setwcgr2 (int)
9567 int __builtin_arm_getwcgr3 (void)
9568 void __builtin_arm_setwcgr3 (int)
9569 int __builtin_arm_textrmsb (v8qi, int)
9570 int __builtin_arm_textrmsh (v4hi, int)
9571 int __builtin_arm_textrmsw (v2si, int)
9572 int __builtin_arm_textrmub (v8qi, int)
9573 int __builtin_arm_textrmuh (v4hi, int)
9574 int __builtin_arm_textrmuw (v2si, int)
9575 v8qi __builtin_arm_tinsrb (v8qi, int, int)
9576 v4hi __builtin_arm_tinsrh (v4hi, int, int)
9577 v2si __builtin_arm_tinsrw (v2si, int, int)
9578 long long __builtin_arm_tmia (long long, int, int)
9579 long long __builtin_arm_tmiabb (long long, int, int)
9580 long long __builtin_arm_tmiabt (long long, int, int)
9581 long long __builtin_arm_tmiaph (long long, int, int)
9582 long long __builtin_arm_tmiatb (long long, int, int)
9583 long long __builtin_arm_tmiatt (long long, int, int)
9584 int __builtin_arm_tmovmskb (v8qi)
9585 int __builtin_arm_tmovmskh (v4hi)
9586 int __builtin_arm_tmovmskw (v2si)
9587 long long __builtin_arm_waccb (v8qi)
9588 long long __builtin_arm_wacch (v4hi)
9589 long long __builtin_arm_waccw (v2si)
9590 v8qi __builtin_arm_waddb (v8qi, v8qi)
9591 v8qi __builtin_arm_waddbss (v8qi, v8qi)
9592 v8qi __builtin_arm_waddbus (v8qi, v8qi)
9593 v4hi __builtin_arm_waddh (v4hi, v4hi)
9594 v4hi __builtin_arm_waddhss (v4hi, v4hi)
9595 v4hi __builtin_arm_waddhus (v4hi, v4hi)
9596 v2si __builtin_arm_waddw (v2si, v2si)
9597 v2si __builtin_arm_waddwss (v2si, v2si)
9598 v2si __builtin_arm_waddwus (v2si, v2si)
9599 v8qi __builtin_arm_walign (v8qi, v8qi, int)
9600 long long __builtin_arm_wand(long long, long long)
9601 long long __builtin_arm_wandn (long long, long long)
9602 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
9603 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
9604 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
9605 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
9606 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
9607 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
9608 v2si __builtin_arm_wcmpeqw (v2si, v2si)
9609 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
9610 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
9611 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
9612 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
9613 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
9614 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
9615 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
9616 long long __builtin_arm_wmacsz (v4hi, v4hi)
9617 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
9618 long long __builtin_arm_wmacuz (v4hi, v4hi)
9619 v4hi __builtin_arm_wmadds (v4hi, v4hi)
9620 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
9621 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
9622 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
9623 v2si __builtin_arm_wmaxsw (v2si, v2si)
9624 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
9625 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
9626 v2si __builtin_arm_wmaxuw (v2si, v2si)
9627 v8qi __builtin_arm_wminsb (v8qi, v8qi)
9628 v4hi __builtin_arm_wminsh (v4hi, v4hi)
9629 v2si __builtin_arm_wminsw (v2si, v2si)
9630 v8qi __builtin_arm_wminub (v8qi, v8qi)
9631 v4hi __builtin_arm_wminuh (v4hi, v4hi)
9632 v2si __builtin_arm_wminuw (v2si, v2si)
9633 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
9634 v4hi __builtin_arm_wmulul (v4hi, v4hi)
9635 v4hi __builtin_arm_wmulum (v4hi, v4hi)
9636 long long __builtin_arm_wor (long long, long long)
9637 v2si __builtin_arm_wpackdss (long long, long long)
9638 v2si __builtin_arm_wpackdus (long long, long long)
9639 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
9640 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
9641 v4hi __builtin_arm_wpackwss (v2si, v2si)
9642 v4hi __builtin_arm_wpackwus (v2si, v2si)
9643 long long __builtin_arm_wrord (long long, long long)
9644 long long __builtin_arm_wrordi (long long, int)
9645 v4hi __builtin_arm_wrorh (v4hi, long long)
9646 v4hi __builtin_arm_wrorhi (v4hi, int)
9647 v2si __builtin_arm_wrorw (v2si, long long)
9648 v2si __builtin_arm_wrorwi (v2si, int)
9649 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
9650 v2si __builtin_arm_wsadbz (v8qi, v8qi)
9651 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
9652 v2si __builtin_arm_wsadhz (v4hi, v4hi)
9653 v4hi __builtin_arm_wshufh (v4hi, int)
9654 long long __builtin_arm_wslld (long long, long long)
9655 long long __builtin_arm_wslldi (long long, int)
9656 v4hi __builtin_arm_wsllh (v4hi, long long)
9657 v4hi __builtin_arm_wsllhi (v4hi, int)
9658 v2si __builtin_arm_wsllw (v2si, long long)
9659 v2si __builtin_arm_wsllwi (v2si, int)
9660 long long __builtin_arm_wsrad (long long, long long)
9661 long long __builtin_arm_wsradi (long long, int)
9662 v4hi __builtin_arm_wsrah (v4hi, long long)
9663 v4hi __builtin_arm_wsrahi (v4hi, int)
9664 v2si __builtin_arm_wsraw (v2si, long long)
9665 v2si __builtin_arm_wsrawi (v2si, int)
9666 long long __builtin_arm_wsrld (long long, long long)
9667 long long __builtin_arm_wsrldi (long long, int)
9668 v4hi __builtin_arm_wsrlh (v4hi, long long)
9669 v4hi __builtin_arm_wsrlhi (v4hi, int)
9670 v2si __builtin_arm_wsrlw (v2si, long long)
9671 v2si __builtin_arm_wsrlwi (v2si, int)
9672 v8qi __builtin_arm_wsubb (v8qi, v8qi)
9673 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
9674 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
9675 v4hi __builtin_arm_wsubh (v4hi, v4hi)
9676 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
9677 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
9678 v2si __builtin_arm_wsubw (v2si, v2si)
9679 v2si __builtin_arm_wsubwss (v2si, v2si)
9680 v2si __builtin_arm_wsubwus (v2si, v2si)
9681 v4hi __builtin_arm_wunpckehsb (v8qi)
9682 v2si __builtin_arm_wunpckehsh (v4hi)
9683 long long __builtin_arm_wunpckehsw (v2si)
9684 v4hi __builtin_arm_wunpckehub (v8qi)
9685 v2si __builtin_arm_wunpckehuh (v4hi)
9686 long long __builtin_arm_wunpckehuw (v2si)
9687 v4hi __builtin_arm_wunpckelsb (v8qi)
9688 v2si __builtin_arm_wunpckelsh (v4hi)
9689 long long __builtin_arm_wunpckelsw (v2si)
9690 v4hi __builtin_arm_wunpckelub (v8qi)
9691 v2si __builtin_arm_wunpckeluh (v4hi)
9692 long long __builtin_arm_wunpckeluw (v2si)
9693 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
9694 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
9695 v2si __builtin_arm_wunpckihw (v2si, v2si)
9696 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
9697 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
9698 v2si __builtin_arm_wunpckilw (v2si, v2si)
9699 long long __builtin_arm_wxor (long long, long long)
9700 long long __builtin_arm_wzero ()
9701 @end smallexample
9703 @node ARM NEON Intrinsics
9704 @subsection ARM NEON Intrinsics
9706 These built-in intrinsics for the ARM Advanced SIMD extension are available
9707 when the @option{-mfpu=neon} switch is used:
9709 @include arm-neon-intrinsics.texi
9711 @node AVR Built-in Functions
9712 @subsection AVR Built-in Functions
9714 For each built-in function for AVR, there is an equally named,
9715 uppercase built-in macro defined. That way users can easily query if
9716 or if not a specific built-in is implemented or not. For example, if
9717 @code{__builtin_avr_nop} is available the macro
9718 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
9720 The following built-in functions map to the respective machine
9721 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
9722 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
9723 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
9724 as library call if no hardware multiplier is available.
9726 @smallexample
9727 void __builtin_avr_nop (void)
9728 void __builtin_avr_sei (void)
9729 void __builtin_avr_cli (void)
9730 void __builtin_avr_sleep (void)
9731 void __builtin_avr_wdr (void)
9732 unsigned char __builtin_avr_swap (unsigned char)
9733 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9734 int __builtin_avr_fmuls (char, char)
9735 int __builtin_avr_fmulsu (char, unsigned char)
9736 @end smallexample
9738 In order to delay execution for a specific number of cycles, GCC
9739 implements
9740 @smallexample
9741 void __builtin_avr_delay_cycles (unsigned long ticks)
9742 @end smallexample
9744 @noindent
9745 @code{ticks} is the number of ticks to delay execution. Note that this
9746 built-in does not take into account the effect of interrupts that
9747 might increase delay time. @code{ticks} must be a compile-time
9748 integer constant; delays with a variable number of cycles are not supported.
9750 @smallexample
9751 char __builtin_avr_flash_segment (const __memx void*)
9752 @end smallexample
9754 @noindent
9755 This built-in takes a byte address to the 24-bit
9756 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9757 the number of the flash segment (the 64 KiB chunk) where the address
9758 points to.  Counting starts at @code{0}.
9759 If the address does not point to flash memory, return @code{-1}.
9761 @smallexample
9762 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9763 @end smallexample
9765 @noindent
9766 Insert bits from @var{bits} into @var{val} and return the resulting
9767 value. The nibbles of @var{map} determine how the insertion is
9768 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9769 @enumerate
9770 @item If @var{X} is @code{0xf},
9771 then the @var{n}-th bit of @var{val} is returned unaltered.
9773 @item If X is in the range 0@dots{}7,
9774 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9776 @item If X is in the range 8@dots{}@code{0xe},
9777 then the @var{n}-th result bit is undefined.
9778 @end enumerate
9780 @noindent
9781 One typical use case for this built-in is adjusting input and
9782 output values to non-contiguous port layouts. Some examples:
9784 @smallexample
9785 // same as val, bits is unused
9786 __builtin_avr_insert_bits (0xffffffff, bits, val)
9787 @end smallexample
9789 @smallexample
9790 // same as bits, val is unused
9791 __builtin_avr_insert_bits (0x76543210, bits, val)
9792 @end smallexample
9794 @smallexample
9795 // same as rotating bits by 4
9796 __builtin_avr_insert_bits (0x32107654, bits, 0)
9797 @end smallexample
9799 @smallexample
9800 // high nibble of result is the high nibble of val
9801 // low nibble of result is the low nibble of bits
9802 __builtin_avr_insert_bits (0xffff3210, bits, val)
9803 @end smallexample
9805 @smallexample
9806 // reverse the bit order of bits
9807 __builtin_avr_insert_bits (0x01234567, bits, 0)
9808 @end smallexample
9810 @node Blackfin Built-in Functions
9811 @subsection Blackfin Built-in Functions
9813 Currently, there are two Blackfin-specific built-in functions.  These are
9814 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9815 using inline assembly; by using these built-in functions the compiler can
9816 automatically add workarounds for hardware errata involving these
9817 instructions.  These functions are named as follows:
9819 @smallexample
9820 void __builtin_bfin_csync (void)
9821 void __builtin_bfin_ssync (void)
9822 @end smallexample
9824 @node FR-V Built-in Functions
9825 @subsection FR-V Built-in Functions
9827 GCC provides many FR-V-specific built-in functions.  In general,
9828 these functions are intended to be compatible with those described
9829 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9830 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
9831 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9832 pointer rather than by value.
9834 Most of the functions are named after specific FR-V instructions.
9835 Such functions are said to be ``directly mapped'' and are summarized
9836 here in tabular form.
9838 @menu
9839 * Argument Types::
9840 * Directly-mapped Integer Functions::
9841 * Directly-mapped Media Functions::
9842 * Raw read/write Functions::
9843 * Other Built-in Functions::
9844 @end menu
9846 @node Argument Types
9847 @subsubsection Argument Types
9849 The arguments to the built-in functions can be divided into three groups:
9850 register numbers, compile-time constants and run-time values.  In order
9851 to make this classification clear at a glance, the arguments and return
9852 values are given the following pseudo types:
9854 @multitable @columnfractions .20 .30 .15 .35
9855 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9856 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9857 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9858 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9859 @item @code{uw2} @tab @code{unsigned long long} @tab No
9860 @tab an unsigned doubleword
9861 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9862 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9863 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9864 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9865 @end multitable
9867 These pseudo types are not defined by GCC, they are simply a notational
9868 convenience used in this manual.
9870 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9871 and @code{sw2} are evaluated at run time.  They correspond to
9872 register operands in the underlying FR-V instructions.
9874 @code{const} arguments represent immediate operands in the underlying
9875 FR-V instructions.  They must be compile-time constants.
9877 @code{acc} arguments are evaluated at compile time and specify the number
9878 of an accumulator register.  For example, an @code{acc} argument of 2
9879 selects the ACC2 register.
9881 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9882 number of an IACC register.  See @pxref{Other Built-in Functions}
9883 for more details.
9885 @node Directly-mapped Integer Functions
9886 @subsubsection Directly-mapped Integer Functions
9888 The functions listed below map directly to FR-V I-type instructions.
9890 @multitable @columnfractions .45 .32 .23
9891 @item Function prototype @tab Example usage @tab Assembly output
9892 @item @code{sw1 __ADDSS (sw1, sw1)}
9893 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9894 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9895 @item @code{sw1 __SCAN (sw1, sw1)}
9896 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9897 @tab @code{SCAN @var{a},@var{b},@var{c}}
9898 @item @code{sw1 __SCUTSS (sw1)}
9899 @tab @code{@var{b} = __SCUTSS (@var{a})}
9900 @tab @code{SCUTSS @var{a},@var{b}}
9901 @item @code{sw1 __SLASS (sw1, sw1)}
9902 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9903 @tab @code{SLASS @var{a},@var{b},@var{c}}
9904 @item @code{void __SMASS (sw1, sw1)}
9905 @tab @code{__SMASS (@var{a}, @var{b})}
9906 @tab @code{SMASS @var{a},@var{b}}
9907 @item @code{void __SMSSS (sw1, sw1)}
9908 @tab @code{__SMSSS (@var{a}, @var{b})}
9909 @tab @code{SMSSS @var{a},@var{b}}
9910 @item @code{void __SMU (sw1, sw1)}
9911 @tab @code{__SMU (@var{a}, @var{b})}
9912 @tab @code{SMU @var{a},@var{b}}
9913 @item @code{sw2 __SMUL (sw1, sw1)}
9914 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9915 @tab @code{SMUL @var{a},@var{b},@var{c}}
9916 @item @code{sw1 __SUBSS (sw1, sw1)}
9917 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9918 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9919 @item @code{uw2 __UMUL (uw1, uw1)}
9920 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9921 @tab @code{UMUL @var{a},@var{b},@var{c}}
9922 @end multitable
9924 @node Directly-mapped Media Functions
9925 @subsubsection Directly-mapped Media Functions
9927 The functions listed below map directly to FR-V M-type instructions.
9929 @multitable @columnfractions .45 .32 .23
9930 @item Function prototype @tab Example usage @tab Assembly output
9931 @item @code{uw1 __MABSHS (sw1)}
9932 @tab @code{@var{b} = __MABSHS (@var{a})}
9933 @tab @code{MABSHS @var{a},@var{b}}
9934 @item @code{void __MADDACCS (acc, acc)}
9935 @tab @code{__MADDACCS (@var{b}, @var{a})}
9936 @tab @code{MADDACCS @var{a},@var{b}}
9937 @item @code{sw1 __MADDHSS (sw1, sw1)}
9938 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9939 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9940 @item @code{uw1 __MADDHUS (uw1, uw1)}
9941 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9942 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9943 @item @code{uw1 __MAND (uw1, uw1)}
9944 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9945 @tab @code{MAND @var{a},@var{b},@var{c}}
9946 @item @code{void __MASACCS (acc, acc)}
9947 @tab @code{__MASACCS (@var{b}, @var{a})}
9948 @tab @code{MASACCS @var{a},@var{b}}
9949 @item @code{uw1 __MAVEH (uw1, uw1)}
9950 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9951 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9952 @item @code{uw2 __MBTOH (uw1)}
9953 @tab @code{@var{b} = __MBTOH (@var{a})}
9954 @tab @code{MBTOH @var{a},@var{b}}
9955 @item @code{void __MBTOHE (uw1 *, uw1)}
9956 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9957 @tab @code{MBTOHE @var{a},@var{b}}
9958 @item @code{void __MCLRACC (acc)}
9959 @tab @code{__MCLRACC (@var{a})}
9960 @tab @code{MCLRACC @var{a}}
9961 @item @code{void __MCLRACCA (void)}
9962 @tab @code{__MCLRACCA ()}
9963 @tab @code{MCLRACCA}
9964 @item @code{uw1 __Mcop1 (uw1, uw1)}
9965 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9966 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9967 @item @code{uw1 __Mcop2 (uw1, uw1)}
9968 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9969 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9970 @item @code{uw1 __MCPLHI (uw2, const)}
9971 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9972 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9973 @item @code{uw1 __MCPLI (uw2, const)}
9974 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9975 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9976 @item @code{void __MCPXIS (acc, sw1, sw1)}
9977 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9978 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9979 @item @code{void __MCPXIU (acc, uw1, uw1)}
9980 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9981 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9982 @item @code{void __MCPXRS (acc, sw1, sw1)}
9983 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9984 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9985 @item @code{void __MCPXRU (acc, uw1, uw1)}
9986 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9987 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9988 @item @code{uw1 __MCUT (acc, uw1)}
9989 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9990 @tab @code{MCUT @var{a},@var{b},@var{c}}
9991 @item @code{uw1 __MCUTSS (acc, sw1)}
9992 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9993 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9994 @item @code{void __MDADDACCS (acc, acc)}
9995 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9996 @tab @code{MDADDACCS @var{a},@var{b}}
9997 @item @code{void __MDASACCS (acc, acc)}
9998 @tab @code{__MDASACCS (@var{b}, @var{a})}
9999 @tab @code{MDASACCS @var{a},@var{b}}
10000 @item @code{uw2 __MDCUTSSI (acc, const)}
10001 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
10002 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
10003 @item @code{uw2 __MDPACKH (uw2, uw2)}
10004 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
10005 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
10006 @item @code{uw2 __MDROTLI (uw2, const)}
10007 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
10008 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
10009 @item @code{void __MDSUBACCS (acc, acc)}
10010 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
10011 @tab @code{MDSUBACCS @var{a},@var{b}}
10012 @item @code{void __MDUNPACKH (uw1 *, uw2)}
10013 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
10014 @tab @code{MDUNPACKH @var{a},@var{b}}
10015 @item @code{uw2 __MEXPDHD (uw1, const)}
10016 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
10017 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
10018 @item @code{uw1 __MEXPDHW (uw1, const)}
10019 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
10020 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
10021 @item @code{uw1 __MHDSETH (uw1, const)}
10022 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
10023 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
10024 @item @code{sw1 __MHDSETS (const)}
10025 @tab @code{@var{b} = __MHDSETS (@var{a})}
10026 @tab @code{MHDSETS #@var{a},@var{b}}
10027 @item @code{uw1 __MHSETHIH (uw1, const)}
10028 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
10029 @tab @code{MHSETHIH #@var{a},@var{b}}
10030 @item @code{sw1 __MHSETHIS (sw1, const)}
10031 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
10032 @tab @code{MHSETHIS #@var{a},@var{b}}
10033 @item @code{uw1 __MHSETLOH (uw1, const)}
10034 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
10035 @tab @code{MHSETLOH #@var{a},@var{b}}
10036 @item @code{sw1 __MHSETLOS (sw1, const)}
10037 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
10038 @tab @code{MHSETLOS #@var{a},@var{b}}
10039 @item @code{uw1 __MHTOB (uw2)}
10040 @tab @code{@var{b} = __MHTOB (@var{a})}
10041 @tab @code{MHTOB @var{a},@var{b}}
10042 @item @code{void __MMACHS (acc, sw1, sw1)}
10043 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
10044 @tab @code{MMACHS @var{a},@var{b},@var{c}}
10045 @item @code{void __MMACHU (acc, uw1, uw1)}
10046 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
10047 @tab @code{MMACHU @var{a},@var{b},@var{c}}
10048 @item @code{void __MMRDHS (acc, sw1, sw1)}
10049 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
10050 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
10051 @item @code{void __MMRDHU (acc, uw1, uw1)}
10052 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
10053 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
10054 @item @code{void __MMULHS (acc, sw1, sw1)}
10055 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
10056 @tab @code{MMULHS @var{a},@var{b},@var{c}}
10057 @item @code{void __MMULHU (acc, uw1, uw1)}
10058 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
10059 @tab @code{MMULHU @var{a},@var{b},@var{c}}
10060 @item @code{void __MMULXHS (acc, sw1, sw1)}
10061 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
10062 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
10063 @item @code{void __MMULXHU (acc, uw1, uw1)}
10064 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
10065 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
10066 @item @code{uw1 __MNOT (uw1)}
10067 @tab @code{@var{b} = __MNOT (@var{a})}
10068 @tab @code{MNOT @var{a},@var{b}}
10069 @item @code{uw1 __MOR (uw1, uw1)}
10070 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
10071 @tab @code{MOR @var{a},@var{b},@var{c}}
10072 @item @code{uw1 __MPACKH (uh, uh)}
10073 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
10074 @tab @code{MPACKH @var{a},@var{b},@var{c}}
10075 @item @code{sw2 __MQADDHSS (sw2, sw2)}
10076 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
10077 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
10078 @item @code{uw2 __MQADDHUS (uw2, uw2)}
10079 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
10080 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
10081 @item @code{void __MQCPXIS (acc, sw2, sw2)}
10082 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
10083 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
10084 @item @code{void __MQCPXIU (acc, uw2, uw2)}
10085 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
10086 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
10087 @item @code{void __MQCPXRS (acc, sw2, sw2)}
10088 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
10089 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
10090 @item @code{void __MQCPXRU (acc, uw2, uw2)}
10091 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
10092 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
10093 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
10094 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
10095 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
10096 @item @code{sw2 __MQLMTHS (sw2, sw2)}
10097 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
10098 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
10099 @item @code{void __MQMACHS (acc, sw2, sw2)}
10100 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
10101 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
10102 @item @code{void __MQMACHU (acc, uw2, uw2)}
10103 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
10104 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
10105 @item @code{void __MQMACXHS (acc, sw2, sw2)}
10106 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
10107 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
10108 @item @code{void __MQMULHS (acc, sw2, sw2)}
10109 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
10110 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
10111 @item @code{void __MQMULHU (acc, uw2, uw2)}
10112 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
10113 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
10114 @item @code{void __MQMULXHS (acc, sw2, sw2)}
10115 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
10116 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
10117 @item @code{void __MQMULXHU (acc, uw2, uw2)}
10118 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
10119 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
10120 @item @code{sw2 __MQSATHS (sw2, sw2)}
10121 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
10122 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
10123 @item @code{uw2 __MQSLLHI (uw2, int)}
10124 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
10125 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
10126 @item @code{sw2 __MQSRAHI (sw2, int)}
10127 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
10128 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
10129 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
10130 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
10131 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
10132 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
10133 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
10134 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
10135 @item @code{void __MQXMACHS (acc, sw2, sw2)}
10136 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
10137 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
10138 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
10139 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
10140 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
10141 @item @code{uw1 __MRDACC (acc)}
10142 @tab @code{@var{b} = __MRDACC (@var{a})}
10143 @tab @code{MRDACC @var{a},@var{b}}
10144 @item @code{uw1 __MRDACCG (acc)}
10145 @tab @code{@var{b} = __MRDACCG (@var{a})}
10146 @tab @code{MRDACCG @var{a},@var{b}}
10147 @item @code{uw1 __MROTLI (uw1, const)}
10148 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
10149 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
10150 @item @code{uw1 __MROTRI (uw1, const)}
10151 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
10152 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
10153 @item @code{sw1 __MSATHS (sw1, sw1)}
10154 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
10155 @tab @code{MSATHS @var{a},@var{b},@var{c}}
10156 @item @code{uw1 __MSATHU (uw1, uw1)}
10157 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
10158 @tab @code{MSATHU @var{a},@var{b},@var{c}}
10159 @item @code{uw1 __MSLLHI (uw1, const)}
10160 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
10161 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
10162 @item @code{sw1 __MSRAHI (sw1, const)}
10163 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
10164 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
10165 @item @code{uw1 __MSRLHI (uw1, const)}
10166 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
10167 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
10168 @item @code{void __MSUBACCS (acc, acc)}
10169 @tab @code{__MSUBACCS (@var{b}, @var{a})}
10170 @tab @code{MSUBACCS @var{a},@var{b}}
10171 @item @code{sw1 __MSUBHSS (sw1, sw1)}
10172 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
10173 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
10174 @item @code{uw1 __MSUBHUS (uw1, uw1)}
10175 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
10176 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
10177 @item @code{void __MTRAP (void)}
10178 @tab @code{__MTRAP ()}
10179 @tab @code{MTRAP}
10180 @item @code{uw2 __MUNPACKH (uw1)}
10181 @tab @code{@var{b} = __MUNPACKH (@var{a})}
10182 @tab @code{MUNPACKH @var{a},@var{b}}
10183 @item @code{uw1 __MWCUT (uw2, uw1)}
10184 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
10185 @tab @code{MWCUT @var{a},@var{b},@var{c}}
10186 @item @code{void __MWTACC (acc, uw1)}
10187 @tab @code{__MWTACC (@var{b}, @var{a})}
10188 @tab @code{MWTACC @var{a},@var{b}}
10189 @item @code{void __MWTACCG (acc, uw1)}
10190 @tab @code{__MWTACCG (@var{b}, @var{a})}
10191 @tab @code{MWTACCG @var{a},@var{b}}
10192 @item @code{uw1 __MXOR (uw1, uw1)}
10193 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
10194 @tab @code{MXOR @var{a},@var{b},@var{c}}
10195 @end multitable
10197 @node Raw read/write Functions
10198 @subsubsection Raw read/write Functions
10200 This sections describes built-in functions related to read and write
10201 instructions to access memory.  These functions generate
10202 @code{membar} instructions to flush the I/O load and stores where
10203 appropriate, as described in Fujitsu's manual described above.
10205 @table @code
10207 @item unsigned char __builtin_read8 (void *@var{data})
10208 @item unsigned short __builtin_read16 (void *@var{data})
10209 @item unsigned long __builtin_read32 (void *@var{data})
10210 @item unsigned long long __builtin_read64 (void *@var{data})
10212 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
10213 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
10214 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
10215 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
10216 @end table
10218 @node Other Built-in Functions
10219 @subsubsection Other Built-in Functions
10221 This section describes built-in functions that are not named after
10222 a specific FR-V instruction.
10224 @table @code
10225 @item sw2 __IACCreadll (iacc @var{reg})
10226 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
10227 for future expansion and must be 0.
10229 @item sw1 __IACCreadl (iacc @var{reg})
10230 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
10231 Other values of @var{reg} are rejected as invalid.
10233 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
10234 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
10235 is reserved for future expansion and must be 0.
10237 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
10238 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
10239 is 1.  Other values of @var{reg} are rejected as invalid.
10241 @item void __data_prefetch0 (const void *@var{x})
10242 Use the @code{dcpl} instruction to load the contents of address @var{x}
10243 into the data cache.
10245 @item void __data_prefetch (const void *@var{x})
10246 Use the @code{nldub} instruction to load the contents of address @var{x}
10247 into the data cache.  The instruction is issued in slot I1@.
10248 @end table
10250 @node X86 Built-in Functions
10251 @subsection X86 Built-in Functions
10253 These built-in functions are available for the i386 and x86-64 family
10254 of computers, depending on the command-line switches used.
10256 If you specify command-line switches such as @option{-msse},
10257 the compiler could use the extended instruction sets even if the built-ins
10258 are not used explicitly in the program.  For this reason, applications
10259 that perform run-time CPU detection must compile separate files for each
10260 supported architecture, using the appropriate flags.  In particular,
10261 the file containing the CPU detection code should be compiled without
10262 these options.
10264 The following machine modes are available for use with MMX built-in functions
10265 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
10266 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
10267 vector of eight 8-bit integers.  Some of the built-in functions operate on
10268 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
10270 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
10271 of two 32-bit floating-point values.
10273 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
10274 floating-point values.  Some instructions use a vector of four 32-bit
10275 integers, these use @code{V4SI}.  Finally, some instructions operate on an
10276 entire vector register, interpreting it as a 128-bit integer, these use mode
10277 @code{TI}.
10279 In 64-bit mode, the x86-64 family of processors uses additional built-in
10280 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
10281 floating point and @code{TC} 128-bit complex floating-point values.
10283 The following floating-point built-in functions are available in 64-bit
10284 mode.  All of them implement the function that is part of the name.
10286 @smallexample
10287 __float128 __builtin_fabsq (__float128)
10288 __float128 __builtin_copysignq (__float128, __float128)
10289 @end smallexample
10291 The following built-in function is always available.
10293 @table @code
10294 @item void __builtin_ia32_pause (void)
10295 Generates the @code{pause} machine instruction with a compiler memory
10296 barrier.
10297 @end table
10299 The following floating-point built-in functions are made available in the
10300 64-bit mode.
10302 @table @code
10303 @item __float128 __builtin_infq (void)
10304 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
10305 @findex __builtin_infq
10307 @item __float128 __builtin_huge_valq (void)
10308 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
10309 @findex __builtin_huge_valq
10310 @end table
10312 The following built-in functions are always available and can be used to
10313 check the target platform type.
10315 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
10316 This function runs the CPU detection code to check the type of CPU and the
10317 features supported.  This built-in function needs to be invoked along with the built-in functions
10318 to check CPU type and features, @code{__builtin_cpu_is} and
10319 @code{__builtin_cpu_supports}, only when used in a function that is
10320 executed before any constructors are called.  The CPU detection code is
10321 automatically executed in a very high priority constructor.
10323 For example, this function has to be used in @code{ifunc} resolvers that
10324 check for CPU type using the built-in functions @code{__builtin_cpu_is}
10325 and @code{__builtin_cpu_supports}, or in constructors on targets that
10326 don't support constructor priority.
10327 @smallexample
10329 static void (*resolve_memcpy (void)) (void)
10331   // ifunc resolvers fire before constructors, explicitly call the init
10332   // function.
10333   __builtin_cpu_init ();
10334   if (__builtin_cpu_supports ("ssse3"))
10335     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
10336   else
10337     return default_memcpy;
10340 void *memcpy (void *, const void *, size_t)
10341      __attribute__ ((ifunc ("resolve_memcpy")));
10342 @end smallexample
10344 @end deftypefn
10346 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
10347 This function returns a positive integer if the run-time CPU
10348 is of type @var{cpuname}
10349 and returns @code{0} otherwise. The following CPU names can be detected:
10351 @table @samp
10352 @item intel
10353 Intel CPU.
10355 @item atom
10356 Intel Atom CPU.
10358 @item core2
10359 Intel Core 2 CPU.
10361 @item corei7
10362 Intel Core i7 CPU.
10364 @item nehalem
10365 Intel Core i7 Nehalem CPU.
10367 @item westmere
10368 Intel Core i7 Westmere CPU.
10370 @item sandybridge
10371 Intel Core i7 Sandy Bridge CPU.
10373 @item amd
10374 AMD CPU.
10376 @item amdfam10h
10377 AMD Family 10h CPU.
10379 @item barcelona
10380 AMD Family 10h Barcelona CPU.
10382 @item shanghai
10383 AMD Family 10h Shanghai CPU.
10385 @item istanbul
10386 AMD Family 10h Istanbul CPU.
10388 @item btver1
10389 AMD Family 14h CPU.
10391 @item amdfam15h
10392 AMD Family 15h CPU.
10394 @item bdver1
10395 AMD Family 15h Bulldozer version 1.
10397 @item bdver2
10398 AMD Family 15h Bulldozer version 2.
10400 @item bdver3
10401 AMD Family 15h Bulldozer version 3.
10403 @item bdver4
10404 AMD Family 15h Bulldozer version 4.
10406 @item btver2
10407 AMD Family 16h CPU.
10408 @end table
10410 Here is an example:
10411 @smallexample
10412 if (__builtin_cpu_is ("corei7"))
10413   @{
10414      do_corei7 (); // Core i7 specific implementation.
10415   @}
10416 else
10417   @{
10418      do_generic (); // Generic implementation.
10419   @}
10420 @end smallexample
10421 @end deftypefn
10423 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
10424 This function returns a positive integer if the run-time CPU
10425 supports @var{feature}
10426 and returns @code{0} otherwise. The following features can be detected:
10428 @table @samp
10429 @item cmov
10430 CMOV instruction.
10431 @item mmx
10432 MMX instructions.
10433 @item popcnt
10434 POPCNT instruction.
10435 @item sse
10436 SSE instructions.
10437 @item sse2
10438 SSE2 instructions.
10439 @item sse3
10440 SSE3 instructions.
10441 @item ssse3
10442 SSSE3 instructions.
10443 @item sse4.1
10444 SSE4.1 instructions.
10445 @item sse4.2
10446 SSE4.2 instructions.
10447 @item avx
10448 AVX instructions.
10449 @item avx2
10450 AVX2 instructions.
10451 @end table
10453 Here is an example:
10454 @smallexample
10455 if (__builtin_cpu_supports ("popcnt"))
10456   @{
10457      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
10458   @}
10459 else
10460   @{
10461      count = generic_countbits (n); //generic implementation.
10462   @}
10463 @end smallexample
10464 @end deftypefn
10467 The following built-in functions are made available by @option{-mmmx}.
10468 All of them generate the machine instruction that is part of the name.
10470 @smallexample
10471 v8qi __builtin_ia32_paddb (v8qi, v8qi)
10472 v4hi __builtin_ia32_paddw (v4hi, v4hi)
10473 v2si __builtin_ia32_paddd (v2si, v2si)
10474 v8qi __builtin_ia32_psubb (v8qi, v8qi)
10475 v4hi __builtin_ia32_psubw (v4hi, v4hi)
10476 v2si __builtin_ia32_psubd (v2si, v2si)
10477 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
10478 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
10479 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
10480 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
10481 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
10482 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
10483 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
10484 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
10485 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
10486 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
10487 di __builtin_ia32_pand (di, di)
10488 di __builtin_ia32_pandn (di,di)
10489 di __builtin_ia32_por (di, di)
10490 di __builtin_ia32_pxor (di, di)
10491 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
10492 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
10493 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
10494 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
10495 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
10496 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
10497 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
10498 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
10499 v2si __builtin_ia32_punpckhdq (v2si, v2si)
10500 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
10501 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
10502 v2si __builtin_ia32_punpckldq (v2si, v2si)
10503 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
10504 v4hi __builtin_ia32_packssdw (v2si, v2si)
10505 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
10507 v4hi __builtin_ia32_psllw (v4hi, v4hi)
10508 v2si __builtin_ia32_pslld (v2si, v2si)
10509 v1di __builtin_ia32_psllq (v1di, v1di)
10510 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
10511 v2si __builtin_ia32_psrld (v2si, v2si)
10512 v1di __builtin_ia32_psrlq (v1di, v1di)
10513 v4hi __builtin_ia32_psraw (v4hi, v4hi)
10514 v2si __builtin_ia32_psrad (v2si, v2si)
10515 v4hi __builtin_ia32_psllwi (v4hi, int)
10516 v2si __builtin_ia32_pslldi (v2si, int)
10517 v1di __builtin_ia32_psllqi (v1di, int)
10518 v4hi __builtin_ia32_psrlwi (v4hi, int)
10519 v2si __builtin_ia32_psrldi (v2si, int)
10520 v1di __builtin_ia32_psrlqi (v1di, int)
10521 v4hi __builtin_ia32_psrawi (v4hi, int)
10522 v2si __builtin_ia32_psradi (v2si, int)
10524 @end smallexample
10526 The following built-in functions are made available either with
10527 @option{-msse}, or with a combination of @option{-m3dnow} and
10528 @option{-march=athlon}.  All of them generate the machine
10529 instruction that is part of the name.
10531 @smallexample
10532 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
10533 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
10534 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
10535 v1di __builtin_ia32_psadbw (v8qi, v8qi)
10536 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
10537 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
10538 v8qi __builtin_ia32_pminub (v8qi, v8qi)
10539 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
10540 int __builtin_ia32_pmovmskb (v8qi)
10541 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
10542 void __builtin_ia32_movntq (di *, di)
10543 void __builtin_ia32_sfence (void)
10544 @end smallexample
10546 The following built-in functions are available when @option{-msse} is used.
10547 All of them generate the machine instruction that is part of the name.
10549 @smallexample
10550 int __builtin_ia32_comieq (v4sf, v4sf)
10551 int __builtin_ia32_comineq (v4sf, v4sf)
10552 int __builtin_ia32_comilt (v4sf, v4sf)
10553 int __builtin_ia32_comile (v4sf, v4sf)
10554 int __builtin_ia32_comigt (v4sf, v4sf)
10555 int __builtin_ia32_comige (v4sf, v4sf)
10556 int __builtin_ia32_ucomieq (v4sf, v4sf)
10557 int __builtin_ia32_ucomineq (v4sf, v4sf)
10558 int __builtin_ia32_ucomilt (v4sf, v4sf)
10559 int __builtin_ia32_ucomile (v4sf, v4sf)
10560 int __builtin_ia32_ucomigt (v4sf, v4sf)
10561 int __builtin_ia32_ucomige (v4sf, v4sf)
10562 v4sf __builtin_ia32_addps (v4sf, v4sf)
10563 v4sf __builtin_ia32_subps (v4sf, v4sf)
10564 v4sf __builtin_ia32_mulps (v4sf, v4sf)
10565 v4sf __builtin_ia32_divps (v4sf, v4sf)
10566 v4sf __builtin_ia32_addss (v4sf, v4sf)
10567 v4sf __builtin_ia32_subss (v4sf, v4sf)
10568 v4sf __builtin_ia32_mulss (v4sf, v4sf)
10569 v4sf __builtin_ia32_divss (v4sf, v4sf)
10570 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
10571 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
10572 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
10573 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
10574 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
10575 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
10576 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
10577 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
10578 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
10579 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
10580 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
10581 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
10582 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
10583 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
10584 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
10585 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
10586 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
10587 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
10588 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
10589 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
10590 v4sf __builtin_ia32_maxps (v4sf, v4sf)
10591 v4sf __builtin_ia32_maxss (v4sf, v4sf)
10592 v4sf __builtin_ia32_minps (v4sf, v4sf)
10593 v4sf __builtin_ia32_minss (v4sf, v4sf)
10594 v4sf __builtin_ia32_andps (v4sf, v4sf)
10595 v4sf __builtin_ia32_andnps (v4sf, v4sf)
10596 v4sf __builtin_ia32_orps (v4sf, v4sf)
10597 v4sf __builtin_ia32_xorps (v4sf, v4sf)
10598 v4sf __builtin_ia32_movss (v4sf, v4sf)
10599 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
10600 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
10601 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
10602 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
10603 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
10604 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
10605 v2si __builtin_ia32_cvtps2pi (v4sf)
10606 int __builtin_ia32_cvtss2si (v4sf)
10607 v2si __builtin_ia32_cvttps2pi (v4sf)
10608 int __builtin_ia32_cvttss2si (v4sf)
10609 v4sf __builtin_ia32_rcpps (v4sf)
10610 v4sf __builtin_ia32_rsqrtps (v4sf)
10611 v4sf __builtin_ia32_sqrtps (v4sf)
10612 v4sf __builtin_ia32_rcpss (v4sf)
10613 v4sf __builtin_ia32_rsqrtss (v4sf)
10614 v4sf __builtin_ia32_sqrtss (v4sf)
10615 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
10616 void __builtin_ia32_movntps (float *, v4sf)
10617 int __builtin_ia32_movmskps (v4sf)
10618 @end smallexample
10620 The following built-in functions are available when @option{-msse} is used.
10622 @table @code
10623 @item v4sf __builtin_ia32_loadups (float *)
10624 Generates the @code{movups} machine instruction as a load from memory.
10625 @item void __builtin_ia32_storeups (float *, v4sf)
10626 Generates the @code{movups} machine instruction as a store to memory.
10627 @item v4sf __builtin_ia32_loadss (float *)
10628 Generates the @code{movss} machine instruction as a load from memory.
10629 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
10630 Generates the @code{movhps} machine instruction as a load from memory.
10631 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
10632 Generates the @code{movlps} machine instruction as a load from memory
10633 @item void __builtin_ia32_storehps (v2sf *, v4sf)
10634 Generates the @code{movhps} machine instruction as a store to memory.
10635 @item void __builtin_ia32_storelps (v2sf *, v4sf)
10636 Generates the @code{movlps} machine instruction as a store to memory.
10637 @end table
10639 The following built-in functions are available when @option{-msse2} is used.
10640 All of them generate the machine instruction that is part of the name.
10642 @smallexample
10643 int __builtin_ia32_comisdeq (v2df, v2df)
10644 int __builtin_ia32_comisdlt (v2df, v2df)
10645 int __builtin_ia32_comisdle (v2df, v2df)
10646 int __builtin_ia32_comisdgt (v2df, v2df)
10647 int __builtin_ia32_comisdge (v2df, v2df)
10648 int __builtin_ia32_comisdneq (v2df, v2df)
10649 int __builtin_ia32_ucomisdeq (v2df, v2df)
10650 int __builtin_ia32_ucomisdlt (v2df, v2df)
10651 int __builtin_ia32_ucomisdle (v2df, v2df)
10652 int __builtin_ia32_ucomisdgt (v2df, v2df)
10653 int __builtin_ia32_ucomisdge (v2df, v2df)
10654 int __builtin_ia32_ucomisdneq (v2df, v2df)
10655 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
10656 v2df __builtin_ia32_cmpltpd (v2df, v2df)
10657 v2df __builtin_ia32_cmplepd (v2df, v2df)
10658 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
10659 v2df __builtin_ia32_cmpgepd (v2df, v2df)
10660 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
10661 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
10662 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
10663 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
10664 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
10665 v2df __builtin_ia32_cmpngepd (v2df, v2df)
10666 v2df __builtin_ia32_cmpordpd (v2df, v2df)
10667 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
10668 v2df __builtin_ia32_cmpltsd (v2df, v2df)
10669 v2df __builtin_ia32_cmplesd (v2df, v2df)
10670 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
10671 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
10672 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
10673 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
10674 v2df __builtin_ia32_cmpordsd (v2df, v2df)
10675 v2di __builtin_ia32_paddq (v2di, v2di)
10676 v2di __builtin_ia32_psubq (v2di, v2di)
10677 v2df __builtin_ia32_addpd (v2df, v2df)
10678 v2df __builtin_ia32_subpd (v2df, v2df)
10679 v2df __builtin_ia32_mulpd (v2df, v2df)
10680 v2df __builtin_ia32_divpd (v2df, v2df)
10681 v2df __builtin_ia32_addsd (v2df, v2df)
10682 v2df __builtin_ia32_subsd (v2df, v2df)
10683 v2df __builtin_ia32_mulsd (v2df, v2df)
10684 v2df __builtin_ia32_divsd (v2df, v2df)
10685 v2df __builtin_ia32_minpd (v2df, v2df)
10686 v2df __builtin_ia32_maxpd (v2df, v2df)
10687 v2df __builtin_ia32_minsd (v2df, v2df)
10688 v2df __builtin_ia32_maxsd (v2df, v2df)
10689 v2df __builtin_ia32_andpd (v2df, v2df)
10690 v2df __builtin_ia32_andnpd (v2df, v2df)
10691 v2df __builtin_ia32_orpd (v2df, v2df)
10692 v2df __builtin_ia32_xorpd (v2df, v2df)
10693 v2df __builtin_ia32_movsd (v2df, v2df)
10694 v2df __builtin_ia32_unpckhpd (v2df, v2df)
10695 v2df __builtin_ia32_unpcklpd (v2df, v2df)
10696 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
10697 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
10698 v4si __builtin_ia32_paddd128 (v4si, v4si)
10699 v2di __builtin_ia32_paddq128 (v2di, v2di)
10700 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
10701 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
10702 v4si __builtin_ia32_psubd128 (v4si, v4si)
10703 v2di __builtin_ia32_psubq128 (v2di, v2di)
10704 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
10705 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
10706 v2di __builtin_ia32_pand128 (v2di, v2di)
10707 v2di __builtin_ia32_pandn128 (v2di, v2di)
10708 v2di __builtin_ia32_por128 (v2di, v2di)
10709 v2di __builtin_ia32_pxor128 (v2di, v2di)
10710 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
10711 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
10712 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
10713 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
10714 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
10715 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
10716 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
10717 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
10718 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
10719 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
10720 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
10721 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
10722 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
10723 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
10724 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
10725 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
10726 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
10727 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
10728 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10729 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10730 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10731 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10732 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10733 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10734 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10735 v2df __builtin_ia32_loadupd (double *)
10736 void __builtin_ia32_storeupd (double *, v2df)
10737 v2df __builtin_ia32_loadhpd (v2df, double const *)
10738 v2df __builtin_ia32_loadlpd (v2df, double const *)
10739 int __builtin_ia32_movmskpd (v2df)
10740 int __builtin_ia32_pmovmskb128 (v16qi)
10741 void __builtin_ia32_movnti (int *, int)
10742 void __builtin_ia32_movnti64 (long long int *, long long int)
10743 void __builtin_ia32_movntpd (double *, v2df)
10744 void __builtin_ia32_movntdq (v2df *, v2df)
10745 v4si __builtin_ia32_pshufd (v4si, int)
10746 v8hi __builtin_ia32_pshuflw (v8hi, int)
10747 v8hi __builtin_ia32_pshufhw (v8hi, int)
10748 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10749 v2df __builtin_ia32_sqrtpd (v2df)
10750 v2df __builtin_ia32_sqrtsd (v2df)
10751 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10752 v2df __builtin_ia32_cvtdq2pd (v4si)
10753 v4sf __builtin_ia32_cvtdq2ps (v4si)
10754 v4si __builtin_ia32_cvtpd2dq (v2df)
10755 v2si __builtin_ia32_cvtpd2pi (v2df)
10756 v4sf __builtin_ia32_cvtpd2ps (v2df)
10757 v4si __builtin_ia32_cvttpd2dq (v2df)
10758 v2si __builtin_ia32_cvttpd2pi (v2df)
10759 v2df __builtin_ia32_cvtpi2pd (v2si)
10760 int __builtin_ia32_cvtsd2si (v2df)
10761 int __builtin_ia32_cvttsd2si (v2df)
10762 long long __builtin_ia32_cvtsd2si64 (v2df)
10763 long long __builtin_ia32_cvttsd2si64 (v2df)
10764 v4si __builtin_ia32_cvtps2dq (v4sf)
10765 v2df __builtin_ia32_cvtps2pd (v4sf)
10766 v4si __builtin_ia32_cvttps2dq (v4sf)
10767 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10768 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10769 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10770 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10771 void __builtin_ia32_clflush (const void *)
10772 void __builtin_ia32_lfence (void)
10773 void __builtin_ia32_mfence (void)
10774 v16qi __builtin_ia32_loaddqu (const char *)
10775 void __builtin_ia32_storedqu (char *, v16qi)
10776 v1di __builtin_ia32_pmuludq (v2si, v2si)
10777 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10778 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10779 v4si __builtin_ia32_pslld128 (v4si, v4si)
10780 v2di __builtin_ia32_psllq128 (v2di, v2di)
10781 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10782 v4si __builtin_ia32_psrld128 (v4si, v4si)
10783 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10784 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10785 v4si __builtin_ia32_psrad128 (v4si, v4si)
10786 v2di __builtin_ia32_pslldqi128 (v2di, int)
10787 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10788 v4si __builtin_ia32_pslldi128 (v4si, int)
10789 v2di __builtin_ia32_psllqi128 (v2di, int)
10790 v2di __builtin_ia32_psrldqi128 (v2di, int)
10791 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10792 v4si __builtin_ia32_psrldi128 (v4si, int)
10793 v2di __builtin_ia32_psrlqi128 (v2di, int)
10794 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10795 v4si __builtin_ia32_psradi128 (v4si, int)
10796 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10797 v2di __builtin_ia32_movq128 (v2di)
10798 @end smallexample
10800 The following built-in functions are available when @option{-msse3} is used.
10801 All of them generate the machine instruction that is part of the name.
10803 @smallexample
10804 v2df __builtin_ia32_addsubpd (v2df, v2df)
10805 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10806 v2df __builtin_ia32_haddpd (v2df, v2df)
10807 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10808 v2df __builtin_ia32_hsubpd (v2df, v2df)
10809 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10810 v16qi __builtin_ia32_lddqu (char const *)
10811 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10812 v4sf __builtin_ia32_movshdup (v4sf)
10813 v4sf __builtin_ia32_movsldup (v4sf)
10814 void __builtin_ia32_mwait (unsigned int, unsigned int)
10815 @end smallexample
10817 The following built-in functions are available when @option{-mssse3} is used.
10818 All of them generate the machine instruction that is part of the name.
10820 @smallexample
10821 v2si __builtin_ia32_phaddd (v2si, v2si)
10822 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10823 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10824 v2si __builtin_ia32_phsubd (v2si, v2si)
10825 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10826 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10827 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10828 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10829 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10830 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10831 v2si __builtin_ia32_psignd (v2si, v2si)
10832 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10833 v1di __builtin_ia32_palignr (v1di, v1di, int)
10834 v8qi __builtin_ia32_pabsb (v8qi)
10835 v2si __builtin_ia32_pabsd (v2si)
10836 v4hi __builtin_ia32_pabsw (v4hi)
10837 @end smallexample
10839 The following built-in functions are available when @option{-mssse3} is used.
10840 All of them generate the machine instruction that is part of the name.
10842 @smallexample
10843 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10844 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10845 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10846 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10847 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10848 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10849 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10850 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10851 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10852 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10853 v4si __builtin_ia32_psignd128 (v4si, v4si)
10854 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10855 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10856 v16qi __builtin_ia32_pabsb128 (v16qi)
10857 v4si __builtin_ia32_pabsd128 (v4si)
10858 v8hi __builtin_ia32_pabsw128 (v8hi)
10859 @end smallexample
10861 The following built-in functions are available when @option{-msse4.1} is
10862 used.  All of them generate the machine instruction that is part of the
10863 name.
10865 @smallexample
10866 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10867 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10868 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10869 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10870 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10871 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10872 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10873 v2di __builtin_ia32_movntdqa (v2di *);
10874 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10875 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10876 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10877 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10878 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10879 v8hi __builtin_ia32_phminposuw128 (v8hi)
10880 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10881 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10882 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10883 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10884 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10885 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10886 v4si __builtin_ia32_pminud128 (v4si, v4si)
10887 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10888 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10889 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10890 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10891 v2di __builtin_ia32_pmovsxdq128 (v4si)
10892 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10893 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10894 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10895 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10896 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10897 v2di __builtin_ia32_pmovzxdq128 (v4si)
10898 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10899 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10900 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10901 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10902 int __builtin_ia32_ptestc128 (v2di, v2di)
10903 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10904 int __builtin_ia32_ptestz128 (v2di, v2di)
10905 v2df __builtin_ia32_roundpd (v2df, const int)
10906 v4sf __builtin_ia32_roundps (v4sf, const int)
10907 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10908 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10909 @end smallexample
10911 The following built-in functions are available when @option{-msse4.1} is
10912 used.
10914 @table @code
10915 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10916 Generates the @code{insertps} machine instruction.
10917 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10918 Generates the @code{pextrb} machine instruction.
10919 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10920 Generates the @code{pinsrb} machine instruction.
10921 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10922 Generates the @code{pinsrd} machine instruction.
10923 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10924 Generates the @code{pinsrq} machine instruction in 64bit mode.
10925 @end table
10927 The following built-in functions are changed to generate new SSE4.1
10928 instructions when @option{-msse4.1} is used.
10930 @table @code
10931 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10932 Generates the @code{extractps} machine instruction.
10933 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10934 Generates the @code{pextrd} machine instruction.
10935 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10936 Generates the @code{pextrq} machine instruction in 64bit mode.
10937 @end table
10939 The following built-in functions are available when @option{-msse4.2} is
10940 used.  All of them generate the machine instruction that is part of the
10941 name.
10943 @smallexample
10944 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10945 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10946 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10947 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10948 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10949 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10950 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10951 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10952 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10953 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10954 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10955 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10956 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10957 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10958 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10959 @end smallexample
10961 The following built-in functions are available when @option{-msse4.2} is
10962 used.
10964 @table @code
10965 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10966 Generates the @code{crc32b} machine instruction.
10967 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10968 Generates the @code{crc32w} machine instruction.
10969 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10970 Generates the @code{crc32l} machine instruction.
10971 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10972 Generates the @code{crc32q} machine instruction.
10973 @end table
10975 The following built-in functions are changed to generate new SSE4.2
10976 instructions when @option{-msse4.2} is used.
10978 @table @code
10979 @item int __builtin_popcount (unsigned int)
10980 Generates the @code{popcntl} machine instruction.
10981 @item int __builtin_popcountl (unsigned long)
10982 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10983 depending on the size of @code{unsigned long}.
10984 @item int __builtin_popcountll (unsigned long long)
10985 Generates the @code{popcntq} machine instruction.
10986 @end table
10988 The following built-in functions are available when @option{-mavx} is
10989 used. All of them generate the machine instruction that is part of the
10990 name.
10992 @smallexample
10993 v4df __builtin_ia32_addpd256 (v4df,v4df)
10994 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10995 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10996 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10997 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10998 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10999 v4df __builtin_ia32_andpd256 (v4df,v4df)
11000 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
11001 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
11002 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
11003 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
11004 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
11005 v2df __builtin_ia32_cmppd (v2df,v2df,int)
11006 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
11007 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
11008 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
11009 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
11010 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
11011 v4df __builtin_ia32_cvtdq2pd256 (v4si)
11012 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
11013 v4si __builtin_ia32_cvtpd2dq256 (v4df)
11014 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
11015 v8si __builtin_ia32_cvtps2dq256 (v8sf)
11016 v4df __builtin_ia32_cvtps2pd256 (v4sf)
11017 v4si __builtin_ia32_cvttpd2dq256 (v4df)
11018 v8si __builtin_ia32_cvttps2dq256 (v8sf)
11019 v4df __builtin_ia32_divpd256 (v4df,v4df)
11020 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
11021 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
11022 v4df __builtin_ia32_haddpd256 (v4df,v4df)
11023 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
11024 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
11025 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
11026 v32qi __builtin_ia32_lddqu256 (pcchar)
11027 v32qi __builtin_ia32_loaddqu256 (pcchar)
11028 v4df __builtin_ia32_loadupd256 (pcdouble)
11029 v8sf __builtin_ia32_loadups256 (pcfloat)
11030 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
11031 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
11032 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
11033 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
11034 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
11035 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
11036 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
11037 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
11038 v4df __builtin_ia32_maxpd256 (v4df,v4df)
11039 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
11040 v4df __builtin_ia32_minpd256 (v4df,v4df)
11041 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
11042 v4df __builtin_ia32_movddup256 (v4df)
11043 int __builtin_ia32_movmskpd256 (v4df)
11044 int __builtin_ia32_movmskps256 (v8sf)
11045 v8sf __builtin_ia32_movshdup256 (v8sf)
11046 v8sf __builtin_ia32_movsldup256 (v8sf)
11047 v4df __builtin_ia32_mulpd256 (v4df,v4df)
11048 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
11049 v4df __builtin_ia32_orpd256 (v4df,v4df)
11050 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
11051 v2df __builtin_ia32_pd_pd256 (v4df)
11052 v4df __builtin_ia32_pd256_pd (v2df)
11053 v4sf __builtin_ia32_ps_ps256 (v8sf)
11054 v8sf __builtin_ia32_ps256_ps (v4sf)
11055 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
11056 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
11057 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
11058 v8sf __builtin_ia32_rcpps256 (v8sf)
11059 v4df __builtin_ia32_roundpd256 (v4df,int)
11060 v8sf __builtin_ia32_roundps256 (v8sf,int)
11061 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
11062 v8sf __builtin_ia32_rsqrtps256 (v8sf)
11063 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
11064 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
11065 v4si __builtin_ia32_si_si256 (v8si)
11066 v8si __builtin_ia32_si256_si (v4si)
11067 v4df __builtin_ia32_sqrtpd256 (v4df)
11068 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
11069 v8sf __builtin_ia32_sqrtps256 (v8sf)
11070 void __builtin_ia32_storedqu256 (pchar,v32qi)
11071 void __builtin_ia32_storeupd256 (pdouble,v4df)
11072 void __builtin_ia32_storeups256 (pfloat,v8sf)
11073 v4df __builtin_ia32_subpd256 (v4df,v4df)
11074 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
11075 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
11076 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
11077 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
11078 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
11079 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
11080 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
11081 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
11082 v4sf __builtin_ia32_vbroadcastss (pcfloat)
11083 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
11084 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
11085 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
11086 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
11087 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
11088 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
11089 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
11090 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
11091 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
11092 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
11093 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
11094 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
11095 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
11096 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
11097 v2df __builtin_ia32_vpermilpd (v2df,int)
11098 v4df __builtin_ia32_vpermilpd256 (v4df,int)
11099 v4sf __builtin_ia32_vpermilps (v4sf,int)
11100 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
11101 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
11102 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
11103 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
11104 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
11105 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
11106 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
11107 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
11108 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
11109 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
11110 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
11111 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
11112 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
11113 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
11114 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
11115 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
11116 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
11117 void __builtin_ia32_vzeroall (void)
11118 void __builtin_ia32_vzeroupper (void)
11119 v4df __builtin_ia32_xorpd256 (v4df,v4df)
11120 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
11121 @end smallexample
11123 The following built-in functions are available when @option{-mavx2} is
11124 used. All of them generate the machine instruction that is part of the
11125 name.
11127 @smallexample
11128 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
11129 v32qi __builtin_ia32_pabsb256 (v32qi)
11130 v16hi __builtin_ia32_pabsw256 (v16hi)
11131 v8si __builtin_ia32_pabsd256 (v8si)
11132 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
11133 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
11134 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
11135 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
11136 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
11137 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
11138 v8si __builtin_ia32_paddd256 (v8si,v8si)
11139 v4di __builtin_ia32_paddq256 (v4di,v4di)
11140 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
11141 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
11142 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
11143 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
11144 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
11145 v4di __builtin_ia32_andsi256 (v4di,v4di)
11146 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
11147 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
11148 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
11149 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
11150 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
11151 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
11152 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
11153 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
11154 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
11155 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
11156 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
11157 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
11158 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
11159 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
11160 v8si __builtin_ia32_phaddd256 (v8si,v8si)
11161 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
11162 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
11163 v8si __builtin_ia32_phsubd256 (v8si,v8si)
11164 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
11165 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
11166 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
11167 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
11168 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
11169 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
11170 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
11171 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
11172 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
11173 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
11174 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
11175 v8si __builtin_ia32_pminsd256 (v8si,v8si)
11176 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
11177 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
11178 v8si __builtin_ia32_pminud256 (v8si,v8si)
11179 int __builtin_ia32_pmovmskb256 (v32qi)
11180 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
11181 v8si __builtin_ia32_pmovsxbd256 (v16qi)
11182 v4di __builtin_ia32_pmovsxbq256 (v16qi)
11183 v8si __builtin_ia32_pmovsxwd256 (v8hi)
11184 v4di __builtin_ia32_pmovsxwq256 (v8hi)
11185 v4di __builtin_ia32_pmovsxdq256 (v4si)
11186 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
11187 v8si __builtin_ia32_pmovzxbd256 (v16qi)
11188 v4di __builtin_ia32_pmovzxbq256 (v16qi)
11189 v8si __builtin_ia32_pmovzxwd256 (v8hi)
11190 v4di __builtin_ia32_pmovzxwq256 (v8hi)
11191 v4di __builtin_ia32_pmovzxdq256 (v4si)
11192 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
11193 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
11194 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
11195 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
11196 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
11197 v8si __builtin_ia32_pmulld256 (v8si,v8si)
11198 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
11199 v4di __builtin_ia32_por256 (v4di,v4di)
11200 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
11201 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
11202 v8si __builtin_ia32_pshufd256 (v8si,int)
11203 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
11204 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
11205 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
11206 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
11207 v8si __builtin_ia32_psignd256 (v8si,v8si)
11208 v4di __builtin_ia32_pslldqi256 (v4di,int)
11209 v16hi __builtin_ia32_psllwi256 (16hi,int)
11210 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
11211 v8si __builtin_ia32_pslldi256 (v8si,int)
11212 v8si __builtin_ia32_pslld256(v8si,v4si)
11213 v4di __builtin_ia32_psllqi256 (v4di,int)
11214 v4di __builtin_ia32_psllq256(v4di,v2di)
11215 v16hi __builtin_ia32_psrawi256 (v16hi,int)
11216 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
11217 v8si __builtin_ia32_psradi256 (v8si,int)
11218 v8si __builtin_ia32_psrad256 (v8si,v4si)
11219 v4di __builtin_ia32_psrldqi256 (v4di, int)
11220 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
11221 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
11222 v8si __builtin_ia32_psrldi256 (v8si,int)
11223 v8si __builtin_ia32_psrld256 (v8si,v4si)
11224 v4di __builtin_ia32_psrlqi256 (v4di,int)
11225 v4di __builtin_ia32_psrlq256(v4di,v2di)
11226 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
11227 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
11228 v8si __builtin_ia32_psubd256 (v8si,v8si)
11229 v4di __builtin_ia32_psubq256 (v4di,v4di)
11230 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
11231 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
11232 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
11233 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
11234 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
11235 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
11236 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
11237 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
11238 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
11239 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
11240 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
11241 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
11242 v4di __builtin_ia32_pxor256 (v4di,v4di)
11243 v4di __builtin_ia32_movntdqa256 (pv4di)
11244 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
11245 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
11246 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
11247 v4di __builtin_ia32_vbroadcastsi256 (v2di)
11248 v4si __builtin_ia32_pblendd128 (v4si,v4si)
11249 v8si __builtin_ia32_pblendd256 (v8si,v8si)
11250 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
11251 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
11252 v8si __builtin_ia32_pbroadcastd256 (v4si)
11253 v4di __builtin_ia32_pbroadcastq256 (v2di)
11254 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
11255 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
11256 v4si __builtin_ia32_pbroadcastd128 (v4si)
11257 v2di __builtin_ia32_pbroadcastq128 (v2di)
11258 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
11259 v4df __builtin_ia32_permdf256 (v4df,int)
11260 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
11261 v4di __builtin_ia32_permdi256 (v4di,int)
11262 v4di __builtin_ia32_permti256 (v4di,v4di,int)
11263 v4di __builtin_ia32_extract128i256 (v4di,int)
11264 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
11265 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
11266 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
11267 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
11268 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
11269 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
11270 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
11271 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
11272 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
11273 v8si __builtin_ia32_psllv8si (v8si,v8si)
11274 v4si __builtin_ia32_psllv4si (v4si,v4si)
11275 v4di __builtin_ia32_psllv4di (v4di,v4di)
11276 v2di __builtin_ia32_psllv2di (v2di,v2di)
11277 v8si __builtin_ia32_psrav8si (v8si,v8si)
11278 v4si __builtin_ia32_psrav4si (v4si,v4si)
11279 v8si __builtin_ia32_psrlv8si (v8si,v8si)
11280 v4si __builtin_ia32_psrlv4si (v4si,v4si)
11281 v4di __builtin_ia32_psrlv4di (v4di,v4di)
11282 v2di __builtin_ia32_psrlv2di (v2di,v2di)
11283 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
11284 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
11285 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
11286 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
11287 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
11288 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
11289 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
11290 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
11291 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
11292 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
11293 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
11294 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
11295 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
11296 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
11297 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
11298 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
11299 @end smallexample
11301 The following built-in functions are available when @option{-maes} is
11302 used.  All of them generate the machine instruction that is part of the
11303 name.
11305 @smallexample
11306 v2di __builtin_ia32_aesenc128 (v2di, v2di)
11307 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
11308 v2di __builtin_ia32_aesdec128 (v2di, v2di)
11309 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
11310 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
11311 v2di __builtin_ia32_aesimc128 (v2di)
11312 @end smallexample
11314 The following built-in function is available when @option{-mpclmul} is
11315 used.
11317 @table @code
11318 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
11319 Generates the @code{pclmulqdq} machine instruction.
11320 @end table
11322 The following built-in function is available when @option{-mfsgsbase} is
11323 used.  All of them generate the machine instruction that is part of the
11324 name.
11326 @smallexample
11327 unsigned int __builtin_ia32_rdfsbase32 (void)
11328 unsigned long long __builtin_ia32_rdfsbase64 (void)
11329 unsigned int __builtin_ia32_rdgsbase32 (void)
11330 unsigned long long __builtin_ia32_rdgsbase64 (void)
11331 void _writefsbase_u32 (unsigned int)
11332 void _writefsbase_u64 (unsigned long long)
11333 void _writegsbase_u32 (unsigned int)
11334 void _writegsbase_u64 (unsigned long long)
11335 @end smallexample
11337 The following built-in function is available when @option{-mrdrnd} is
11338 used.  All of them generate the machine instruction that is part of the
11339 name.
11341 @smallexample
11342 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
11343 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
11344 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
11345 @end smallexample
11347 The following built-in functions are available when @option{-msse4a} is used.
11348 All of them generate the machine instruction that is part of the name.
11350 @smallexample
11351 void __builtin_ia32_movntsd (double *, v2df)
11352 void __builtin_ia32_movntss (float *, v4sf)
11353 v2di __builtin_ia32_extrq  (v2di, v16qi)
11354 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
11355 v2di __builtin_ia32_insertq (v2di, v2di)
11356 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
11357 @end smallexample
11359 The following built-in functions are available when @option{-mxop} is used.
11360 @smallexample
11361 v2df __builtin_ia32_vfrczpd (v2df)
11362 v4sf __builtin_ia32_vfrczps (v4sf)
11363 v2df __builtin_ia32_vfrczsd (v2df, v2df)
11364 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
11365 v4df __builtin_ia32_vfrczpd256 (v4df)
11366 v8sf __builtin_ia32_vfrczps256 (v8sf)
11367 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
11368 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
11369 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
11370 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
11371 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
11372 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
11373 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
11374 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
11375 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
11376 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
11377 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
11378 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
11379 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
11380 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
11381 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11382 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
11383 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
11384 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
11385 v4si __builtin_ia32_vpcomequd (v4si, v4si)
11386 v2di __builtin_ia32_vpcomequq (v2di, v2di)
11387 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
11388 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
11389 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
11390 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
11391 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
11392 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
11393 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
11394 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
11395 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
11396 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
11397 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
11398 v4si __builtin_ia32_vpcomged (v4si, v4si)
11399 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
11400 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
11401 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
11402 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
11403 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
11404 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
11405 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
11406 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
11407 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
11408 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
11409 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
11410 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
11411 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
11412 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
11413 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
11414 v4si __builtin_ia32_vpcomled (v4si, v4si)
11415 v2di __builtin_ia32_vpcomleq (v2di, v2di)
11416 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
11417 v4si __builtin_ia32_vpcomleud (v4si, v4si)
11418 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
11419 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
11420 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
11421 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
11422 v4si __builtin_ia32_vpcomltd (v4si, v4si)
11423 v2di __builtin_ia32_vpcomltq (v2di, v2di)
11424 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
11425 v4si __builtin_ia32_vpcomltud (v4si, v4si)
11426 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
11427 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
11428 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
11429 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
11430 v4si __builtin_ia32_vpcomned (v4si, v4si)
11431 v2di __builtin_ia32_vpcomneq (v2di, v2di)
11432 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
11433 v4si __builtin_ia32_vpcomneud (v4si, v4si)
11434 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
11435 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
11436 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
11437 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
11438 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
11439 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
11440 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
11441 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
11442 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
11443 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
11444 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
11445 v4si __builtin_ia32_vphaddbd (v16qi)
11446 v2di __builtin_ia32_vphaddbq (v16qi)
11447 v8hi __builtin_ia32_vphaddbw (v16qi)
11448 v2di __builtin_ia32_vphadddq (v4si)
11449 v4si __builtin_ia32_vphaddubd (v16qi)
11450 v2di __builtin_ia32_vphaddubq (v16qi)
11451 v8hi __builtin_ia32_vphaddubw (v16qi)
11452 v2di __builtin_ia32_vphaddudq (v4si)
11453 v4si __builtin_ia32_vphadduwd (v8hi)
11454 v2di __builtin_ia32_vphadduwq (v8hi)
11455 v4si __builtin_ia32_vphaddwd (v8hi)
11456 v2di __builtin_ia32_vphaddwq (v8hi)
11457 v8hi __builtin_ia32_vphsubbw (v16qi)
11458 v2di __builtin_ia32_vphsubdq (v4si)
11459 v4si __builtin_ia32_vphsubwd (v8hi)
11460 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
11461 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
11462 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
11463 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
11464 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
11465 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
11466 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
11467 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
11468 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
11469 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
11470 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
11471 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
11472 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
11473 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
11474 v4si __builtin_ia32_vprotd (v4si, v4si)
11475 v2di __builtin_ia32_vprotq (v2di, v2di)
11476 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
11477 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
11478 v4si __builtin_ia32_vpshad (v4si, v4si)
11479 v2di __builtin_ia32_vpshaq (v2di, v2di)
11480 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
11481 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
11482 v4si __builtin_ia32_vpshld (v4si, v4si)
11483 v2di __builtin_ia32_vpshlq (v2di, v2di)
11484 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
11485 @end smallexample
11487 The following built-in functions are available when @option{-mfma4} is used.
11488 All of them generate the machine instruction that is part of the name.
11490 @smallexample
11491 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
11492 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
11493 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
11494 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
11495 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
11496 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
11497 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
11498 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
11499 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
11500 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
11501 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
11502 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
11503 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
11504 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
11505 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
11506 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
11507 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
11508 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
11509 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
11510 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
11511 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
11512 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
11513 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
11514 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
11515 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
11516 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
11517 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
11518 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
11519 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
11520 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
11521 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
11522 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
11524 @end smallexample
11526 The following built-in functions are available when @option{-mlwp} is used.
11528 @smallexample
11529 void __builtin_ia32_llwpcb16 (void *);
11530 void __builtin_ia32_llwpcb32 (void *);
11531 void __builtin_ia32_llwpcb64 (void *);
11532 void * __builtin_ia32_llwpcb16 (void);
11533 void * __builtin_ia32_llwpcb32 (void);
11534 void * __builtin_ia32_llwpcb64 (void);
11535 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
11536 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
11537 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
11538 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
11539 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
11540 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
11541 @end smallexample
11543 The following built-in functions are available when @option{-mbmi} is used.
11544 All of them generate the machine instruction that is part of the name.
11545 @smallexample
11546 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
11547 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
11548 @end smallexample
11550 The following built-in functions are available when @option{-mbmi2} is used.
11551 All of them generate the machine instruction that is part of the name.
11552 @smallexample
11553 unsigned int _bzhi_u32 (unsigned int, unsigned int)
11554 unsigned int _pdep_u32 (unsigned int, unsigned int)
11555 unsigned int _pext_u32 (unsigned int, unsigned int)
11556 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
11557 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
11558 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
11559 @end smallexample
11561 The following built-in functions are available when @option{-mlzcnt} is used.
11562 All of them generate the machine instruction that is part of the name.
11563 @smallexample
11564 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
11565 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
11566 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
11567 @end smallexample
11569 The following built-in functions are available when @option{-mfxsr} is used.
11570 All of them generate the machine instruction that is part of the name.
11571 @smallexample
11572 void __builtin_ia32_fxsave (void *)
11573 void __builtin_ia32_fxrstor (void *)
11574 void __builtin_ia32_fxsave64 (void *)
11575 void __builtin_ia32_fxrstor64 (void *)
11576 @end smallexample
11578 The following built-in functions are available when @option{-mxsave} is used.
11579 All of them generate the machine instruction that is part of the name.
11580 @smallexample
11581 void __builtin_ia32_xsave (void *, long long)
11582 void __builtin_ia32_xrstor (void *, long long)
11583 void __builtin_ia32_xsave64 (void *, long long)
11584 void __builtin_ia32_xrstor64 (void *, long long)
11585 @end smallexample
11587 The following built-in functions are available when @option{-mxsaveopt} is used.
11588 All of them generate the machine instruction that is part of the name.
11589 @smallexample
11590 void __builtin_ia32_xsaveopt (void *, long long)
11591 void __builtin_ia32_xsaveopt64 (void *, long long)
11592 @end smallexample
11594 The following built-in functions are available when @option{-mtbm} is used.
11595 Both of them generate the immediate form of the bextr machine instruction.
11596 @smallexample
11597 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
11598 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
11599 @end smallexample
11602 The following built-in functions are available when @option{-m3dnow} is used.
11603 All of them generate the machine instruction that is part of the name.
11605 @smallexample
11606 void __builtin_ia32_femms (void)
11607 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
11608 v2si __builtin_ia32_pf2id (v2sf)
11609 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
11610 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
11611 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
11612 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
11613 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
11614 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
11615 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
11616 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
11617 v2sf __builtin_ia32_pfrcp (v2sf)
11618 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
11619 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
11620 v2sf __builtin_ia32_pfrsqrt (v2sf)
11621 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
11622 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
11623 v2sf __builtin_ia32_pi2fd (v2si)
11624 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
11625 @end smallexample
11627 The following built-in functions are available when both @option{-m3dnow}
11628 and @option{-march=athlon} are used.  All of them generate the machine
11629 instruction that is part of the name.
11631 @smallexample
11632 v2si __builtin_ia32_pf2iw (v2sf)
11633 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
11634 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
11635 v2sf __builtin_ia32_pi2fw (v2si)
11636 v2sf __builtin_ia32_pswapdsf (v2sf)
11637 v2si __builtin_ia32_pswapdsi (v2si)
11638 @end smallexample
11640 The following built-in functions are available when @option{-mrtm} is used
11641 They are used for restricted transactional memory. These are the internal
11642 low level functions. Normally the functions in 
11643 @ref{X86 transactional memory intrinsics} should be used instead.
11645 @smallexample
11646 int __builtin_ia32_xbegin ()
11647 void __builtin_ia32_xend ()
11648 void __builtin_ia32_xabort (status)
11649 int __builtin_ia32_xtest ()
11650 @end smallexample
11652 @node X86 transactional memory intrinsics
11653 @subsection X86 transaction memory intrinsics
11655 Hardware transactional memory intrinsics for i386. These allow to use
11656 memory transactions with RTM (Restricted Transactional Memory).
11657 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
11658 This support is enabled with the @option{-mrtm} option.
11660 A memory transaction commits all changes to memory in an atomic way,
11661 as visible to other threads. If the transaction fails it is rolled back
11662 and all side effects discarded.
11664 Generally there is no guarantee that a memory transaction ever succeeds
11665 and suitable fallback code always needs to be supplied.
11667 @deftypefn {RTM Function} {unsigned} _xbegin ()
11668 Start a RTM (Restricted Transactional Memory) transaction. 
11669 Returns _XBEGIN_STARTED when the transaction
11670 started successfully (note this is not 0, so the constant has to be 
11671 explicitely tested). When the transaction aborts all side effects
11672 are undone and an abort code is returned. There is no guarantee
11673 any transaction ever succeeds, so there always needs to be a valid
11674 tested fallback path.
11675 @end deftypefn
11677 @smallexample
11678 #include <immintrin.h>
11680 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
11681     ... transaction code...
11682     _xend ();
11683 @} else @{
11684     ... non transactional fallback path...
11686 @end smallexample
11688 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
11690 @table @code
11691 @item _XABORT_EXPLICIT
11692 Transaction explicitely aborted with @code{_xabort}. The parameter passed
11693 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
11694 @item _XABORT_RETRY
11695 Transaction retry is possible.
11696 @item _XABORT_CONFLICT
11697 Transaction abort due to a memory conflict with another thread
11698 @item _XABORT_CAPACITY
11699 Transaction abort due to the transaction using too much memory
11700 @item _XABORT_DEBUG
11701 Transaction abort due to a debug trap
11702 @item _XABORT_NESTED
11703 Transaction abort in a inner nested transaction
11704 @end table
11706 @deftypefn {RTM Function} {void} _xend ()
11707 Commit the current transaction. When no transaction is active this will
11708 fault. All memory side effects of the transactions will become visible
11709 to other threads in an atomic matter.
11710 @end deftypefn
11712 @deftypefn {RTM Function} {int} _xtest ()
11713 Return a value not zero when a transaction is currently active, otherwise 0.
11714 @end deftypefn
11716 @deftypefn {RTM Function} {void} _xabort (status)
11717 Abort the current transaction. When no transaction is active this is a no-op.
11718 status must be a 8bit constant, that is included in the status code returned
11719 by @code{_xbegin}
11720 @end deftypefn
11722 @node MIPS DSP Built-in Functions
11723 @subsection MIPS DSP Built-in Functions
11725 The MIPS DSP Application-Specific Extension (ASE) includes new
11726 instructions that are designed to improve the performance of DSP and
11727 media applications.  It provides instructions that operate on packed
11728 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11730 GCC supports MIPS DSP operations using both the generic
11731 vector extensions (@pxref{Vector Extensions}) and a collection of
11732 MIPS-specific built-in functions.  Both kinds of support are
11733 enabled by the @option{-mdsp} command-line option.
11735 Revision 2 of the ASE was introduced in the second half of 2006.
11736 This revision adds extra instructions to the original ASE, but is
11737 otherwise backwards-compatible with it.  You can select revision 2
11738 using the command-line option @option{-mdspr2}; this option implies
11739 @option{-mdsp}.
11741 The SCOUNT and POS bits of the DSP control register are global.  The
11742 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11743 POS bits.  During optimization, the compiler does not delete these
11744 instructions and it does not delete calls to functions containing
11745 these instructions.
11747 At present, GCC only provides support for operations on 32-bit
11748 vectors.  The vector type associated with 8-bit integer data is
11749 usually called @code{v4i8}, the vector type associated with Q7
11750 is usually called @code{v4q7}, the vector type associated with 16-bit
11751 integer data is usually called @code{v2i16}, and the vector type
11752 associated with Q15 is usually called @code{v2q15}.  They can be
11753 defined in C as follows:
11755 @smallexample
11756 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11757 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11758 typedef short v2i16 __attribute__ ((vector_size(4)));
11759 typedef short v2q15 __attribute__ ((vector_size(4)));
11760 @end smallexample
11762 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11763 initialized in the same way as aggregates.  For example:
11765 @smallexample
11766 v4i8 a = @{1, 2, 3, 4@};
11767 v4i8 b;
11768 b = (v4i8) @{5, 6, 7, 8@};
11770 v2q15 c = @{0x0fcb, 0x3a75@};
11771 v2q15 d;
11772 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11773 @end smallexample
11775 @emph{Note:} The CPU's endianness determines the order in which values
11776 are packed.  On little-endian targets, the first value is the least
11777 significant and the last value is the most significant.  The opposite
11778 order applies to big-endian targets.  For example, the code above
11779 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11780 and @code{4} on big-endian targets.
11782 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11783 representation.  As shown in this example, the integer representation
11784 of a Q7 value can be obtained by multiplying the fractional value by
11785 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
11786 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
11787 @code{0x1.0p31}.
11789 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11790 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
11791 and @code{c} and @code{d} are @code{v2q15} values.
11793 @multitable @columnfractions .50 .50
11794 @item C code @tab MIPS instruction
11795 @item @code{a + b} @tab @code{addu.qb}
11796 @item @code{c + d} @tab @code{addq.ph}
11797 @item @code{a - b} @tab @code{subu.qb}
11798 @item @code{c - d} @tab @code{subq.ph}
11799 @end multitable
11801 The table below lists the @code{v2i16} operation for which
11802 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
11803 @code{v2i16} values.
11805 @multitable @columnfractions .50 .50
11806 @item C code @tab MIPS instruction
11807 @item @code{e * f} @tab @code{mul.ph}
11808 @end multitable
11810 It is easier to describe the DSP built-in functions if we first define
11811 the following types:
11813 @smallexample
11814 typedef int q31;
11815 typedef int i32;
11816 typedef unsigned int ui32;
11817 typedef long long a64;
11818 @end smallexample
11820 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11821 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11822 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
11823 @code{long long}, but we use @code{a64} to indicate values that are
11824 placed in one of the four DSP accumulators (@code{$ac0},
11825 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11827 Also, some built-in functions prefer or require immediate numbers as
11828 parameters, because the corresponding DSP instructions accept both immediate
11829 numbers and register operands, or accept immediate numbers only.  The
11830 immediate parameters are listed as follows.
11832 @smallexample
11833 imm0_3: 0 to 3.
11834 imm0_7: 0 to 7.
11835 imm0_15: 0 to 15.
11836 imm0_31: 0 to 31.
11837 imm0_63: 0 to 63.
11838 imm0_255: 0 to 255.
11839 imm_n32_31: -32 to 31.
11840 imm_n512_511: -512 to 511.
11841 @end smallexample
11843 The following built-in functions map directly to a particular MIPS DSP
11844 instruction.  Please refer to the architecture specification
11845 for details on what each instruction does.
11847 @smallexample
11848 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11849 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11850 q31 __builtin_mips_addq_s_w (q31, q31)
11851 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11852 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11853 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11854 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11855 q31 __builtin_mips_subq_s_w (q31, q31)
11856 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11857 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11858 i32 __builtin_mips_addsc (i32, i32)
11859 i32 __builtin_mips_addwc (i32, i32)
11860 i32 __builtin_mips_modsub (i32, i32)
11861 i32 __builtin_mips_raddu_w_qb (v4i8)
11862 v2q15 __builtin_mips_absq_s_ph (v2q15)
11863 q31 __builtin_mips_absq_s_w (q31)
11864 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11865 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11866 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11867 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11868 q31 __builtin_mips_preceq_w_phl (v2q15)
11869 q31 __builtin_mips_preceq_w_phr (v2q15)
11870 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11871 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11872 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11873 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11874 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11875 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11876 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11877 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11878 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11879 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11880 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11881 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11882 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11883 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11884 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11885 q31 __builtin_mips_shll_s_w (q31, i32)
11886 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11887 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11888 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11889 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11890 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11891 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11892 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11893 q31 __builtin_mips_shra_r_w (q31, i32)
11894 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11895 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11896 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11897 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11898 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11899 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11900 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11901 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11902 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11903 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11904 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11905 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11906 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11907 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11908 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11909 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11910 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11911 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11912 i32 __builtin_mips_bitrev (i32)
11913 i32 __builtin_mips_insv (i32, i32)
11914 v4i8 __builtin_mips_repl_qb (imm0_255)
11915 v4i8 __builtin_mips_repl_qb (i32)
11916 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11917 v2q15 __builtin_mips_repl_ph (i32)
11918 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11919 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11920 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11921 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11922 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11923 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11924 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11925 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11926 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11927 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11928 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11929 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11930 i32 __builtin_mips_extr_w (a64, imm0_31)
11931 i32 __builtin_mips_extr_w (a64, i32)
11932 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11933 i32 __builtin_mips_extr_s_h (a64, i32)
11934 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11935 i32 __builtin_mips_extr_rs_w (a64, i32)
11936 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11937 i32 __builtin_mips_extr_r_w (a64, i32)
11938 i32 __builtin_mips_extp (a64, imm0_31)
11939 i32 __builtin_mips_extp (a64, i32)
11940 i32 __builtin_mips_extpdp (a64, imm0_31)
11941 i32 __builtin_mips_extpdp (a64, i32)
11942 a64 __builtin_mips_shilo (a64, imm_n32_31)
11943 a64 __builtin_mips_shilo (a64, i32)
11944 a64 __builtin_mips_mthlip (a64, i32)
11945 void __builtin_mips_wrdsp (i32, imm0_63)
11946 i32 __builtin_mips_rddsp (imm0_63)
11947 i32 __builtin_mips_lbux (void *, i32)
11948 i32 __builtin_mips_lhx (void *, i32)
11949 i32 __builtin_mips_lwx (void *, i32)
11950 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11951 i32 __builtin_mips_bposge32 (void)
11952 a64 __builtin_mips_madd (a64, i32, i32);
11953 a64 __builtin_mips_maddu (a64, ui32, ui32);
11954 a64 __builtin_mips_msub (a64, i32, i32);
11955 a64 __builtin_mips_msubu (a64, ui32, ui32);
11956 a64 __builtin_mips_mult (i32, i32);
11957 a64 __builtin_mips_multu (ui32, ui32);
11958 @end smallexample
11960 The following built-in functions map directly to a particular MIPS DSP REV 2
11961 instruction.  Please refer to the architecture specification
11962 for details on what each instruction does.
11964 @smallexample
11965 v4q7 __builtin_mips_absq_s_qb (v4q7);
11966 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11967 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11968 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11969 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11970 i32 __builtin_mips_append (i32, i32, imm0_31);
11971 i32 __builtin_mips_balign (i32, i32, imm0_3);
11972 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11973 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11974 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11975 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11976 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11977 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11978 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11979 q31 __builtin_mips_mulq_rs_w (q31, q31);
11980 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11981 q31 __builtin_mips_mulq_s_w (q31, q31);
11982 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11983 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11984 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11985 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11986 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11987 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11988 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11989 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11990 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11991 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11992 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11993 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11994 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11995 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11996 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11997 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11998 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11999 q31 __builtin_mips_addqh_w (q31, q31);
12000 q31 __builtin_mips_addqh_r_w (q31, q31);
12001 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12002 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12003 q31 __builtin_mips_subqh_w (q31, q31);
12004 q31 __builtin_mips_subqh_r_w (q31, q31);
12005 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12006 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12007 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12008 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12009 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12010 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12011 @end smallexample
12014 @node MIPS Paired-Single Support
12015 @subsection MIPS Paired-Single Support
12017 The MIPS64 architecture includes a number of instructions that
12018 operate on pairs of single-precision floating-point values.
12019 Each pair is packed into a 64-bit floating-point register,
12020 with one element being designated the ``upper half'' and
12021 the other being designated the ``lower half''.
12023 GCC supports paired-single operations using both the generic
12024 vector extensions (@pxref{Vector Extensions}) and a collection of
12025 MIPS-specific built-in functions.  Both kinds of support are
12026 enabled by the @option{-mpaired-single} command-line option.
12028 The vector type associated with paired-single values is usually
12029 called @code{v2sf}.  It can be defined in C as follows:
12031 @smallexample
12032 typedef float v2sf __attribute__ ((vector_size (8)));
12033 @end smallexample
12035 @code{v2sf} values are initialized in the same way as aggregates.
12036 For example:
12038 @smallexample
12039 v2sf a = @{1.5, 9.1@};
12040 v2sf b;
12041 float e, f;
12042 b = (v2sf) @{e, f@};
12043 @end smallexample
12045 @emph{Note:} The CPU's endianness determines which value is stored in
12046 the upper half of a register and which value is stored in the lower half.
12047 On little-endian targets, the first value is the lower one and the second
12048 value is the upper one.  The opposite order applies to big-endian targets.
12049 For example, the code above sets the lower half of @code{a} to
12050 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12052 @node MIPS Loongson Built-in Functions
12053 @subsection MIPS Loongson Built-in Functions
12055 GCC provides intrinsics to access the SIMD instructions provided by the
12056 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
12057 available after inclusion of the @code{loongson.h} header file,
12058 operate on the following 64-bit vector types:
12060 @itemize
12061 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12062 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12063 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12064 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12065 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12066 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12067 @end itemize
12069 The intrinsics provided are listed below; each is named after the
12070 machine instruction to which it corresponds, with suffixes added as
12071 appropriate to distinguish intrinsics that expand to the same machine
12072 instruction yet have different argument types.  Refer to the architecture
12073 documentation for a description of the functionality of each
12074 instruction.
12076 @smallexample
12077 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12078 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12079 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12080 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12081 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12082 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12083 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12084 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12085 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12086 uint64_t paddd_u (uint64_t s, uint64_t t);
12087 int64_t paddd_s (int64_t s, int64_t t);
12088 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12089 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12090 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12091 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12092 uint64_t pandn_ud (uint64_t s, uint64_t t);
12093 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12094 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12095 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12096 int64_t pandn_sd (int64_t s, int64_t t);
12097 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12098 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12099 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12100 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12101 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12102 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12103 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12104 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12105 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12106 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12107 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12108 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12109 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12110 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12111 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12112 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12113 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12114 uint16x4_t pextrh_u (uint16x4_t s, int field);
12115 int16x4_t pextrh_s (int16x4_t s, int field);
12116 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12117 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12118 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12119 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12120 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12121 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12122 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12123 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12124 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12125 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12126 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12127 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12128 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12129 uint8x8_t pmovmskb_u (uint8x8_t s);
12130 int8x8_t pmovmskb_s (int8x8_t s);
12131 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12132 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12133 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12134 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12135 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12136 uint16x4_t biadd (uint8x8_t s);
12137 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12138 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12139 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12140 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12141 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12142 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12143 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12144 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12145 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12146 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12147 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12148 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12149 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12150 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12151 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12152 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12153 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12154 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12155 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12156 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12157 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12158 uint64_t psubd_u (uint64_t s, uint64_t t);
12159 int64_t psubd_s (int64_t s, int64_t t);
12160 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12161 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12162 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12163 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12164 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12165 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12166 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12167 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12168 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12169 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12170 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12171 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12172 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12173 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12174 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
12175 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
12176 @end smallexample
12178 @menu
12179 * Paired-Single Arithmetic::
12180 * Paired-Single Built-in Functions::
12181 * MIPS-3D Built-in Functions::
12182 @end menu
12184 @node Paired-Single Arithmetic
12185 @subsubsection Paired-Single Arithmetic
12187 The table below lists the @code{v2sf} operations for which hardware
12188 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
12189 values and @code{x} is an integral value.
12191 @multitable @columnfractions .50 .50
12192 @item C code @tab MIPS instruction
12193 @item @code{a + b} @tab @code{add.ps}
12194 @item @code{a - b} @tab @code{sub.ps}
12195 @item @code{-a} @tab @code{neg.ps}
12196 @item @code{a * b} @tab @code{mul.ps}
12197 @item @code{a * b + c} @tab @code{madd.ps}
12198 @item @code{a * b - c} @tab @code{msub.ps}
12199 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
12200 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
12201 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
12202 @end multitable
12204 Note that the multiply-accumulate instructions can be disabled
12205 using the command-line option @code{-mno-fused-madd}.
12207 @node Paired-Single Built-in Functions
12208 @subsubsection Paired-Single Built-in Functions
12210 The following paired-single functions map directly to a particular
12211 MIPS instruction.  Please refer to the architecture specification
12212 for details on what each instruction does.
12214 @table @code
12215 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
12216 Pair lower lower (@code{pll.ps}).
12218 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
12219 Pair upper lower (@code{pul.ps}).
12221 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
12222 Pair lower upper (@code{plu.ps}).
12224 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
12225 Pair upper upper (@code{puu.ps}).
12227 @item v2sf __builtin_mips_cvt_ps_s (float, float)
12228 Convert pair to paired single (@code{cvt.ps.s}).
12230 @item float __builtin_mips_cvt_s_pl (v2sf)
12231 Convert pair lower to single (@code{cvt.s.pl}).
12233 @item float __builtin_mips_cvt_s_pu (v2sf)
12234 Convert pair upper to single (@code{cvt.s.pu}).
12236 @item v2sf __builtin_mips_abs_ps (v2sf)
12237 Absolute value (@code{abs.ps}).
12239 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12240 Align variable (@code{alnv.ps}).
12242 @emph{Note:} The value of the third parameter must be 0 or 4
12243 modulo 8, otherwise the result is unpredictable.  Please read the
12244 instruction description for details.
12245 @end table
12247 The following multi-instruction functions are also available.
12248 In each case, @var{cond} can be any of the 16 floating-point conditions:
12249 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12250 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12251 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12253 @table @code
12254 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12255 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12256 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12257 @code{movt.ps}/@code{movf.ps}).
12259 The @code{movt} functions return the value @var{x} computed by:
12261 @smallexample
12262 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12263 mov.ps @var{x},@var{c}
12264 movt.ps @var{x},@var{d},@var{cc}
12265 @end smallexample
12267 The @code{movf} functions are similar but use @code{movf.ps} instead
12268 of @code{movt.ps}.
12270 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12271 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12272 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12273 @code{bc1t}/@code{bc1f}).
12275 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12276 and return either the upper or lower half of the result.  For example:
12278 @smallexample
12279 v2sf a, b;
12280 if (__builtin_mips_upper_c_eq_ps (a, b))
12281   upper_halves_are_equal ();
12282 else
12283   upper_halves_are_unequal ();
12285 if (__builtin_mips_lower_c_eq_ps (a, b))
12286   lower_halves_are_equal ();
12287 else
12288   lower_halves_are_unequal ();
12289 @end smallexample
12290 @end table
12292 @node MIPS-3D Built-in Functions
12293 @subsubsection MIPS-3D Built-in Functions
12295 The MIPS-3D Application-Specific Extension (ASE) includes additional
12296 paired-single instructions that are designed to improve the performance
12297 of 3D graphics operations.  Support for these instructions is controlled
12298 by the @option{-mips3d} command-line option.
12300 The functions listed below map directly to a particular MIPS-3D
12301 instruction.  Please refer to the architecture specification for
12302 more details on what each instruction does.
12304 @table @code
12305 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12306 Reduction add (@code{addr.ps}).
12308 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12309 Reduction multiply (@code{mulr.ps}).
12311 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12312 Convert paired single to paired word (@code{cvt.pw.ps}).
12314 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12315 Convert paired word to paired single (@code{cvt.ps.pw}).
12317 @item float __builtin_mips_recip1_s (float)
12318 @itemx double __builtin_mips_recip1_d (double)
12319 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12320 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12322 @item float __builtin_mips_recip2_s (float, float)
12323 @itemx double __builtin_mips_recip2_d (double, double)
12324 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12325 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12327 @item float __builtin_mips_rsqrt1_s (float)
12328 @itemx double __builtin_mips_rsqrt1_d (double)
12329 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12330 Reduced-precision reciprocal square root (sequence step 1)
12331 (@code{rsqrt1.@var{fmt}}).
12333 @item float __builtin_mips_rsqrt2_s (float, float)
12334 @itemx double __builtin_mips_rsqrt2_d (double, double)
12335 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12336 Reduced-precision reciprocal square root (sequence step 2)
12337 (@code{rsqrt2.@var{fmt}}).
12338 @end table
12340 The following multi-instruction functions are also available.
12341 In each case, @var{cond} can be any of the 16 floating-point conditions:
12342 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12343 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12344 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12346 @table @code
12347 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12348 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12349 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12350 @code{bc1t}/@code{bc1f}).
12352 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12353 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12354 For example:
12356 @smallexample
12357 float a, b;
12358 if (__builtin_mips_cabs_eq_s (a, b))
12359   true ();
12360 else
12361   false ();
12362 @end smallexample
12364 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12365 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12366 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12367 @code{bc1t}/@code{bc1f}).
12369 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12370 and return either the upper or lower half of the result.  For example:
12372 @smallexample
12373 v2sf a, b;
12374 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12375   upper_halves_are_equal ();
12376 else
12377   upper_halves_are_unequal ();
12379 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12380   lower_halves_are_equal ();
12381 else
12382   lower_halves_are_unequal ();
12383 @end smallexample
12385 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12386 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12387 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12388 @code{movt.ps}/@code{movf.ps}).
12390 The @code{movt} functions return the value @var{x} computed by:
12392 @smallexample
12393 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12394 mov.ps @var{x},@var{c}
12395 movt.ps @var{x},@var{d},@var{cc}
12396 @end smallexample
12398 The @code{movf} functions are similar but use @code{movf.ps} instead
12399 of @code{movt.ps}.
12401 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12402 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12403 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12404 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12405 Comparison of two paired-single values
12406 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12407 @code{bc1any2t}/@code{bc1any2f}).
12409 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12410 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12411 result is true and the @code{all} forms return true if both results are true.
12412 For example:
12414 @smallexample
12415 v2sf a, b;
12416 if (__builtin_mips_any_c_eq_ps (a, b))
12417   one_is_true ();
12418 else
12419   both_are_false ();
12421 if (__builtin_mips_all_c_eq_ps (a, b))
12422   both_are_true ();
12423 else
12424   one_is_false ();
12425 @end smallexample
12427 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12428 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12429 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12430 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12431 Comparison of four paired-single values
12432 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12433 @code{bc1any4t}/@code{bc1any4f}).
12435 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12436 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12437 The @code{any} forms return true if any of the four results are true
12438 and the @code{all} forms return true if all four results are true.
12439 For example:
12441 @smallexample
12442 v2sf a, b, c, d;
12443 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12444   some_are_true ();
12445 else
12446   all_are_false ();
12448 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12449   all_are_true ();
12450 else
12451   some_are_false ();
12452 @end smallexample
12453 @end table
12455 @node Other MIPS Built-in Functions
12456 @subsection Other MIPS Built-in Functions
12458 GCC provides other MIPS-specific built-in functions:
12460 @table @code
12461 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12462 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12463 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12464 when this function is available.
12465 @end table
12467 @node MSP430 Built-in Functions
12468 @subsection MSP430 Built-in Functions
12470 GCC provides a couple of special builtin functions to aid in the
12471 writing of interrupt handlers in C.
12473 @table @code
12474 @item __bic_SR_register_on_exit (int @var{mask})
12475 This clears the indicated bits in the saved copy of the status register
12476 currently residing on the stack.  This only works inside interrupt
12477 handlers and the changes to the status register will only take affect
12478 once the handler returns.
12480 @item __bis_SR_register_on_exit (int @var{mask})
12481 This sets the indicated bits in the saved copy of the status register
12482 currently residing on the stack.  This only works inside interrupt
12483 handlers and the changes to the status register will only take affect
12484 once the handler returns.
12485 @end table
12487 @node NDS32 Built-in Functions
12488 @subsection NDS32 Built-in Functions
12490 These built-in functions are available for the NDS32 target:
12492 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12493 Insert an ISYNC instruction into the instruction stream where
12494 @var{addr} is an instruction address for serialization.
12495 @end deftypefn
12497 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12498 Insert an ISB instruction into the instruction stream.
12499 @end deftypefn
12501 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12502 Return the content of a system register which is mapped by @var{sr}.
12503 @end deftypefn
12505 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12506 Return the content of a user space register which is mapped by @var{usr}.
12507 @end deftypefn
12509 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12510 Move the @var{value} to a system register which is mapped by @var{sr}.
12511 @end deftypefn
12513 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12514 Move the @var{value} to a user space register which is mapped by @var{usr}.
12515 @end deftypefn
12517 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12518 Enable global interrupt.
12519 @end deftypefn
12521 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12522 Disable global interrupt.
12523 @end deftypefn
12525 @node picoChip Built-in Functions
12526 @subsection picoChip Built-in Functions
12528 GCC provides an interface to selected machine instructions from the
12529 picoChip instruction set.
12531 @table @code
12532 @item int __builtin_sbc (int @var{value})
12533 Sign bit count.  Return the number of consecutive bits in @var{value}
12534 that have the same value as the sign bit.  The result is the number of
12535 leading sign bits minus one, giving the number of redundant sign bits in
12536 @var{value}.
12538 @item int __builtin_byteswap (int @var{value})
12539 Byte swap.  Return the result of swapping the upper and lower bytes of
12540 @var{value}.
12542 @item int __builtin_brev (int @var{value})
12543 Bit reversal.  Return the result of reversing the bits in
12544 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12545 and so on.
12547 @item int __builtin_adds (int @var{x}, int @var{y})
12548 Saturating addition.  Return the result of adding @var{x} and @var{y},
12549 storing the value 32767 if the result overflows.
12551 @item int __builtin_subs (int @var{x}, int @var{y})
12552 Saturating subtraction.  Return the result of subtracting @var{y} from
12553 @var{x}, storing the value @minus{}32768 if the result overflows.
12555 @item void __builtin_halt (void)
12556 Halt.  The processor stops execution.  This built-in is useful for
12557 implementing assertions.
12559 @end table
12561 @node PowerPC Built-in Functions
12562 @subsection PowerPC Built-in Functions
12564 These built-in functions are available for the PowerPC family of
12565 processors:
12566 @smallexample
12567 float __builtin_recipdivf (float, float);
12568 float __builtin_rsqrtf (float);
12569 double __builtin_recipdiv (double, double);
12570 double __builtin_rsqrt (double);
12571 long __builtin_bpermd (long, long);
12572 uint64_t __builtin_ppc_get_timebase ();
12573 unsigned long __builtin_ppc_mftb ();
12574 @end smallexample
12576 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12577 @code{__builtin_rsqrtf} functions generate multiple instructions to
12578 implement the reciprocal sqrt functionality using reciprocal sqrt
12579 estimate instructions.
12581 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12582 functions generate multiple instructions to implement division using
12583 the reciprocal estimate instructions.
12585 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12586 functions generate instructions to read the Time Base Register.  The
12587 @code{__builtin_ppc_get_timebase} function may generate multiple
12588 instructions and always returns the 64 bits of the Time Base Register.
12589 The @code{__builtin_ppc_mftb} function always generates one instruction and
12590 returns the Time Base Register value as an unsigned long, throwing away
12591 the most significant word on 32-bit environments.
12593 @node PowerPC AltiVec/VSX Built-in Functions
12594 @subsection PowerPC AltiVec Built-in Functions
12596 GCC provides an interface for the PowerPC family of processors to access
12597 the AltiVec operations described in Motorola's AltiVec Programming
12598 Interface Manual.  The interface is made available by including
12599 @code{<altivec.h>} and using @option{-maltivec} and
12600 @option{-mabi=altivec}.  The interface supports the following vector
12601 types.
12603 @smallexample
12604 vector unsigned char
12605 vector signed char
12606 vector bool char
12608 vector unsigned short
12609 vector signed short
12610 vector bool short
12611 vector pixel
12613 vector unsigned int
12614 vector signed int
12615 vector bool int
12616 vector float
12617 @end smallexample
12619 If @option{-mvsx} is used the following additional vector types are
12620 implemented.
12622 @smallexample
12623 vector unsigned long
12624 vector signed long
12625 vector double
12626 @end smallexample
12628 The long types are only implemented for 64-bit code generation, and
12629 the long type is only used in the floating point/integer conversion
12630 instructions.
12632 GCC's implementation of the high-level language interface available from
12633 C and C++ code differs from Motorola's documentation in several ways.
12635 @itemize @bullet
12637 @item
12638 A vector constant is a list of constant expressions within curly braces.
12640 @item
12641 A vector initializer requires no cast if the vector constant is of the
12642 same type as the variable it is initializing.
12644 @item
12645 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12646 vector type is the default signedness of the base type.  The default
12647 varies depending on the operating system, so a portable program should
12648 always specify the signedness.
12650 @item
12651 Compiling with @option{-maltivec} adds keywords @code{__vector},
12652 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
12653 @code{bool}.  When compiling ISO C, the context-sensitive substitution
12654 of the keywords @code{vector}, @code{pixel} and @code{bool} is
12655 disabled.  To use them, you must include @code{<altivec.h>} instead.
12657 @item
12658 GCC allows using a @code{typedef} name as the type specifier for a
12659 vector type.
12661 @item
12662 For C, overloaded functions are implemented with macros so the following
12663 does not work:
12665 @smallexample
12666   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12667 @end smallexample
12669 @noindent
12670 Since @code{vec_add} is a macro, the vector constant in the example
12671 is treated as four separate arguments.  Wrap the entire argument in
12672 parentheses for this to work.
12673 @end itemize
12675 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
12676 Internally, GCC uses built-in functions to achieve the functionality in
12677 the aforementioned header file, but they are not supported and are
12678 subject to change without notice.
12680 The following interfaces are supported for the generic and specific
12681 AltiVec operations and the AltiVec predicates.  In cases where there
12682 is a direct mapping between generic and specific operations, only the
12683 generic names are shown here, although the specific operations can also
12684 be used.
12686 Arguments that are documented as @code{const int} require literal
12687 integral values within the range required for that operation.
12689 @smallexample
12690 vector signed char vec_abs (vector signed char);
12691 vector signed short vec_abs (vector signed short);
12692 vector signed int vec_abs (vector signed int);
12693 vector float vec_abs (vector float);
12695 vector signed char vec_abss (vector signed char);
12696 vector signed short vec_abss (vector signed short);
12697 vector signed int vec_abss (vector signed int);
12699 vector signed char vec_add (vector bool char, vector signed char);
12700 vector signed char vec_add (vector signed char, vector bool char);
12701 vector signed char vec_add (vector signed char, vector signed char);
12702 vector unsigned char vec_add (vector bool char, vector unsigned char);
12703 vector unsigned char vec_add (vector unsigned char, vector bool char);
12704 vector unsigned char vec_add (vector unsigned char,
12705                               vector unsigned char);
12706 vector signed short vec_add (vector bool short, vector signed short);
12707 vector signed short vec_add (vector signed short, vector bool short);
12708 vector signed short vec_add (vector signed short, vector signed short);
12709 vector unsigned short vec_add (vector bool short,
12710                                vector unsigned short);
12711 vector unsigned short vec_add (vector unsigned short,
12712                                vector bool short);
12713 vector unsigned short vec_add (vector unsigned short,
12714                                vector unsigned short);
12715 vector signed int vec_add (vector bool int, vector signed int);
12716 vector signed int vec_add (vector signed int, vector bool int);
12717 vector signed int vec_add (vector signed int, vector signed int);
12718 vector unsigned int vec_add (vector bool int, vector unsigned int);
12719 vector unsigned int vec_add (vector unsigned int, vector bool int);
12720 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12721 vector float vec_add (vector float, vector float);
12723 vector float vec_vaddfp (vector float, vector float);
12725 vector signed int vec_vadduwm (vector bool int, vector signed int);
12726 vector signed int vec_vadduwm (vector signed int, vector bool int);
12727 vector signed int vec_vadduwm (vector signed int, vector signed int);
12728 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12729 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12730 vector unsigned int vec_vadduwm (vector unsigned int,
12731                                  vector unsigned int);
12733 vector signed short vec_vadduhm (vector bool short,
12734                                  vector signed short);
12735 vector signed short vec_vadduhm (vector signed short,
12736                                  vector bool short);
12737 vector signed short vec_vadduhm (vector signed short,
12738                                  vector signed short);
12739 vector unsigned short vec_vadduhm (vector bool short,
12740                                    vector unsigned short);
12741 vector unsigned short vec_vadduhm (vector unsigned short,
12742                                    vector bool short);
12743 vector unsigned short vec_vadduhm (vector unsigned short,
12744                                    vector unsigned short);
12746 vector signed char vec_vaddubm (vector bool char, vector signed char);
12747 vector signed char vec_vaddubm (vector signed char, vector bool char);
12748 vector signed char vec_vaddubm (vector signed char, vector signed char);
12749 vector unsigned char vec_vaddubm (vector bool char,
12750                                   vector unsigned char);
12751 vector unsigned char vec_vaddubm (vector unsigned char,
12752                                   vector bool char);
12753 vector unsigned char vec_vaddubm (vector unsigned char,
12754                                   vector unsigned char);
12756 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12758 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12759 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12760 vector unsigned char vec_adds (vector unsigned char,
12761                                vector unsigned char);
12762 vector signed char vec_adds (vector bool char, vector signed char);
12763 vector signed char vec_adds (vector signed char, vector bool char);
12764 vector signed char vec_adds (vector signed char, vector signed char);
12765 vector unsigned short vec_adds (vector bool short,
12766                                 vector unsigned short);
12767 vector unsigned short vec_adds (vector unsigned short,
12768                                 vector bool short);
12769 vector unsigned short vec_adds (vector unsigned short,
12770                                 vector unsigned short);
12771 vector signed short vec_adds (vector bool short, vector signed short);
12772 vector signed short vec_adds (vector signed short, vector bool short);
12773 vector signed short vec_adds (vector signed short, vector signed short);
12774 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12775 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12776 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12777 vector signed int vec_adds (vector bool int, vector signed int);
12778 vector signed int vec_adds (vector signed int, vector bool int);
12779 vector signed int vec_adds (vector signed int, vector signed int);
12781 vector signed int vec_vaddsws (vector bool int, vector signed int);
12782 vector signed int vec_vaddsws (vector signed int, vector bool int);
12783 vector signed int vec_vaddsws (vector signed int, vector signed int);
12785 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12786 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12787 vector unsigned int vec_vadduws (vector unsigned int,
12788                                  vector unsigned int);
12790 vector signed short vec_vaddshs (vector bool short,
12791                                  vector signed short);
12792 vector signed short vec_vaddshs (vector signed short,
12793                                  vector bool short);
12794 vector signed short vec_vaddshs (vector signed short,
12795                                  vector signed short);
12797 vector unsigned short vec_vadduhs (vector bool short,
12798                                    vector unsigned short);
12799 vector unsigned short vec_vadduhs (vector unsigned short,
12800                                    vector bool short);
12801 vector unsigned short vec_vadduhs (vector unsigned short,
12802                                    vector unsigned short);
12804 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12805 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12806 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12808 vector unsigned char vec_vaddubs (vector bool char,
12809                                   vector unsigned char);
12810 vector unsigned char vec_vaddubs (vector unsigned char,
12811                                   vector bool char);
12812 vector unsigned char vec_vaddubs (vector unsigned char,
12813                                   vector unsigned char);
12815 vector float vec_and (vector float, vector float);
12816 vector float vec_and (vector float, vector bool int);
12817 vector float vec_and (vector bool int, vector float);
12818 vector bool int vec_and (vector bool int, vector bool int);
12819 vector signed int vec_and (vector bool int, vector signed int);
12820 vector signed int vec_and (vector signed int, vector bool int);
12821 vector signed int vec_and (vector signed int, vector signed int);
12822 vector unsigned int vec_and (vector bool int, vector unsigned int);
12823 vector unsigned int vec_and (vector unsigned int, vector bool int);
12824 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12825 vector bool short vec_and (vector bool short, vector bool short);
12826 vector signed short vec_and (vector bool short, vector signed short);
12827 vector signed short vec_and (vector signed short, vector bool short);
12828 vector signed short vec_and (vector signed short, vector signed short);
12829 vector unsigned short vec_and (vector bool short,
12830                                vector unsigned short);
12831 vector unsigned short vec_and (vector unsigned short,
12832                                vector bool short);
12833 vector unsigned short vec_and (vector unsigned short,
12834                                vector unsigned short);
12835 vector signed char vec_and (vector bool char, vector signed char);
12836 vector bool char vec_and (vector bool char, vector bool char);
12837 vector signed char vec_and (vector signed char, vector bool char);
12838 vector signed char vec_and (vector signed char, vector signed char);
12839 vector unsigned char vec_and (vector bool char, vector unsigned char);
12840 vector unsigned char vec_and (vector unsigned char, vector bool char);
12841 vector unsigned char vec_and (vector unsigned char,
12842                               vector unsigned char);
12844 vector float vec_andc (vector float, vector float);
12845 vector float vec_andc (vector float, vector bool int);
12846 vector float vec_andc (vector bool int, vector float);
12847 vector bool int vec_andc (vector bool int, vector bool int);
12848 vector signed int vec_andc (vector bool int, vector signed int);
12849 vector signed int vec_andc (vector signed int, vector bool int);
12850 vector signed int vec_andc (vector signed int, vector signed int);
12851 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12852 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12853 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12854 vector bool short vec_andc (vector bool short, vector bool short);
12855 vector signed short vec_andc (vector bool short, vector signed short);
12856 vector signed short vec_andc (vector signed short, vector bool short);
12857 vector signed short vec_andc (vector signed short, vector signed short);
12858 vector unsigned short vec_andc (vector bool short,
12859                                 vector unsigned short);
12860 vector unsigned short vec_andc (vector unsigned short,
12861                                 vector bool short);
12862 vector unsigned short vec_andc (vector unsigned short,
12863                                 vector unsigned short);
12864 vector signed char vec_andc (vector bool char, vector signed char);
12865 vector bool char vec_andc (vector bool char, vector bool char);
12866 vector signed char vec_andc (vector signed char, vector bool char);
12867 vector signed char vec_andc (vector signed char, vector signed char);
12868 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12869 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12870 vector unsigned char vec_andc (vector unsigned char,
12871                                vector unsigned char);
12873 vector unsigned char vec_avg (vector unsigned char,
12874                               vector unsigned char);
12875 vector signed char vec_avg (vector signed char, vector signed char);
12876 vector unsigned short vec_avg (vector unsigned short,
12877                                vector unsigned short);
12878 vector signed short vec_avg (vector signed short, vector signed short);
12879 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12880 vector signed int vec_avg (vector signed int, vector signed int);
12882 vector signed int vec_vavgsw (vector signed int, vector signed int);
12884 vector unsigned int vec_vavguw (vector unsigned int,
12885                                 vector unsigned int);
12887 vector signed short vec_vavgsh (vector signed short,
12888                                 vector signed short);
12890 vector unsigned short vec_vavguh (vector unsigned short,
12891                                   vector unsigned short);
12893 vector signed char vec_vavgsb (vector signed char, vector signed char);
12895 vector unsigned char vec_vavgub (vector unsigned char,
12896                                  vector unsigned char);
12898 vector float vec_copysign (vector float);
12900 vector float vec_ceil (vector float);
12902 vector signed int vec_cmpb (vector float, vector float);
12904 vector bool char vec_cmpeq (vector signed char, vector signed char);
12905 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12906 vector bool short vec_cmpeq (vector signed short, vector signed short);
12907 vector bool short vec_cmpeq (vector unsigned short,
12908                              vector unsigned short);
12909 vector bool int vec_cmpeq (vector signed int, vector signed int);
12910 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12911 vector bool int vec_cmpeq (vector float, vector float);
12913 vector bool int vec_vcmpeqfp (vector float, vector float);
12915 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12916 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12918 vector bool short vec_vcmpequh (vector signed short,
12919                                 vector signed short);
12920 vector bool short vec_vcmpequh (vector unsigned short,
12921                                 vector unsigned short);
12923 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12924 vector bool char vec_vcmpequb (vector unsigned char,
12925                                vector unsigned char);
12927 vector bool int vec_cmpge (vector float, vector float);
12929 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12930 vector bool char vec_cmpgt (vector signed char, vector signed char);
12931 vector bool short vec_cmpgt (vector unsigned short,
12932                              vector unsigned short);
12933 vector bool short vec_cmpgt (vector signed short, vector signed short);
12934 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12935 vector bool int vec_cmpgt (vector signed int, vector signed int);
12936 vector bool int vec_cmpgt (vector float, vector float);
12938 vector bool int vec_vcmpgtfp (vector float, vector float);
12940 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12942 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12944 vector bool short vec_vcmpgtsh (vector signed short,
12945                                 vector signed short);
12947 vector bool short vec_vcmpgtuh (vector unsigned short,
12948                                 vector unsigned short);
12950 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12952 vector bool char vec_vcmpgtub (vector unsigned char,
12953                                vector unsigned char);
12955 vector bool int vec_cmple (vector float, vector float);
12957 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12958 vector bool char vec_cmplt (vector signed char, vector signed char);
12959 vector bool short vec_cmplt (vector unsigned short,
12960                              vector unsigned short);
12961 vector bool short vec_cmplt (vector signed short, vector signed short);
12962 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12963 vector bool int vec_cmplt (vector signed int, vector signed int);
12964 vector bool int vec_cmplt (vector float, vector float);
12966 vector float vec_ctf (vector unsigned int, const int);
12967 vector float vec_ctf (vector signed int, const int);
12969 vector float vec_vcfsx (vector signed int, const int);
12971 vector float vec_vcfux (vector unsigned int, const int);
12973 vector signed int vec_cts (vector float, const int);
12975 vector unsigned int vec_ctu (vector float, const int);
12977 void vec_dss (const int);
12979 void vec_dssall (void);
12981 void vec_dst (const vector unsigned char *, int, const int);
12982 void vec_dst (const vector signed char *, int, const int);
12983 void vec_dst (const vector bool char *, int, const int);
12984 void vec_dst (const vector unsigned short *, int, const int);
12985 void vec_dst (const vector signed short *, int, const int);
12986 void vec_dst (const vector bool short *, int, const int);
12987 void vec_dst (const vector pixel *, int, const int);
12988 void vec_dst (const vector unsigned int *, int, const int);
12989 void vec_dst (const vector signed int *, int, const int);
12990 void vec_dst (const vector bool int *, int, const int);
12991 void vec_dst (const vector float *, int, const int);
12992 void vec_dst (const unsigned char *, int, const int);
12993 void vec_dst (const signed char *, int, const int);
12994 void vec_dst (const unsigned short *, int, const int);
12995 void vec_dst (const short *, int, const int);
12996 void vec_dst (const unsigned int *, int, const int);
12997 void vec_dst (const int *, int, const int);
12998 void vec_dst (const unsigned long *, int, const int);
12999 void vec_dst (const long *, int, const int);
13000 void vec_dst (const float *, int, const int);
13002 void vec_dstst (const vector unsigned char *, int, const int);
13003 void vec_dstst (const vector signed char *, int, const int);
13004 void vec_dstst (const vector bool char *, int, const int);
13005 void vec_dstst (const vector unsigned short *, int, const int);
13006 void vec_dstst (const vector signed short *, int, const int);
13007 void vec_dstst (const vector bool short *, int, const int);
13008 void vec_dstst (const vector pixel *, int, const int);
13009 void vec_dstst (const vector unsigned int *, int, const int);
13010 void vec_dstst (const vector signed int *, int, const int);
13011 void vec_dstst (const vector bool int *, int, const int);
13012 void vec_dstst (const vector float *, int, const int);
13013 void vec_dstst (const unsigned char *, int, const int);
13014 void vec_dstst (const signed char *, int, const int);
13015 void vec_dstst (const unsigned short *, int, const int);
13016 void vec_dstst (const short *, int, const int);
13017 void vec_dstst (const unsigned int *, int, const int);
13018 void vec_dstst (const int *, int, const int);
13019 void vec_dstst (const unsigned long *, int, const int);
13020 void vec_dstst (const long *, int, const int);
13021 void vec_dstst (const float *, int, const int);
13023 void vec_dststt (const vector unsigned char *, int, const int);
13024 void vec_dststt (const vector signed char *, int, const int);
13025 void vec_dststt (const vector bool char *, int, const int);
13026 void vec_dststt (const vector unsigned short *, int, const int);
13027 void vec_dststt (const vector signed short *, int, const int);
13028 void vec_dststt (const vector bool short *, int, const int);
13029 void vec_dststt (const vector pixel *, int, const int);
13030 void vec_dststt (const vector unsigned int *, int, const int);
13031 void vec_dststt (const vector signed int *, int, const int);
13032 void vec_dststt (const vector bool int *, int, const int);
13033 void vec_dststt (const vector float *, int, const int);
13034 void vec_dststt (const unsigned char *, int, const int);
13035 void vec_dststt (const signed char *, int, const int);
13036 void vec_dststt (const unsigned short *, int, const int);
13037 void vec_dststt (const short *, int, const int);
13038 void vec_dststt (const unsigned int *, int, const int);
13039 void vec_dststt (const int *, int, const int);
13040 void vec_dststt (const unsigned long *, int, const int);
13041 void vec_dststt (const long *, int, const int);
13042 void vec_dststt (const float *, int, const int);
13044 void vec_dstt (const vector unsigned char *, int, const int);
13045 void vec_dstt (const vector signed char *, int, const int);
13046 void vec_dstt (const vector bool char *, int, const int);
13047 void vec_dstt (const vector unsigned short *, int, const int);
13048 void vec_dstt (const vector signed short *, int, const int);
13049 void vec_dstt (const vector bool short *, int, const int);
13050 void vec_dstt (const vector pixel *, int, const int);
13051 void vec_dstt (const vector unsigned int *, int, const int);
13052 void vec_dstt (const vector signed int *, int, const int);
13053 void vec_dstt (const vector bool int *, int, const int);
13054 void vec_dstt (const vector float *, int, const int);
13055 void vec_dstt (const unsigned char *, int, const int);
13056 void vec_dstt (const signed char *, int, const int);
13057 void vec_dstt (const unsigned short *, int, const int);
13058 void vec_dstt (const short *, int, const int);
13059 void vec_dstt (const unsigned int *, int, const int);
13060 void vec_dstt (const int *, int, const int);
13061 void vec_dstt (const unsigned long *, int, const int);
13062 void vec_dstt (const long *, int, const int);
13063 void vec_dstt (const float *, int, const int);
13065 vector float vec_expte (vector float);
13067 vector float vec_floor (vector float);
13069 vector float vec_ld (int, const vector float *);
13070 vector float vec_ld (int, const float *);
13071 vector bool int vec_ld (int, const vector bool int *);
13072 vector signed int vec_ld (int, const vector signed int *);
13073 vector signed int vec_ld (int, const int *);
13074 vector signed int vec_ld (int, const long *);
13075 vector unsigned int vec_ld (int, const vector unsigned int *);
13076 vector unsigned int vec_ld (int, const unsigned int *);
13077 vector unsigned int vec_ld (int, const unsigned long *);
13078 vector bool short vec_ld (int, const vector bool short *);
13079 vector pixel vec_ld (int, const vector pixel *);
13080 vector signed short vec_ld (int, const vector signed short *);
13081 vector signed short vec_ld (int, const short *);
13082 vector unsigned short vec_ld (int, const vector unsigned short *);
13083 vector unsigned short vec_ld (int, const unsigned short *);
13084 vector bool char vec_ld (int, const vector bool char *);
13085 vector signed char vec_ld (int, const vector signed char *);
13086 vector signed char vec_ld (int, const signed char *);
13087 vector unsigned char vec_ld (int, const vector unsigned char *);
13088 vector unsigned char vec_ld (int, const unsigned char *);
13090 vector signed char vec_lde (int, const signed char *);
13091 vector unsigned char vec_lde (int, const unsigned char *);
13092 vector signed short vec_lde (int, const short *);
13093 vector unsigned short vec_lde (int, const unsigned short *);
13094 vector float vec_lde (int, const float *);
13095 vector signed int vec_lde (int, const int *);
13096 vector unsigned int vec_lde (int, const unsigned int *);
13097 vector signed int vec_lde (int, const long *);
13098 vector unsigned int vec_lde (int, const unsigned long *);
13100 vector float vec_lvewx (int, float *);
13101 vector signed int vec_lvewx (int, int *);
13102 vector unsigned int vec_lvewx (int, unsigned int *);
13103 vector signed int vec_lvewx (int, long *);
13104 vector unsigned int vec_lvewx (int, unsigned long *);
13106 vector signed short vec_lvehx (int, short *);
13107 vector unsigned short vec_lvehx (int, unsigned short *);
13109 vector signed char vec_lvebx (int, char *);
13110 vector unsigned char vec_lvebx (int, unsigned char *);
13112 vector float vec_ldl (int, const vector float *);
13113 vector float vec_ldl (int, const float *);
13114 vector bool int vec_ldl (int, const vector bool int *);
13115 vector signed int vec_ldl (int, const vector signed int *);
13116 vector signed int vec_ldl (int, const int *);
13117 vector signed int vec_ldl (int, const long *);
13118 vector unsigned int vec_ldl (int, const vector unsigned int *);
13119 vector unsigned int vec_ldl (int, const unsigned int *);
13120 vector unsigned int vec_ldl (int, const unsigned long *);
13121 vector bool short vec_ldl (int, const vector bool short *);
13122 vector pixel vec_ldl (int, const vector pixel *);
13123 vector signed short vec_ldl (int, const vector signed short *);
13124 vector signed short vec_ldl (int, const short *);
13125 vector unsigned short vec_ldl (int, const vector unsigned short *);
13126 vector unsigned short vec_ldl (int, const unsigned short *);
13127 vector bool char vec_ldl (int, const vector bool char *);
13128 vector signed char vec_ldl (int, const vector signed char *);
13129 vector signed char vec_ldl (int, const signed char *);
13130 vector unsigned char vec_ldl (int, const vector unsigned char *);
13131 vector unsigned char vec_ldl (int, const unsigned char *);
13133 vector float vec_loge (vector float);
13135 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
13136 vector unsigned char vec_lvsl (int, const volatile signed char *);
13137 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
13138 vector unsigned char vec_lvsl (int, const volatile short *);
13139 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
13140 vector unsigned char vec_lvsl (int, const volatile int *);
13141 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
13142 vector unsigned char vec_lvsl (int, const volatile long *);
13143 vector unsigned char vec_lvsl (int, const volatile float *);
13145 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
13146 vector unsigned char vec_lvsr (int, const volatile signed char *);
13147 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
13148 vector unsigned char vec_lvsr (int, const volatile short *);
13149 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
13150 vector unsigned char vec_lvsr (int, const volatile int *);
13151 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
13152 vector unsigned char vec_lvsr (int, const volatile long *);
13153 vector unsigned char vec_lvsr (int, const volatile float *);
13155 vector float vec_madd (vector float, vector float, vector float);
13157 vector signed short vec_madds (vector signed short,
13158                                vector signed short,
13159                                vector signed short);
13161 vector unsigned char vec_max (vector bool char, vector unsigned char);
13162 vector unsigned char vec_max (vector unsigned char, vector bool char);
13163 vector unsigned char vec_max (vector unsigned char,
13164                               vector unsigned char);
13165 vector signed char vec_max (vector bool char, vector signed char);
13166 vector signed char vec_max (vector signed char, vector bool char);
13167 vector signed char vec_max (vector signed char, vector signed char);
13168 vector unsigned short vec_max (vector bool short,
13169                                vector unsigned short);
13170 vector unsigned short vec_max (vector unsigned short,
13171                                vector bool short);
13172 vector unsigned short vec_max (vector unsigned short,
13173                                vector unsigned short);
13174 vector signed short vec_max (vector bool short, vector signed short);
13175 vector signed short vec_max (vector signed short, vector bool short);
13176 vector signed short vec_max (vector signed short, vector signed short);
13177 vector unsigned int vec_max (vector bool int, vector unsigned int);
13178 vector unsigned int vec_max (vector unsigned int, vector bool int);
13179 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13180 vector signed int vec_max (vector bool int, vector signed int);
13181 vector signed int vec_max (vector signed int, vector bool int);
13182 vector signed int vec_max (vector signed int, vector signed int);
13183 vector float vec_max (vector float, vector float);
13185 vector float vec_vmaxfp (vector float, vector float);
13187 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13188 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13189 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13191 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13192 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13193 vector unsigned int vec_vmaxuw (vector unsigned int,
13194                                 vector unsigned int);
13196 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13197 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13198 vector signed short vec_vmaxsh (vector signed short,
13199                                 vector signed short);
13201 vector unsigned short vec_vmaxuh (vector bool short,
13202                                   vector unsigned short);
13203 vector unsigned short vec_vmaxuh (vector unsigned short,
13204                                   vector bool short);
13205 vector unsigned short vec_vmaxuh (vector unsigned short,
13206                                   vector unsigned short);
13208 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13209 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13210 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13212 vector unsigned char vec_vmaxub (vector bool char,
13213                                  vector unsigned char);
13214 vector unsigned char vec_vmaxub (vector unsigned char,
13215                                  vector bool char);
13216 vector unsigned char vec_vmaxub (vector unsigned char,
13217                                  vector unsigned char);
13219 vector bool char vec_mergeh (vector bool char, vector bool char);
13220 vector signed char vec_mergeh (vector signed char, vector signed char);
13221 vector unsigned char vec_mergeh (vector unsigned char,
13222                                  vector unsigned char);
13223 vector bool short vec_mergeh (vector bool short, vector bool short);
13224 vector pixel vec_mergeh (vector pixel, vector pixel);
13225 vector signed short vec_mergeh (vector signed short,
13226                                 vector signed short);
13227 vector unsigned short vec_mergeh (vector unsigned short,
13228                                   vector unsigned short);
13229 vector float vec_mergeh (vector float, vector float);
13230 vector bool int vec_mergeh (vector bool int, vector bool int);
13231 vector signed int vec_mergeh (vector signed int, vector signed int);
13232 vector unsigned int vec_mergeh (vector unsigned int,
13233                                 vector unsigned int);
13235 vector float vec_vmrghw (vector float, vector float);
13236 vector bool int vec_vmrghw (vector bool int, vector bool int);
13237 vector signed int vec_vmrghw (vector signed int, vector signed int);
13238 vector unsigned int vec_vmrghw (vector unsigned int,
13239                                 vector unsigned int);
13241 vector bool short vec_vmrghh (vector bool short, vector bool short);
13242 vector signed short vec_vmrghh (vector signed short,
13243                                 vector signed short);
13244 vector unsigned short vec_vmrghh (vector unsigned short,
13245                                   vector unsigned short);
13246 vector pixel vec_vmrghh (vector pixel, vector pixel);
13248 vector bool char vec_vmrghb (vector bool char, vector bool char);
13249 vector signed char vec_vmrghb (vector signed char, vector signed char);
13250 vector unsigned char vec_vmrghb (vector unsigned char,
13251                                  vector unsigned char);
13253 vector bool char vec_mergel (vector bool char, vector bool char);
13254 vector signed char vec_mergel (vector signed char, vector signed char);
13255 vector unsigned char vec_mergel (vector unsigned char,
13256                                  vector unsigned char);
13257 vector bool short vec_mergel (vector bool short, vector bool short);
13258 vector pixel vec_mergel (vector pixel, vector pixel);
13259 vector signed short vec_mergel (vector signed short,
13260                                 vector signed short);
13261 vector unsigned short vec_mergel (vector unsigned short,
13262                                   vector unsigned short);
13263 vector float vec_mergel (vector float, vector float);
13264 vector bool int vec_mergel (vector bool int, vector bool int);
13265 vector signed int vec_mergel (vector signed int, vector signed int);
13266 vector unsigned int vec_mergel (vector unsigned int,
13267                                 vector unsigned int);
13269 vector float vec_vmrglw (vector float, vector float);
13270 vector signed int vec_vmrglw (vector signed int, vector signed int);
13271 vector unsigned int vec_vmrglw (vector unsigned int,
13272                                 vector unsigned int);
13273 vector bool int vec_vmrglw (vector bool int, vector bool int);
13275 vector bool short vec_vmrglh (vector bool short, vector bool short);
13276 vector signed short vec_vmrglh (vector signed short,
13277                                 vector signed short);
13278 vector unsigned short vec_vmrglh (vector unsigned short,
13279                                   vector unsigned short);
13280 vector pixel vec_vmrglh (vector pixel, vector pixel);
13282 vector bool char vec_vmrglb (vector bool char, vector bool char);
13283 vector signed char vec_vmrglb (vector signed char, vector signed char);
13284 vector unsigned char vec_vmrglb (vector unsigned char,
13285                                  vector unsigned char);
13287 vector unsigned short vec_mfvscr (void);
13289 vector unsigned char vec_min (vector bool char, vector unsigned char);
13290 vector unsigned char vec_min (vector unsigned char, vector bool char);
13291 vector unsigned char vec_min (vector unsigned char,
13292                               vector unsigned char);
13293 vector signed char vec_min (vector bool char, vector signed char);
13294 vector signed char vec_min (vector signed char, vector bool char);
13295 vector signed char vec_min (vector signed char, vector signed char);
13296 vector unsigned short vec_min (vector bool short,
13297                                vector unsigned short);
13298 vector unsigned short vec_min (vector unsigned short,
13299                                vector bool short);
13300 vector unsigned short vec_min (vector unsigned short,
13301                                vector unsigned short);
13302 vector signed short vec_min (vector bool short, vector signed short);
13303 vector signed short vec_min (vector signed short, vector bool short);
13304 vector signed short vec_min (vector signed short, vector signed short);
13305 vector unsigned int vec_min (vector bool int, vector unsigned int);
13306 vector unsigned int vec_min (vector unsigned int, vector bool int);
13307 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13308 vector signed int vec_min (vector bool int, vector signed int);
13309 vector signed int vec_min (vector signed int, vector bool int);
13310 vector signed int vec_min (vector signed int, vector signed int);
13311 vector float vec_min (vector float, vector float);
13313 vector float vec_vminfp (vector float, vector float);
13315 vector signed int vec_vminsw (vector bool int, vector signed int);
13316 vector signed int vec_vminsw (vector signed int, vector bool int);
13317 vector signed int vec_vminsw (vector signed int, vector signed int);
13319 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13320 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13321 vector unsigned int vec_vminuw (vector unsigned int,
13322                                 vector unsigned int);
13324 vector signed short vec_vminsh (vector bool short, vector signed short);
13325 vector signed short vec_vminsh (vector signed short, vector bool short);
13326 vector signed short vec_vminsh (vector signed short,
13327                                 vector signed short);
13329 vector unsigned short vec_vminuh (vector bool short,
13330                                   vector unsigned short);
13331 vector unsigned short vec_vminuh (vector unsigned short,
13332                                   vector bool short);
13333 vector unsigned short vec_vminuh (vector unsigned short,
13334                                   vector unsigned short);
13336 vector signed char vec_vminsb (vector bool char, vector signed char);
13337 vector signed char vec_vminsb (vector signed char, vector bool char);
13338 vector signed char vec_vminsb (vector signed char, vector signed char);
13340 vector unsigned char vec_vminub (vector bool char,
13341                                  vector unsigned char);
13342 vector unsigned char vec_vminub (vector unsigned char,
13343                                  vector bool char);
13344 vector unsigned char vec_vminub (vector unsigned char,
13345                                  vector unsigned char);
13347 vector signed short vec_mladd (vector signed short,
13348                                vector signed short,
13349                                vector signed short);
13350 vector signed short vec_mladd (vector signed short,
13351                                vector unsigned short,
13352                                vector unsigned short);
13353 vector signed short vec_mladd (vector unsigned short,
13354                                vector signed short,
13355                                vector signed short);
13356 vector unsigned short vec_mladd (vector unsigned short,
13357                                  vector unsigned short,
13358                                  vector unsigned short);
13360 vector signed short vec_mradds (vector signed short,
13361                                 vector signed short,
13362                                 vector signed short);
13364 vector unsigned int vec_msum (vector unsigned char,
13365                               vector unsigned char,
13366                               vector unsigned int);
13367 vector signed int vec_msum (vector signed char,
13368                             vector unsigned char,
13369                             vector signed int);
13370 vector unsigned int vec_msum (vector unsigned short,
13371                               vector unsigned short,
13372                               vector unsigned int);
13373 vector signed int vec_msum (vector signed short,
13374                             vector signed short,
13375                             vector signed int);
13377 vector signed int vec_vmsumshm (vector signed short,
13378                                 vector signed short,
13379                                 vector signed int);
13381 vector unsigned int vec_vmsumuhm (vector unsigned short,
13382                                   vector unsigned short,
13383                                   vector unsigned int);
13385 vector signed int vec_vmsummbm (vector signed char,
13386                                 vector unsigned char,
13387                                 vector signed int);
13389 vector unsigned int vec_vmsumubm (vector unsigned char,
13390                                   vector unsigned char,
13391                                   vector unsigned int);
13393 vector unsigned int vec_msums (vector unsigned short,
13394                                vector unsigned short,
13395                                vector unsigned int);
13396 vector signed int vec_msums (vector signed short,
13397                              vector signed short,
13398                              vector signed int);
13400 vector signed int vec_vmsumshs (vector signed short,
13401                                 vector signed short,
13402                                 vector signed int);
13404 vector unsigned int vec_vmsumuhs (vector unsigned short,
13405                                   vector unsigned short,
13406                                   vector unsigned int);
13408 void vec_mtvscr (vector signed int);
13409 void vec_mtvscr (vector unsigned int);
13410 void vec_mtvscr (vector bool int);
13411 void vec_mtvscr (vector signed short);
13412 void vec_mtvscr (vector unsigned short);
13413 void vec_mtvscr (vector bool short);
13414 void vec_mtvscr (vector pixel);
13415 void vec_mtvscr (vector signed char);
13416 void vec_mtvscr (vector unsigned char);
13417 void vec_mtvscr (vector bool char);
13419 vector unsigned short vec_mule (vector unsigned char,
13420                                 vector unsigned char);
13421 vector signed short vec_mule (vector signed char,
13422                               vector signed char);
13423 vector unsigned int vec_mule (vector unsigned short,
13424                               vector unsigned short);
13425 vector signed int vec_mule (vector signed short, vector signed short);
13427 vector signed int vec_vmulesh (vector signed short,
13428                                vector signed short);
13430 vector unsigned int vec_vmuleuh (vector unsigned short,
13431                                  vector unsigned short);
13433 vector signed short vec_vmulesb (vector signed char,
13434                                  vector signed char);
13436 vector unsigned short vec_vmuleub (vector unsigned char,
13437                                   vector unsigned char);
13439 vector unsigned short vec_mulo (vector unsigned char,
13440                                 vector unsigned char);
13441 vector signed short vec_mulo (vector signed char, vector signed char);
13442 vector unsigned int vec_mulo (vector unsigned short,
13443                               vector unsigned short);
13444 vector signed int vec_mulo (vector signed short, vector signed short);
13446 vector signed int vec_vmulosh (vector signed short,
13447                                vector signed short);
13449 vector unsigned int vec_vmulouh (vector unsigned short,
13450                                  vector unsigned short);
13452 vector signed short vec_vmulosb (vector signed char,
13453                                  vector signed char);
13455 vector unsigned short vec_vmuloub (vector unsigned char,
13456                                    vector unsigned char);
13458 vector float vec_nmsub (vector float, vector float, vector float);
13460 vector float vec_nor (vector float, vector float);
13461 vector signed int vec_nor (vector signed int, vector signed int);
13462 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13463 vector bool int vec_nor (vector bool int, vector bool int);
13464 vector signed short vec_nor (vector signed short, vector signed short);
13465 vector unsigned short vec_nor (vector unsigned short,
13466                                vector unsigned short);
13467 vector bool short vec_nor (vector bool short, vector bool short);
13468 vector signed char vec_nor (vector signed char, vector signed char);
13469 vector unsigned char vec_nor (vector unsigned char,
13470                               vector unsigned char);
13471 vector bool char vec_nor (vector bool char, vector bool char);
13473 vector float vec_or (vector float, vector float);
13474 vector float vec_or (vector float, vector bool int);
13475 vector float vec_or (vector bool int, vector float);
13476 vector bool int vec_or (vector bool int, vector bool int);
13477 vector signed int vec_or (vector bool int, vector signed int);
13478 vector signed int vec_or (vector signed int, vector bool int);
13479 vector signed int vec_or (vector signed int, vector signed int);
13480 vector unsigned int vec_or (vector bool int, vector unsigned int);
13481 vector unsigned int vec_or (vector unsigned int, vector bool int);
13482 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13483 vector bool short vec_or (vector bool short, vector bool short);
13484 vector signed short vec_or (vector bool short, vector signed short);
13485 vector signed short vec_or (vector signed short, vector bool short);
13486 vector signed short vec_or (vector signed short, vector signed short);
13487 vector unsigned short vec_or (vector bool short, vector unsigned short);
13488 vector unsigned short vec_or (vector unsigned short, vector bool short);
13489 vector unsigned short vec_or (vector unsigned short,
13490                               vector unsigned short);
13491 vector signed char vec_or (vector bool char, vector signed char);
13492 vector bool char vec_or (vector bool char, vector bool char);
13493 vector signed char vec_or (vector signed char, vector bool char);
13494 vector signed char vec_or (vector signed char, vector signed char);
13495 vector unsigned char vec_or (vector bool char, vector unsigned char);
13496 vector unsigned char vec_or (vector unsigned char, vector bool char);
13497 vector unsigned char vec_or (vector unsigned char,
13498                              vector unsigned char);
13500 vector signed char vec_pack (vector signed short, vector signed short);
13501 vector unsigned char vec_pack (vector unsigned short,
13502                                vector unsigned short);
13503 vector bool char vec_pack (vector bool short, vector bool short);
13504 vector signed short vec_pack (vector signed int, vector signed int);
13505 vector unsigned short vec_pack (vector unsigned int,
13506                                 vector unsigned int);
13507 vector bool short vec_pack (vector bool int, vector bool int);
13509 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13510 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13511 vector unsigned short vec_vpkuwum (vector unsigned int,
13512                                    vector unsigned int);
13514 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13515 vector signed char vec_vpkuhum (vector signed short,
13516                                 vector signed short);
13517 vector unsigned char vec_vpkuhum (vector unsigned short,
13518                                   vector unsigned short);
13520 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13522 vector unsigned char vec_packs (vector unsigned short,
13523                                 vector unsigned short);
13524 vector signed char vec_packs (vector signed short, vector signed short);
13525 vector unsigned short vec_packs (vector unsigned int,
13526                                  vector unsigned int);
13527 vector signed short vec_packs (vector signed int, vector signed int);
13529 vector signed short vec_vpkswss (vector signed int, vector signed int);
13531 vector unsigned short vec_vpkuwus (vector unsigned int,
13532                                    vector unsigned int);
13534 vector signed char vec_vpkshss (vector signed short,
13535                                 vector signed short);
13537 vector unsigned char vec_vpkuhus (vector unsigned short,
13538                                   vector unsigned short);
13540 vector unsigned char vec_packsu (vector unsigned short,
13541                                  vector unsigned short);
13542 vector unsigned char vec_packsu (vector signed short,
13543                                  vector signed short);
13544 vector unsigned short vec_packsu (vector unsigned int,
13545                                   vector unsigned int);
13546 vector unsigned short vec_packsu (vector signed int, vector signed int);
13548 vector unsigned short vec_vpkswus (vector signed int,
13549                                    vector signed int);
13551 vector unsigned char vec_vpkshus (vector signed short,
13552                                   vector signed short);
13554 vector float vec_perm (vector float,
13555                        vector float,
13556                        vector unsigned char);
13557 vector signed int vec_perm (vector signed int,
13558                             vector signed int,
13559                             vector unsigned char);
13560 vector unsigned int vec_perm (vector unsigned int,
13561                               vector unsigned int,
13562                               vector unsigned char);
13563 vector bool int vec_perm (vector bool int,
13564                           vector bool int,
13565                           vector unsigned char);
13566 vector signed short vec_perm (vector signed short,
13567                               vector signed short,
13568                               vector unsigned char);
13569 vector unsigned short vec_perm (vector unsigned short,
13570                                 vector unsigned short,
13571                                 vector unsigned char);
13572 vector bool short vec_perm (vector bool short,
13573                             vector bool short,
13574                             vector unsigned char);
13575 vector pixel vec_perm (vector pixel,
13576                        vector pixel,
13577                        vector unsigned char);
13578 vector signed char vec_perm (vector signed char,
13579                              vector signed char,
13580                              vector unsigned char);
13581 vector unsigned char vec_perm (vector unsigned char,
13582                                vector unsigned char,
13583                                vector unsigned char);
13584 vector bool char vec_perm (vector bool char,
13585                            vector bool char,
13586                            vector unsigned char);
13588 vector float vec_re (vector float);
13590 vector signed char vec_rl (vector signed char,
13591                            vector unsigned char);
13592 vector unsigned char vec_rl (vector unsigned char,
13593                              vector unsigned char);
13594 vector signed short vec_rl (vector signed short, vector unsigned short);
13595 vector unsigned short vec_rl (vector unsigned short,
13596                               vector unsigned short);
13597 vector signed int vec_rl (vector signed int, vector unsigned int);
13598 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13600 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13601 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
13603 vector signed short vec_vrlh (vector signed short,
13604                               vector unsigned short);
13605 vector unsigned short vec_vrlh (vector unsigned short,
13606                                 vector unsigned short);
13608 vector signed char vec_vrlb (vector signed char, vector unsigned char);
13609 vector unsigned char vec_vrlb (vector unsigned char,
13610                                vector unsigned char);
13612 vector float vec_round (vector float);
13614 vector float vec_recip (vector float, vector float);
13616 vector float vec_rsqrt (vector float);
13618 vector float vec_rsqrte (vector float);
13620 vector float vec_sel (vector float, vector float, vector bool int);
13621 vector float vec_sel (vector float, vector float, vector unsigned int);
13622 vector signed int vec_sel (vector signed int,
13623                            vector signed int,
13624                            vector bool int);
13625 vector signed int vec_sel (vector signed int,
13626                            vector signed int,
13627                            vector unsigned int);
13628 vector unsigned int vec_sel (vector unsigned int,
13629                              vector unsigned int,
13630                              vector bool int);
13631 vector unsigned int vec_sel (vector unsigned int,
13632                              vector unsigned int,
13633                              vector unsigned int);
13634 vector bool int vec_sel (vector bool int,
13635                          vector bool int,
13636                          vector bool int);
13637 vector bool int vec_sel (vector bool int,
13638                          vector bool int,
13639                          vector unsigned int);
13640 vector signed short vec_sel (vector signed short,
13641                              vector signed short,
13642                              vector bool short);
13643 vector signed short vec_sel (vector signed short,
13644                              vector signed short,
13645                              vector unsigned short);
13646 vector unsigned short vec_sel (vector unsigned short,
13647                                vector unsigned short,
13648                                vector bool short);
13649 vector unsigned short vec_sel (vector unsigned short,
13650                                vector unsigned short,
13651                                vector unsigned short);
13652 vector bool short vec_sel (vector bool short,
13653                            vector bool short,
13654                            vector bool short);
13655 vector bool short vec_sel (vector bool short,
13656                            vector bool short,
13657                            vector unsigned short);
13658 vector signed char vec_sel (vector signed char,
13659                             vector signed char,
13660                             vector bool char);
13661 vector signed char vec_sel (vector signed char,
13662                             vector signed char,
13663                             vector unsigned char);
13664 vector unsigned char vec_sel (vector unsigned char,
13665                               vector unsigned char,
13666                               vector bool char);
13667 vector unsigned char vec_sel (vector unsigned char,
13668                               vector unsigned char,
13669                               vector unsigned char);
13670 vector bool char vec_sel (vector bool char,
13671                           vector bool char,
13672                           vector bool char);
13673 vector bool char vec_sel (vector bool char,
13674                           vector bool char,
13675                           vector unsigned char);
13677 vector signed char vec_sl (vector signed char,
13678                            vector unsigned char);
13679 vector unsigned char vec_sl (vector unsigned char,
13680                              vector unsigned char);
13681 vector signed short vec_sl (vector signed short, vector unsigned short);
13682 vector unsigned short vec_sl (vector unsigned short,
13683                               vector unsigned short);
13684 vector signed int vec_sl (vector signed int, vector unsigned int);
13685 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13687 vector signed int vec_vslw (vector signed int, vector unsigned int);
13688 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13690 vector signed short vec_vslh (vector signed short,
13691                               vector unsigned short);
13692 vector unsigned short vec_vslh (vector unsigned short,
13693                                 vector unsigned short);
13695 vector signed char vec_vslb (vector signed char, vector unsigned char);
13696 vector unsigned char vec_vslb (vector unsigned char,
13697                                vector unsigned char);
13699 vector float vec_sld (vector float, vector float, const int);
13700 vector signed int vec_sld (vector signed int,
13701                            vector signed int,
13702                            const int);
13703 vector unsigned int vec_sld (vector unsigned int,
13704                              vector unsigned int,
13705                              const int);
13706 vector bool int vec_sld (vector bool int,
13707                          vector bool int,
13708                          const int);
13709 vector signed short vec_sld (vector signed short,
13710                              vector signed short,
13711                              const int);
13712 vector unsigned short vec_sld (vector unsigned short,
13713                                vector unsigned short,
13714                                const int);
13715 vector bool short vec_sld (vector bool short,
13716                            vector bool short,
13717                            const int);
13718 vector pixel vec_sld (vector pixel,
13719                       vector pixel,
13720                       const int);
13721 vector signed char vec_sld (vector signed char,
13722                             vector signed char,
13723                             const int);
13724 vector unsigned char vec_sld (vector unsigned char,
13725                               vector unsigned char,
13726                               const int);
13727 vector bool char vec_sld (vector bool char,
13728                           vector bool char,
13729                           const int);
13731 vector signed int vec_sll (vector signed int,
13732                            vector unsigned int);
13733 vector signed int vec_sll (vector signed int,
13734                            vector unsigned short);
13735 vector signed int vec_sll (vector signed int,
13736                            vector unsigned char);
13737 vector unsigned int vec_sll (vector unsigned int,
13738                              vector unsigned int);
13739 vector unsigned int vec_sll (vector unsigned int,
13740                              vector unsigned short);
13741 vector unsigned int vec_sll (vector unsigned int,
13742                              vector unsigned char);
13743 vector bool int vec_sll (vector bool int,
13744                          vector unsigned int);
13745 vector bool int vec_sll (vector bool int,
13746                          vector unsigned short);
13747 vector bool int vec_sll (vector bool int,
13748                          vector unsigned char);
13749 vector signed short vec_sll (vector signed short,
13750                              vector unsigned int);
13751 vector signed short vec_sll (vector signed short,
13752                              vector unsigned short);
13753 vector signed short vec_sll (vector signed short,
13754                              vector unsigned char);
13755 vector unsigned short vec_sll (vector unsigned short,
13756                                vector unsigned int);
13757 vector unsigned short vec_sll (vector unsigned short,
13758                                vector unsigned short);
13759 vector unsigned short vec_sll (vector unsigned short,
13760                                vector unsigned char);
13761 vector bool short vec_sll (vector bool short, vector unsigned int);
13762 vector bool short vec_sll (vector bool short, vector unsigned short);
13763 vector bool short vec_sll (vector bool short, vector unsigned char);
13764 vector pixel vec_sll (vector pixel, vector unsigned int);
13765 vector pixel vec_sll (vector pixel, vector unsigned short);
13766 vector pixel vec_sll (vector pixel, vector unsigned char);
13767 vector signed char vec_sll (vector signed char, vector unsigned int);
13768 vector signed char vec_sll (vector signed char, vector unsigned short);
13769 vector signed char vec_sll (vector signed char, vector unsigned char);
13770 vector unsigned char vec_sll (vector unsigned char,
13771                               vector unsigned int);
13772 vector unsigned char vec_sll (vector unsigned char,
13773                               vector unsigned short);
13774 vector unsigned char vec_sll (vector unsigned char,
13775                               vector unsigned char);
13776 vector bool char vec_sll (vector bool char, vector unsigned int);
13777 vector bool char vec_sll (vector bool char, vector unsigned short);
13778 vector bool char vec_sll (vector bool char, vector unsigned char);
13780 vector float vec_slo (vector float, vector signed char);
13781 vector float vec_slo (vector float, vector unsigned char);
13782 vector signed int vec_slo (vector signed int, vector signed char);
13783 vector signed int vec_slo (vector signed int, vector unsigned char);
13784 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13785 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13786 vector signed short vec_slo (vector signed short, vector signed char);
13787 vector signed short vec_slo (vector signed short, vector unsigned char);
13788 vector unsigned short vec_slo (vector unsigned short,
13789                                vector signed char);
13790 vector unsigned short vec_slo (vector unsigned short,
13791                                vector unsigned char);
13792 vector pixel vec_slo (vector pixel, vector signed char);
13793 vector pixel vec_slo (vector pixel, vector unsigned char);
13794 vector signed char vec_slo (vector signed char, vector signed char);
13795 vector signed char vec_slo (vector signed char, vector unsigned char);
13796 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13797 vector unsigned char vec_slo (vector unsigned char,
13798                               vector unsigned char);
13800 vector signed char vec_splat (vector signed char, const int);
13801 vector unsigned char vec_splat (vector unsigned char, const int);
13802 vector bool char vec_splat (vector bool char, const int);
13803 vector signed short vec_splat (vector signed short, const int);
13804 vector unsigned short vec_splat (vector unsigned short, const int);
13805 vector bool short vec_splat (vector bool short, const int);
13806 vector pixel vec_splat (vector pixel, const int);
13807 vector float vec_splat (vector float, const int);
13808 vector signed int vec_splat (vector signed int, const int);
13809 vector unsigned int vec_splat (vector unsigned int, const int);
13810 vector bool int vec_splat (vector bool int, const int);
13812 vector float vec_vspltw (vector float, const int);
13813 vector signed int vec_vspltw (vector signed int, const int);
13814 vector unsigned int vec_vspltw (vector unsigned int, const int);
13815 vector bool int vec_vspltw (vector bool int, const int);
13817 vector bool short vec_vsplth (vector bool short, const int);
13818 vector signed short vec_vsplth (vector signed short, const int);
13819 vector unsigned short vec_vsplth (vector unsigned short, const int);
13820 vector pixel vec_vsplth (vector pixel, const int);
13822 vector signed char vec_vspltb (vector signed char, const int);
13823 vector unsigned char vec_vspltb (vector unsigned char, const int);
13824 vector bool char vec_vspltb (vector bool char, const int);
13826 vector signed char vec_splat_s8 (const int);
13828 vector signed short vec_splat_s16 (const int);
13830 vector signed int vec_splat_s32 (const int);
13832 vector unsigned char vec_splat_u8 (const int);
13834 vector unsigned short vec_splat_u16 (const int);
13836 vector unsigned int vec_splat_u32 (const int);
13838 vector signed char vec_sr (vector signed char, vector unsigned char);
13839 vector unsigned char vec_sr (vector unsigned char,
13840                              vector unsigned char);
13841 vector signed short vec_sr (vector signed short,
13842                             vector unsigned short);
13843 vector unsigned short vec_sr (vector unsigned short,
13844                               vector unsigned short);
13845 vector signed int vec_sr (vector signed int, vector unsigned int);
13846 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13848 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13849 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13851 vector signed short vec_vsrh (vector signed short,
13852                               vector unsigned short);
13853 vector unsigned short vec_vsrh (vector unsigned short,
13854                                 vector unsigned short);
13856 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13857 vector unsigned char vec_vsrb (vector unsigned char,
13858                                vector unsigned char);
13860 vector signed char vec_sra (vector signed char, vector unsigned char);
13861 vector unsigned char vec_sra (vector unsigned char,
13862                               vector unsigned char);
13863 vector signed short vec_sra (vector signed short,
13864                              vector unsigned short);
13865 vector unsigned short vec_sra (vector unsigned short,
13866                                vector unsigned short);
13867 vector signed int vec_sra (vector signed int, vector unsigned int);
13868 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13870 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13871 vector unsigned int vec_vsraw (vector unsigned int,
13872                                vector unsigned int);
13874 vector signed short vec_vsrah (vector signed short,
13875                                vector unsigned short);
13876 vector unsigned short vec_vsrah (vector unsigned short,
13877                                  vector unsigned short);
13879 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13880 vector unsigned char vec_vsrab (vector unsigned char,
13881                                 vector unsigned char);
13883 vector signed int vec_srl (vector signed int, vector unsigned int);
13884 vector signed int vec_srl (vector signed int, vector unsigned short);
13885 vector signed int vec_srl (vector signed int, vector unsigned char);
13886 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13887 vector unsigned int vec_srl (vector unsigned int,
13888                              vector unsigned short);
13889 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13890 vector bool int vec_srl (vector bool int, vector unsigned int);
13891 vector bool int vec_srl (vector bool int, vector unsigned short);
13892 vector bool int vec_srl (vector bool int, vector unsigned char);
13893 vector signed short vec_srl (vector signed short, vector unsigned int);
13894 vector signed short vec_srl (vector signed short,
13895                              vector unsigned short);
13896 vector signed short vec_srl (vector signed short, vector unsigned char);
13897 vector unsigned short vec_srl (vector unsigned short,
13898                                vector unsigned int);
13899 vector unsigned short vec_srl (vector unsigned short,
13900                                vector unsigned short);
13901 vector unsigned short vec_srl (vector unsigned short,
13902                                vector unsigned char);
13903 vector bool short vec_srl (vector bool short, vector unsigned int);
13904 vector bool short vec_srl (vector bool short, vector unsigned short);
13905 vector bool short vec_srl (vector bool short, vector unsigned char);
13906 vector pixel vec_srl (vector pixel, vector unsigned int);
13907 vector pixel vec_srl (vector pixel, vector unsigned short);
13908 vector pixel vec_srl (vector pixel, vector unsigned char);
13909 vector signed char vec_srl (vector signed char, vector unsigned int);
13910 vector signed char vec_srl (vector signed char, vector unsigned short);
13911 vector signed char vec_srl (vector signed char, vector unsigned char);
13912 vector unsigned char vec_srl (vector unsigned char,
13913                               vector unsigned int);
13914 vector unsigned char vec_srl (vector unsigned char,
13915                               vector unsigned short);
13916 vector unsigned char vec_srl (vector unsigned char,
13917                               vector unsigned char);
13918 vector bool char vec_srl (vector bool char, vector unsigned int);
13919 vector bool char vec_srl (vector bool char, vector unsigned short);
13920 vector bool char vec_srl (vector bool char, vector unsigned char);
13922 vector float vec_sro (vector float, vector signed char);
13923 vector float vec_sro (vector float, vector unsigned char);
13924 vector signed int vec_sro (vector signed int, vector signed char);
13925 vector signed int vec_sro (vector signed int, vector unsigned char);
13926 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13927 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13928 vector signed short vec_sro (vector signed short, vector signed char);
13929 vector signed short vec_sro (vector signed short, vector unsigned char);
13930 vector unsigned short vec_sro (vector unsigned short,
13931                                vector signed char);
13932 vector unsigned short vec_sro (vector unsigned short,
13933                                vector unsigned char);
13934 vector pixel vec_sro (vector pixel, vector signed char);
13935 vector pixel vec_sro (vector pixel, vector unsigned char);
13936 vector signed char vec_sro (vector signed char, vector signed char);
13937 vector signed char vec_sro (vector signed char, vector unsigned char);
13938 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13939 vector unsigned char vec_sro (vector unsigned char,
13940                               vector unsigned char);
13942 void vec_st (vector float, int, vector float *);
13943 void vec_st (vector float, int, float *);
13944 void vec_st (vector signed int, int, vector signed int *);
13945 void vec_st (vector signed int, int, int *);
13946 void vec_st (vector unsigned int, int, vector unsigned int *);
13947 void vec_st (vector unsigned int, int, unsigned int *);
13948 void vec_st (vector bool int, int, vector bool int *);
13949 void vec_st (vector bool int, int, unsigned int *);
13950 void vec_st (vector bool int, int, int *);
13951 void vec_st (vector signed short, int, vector signed short *);
13952 void vec_st (vector signed short, int, short *);
13953 void vec_st (vector unsigned short, int, vector unsigned short *);
13954 void vec_st (vector unsigned short, int, unsigned short *);
13955 void vec_st (vector bool short, int, vector bool short *);
13956 void vec_st (vector bool short, int, unsigned short *);
13957 void vec_st (vector pixel, int, vector pixel *);
13958 void vec_st (vector pixel, int, unsigned short *);
13959 void vec_st (vector pixel, int, short *);
13960 void vec_st (vector bool short, int, short *);
13961 void vec_st (vector signed char, int, vector signed char *);
13962 void vec_st (vector signed char, int, signed char *);
13963 void vec_st (vector unsigned char, int, vector unsigned char *);
13964 void vec_st (vector unsigned char, int, unsigned char *);
13965 void vec_st (vector bool char, int, vector bool char *);
13966 void vec_st (vector bool char, int, unsigned char *);
13967 void vec_st (vector bool char, int, signed char *);
13969 void vec_ste (vector signed char, int, signed char *);
13970 void vec_ste (vector unsigned char, int, unsigned char *);
13971 void vec_ste (vector bool char, int, signed char *);
13972 void vec_ste (vector bool char, int, unsigned char *);
13973 void vec_ste (vector signed short, int, short *);
13974 void vec_ste (vector unsigned short, int, unsigned short *);
13975 void vec_ste (vector bool short, int, short *);
13976 void vec_ste (vector bool short, int, unsigned short *);
13977 void vec_ste (vector pixel, int, short *);
13978 void vec_ste (vector pixel, int, unsigned short *);
13979 void vec_ste (vector float, int, float *);
13980 void vec_ste (vector signed int, int, int *);
13981 void vec_ste (vector unsigned int, int, unsigned int *);
13982 void vec_ste (vector bool int, int, int *);
13983 void vec_ste (vector bool int, int, unsigned int *);
13985 void vec_stvewx (vector float, int, float *);
13986 void vec_stvewx (vector signed int, int, int *);
13987 void vec_stvewx (vector unsigned int, int, unsigned int *);
13988 void vec_stvewx (vector bool int, int, int *);
13989 void vec_stvewx (vector bool int, int, unsigned int *);
13991 void vec_stvehx (vector signed short, int, short *);
13992 void vec_stvehx (vector unsigned short, int, unsigned short *);
13993 void vec_stvehx (vector bool short, int, short *);
13994 void vec_stvehx (vector bool short, int, unsigned short *);
13995 void vec_stvehx (vector pixel, int, short *);
13996 void vec_stvehx (vector pixel, int, unsigned short *);
13998 void vec_stvebx (vector signed char, int, signed char *);
13999 void vec_stvebx (vector unsigned char, int, unsigned char *);
14000 void vec_stvebx (vector bool char, int, signed char *);
14001 void vec_stvebx (vector bool char, int, unsigned char *);
14003 void vec_stl (vector float, int, vector float *);
14004 void vec_stl (vector float, int, float *);
14005 void vec_stl (vector signed int, int, vector signed int *);
14006 void vec_stl (vector signed int, int, int *);
14007 void vec_stl (vector unsigned int, int, vector unsigned int *);
14008 void vec_stl (vector unsigned int, int, unsigned int *);
14009 void vec_stl (vector bool int, int, vector bool int *);
14010 void vec_stl (vector bool int, int, unsigned int *);
14011 void vec_stl (vector bool int, int, int *);
14012 void vec_stl (vector signed short, int, vector signed short *);
14013 void vec_stl (vector signed short, int, short *);
14014 void vec_stl (vector unsigned short, int, vector unsigned short *);
14015 void vec_stl (vector unsigned short, int, unsigned short *);
14016 void vec_stl (vector bool short, int, vector bool short *);
14017 void vec_stl (vector bool short, int, unsigned short *);
14018 void vec_stl (vector bool short, int, short *);
14019 void vec_stl (vector pixel, int, vector pixel *);
14020 void vec_stl (vector pixel, int, unsigned short *);
14021 void vec_stl (vector pixel, int, short *);
14022 void vec_stl (vector signed char, int, vector signed char *);
14023 void vec_stl (vector signed char, int, signed char *);
14024 void vec_stl (vector unsigned char, int, vector unsigned char *);
14025 void vec_stl (vector unsigned char, int, unsigned char *);
14026 void vec_stl (vector bool char, int, vector bool char *);
14027 void vec_stl (vector bool char, int, unsigned char *);
14028 void vec_stl (vector bool char, int, signed char *);
14030 vector signed char vec_sub (vector bool char, vector signed char);
14031 vector signed char vec_sub (vector signed char, vector bool char);
14032 vector signed char vec_sub (vector signed char, vector signed char);
14033 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14034 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14035 vector unsigned char vec_sub (vector unsigned char,
14036                               vector unsigned char);
14037 vector signed short vec_sub (vector bool short, vector signed short);
14038 vector signed short vec_sub (vector signed short, vector bool short);
14039 vector signed short vec_sub (vector signed short, vector signed short);
14040 vector unsigned short vec_sub (vector bool short,
14041                                vector unsigned short);
14042 vector unsigned short vec_sub (vector unsigned short,
14043                                vector bool short);
14044 vector unsigned short vec_sub (vector unsigned short,
14045                                vector unsigned short);
14046 vector signed int vec_sub (vector bool int, vector signed int);
14047 vector signed int vec_sub (vector signed int, vector bool int);
14048 vector signed int vec_sub (vector signed int, vector signed int);
14049 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14050 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14051 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14052 vector float vec_sub (vector float, vector float);
14054 vector float vec_vsubfp (vector float, vector float);
14056 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14057 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14058 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14059 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14060 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14061 vector unsigned int vec_vsubuwm (vector unsigned int,
14062                                  vector unsigned int);
14064 vector signed short vec_vsubuhm (vector bool short,
14065                                  vector signed short);
14066 vector signed short vec_vsubuhm (vector signed short,
14067                                  vector bool short);
14068 vector signed short vec_vsubuhm (vector signed short,
14069                                  vector signed short);
14070 vector unsigned short vec_vsubuhm (vector bool short,
14071                                    vector unsigned short);
14072 vector unsigned short vec_vsubuhm (vector unsigned short,
14073                                    vector bool short);
14074 vector unsigned short vec_vsubuhm (vector unsigned short,
14075                                    vector unsigned short);
14077 vector signed char vec_vsububm (vector bool char, vector signed char);
14078 vector signed char vec_vsububm (vector signed char, vector bool char);
14079 vector signed char vec_vsububm (vector signed char, vector signed char);
14080 vector unsigned char vec_vsububm (vector bool char,
14081                                   vector unsigned char);
14082 vector unsigned char vec_vsububm (vector unsigned char,
14083                                   vector bool char);
14084 vector unsigned char vec_vsububm (vector unsigned char,
14085                                   vector unsigned char);
14087 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14089 vector unsigned char vec_subs (vector bool char, vector unsigned char);
14090 vector unsigned char vec_subs (vector unsigned char, vector bool char);
14091 vector unsigned char vec_subs (vector unsigned char,
14092                                vector unsigned char);
14093 vector signed char vec_subs (vector bool char, vector signed char);
14094 vector signed char vec_subs (vector signed char, vector bool char);
14095 vector signed char vec_subs (vector signed char, vector signed char);
14096 vector unsigned short vec_subs (vector bool short,
14097                                 vector unsigned short);
14098 vector unsigned short vec_subs (vector unsigned short,
14099                                 vector bool short);
14100 vector unsigned short vec_subs (vector unsigned short,
14101                                 vector unsigned short);
14102 vector signed short vec_subs (vector bool short, vector signed short);
14103 vector signed short vec_subs (vector signed short, vector bool short);
14104 vector signed short vec_subs (vector signed short, vector signed short);
14105 vector unsigned int vec_subs (vector bool int, vector unsigned int);
14106 vector unsigned int vec_subs (vector unsigned int, vector bool int);
14107 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
14108 vector signed int vec_subs (vector bool int, vector signed int);
14109 vector signed int vec_subs (vector signed int, vector bool int);
14110 vector signed int vec_subs (vector signed int, vector signed int);
14112 vector signed int vec_vsubsws (vector bool int, vector signed int);
14113 vector signed int vec_vsubsws (vector signed int, vector bool int);
14114 vector signed int vec_vsubsws (vector signed int, vector signed int);
14116 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
14117 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
14118 vector unsigned int vec_vsubuws (vector unsigned int,
14119                                  vector unsigned int);
14121 vector signed short vec_vsubshs (vector bool short,
14122                                  vector signed short);
14123 vector signed short vec_vsubshs (vector signed short,
14124                                  vector bool short);
14125 vector signed short vec_vsubshs (vector signed short,
14126                                  vector signed short);
14128 vector unsigned short vec_vsubuhs (vector bool short,
14129                                    vector unsigned short);
14130 vector unsigned short vec_vsubuhs (vector unsigned short,
14131                                    vector bool short);
14132 vector unsigned short vec_vsubuhs (vector unsigned short,
14133                                    vector unsigned short);
14135 vector signed char vec_vsubsbs (vector bool char, vector signed char);
14136 vector signed char vec_vsubsbs (vector signed char, vector bool char);
14137 vector signed char vec_vsubsbs (vector signed char, vector signed char);
14139 vector unsigned char vec_vsububs (vector bool char,
14140                                   vector unsigned char);
14141 vector unsigned char vec_vsububs (vector unsigned char,
14142                                   vector bool char);
14143 vector unsigned char vec_vsububs (vector unsigned char,
14144                                   vector unsigned char);
14146 vector unsigned int vec_sum4s (vector unsigned char,
14147                                vector unsigned int);
14148 vector signed int vec_sum4s (vector signed char, vector signed int);
14149 vector signed int vec_sum4s (vector signed short, vector signed int);
14151 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14153 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14155 vector unsigned int vec_vsum4ubs (vector unsigned char,
14156                                   vector unsigned int);
14158 vector signed int vec_sum2s (vector signed int, vector signed int);
14160 vector signed int vec_sums (vector signed int, vector signed int);
14162 vector float vec_trunc (vector float);
14164 vector signed short vec_unpackh (vector signed char);
14165 vector bool short vec_unpackh (vector bool char);
14166 vector signed int vec_unpackh (vector signed short);
14167 vector bool int vec_unpackh (vector bool short);
14168 vector unsigned int vec_unpackh (vector pixel);
14170 vector bool int vec_vupkhsh (vector bool short);
14171 vector signed int vec_vupkhsh (vector signed short);
14173 vector unsigned int vec_vupkhpx (vector pixel);
14175 vector bool short vec_vupkhsb (vector bool char);
14176 vector signed short vec_vupkhsb (vector signed char);
14178 vector signed short vec_unpackl (vector signed char);
14179 vector bool short vec_unpackl (vector bool char);
14180 vector unsigned int vec_unpackl (vector pixel);
14181 vector signed int vec_unpackl (vector signed short);
14182 vector bool int vec_unpackl (vector bool short);
14184 vector unsigned int vec_vupklpx (vector pixel);
14186 vector bool int vec_vupklsh (vector bool short);
14187 vector signed int vec_vupklsh (vector signed short);
14189 vector bool short vec_vupklsb (vector bool char);
14190 vector signed short vec_vupklsb (vector signed char);
14192 vector float vec_xor (vector float, vector float);
14193 vector float vec_xor (vector float, vector bool int);
14194 vector float vec_xor (vector bool int, vector float);
14195 vector bool int vec_xor (vector bool int, vector bool int);
14196 vector signed int vec_xor (vector bool int, vector signed int);
14197 vector signed int vec_xor (vector signed int, vector bool int);
14198 vector signed int vec_xor (vector signed int, vector signed int);
14199 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14200 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14201 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14202 vector bool short vec_xor (vector bool short, vector bool short);
14203 vector signed short vec_xor (vector bool short, vector signed short);
14204 vector signed short vec_xor (vector signed short, vector bool short);
14205 vector signed short vec_xor (vector signed short, vector signed short);
14206 vector unsigned short vec_xor (vector bool short,
14207                                vector unsigned short);
14208 vector unsigned short vec_xor (vector unsigned short,
14209                                vector bool short);
14210 vector unsigned short vec_xor (vector unsigned short,
14211                                vector unsigned short);
14212 vector signed char vec_xor (vector bool char, vector signed char);
14213 vector bool char vec_xor (vector bool char, vector bool char);
14214 vector signed char vec_xor (vector signed char, vector bool char);
14215 vector signed char vec_xor (vector signed char, vector signed char);
14216 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14217 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14218 vector unsigned char vec_xor (vector unsigned char,
14219                               vector unsigned char);
14221 int vec_all_eq (vector signed char, vector bool char);
14222 int vec_all_eq (vector signed char, vector signed char);
14223 int vec_all_eq (vector unsigned char, vector bool char);
14224 int vec_all_eq (vector unsigned char, vector unsigned char);
14225 int vec_all_eq (vector bool char, vector bool char);
14226 int vec_all_eq (vector bool char, vector unsigned char);
14227 int vec_all_eq (vector bool char, vector signed char);
14228 int vec_all_eq (vector signed short, vector bool short);
14229 int vec_all_eq (vector signed short, vector signed short);
14230 int vec_all_eq (vector unsigned short, vector bool short);
14231 int vec_all_eq (vector unsigned short, vector unsigned short);
14232 int vec_all_eq (vector bool short, vector bool short);
14233 int vec_all_eq (vector bool short, vector unsigned short);
14234 int vec_all_eq (vector bool short, vector signed short);
14235 int vec_all_eq (vector pixel, vector pixel);
14236 int vec_all_eq (vector signed int, vector bool int);
14237 int vec_all_eq (vector signed int, vector signed int);
14238 int vec_all_eq (vector unsigned int, vector bool int);
14239 int vec_all_eq (vector unsigned int, vector unsigned int);
14240 int vec_all_eq (vector bool int, vector bool int);
14241 int vec_all_eq (vector bool int, vector unsigned int);
14242 int vec_all_eq (vector bool int, vector signed int);
14243 int vec_all_eq (vector float, vector float);
14245 int vec_all_ge (vector bool char, vector unsigned char);
14246 int vec_all_ge (vector unsigned char, vector bool char);
14247 int vec_all_ge (vector unsigned char, vector unsigned char);
14248 int vec_all_ge (vector bool char, vector signed char);
14249 int vec_all_ge (vector signed char, vector bool char);
14250 int vec_all_ge (vector signed char, vector signed char);
14251 int vec_all_ge (vector bool short, vector unsigned short);
14252 int vec_all_ge (vector unsigned short, vector bool short);
14253 int vec_all_ge (vector unsigned short, vector unsigned short);
14254 int vec_all_ge (vector signed short, vector signed short);
14255 int vec_all_ge (vector bool short, vector signed short);
14256 int vec_all_ge (vector signed short, vector bool short);
14257 int vec_all_ge (vector bool int, vector unsigned int);
14258 int vec_all_ge (vector unsigned int, vector bool int);
14259 int vec_all_ge (vector unsigned int, vector unsigned int);
14260 int vec_all_ge (vector bool int, vector signed int);
14261 int vec_all_ge (vector signed int, vector bool int);
14262 int vec_all_ge (vector signed int, vector signed int);
14263 int vec_all_ge (vector float, vector float);
14265 int vec_all_gt (vector bool char, vector unsigned char);
14266 int vec_all_gt (vector unsigned char, vector bool char);
14267 int vec_all_gt (vector unsigned char, vector unsigned char);
14268 int vec_all_gt (vector bool char, vector signed char);
14269 int vec_all_gt (vector signed char, vector bool char);
14270 int vec_all_gt (vector signed char, vector signed char);
14271 int vec_all_gt (vector bool short, vector unsigned short);
14272 int vec_all_gt (vector unsigned short, vector bool short);
14273 int vec_all_gt (vector unsigned short, vector unsigned short);
14274 int vec_all_gt (vector bool short, vector signed short);
14275 int vec_all_gt (vector signed short, vector bool short);
14276 int vec_all_gt (vector signed short, vector signed short);
14277 int vec_all_gt (vector bool int, vector unsigned int);
14278 int vec_all_gt (vector unsigned int, vector bool int);
14279 int vec_all_gt (vector unsigned int, vector unsigned int);
14280 int vec_all_gt (vector bool int, vector signed int);
14281 int vec_all_gt (vector signed int, vector bool int);
14282 int vec_all_gt (vector signed int, vector signed int);
14283 int vec_all_gt (vector float, vector float);
14285 int vec_all_in (vector float, vector float);
14287 int vec_all_le (vector bool char, vector unsigned char);
14288 int vec_all_le (vector unsigned char, vector bool char);
14289 int vec_all_le (vector unsigned char, vector unsigned char);
14290 int vec_all_le (vector bool char, vector signed char);
14291 int vec_all_le (vector signed char, vector bool char);
14292 int vec_all_le (vector signed char, vector signed char);
14293 int vec_all_le (vector bool short, vector unsigned short);
14294 int vec_all_le (vector unsigned short, vector bool short);
14295 int vec_all_le (vector unsigned short, vector unsigned short);
14296 int vec_all_le (vector bool short, vector signed short);
14297 int vec_all_le (vector signed short, vector bool short);
14298 int vec_all_le (vector signed short, vector signed short);
14299 int vec_all_le (vector bool int, vector unsigned int);
14300 int vec_all_le (vector unsigned int, vector bool int);
14301 int vec_all_le (vector unsigned int, vector unsigned int);
14302 int vec_all_le (vector bool int, vector signed int);
14303 int vec_all_le (vector signed int, vector bool int);
14304 int vec_all_le (vector signed int, vector signed int);
14305 int vec_all_le (vector float, vector float);
14307 int vec_all_lt (vector bool char, vector unsigned char);
14308 int vec_all_lt (vector unsigned char, vector bool char);
14309 int vec_all_lt (vector unsigned char, vector unsigned char);
14310 int vec_all_lt (vector bool char, vector signed char);
14311 int vec_all_lt (vector signed char, vector bool char);
14312 int vec_all_lt (vector signed char, vector signed char);
14313 int vec_all_lt (vector bool short, vector unsigned short);
14314 int vec_all_lt (vector unsigned short, vector bool short);
14315 int vec_all_lt (vector unsigned short, vector unsigned short);
14316 int vec_all_lt (vector bool short, vector signed short);
14317 int vec_all_lt (vector signed short, vector bool short);
14318 int vec_all_lt (vector signed short, vector signed short);
14319 int vec_all_lt (vector bool int, vector unsigned int);
14320 int vec_all_lt (vector unsigned int, vector bool int);
14321 int vec_all_lt (vector unsigned int, vector unsigned int);
14322 int vec_all_lt (vector bool int, vector signed int);
14323 int vec_all_lt (vector signed int, vector bool int);
14324 int vec_all_lt (vector signed int, vector signed int);
14325 int vec_all_lt (vector float, vector float);
14327 int vec_all_nan (vector float);
14329 int vec_all_ne (vector signed char, vector bool char);
14330 int vec_all_ne (vector signed char, vector signed char);
14331 int vec_all_ne (vector unsigned char, vector bool char);
14332 int vec_all_ne (vector unsigned char, vector unsigned char);
14333 int vec_all_ne (vector bool char, vector bool char);
14334 int vec_all_ne (vector bool char, vector unsigned char);
14335 int vec_all_ne (vector bool char, vector signed char);
14336 int vec_all_ne (vector signed short, vector bool short);
14337 int vec_all_ne (vector signed short, vector signed short);
14338 int vec_all_ne (vector unsigned short, vector bool short);
14339 int vec_all_ne (vector unsigned short, vector unsigned short);
14340 int vec_all_ne (vector bool short, vector bool short);
14341 int vec_all_ne (vector bool short, vector unsigned short);
14342 int vec_all_ne (vector bool short, vector signed short);
14343 int vec_all_ne (vector pixel, vector pixel);
14344 int vec_all_ne (vector signed int, vector bool int);
14345 int vec_all_ne (vector signed int, vector signed int);
14346 int vec_all_ne (vector unsigned int, vector bool int);
14347 int vec_all_ne (vector unsigned int, vector unsigned int);
14348 int vec_all_ne (vector bool int, vector bool int);
14349 int vec_all_ne (vector bool int, vector unsigned int);
14350 int vec_all_ne (vector bool int, vector signed int);
14351 int vec_all_ne (vector float, vector float);
14353 int vec_all_nge (vector float, vector float);
14355 int vec_all_ngt (vector float, vector float);
14357 int vec_all_nle (vector float, vector float);
14359 int vec_all_nlt (vector float, vector float);
14361 int vec_all_numeric (vector float);
14363 int vec_any_eq (vector signed char, vector bool char);
14364 int vec_any_eq (vector signed char, vector signed char);
14365 int vec_any_eq (vector unsigned char, vector bool char);
14366 int vec_any_eq (vector unsigned char, vector unsigned char);
14367 int vec_any_eq (vector bool char, vector bool char);
14368 int vec_any_eq (vector bool char, vector unsigned char);
14369 int vec_any_eq (vector bool char, vector signed char);
14370 int vec_any_eq (vector signed short, vector bool short);
14371 int vec_any_eq (vector signed short, vector signed short);
14372 int vec_any_eq (vector unsigned short, vector bool short);
14373 int vec_any_eq (vector unsigned short, vector unsigned short);
14374 int vec_any_eq (vector bool short, vector bool short);
14375 int vec_any_eq (vector bool short, vector unsigned short);
14376 int vec_any_eq (vector bool short, vector signed short);
14377 int vec_any_eq (vector pixel, vector pixel);
14378 int vec_any_eq (vector signed int, vector bool int);
14379 int vec_any_eq (vector signed int, vector signed int);
14380 int vec_any_eq (vector unsigned int, vector bool int);
14381 int vec_any_eq (vector unsigned int, vector unsigned int);
14382 int vec_any_eq (vector bool int, vector bool int);
14383 int vec_any_eq (vector bool int, vector unsigned int);
14384 int vec_any_eq (vector bool int, vector signed int);
14385 int vec_any_eq (vector float, vector float);
14387 int vec_any_ge (vector signed char, vector bool char);
14388 int vec_any_ge (vector unsigned char, vector bool char);
14389 int vec_any_ge (vector unsigned char, vector unsigned char);
14390 int vec_any_ge (vector signed char, vector signed char);
14391 int vec_any_ge (vector bool char, vector unsigned char);
14392 int vec_any_ge (vector bool char, vector signed char);
14393 int vec_any_ge (vector unsigned short, vector bool short);
14394 int vec_any_ge (vector unsigned short, vector unsigned short);
14395 int vec_any_ge (vector signed short, vector signed short);
14396 int vec_any_ge (vector signed short, vector bool short);
14397 int vec_any_ge (vector bool short, vector unsigned short);
14398 int vec_any_ge (vector bool short, vector signed short);
14399 int vec_any_ge (vector signed int, vector bool int);
14400 int vec_any_ge (vector unsigned int, vector bool int);
14401 int vec_any_ge (vector unsigned int, vector unsigned int);
14402 int vec_any_ge (vector signed int, vector signed int);
14403 int vec_any_ge (vector bool int, vector unsigned int);
14404 int vec_any_ge (vector bool int, vector signed int);
14405 int vec_any_ge (vector float, vector float);
14407 int vec_any_gt (vector bool char, vector unsigned char);
14408 int vec_any_gt (vector unsigned char, vector bool char);
14409 int vec_any_gt (vector unsigned char, vector unsigned char);
14410 int vec_any_gt (vector bool char, vector signed char);
14411 int vec_any_gt (vector signed char, vector bool char);
14412 int vec_any_gt (vector signed char, vector signed char);
14413 int vec_any_gt (vector bool short, vector unsigned short);
14414 int vec_any_gt (vector unsigned short, vector bool short);
14415 int vec_any_gt (vector unsigned short, vector unsigned short);
14416 int vec_any_gt (vector bool short, vector signed short);
14417 int vec_any_gt (vector signed short, vector bool short);
14418 int vec_any_gt (vector signed short, vector signed short);
14419 int vec_any_gt (vector bool int, vector unsigned int);
14420 int vec_any_gt (vector unsigned int, vector bool int);
14421 int vec_any_gt (vector unsigned int, vector unsigned int);
14422 int vec_any_gt (vector bool int, vector signed int);
14423 int vec_any_gt (vector signed int, vector bool int);
14424 int vec_any_gt (vector signed int, vector signed int);
14425 int vec_any_gt (vector float, vector float);
14427 int vec_any_le (vector bool char, vector unsigned char);
14428 int vec_any_le (vector unsigned char, vector bool char);
14429 int vec_any_le (vector unsigned char, vector unsigned char);
14430 int vec_any_le (vector bool char, vector signed char);
14431 int vec_any_le (vector signed char, vector bool char);
14432 int vec_any_le (vector signed char, vector signed char);
14433 int vec_any_le (vector bool short, vector unsigned short);
14434 int vec_any_le (vector unsigned short, vector bool short);
14435 int vec_any_le (vector unsigned short, vector unsigned short);
14436 int vec_any_le (vector bool short, vector signed short);
14437 int vec_any_le (vector signed short, vector bool short);
14438 int vec_any_le (vector signed short, vector signed short);
14439 int vec_any_le (vector bool int, vector unsigned int);
14440 int vec_any_le (vector unsigned int, vector bool int);
14441 int vec_any_le (vector unsigned int, vector unsigned int);
14442 int vec_any_le (vector bool int, vector signed int);
14443 int vec_any_le (vector signed int, vector bool int);
14444 int vec_any_le (vector signed int, vector signed int);
14445 int vec_any_le (vector float, vector float);
14447 int vec_any_lt (vector bool char, vector unsigned char);
14448 int vec_any_lt (vector unsigned char, vector bool char);
14449 int vec_any_lt (vector unsigned char, vector unsigned char);
14450 int vec_any_lt (vector bool char, vector signed char);
14451 int vec_any_lt (vector signed char, vector bool char);
14452 int vec_any_lt (vector signed char, vector signed char);
14453 int vec_any_lt (vector bool short, vector unsigned short);
14454 int vec_any_lt (vector unsigned short, vector bool short);
14455 int vec_any_lt (vector unsigned short, vector unsigned short);
14456 int vec_any_lt (vector bool short, vector signed short);
14457 int vec_any_lt (vector signed short, vector bool short);
14458 int vec_any_lt (vector signed short, vector signed short);
14459 int vec_any_lt (vector bool int, vector unsigned int);
14460 int vec_any_lt (vector unsigned int, vector bool int);
14461 int vec_any_lt (vector unsigned int, vector unsigned int);
14462 int vec_any_lt (vector bool int, vector signed int);
14463 int vec_any_lt (vector signed int, vector bool int);
14464 int vec_any_lt (vector signed int, vector signed int);
14465 int vec_any_lt (vector float, vector float);
14467 int vec_any_nan (vector float);
14469 int vec_any_ne (vector signed char, vector bool char);
14470 int vec_any_ne (vector signed char, vector signed char);
14471 int vec_any_ne (vector unsigned char, vector bool char);
14472 int vec_any_ne (vector unsigned char, vector unsigned char);
14473 int vec_any_ne (vector bool char, vector bool char);
14474 int vec_any_ne (vector bool char, vector unsigned char);
14475 int vec_any_ne (vector bool char, vector signed char);
14476 int vec_any_ne (vector signed short, vector bool short);
14477 int vec_any_ne (vector signed short, vector signed short);
14478 int vec_any_ne (vector unsigned short, vector bool short);
14479 int vec_any_ne (vector unsigned short, vector unsigned short);
14480 int vec_any_ne (vector bool short, vector bool short);
14481 int vec_any_ne (vector bool short, vector unsigned short);
14482 int vec_any_ne (vector bool short, vector signed short);
14483 int vec_any_ne (vector pixel, vector pixel);
14484 int vec_any_ne (vector signed int, vector bool int);
14485 int vec_any_ne (vector signed int, vector signed int);
14486 int vec_any_ne (vector unsigned int, vector bool int);
14487 int vec_any_ne (vector unsigned int, vector unsigned int);
14488 int vec_any_ne (vector bool int, vector bool int);
14489 int vec_any_ne (vector bool int, vector unsigned int);
14490 int vec_any_ne (vector bool int, vector signed int);
14491 int vec_any_ne (vector float, vector float);
14493 int vec_any_nge (vector float, vector float);
14495 int vec_any_ngt (vector float, vector float);
14497 int vec_any_nle (vector float, vector float);
14499 int vec_any_nlt (vector float, vector float);
14501 int vec_any_numeric (vector float);
14503 int vec_any_out (vector float, vector float);
14504 @end smallexample
14506 If the vector/scalar (VSX) instruction set is available, the following
14507 additional functions are available:
14509 @smallexample
14510 vector double vec_abs (vector double);
14511 vector double vec_add (vector double, vector double);
14512 vector double vec_and (vector double, vector double);
14513 vector double vec_and (vector double, vector bool long);
14514 vector double vec_and (vector bool long, vector double);
14515 vector double vec_andc (vector double, vector double);
14516 vector double vec_andc (vector double, vector bool long);
14517 vector double vec_andc (vector bool long, vector double);
14518 vector double vec_ceil (vector double);
14519 vector bool long vec_cmpeq (vector double, vector double);
14520 vector bool long vec_cmpge (vector double, vector double);
14521 vector bool long vec_cmpgt (vector double, vector double);
14522 vector bool long vec_cmple (vector double, vector double);
14523 vector bool long vec_cmplt (vector double, vector double);
14524 vector float vec_div (vector float, vector float);
14525 vector double vec_div (vector double, vector double);
14526 vector double vec_floor (vector double);
14527 vector double vec_ld (int, const vector double *);
14528 vector double vec_ld (int, const double *);
14529 vector double vec_ldl (int, const vector double *);
14530 vector double vec_ldl (int, const double *);
14531 vector unsigned char vec_lvsl (int, const volatile double *);
14532 vector unsigned char vec_lvsr (int, const volatile double *);
14533 vector double vec_madd (vector double, vector double, vector double);
14534 vector double vec_max (vector double, vector double);
14535 vector double vec_min (vector double, vector double);
14536 vector float vec_msub (vector float, vector float, vector float);
14537 vector double vec_msub (vector double, vector double, vector double);
14538 vector float vec_mul (vector float, vector float);
14539 vector double vec_mul (vector double, vector double);
14540 vector float vec_nearbyint (vector float);
14541 vector double vec_nearbyint (vector double);
14542 vector float vec_nmadd (vector float, vector float, vector float);
14543 vector double vec_nmadd (vector double, vector double, vector double);
14544 vector double vec_nmsub (vector double, vector double, vector double);
14545 vector double vec_nor (vector double, vector double);
14546 vector double vec_or (vector double, vector double);
14547 vector double vec_or (vector double, vector bool long);
14548 vector double vec_or (vector bool long, vector double);
14549 vector double vec_perm (vector double,
14550                         vector double,
14551                         vector unsigned char);
14552 vector double vec_rint (vector double);
14553 vector double vec_recip (vector double, vector double);
14554 vector double vec_rsqrt (vector double);
14555 vector double vec_rsqrte (vector double);
14556 vector double vec_sel (vector double, vector double, vector bool long);
14557 vector double vec_sel (vector double, vector double, vector unsigned long);
14558 vector double vec_sub (vector double, vector double);
14559 vector float vec_sqrt (vector float);
14560 vector double vec_sqrt (vector double);
14561 void vec_st (vector double, int, vector double *);
14562 void vec_st (vector double, int, double *);
14563 vector double vec_trunc (vector double);
14564 vector double vec_xor (vector double, vector double);
14565 vector double vec_xor (vector double, vector bool long);
14566 vector double vec_xor (vector bool long, vector double);
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 *);
14643 @end smallexample
14645 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
14646 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
14647 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
14648 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
14649 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
14651 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14652 instruction set is available, the following additional functions are
14653 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
14654 can use @var{vector long} instead of @var{vector long long},
14655 @var{vector bool long} instead of @var{vector bool long long}, and
14656 @var{vector unsigned long} instead of @var{vector unsigned long long}.
14658 @smallexample
14659 vector long long vec_abs (vector long long);
14661 vector long long vec_add (vector long long, vector long long);
14662 vector unsigned long long vec_add (vector unsigned long long,
14663                                    vector unsigned long long);
14665 int vec_all_eq (vector long long, vector long long);
14666 int vec_all_ge (vector long long, vector long long);
14667 int vec_all_gt (vector long long, vector long long);
14668 int vec_all_le (vector long long, vector long long);
14669 int vec_all_lt (vector long long, vector long long);
14670 int vec_all_ne (vector long long, vector long long);
14671 int vec_any_eq (vector long long, vector long long);
14672 int vec_any_ge (vector long long, vector long long);
14673 int vec_any_gt (vector long long, vector long long);
14674 int vec_any_le (vector long long, vector long long);
14675 int vec_any_lt (vector long long, vector long long);
14676 int vec_any_ne (vector long long, vector long long);
14678 vector long long vec_eqv (vector long long, vector long long);
14679 vector long long vec_eqv (vector bool long long, vector long long);
14680 vector long long vec_eqv (vector long long, vector bool long long);
14681 vector unsigned long long vec_eqv (vector unsigned long long,
14682                                    vector unsigned long long);
14683 vector unsigned long long vec_eqv (vector bool long long,
14684                                    vector unsigned long long);
14685 vector unsigned long long vec_eqv (vector unsigned long long,
14686                                    vector bool long long);
14687 vector int vec_eqv (vector int, vector int);
14688 vector int vec_eqv (vector bool int, vector int);
14689 vector int vec_eqv (vector int, vector bool int);
14690 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14691 vector unsigned int vec_eqv (vector bool unsigned int,
14692                              vector unsigned int);
14693 vector unsigned int vec_eqv (vector unsigned int,
14694                              vector bool unsigned int);
14695 vector short vec_eqv (vector short, vector short);
14696 vector short vec_eqv (vector bool short, vector short);
14697 vector short vec_eqv (vector short, vector bool short);
14698 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14699 vector unsigned short vec_eqv (vector bool unsigned short,
14700                                vector unsigned short);
14701 vector unsigned short vec_eqv (vector unsigned short,
14702                                vector bool unsigned short);
14703 vector signed char vec_eqv (vector signed char, vector signed char);
14704 vector signed char vec_eqv (vector bool signed char, vector signed char);
14705 vector signed char vec_eqv (vector signed char, vector bool signed char);
14706 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14707 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14708 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14710 vector long long vec_max (vector long long, vector long long);
14711 vector unsigned long long vec_max (vector unsigned long long,
14712                                    vector unsigned long long);
14714 vector long long vec_min (vector long long, vector long long);
14715 vector unsigned long long vec_min (vector unsigned long long,
14716                                    vector unsigned long long);
14718 vector long long vec_nand (vector long long, vector long long);
14719 vector long long vec_nand (vector bool long long, vector long long);
14720 vector long long vec_nand (vector long long, vector bool long long);
14721 vector unsigned long long vec_nand (vector unsigned long long,
14722                                     vector unsigned long long);
14723 vector unsigned long long vec_nand (vector bool long long,
14724                                    vector unsigned long long);
14725 vector unsigned long long vec_nand (vector unsigned long long,
14726                                     vector bool long long);
14727 vector int vec_nand (vector int, vector int);
14728 vector int vec_nand (vector bool int, vector int);
14729 vector int vec_nand (vector int, vector bool int);
14730 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14731 vector unsigned int vec_nand (vector bool unsigned int,
14732                               vector unsigned int);
14733 vector unsigned int vec_nand (vector unsigned int,
14734                               vector bool unsigned int);
14735 vector short vec_nand (vector short, vector short);
14736 vector short vec_nand (vector bool short, vector short);
14737 vector short vec_nand (vector short, vector bool short);
14738 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14739 vector unsigned short vec_nand (vector bool unsigned short,
14740                                 vector unsigned short);
14741 vector unsigned short vec_nand (vector unsigned short,
14742                                 vector bool unsigned short);
14743 vector signed char vec_nand (vector signed char, vector signed char);
14744 vector signed char vec_nand (vector bool signed char, vector signed char);
14745 vector signed char vec_nand (vector signed char, vector bool signed char);
14746 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14747 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14748 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14750 vector long long vec_orc (vector long long, vector long long);
14751 vector long long vec_orc (vector bool long long, vector long long);
14752 vector long long vec_orc (vector long long, vector bool long long);
14753 vector unsigned long long vec_orc (vector unsigned long long,
14754                                    vector unsigned long long);
14755 vector unsigned long long vec_orc (vector bool long long,
14756                                    vector unsigned long long);
14757 vector unsigned long long vec_orc (vector unsigned long long,
14758                                    vector bool long long);
14759 vector int vec_orc (vector int, vector int);
14760 vector int vec_orc (vector bool int, vector int);
14761 vector int vec_orc (vector int, vector bool int);
14762 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14763 vector unsigned int vec_orc (vector bool unsigned int,
14764                              vector unsigned int);
14765 vector unsigned int vec_orc (vector unsigned int,
14766                              vector bool unsigned int);
14767 vector short vec_orc (vector short, vector short);
14768 vector short vec_orc (vector bool short, vector short);
14769 vector short vec_orc (vector short, vector bool short);
14770 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14771 vector unsigned short vec_orc (vector bool unsigned short,
14772                                vector unsigned short);
14773 vector unsigned short vec_orc (vector unsigned short,
14774                                vector bool unsigned short);
14775 vector signed char vec_orc (vector signed char, vector signed char);
14776 vector signed char vec_orc (vector bool signed char, vector signed char);
14777 vector signed char vec_orc (vector signed char, vector bool signed char);
14778 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14779 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14780 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14782 vector int vec_pack (vector long long, vector long long);
14783 vector unsigned int vec_pack (vector unsigned long long,
14784                               vector unsigned long long);
14785 vector bool int vec_pack (vector bool long long, vector bool long long);
14787 vector int vec_packs (vector long long, vector long long);
14788 vector unsigned int vec_packs (vector unsigned long long,
14789                                vector unsigned long long);
14791 vector unsigned int vec_packsu (vector long long, vector long long);
14793 vector long long vec_rl (vector long long,
14794                          vector unsigned long long);
14795 vector long long vec_rl (vector unsigned long long,
14796                          vector unsigned long long);
14798 vector long long vec_sl (vector long long, vector unsigned long long);
14799 vector long long vec_sl (vector unsigned long long,
14800                          vector unsigned long long);
14802 vector long long vec_sr (vector long long, vector unsigned long long);
14803 vector unsigned long long char vec_sr (vector unsigned long long,
14804                                        vector unsigned long long);
14806 vector long long vec_sra (vector long long, vector unsigned long long);
14807 vector unsigned long long vec_sra (vector unsigned long long,
14808                                    vector unsigned long long);
14810 vector long long vec_sub (vector long long, vector long long);
14811 vector unsigned long long vec_sub (vector unsigned long long,
14812                                    vector unsigned long long);
14814 vector long long vec_unpackh (vector int);
14815 vector unsigned long long vec_unpackh (vector unsigned int);
14817 vector long long vec_unpackl (vector int);
14818 vector unsigned long long vec_unpackl (vector unsigned int);
14820 vector long long vec_vaddudm (vector long long, vector long long);
14821 vector long long vec_vaddudm (vector bool long long, vector long long);
14822 vector long long vec_vaddudm (vector long long, vector bool long long);
14823 vector unsigned long long vec_vaddudm (vector unsigned long long,
14824                                        vector unsigned long long);
14825 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14826                                        vector unsigned long long);
14827 vector unsigned long long vec_vaddudm (vector unsigned long long,
14828                                        vector bool unsigned long long);
14830 vector long long vec_vclz (vector long long);
14831 vector unsigned long long vec_vclz (vector unsigned long long);
14832 vector int vec_vclz (vector int);
14833 vector unsigned int vec_vclz (vector int);
14834 vector short vec_vclz (vector short);
14835 vector unsigned short vec_vclz (vector unsigned short);
14836 vector signed char vec_vclz (vector signed char);
14837 vector unsigned char vec_vclz (vector unsigned char);
14839 vector signed char vec_vclzb (vector signed char);
14840 vector unsigned char vec_vclzb (vector unsigned char);
14842 vector long long vec_vclzd (vector long long);
14843 vector unsigned long long vec_vclzd (vector unsigned long long);
14845 vector short vec_vclzh (vector short);
14846 vector unsigned short vec_vclzh (vector unsigned short);
14848 vector int vec_vclzw (vector int);
14849 vector unsigned int vec_vclzw (vector int);
14851 vector long long vec_vmaxsd (vector long long, vector long long);
14853 vector unsigned long long vec_vmaxud (vector unsigned long long,
14854                                       unsigned vector long long);
14856 vector long long vec_vminsd (vector long long, vector long long);
14858 vector unsigned long long vec_vminud (vector long long,
14859                                       vector long long);
14861 vector int vec_vpksdss (vector long long, vector long long);
14862 vector unsigned int vec_vpksdss (vector long long, vector long long);
14864 vector unsigned int vec_vpkudus (vector unsigned long long,
14865                                  vector unsigned long long);
14867 vector int vec_vpkudum (vector long long, vector long long);
14868 vector unsigned int vec_vpkudum (vector unsigned long long,
14869                                  vector unsigned long long);
14870 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
14872 vector long long vec_vpopcnt (vector long long);
14873 vector unsigned long long vec_vpopcnt (vector unsigned long long);
14874 vector int vec_vpopcnt (vector int);
14875 vector unsigned int vec_vpopcnt (vector int);
14876 vector short vec_vpopcnt (vector short);
14877 vector unsigned short vec_vpopcnt (vector unsigned short);
14878 vector signed char vec_vpopcnt (vector signed char);
14879 vector unsigned char vec_vpopcnt (vector unsigned char);
14881 vector signed char vec_vpopcntb (vector signed char);
14882 vector unsigned char vec_vpopcntb (vector unsigned char);
14884 vector long long vec_vpopcntd (vector long long);
14885 vector unsigned long long vec_vpopcntd (vector unsigned long long);
14887 vector short vec_vpopcnth (vector short);
14888 vector unsigned short vec_vpopcnth (vector unsigned short);
14890 vector int vec_vpopcntw (vector int);
14891 vector unsigned int vec_vpopcntw (vector int);
14893 vector long long vec_vrld (vector long long, vector unsigned long long);
14894 vector unsigned long long vec_vrld (vector unsigned long long,
14895                                     vector unsigned long long);
14897 vector long long vec_vsld (vector long long, vector unsigned long long);
14898 vector long long vec_vsld (vector unsigned long long,
14899                            vector unsigned long long);
14901 vector long long vec_vsrad (vector long long, vector unsigned long long);
14902 vector unsigned long long vec_vsrad (vector unsigned long long,
14903                                      vector unsigned long long);
14905 vector long long vec_vsrd (vector long long, vector unsigned long long);
14906 vector unsigned long long char vec_vsrd (vector unsigned long long,
14907                                          vector unsigned long long);
14909 vector long long vec_vsubudm (vector long long, vector long long);
14910 vector long long vec_vsubudm (vector bool long long, vector long long);
14911 vector long long vec_vsubudm (vector long long, vector bool long long);
14912 vector unsigned long long vec_vsubudm (vector unsigned long long,
14913                                        vector unsigned long long);
14914 vector unsigned long long vec_vsubudm (vector bool long long,
14915                                        vector unsigned long long);
14916 vector unsigned long long vec_vsubudm (vector unsigned long long,
14917                                        vector bool long long);
14919 vector long long vec_vupkhsw (vector int);
14920 vector unsigned long long vec_vupkhsw (vector unsigned int);
14922 vector long long vec_vupklsw (vector int);
14923 vector unsigned long long vec_vupklsw (vector int);
14924 @end smallexample
14926 If the cryptographic instructions are enabled (@option{-mcrypto} or
14927 @option{-mcpu=power8}), the following builtins are enabled.
14929 @smallexample
14930 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
14932 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
14933                                                     vector unsigned long long);
14935 vector unsigned long long __builtin_crypto_vcipherlast
14936                                      (vector unsigned long long,
14937                                       vector unsigned long long);
14939 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
14940                                                      vector unsigned long long);
14942 vector unsigned long long __builtin_crypto_vncipherlast
14943                                      (vector unsigned long long,
14944                                       vector unsigned long long);
14946 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
14947                                                 vector unsigned char,
14948                                                 vector unsigned char);
14950 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
14951                                                  vector unsigned short,
14952                                                  vector unsigned short);
14954 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
14955                                                vector unsigned int,
14956                                                vector unsigned int);
14958 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
14959                                                      vector unsigned long long,
14960                                                      vector unsigned long long);
14962 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
14963                                                vector unsigned char);
14965 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
14966                                                 vector unsigned short);
14968 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
14969                                               vector unsigned int);
14971 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
14972                                                     vector unsigned long long);
14974 vector unsigned long long __builtin_crypto_vshasigmad
14975                                (vector unsigned long long, int, int);
14977 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
14978                                                  int, int);
14979 @end smallexample
14981 The second argument to the @var{__builtin_crypto_vshasigmad} and
14982 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
14983 integer that is 0 or 1.  The third argument to these builtin functions
14984 must be a constant integer in the range of 0 to 15.
14986 @node PowerPC Hardware Transactional Memory Built-in Functions
14987 @subsection PowerPC Hardware Transactional Memory Built-in Functions
14988 GCC provides two interfaces for accessing the Hardware Transactional
14989 Memory (HTM) instructions available on some of the PowerPC family
14990 of prcoessors (eg, POWER8).  The two interfaces come in a low level
14991 interface, consisting of built-in functions specific to PowerPC and a
14992 higher level interface consisting of inline functions that are common
14993 between PowerPC and S/390.
14995 @subsubsection PowerPC HTM Low Level Built-in Functions
14997 The following low level built-in functions are available with
14998 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
14999 They all generate the machine instruction that is part of the name.
15001 The HTM built-ins return true or false depending on their success and
15002 their arguments match exactly the type and order of the associated
15003 hardware instruction's operands.  Refer to the ISA manual for a
15004 description of each instruction's operands.
15006 @smallexample
15007 unsigned int __builtin_tbegin (unsigned int)
15008 unsigned int __builtin_tend (unsigned int)
15010 unsigned int __builtin_tabort (unsigned int)
15011 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15012 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15013 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15014 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15016 unsigned int __builtin_tcheck (unsigned int)
15017 unsigned int __builtin_treclaim (unsigned int)
15018 unsigned int __builtin_trechkpt (void)
15019 unsigned int __builtin_tsr (unsigned int)
15020 @end smallexample
15022 In addition to the above HTM built-ins, we have added built-ins for
15023 some common extended mnemonics of the HTM instructions:
15025 @smallexample
15026 unsigned int __builtin_tendall (void)
15027 unsigned int __builtin_tresume (void)
15028 unsigned int __builtin_tsuspend (void)
15029 @end smallexample
15031 The following set of built-in functions are available to gain access
15032 to the HTM specific special purpose registers.
15034 @smallexample
15035 unsigned long __builtin_get_texasr (void)
15036 unsigned long __builtin_get_texasru (void)
15037 unsigned long __builtin_get_tfhar (void)
15038 unsigned long __builtin_get_tfiar (void)
15040 void __builtin_set_texasr (unsigned long);
15041 void __builtin_set_texasru (unsigned long);
15042 void __builtin_set_tfhar (unsigned long);
15043 void __builtin_set_tfiar (unsigned long);
15044 @end smallexample
15046 Example usage of these low level built-in functions may look like:
15048 @smallexample
15049 #include <htmintrin.h>
15051 int num_retries = 10;
15053 while (1)
15054   @{
15055     if (__builtin_tbegin (0))
15056       @{
15057         /* Transaction State Initiated.  */
15058         if (is_locked (lock))
15059           __builtin_tabort (0);
15060         ... transaction code...
15061         __builtin_tend (0);
15062         break;
15063       @}
15064     else
15065       @{
15066         /* Transaction State Failed.  Use locks if the transaction
15067            failure is "persistent" or we've tried too many times.  */
15068         if (num_retries-- <= 0
15069             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15070           @{
15071             acquire_lock (lock);
15072             ... non transactional fallback path...
15073             release_lock (lock);
15074             break;
15075           @}
15076       @}
15077   @}
15078 @end smallexample
15080 One final built-in function has been added that returns the value of
15081 the 2-bit Transaction State field of the Machine Status Register (MSR)
15082 as stored in @code{CR0}.
15084 @smallexample
15085 unsigned long __builtin_ttest (void)
15086 @end smallexample
15088 This built-in can be used to determine the current transaction state
15089 using the following code example:
15091 @smallexample
15092 #include <htmintrin.h>
15094 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15096 if (tx_state == _HTM_TRANSACTIONAL)
15097   @{
15098     /* Code to use in transactional state.  */
15099   @}
15100 else if (tx_state == _HTM_NONTRANSACTIONAL)
15101   @{
15102     /* Code to use in non-transactional state.  */
15103   @}
15104 else if (tx_state == _HTM_SUSPENDED)
15105   @{
15106     /* Code to use in transaction suspended state.  */
15107   @}
15108 @end smallexample
15110 @subsubsection PowerPC HTM High Level Inline Functions
15112 The following high level HTM interface is made available by including
15113 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15114 where CPU is `power8' or later.  This interface is common between PowerPC
15115 and S/390, allowing users to write one HTM source implementation that
15116 can be compiled and executed on either system.
15118 @smallexample
15119 long __TM_simple_begin (void)
15120 long __TM_begin (void* const TM_buff)
15121 long __TM_end (void)
15122 void __TM_abort (void)
15123 void __TM_named_abort (unsigned char const code)
15124 void __TM_resume (void)
15125 void __TM_suspend (void)
15127 long __TM_is_user_abort (void* const TM_buff)
15128 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15129 long __TM_is_illegal (void* const TM_buff)
15130 long __TM_is_footprint_exceeded (void* const TM_buff)
15131 long __TM_nesting_depth (void* const TM_buff)
15132 long __TM_is_nested_too_deep(void* const TM_buff)
15133 long __TM_is_conflict(void* const TM_buff)
15134 long __TM_is_failure_persistent(void* const TM_buff)
15135 long __TM_failure_address(void* const TM_buff)
15136 long long __TM_failure_code(void* const TM_buff)
15137 @end smallexample
15139 Using these common set of HTM inline functions, we can create
15140 a more portable version of the HTM example in the previous
15141 section that will work on either PowerPC or S/390:
15143 @smallexample
15144 #include <htmxlintrin.h>
15146 int num_retries = 10;
15147 TM_buff_type TM_buff;
15149 while (1)
15150   @{
15151     if (__TM_begin (TM_buff))
15152       @{
15153         /* Transaction State Initiated.  */
15154         if (is_locked (lock))
15155           __TM_abort ();
15156         ... transaction code...
15157         __TM_end ();
15158         break;
15159       @}
15160     else
15161       @{
15162         /* Transaction State Failed.  Use locks if the transaction
15163            failure is "persistent" or we've tried too many times.  */
15164         if (num_retries-- <= 0
15165             || __TM_is_failure_persistent (TM_buff))
15166           @{
15167             acquire_lock (lock);
15168             ... non transactional fallback path...
15169             release_lock (lock);
15170             break;
15171           @}
15172       @}
15173   @}
15174 @end smallexample
15176 @node RX Built-in Functions
15177 @subsection RX Built-in Functions
15178 GCC supports some of the RX instructions which cannot be expressed in
15179 the C programming language via the use of built-in functions.  The
15180 following functions are supported:
15182 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
15183 Generates the @code{brk} machine instruction.
15184 @end deftypefn
15186 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
15187 Generates the @code{clrpsw} machine instruction to clear the specified
15188 bit in the processor status word.
15189 @end deftypefn
15191 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
15192 Generates the @code{int} machine instruction to generate an interrupt
15193 with the specified value.
15194 @end deftypefn
15196 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
15197 Generates the @code{machi} machine instruction to add the result of
15198 multiplying the top 16 bits of the two arguments into the
15199 accumulator.
15200 @end deftypefn
15202 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
15203 Generates the @code{maclo} machine instruction to add the result of
15204 multiplying the bottom 16 bits of the two arguments into the
15205 accumulator.
15206 @end deftypefn
15208 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
15209 Generates the @code{mulhi} machine instruction to place the result of
15210 multiplying the top 16 bits of the two arguments into the
15211 accumulator.
15212 @end deftypefn
15214 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
15215 Generates the @code{mullo} machine instruction to place the result of
15216 multiplying the bottom 16 bits of the two arguments into the
15217 accumulator.
15218 @end deftypefn
15220 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
15221 Generates the @code{mvfachi} machine instruction to read the top
15222 32 bits of the accumulator.
15223 @end deftypefn
15225 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
15226 Generates the @code{mvfacmi} machine instruction to read the middle
15227 32 bits of the accumulator.
15228 @end deftypefn
15230 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
15231 Generates the @code{mvfc} machine instruction which reads the control
15232 register specified in its argument and returns its value.
15233 @end deftypefn
15235 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
15236 Generates the @code{mvtachi} machine instruction to set the top
15237 32 bits of the accumulator.
15238 @end deftypefn
15240 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
15241 Generates the @code{mvtaclo} machine instruction to set the bottom
15242 32 bits of the accumulator.
15243 @end deftypefn
15245 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
15246 Generates the @code{mvtc} machine instruction which sets control
15247 register number @code{reg} to @code{val}.
15248 @end deftypefn
15250 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
15251 Generates the @code{mvtipl} machine instruction set the interrupt
15252 priority level.
15253 @end deftypefn
15255 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
15256 Generates the @code{racw} machine instruction to round the accumulator
15257 according to the specified mode.
15258 @end deftypefn
15260 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
15261 Generates the @code{revw} machine instruction which swaps the bytes in
15262 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15263 and also bits 16--23 occupy bits 24--31 and vice versa.
15264 @end deftypefn
15266 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
15267 Generates the @code{rmpa} machine instruction which initiates a
15268 repeated multiply and accumulate sequence.
15269 @end deftypefn
15271 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
15272 Generates the @code{round} machine instruction which returns the
15273 floating-point argument rounded according to the current rounding mode
15274 set in the floating-point status word register.
15275 @end deftypefn
15277 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
15278 Generates the @code{sat} machine instruction which returns the
15279 saturated value of the argument.
15280 @end deftypefn
15282 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
15283 Generates the @code{setpsw} machine instruction to set the specified
15284 bit in the processor status word.
15285 @end deftypefn
15287 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
15288 Generates the @code{wait} machine instruction.
15289 @end deftypefn
15291 @node S/390 System z Built-in Functions
15292 @subsection S/390 System z Built-in Functions
15293 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15294 Generates the @code{tbegin} machine instruction starting a
15295 non-constraint hardware transaction.  If the parameter is non-NULL the
15296 memory area is used to store the transaction diagnostic buffer and
15297 will be passed as first operand to @code{tbegin}.  This buffer can be
15298 defined using the @code{struct __htm_tdb} C struct defined in
15299 @code{htmintrin.h} and must reside on a double-word boundary.  The
15300 second tbegin operand is set to @code{0xff0c}. This enables
15301 save/restore of all GPRs and disables aborts for FPR and AR
15302 manipulations inside the transaction body.  The condition code set by
15303 the tbegin instruction is returned as integer value.  The tbegin
15304 instruction by definition overwrites the content of all FPRs.  The
15305 compiler will generate code which saves and restores the FPRs.  For
15306 soft-float code it is recommended to used the @code{*_nofloat}
15307 variant.  In order to prevent a TDB from being written it is required
15308 to pass an constant zero value as parameter.  Passing the zero value
15309 through a variable is not sufficient.  Although modifications of
15310 access registers inside the transaction will not trigger an
15311 transaction abort it is not supported to actually modify them.  Access
15312 registers do not get saved when entering a transaction. They will have
15313 undefined state when reaching the abort code.
15314 @end deftypefn
15316 Macros for the possible return codes of tbegin are defined in the
15317 @code{htmintrin.h} header file:
15319 @table @code
15320 @item _HTM_TBEGIN_STARTED
15321 @code{tbegin} has been executed as part of normal processing.  The
15322 transaction body is supposed to be executed.
15323 @item _HTM_TBEGIN_INDETERMINATE
15324 The transaction was aborted due to an indeterminate condition which
15325 might be persistent.
15326 @item _HTM_TBEGIN_TRANSIENT
15327 The transaction aborted due to a transient failure.  The transaction
15328 should be re-executed in that case.
15329 @item _HTM_TBEGIN_PERSISTENT
15330 The transaction aborted due to a persistent failure.  Re-execution
15331 under same circumstances will not be productive.
15332 @end table
15334 @defmac _HTM_FIRST_USER_ABORT_CODE
15335 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15336 specifies the first abort code which can be used for
15337 @code{__builtin_tabort}.  Values below this threshold are reserved for
15338 machine use.
15339 @end defmac
15341 @deftp {Data type} {struct __htm_tdb}
15342 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15343 the structure of the transaction diagnostic block as specified in the
15344 Principles of Operation manual chapter 5-91.
15345 @end deftp
15347 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15348 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15349 Using this variant in code making use of FPRs will leave the FPRs in
15350 undefined state when entering the transaction abort handler code.
15351 @end deftypefn
15353 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15354 In addition to @code{__builtin_tbegin} a loop for transient failures
15355 is generated.  If tbegin returns a condition code of 2 the transaction
15356 will be retried as often as specified in the second argument.  The
15357 perform processor assist instruction is used to tell the CPU about the
15358 number of fails so far.
15359 @end deftypefn
15361 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15362 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15363 restores.  Using this variant in code making use of FPRs will leave
15364 the FPRs in undefined state when entering the transaction abort
15365 handler code.
15366 @end deftypefn
15368 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15369 Generates the @code{tbeginc} machine instruction starting a constraint
15370 hardware transaction.  The second operand is set to @code{0xff08}.
15371 @end deftypefn
15373 @deftypefn {Built-in Function} int __builtin_tend (void)
15374 Generates the @code{tend} machine instruction finishing a transaction
15375 and making the changes visible to other threads.  The condition code
15376 generated by tend is returned as integer value.
15377 @end deftypefn
15379 @deftypefn {Built-in Function} void __builtin_tabort (int)
15380 Generates the @code{tabort} machine instruction with the specified
15381 abort code.  Abort codes from 0 through 255 are reserved and will
15382 result in an error message.
15383 @end deftypefn
15385 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15386 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
15387 integer parameter is loaded into rX and a value of zero is loaded into
15388 rY.  The integer parameter specifies the number of times the
15389 transaction repeatedly aborted.
15390 @end deftypefn
15392 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15393 Generates the @code{etnd} machine instruction.  The current nesting
15394 depth is returned as integer value.  For a nesting depth of 0 the code
15395 is not executed as part of an transaction.
15396 @end deftypefn
15398 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15400 Generates the @code{ntstg} machine instruction.  The second argument
15401 is written to the first arguments location.  The store operation will
15402 not be rolled-back in case of an transaction abort.
15403 @end deftypefn
15405 @node SH Built-in Functions
15406 @subsection SH Built-in Functions
15407 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
15408 families of processors:
15410 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
15411 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
15412 used by system code that manages threads and execution contexts.  The compiler
15413 normally does not generate code that modifies the contents of @samp{GBR} and
15414 thus the value is preserved across function calls.  Changing the @samp{GBR}
15415 value in user code must be done with caution, since the compiler might use
15416 @samp{GBR} in order to access thread local variables.
15418 @end deftypefn
15420 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
15421 Returns the value that is currently set in the @samp{GBR} register.
15422 Memory loads and stores that use the thread pointer as a base address are
15423 turned into @samp{GBR} based displacement loads and stores, if possible.
15424 For example:
15425 @smallexample
15426 struct my_tcb
15428    int a, b, c, d, e;
15431 int get_tcb_value (void)
15433   // Generate @samp{mov.l @@(8,gbr),r0} instruction
15434   return ((my_tcb*)__builtin_thread_pointer ())->c;
15437 @end smallexample
15438 @end deftypefn
15440 @node SPARC VIS Built-in Functions
15441 @subsection SPARC VIS Built-in Functions
15443 GCC supports SIMD operations on the SPARC using both the generic vector
15444 extensions (@pxref{Vector Extensions}) as well as built-in functions for
15445 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
15446 switch, the VIS extension is exposed as the following built-in functions:
15448 @smallexample
15449 typedef int v1si __attribute__ ((vector_size (4)));
15450 typedef int v2si __attribute__ ((vector_size (8)));
15451 typedef short v4hi __attribute__ ((vector_size (8)));
15452 typedef short v2hi __attribute__ ((vector_size (4)));
15453 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
15454 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
15456 void __builtin_vis_write_gsr (int64_t);
15457 int64_t __builtin_vis_read_gsr (void);
15459 void * __builtin_vis_alignaddr (void *, long);
15460 void * __builtin_vis_alignaddrl (void *, long);
15461 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
15462 v2si __builtin_vis_faligndatav2si (v2si, v2si);
15463 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
15464 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
15466 v4hi __builtin_vis_fexpand (v4qi);
15468 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
15469 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
15470 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
15471 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
15472 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
15473 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
15474 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
15476 v4qi __builtin_vis_fpack16 (v4hi);
15477 v8qi __builtin_vis_fpack32 (v2si, v8qi);
15478 v2hi __builtin_vis_fpackfix (v2si);
15479 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
15481 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
15483 long __builtin_vis_edge8 (void *, void *);
15484 long __builtin_vis_edge8l (void *, void *);
15485 long __builtin_vis_edge16 (void *, void *);
15486 long __builtin_vis_edge16l (void *, void *);
15487 long __builtin_vis_edge32 (void *, void *);
15488 long __builtin_vis_edge32l (void *, void *);
15490 long __builtin_vis_fcmple16 (v4hi, v4hi);
15491 long __builtin_vis_fcmple32 (v2si, v2si);
15492 long __builtin_vis_fcmpne16 (v4hi, v4hi);
15493 long __builtin_vis_fcmpne32 (v2si, v2si);
15494 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
15495 long __builtin_vis_fcmpgt32 (v2si, v2si);
15496 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
15497 long __builtin_vis_fcmpeq32 (v2si, v2si);
15499 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
15500 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
15501 v2si __builtin_vis_fpadd32 (v2si, v2si);
15502 v1si __builtin_vis_fpadd32s (v1si, v1si);
15503 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
15504 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
15505 v2si __builtin_vis_fpsub32 (v2si, v2si);
15506 v1si __builtin_vis_fpsub32s (v1si, v1si);
15508 long __builtin_vis_array8 (long, long);
15509 long __builtin_vis_array16 (long, long);
15510 long __builtin_vis_array32 (long, long);
15511 @end smallexample
15513 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
15514 functions also become available:
15516 @smallexample
15517 long __builtin_vis_bmask (long, long);
15518 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
15519 v2si __builtin_vis_bshufflev2si (v2si, v2si);
15520 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
15521 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
15523 long __builtin_vis_edge8n (void *, void *);
15524 long __builtin_vis_edge8ln (void *, void *);
15525 long __builtin_vis_edge16n (void *, void *);
15526 long __builtin_vis_edge16ln (void *, void *);
15527 long __builtin_vis_edge32n (void *, void *);
15528 long __builtin_vis_edge32ln (void *, void *);
15529 @end smallexample
15531 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
15532 functions also become available:
15534 @smallexample
15535 void __builtin_vis_cmask8 (long);
15536 void __builtin_vis_cmask16 (long);
15537 void __builtin_vis_cmask32 (long);
15539 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
15541 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
15542 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
15543 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
15544 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
15545 v2si __builtin_vis_fsll16 (v2si, v2si);
15546 v2si __builtin_vis_fslas16 (v2si, v2si);
15547 v2si __builtin_vis_fsrl16 (v2si, v2si);
15548 v2si __builtin_vis_fsra16 (v2si, v2si);
15550 long __builtin_vis_pdistn (v8qi, v8qi);
15552 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
15554 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
15555 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
15557 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
15558 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
15559 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
15560 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
15561 v2si __builtin_vis_fpadds32 (v2si, v2si);
15562 v1si __builtin_vis_fpadds32s (v1si, v1si);
15563 v2si __builtin_vis_fpsubs32 (v2si, v2si);
15564 v1si __builtin_vis_fpsubs32s (v1si, v1si);
15566 long __builtin_vis_fucmple8 (v8qi, v8qi);
15567 long __builtin_vis_fucmpne8 (v8qi, v8qi);
15568 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
15569 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
15571 float __builtin_vis_fhadds (float, float);
15572 double __builtin_vis_fhaddd (double, double);
15573 float __builtin_vis_fhsubs (float, float);
15574 double __builtin_vis_fhsubd (double, double);
15575 float __builtin_vis_fnhadds (float, float);
15576 double __builtin_vis_fnhaddd (double, double);
15578 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
15579 int64_t __builtin_vis_xmulx (int64_t, int64_t);
15580 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
15581 @end smallexample
15583 @node SPU Built-in Functions
15584 @subsection SPU Built-in Functions
15586 GCC provides extensions for the SPU processor as described in the
15587 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
15588 found at @uref{http://cell.scei.co.jp/} or
15589 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
15590 implementation differs in several ways.
15592 @itemize @bullet
15594 @item
15595 The optional extension of specifying vector constants in parentheses is
15596 not supported.
15598 @item
15599 A vector initializer requires no cast if the vector constant is of the
15600 same type as the variable it is initializing.
15602 @item
15603 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15604 vector type is the default signedness of the base type.  The default
15605 varies depending on the operating system, so a portable program should
15606 always specify the signedness.
15608 @item
15609 By default, the keyword @code{__vector} is added. The macro
15610 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
15611 undefined.
15613 @item
15614 GCC allows using a @code{typedef} name as the type specifier for a
15615 vector type.
15617 @item
15618 For C, overloaded functions are implemented with macros so the following
15619 does not work:
15621 @smallexample
15622   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15623 @end smallexample
15625 @noindent
15626 Since @code{spu_add} is a macro, the vector constant in the example
15627 is treated as four separate arguments.  Wrap the entire argument in
15628 parentheses for this to work.
15630 @item
15631 The extended version of @code{__builtin_expect} is not supported.
15633 @end itemize
15635 @emph{Note:} Only the interface described in the aforementioned
15636 specification is supported. Internally, GCC uses built-in functions to
15637 implement the required functionality, but these are not supported and
15638 are subject to change without notice.
15640 @node TI C6X Built-in Functions
15641 @subsection TI C6X Built-in Functions
15643 GCC provides intrinsics to access certain instructions of the TI C6X
15644 processors.  These intrinsics, listed below, are available after
15645 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
15646 to C6X instructions.
15648 @smallexample
15650 int _sadd (int, int)
15651 int _ssub (int, int)
15652 int _sadd2 (int, int)
15653 int _ssub2 (int, int)
15654 long long _mpy2 (int, int)
15655 long long _smpy2 (int, int)
15656 int _add4 (int, int)
15657 int _sub4 (int, int)
15658 int _saddu4 (int, int)
15660 int _smpy (int, int)
15661 int _smpyh (int, int)
15662 int _smpyhl (int, int)
15663 int _smpylh (int, int)
15665 int _sshl (int, int)
15666 int _subc (int, int)
15668 int _avg2 (int, int)
15669 int _avgu4 (int, int)
15671 int _clrr (int, int)
15672 int _extr (int, int)
15673 int _extru (int, int)
15674 int _abs (int)
15675 int _abs2 (int)
15677 @end smallexample
15679 @node TILE-Gx Built-in Functions
15680 @subsection TILE-Gx Built-in Functions
15682 GCC provides intrinsics to access every instruction of the TILE-Gx
15683 processor.  The intrinsics are of the form:
15685 @smallexample
15687 unsigned long long __insn_@var{op} (...)
15689 @end smallexample
15691 Where @var{op} is the name of the instruction.  Refer to the ISA manual
15692 for the complete list of instructions.
15694 GCC also provides intrinsics to directly access the network registers.
15695 The intrinsics are:
15697 @smallexample
15699 unsigned long long __tile_idn0_receive (void)
15700 unsigned long long __tile_idn1_receive (void)
15701 unsigned long long __tile_udn0_receive (void)
15702 unsigned long long __tile_udn1_receive (void)
15703 unsigned long long __tile_udn2_receive (void)
15704 unsigned long long __tile_udn3_receive (void)
15705 void __tile_idn_send (unsigned long long)
15706 void __tile_udn_send (unsigned long long)
15708 @end smallexample
15710 The intrinsic @code{void __tile_network_barrier (void)} is used to
15711 guarantee that no network operations before it are reordered with
15712 those after it.
15714 @node TILEPro Built-in Functions
15715 @subsection TILEPro Built-in Functions
15717 GCC provides intrinsics to access every instruction of the TILEPro
15718 processor.  The intrinsics are of the form:
15720 @smallexample
15722 unsigned __insn_@var{op} (...)
15724 @end smallexample
15726 @noindent
15727 where @var{op} is the name of the instruction.  Refer to the ISA manual
15728 for the complete list of instructions.
15730 GCC also provides intrinsics to directly access the network registers.
15731 The intrinsics are:
15733 @smallexample
15735 unsigned __tile_idn0_receive (void)
15736 unsigned __tile_idn1_receive (void)
15737 unsigned __tile_sn_receive (void)
15738 unsigned __tile_udn0_receive (void)
15739 unsigned __tile_udn1_receive (void)
15740 unsigned __tile_udn2_receive (void)
15741 unsigned __tile_udn3_receive (void)
15742 void __tile_idn_send (unsigned)
15743 void __tile_sn_send (unsigned)
15744 void __tile_udn_send (unsigned)
15746 @end smallexample
15748 The intrinsic @code{void __tile_network_barrier (void)} is used to
15749 guarantee that no network operations before it are reordered with
15750 those after it.
15752 @node Target Format Checks
15753 @section Format Checks Specific to Particular Target Machines
15755 For some target machines, GCC supports additional options to the
15756 format attribute
15757 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
15759 @menu
15760 * Solaris Format Checks::
15761 * Darwin Format Checks::
15762 @end menu
15764 @node Solaris Format Checks
15765 @subsection Solaris Format Checks
15767 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
15768 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
15769 conversions, and the two-argument @code{%b} conversion for displaying
15770 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
15772 @node Darwin Format Checks
15773 @subsection Darwin Format Checks
15775 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
15776 attribute context.  Declarations made with such attribution are parsed for correct syntax
15777 and format argument types.  However, parsing of the format string itself is currently undefined
15778 and is not carried out by this version of the compiler.
15780 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
15781 also be used as format arguments.  Note that the relevant headers are only likely to be
15782 available on Darwin (OSX) installations.  On such installations, the XCode and system
15783 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
15784 associated functions.
15786 @node Pragmas
15787 @section Pragmas Accepted by GCC
15788 @cindex pragmas
15789 @cindex @code{#pragma}
15791 GCC supports several types of pragmas, primarily in order to compile
15792 code originally written for other compilers.  Note that in general
15793 we do not recommend the use of pragmas; @xref{Function Attributes},
15794 for further explanation.
15796 @menu
15797 * ARM Pragmas::
15798 * M32C Pragmas::
15799 * MeP Pragmas::
15800 * RS/6000 and PowerPC Pragmas::
15801 * Darwin Pragmas::
15802 * Solaris Pragmas::
15803 * Symbol-Renaming Pragmas::
15804 * Structure-Packing Pragmas::
15805 * Weak Pragmas::
15806 * Diagnostic Pragmas::
15807 * Visibility Pragmas::
15808 * Push/Pop Macro Pragmas::
15809 * Function Specific Option Pragmas::
15810 * Loop-Specific Pragmas::
15811 @end menu
15813 @node ARM Pragmas
15814 @subsection ARM Pragmas
15816 The ARM target defines pragmas for controlling the default addition of
15817 @code{long_call} and @code{short_call} attributes to functions.
15818 @xref{Function Attributes}, for information about the effects of these
15819 attributes.
15821 @table @code
15822 @item long_calls
15823 @cindex pragma, long_calls
15824 Set all subsequent functions to have the @code{long_call} attribute.
15826 @item no_long_calls
15827 @cindex pragma, no_long_calls
15828 Set all subsequent functions to have the @code{short_call} attribute.
15830 @item long_calls_off
15831 @cindex pragma, long_calls_off
15832 Do not affect the @code{long_call} or @code{short_call} attributes of
15833 subsequent functions.
15834 @end table
15836 @node M32C Pragmas
15837 @subsection M32C Pragmas
15839 @table @code
15840 @item GCC memregs @var{number}
15841 @cindex pragma, memregs
15842 Overrides the command-line option @code{-memregs=} for the current
15843 file.  Use with care!  This pragma must be before any function in the
15844 file, and mixing different memregs values in different objects may
15845 make them incompatible.  This pragma is useful when a
15846 performance-critical function uses a memreg for temporary values,
15847 as it may allow you to reduce the number of memregs used.
15849 @item ADDRESS @var{name} @var{address}
15850 @cindex pragma, address
15851 For any declared symbols matching @var{name}, this does three things
15852 to that symbol: it forces the symbol to be located at the given
15853 address (a number), it forces the symbol to be volatile, and it
15854 changes the symbol's scope to be static.  This pragma exists for
15855 compatibility with other compilers, but note that the common
15856 @code{1234H} numeric syntax is not supported (use @code{0x1234}
15857 instead).  Example:
15859 @smallexample
15860 #pragma ADDRESS port3 0x103
15861 char port3;
15862 @end smallexample
15864 @end table
15866 @node MeP Pragmas
15867 @subsection MeP Pragmas
15869 @table @code
15871 @item custom io_volatile (on|off)
15872 @cindex pragma, custom io_volatile
15873 Overrides the command-line option @code{-mio-volatile} for the current
15874 file.  Note that for compatibility with future GCC releases, this
15875 option should only be used once before any @code{io} variables in each
15876 file.
15878 @item GCC coprocessor available @var{registers}
15879 @cindex pragma, coprocessor available
15880 Specifies which coprocessor registers are available to the register
15881 allocator.  @var{registers} may be a single register, register range
15882 separated by ellipses, or comma-separated list of those.  Example:
15884 @smallexample
15885 #pragma GCC coprocessor available $c0...$c10, $c28
15886 @end smallexample
15888 @item GCC coprocessor call_saved @var{registers}
15889 @cindex pragma, coprocessor call_saved
15890 Specifies which coprocessor registers are to be saved and restored by
15891 any function using them.  @var{registers} may be a single register,
15892 register range separated by ellipses, or comma-separated list of
15893 those.  Example:
15895 @smallexample
15896 #pragma GCC coprocessor call_saved $c4...$c6, $c31
15897 @end smallexample
15899 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
15900 @cindex pragma, coprocessor subclass
15901 Creates and defines a register class.  These register classes can be
15902 used by inline @code{asm} constructs.  @var{registers} may be a single
15903 register, register range separated by ellipses, or comma-separated
15904 list of those.  Example:
15906 @smallexample
15907 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
15909 asm ("cpfoo %0" : "=B" (x));
15910 @end smallexample
15912 @item GCC disinterrupt @var{name} , @var{name} @dots{}
15913 @cindex pragma, disinterrupt
15914 For the named functions, the compiler adds code to disable interrupts
15915 for the duration of those functions.  If any functions so named 
15916 are not encountered in the source, a warning is emitted that the pragma is
15917 not used.  Examples:
15919 @smallexample
15920 #pragma disinterrupt foo
15921 #pragma disinterrupt bar, grill
15922 int foo () @{ @dots{} @}
15923 @end smallexample
15925 @item GCC call @var{name} , @var{name} @dots{}
15926 @cindex pragma, call
15927 For the named functions, the compiler always uses a register-indirect
15928 call model when calling the named functions.  Examples:
15930 @smallexample
15931 extern int foo ();
15932 #pragma call foo
15933 @end smallexample
15935 @end table
15937 @node RS/6000 and PowerPC Pragmas
15938 @subsection RS/6000 and PowerPC Pragmas
15940 The RS/6000 and PowerPC targets define one pragma for controlling
15941 whether or not the @code{longcall} attribute is added to function
15942 declarations by default.  This pragma overrides the @option{-mlongcall}
15943 option, but not the @code{longcall} and @code{shortcall} attributes.
15944 @xref{RS/6000 and PowerPC Options}, for more information about when long
15945 calls are and are not necessary.
15947 @table @code
15948 @item longcall (1)
15949 @cindex pragma, longcall
15950 Apply the @code{longcall} attribute to all subsequent function
15951 declarations.
15953 @item longcall (0)
15954 Do not apply the @code{longcall} attribute to subsequent function
15955 declarations.
15956 @end table
15958 @c Describe h8300 pragmas here.
15959 @c Describe sh pragmas here.
15960 @c Describe v850 pragmas here.
15962 @node Darwin Pragmas
15963 @subsection Darwin Pragmas
15965 The following pragmas are available for all architectures running the
15966 Darwin operating system.  These are useful for compatibility with other
15967 Mac OS compilers.
15969 @table @code
15970 @item mark @var{tokens}@dots{}
15971 @cindex pragma, mark
15972 This pragma is accepted, but has no effect.
15974 @item options align=@var{alignment}
15975 @cindex pragma, options align
15976 This pragma sets the alignment of fields in structures.  The values of
15977 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
15978 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
15979 properly; to restore the previous setting, use @code{reset} for the
15980 @var{alignment}.
15982 @item segment @var{tokens}@dots{}
15983 @cindex pragma, segment
15984 This pragma is accepted, but has no effect.
15986 @item unused (@var{var} [, @var{var}]@dots{})
15987 @cindex pragma, unused
15988 This pragma declares variables to be possibly unused.  GCC does not
15989 produce warnings for the listed variables.  The effect is similar to
15990 that of the @code{unused} attribute, except that this pragma may appear
15991 anywhere within the variables' scopes.
15992 @end table
15994 @node Solaris Pragmas
15995 @subsection Solaris Pragmas
15997 The Solaris target supports @code{#pragma redefine_extname}
15998 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
15999 @code{#pragma} directives for compatibility with the system compiler.
16001 @table @code
16002 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
16003 @cindex pragma, align
16005 Increase the minimum alignment of each @var{variable} to @var{alignment}.
16006 This is the same as GCC's @code{aligned} attribute @pxref{Variable
16007 Attributes}).  Macro expansion occurs on the arguments to this pragma
16008 when compiling C and Objective-C@.  It does not currently occur when
16009 compiling C++, but this is a bug which may be fixed in a future
16010 release.
16012 @item fini (@var{function} [, @var{function}]...)
16013 @cindex pragma, fini
16015 This pragma causes each listed @var{function} to be called after
16016 main, or during shared module unloading, by adding a call to the
16017 @code{.fini} section.
16019 @item init (@var{function} [, @var{function}]...)
16020 @cindex pragma, init
16022 This pragma causes each listed @var{function} to be called during
16023 initialization (before @code{main}) or during shared module loading, by
16024 adding a call to the @code{.init} section.
16026 @end table
16028 @node Symbol-Renaming Pragmas
16029 @subsection Symbol-Renaming Pragmas
16031 For compatibility with the Solaris system headers, GCC
16032 supports two @code{#pragma} directives that change the name used in
16033 assembly for a given declaration. To get this effect
16034 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
16035 Labels}).
16037 @table @code
16038 @item redefine_extname @var{oldname} @var{newname}
16039 @cindex pragma, redefine_extname
16041 This pragma gives the C function @var{oldname} the assembly symbol
16042 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
16043 is defined if this pragma is available (currently on all platforms).
16044 @end table
16046 This pragma and the asm labels extension interact in a complicated
16047 manner.  Here are some corner cases you may want to be aware of.
16049 @enumerate
16050 @item Both pragmas silently apply only to declarations with external
16051 linkage.  Asm labels do not have this restriction.
16053 @item In C++, both pragmas silently apply only to declarations with
16054 ``C'' linkage.  Again, asm labels do not have this restriction.
16056 @item If any of the three ways of changing the assembly name of a
16057 declaration is applied to a declaration whose assembly name has
16058 already been determined (either by a previous use of one of these
16059 features, or because the compiler needed the assembly name in order to
16060 generate code), and the new name is different, a warning issues and
16061 the name does not change.
16063 @item The @var{oldname} used by @code{#pragma redefine_extname} is
16064 always the C-language name.
16065 @end enumerate
16067 @node Structure-Packing Pragmas
16068 @subsection Structure-Packing Pragmas
16070 For compatibility with Microsoft Windows compilers, GCC supports a
16071 set of @code{#pragma} directives that change the maximum alignment of
16072 members of structures (other than zero-width bit-fields), unions, and
16073 classes subsequently defined. The @var{n} value below always is required
16074 to be a small power of two and specifies the new alignment in bytes.
16076 @enumerate
16077 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
16078 @item @code{#pragma pack()} sets the alignment to the one that was in
16079 effect when compilation started (see also command-line option
16080 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
16081 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
16082 setting on an internal stack and then optionally sets the new alignment.
16083 @item @code{#pragma pack(pop)} restores the alignment setting to the one
16084 saved at the top of the internal stack (and removes that stack entry).
16085 Note that @code{#pragma pack([@var{n}])} does not influence this internal
16086 stack; thus it is possible to have @code{#pragma pack(push)} followed by
16087 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
16088 @code{#pragma pack(pop)}.
16089 @end enumerate
16091 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
16092 @code{#pragma} which lays out a structure as the documented
16093 @code{__attribute__ ((ms_struct))}.
16094 @enumerate
16095 @item @code{#pragma ms_struct on} turns on the layout for structures
16096 declared.
16097 @item @code{#pragma ms_struct off} turns off the layout for structures
16098 declared.
16099 @item @code{#pragma ms_struct reset} goes back to the default layout.
16100 @end enumerate
16102 @node Weak Pragmas
16103 @subsection Weak Pragmas
16105 For compatibility with SVR4, GCC supports a set of @code{#pragma}
16106 directives for declaring symbols to be weak, and defining weak
16107 aliases.
16109 @table @code
16110 @item #pragma weak @var{symbol}
16111 @cindex pragma, weak
16112 This pragma declares @var{symbol} to be weak, as if the declaration
16113 had the attribute of the same name.  The pragma may appear before
16114 or after the declaration of @var{symbol}.  It is not an error for
16115 @var{symbol} to never be defined at all.
16117 @item #pragma weak @var{symbol1} = @var{symbol2}
16118 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
16119 It is an error if @var{symbol2} is not defined in the current
16120 translation unit.
16121 @end table
16123 @node Diagnostic Pragmas
16124 @subsection Diagnostic Pragmas
16126 GCC allows the user to selectively enable or disable certain types of
16127 diagnostics, and change the kind of the diagnostic.  For example, a
16128 project's policy might require that all sources compile with
16129 @option{-Werror} but certain files might have exceptions allowing
16130 specific types of warnings.  Or, a project might selectively enable
16131 diagnostics and treat them as errors depending on which preprocessor
16132 macros are defined.
16134 @table @code
16135 @item #pragma GCC diagnostic @var{kind} @var{option}
16136 @cindex pragma, diagnostic
16138 Modifies the disposition of a diagnostic.  Note that not all
16139 diagnostics are modifiable; at the moment only warnings (normally
16140 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
16141 Use @option{-fdiagnostics-show-option} to determine which diagnostics
16142 are controllable and which option controls them.
16144 @var{kind} is @samp{error} to treat this diagnostic as an error,
16145 @samp{warning} to treat it like a warning (even if @option{-Werror} is
16146 in effect), or @samp{ignored} if the diagnostic is to be ignored.
16147 @var{option} is a double quoted string that matches the command-line
16148 option.
16150 @smallexample
16151 #pragma GCC diagnostic warning "-Wformat"
16152 #pragma GCC diagnostic error "-Wformat"
16153 #pragma GCC diagnostic ignored "-Wformat"
16154 @end smallexample
16156 Note that these pragmas override any command-line options.  GCC keeps
16157 track of the location of each pragma, and issues diagnostics according
16158 to the state as of that point in the source file.  Thus, pragmas occurring
16159 after a line do not affect diagnostics caused by that line.
16161 @item #pragma GCC diagnostic push
16162 @itemx #pragma GCC diagnostic pop
16164 Causes GCC to remember the state of the diagnostics as of each
16165 @code{push}, and restore to that point at each @code{pop}.  If a
16166 @code{pop} has no matching @code{push}, the command-line options are
16167 restored.
16169 @smallexample
16170 #pragma GCC diagnostic error "-Wuninitialized"
16171   foo(a);                       /* error is given for this one */
16172 #pragma GCC diagnostic push
16173 #pragma GCC diagnostic ignored "-Wuninitialized"
16174   foo(b);                       /* no diagnostic for this one */
16175 #pragma GCC diagnostic pop
16176   foo(c);                       /* error is given for this one */
16177 #pragma GCC diagnostic pop
16178   foo(d);                       /* depends on command-line options */
16179 @end smallexample
16181 @end table
16183 GCC also offers a simple mechanism for printing messages during
16184 compilation.
16186 @table @code
16187 @item #pragma message @var{string}
16188 @cindex pragma, diagnostic
16190 Prints @var{string} as a compiler message on compilation.  The message
16191 is informational only, and is neither a compilation warning nor an error.
16193 @smallexample
16194 #pragma message "Compiling " __FILE__ "..."
16195 @end smallexample
16197 @var{string} may be parenthesized, and is printed with location
16198 information.  For example,
16200 @smallexample
16201 #define DO_PRAGMA(x) _Pragma (#x)
16202 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
16204 TODO(Remember to fix this)
16205 @end smallexample
16207 @noindent
16208 prints @samp{/tmp/file.c:4: note: #pragma message:
16209 TODO - Remember to fix this}.
16211 @end table
16213 @node Visibility Pragmas
16214 @subsection Visibility Pragmas
16216 @table @code
16217 @item #pragma GCC visibility push(@var{visibility})
16218 @itemx #pragma GCC visibility pop
16219 @cindex pragma, visibility
16221 This pragma allows the user to set the visibility for multiple
16222 declarations without having to give each a visibility attribute
16223 @xref{Function Attributes}, for more information about visibility and
16224 the attribute syntax.
16226 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
16227 declarations.  Class members and template specializations are not
16228 affected; if you want to override the visibility for a particular
16229 member or instantiation, you must use an attribute.
16231 @end table
16234 @node Push/Pop Macro Pragmas
16235 @subsection Push/Pop Macro Pragmas
16237 For compatibility with Microsoft Windows compilers, GCC supports
16238 @samp{#pragma push_macro(@var{"macro_name"})}
16239 and @samp{#pragma pop_macro(@var{"macro_name"})}.
16241 @table @code
16242 @item #pragma push_macro(@var{"macro_name"})
16243 @cindex pragma, push_macro
16244 This pragma saves the value of the macro named as @var{macro_name} to
16245 the top of the stack for this macro.
16247 @item #pragma pop_macro(@var{"macro_name"})
16248 @cindex pragma, pop_macro
16249 This pragma sets the value of the macro named as @var{macro_name} to
16250 the value on top of the stack for this macro. If the stack for
16251 @var{macro_name} is empty, the value of the macro remains unchanged.
16252 @end table
16254 For example:
16256 @smallexample
16257 #define X  1
16258 #pragma push_macro("X")
16259 #undef X
16260 #define X -1
16261 #pragma pop_macro("X")
16262 int x [X];
16263 @end smallexample
16265 @noindent
16266 In this example, the definition of X as 1 is saved by @code{#pragma
16267 push_macro} and restored by @code{#pragma pop_macro}.
16269 @node Function Specific Option Pragmas
16270 @subsection Function Specific Option Pragmas
16272 @table @code
16273 @item #pragma GCC target (@var{"string"}...)
16274 @cindex pragma GCC target
16276 This pragma allows you to set target specific options for functions
16277 defined later in the source file.  One or more strings can be
16278 specified.  Each function that is defined after this point is as
16279 if @code{attribute((target("STRING")))} was specified for that
16280 function.  The parenthesis around the options is optional.
16281 @xref{Function Attributes}, for more information about the
16282 @code{target} attribute and the attribute syntax.
16284 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
16285 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends.  At
16286 present, it is not implemented for other back ends.
16287 @end table
16289 @table @code
16290 @item #pragma GCC optimize (@var{"string"}...)
16291 @cindex pragma GCC optimize
16293 This pragma allows you to set global optimization options for functions
16294 defined later in the source file.  One or more strings can be
16295 specified.  Each function that is defined after this point is as
16296 if @code{attribute((optimize("STRING")))} was specified for that
16297 function.  The parenthesis around the options is optional.
16298 @xref{Function Attributes}, for more information about the
16299 @code{optimize} attribute and the attribute syntax.
16301 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
16302 versions earlier than 4.4.
16303 @end table
16305 @table @code
16306 @item #pragma GCC push_options
16307 @itemx #pragma GCC pop_options
16308 @cindex pragma GCC push_options
16309 @cindex pragma GCC pop_options
16311 These pragmas maintain a stack of the current target and optimization
16312 options.  It is intended for include files where you temporarily want
16313 to switch to using a different @samp{#pragma GCC target} or
16314 @samp{#pragma GCC optimize} and then to pop back to the previous
16315 options.
16317 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
16318 pragmas are not implemented in GCC versions earlier than 4.4.
16319 @end table
16321 @table @code
16322 @item #pragma GCC reset_options
16323 @cindex pragma GCC reset_options
16325 This pragma clears the current @code{#pragma GCC target} and
16326 @code{#pragma GCC optimize} to use the default switches as specified
16327 on the command line.
16329 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
16330 versions earlier than 4.4.
16331 @end table
16333 @node Loop-Specific Pragmas
16334 @subsection Loop-Specific Pragmas
16336 @table @code
16337 @item #pragma GCC ivdep
16338 @cindex pragma GCC ivdep
16339 @end table
16341 With this pragma, the programmer asserts that there are no loop-carried
16342 dependencies which would prevent that consecutive iterations of
16343 the following loop can be executed concurrently with SIMD
16344 (single instruction multiple data) instructions.
16346 For example, the compiler can only unconditionally vectorize the following
16347 loop with the pragma:
16349 @smallexample
16350 void foo (int n, int *a, int *b, int *c)
16352   int i, j;
16353 #pragma GCC ivdep
16354   for (i = 0; i < n; ++i)
16355     a[i] = b[i] + c[i];
16357 @end smallexample
16359 @noindent
16360 In this example, using the @code{restrict} qualifier had the same
16361 effect. In the following example, that would not be possible. Assume
16362 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
16363 that it can unconditionally vectorize the following loop:
16365 @smallexample
16366 void ignore_vec_dep (int *a, int k, int c, int m)
16368 #pragma GCC ivdep
16369   for (int i = 0; i < m; i++)
16370     a[i] = a[i + k] * c;
16372 @end smallexample
16375 @node Unnamed Fields
16376 @section Unnamed struct/union fields within structs/unions
16377 @cindex @code{struct}
16378 @cindex @code{union}
16380 As permitted by ISO C11 and for compatibility with other compilers,
16381 GCC allows you to define
16382 a structure or union that contains, as fields, structures and unions
16383 without names.  For example:
16385 @smallexample
16386 struct @{
16387   int a;
16388   union @{
16389     int b;
16390     float c;
16391   @};
16392   int d;
16393 @} foo;
16394 @end smallexample
16396 @noindent
16397 In this example, you are able to access members of the unnamed
16398 union with code like @samp{foo.b}.  Note that only unnamed structs and
16399 unions are allowed, you may not have, for example, an unnamed
16400 @code{int}.
16402 You must never create such structures that cause ambiguous field definitions.
16403 For example, in this structure:
16405 @smallexample
16406 struct @{
16407   int a;
16408   struct @{
16409     int a;
16410   @};
16411 @} foo;
16412 @end smallexample
16414 @noindent
16415 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
16416 The compiler gives errors for such constructs.
16418 @opindex fms-extensions
16419 Unless @option{-fms-extensions} is used, the unnamed field must be a
16420 structure or union definition without a tag (for example, @samp{struct
16421 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
16422 also be a definition with a tag such as @samp{struct foo @{ int a;
16423 @};}, a reference to a previously defined structure or union such as
16424 @samp{struct foo;}, or a reference to a @code{typedef} name for a
16425 previously defined structure or union type.
16427 @opindex fplan9-extensions
16428 The option @option{-fplan9-extensions} enables
16429 @option{-fms-extensions} as well as two other extensions.  First, a
16430 pointer to a structure is automatically converted to a pointer to an
16431 anonymous field for assignments and function calls.  For example:
16433 @smallexample
16434 struct s1 @{ int a; @};
16435 struct s2 @{ struct s1; @};
16436 extern void f1 (struct s1 *);
16437 void f2 (struct s2 *p) @{ f1 (p); @}
16438 @end smallexample
16440 @noindent
16441 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
16442 converted into a pointer to the anonymous field.
16444 Second, when the type of an anonymous field is a @code{typedef} for a
16445 @code{struct} or @code{union}, code may refer to the field using the
16446 name of the @code{typedef}.
16448 @smallexample
16449 typedef struct @{ int a; @} s1;
16450 struct s2 @{ s1; @};
16451 s1 f1 (struct s2 *p) @{ return p->s1; @}
16452 @end smallexample
16454 These usages are only permitted when they are not ambiguous.
16456 @node Thread-Local
16457 @section Thread-Local Storage
16458 @cindex Thread-Local Storage
16459 @cindex @acronym{TLS}
16460 @cindex @code{__thread}
16462 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
16463 are allocated such that there is one instance of the variable per extant
16464 thread.  The runtime model GCC uses to implement this originates
16465 in the IA-64 processor-specific ABI, but has since been migrated
16466 to other processors as well.  It requires significant support from
16467 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
16468 system libraries (@file{libc.so} and @file{libpthread.so}), so it
16469 is not available everywhere.
16471 At the user level, the extension is visible with a new storage
16472 class keyword: @code{__thread}.  For example:
16474 @smallexample
16475 __thread int i;
16476 extern __thread struct state s;
16477 static __thread char *p;
16478 @end smallexample
16480 The @code{__thread} specifier may be used alone, with the @code{extern}
16481 or @code{static} specifiers, but with no other storage class specifier.
16482 When used with @code{extern} or @code{static}, @code{__thread} must appear
16483 immediately after the other storage class specifier.
16485 The @code{__thread} specifier may be applied to any global, file-scoped
16486 static, function-scoped static, or static data member of a class.  It may
16487 not be applied to block-scoped automatic or non-static data member.
16489 When the address-of operator is applied to a thread-local variable, it is
16490 evaluated at run time and returns the address of the current thread's
16491 instance of that variable.  An address so obtained may be used by any
16492 thread.  When a thread terminates, any pointers to thread-local variables
16493 in that thread become invalid.
16495 No static initialization may refer to the address of a thread-local variable.
16497 In C++, if an initializer is present for a thread-local variable, it must
16498 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
16499 standard.
16501 See @uref{http://www.akkadia.org/drepper/tls.pdf,
16502 ELF Handling For Thread-Local Storage} for a detailed explanation of
16503 the four thread-local storage addressing models, and how the runtime
16504 is expected to function.
16506 @menu
16507 * C99 Thread-Local Edits::
16508 * C++98 Thread-Local Edits::
16509 @end menu
16511 @node C99 Thread-Local Edits
16512 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
16514 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
16515 that document the exact semantics of the language extension.
16517 @itemize @bullet
16518 @item
16519 @cite{5.1.2  Execution environments}
16521 Add new text after paragraph 1
16523 @quotation
16524 Within either execution environment, a @dfn{thread} is a flow of
16525 control within a program.  It is implementation defined whether
16526 or not there may be more than one thread associated with a program.
16527 It is implementation defined how threads beyond the first are
16528 created, the name and type of the function called at thread
16529 startup, and how threads may be terminated.  However, objects
16530 with thread storage duration shall be initialized before thread
16531 startup.
16532 @end quotation
16534 @item
16535 @cite{6.2.4  Storage durations of objects}
16537 Add new text before paragraph 3
16539 @quotation
16540 An object whose identifier is declared with the storage-class
16541 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
16542 Its lifetime is the entire execution of the thread, and its
16543 stored value is initialized only once, prior to thread startup.
16544 @end quotation
16546 @item
16547 @cite{6.4.1  Keywords}
16549 Add @code{__thread}.
16551 @item
16552 @cite{6.7.1  Storage-class specifiers}
16554 Add @code{__thread} to the list of storage class specifiers in
16555 paragraph 1.
16557 Change paragraph 2 to
16559 @quotation
16560 With the exception of @code{__thread}, at most one storage-class
16561 specifier may be given [@dots{}].  The @code{__thread} specifier may
16562 be used alone, or immediately following @code{extern} or
16563 @code{static}.
16564 @end quotation
16566 Add new text after paragraph 6
16568 @quotation
16569 The declaration of an identifier for a variable that has
16570 block scope that specifies @code{__thread} shall also
16571 specify either @code{extern} or @code{static}.
16573 The @code{__thread} specifier shall be used only with
16574 variables.
16575 @end quotation
16576 @end itemize
16578 @node C++98 Thread-Local Edits
16579 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
16581 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
16582 that document the exact semantics of the language extension.
16584 @itemize @bullet
16585 @item
16586 @b{[intro.execution]}
16588 New text after paragraph 4
16590 @quotation
16591 A @dfn{thread} is a flow of control within the abstract machine.
16592 It is implementation defined whether or not there may be more than
16593 one thread.
16594 @end quotation
16596 New text after paragraph 7
16598 @quotation
16599 It is unspecified whether additional action must be taken to
16600 ensure when and whether side effects are visible to other threads.
16601 @end quotation
16603 @item
16604 @b{[lex.key]}
16606 Add @code{__thread}.
16608 @item
16609 @b{[basic.start.main]}
16611 Add after paragraph 5
16613 @quotation
16614 The thread that begins execution at the @code{main} function is called
16615 the @dfn{main thread}.  It is implementation defined how functions
16616 beginning threads other than the main thread are designated or typed.
16617 A function so designated, as well as the @code{main} function, is called
16618 a @dfn{thread startup function}.  It is implementation defined what
16619 happens if a thread startup function returns.  It is implementation
16620 defined what happens to other threads when any thread calls @code{exit}.
16621 @end quotation
16623 @item
16624 @b{[basic.start.init]}
16626 Add after paragraph 4
16628 @quotation
16629 The storage for an object of thread storage duration shall be
16630 statically initialized before the first statement of the thread startup
16631 function.  An object of thread storage duration shall not require
16632 dynamic initialization.
16633 @end quotation
16635 @item
16636 @b{[basic.start.term]}
16638 Add after paragraph 3
16640 @quotation
16641 The type of an object with thread storage duration shall not have a
16642 non-trivial destructor, nor shall it be an array type whose elements
16643 (directly or indirectly) have non-trivial destructors.
16644 @end quotation
16646 @item
16647 @b{[basic.stc]}
16649 Add ``thread storage duration'' to the list in paragraph 1.
16651 Change paragraph 2
16653 @quotation
16654 Thread, static, and automatic storage durations are associated with
16655 objects introduced by declarations [@dots{}].
16656 @end quotation
16658 Add @code{__thread} to the list of specifiers in paragraph 3.
16660 @item
16661 @b{[basic.stc.thread]}
16663 New section before @b{[basic.stc.static]}
16665 @quotation
16666 The keyword @code{__thread} applied to a non-local object gives the
16667 object thread storage duration.
16669 A local variable or class data member declared both @code{static}
16670 and @code{__thread} gives the variable or member thread storage
16671 duration.
16672 @end quotation
16674 @item
16675 @b{[basic.stc.static]}
16677 Change paragraph 1
16679 @quotation
16680 All objects that have neither thread storage duration, dynamic
16681 storage duration nor are local [@dots{}].
16682 @end quotation
16684 @item
16685 @b{[dcl.stc]}
16687 Add @code{__thread} to the list in paragraph 1.
16689 Change paragraph 1
16691 @quotation
16692 With the exception of @code{__thread}, at most one
16693 @var{storage-class-specifier} shall appear in a given
16694 @var{decl-specifier-seq}.  The @code{__thread} specifier may
16695 be used alone, or immediately following the @code{extern} or
16696 @code{static} specifiers.  [@dots{}]
16697 @end quotation
16699 Add after paragraph 5
16701 @quotation
16702 The @code{__thread} specifier can be applied only to the names of objects
16703 and to anonymous unions.
16704 @end quotation
16706 @item
16707 @b{[class.mem]}
16709 Add after paragraph 6
16711 @quotation
16712 Non-@code{static} members shall not be @code{__thread}.
16713 @end quotation
16714 @end itemize
16716 @node Binary constants
16717 @section Binary constants using the @samp{0b} prefix
16718 @cindex Binary constants using the @samp{0b} prefix
16720 Integer constants can be written as binary constants, consisting of a
16721 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
16722 @samp{0B}.  This is particularly useful in environments that operate a
16723 lot on the bit level (like microcontrollers).
16725 The following statements are identical:
16727 @smallexample
16728 i =       42;
16729 i =     0x2a;
16730 i =      052;
16731 i = 0b101010;
16732 @end smallexample
16734 The type of these constants follows the same rules as for octal or
16735 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
16736 can be applied.
16738 @node C++ Extensions
16739 @chapter Extensions to the C++ Language
16740 @cindex extensions, C++ language
16741 @cindex C++ language extensions
16743 The GNU compiler provides these extensions to the C++ language (and you
16744 can also use most of the C language extensions in your C++ programs).  If you
16745 want to write code that checks whether these features are available, you can
16746 test for the GNU compiler the same way as for C programs: check for a
16747 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
16748 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
16749 Predefined Macros,cpp,The GNU C Preprocessor}).
16751 @menu
16752 * C++ Volatiles::       What constitutes an access to a volatile object.
16753 * Restricted Pointers:: C99 restricted pointers and references.
16754 * Vague Linkage::       Where G++ puts inlines, vtables and such.
16755 * C++ Interface::       You can use a single C++ header file for both
16756                         declarations and definitions.
16757 * Template Instantiation:: Methods for ensuring that exactly one copy of
16758                         each needed template instantiation is emitted.
16759 * Bound member functions:: You can extract a function pointer to the
16760                         method denoted by a @samp{->*} or @samp{.*} expression.
16761 * C++ Attributes::      Variable, function, and type attributes for C++ only.
16762 * Function Multiversioning::   Declaring multiple function versions.
16763 * Namespace Association:: Strong using-directives for namespace association.
16764 * Type Traits::         Compiler support for type traits
16765 * Java Exceptions::     Tweaking exception handling to work with Java.
16766 * Deprecated Features:: Things will disappear from G++.
16767 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
16768 @end menu
16770 @node C++ Volatiles
16771 @section When is a Volatile C++ Object Accessed?
16772 @cindex accessing volatiles
16773 @cindex volatile read
16774 @cindex volatile write
16775 @cindex volatile access
16777 The C++ standard differs from the C standard in its treatment of
16778 volatile objects.  It fails to specify what constitutes a volatile
16779 access, except to say that C++ should behave in a similar manner to C
16780 with respect to volatiles, where possible.  However, the different
16781 lvalueness of expressions between C and C++ complicate the behavior.
16782 G++ behaves the same as GCC for volatile access, @xref{C
16783 Extensions,,Volatiles}, for a description of GCC's behavior.
16785 The C and C++ language specifications differ when an object is
16786 accessed in a void context:
16788 @smallexample
16789 volatile int *src = @var{somevalue};
16790 *src;
16791 @end smallexample
16793 The C++ standard specifies that such expressions do not undergo lvalue
16794 to rvalue conversion, and that the type of the dereferenced object may
16795 be incomplete.  The C++ standard does not specify explicitly that it
16796 is lvalue to rvalue conversion that is responsible for causing an
16797 access.  There is reason to believe that it is, because otherwise
16798 certain simple expressions become undefined.  However, because it
16799 would surprise most programmers, G++ treats dereferencing a pointer to
16800 volatile object of complete type as GCC would do for an equivalent
16801 type in C@.  When the object has incomplete type, G++ issues a
16802 warning; if you wish to force an error, you must force a conversion to
16803 rvalue with, for instance, a static cast.
16805 When using a reference to volatile, G++ does not treat equivalent
16806 expressions as accesses to volatiles, but instead issues a warning that
16807 no volatile is accessed.  The rationale for this is that otherwise it
16808 becomes difficult to determine where volatile access occur, and not
16809 possible to ignore the return value from functions returning volatile
16810 references.  Again, if you wish to force a read, cast the reference to
16811 an rvalue.
16813 G++ implements the same behavior as GCC does when assigning to a
16814 volatile object---there is no reread of the assigned-to object, the
16815 assigned rvalue is reused.  Note that in C++ assignment expressions
16816 are lvalues, and if used as an lvalue, the volatile object is
16817 referred to.  For instance, @var{vref} refers to @var{vobj}, as
16818 expected, in the following example:
16820 @smallexample
16821 volatile int vobj;
16822 volatile int &vref = vobj = @var{something};
16823 @end smallexample
16825 @node Restricted Pointers
16826 @section Restricting Pointer Aliasing
16827 @cindex restricted pointers
16828 @cindex restricted references
16829 @cindex restricted this pointer
16831 As with the C front end, G++ understands the C99 feature of restricted pointers,
16832 specified with the @code{__restrict__}, or @code{__restrict} type
16833 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
16834 language flag, @code{restrict} is not a keyword in C++.
16836 In addition to allowing restricted pointers, you can specify restricted
16837 references, which indicate that the reference is not aliased in the local
16838 context.
16840 @smallexample
16841 void fn (int *__restrict__ rptr, int &__restrict__ rref)
16843   /* @r{@dots{}} */
16845 @end smallexample
16847 @noindent
16848 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
16849 @var{rref} refers to a (different) unaliased integer.
16851 You may also specify whether a member function's @var{this} pointer is
16852 unaliased by using @code{__restrict__} as a member function qualifier.
16854 @smallexample
16855 void T::fn () __restrict__
16857   /* @r{@dots{}} */
16859 @end smallexample
16861 @noindent
16862 Within the body of @code{T::fn}, @var{this} has the effective
16863 definition @code{T *__restrict__ const this}.  Notice that the
16864 interpretation of a @code{__restrict__} member function qualifier is
16865 different to that of @code{const} or @code{volatile} qualifier, in that it
16866 is applied to the pointer rather than the object.  This is consistent with
16867 other compilers that implement restricted pointers.
16869 As with all outermost parameter qualifiers, @code{__restrict__} is
16870 ignored in function definition matching.  This means you only need to
16871 specify @code{__restrict__} in a function definition, rather than
16872 in a function prototype as well.
16874 @node Vague Linkage
16875 @section Vague Linkage
16876 @cindex vague linkage
16878 There are several constructs in C++ that require space in the object
16879 file but are not clearly tied to a single translation unit.  We say that
16880 these constructs have ``vague linkage''.  Typically such constructs are
16881 emitted wherever they are needed, though sometimes we can be more
16882 clever.
16884 @table @asis
16885 @item Inline Functions
16886 Inline functions are typically defined in a header file which can be
16887 included in many different compilations.  Hopefully they can usually be
16888 inlined, but sometimes an out-of-line copy is necessary, if the address
16889 of the function is taken or if inlining fails.  In general, we emit an
16890 out-of-line copy in all translation units where one is needed.  As an
16891 exception, we only emit inline virtual functions with the vtable, since
16892 it always requires a copy.
16894 Local static variables and string constants used in an inline function
16895 are also considered to have vague linkage, since they must be shared
16896 between all inlined and out-of-line instances of the function.
16898 @item VTables
16899 @cindex vtable
16900 C++ virtual functions are implemented in most compilers using a lookup
16901 table, known as a vtable.  The vtable contains pointers to the virtual
16902 functions provided by a class, and each object of the class contains a
16903 pointer to its vtable (or vtables, in some multiple-inheritance
16904 situations).  If the class declares any non-inline, non-pure virtual
16905 functions, the first one is chosen as the ``key method'' for the class,
16906 and the vtable is only emitted in the translation unit where the key
16907 method is defined.
16909 @emph{Note:} If the chosen key method is later defined as inline, the
16910 vtable is still emitted in every translation unit that defines it.
16911 Make sure that any inline virtuals are declared inline in the class
16912 body, even if they are not defined there.
16914 @item @code{type_info} objects
16915 @cindex @code{type_info}
16916 @cindex RTTI
16917 C++ requires information about types to be written out in order to
16918 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
16919 For polymorphic classes (classes with virtual functions), the @samp{type_info}
16920 object is written out along with the vtable so that @samp{dynamic_cast}
16921 can determine the dynamic type of a class object at run time.  For all
16922 other types, we write out the @samp{type_info} object when it is used: when
16923 applying @samp{typeid} to an expression, throwing an object, or
16924 referring to a type in a catch clause or exception specification.
16926 @item Template Instantiations
16927 Most everything in this section also applies to template instantiations,
16928 but there are other options as well.
16929 @xref{Template Instantiation,,Where's the Template?}.
16931 @end table
16933 When used with GNU ld version 2.8 or later on an ELF system such as
16934 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
16935 these constructs will be discarded at link time.  This is known as
16936 COMDAT support.
16938 On targets that don't support COMDAT, but do support weak symbols, GCC
16939 uses them.  This way one copy overrides all the others, but
16940 the unused copies still take up space in the executable.
16942 For targets that do not support either COMDAT or weak symbols,
16943 most entities with vague linkage are emitted as local symbols to
16944 avoid duplicate definition errors from the linker.  This does not happen
16945 for local statics in inlines, however, as having multiple copies
16946 almost certainly breaks things.
16948 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
16949 another way to control placement of these constructs.
16951 @node C++ Interface
16952 @section #pragma interface and implementation
16954 @cindex interface and implementation headers, C++
16955 @cindex C++ interface and implementation headers
16956 @cindex pragmas, interface and implementation
16958 @code{#pragma interface} and @code{#pragma implementation} provide the
16959 user with a way of explicitly directing the compiler to emit entities
16960 with vague linkage (and debugging information) in a particular
16961 translation unit.
16963 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
16964 most cases, because of COMDAT support and the ``key method'' heuristic
16965 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
16966 program to grow due to unnecessary out-of-line copies of inline
16967 functions.  Currently (3.4) the only benefit of these
16968 @code{#pragma}s is reduced duplication of debugging information, and
16969 that should be addressed soon on DWARF 2 targets with the use of
16970 COMDAT groups.
16972 @table @code
16973 @item #pragma interface
16974 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
16975 @kindex #pragma interface
16976 Use this directive in @emph{header files} that define object classes, to save
16977 space in most of the object files that use those classes.  Normally,
16978 local copies of certain information (backup copies of inline member
16979 functions, debugging information, and the internal tables that implement
16980 virtual functions) must be kept in each object file that includes class
16981 definitions.  You can use this pragma to avoid such duplication.  When a
16982 header file containing @samp{#pragma interface} is included in a
16983 compilation, this auxiliary information is not generated (unless
16984 the main input source file itself uses @samp{#pragma implementation}).
16985 Instead, the object files contain references to be resolved at link
16986 time.
16988 The second form of this directive is useful for the case where you have
16989 multiple headers with the same name in different directories.  If you
16990 use this form, you must specify the same string to @samp{#pragma
16991 implementation}.
16993 @item #pragma implementation
16994 @itemx #pragma implementation "@var{objects}.h"
16995 @kindex #pragma implementation
16996 Use this pragma in a @emph{main input file}, when you want full output from
16997 included header files to be generated (and made globally visible).  The
16998 included header file, in turn, should use @samp{#pragma interface}.
16999 Backup copies of inline member functions, debugging information, and the
17000 internal tables used to implement virtual functions are all generated in
17001 implementation files.
17003 @cindex implied @code{#pragma implementation}
17004 @cindex @code{#pragma implementation}, implied
17005 @cindex naming convention, implementation headers
17006 If you use @samp{#pragma implementation} with no argument, it applies to
17007 an include file with the same basename@footnote{A file's @dfn{basename}
17008 is the name stripped of all leading path information and of trailing
17009 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
17010 file.  For example, in @file{allclass.cc}, giving just
17011 @samp{#pragma implementation}
17012 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
17014 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
17015 an implementation file whenever you would include it from
17016 @file{allclass.cc} even if you never specified @samp{#pragma
17017 implementation}.  This was deemed to be more trouble than it was worth,
17018 however, and disabled.
17020 Use the string argument if you want a single implementation file to
17021 include code from multiple header files.  (You must also use
17022 @samp{#include} to include the header file; @samp{#pragma
17023 implementation} only specifies how to use the file---it doesn't actually
17024 include it.)
17026 There is no way to split up the contents of a single header file into
17027 multiple implementation files.
17028 @end table
17030 @cindex inlining and C++ pragmas
17031 @cindex C++ pragmas, effect on inlining
17032 @cindex pragmas in C++, effect on inlining
17033 @samp{#pragma implementation} and @samp{#pragma interface} also have an
17034 effect on function inlining.
17036 If you define a class in a header file marked with @samp{#pragma
17037 interface}, the effect on an inline function defined in that class is
17038 similar to an explicit @code{extern} declaration---the compiler emits
17039 no code at all to define an independent version of the function.  Its
17040 definition is used only for inlining with its callers.
17042 @opindex fno-implement-inlines
17043 Conversely, when you include the same header file in a main source file
17044 that declares it as @samp{#pragma implementation}, the compiler emits
17045 code for the function itself; this defines a version of the function
17046 that can be found via pointers (or by callers compiled without
17047 inlining).  If all calls to the function can be inlined, you can avoid
17048 emitting the function by compiling with @option{-fno-implement-inlines}.
17049 If any calls are not inlined, you will get linker errors.
17051 @node Template Instantiation
17052 @section Where's the Template?
17053 @cindex template instantiation
17055 C++ templates are the first language feature to require more
17056 intelligence from the environment than one usually finds on a UNIX
17057 system.  Somehow the compiler and linker have to make sure that each
17058 template instance occurs exactly once in the executable if it is needed,
17059 and not at all otherwise.  There are two basic approaches to this
17060 problem, which are referred to as the Borland model and the Cfront model.
17062 @table @asis
17063 @item Borland model
17064 Borland C++ solved the template instantiation problem by adding the code
17065 equivalent of common blocks to their linker; the compiler emits template
17066 instances in each translation unit that uses them, and the linker
17067 collapses them together.  The advantage of this model is that the linker
17068 only has to consider the object files themselves; there is no external
17069 complexity to worry about.  This disadvantage is that compilation time
17070 is increased because the template code is being compiled repeatedly.
17071 Code written for this model tends to include definitions of all
17072 templates in the header file, since they must be seen to be
17073 instantiated.
17075 @item Cfront model
17076 The AT&T C++ translator, Cfront, solved the template instantiation
17077 problem by creating the notion of a template repository, an
17078 automatically maintained place where template instances are stored.  A
17079 more modern version of the repository works as follows: As individual
17080 object files are built, the compiler places any template definitions and
17081 instantiations encountered in the repository.  At link time, the link
17082 wrapper adds in the objects in the repository and compiles any needed
17083 instances that were not previously emitted.  The advantages of this
17084 model are more optimal compilation speed and the ability to use the
17085 system linker; to implement the Borland model a compiler vendor also
17086 needs to replace the linker.  The disadvantages are vastly increased
17087 complexity, and thus potential for error; for some code this can be
17088 just as transparent, but in practice it can been very difficult to build
17089 multiple programs in one directory and one program in multiple
17090 directories.  Code written for this model tends to separate definitions
17091 of non-inline member templates into a separate file, which should be
17092 compiled separately.
17093 @end table
17095 When used with GNU ld version 2.8 or later on an ELF system such as
17096 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
17097 Borland model.  On other systems, G++ implements neither automatic
17098 model.
17100 You have the following options for dealing with template instantiations:
17102 @enumerate
17103 @item
17104 @opindex frepo
17105 Compile your template-using code with @option{-frepo}.  The compiler
17106 generates files with the extension @samp{.rpo} listing all of the
17107 template instantiations used in the corresponding object files that
17108 could be instantiated there; the link wrapper, @samp{collect2},
17109 then updates the @samp{.rpo} files to tell the compiler where to place
17110 those instantiations and rebuild any affected object files.  The
17111 link-time overhead is negligible after the first pass, as the compiler
17112 continues to place the instantiations in the same files.
17114 This is your best option for application code written for the Borland
17115 model, as it just works.  Code written for the Cfront model 
17116 needs to be modified so that the template definitions are available at
17117 one or more points of instantiation; usually this is as simple as adding
17118 @code{#include <tmethods.cc>} to the end of each template header.
17120 For library code, if you want the library to provide all of the template
17121 instantiations it needs, just try to link all of its object files
17122 together; the link will fail, but cause the instantiations to be
17123 generated as a side effect.  Be warned, however, that this may cause
17124 conflicts if multiple libraries try to provide the same instantiations.
17125 For greater control, use explicit instantiation as described in the next
17126 option.
17128 @item
17129 @opindex fno-implicit-templates
17130 Compile your code with @option{-fno-implicit-templates} to disable the
17131 implicit generation of template instances, and explicitly instantiate
17132 all the ones you use.  This approach requires more knowledge of exactly
17133 which instances you need than do the others, but it's less
17134 mysterious and allows greater control.  You can scatter the explicit
17135 instantiations throughout your program, perhaps putting them in the
17136 translation units where the instances are used or the translation units
17137 that define the templates themselves; you can put all of the explicit
17138 instantiations you need into one big file; or you can create small files
17139 like
17141 @smallexample
17142 #include "Foo.h"
17143 #include "Foo.cc"
17145 template class Foo<int>;
17146 template ostream& operator <<
17147                 (ostream&, const Foo<int>&);
17148 @end smallexample
17150 @noindent
17151 for each of the instances you need, and create a template instantiation
17152 library from those.
17154 If you are using Cfront-model code, you can probably get away with not
17155 using @option{-fno-implicit-templates} when compiling files that don't
17156 @samp{#include} the member template definitions.
17158 If you use one big file to do the instantiations, you may want to
17159 compile it without @option{-fno-implicit-templates} so you get all of the
17160 instances required by your explicit instantiations (but not by any
17161 other files) without having to specify them as well.
17163 The ISO C++ 2011 standard allows forward declaration of explicit
17164 instantiations (with @code{extern}). G++ supports explicit instantiation
17165 declarations in C++98 mode and has extended the template instantiation
17166 syntax to support instantiation of the compiler support data for a
17167 template class (i.e.@: the vtable) without instantiating any of its
17168 members (with @code{inline}), and instantiation of only the static data
17169 members of a template class, without the support data or member
17170 functions (with (@code{static}):
17172 @smallexample
17173 extern template int max (int, int);
17174 inline template class Foo<int>;
17175 static template class Foo<int>;
17176 @end smallexample
17178 @item
17179 Do nothing.  Pretend G++ does implement automatic instantiation
17180 management.  Code written for the Borland model works fine, but
17181 each translation unit contains instances of each of the templates it
17182 uses.  In a large program, this can lead to an unacceptable amount of code
17183 duplication.
17184 @end enumerate
17186 @node Bound member functions
17187 @section Extracting the function pointer from a bound pointer to member function
17188 @cindex pmf
17189 @cindex pointer to member function
17190 @cindex bound pointer to member function
17192 In C++, pointer to member functions (PMFs) are implemented using a wide
17193 pointer of sorts to handle all the possible call mechanisms; the PMF
17194 needs to store information about how to adjust the @samp{this} pointer,
17195 and if the function pointed to is virtual, where to find the vtable, and
17196 where in the vtable to look for the member function.  If you are using
17197 PMFs in an inner loop, you should really reconsider that decision.  If
17198 that is not an option, you can extract the pointer to the function that
17199 would be called for a given object/PMF pair and call it directly inside
17200 the inner loop, to save a bit of time.
17202 Note that you still pay the penalty for the call through a
17203 function pointer; on most modern architectures, such a call defeats the
17204 branch prediction features of the CPU@.  This is also true of normal
17205 virtual function calls.
17207 The syntax for this extension is
17209 @smallexample
17210 extern A a;
17211 extern int (A::*fp)();
17212 typedef int (*fptr)(A *);
17214 fptr p = (fptr)(a.*fp);
17215 @end smallexample
17217 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
17218 no object is needed to obtain the address of the function.  They can be
17219 converted to function pointers directly:
17221 @smallexample
17222 fptr p1 = (fptr)(&A::foo);
17223 @end smallexample
17225 @opindex Wno-pmf-conversions
17226 You must specify @option{-Wno-pmf-conversions} to use this extension.
17228 @node C++ Attributes
17229 @section C++-Specific Variable, Function, and Type Attributes
17231 Some attributes only make sense for C++ programs.
17233 @table @code
17234 @item abi_tag ("@var{tag}", ...)
17235 @cindex @code{abi_tag} attribute
17236 The @code{abi_tag} attribute can be applied to a function or class
17237 declaration.  It modifies the mangled name of the function or class to
17238 incorporate the tag name, in order to distinguish the function or
17239 class from an earlier version with a different ABI; perhaps the class
17240 has changed size, or the function has a different return type that is
17241 not encoded in the mangled name.
17243 The argument can be a list of strings of arbitrary length.  The
17244 strings are sorted on output, so the order of the list is
17245 unimportant.
17247 A redeclaration of a function or class must not add new ABI tags,
17248 since doing so would change the mangled name.
17250 The @option{-Wabi-tag} flag enables a warning about a class which does
17251 not have all the ABI tags used by its subobjects and virtual functions; for users with code
17252 that needs to coexist with an earlier ABI, using this option can help
17253 to find all affected types that need to be tagged.
17255 @item init_priority (@var{priority})
17256 @cindex @code{init_priority} attribute
17259 In Standard C++, objects defined at namespace scope are guaranteed to be
17260 initialized in an order in strict accordance with that of their definitions
17261 @emph{in a given translation unit}.  No guarantee is made for initializations
17262 across translation units.  However, GNU C++ allows users to control the
17263 order of initialization of objects defined at namespace scope with the
17264 @code{init_priority} attribute by specifying a relative @var{priority},
17265 a constant integral expression currently bounded between 101 and 65535
17266 inclusive.  Lower numbers indicate a higher priority.
17268 In the following example, @code{A} would normally be created before
17269 @code{B}, but the @code{init_priority} attribute reverses that order:
17271 @smallexample
17272 Some_Class  A  __attribute__ ((init_priority (2000)));
17273 Some_Class  B  __attribute__ ((init_priority (543)));
17274 @end smallexample
17276 @noindent
17277 Note that the particular values of @var{priority} do not matter; only their
17278 relative ordering.
17280 @item java_interface
17281 @cindex @code{java_interface} attribute
17283 This type attribute informs C++ that the class is a Java interface.  It may
17284 only be applied to classes declared within an @code{extern "Java"} block.
17285 Calls to methods declared in this interface are dispatched using GCJ's
17286 interface table mechanism, instead of regular virtual table dispatch.
17288 @item warn_unused
17289 @cindex @code{warn_unused} attribute
17291 For C++ types with non-trivial constructors and/or destructors it is
17292 impossible for the compiler to determine whether a variable of this
17293 type is truly unused if it is not referenced. This type attribute
17294 informs the compiler that variables of this type should be warned
17295 about if they appear to be unused, just like variables of fundamental
17296 types.
17298 This attribute is appropriate for types which just represent a value,
17299 such as @code{std::string}; it is not appropriate for types which
17300 control a resource, such as @code{std::mutex}.
17302 This attribute is also accepted in C, but it is unnecessary because C
17303 does not have constructors or destructors.
17305 @end table
17307 See also @ref{Namespace Association}.
17309 @node Function Multiversioning
17310 @section Function Multiversioning
17311 @cindex function versions
17313 With the GNU C++ front end, for target i386, you may specify multiple
17314 versions of a function, where each function is specialized for a
17315 specific target feature.  At runtime, the appropriate version of the
17316 function is automatically executed depending on the characteristics of
17317 the execution platform.  Here is an example.
17319 @smallexample
17320 __attribute__ ((target ("default")))
17321 int foo ()
17323   // The default version of foo.
17324   return 0;
17327 __attribute__ ((target ("sse4.2")))
17328 int foo ()
17330   // foo version for SSE4.2
17331   return 1;
17334 __attribute__ ((target ("arch=atom")))
17335 int foo ()
17337   // foo version for the Intel ATOM processor
17338   return 2;
17341 __attribute__ ((target ("arch=amdfam10")))
17342 int foo ()
17344   // foo version for the AMD Family 0x10 processors.
17345   return 3;
17348 int main ()
17350   int (*p)() = &foo;
17351   assert ((*p) () == foo ());
17352   return 0;
17354 @end smallexample
17356 In the above example, four versions of function foo are created. The
17357 first version of foo with the target attribute "default" is the default
17358 version.  This version gets executed when no other target specific
17359 version qualifies for execution on a particular platform. A new version
17360 of foo is created by using the same function signature but with a
17361 different target string.  Function foo is called or a pointer to it is
17362 taken just like a regular function.  GCC takes care of doing the
17363 dispatching to call the right version at runtime.  Refer to the
17364 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
17365 Function Multiversioning} for more details.
17367 @node Namespace Association
17368 @section Namespace Association
17370 @strong{Caution:} The semantics of this extension are equivalent
17371 to C++ 2011 inline namespaces.  Users should use inline namespaces
17372 instead as this extension will be removed in future versions of G++.
17374 A using-directive with @code{__attribute ((strong))} is stronger
17375 than a normal using-directive in two ways:
17377 @itemize @bullet
17378 @item
17379 Templates from the used namespace can be specialized and explicitly
17380 instantiated as though they were members of the using namespace.
17382 @item
17383 The using namespace is considered an associated namespace of all
17384 templates in the used namespace for purposes of argument-dependent
17385 name lookup.
17386 @end itemize
17388 The used namespace must be nested within the using namespace so that
17389 normal unqualified lookup works properly.
17391 This is useful for composing a namespace transparently from
17392 implementation namespaces.  For example:
17394 @smallexample
17395 namespace std @{
17396   namespace debug @{
17397     template <class T> struct A @{ @};
17398   @}
17399   using namespace debug __attribute ((__strong__));
17400   template <> struct A<int> @{ @};   // @r{OK to specialize}
17402   template <class T> void f (A<T>);
17405 int main()
17407   f (std::A<float>());             // @r{lookup finds} std::f
17408   f (std::A<int>());
17410 @end smallexample
17412 @node Type Traits
17413 @section Type Traits
17415 The C++ front end implements syntactic extensions that allow
17416 compile-time determination of 
17417 various characteristics of a type (or of a
17418 pair of types).
17420 @table @code
17421 @item __has_nothrow_assign (type)
17422 If @code{type} is const qualified or is a reference type then the trait is
17423 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
17424 is true, else if @code{type} is a cv class or union type with copy assignment
17425 operators that are known not to throw an exception then the trait is true,
17426 else it is false.  Requires: @code{type} shall be a complete type,
17427 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17429 @item __has_nothrow_copy (type)
17430 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
17431 @code{type} is a cv class or union type with copy constructors that
17432 are known not to throw an exception then the trait is true, else it is false.
17433 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
17434 @code{void}, or an array of unknown bound.
17436 @item __has_nothrow_constructor (type)
17437 If @code{__has_trivial_constructor (type)} is true then the trait is
17438 true, else if @code{type} is a cv class or union type (or array
17439 thereof) with a default constructor that is known not to throw an
17440 exception then the trait is true, else it is false.  Requires:
17441 @code{type} shall be a complete type, (possibly cv-qualified)
17442 @code{void}, or an array of unknown bound.
17444 @item __has_trivial_assign (type)
17445 If @code{type} is const qualified or is a reference type then the trait is
17446 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
17447 true, else if @code{type} is a cv class or union type with a trivial
17448 copy assignment ([class.copy]) then the trait is true, else it is
17449 false.  Requires: @code{type} shall be a complete type, (possibly
17450 cv-qualified) @code{void}, or an array of unknown bound.
17452 @item __has_trivial_copy (type)
17453 If @code{__is_pod (type)} is true or @code{type} is a reference type
17454 then the trait is true, else if @code{type} is a cv class or union type
17455 with a trivial copy constructor ([class.copy]) then the trait
17456 is true, else it is false.  Requires: @code{type} shall be a complete
17457 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17459 @item __has_trivial_constructor (type)
17460 If @code{__is_pod (type)} is true then the trait is true, else if
17461 @code{type} is a cv class or union type (or array thereof) with a
17462 trivial default constructor ([class.ctor]) then the trait is true,
17463 else it is false.  Requires: @code{type} shall be a complete
17464 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17466 @item __has_trivial_destructor (type)
17467 If @code{__is_pod (type)} is true or @code{type} is a reference type then
17468 the trait is true, else if @code{type} is a cv class or union type (or
17469 array thereof) with a trivial destructor ([class.dtor]) then the trait
17470 is true, else it is false.  Requires: @code{type} shall be a complete
17471 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17473 @item __has_virtual_destructor (type)
17474 If @code{type} is a class type with a virtual destructor
17475 ([class.dtor]) then the trait is true, else it is false.  Requires:
17476 @code{type} shall be a complete type, (possibly cv-qualified)
17477 @code{void}, or an array of unknown bound.
17479 @item __is_abstract (type)
17480 If @code{type} is an abstract class ([class.abstract]) then the trait
17481 is true, else it is false.  Requires: @code{type} shall be a complete
17482 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17484 @item __is_base_of (base_type, derived_type)
17485 If @code{base_type} is a base class of @code{derived_type}
17486 ([class.derived]) then the trait is true, otherwise it is false.
17487 Top-level cv qualifications of @code{base_type} and
17488 @code{derived_type} are ignored.  For the purposes of this trait, a
17489 class type is considered is own base.  Requires: if @code{__is_class
17490 (base_type)} and @code{__is_class (derived_type)} are true and
17491 @code{base_type} and @code{derived_type} are not the same type
17492 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
17493 type.  Diagnostic is produced if this requirement is not met.
17495 @item __is_class (type)
17496 If @code{type} is a cv class type, and not a union type
17497 ([basic.compound]) the trait is true, else it is false.
17499 @item __is_empty (type)
17500 If @code{__is_class (type)} is false then the trait is false.
17501 Otherwise @code{type} is considered empty if and only if: @code{type}
17502 has no non-static data members, or all non-static data members, if
17503 any, are bit-fields of length 0, and @code{type} has no virtual
17504 members, and @code{type} has no virtual base classes, and @code{type}
17505 has no base classes @code{base_type} for which
17506 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
17507 be a complete type, (possibly cv-qualified) @code{void}, or an array
17508 of unknown bound.
17510 @item __is_enum (type)
17511 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
17512 true, else it is false.
17514 @item __is_literal_type (type)
17515 If @code{type} is a literal type ([basic.types]) the trait is
17516 true, else it is false.  Requires: @code{type} shall be a complete type,
17517 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17519 @item __is_pod (type)
17520 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
17521 else it is false.  Requires: @code{type} shall be a complete type,
17522 (possibly cv-qualified) @code{void}, or an array of unknown bound.
17524 @item __is_polymorphic (type)
17525 If @code{type} is a polymorphic class ([class.virtual]) then the trait
17526 is true, else it is false.  Requires: @code{type} shall be a complete
17527 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17529 @item __is_standard_layout (type)
17530 If @code{type} is a standard-layout type ([basic.types]) the trait is
17531 true, else it is false.  Requires: @code{type} shall be a complete
17532 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17534 @item __is_trivial (type)
17535 If @code{type} is a trivial type ([basic.types]) the trait is
17536 true, else it is false.  Requires: @code{type} shall be a complete
17537 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
17539 @item __is_union (type)
17540 If @code{type} is a cv union type ([basic.compound]) the trait is
17541 true, else it is false.
17543 @item __underlying_type (type)
17544 The underlying type of @code{type}.  Requires: @code{type} shall be
17545 an enumeration type ([dcl.enum]).
17547 @end table
17549 @node Java Exceptions
17550 @section Java Exceptions
17552 The Java language uses a slightly different exception handling model
17553 from C++.  Normally, GNU C++ automatically detects when you are
17554 writing C++ code that uses Java exceptions, and handle them
17555 appropriately.  However, if C++ code only needs to execute destructors
17556 when Java exceptions are thrown through it, GCC guesses incorrectly.
17557 Sample problematic code is:
17559 @smallexample
17560   struct S @{ ~S(); @};
17561   extern void bar();    // @r{is written in Java, and may throw exceptions}
17562   void foo()
17563   @{
17564     S s;
17565     bar();
17566   @}
17567 @end smallexample
17569 @noindent
17570 The usual effect of an incorrect guess is a link failure, complaining of
17571 a missing routine called @samp{__gxx_personality_v0}.
17573 You can inform the compiler that Java exceptions are to be used in a
17574 translation unit, irrespective of what it might think, by writing
17575 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
17576 @samp{#pragma} must appear before any functions that throw or catch
17577 exceptions, or run destructors when exceptions are thrown through them.
17579 You cannot mix Java and C++ exceptions in the same translation unit.  It
17580 is believed to be safe to throw a C++ exception from one file through
17581 another file compiled for the Java exception model, or vice versa, but
17582 there may be bugs in this area.
17584 @node Deprecated Features
17585 @section Deprecated Features
17587 In the past, the GNU C++ compiler was extended to experiment with new
17588 features, at a time when the C++ language was still evolving.  Now that
17589 the C++ standard is complete, some of those features are superseded by
17590 superior alternatives.  Using the old features might cause a warning in
17591 some cases that the feature will be dropped in the future.  In other
17592 cases, the feature might be gone already.
17594 While the list below is not exhaustive, it documents some of the options
17595 that are now deprecated:
17597 @table @code
17598 @item -fexternal-templates
17599 @itemx -falt-external-templates
17600 These are two of the many ways for G++ to implement template
17601 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
17602 defines how template definitions have to be organized across
17603 implementation units.  G++ has an implicit instantiation mechanism that
17604 should work just fine for standard-conforming code.
17606 @item -fstrict-prototype
17607 @itemx -fno-strict-prototype
17608 Previously it was possible to use an empty prototype parameter list to
17609 indicate an unspecified number of parameters (like C), rather than no
17610 parameters, as C++ demands.  This feature has been removed, except where
17611 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
17612 @end table
17614 G++ allows a virtual function returning @samp{void *} to be overridden
17615 by one returning a different pointer type.  This extension to the
17616 covariant return type rules is now deprecated and will be removed from a
17617 future version.
17619 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
17620 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
17621 and are now removed from G++.  Code using these operators should be
17622 modified to use @code{std::min} and @code{std::max} instead.
17624 The named return value extension has been deprecated, and is now
17625 removed from G++.
17627 The use of initializer lists with new expressions has been deprecated,
17628 and is now removed from G++.
17630 Floating and complex non-type template parameters have been deprecated,
17631 and are now removed from G++.
17633 The implicit typename extension has been deprecated and is now
17634 removed from G++.
17636 The use of default arguments in function pointers, function typedefs
17637 and other places where they are not permitted by the standard is
17638 deprecated and will be removed from a future version of G++.
17640 G++ allows floating-point literals to appear in integral constant expressions,
17641 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
17642 This extension is deprecated and will be removed from a future version.
17644 G++ allows static data members of const floating-point type to be declared
17645 with an initializer in a class definition. The standard only allows
17646 initializers for static members of const integral types and const
17647 enumeration types so this extension has been deprecated and will be removed
17648 from a future version.
17650 @node Backwards Compatibility
17651 @section Backwards Compatibility
17652 @cindex Backwards Compatibility
17653 @cindex ARM [Annotated C++ Reference Manual]
17655 Now that there is a definitive ISO standard C++, G++ has a specification
17656 to adhere to.  The C++ language evolved over time, and features that
17657 used to be acceptable in previous drafts of the standard, such as the ARM
17658 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
17659 compilation of C++ written to such drafts, G++ contains some backwards
17660 compatibilities.  @emph{All such backwards compatibility features are
17661 liable to disappear in future versions of G++.} They should be considered
17662 deprecated.   @xref{Deprecated Features}.
17664 @table @code
17665 @item For scope
17666 If a variable is declared at for scope, it used to remain in scope until
17667 the end of the scope that contained the for statement (rather than just
17668 within the for scope).  G++ retains this, but issues a warning, if such a
17669 variable is accessed outside the for scope.
17671 @item Implicit C language
17672 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
17673 scope to set the language.  On such systems, all header files are
17674 implicitly scoped inside a C language scope.  Also, an empty prototype
17675 @code{()} is treated as an unspecified number of arguments, rather
17676 than no arguments, as C++ demands.
17677 @end table
17679 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
17680 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign