Import pre-release gcc-5.0 to new vendor branch
[dragonfly.git] / contrib / gcc-5.0 / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
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@.
17
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++.
21
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++.
24
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Label Attributes::    Specifying attributes on labels.
60 * Attribute Syntax::    Formal syntax for attributes.
61 * Function Prototypes:: Prototype declarations and old-style definitions.
62 * C++ Comments::        C++ comments are recognized.
63 * Dollar Signs::        Dollar sign is allowed in identifiers.
64 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
65 * Variable Attributes:: Specifying attributes of variables.
66 * Type Attributes::     Specifying attributes of types.
67 * Alignment::           Inquiring about the alignment of a type or variable.
68 * Inline::              Defining inline functions (as fast as macros).
69 * Volatiles::           What constitutes an access to a volatile object.
70 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
71 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
72 * Incomplete Enums::    @code{enum foo;}, with details to follow.
73 * Function Names::      Printable strings which are the name of the current
74                         function.
75 * Return Address::      Getting the return or frame address of a function.
76 * Vector Extensions::   Using vector instructions through built-in functions.
77 * Offsetof::            Special syntax for implementing @code{offsetof}.
78 * __sync Builtins::     Legacy built-in functions for atomic memory access.
79 * __atomic Builtins::   Atomic built-in functions with memory model.
80 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
81                         arithmetic overflow checking.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84                         checking.
85 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
86 * Cilk Plus Builtins::  Built-in functions for the Cilk Plus language extension.
87 * Other Builtins::      Other built-in functions.
88 * Target Builtins::     Built-in functions specific to particular targets.
89 * Target Format Checks:: Format checks specific to particular targets.
90 * Pragmas::             Pragmas accepted by GCC.
91 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
92 * Thread-Local::        Per-thread variables.
93 * Binary constants::    Binary constants using the @samp{0b} prefix.
94 @end menu
95
96 @node Statement Exprs
97 @section Statements and Declarations in Expressions
98 @cindex statements inside expressions
99 @cindex declarations inside expressions
100 @cindex expressions containing statements
101 @cindex macros, statements in expressions
102
103 @c the above section title wrapped and causes an underfull hbox.. i
104 @c changed it from "within" to "in". --mew 4feb93
105 A compound statement enclosed in parentheses may appear as an expression
106 in GNU C@.  This allows you to use loops, switches, and local variables
107 within an expression.
108
109 Recall that a compound statement is a sequence of statements surrounded
110 by braces; in this construct, parentheses go around the braces.  For
111 example:
112
113 @smallexample
114 (@{ int y = foo (); int z;
115    if (y > 0) z = y;
116    else z = - y;
117    z; @})
118 @end smallexample
119
120 @noindent
121 is a valid (though slightly more complex than necessary) expression
122 for the absolute value of @code{foo ()}.
123
124 The last thing in the compound statement should be an expression
125 followed by a semicolon; the value of this subexpression serves as the
126 value of the entire construct.  (If you use some other kind of statement
127 last within the braces, the construct has type @code{void}, and thus
128 effectively no value.)
129
130 This feature is especially useful in making macro definitions ``safe'' (so
131 that they evaluate each operand exactly once).  For example, the
132 ``maximum'' function is commonly defined as a macro in standard C as
133 follows:
134
135 @smallexample
136 #define max(a,b) ((a) > (b) ? (a) : (b))
137 @end smallexample
138
139 @noindent
140 @cindex side effects, macro argument
141 But this definition computes either @var{a} or @var{b} twice, with bad
142 results if the operand has side effects.  In GNU C, if you know the
143 type of the operands (here taken as @code{int}), you can define
144 the macro safely as follows:
145
146 @smallexample
147 #define maxint(a,b) \
148   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
149 @end smallexample
150
151 Embedded statements are not allowed in constant expressions, such as
152 the value of an enumeration constant, the width of a bit-field, or
153 the initial value of a static variable.
154
155 If you don't know the type of the operand, you can still do this, but you
156 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
157
158 In G++, the result value of a statement expression undergoes array and
159 function pointer decay, and is returned by value to the enclosing
160 expression.  For instance, if @code{A} is a class, then
161
162 @smallexample
163         A a;
164
165         (@{a;@}).Foo ()
166 @end smallexample
167
168 @noindent
169 constructs a temporary @code{A} object to hold the result of the
170 statement expression, and that is used to invoke @code{Foo}.
171 Therefore the @code{this} pointer observed by @code{Foo} is not the
172 address of @code{a}.
173
174 In a statement expression, any temporaries created within a statement
175 are destroyed at that statement's end.  This makes statement
176 expressions inside macros slightly different from function calls.  In
177 the latter case temporaries introduced during argument evaluation are
178 destroyed at the end of the statement that includes the function
179 call.  In the statement expression case they are destroyed during
180 the statement expression.  For instance,
181
182 @smallexample
183 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
184 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
185
186 void foo ()
187 @{
188   macro (X ());
189   function (X ());
190 @}
191 @end smallexample
192
193 @noindent
194 has different places where temporaries are destroyed.  For the
195 @code{macro} case, the temporary @code{X} is destroyed just after
196 the initialization of @code{b}.  In the @code{function} case that
197 temporary is destroyed when the function returns.
198
199 These considerations mean that it is probably a bad idea to use
200 statement expressions of this form in header files that are designed to
201 work with C++.  (Note that some versions of the GNU C Library contained
202 header files using statement expressions that lead to precisely this
203 bug.)
204
205 Jumping into a statement expression with @code{goto} or using a
206 @code{switch} statement outside the statement expression with a
207 @code{case} or @code{default} label inside the statement expression is
208 not permitted.  Jumping into a statement expression with a computed
209 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
210 Jumping out of a statement expression is permitted, but if the
211 statement expression is part of a larger expression then it is
212 unspecified which other subexpressions of that expression have been
213 evaluated except where the language definition requires certain
214 subexpressions to be evaluated before or after the statement
215 expression.  In any case, as with a function call, the evaluation of a
216 statement expression is not interleaved with the evaluation of other
217 parts of the containing expression.  For example,
218
219 @smallexample
220   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
221 @end smallexample
222
223 @noindent
224 calls @code{foo} and @code{bar1} and does not call @code{baz} but
225 may or may not call @code{bar2}.  If @code{bar2} is called, it is
226 called after @code{foo} and before @code{bar1}.
227
228 @node Local Labels
229 @section Locally Declared Labels
230 @cindex local labels
231 @cindex macros, local labels
232
233 GCC allows you to declare @dfn{local labels} in any nested block
234 scope.  A local label is just like an ordinary label, but you can
235 only reference it (with a @code{goto} statement, or by taking its
236 address) within the block in which it is declared.
237
238 A local label declaration looks like this:
239
240 @smallexample
241 __label__ @var{label};
242 @end smallexample
243
244 @noindent
245 or
246
247 @smallexample
248 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
249 @end smallexample
250
251 Local label declarations must come at the beginning of the block,
252 before any ordinary declarations or statements.
253
254 The label declaration defines the label @emph{name}, but does not define
255 the label itself.  You must do this in the usual way, with
256 @code{@var{label}:}, within the statements of the statement expression.
257
258 The local label feature is useful for complex macros.  If a macro
259 contains nested loops, a @code{goto} can be useful for breaking out of
260 them.  However, an ordinary label whose scope is the whole function
261 cannot be used: if the macro can be expanded several times in one
262 function, the label is multiply defined in that function.  A
263 local label avoids this problem.  For example:
264
265 @smallexample
266 #define SEARCH(value, array, target)              \
267 do @{                                              \
268   __label__ found;                                \
269   typeof (target) _SEARCH_target = (target);      \
270   typeof (*(array)) *_SEARCH_array = (array);     \
271   int i, j;                                       \
272   int value;                                      \
273   for (i = 0; i < max; i++)                       \
274     for (j = 0; j < max; j++)                     \
275       if (_SEARCH_array[i][j] == _SEARCH_target)  \
276         @{ (value) = i; goto found; @}              \
277   (value) = -1;                                   \
278  found:;                                          \
279 @} while (0)
280 @end smallexample
281
282 This could also be written using a statement expression:
283
284 @smallexample
285 #define SEARCH(array, target)                     \
286 (@{                                                \
287   __label__ found;                                \
288   typeof (target) _SEARCH_target = (target);      \
289   typeof (*(array)) *_SEARCH_array = (array);     \
290   int i, j;                                       \
291   int value;                                      \
292   for (i = 0; i < max; i++)                       \
293     for (j = 0; j < max; j++)                     \
294       if (_SEARCH_array[i][j] == _SEARCH_target)  \
295         @{ value = i; goto found; @}                \
296   value = -1;                                     \
297  found:                                           \
298   value;                                          \
299 @})
300 @end smallexample
301
302 Local label declarations also make the labels they declare visible to
303 nested functions, if there are any.  @xref{Nested Functions}, for details.
304
305 @node Labels as Values
306 @section Labels as Values
307 @cindex labels as values
308 @cindex computed gotos
309 @cindex goto with computed label
310 @cindex address of a label
311
312 You can get the address of a label defined in the current function
313 (or a containing function) with the unary operator @samp{&&}.  The
314 value has type @code{void *}.  This value is a constant and can be used
315 wherever a constant of that type is valid.  For example:
316
317 @smallexample
318 void *ptr;
319 /* @r{@dots{}} */
320 ptr = &&foo;
321 @end smallexample
322
323 To use these values, you need to be able to jump to one.  This is done
324 with the computed goto statement@footnote{The analogous feature in
325 Fortran is called an assigned goto, but that name seems inappropriate in
326 C, where one can do more than simply store label addresses in label
327 variables.}, @code{goto *@var{exp};}.  For example,
328
329 @smallexample
330 goto *ptr;
331 @end smallexample
332
333 @noindent
334 Any expression of type @code{void *} is allowed.
335
336 One way of using these constants is in initializing a static array that
337 serves as a jump table:
338
339 @smallexample
340 static void *array[] = @{ &&foo, &&bar, &&hack @};
341 @end smallexample
342
343 @noindent
344 Then you can select a label with indexing, like this:
345
346 @smallexample
347 goto *array[i];
348 @end smallexample
349
350 @noindent
351 Note that this does not check whether the subscript is in bounds---array
352 indexing in C never does that.
353
354 Such an array of label values serves a purpose much like that of the
355 @code{switch} statement.  The @code{switch} statement is cleaner, so
356 use that rather than an array unless the problem does not fit a
357 @code{switch} statement very well.
358
359 Another use of label values is in an interpreter for threaded code.
360 The labels within the interpreter function can be stored in the
361 threaded code for super-fast dispatching.
362
363 You may not use this mechanism to jump to code in a different function.
364 If you do that, totally unpredictable things happen.  The best way to
365 avoid this is to store the label address only in automatic variables and
366 never pass it as an argument.
367
368 An alternate way to write the above example is
369
370 @smallexample
371 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
372                              &&hack - &&foo @};
373 goto *(&&foo + array[i]);
374 @end smallexample
375
376 @noindent
377 This is more friendly to code living in shared libraries, as it reduces
378 the number of dynamic relocations that are needed, and by consequence,
379 allows the data to be read-only.
380 This alternative with label differences is not supported for the AVR target,
381 please use the first approach for AVR programs.
382
383 The @code{&&foo} expressions for the same label might have different
384 values if the containing function is inlined or cloned.  If a program
385 relies on them being always the same,
386 @code{__attribute__((__noinline__,__noclone__))} should be used to
387 prevent inlining and cloning.  If @code{&&foo} is used in a static
388 variable initializer, inlining and cloning is forbidden.
389
390 @node Nested Functions
391 @section Nested Functions
392 @cindex nested functions
393 @cindex downward funargs
394 @cindex thunks
395
396 A @dfn{nested function} is a function defined inside another function.
397 Nested functions are supported as an extension in GNU C, but are not
398 supported by GNU C++.
399
400 The nested function's name is local to the block where it is defined.
401 For example, here we define a nested function named @code{square}, and
402 call it twice:
403
404 @smallexample
405 @group
406 foo (double a, double b)
407 @{
408   double square (double z) @{ return z * z; @}
409
410   return square (a) + square (b);
411 @}
412 @end group
413 @end smallexample
414
415 The nested function can access all the variables of the containing
416 function that are visible at the point of its definition.  This is
417 called @dfn{lexical scoping}.  For example, here we show a nested
418 function which uses an inherited variable named @code{offset}:
419
420 @smallexample
421 @group
422 bar (int *array, int offset, int size)
423 @{
424   int access (int *array, int index)
425     @{ return array[index + offset]; @}
426   int i;
427   /* @r{@dots{}} */
428   for (i = 0; i < size; i++)
429     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
430 @}
431 @end group
432 @end smallexample
433
434 Nested function definitions are permitted within functions in the places
435 where variable definitions are allowed; that is, in any block, mixed
436 with the other declarations and statements in the block.
437
438 It is possible to call the nested function from outside the scope of its
439 name by storing its address or passing the address to another function:
440
441 @smallexample
442 hack (int *array, int size)
443 @{
444   void store (int index, int value)
445     @{ array[index] = value; @}
446
447   intermediate (store, size);
448 @}
449 @end smallexample
450
451 Here, the function @code{intermediate} receives the address of
452 @code{store} as an argument.  If @code{intermediate} calls @code{store},
453 the arguments given to @code{store} are used to store into @code{array}.
454 But this technique works only so long as the containing function
455 (@code{hack}, in this example) does not exit.
456
457 If you try to call the nested function through its address after the
458 containing function exits, all hell breaks loose.  If you try
459 to call it after a containing scope level exits, and if it refers
460 to some of the variables that are no longer in scope, you may be lucky,
461 but it's not wise to take the risk.  If, however, the nested function
462 does not refer to anything that has gone out of scope, you should be
463 safe.
464
465 GCC implements taking the address of a nested function using a technique
466 called @dfn{trampolines}.  This technique was described in
467 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
468 C++ Conference Proceedings, October 17-21, 1988).
469
470 A nested function can jump to a label inherited from a containing
471 function, provided the label is explicitly declared in the containing
472 function (@pxref{Local Labels}).  Such a jump returns instantly to the
473 containing function, exiting the nested function that did the
474 @code{goto} and any intermediate functions as well.  Here is an example:
475
476 @smallexample
477 @group
478 bar (int *array, int offset, int size)
479 @{
480   __label__ failure;
481   int access (int *array, int index)
482     @{
483       if (index > size)
484         goto failure;
485       return array[index + offset];
486     @}
487   int i;
488   /* @r{@dots{}} */
489   for (i = 0; i < size; i++)
490     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
491   /* @r{@dots{}} */
492   return 0;
493
494  /* @r{Control comes here from @code{access}
495     if it detects an error.}  */
496  failure:
497   return -1;
498 @}
499 @end group
500 @end smallexample
501
502 A nested function always has no linkage.  Declaring one with
503 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
504 before its definition, use @code{auto} (which is otherwise meaningless
505 for function declarations).
506
507 @smallexample
508 bar (int *array, int offset, int size)
509 @{
510   __label__ failure;
511   auto int access (int *, int);
512   /* @r{@dots{}} */
513   int access (int *array, int index)
514     @{
515       if (index > size)
516         goto failure;
517       return array[index + offset];
518     @}
519   /* @r{@dots{}} */
520 @}
521 @end smallexample
522
523 @node Constructing Calls
524 @section Constructing Function Calls
525 @cindex constructing calls
526 @cindex forwarding calls
527
528 Using the built-in functions described below, you can record
529 the arguments a function received, and call another function
530 with the same arguments, without knowing the number or types
531 of the arguments.
532
533 You can also record the return value of that function call,
534 and later return that value, without knowing what data type
535 the function tried to return (as long as your caller expects
536 that data type).
537
538 However, these built-in functions may interact badly with some
539 sophisticated features or other extensions of the language.  It
540 is, therefore, not recommended to use them outside very simple
541 functions acting as mere forwarders for their arguments.
542
543 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
544 This built-in function returns a pointer to data
545 describing how to perform a call with the same arguments as are passed
546 to the current function.
547
548 The function saves the arg pointer register, structure value address,
549 and all registers that might be used to pass arguments to a function
550 into a block of memory allocated on the stack.  Then it returns the
551 address of that block.
552 @end deftypefn
553
554 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
555 This built-in function invokes @var{function}
556 with a copy of the parameters described by @var{arguments}
557 and @var{size}.
558
559 The value of @var{arguments} should be the value returned by
560 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
561 of the stack argument data, in bytes.
562
563 This function returns a pointer to data describing
564 how to return whatever value is returned by @var{function}.  The data
565 is saved in a block of memory allocated on the stack.
566
567 It is not always simple to compute the proper value for @var{size}.  The
568 value is used by @code{__builtin_apply} to compute the amount of data
569 that should be pushed on the stack and copied from the incoming argument
570 area.
571 @end deftypefn
572
573 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
574 This built-in function returns the value described by @var{result} from
575 the containing function.  You should specify, for @var{result}, a value
576 returned by @code{__builtin_apply}.
577 @end deftypefn
578
579 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
580 This built-in function represents all anonymous arguments of an inline
581 function.  It can be used only in inline functions that are always
582 inlined, never compiled as a separate function, such as those using
583 @code{__attribute__ ((__always_inline__))} or
584 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
585 It must be only passed as last argument to some other function
586 with variable arguments.  This is useful for writing small wrapper
587 inlines for variable argument functions, when using preprocessor
588 macros is undesirable.  For example:
589 @smallexample
590 extern int myprintf (FILE *f, const char *format, ...);
591 extern inline __attribute__ ((__gnu_inline__)) int
592 myprintf (FILE *f, const char *format, ...)
593 @{
594   int r = fprintf (f, "myprintf: ");
595   if (r < 0)
596     return r;
597   int s = fprintf (f, format, __builtin_va_arg_pack ());
598   if (s < 0)
599     return s;
600   return r + s;
601 @}
602 @end smallexample
603 @end deftypefn
604
605 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
606 This built-in function returns the number of anonymous arguments of
607 an inline function.  It can be used only in inline functions that
608 are always inlined, never compiled as a separate function, such
609 as those using @code{__attribute__ ((__always_inline__))} or
610 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
611 For example following does link- or run-time checking of open
612 arguments for optimized code:
613 @smallexample
614 #ifdef __OPTIMIZE__
615 extern inline __attribute__((__gnu_inline__)) int
616 myopen (const char *path, int oflag, ...)
617 @{
618   if (__builtin_va_arg_pack_len () > 1)
619     warn_open_too_many_arguments ();
620
621   if (__builtin_constant_p (oflag))
622     @{
623       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
624         @{
625           warn_open_missing_mode ();
626           return __open_2 (path, oflag);
627         @}
628       return open (path, oflag, __builtin_va_arg_pack ());
629     @}
630
631   if (__builtin_va_arg_pack_len () < 1)
632     return __open_2 (path, oflag);
633
634   return open (path, oflag, __builtin_va_arg_pack ());
635 @}
636 #endif
637 @end smallexample
638 @end deftypefn
639
640 @node Typeof
641 @section Referring to a Type with @code{typeof}
642 @findex typeof
643 @findex sizeof
644 @cindex macros, types of arguments
645
646 Another way to refer to the type of an expression is with @code{typeof}.
647 The syntax of using of this keyword looks like @code{sizeof}, but the
648 construct acts semantically like a type name defined with @code{typedef}.
649
650 There are two ways of writing the argument to @code{typeof}: with an
651 expression or with a type.  Here is an example with an expression:
652
653 @smallexample
654 typeof (x[0](1))
655 @end smallexample
656
657 @noindent
658 This assumes that @code{x} is an array of pointers to functions;
659 the type described is that of the values of the functions.
660
661 Here is an example with a typename as the argument:
662
663 @smallexample
664 typeof (int *)
665 @end smallexample
666
667 @noindent
668 Here the type described is that of pointers to @code{int}.
669
670 If you are writing a header file that must work when included in ISO C
671 programs, write @code{__typeof__} instead of @code{typeof}.
672 @xref{Alternate Keywords}.
673
674 A @code{typeof} construct can be used anywhere a typedef name can be
675 used.  For example, you can use it in a declaration, in a cast, or inside
676 of @code{sizeof} or @code{typeof}.
677
678 The operand of @code{typeof} is evaluated for its side effects if and
679 only if it is an expression of variably modified type or the name of
680 such a type.
681
682 @code{typeof} is often useful in conjunction with
683 statement expressions (@pxref{Statement Exprs}).
684 Here is how the two together can
685 be used to define a safe ``maximum'' macro which operates on any
686 arithmetic type and evaluates each of its arguments exactly once:
687
688 @smallexample
689 #define max(a,b) \
690   (@{ typeof (a) _a = (a); \
691       typeof (b) _b = (b); \
692     _a > _b ? _a : _b; @})
693 @end smallexample
694
695 @cindex underscores in variables in macros
696 @cindex @samp{_} in variables in macros
697 @cindex local variables in macros
698 @cindex variables, local, in macros
699 @cindex macros, local variables in
700
701 The reason for using names that start with underscores for the local
702 variables is to avoid conflicts with variable names that occur within the
703 expressions that are substituted for @code{a} and @code{b}.  Eventually we
704 hope to design a new form of declaration syntax that allows you to declare
705 variables whose scopes start only after their initializers; this will be a
706 more reliable way to prevent such conflicts.
707
708 @noindent
709 Some more examples of the use of @code{typeof}:
710
711 @itemize @bullet
712 @item
713 This declares @code{y} with the type of what @code{x} points to.
714
715 @smallexample
716 typeof (*x) y;
717 @end smallexample
718
719 @item
720 This declares @code{y} as an array of such values.
721
722 @smallexample
723 typeof (*x) y[4];
724 @end smallexample
725
726 @item
727 This declares @code{y} as an array of pointers to characters:
728
729 @smallexample
730 typeof (typeof (char *)[4]) y;
731 @end smallexample
732
733 @noindent
734 It is equivalent to the following traditional C declaration:
735
736 @smallexample
737 char *y[4];
738 @end smallexample
739
740 To see the meaning of the declaration using @code{typeof}, and why it
741 might be a useful way to write, rewrite it with these macros:
742
743 @smallexample
744 #define pointer(T)  typeof(T *)
745 #define array(T, N) typeof(T [N])
746 @end smallexample
747
748 @noindent
749 Now the declaration can be rewritten this way:
750
751 @smallexample
752 array (pointer (char), 4) y;
753 @end smallexample
754
755 @noindent
756 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
757 pointers to @code{char}.
758 @end itemize
759
760 In GNU C, but not GNU C++, you may also declare the type of a variable
761 as @code{__auto_type}.  In that case, the declaration must declare
762 only one variable, whose declarator must just be an identifier, the
763 declaration must be initialized, and the type of the variable is
764 determined by the initializer; the name of the variable is not in
765 scope until after the initializer.  (In C++, you should use C++11
766 @code{auto} for this purpose.)  Using @code{__auto_type}, the
767 ``maximum'' macro above could be written as:
768
769 @smallexample
770 #define max(a,b) \
771   (@{ __auto_type _a = (a); \
772       __auto_type _b = (b); \
773     _a > _b ? _a : _b; @})
774 @end smallexample
775
776 Using @code{__auto_type} instead of @code{typeof} has two advantages:
777
778 @itemize @bullet
779 @item Each argument to the macro appears only once in the expansion of
780 the macro.  This prevents the size of the macro expansion growing
781 exponentially when calls to such macros are nested inside arguments of
782 such macros.
783
784 @item If the argument to the macro has variably modified type, it is
785 evaluated only once when using @code{__auto_type}, but twice if
786 @code{typeof} is used.
787 @end itemize
788
789 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
790 a more limited extension that permitted one to write
791
792 @smallexample
793 typedef @var{T} = @var{expr};
794 @end smallexample
795
796 @noindent
797 with the effect of declaring @var{T} to have the type of the expression
798 @var{expr}.  This extension does not work with GCC 3 (versions between
799 3.0 and 3.2 crash; 3.2.1 and later give an error).  Code that
800 relies on it should be rewritten to use @code{typeof}:
801
802 @smallexample
803 typedef typeof(@var{expr}) @var{T};
804 @end smallexample
805
806 @noindent
807 This works with all versions of GCC@.
808
809 @node Conditionals
810 @section Conditionals with Omitted Operands
811 @cindex conditional expressions, extensions
812 @cindex omitted middle-operands
813 @cindex middle-operands, omitted
814 @cindex extensions, @code{?:}
815 @cindex @code{?:} extensions
816
817 The middle operand in a conditional expression may be omitted.  Then
818 if the first operand is nonzero, its value is the value of the conditional
819 expression.
820
821 Therefore, the expression
822
823 @smallexample
824 x ? : y
825 @end smallexample
826
827 @noindent
828 has the value of @code{x} if that is nonzero; otherwise, the value of
829 @code{y}.
830
831 This example is perfectly equivalent to
832
833 @smallexample
834 x ? x : y
835 @end smallexample
836
837 @cindex side effect in @code{?:}
838 @cindex @code{?:} side effect
839 @noindent
840 In this simple case, the ability to omit the middle operand is not
841 especially useful.  When it becomes useful is when the first operand does,
842 or may (if it is a macro argument), contain a side effect.  Then repeating
843 the operand in the middle would perform the side effect twice.  Omitting
844 the middle operand uses the value already computed without the undesirable
845 effects of recomputing it.
846
847 @node __int128
848 @section 128-bit integers
849 @cindex @code{__int128} data types
850
851 As an extension the integer scalar type @code{__int128} is supported for
852 targets which have an integer mode wide enough to hold 128 bits.
853 Simply write @code{__int128} for a signed 128-bit integer, or
854 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
855 support in GCC for expressing an integer constant of type @code{__int128}
856 for targets with @code{long long} integer less than 128 bits wide.
857
858 @node Long Long
859 @section Double-Word Integers
860 @cindex @code{long long} data types
861 @cindex double-word arithmetic
862 @cindex multiprecision arithmetic
863 @cindex @code{LL} integer suffix
864 @cindex @code{ULL} integer suffix
865
866 ISO C99 supports data types for integers that are at least 64 bits wide,
867 and as an extension GCC supports them in C90 mode and in C++.
868 Simply write @code{long long int} for a signed integer, or
869 @code{unsigned long long int} for an unsigned integer.  To make an
870 integer constant of type @code{long long int}, add the suffix @samp{LL}
871 to the integer.  To make an integer constant of type @code{unsigned long
872 long int}, add the suffix @samp{ULL} to the integer.
873
874 You can use these types in arithmetic like any other integer types.
875 Addition, subtraction, and bitwise boolean operations on these types
876 are open-coded on all types of machines.  Multiplication is open-coded
877 if the machine supports a fullword-to-doubleword widening multiply
878 instruction.  Division and shifts are open-coded only on machines that
879 provide special support.  The operations that are not open-coded use
880 special library routines that come with GCC@.
881
882 There may be pitfalls when you use @code{long long} types for function
883 arguments without function prototypes.  If a function
884 expects type @code{int} for its argument, and you pass a value of type
885 @code{long long int}, confusion results because the caller and the
886 subroutine disagree about the number of bytes for the argument.
887 Likewise, if the function expects @code{long long int} and you pass
888 @code{int}.  The best way to avoid such problems is to use prototypes.
889
890 @node Complex
891 @section Complex Numbers
892 @cindex complex numbers
893 @cindex @code{_Complex} keyword
894 @cindex @code{__complex__} keyword
895
896 ISO C99 supports complex floating data types, and as an extension GCC
897 supports them in C90 mode and in C++.  GCC also supports complex integer data
898 types which are not part of ISO C99.  You can declare complex types
899 using the keyword @code{_Complex}.  As an extension, the older GNU
900 keyword @code{__complex__} is also supported.
901
902 For example, @samp{_Complex double x;} declares @code{x} as a
903 variable whose real part and imaginary part are both of type
904 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
905 have real and imaginary parts of type @code{short int}; this is not
906 likely to be useful, but it shows that the set of complex types is
907 complete.
908
909 To write a constant with a complex data type, use the suffix @samp{i} or
910 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
911 has type @code{_Complex float} and @code{3i} has type
912 @code{_Complex int}.  Such a constant always has a pure imaginary
913 value, but you can form any complex value you like by adding one to a
914 real constant.  This is a GNU extension; if you have an ISO C99
915 conforming C library (such as the GNU C Library), and want to construct complex
916 constants of floating type, you should include @code{<complex.h>} and
917 use the macros @code{I} or @code{_Complex_I} instead.
918
919 @cindex @code{__real__} keyword
920 @cindex @code{__imag__} keyword
921 To extract the real part of a complex-valued expression @var{exp}, write
922 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
923 extract the imaginary part.  This is a GNU extension; for values of
924 floating type, you should use the ISO C99 functions @code{crealf},
925 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
926 @code{cimagl}, declared in @code{<complex.h>} and also provided as
927 built-in functions by GCC@.
928
929 @cindex complex conjugation
930 The operator @samp{~} performs complex conjugation when used on a value
931 with a complex type.  This is a GNU extension; for values of
932 floating type, you should use the ISO C99 functions @code{conjf},
933 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
934 provided as built-in functions by GCC@.
935
936 GCC can allocate complex automatic variables in a noncontiguous
937 fashion; it's even possible for the real part to be in a register while
938 the imaginary part is on the stack (or vice versa).  Only the DWARF 2
939 debug info format can represent this, so use of DWARF 2 is recommended.
940 If you are using the stabs debug info format, GCC describes a noncontiguous
941 complex variable as if it were two separate variables of noncomplex type.
942 If the variable's actual name is @code{foo}, the two fictitious
943 variables are named @code{foo$real} and @code{foo$imag}.  You can
944 examine and set these two fictitious variables with your debugger.
945
946 @node Floating Types
947 @section Additional Floating Types
948 @cindex additional floating types
949 @cindex @code{__float80} data type
950 @cindex @code{__float128} data type
951 @cindex @code{w} floating point suffix
952 @cindex @code{q} floating point suffix
953 @cindex @code{W} floating point suffix
954 @cindex @code{Q} floating point suffix
955
956 As an extension, GNU C supports additional floating
957 types, @code{__float80} and @code{__float128} to support 80-bit
958 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
959 Support for additional types includes the arithmetic operators:
960 add, subtract, multiply, divide; unary arithmetic operators;
961 relational operators; equality operators; and conversions to and from
962 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
963 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
964 for @code{_float128}.  You can declare complex types using the
965 corresponding internal complex type, @code{XCmode} for @code{__float80}
966 type and @code{TCmode} for @code{__float128} type:
967
968 @smallexample
969 typedef _Complex float __attribute__((mode(TC))) _Complex128;
970 typedef _Complex float __attribute__((mode(XC))) _Complex80;
971 @end smallexample
972
973 Not all targets support additional floating-point types.  @code{__float80}
974 and @code{__float128} types are supported on x86 and IA-64 targets.
975 The @code{__float128} type is supported on hppa HP-UX targets.
976
977 @node Half-Precision
978 @section Half-Precision Floating Point
979 @cindex half-precision floating point
980 @cindex @code{__fp16} data type
981
982 On ARM targets, GCC supports half-precision (16-bit) floating point via
983 the @code{__fp16} type.  You must enable this type explicitly
984 with the @option{-mfp16-format} command-line option in order to use it.
985
986 ARM supports two incompatible representations for half-precision
987 floating-point values.  You must choose one of the representations and
988 use it consistently in your program.
989
990 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
991 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
992 There are 11 bits of significand precision, approximately 3
993 decimal digits.
994
995 Specifying @option{-mfp16-format=alternative} selects the ARM
996 alternative format.  This representation is similar to the IEEE
997 format, but does not support infinities or NaNs.  Instead, the range
998 of exponents is extended, so that this format can represent normalized
999 values in the range of @math{2^{-14}} to 131008.
1000
1001 The @code{__fp16} type is a storage format only.  For purposes
1002 of arithmetic and other operations, @code{__fp16} values in C or C++
1003 expressions are automatically promoted to @code{float}.  In addition,
1004 you cannot declare a function with a return value or parameters
1005 of type @code{__fp16}.
1006
1007 Note that conversions from @code{double} to @code{__fp16}
1008 involve an intermediate conversion to @code{float}.  Because
1009 of rounding, this can sometimes produce a different result than a
1010 direct conversion.
1011
1012 ARM provides hardware support for conversions between
1013 @code{__fp16} and @code{float} values
1014 as an extension to VFP and NEON (Advanced SIMD).  GCC generates
1015 code using these hardware instructions if you compile with
1016 options to select an FPU that provides them;
1017 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1018 in addition to the @option{-mfp16-format} option to select
1019 a half-precision format.
1020
1021 Language-level support for the @code{__fp16} data type is
1022 independent of whether GCC generates code using hardware floating-point
1023 instructions.  In cases where hardware support is not specified, GCC
1024 implements conversions between @code{__fp16} and @code{float} values
1025 as library calls.
1026
1027 @node Decimal Float
1028 @section Decimal Floating Types
1029 @cindex decimal floating types
1030 @cindex @code{_Decimal32} data type
1031 @cindex @code{_Decimal64} data type
1032 @cindex @code{_Decimal128} data type
1033 @cindex @code{df} integer suffix
1034 @cindex @code{dd} integer suffix
1035 @cindex @code{dl} integer suffix
1036 @cindex @code{DF} integer suffix
1037 @cindex @code{DD} integer suffix
1038 @cindex @code{DL} integer suffix
1039
1040 As an extension, GNU C supports decimal floating types as
1041 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1042 floating types in GCC will evolve as the draft technical report changes.
1043 Calling conventions for any target might also change.  Not all targets
1044 support decimal floating types.
1045
1046 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1047 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1048 @code{float}, @code{double}, and @code{long double} whose radix is not
1049 specified by the C standard but is usually two.
1050
1051 Support for decimal floating types includes the arithmetic operators
1052 add, subtract, multiply, divide; unary arithmetic operators;
1053 relational operators; equality operators; and conversions to and from
1054 integer and other floating types.  Use a suffix @samp{df} or
1055 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1056 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1057 @code{_Decimal128}.
1058
1059 GCC support of decimal float as specified by the draft technical report
1060 is incomplete:
1061
1062 @itemize @bullet
1063 @item
1064 When the value of a decimal floating type cannot be represented in the
1065 integer type to which it is being converted, the result is undefined
1066 rather than the result value specified by the draft technical report.
1067
1068 @item
1069 GCC does not provide the C library functionality associated with
1070 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1071 @file{wchar.h}, which must come from a separate C library implementation.
1072 Because of this the GNU C compiler does not define macro
1073 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1074 the technical report.
1075 @end itemize
1076
1077 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1078 are supported by the DWARF 2 debug information format.
1079
1080 @node Hex Floats
1081 @section Hex Floats
1082 @cindex hex floats
1083
1084 ISO C99 supports floating-point numbers written not only in the usual
1085 decimal notation, such as @code{1.55e1}, but also numbers such as
1086 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1087 supports this in C90 mode (except in some cases when strictly
1088 conforming) and in C++.  In that format the
1089 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1090 mandatory.  The exponent is a decimal number that indicates the power of
1091 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1092 @tex
1093 $1 {15\over16}$,
1094 @end tex
1095 @ifnottex
1096 1 15/16,
1097 @end ifnottex
1098 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1099 is the same as @code{1.55e1}.
1100
1101 Unlike for floating-point numbers in the decimal notation the exponent
1102 is always required in the hexadecimal notation.  Otherwise the compiler
1103 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1104 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1105 extension for floating-point constants of type @code{float}.
1106
1107 @node Fixed-Point
1108 @section Fixed-Point Types
1109 @cindex fixed-point types
1110 @cindex @code{_Fract} data type
1111 @cindex @code{_Accum} data type
1112 @cindex @code{_Sat} data type
1113 @cindex @code{hr} fixed-suffix
1114 @cindex @code{r} fixed-suffix
1115 @cindex @code{lr} fixed-suffix
1116 @cindex @code{llr} fixed-suffix
1117 @cindex @code{uhr} fixed-suffix
1118 @cindex @code{ur} fixed-suffix
1119 @cindex @code{ulr} fixed-suffix
1120 @cindex @code{ullr} fixed-suffix
1121 @cindex @code{hk} fixed-suffix
1122 @cindex @code{k} fixed-suffix
1123 @cindex @code{lk} fixed-suffix
1124 @cindex @code{llk} fixed-suffix
1125 @cindex @code{uhk} fixed-suffix
1126 @cindex @code{uk} fixed-suffix
1127 @cindex @code{ulk} fixed-suffix
1128 @cindex @code{ullk} fixed-suffix
1129 @cindex @code{HR} fixed-suffix
1130 @cindex @code{R} fixed-suffix
1131 @cindex @code{LR} fixed-suffix
1132 @cindex @code{LLR} fixed-suffix
1133 @cindex @code{UHR} fixed-suffix
1134 @cindex @code{UR} fixed-suffix
1135 @cindex @code{ULR} fixed-suffix
1136 @cindex @code{ULLR} fixed-suffix
1137 @cindex @code{HK} fixed-suffix
1138 @cindex @code{K} fixed-suffix
1139 @cindex @code{LK} fixed-suffix
1140 @cindex @code{LLK} fixed-suffix
1141 @cindex @code{UHK} fixed-suffix
1142 @cindex @code{UK} fixed-suffix
1143 @cindex @code{ULK} fixed-suffix
1144 @cindex @code{ULLK} fixed-suffix
1145
1146 As an extension, GNU C supports fixed-point types as
1147 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1148 types in GCC will evolve as the draft technical report changes.
1149 Calling conventions for any target might also change.  Not all targets
1150 support fixed-point types.
1151
1152 The fixed-point types are
1153 @code{short _Fract},
1154 @code{_Fract},
1155 @code{long _Fract},
1156 @code{long long _Fract},
1157 @code{unsigned short _Fract},
1158 @code{unsigned _Fract},
1159 @code{unsigned long _Fract},
1160 @code{unsigned long long _Fract},
1161 @code{_Sat short _Fract},
1162 @code{_Sat _Fract},
1163 @code{_Sat long _Fract},
1164 @code{_Sat long long _Fract},
1165 @code{_Sat unsigned short _Fract},
1166 @code{_Sat unsigned _Fract},
1167 @code{_Sat unsigned long _Fract},
1168 @code{_Sat unsigned long long _Fract},
1169 @code{short _Accum},
1170 @code{_Accum},
1171 @code{long _Accum},
1172 @code{long long _Accum},
1173 @code{unsigned short _Accum},
1174 @code{unsigned _Accum},
1175 @code{unsigned long _Accum},
1176 @code{unsigned long long _Accum},
1177 @code{_Sat short _Accum},
1178 @code{_Sat _Accum},
1179 @code{_Sat long _Accum},
1180 @code{_Sat long long _Accum},
1181 @code{_Sat unsigned short _Accum},
1182 @code{_Sat unsigned _Accum},
1183 @code{_Sat unsigned long _Accum},
1184 @code{_Sat unsigned long long _Accum}.
1185
1186 Fixed-point data values contain fractional and optional integral parts.
1187 The format of fixed-point data varies and depends on the target machine.
1188
1189 Support for fixed-point types includes:
1190 @itemize @bullet
1191 @item
1192 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1193 @item
1194 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1195 @item
1196 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1197 @item
1198 binary shift operators (@code{<<}, @code{>>})
1199 @item
1200 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1201 @item
1202 equality operators (@code{==}, @code{!=})
1203 @item
1204 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1205 @code{<<=}, @code{>>=})
1206 @item
1207 conversions to and from integer, floating-point, or fixed-point types
1208 @end itemize
1209
1210 Use a suffix in a fixed-point literal constant:
1211 @itemize
1212 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1213 @code{_Sat short _Fract}
1214 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1215 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1216 @code{_Sat long _Fract}
1217 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1218 @code{_Sat long long _Fract}
1219 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1220 @code{_Sat unsigned short _Fract}
1221 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1222 @code{_Sat unsigned _Fract}
1223 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1224 @code{_Sat unsigned long _Fract}
1225 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1226 and @code{_Sat unsigned long long _Fract}
1227 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1228 @code{_Sat short _Accum}
1229 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1230 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1231 @code{_Sat long _Accum}
1232 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1233 @code{_Sat long long _Accum}
1234 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1235 @code{_Sat unsigned short _Accum}
1236 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1237 @code{_Sat unsigned _Accum}
1238 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1239 @code{_Sat unsigned long _Accum}
1240 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1241 and @code{_Sat unsigned long long _Accum}
1242 @end itemize
1243
1244 GCC support of fixed-point types as specified by the draft technical report
1245 is incomplete:
1246
1247 @itemize @bullet
1248 @item
1249 Pragmas to control overflow and rounding behaviors are not implemented.
1250 @end itemize
1251
1252 Fixed-point types are supported by the DWARF 2 debug information format.
1253
1254 @node Named Address Spaces
1255 @section Named Address Spaces
1256 @cindex Named Address Spaces
1257
1258 As an extension, GNU C supports named address spaces as
1259 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1260 address spaces in GCC will evolve as the draft technical report
1261 changes.  Calling conventions for any target might also change.  At
1262 present, only the AVR, SPU, M32C, and RL78 targets support address
1263 spaces other than the generic address space.
1264
1265 Address space identifiers may be used exactly like any other C type
1266 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1267 document for more details.
1268
1269 @anchor{AVR Named Address Spaces}
1270 @subsection AVR Named Address Spaces
1271
1272 On the AVR target, there are several address spaces that can be used
1273 in order to put read-only data into the flash memory and access that
1274 data by means of the special instructions @code{LPM} or @code{ELPM}
1275 needed to read from flash.
1276
1277 Per default, any data including read-only data is located in RAM
1278 (the generic address space) so that non-generic address spaces are
1279 needed to locate read-only data in flash memory
1280 @emph{and} to generate the right instructions to access this data
1281 without using (inline) assembler code.
1282
1283 @table @code
1284 @item __flash
1285 @cindex @code{__flash} AVR Named Address Spaces
1286 The @code{__flash} qualifier locates data in the
1287 @code{.progmem.data} section. Data is read using the @code{LPM}
1288 instruction. Pointers to this address space are 16 bits wide.
1289
1290 @item __flash1
1291 @itemx __flash2
1292 @itemx __flash3
1293 @itemx __flash4
1294 @itemx __flash5
1295 @cindex @code{__flash1} AVR Named Address Spaces
1296 @cindex @code{__flash2} AVR Named Address Spaces
1297 @cindex @code{__flash3} AVR Named Address Spaces
1298 @cindex @code{__flash4} AVR Named Address Spaces
1299 @cindex @code{__flash5} AVR Named Address Spaces
1300 These are 16-bit address spaces locating data in section
1301 @code{.progmem@var{N}.data} where @var{N} refers to
1302 address space @code{__flash@var{N}}.
1303 The compiler sets the @code{RAMPZ} segment register appropriately 
1304 before reading data by means of the @code{ELPM} instruction.
1305
1306 @item __memx
1307 @cindex @code{__memx} AVR Named Address Spaces
1308 This is a 24-bit address space that linearizes flash and RAM:
1309 If the high bit of the address is set, data is read from
1310 RAM using the lower two bytes as RAM address.
1311 If the high bit of the address is clear, data is read from flash
1312 with @code{RAMPZ} set according to the high byte of the address.
1313 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1314
1315 Objects in this address space are located in @code{.progmemx.data}.
1316 @end table
1317
1318 @b{Example}
1319
1320 @smallexample
1321 char my_read (const __flash char ** p)
1322 @{
1323     /* p is a pointer to RAM that points to a pointer to flash.
1324        The first indirection of p reads that flash pointer
1325        from RAM and the second indirection reads a char from this
1326        flash address.  */
1327
1328     return **p;
1329 @}
1330
1331 /* Locate array[] in flash memory */
1332 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1333
1334 int i = 1;
1335
1336 int main (void)
1337 @{
1338    /* Return 17 by reading from flash memory */
1339    return array[array[i]];
1340 @}
1341 @end smallexample
1342
1343 @noindent
1344 For each named address space supported by avr-gcc there is an equally
1345 named but uppercase built-in macro defined. 
1346 The purpose is to facilitate testing if respective address space
1347 support is available or not:
1348
1349 @smallexample
1350 #ifdef __FLASH
1351 const __flash int var = 1;
1352
1353 int read_var (void)
1354 @{
1355     return var;
1356 @}
1357 #else
1358 #include <avr/pgmspace.h> /* From AVR-LibC */
1359
1360 const int var PROGMEM = 1;
1361
1362 int read_var (void)
1363 @{
1364     return (int) pgm_read_word (&var);
1365 @}
1366 #endif /* __FLASH */
1367 @end smallexample
1368
1369 @noindent
1370 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1371 locates data in flash but
1372 accesses to these data read from generic address space, i.e.@:
1373 from RAM,
1374 so that you need special accessors like @code{pgm_read_byte}
1375 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1376 together with attribute @code{progmem}.
1377
1378 @noindent
1379 @b{Limitations and caveats}
1380
1381 @itemize
1382 @item
1383 Reading across the 64@tie{}KiB section boundary of
1384 the @code{__flash} or @code{__flash@var{N}} address spaces
1385 shows undefined behavior. The only address space that
1386 supports reading across the 64@tie{}KiB flash segment boundaries is
1387 @code{__memx}.
1388
1389 @item
1390 If you use one of the @code{__flash@var{N}} address spaces
1391 you must arrange your linker script to locate the
1392 @code{.progmem@var{N}.data} sections according to your needs.
1393
1394 @item
1395 Any data or pointers to the non-generic address spaces must
1396 be qualified as @code{const}, i.e.@: as read-only data.
1397 This still applies if the data in one of these address
1398 spaces like software version number or calibration lookup table are intended to
1399 be changed after load time by, say, a boot loader. In this case
1400 the right qualification is @code{const} @code{volatile} so that the compiler
1401 must not optimize away known values or insert them
1402 as immediates into operands of instructions.
1403
1404 @item
1405 The following code initializes a variable @code{pfoo}
1406 located in static storage with a 24-bit address:
1407 @smallexample
1408 extern const __memx char foo;
1409 const __memx void *pfoo = &foo;
1410 @end smallexample
1411
1412 @noindent
1413 Such code requires at least binutils 2.23, see
1414 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1415
1416 @end itemize
1417
1418 @subsection M32C Named Address Spaces
1419 @cindex @code{__far} M32C Named Address Spaces
1420
1421 On the M32C target, with the R8C and M16C CPU variants, variables
1422 qualified with @code{__far} are accessed using 32-bit addresses in
1423 order to access memory beyond the first 64@tie{}Ki bytes.  If
1424 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1425 effect.
1426
1427 @subsection RL78 Named Address Spaces
1428 @cindex @code{__far} RL78 Named Address Spaces
1429
1430 On the RL78 target, variables qualified with @code{__far} are accessed
1431 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1432 addresses.  Non-far variables are assumed to appear in the topmost
1433 64@tie{}KiB of the address space.
1434
1435 @subsection SPU Named Address Spaces
1436 @cindex @code{__ea} SPU Named Address Spaces
1437
1438 On the SPU target variables may be declared as
1439 belonging to another address space by qualifying the type with the
1440 @code{__ea} address space identifier:
1441
1442 @smallexample
1443 extern int __ea i;
1444 @end smallexample
1445
1446 @noindent 
1447 The compiler generates special code to access the variable @code{i}.
1448 It may use runtime library
1449 support, or generate special machine instructions to access that address
1450 space.
1451
1452 @node Zero Length
1453 @section Arrays of Length Zero
1454 @cindex arrays of length zero
1455 @cindex zero-length arrays
1456 @cindex length-zero arrays
1457 @cindex flexible array members
1458
1459 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1460 last element of a structure that is really a header for a variable-length
1461 object:
1462
1463 @smallexample
1464 struct line @{
1465   int length;
1466   char contents[0];
1467 @};
1468
1469 struct line *thisline = (struct line *)
1470   malloc (sizeof (struct line) + this_length);
1471 thisline->length = this_length;
1472 @end smallexample
1473
1474 In ISO C90, you would have to give @code{contents} a length of 1, which
1475 means either you waste space or complicate the argument to @code{malloc}.
1476
1477 In ISO C99, you would use a @dfn{flexible array member}, which is
1478 slightly different in syntax and semantics:
1479
1480 @itemize @bullet
1481 @item
1482 Flexible array members are written as @code{contents[]} without
1483 the @code{0}.
1484
1485 @item
1486 Flexible array members have incomplete type, and so the @code{sizeof}
1487 operator may not be applied.  As a quirk of the original implementation
1488 of zero-length arrays, @code{sizeof} evaluates to zero.
1489
1490 @item
1491 Flexible array members may only appear as the last member of a
1492 @code{struct} that is otherwise non-empty.
1493
1494 @item
1495 A structure containing a flexible array member, or a union containing
1496 such a structure (possibly recursively), may not be a member of a
1497 structure or an element of an array.  (However, these uses are
1498 permitted by GCC as extensions.)
1499 @end itemize
1500
1501 GCC versions before 3.0 allowed zero-length arrays to be statically
1502 initialized, as if they were flexible arrays.  In addition to those
1503 cases that were useful, it also allowed initializations in situations
1504 that would corrupt later data.  Non-empty initialization of zero-length
1505 arrays is now treated like any case where there are more initializer
1506 elements than the array holds, in that a suitable warning about ``excess
1507 elements in array'' is given, and the excess elements (all of them, in
1508 this case) are ignored.
1509
1510 Instead GCC allows static initialization of flexible array members.
1511 This is equivalent to defining a new structure containing the original
1512 structure followed by an array of sufficient size to contain the data.
1513 E.g.@: in the following, @code{f1} is constructed as if it were declared
1514 like @code{f2}.
1515
1516 @smallexample
1517 struct f1 @{
1518   int x; int y[];
1519 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1520
1521 struct f2 @{
1522   struct f1 f1; int data[3];
1523 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1524 @end smallexample
1525
1526 @noindent
1527 The convenience of this extension is that @code{f1} has the desired
1528 type, eliminating the need to consistently refer to @code{f2.f1}.
1529
1530 This has symmetry with normal static arrays, in that an array of
1531 unknown size is also written with @code{[]}.
1532
1533 Of course, this extension only makes sense if the extra data comes at
1534 the end of a top-level object, as otherwise we would be overwriting
1535 data at subsequent offsets.  To avoid undue complication and confusion
1536 with initialization of deeply nested arrays, we simply disallow any
1537 non-empty initialization except when the structure is the top-level
1538 object.  For example:
1539
1540 @smallexample
1541 struct foo @{ int x; int y[]; @};
1542 struct bar @{ struct foo z; @};
1543
1544 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1545 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1546 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1547 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1548 @end smallexample
1549
1550 @node Empty Structures
1551 @section Structures With No Members
1552 @cindex empty structures
1553 @cindex zero-size structures
1554
1555 GCC permits a C structure to have no members:
1556
1557 @smallexample
1558 struct empty @{
1559 @};
1560 @end smallexample
1561
1562 The structure has size zero.  In C++, empty structures are part
1563 of the language.  G++ treats empty structures as if they had a single
1564 member of type @code{char}.
1565
1566 @node Variable Length
1567 @section Arrays of Variable Length
1568 @cindex variable-length arrays
1569 @cindex arrays of variable length
1570 @cindex VLAs
1571
1572 Variable-length automatic arrays are allowed in ISO C99, and as an
1573 extension GCC accepts them in C90 mode and in C++.  These arrays are
1574 declared like any other automatic arrays, but with a length that is not
1575 a constant expression.  The storage is allocated at the point of
1576 declaration and deallocated when the block scope containing the declaration
1577 exits.  For
1578 example:
1579
1580 @smallexample
1581 FILE *
1582 concat_fopen (char *s1, char *s2, char *mode)
1583 @{
1584   char str[strlen (s1) + strlen (s2) + 1];
1585   strcpy (str, s1);
1586   strcat (str, s2);
1587   return fopen (str, mode);
1588 @}
1589 @end smallexample
1590
1591 @cindex scope of a variable length array
1592 @cindex variable-length array scope
1593 @cindex deallocating variable length arrays
1594 Jumping or breaking out of the scope of the array name deallocates the
1595 storage.  Jumping into the scope is not allowed; you get an error
1596 message for it.
1597
1598 @cindex variable-length array in a structure
1599 As an extension, GCC accepts variable-length arrays as a member of
1600 a structure or a union.  For example:
1601
1602 @smallexample
1603 void
1604 foo (int n)
1605 @{
1606   struct S @{ int x[n]; @};
1607 @}
1608 @end smallexample
1609
1610 @cindex @code{alloca} vs variable-length arrays
1611 You can use the function @code{alloca} to get an effect much like
1612 variable-length arrays.  The function @code{alloca} is available in
1613 many other C implementations (but not in all).  On the other hand,
1614 variable-length arrays are more elegant.
1615
1616 There are other differences between these two methods.  Space allocated
1617 with @code{alloca} exists until the containing @emph{function} returns.
1618 The space for a variable-length array is deallocated as soon as the array
1619 name's scope ends.  (If you use both variable-length arrays and
1620 @code{alloca} in the same function, deallocation of a variable-length array
1621 also deallocates anything more recently allocated with @code{alloca}.)
1622
1623 You can also use variable-length arrays as arguments to functions:
1624
1625 @smallexample
1626 struct entry
1627 tester (int len, char data[len][len])
1628 @{
1629   /* @r{@dots{}} */
1630 @}
1631 @end smallexample
1632
1633 The length of an array is computed once when the storage is allocated
1634 and is remembered for the scope of the array in case you access it with
1635 @code{sizeof}.
1636
1637 If you want to pass the array first and the length afterward, you can
1638 use a forward declaration in the parameter list---another GNU extension.
1639
1640 @smallexample
1641 struct entry
1642 tester (int len; char data[len][len], int len)
1643 @{
1644   /* @r{@dots{}} */
1645 @}
1646 @end smallexample
1647
1648 @cindex parameter forward declaration
1649 The @samp{int len} before the semicolon is a @dfn{parameter forward
1650 declaration}, and it serves the purpose of making the name @code{len}
1651 known when the declaration of @code{data} is parsed.
1652
1653 You can write any number of such parameter forward declarations in the
1654 parameter list.  They can be separated by commas or semicolons, but the
1655 last one must end with a semicolon, which is followed by the ``real''
1656 parameter declarations.  Each forward declaration must match a ``real''
1657 declaration in parameter name and data type.  ISO C99 does not support
1658 parameter forward declarations.
1659
1660 @node Variadic Macros
1661 @section Macros with a Variable Number of Arguments.
1662 @cindex variable number of arguments
1663 @cindex macro with variable arguments
1664 @cindex rest argument (in macro)
1665 @cindex variadic macros
1666
1667 In the ISO C standard of 1999, a macro can be declared to accept a
1668 variable number of arguments much as a function can.  The syntax for
1669 defining the macro is similar to that of a function.  Here is an
1670 example:
1671
1672 @smallexample
1673 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1674 @end smallexample
1675
1676 @noindent
1677 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1678 such a macro, it represents the zero or more tokens until the closing
1679 parenthesis that ends the invocation, including any commas.  This set of
1680 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1681 wherever it appears.  See the CPP manual for more information.
1682
1683 GCC has long supported variadic macros, and used a different syntax that
1684 allowed you to give a name to the variable arguments just like any other
1685 argument.  Here is an example:
1686
1687 @smallexample
1688 #define debug(format, args...) fprintf (stderr, format, args)
1689 @end smallexample
1690
1691 @noindent
1692 This is in all ways equivalent to the ISO C example above, but arguably
1693 more readable and descriptive.
1694
1695 GNU CPP has two further variadic macro extensions, and permits them to
1696 be used with either of the above forms of macro definition.
1697
1698 In standard C, you are not allowed to leave the variable argument out
1699 entirely; but you are allowed to pass an empty argument.  For example,
1700 this invocation is invalid in ISO C, because there is no comma after
1701 the string:
1702
1703 @smallexample
1704 debug ("A message")
1705 @end smallexample
1706
1707 GNU CPP permits you to completely omit the variable arguments in this
1708 way.  In the above examples, the compiler would complain, though since
1709 the expansion of the macro still has the extra comma after the format
1710 string.
1711
1712 To help solve this problem, CPP behaves specially for variable arguments
1713 used with the token paste operator, @samp{##}.  If instead you write
1714
1715 @smallexample
1716 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1717 @end smallexample
1718
1719 @noindent
1720 and if the variable arguments are omitted or empty, the @samp{##}
1721 operator causes the preprocessor to remove the comma before it.  If you
1722 do provide some variable arguments in your macro invocation, GNU CPP
1723 does not complain about the paste operation and instead places the
1724 variable arguments after the comma.  Just like any other pasted macro
1725 argument, these arguments are not macro expanded.
1726
1727 @node Escaped Newlines
1728 @section Slightly Looser Rules for Escaped Newlines
1729 @cindex escaped newlines
1730 @cindex newlines (escaped)
1731
1732 Recently, the preprocessor has relaxed its treatment of escaped
1733 newlines.  Previously, the newline had to immediately follow a
1734 backslash.  The current implementation allows whitespace in the form
1735 of spaces, horizontal and vertical tabs, and form feeds between the
1736 backslash and the subsequent newline.  The preprocessor issues a
1737 warning, but treats it as a valid escaped newline and combines the two
1738 lines to form a single logical line.  This works within comments and
1739 tokens, as well as between tokens.  Comments are @emph{not} treated as
1740 whitespace for the purposes of this relaxation, since they have not
1741 yet been replaced with spaces.
1742
1743 @node Subscripting
1744 @section Non-Lvalue Arrays May Have Subscripts
1745 @cindex subscripting
1746 @cindex arrays, non-lvalue
1747
1748 @cindex subscripting and function values
1749 In ISO C99, arrays that are not lvalues still decay to pointers, and
1750 may be subscripted, although they may not be modified or used after
1751 the next sequence point and the unary @samp{&} operator may not be
1752 applied to them.  As an extension, GNU C allows such arrays to be
1753 subscripted in C90 mode, though otherwise they do not decay to
1754 pointers outside C99 mode.  For example,
1755 this is valid in GNU C though not valid in C90:
1756
1757 @smallexample
1758 @group
1759 struct foo @{int a[4];@};
1760
1761 struct foo f();
1762
1763 bar (int index)
1764 @{
1765   return f().a[index];
1766 @}
1767 @end group
1768 @end smallexample
1769
1770 @node Pointer Arith
1771 @section Arithmetic on @code{void}- and Function-Pointers
1772 @cindex void pointers, arithmetic
1773 @cindex void, size of pointer to
1774 @cindex function pointers, arithmetic
1775 @cindex function, size of pointer to
1776
1777 In GNU C, addition and subtraction operations are supported on pointers to
1778 @code{void} and on pointers to functions.  This is done by treating the
1779 size of a @code{void} or of a function as 1.
1780
1781 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1782 and on function types, and returns 1.
1783
1784 @opindex Wpointer-arith
1785 The option @option{-Wpointer-arith} requests a warning if these extensions
1786 are used.
1787
1788 @node Pointers to Arrays
1789 @section Pointers to arrays with qualifiers work as expected
1790 @cindex pointers to arrays
1791 @cindex const qualifier
1792
1793 In GNU C, pointers to arrays with qualifiers work similar to pointers
1794 to other qualified types. For example, a value of type @code{int (*)[5]}
1795 can be used to initialize a variable of type @code{const int (*)[5]}.
1796 These types are incompatible in ISO C because the @code{const} qualifier
1797 is formally attached to the element type of the array and not the
1798 array itself.
1799
1800 @smallexample
1801 extern void
1802 transpose (int N, int M, double out[M][N], const double in[N][M]);
1803 double x[3][2];
1804 double y[2][3];
1805 @r{@dots{}}
1806 transpose(3, 2, y, x);
1807 @end smallexample
1808
1809 @node Initializers
1810 @section Non-Constant Initializers
1811 @cindex initializers, non-constant
1812 @cindex non-constant initializers
1813
1814 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1815 automatic variable are not required to be constant expressions in GNU C@.
1816 Here is an example of an initializer with run-time varying elements:
1817
1818 @smallexample
1819 foo (float f, float g)
1820 @{
1821   float beat_freqs[2] = @{ f-g, f+g @};
1822   /* @r{@dots{}} */
1823 @}
1824 @end smallexample
1825
1826 @node Compound Literals
1827 @section Compound Literals
1828 @cindex constructor expressions
1829 @cindex initializations in expressions
1830 @cindex structures, constructor expression
1831 @cindex expressions, constructor
1832 @cindex compound literals
1833 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1834
1835 ISO C99 supports compound literals.  A compound literal looks like
1836 a cast containing an initializer.  Its value is an object of the
1837 type specified in the cast, containing the elements specified in
1838 the initializer; it is an lvalue.  As an extension, GCC supports
1839 compound literals in C90 mode and in C++, though the semantics are
1840 somewhat different in C++.
1841
1842 Usually, the specified type is a structure.  Assume that
1843 @code{struct foo} and @code{structure} are declared as shown:
1844
1845 @smallexample
1846 struct foo @{int a; char b[2];@} structure;
1847 @end smallexample
1848
1849 @noindent
1850 Here is an example of constructing a @code{struct foo} with a compound literal:
1851
1852 @smallexample
1853 structure = ((struct foo) @{x + y, 'a', 0@});
1854 @end smallexample
1855
1856 @noindent
1857 This is equivalent to writing the following:
1858
1859 @smallexample
1860 @{
1861   struct foo temp = @{x + y, 'a', 0@};
1862   structure = temp;
1863 @}
1864 @end smallexample
1865
1866 You can also construct an array, though this is dangerous in C++, as
1867 explained below.  If all the elements of the compound literal are
1868 (made up of) simple constant expressions, suitable for use in
1869 initializers of objects of static storage duration, then the compound
1870 literal can be coerced to a pointer to its first element and used in
1871 such an initializer, as shown here:
1872
1873 @smallexample
1874 char **foo = (char *[]) @{ "x", "y", "z" @};
1875 @end smallexample
1876
1877 Compound literals for scalar types and union types are
1878 also allowed, but then the compound literal is equivalent
1879 to a cast.
1880
1881 As a GNU extension, GCC allows initialization of objects with static storage
1882 duration by compound literals (which is not possible in ISO C99, because
1883 the initializer is not a constant).
1884 It is handled as if the object is initialized only with the bracket
1885 enclosed list if the types of the compound literal and the object match.
1886 The initializer list of the compound literal must be constant.
1887 If the object being initialized has array type of unknown size, the size is
1888 determined by compound literal size.
1889
1890 @smallexample
1891 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1892 static int y[] = (int []) @{1, 2, 3@};
1893 static int z[] = (int [3]) @{1@};
1894 @end smallexample
1895
1896 @noindent
1897 The above lines are equivalent to the following:
1898 @smallexample
1899 static struct foo x = @{1, 'a', 'b'@};
1900 static int y[] = @{1, 2, 3@};
1901 static int z[] = @{1, 0, 0@};
1902 @end smallexample
1903
1904 In C, a compound literal designates an unnamed object with static or
1905 automatic storage duration.  In C++, a compound literal designates a
1906 temporary object, which only lives until the end of its
1907 full-expression.  As a result, well-defined C code that takes the
1908 address of a subobject of a compound literal can be undefined in C++.
1909 For instance, if the array compound literal example above appeared
1910 inside a function, any subsequent use of @samp{foo} in C++ has
1911 undefined behavior because the lifetime of the array ends after the
1912 declaration of @samp{foo}.  As a result, the C++ compiler now rejects
1913 the conversion of a temporary array to a pointer.
1914
1915 As an optimization, the C++ compiler sometimes gives array compound
1916 literals longer lifetimes: when the array either appears outside a
1917 function or has const-qualified type.  If @samp{foo} and its
1918 initializer had elements of @samp{char *const} type rather than
1919 @samp{char *}, or if @samp{foo} were a global variable, the array
1920 would have static storage duration.  But it is probably safest just to
1921 avoid the use of array compound literals in code compiled as C++.
1922
1923 @node Designated Inits
1924 @section Designated Initializers
1925 @cindex initializers with labeled elements
1926 @cindex labeled elements in initializers
1927 @cindex case labels in initializers
1928 @cindex designated initializers
1929
1930 Standard C90 requires the elements of an initializer to appear in a fixed
1931 order, the same as the order of the elements in the array or structure
1932 being initialized.
1933
1934 In ISO C99 you can give the elements in any order, specifying the array
1935 indices or structure field names they apply to, and GNU C allows this as
1936 an extension in C90 mode as well.  This extension is not
1937 implemented in GNU C++.
1938
1939 To specify an array index, write
1940 @samp{[@var{index}] =} before the element value.  For example,
1941
1942 @smallexample
1943 int a[6] = @{ [4] = 29, [2] = 15 @};
1944 @end smallexample
1945
1946 @noindent
1947 is equivalent to
1948
1949 @smallexample
1950 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1951 @end smallexample
1952
1953 @noindent
1954 The index values must be constant expressions, even if the array being
1955 initialized is automatic.
1956
1957 An alternative syntax for this that has been obsolete since GCC 2.5 but
1958 GCC still accepts is to write @samp{[@var{index}]} before the element
1959 value, with no @samp{=}.
1960
1961 To initialize a range of elements to the same value, write
1962 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
1963 extension.  For example,
1964
1965 @smallexample
1966 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1967 @end smallexample
1968
1969 @noindent
1970 If the value in it has side-effects, the side-effects happen only once,
1971 not for each initialized field by the range initializer.
1972
1973 @noindent
1974 Note that the length of the array is the highest value specified
1975 plus one.
1976
1977 In a structure initializer, specify the name of a field to initialize
1978 with @samp{.@var{fieldname} =} before the element value.  For example,
1979 given the following structure,
1980
1981 @smallexample
1982 struct point @{ int x, y; @};
1983 @end smallexample
1984
1985 @noindent
1986 the following initialization
1987
1988 @smallexample
1989 struct point p = @{ .y = yvalue, .x = xvalue @};
1990 @end smallexample
1991
1992 @noindent
1993 is equivalent to
1994
1995 @smallexample
1996 struct point p = @{ xvalue, yvalue @};
1997 @end smallexample
1998
1999 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2000 @samp{@var{fieldname}:}, as shown here:
2001
2002 @smallexample
2003 struct point p = @{ y: yvalue, x: xvalue @};
2004 @end smallexample
2005
2006 Omitted field members are implicitly initialized the same as objects
2007 that have static storage duration.
2008
2009 @cindex designators
2010 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2011 @dfn{designator}.  You can also use a designator (or the obsolete colon
2012 syntax) when initializing a union, to specify which element of the union
2013 should be used.  For example,
2014
2015 @smallexample
2016 union foo @{ int i; double d; @};
2017
2018 union foo f = @{ .d = 4 @};
2019 @end smallexample
2020
2021 @noindent
2022 converts 4 to a @code{double} to store it in the union using
2023 the second element.  By contrast, casting 4 to type @code{union foo}
2024 stores it into the union as the integer @code{i}, since it is
2025 an integer.  (@xref{Cast to Union}.)
2026
2027 You can combine this technique of naming elements with ordinary C
2028 initialization of successive elements.  Each initializer element that
2029 does not have a designator applies to the next consecutive element of the
2030 array or structure.  For example,
2031
2032 @smallexample
2033 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2034 @end smallexample
2035
2036 @noindent
2037 is equivalent to
2038
2039 @smallexample
2040 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2041 @end smallexample
2042
2043 Labeling the elements of an array initializer is especially useful
2044 when the indices are characters or belong to an @code{enum} type.
2045 For example:
2046
2047 @smallexample
2048 int whitespace[256]
2049   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2050       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2051 @end smallexample
2052
2053 @cindex designator lists
2054 You can also write a series of @samp{.@var{fieldname}} and
2055 @samp{[@var{index}]} designators before an @samp{=} to specify a
2056 nested subobject to initialize; the list is taken relative to the
2057 subobject corresponding to the closest surrounding brace pair.  For
2058 example, with the @samp{struct point} declaration above:
2059
2060 @smallexample
2061 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2062 @end smallexample
2063
2064 @noindent
2065 If the same field is initialized multiple times, it has the value from
2066 the last initialization.  If any such overridden initialization has
2067 side-effect, it is unspecified whether the side-effect happens or not.
2068 Currently, GCC discards them and issues a warning.
2069
2070 @node Case Ranges
2071 @section Case Ranges
2072 @cindex case ranges
2073 @cindex ranges in case statements
2074
2075 You can specify a range of consecutive values in a single @code{case} label,
2076 like this:
2077
2078 @smallexample
2079 case @var{low} ... @var{high}:
2080 @end smallexample
2081
2082 @noindent
2083 This has the same effect as the proper number of individual @code{case}
2084 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2085
2086 This feature is especially useful for ranges of ASCII character codes:
2087
2088 @smallexample
2089 case 'A' ... 'Z':
2090 @end smallexample
2091
2092 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2093 it may be parsed wrong when you use it with integer values.  For example,
2094 write this:
2095
2096 @smallexample
2097 case 1 ... 5:
2098 @end smallexample
2099
2100 @noindent
2101 rather than this:
2102
2103 @smallexample
2104 case 1...5:
2105 @end smallexample
2106
2107 @node Cast to Union
2108 @section Cast to a Union Type
2109 @cindex cast to a union
2110 @cindex union, casting to a
2111
2112 A cast to union type is similar to other casts, except that the type
2113 specified is a union type.  You can specify the type either with
2114 @code{union @var{tag}} or with a typedef name.  A cast to union is actually
2115 a constructor, not a cast, and hence does not yield an lvalue like
2116 normal casts.  (@xref{Compound Literals}.)
2117
2118 The types that may be cast to the union type are those of the members
2119 of the union.  Thus, given the following union and variables:
2120
2121 @smallexample
2122 union foo @{ int i; double d; @};
2123 int x;
2124 double y;
2125 @end smallexample
2126
2127 @noindent
2128 both @code{x} and @code{y} can be cast to type @code{union foo}.
2129
2130 Using the cast as the right-hand side of an assignment to a variable of
2131 union type is equivalent to storing in a member of the union:
2132
2133 @smallexample
2134 union foo u;
2135 /* @r{@dots{}} */
2136 u = (union foo) x  @equiv{}  u.i = x
2137 u = (union foo) y  @equiv{}  u.d = y
2138 @end smallexample
2139
2140 You can also use the union cast as a function argument:
2141
2142 @smallexample
2143 void hack (union foo);
2144 /* @r{@dots{}} */
2145 hack ((union foo) x);
2146 @end smallexample
2147
2148 @node Mixed Declarations
2149 @section Mixed Declarations and Code
2150 @cindex mixed declarations and code
2151 @cindex declarations, mixed with code
2152 @cindex code, mixed with declarations
2153
2154 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2155 within compound statements.  As an extension, GNU C also allows this in
2156 C90 mode.  For example, you could do:
2157
2158 @smallexample
2159 int i;
2160 /* @r{@dots{}} */
2161 i++;
2162 int j = i + 2;
2163 @end smallexample
2164
2165 Each identifier is visible from where it is declared until the end of
2166 the enclosing block.
2167
2168 @node Function Attributes
2169 @section Declaring Attributes of Functions
2170 @cindex function attributes
2171 @cindex declaring attributes of functions
2172 @cindex functions that never return
2173 @cindex functions that return more than once
2174 @cindex functions that have no side effects
2175 @cindex functions in arbitrary sections
2176 @cindex functions that behave like malloc
2177 @cindex @code{volatile} applied to function
2178 @cindex @code{const} applied to function
2179 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2180 @cindex functions with non-null pointer arguments
2181 @cindex functions that are passed arguments in registers on x86-32
2182 @cindex functions that pop the argument stack on x86-32
2183 @cindex functions that do not pop the argument stack on x86-32
2184 @cindex functions that have different compilation options on x86-32
2185 @cindex functions that have different optimization options
2186 @cindex functions that are dynamically resolved
2187
2188 In GNU C, you declare certain things about functions called in your program
2189 which help the compiler optimize function calls and check your code more
2190 carefully.
2191
2192 The keyword @code{__attribute__} allows you to specify special
2193 attributes when making a declaration.  This keyword is followed by an
2194 attribute specification inside double parentheses.  The following
2195 attributes are currently defined for functions on all targets:
2196 @code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned},
2197 @code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone},
2198 @code{no_icf},
2199 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2200 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2201 @code{no_instrument_function}, @code{no_split_stack},
2202 @code{section}, @code{constructor},
2203 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2204 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2205 @code{warn_unused_result}, @code{nonnull},
2206 @code{returns_nonnull}, @code{gnu_inline},
2207 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2208 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2209 @code{no_sanitize_thread},
2210 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
2211 @code{bnd_instrument}, @code{stack_protect},
2212 @code{error} and @code{warning}.
2213 Several other attributes are defined for functions on particular
2214 target systems.  Other attributes, including @code{section} are
2215 supported for variables declarations (@pxref{Variable Attributes}),
2216 labels (@pxref{Label Attributes})
2217 and for types (@pxref{Type Attributes}).
2218
2219 GCC plugins may provide their own attributes.
2220
2221 You may also specify attributes with @samp{__} preceding and following
2222 each keyword.  This allows you to use them in header files without
2223 being concerned about a possible macro of the same name.  For example,
2224 you may use @code{__noreturn__} instead of @code{noreturn}.
2225
2226 @xref{Attribute Syntax}, for details of the exact syntax for using
2227 attributes.
2228
2229 @table @code
2230 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2231
2232 @item alias ("@var{target}")
2233 @cindex @code{alias} attribute
2234 The @code{alias} attribute causes the declaration to be emitted as an
2235 alias for another symbol, which must be specified.  For instance,
2236
2237 @smallexample
2238 void __f () @{ /* @r{Do something.} */; @}
2239 void f () __attribute__ ((weak, alias ("__f")));
2240 @end smallexample
2241
2242 @noindent
2243 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2244 mangled name for the target must be used.  It is an error if @samp{__f}
2245 is not defined in the same translation unit.
2246
2247 Not all target machines support this attribute.
2248
2249 @item aligned (@var{alignment})
2250 @cindex @code{aligned} attribute
2251 This attribute specifies a minimum alignment for the function,
2252 measured in bytes.
2253
2254 You cannot use this attribute to decrease the alignment of a function,
2255 only to increase it.  However, when you explicitly specify a function
2256 alignment this overrides the effect of the
2257 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2258 function.
2259
2260 Note that the effectiveness of @code{aligned} attributes may be
2261 limited by inherent limitations in your linker.  On many systems, the
2262 linker is only able to arrange for functions to be aligned up to a
2263 certain maximum alignment.  (For some linkers, the maximum supported
2264 alignment may be very very small.)  See your linker documentation for
2265 further information.
2266
2267 The @code{aligned} attribute can also be used for variables and fields
2268 (@pxref{Variable Attributes}.)
2269
2270 @item alloc_size
2271 @cindex @code{alloc_size} attribute
2272 The @code{alloc_size} attribute is used to tell the compiler that the
2273 function return value points to memory, where the size is given by
2274 one or two of the functions parameters.  GCC uses this
2275 information to improve the correctness of @code{__builtin_object_size}.
2276
2277 The function parameter(s) denoting the allocated size are specified by
2278 one or two integer arguments supplied to the attribute.  The allocated size
2279 is either the value of the single function argument specified or the product
2280 of the two function arguments specified.  Argument numbering starts at
2281 one.
2282
2283 For instance,
2284
2285 @smallexample
2286 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2287 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2288 @end smallexample
2289
2290 @noindent
2291 declares that @code{my_calloc} returns memory of the size given by
2292 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2293 of the size given by parameter 2.
2294
2295 @item alloc_align
2296 @cindex @code{alloc_align} attribute
2297 The @code{alloc_align} attribute is used to tell the compiler that the
2298 function return value points to memory, where the returned pointer minimum
2299 alignment is given by one of the functions parameters.  GCC uses this
2300 information to improve pointer alignment analysis.
2301
2302 The function parameter denoting the allocated alignment is specified by
2303 one integer argument, whose number is the argument of the attribute.
2304 Argument numbering starts at one.
2305
2306 For instance,
2307
2308 @smallexample
2309 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2310 @end smallexample
2311
2312 @noindent
2313 declares that @code{my_memalign} returns memory with minimum alignment
2314 given by parameter 1.
2315
2316 @item assume_aligned
2317 @cindex @code{assume_aligned} attribute
2318 The @code{assume_aligned} attribute is used to tell the compiler that the
2319 function return value points to memory, where the returned pointer minimum
2320 alignment is given by the first argument.
2321 If the attribute has two arguments, the second argument is misalignment offset.
2322
2323 For instance
2324
2325 @smallexample
2326 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2327 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2328 @end smallexample
2329
2330 @noindent
2331 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2332 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2333 to 8.
2334
2335 @item always_inline
2336 @cindex @code{always_inline} function attribute
2337 Generally, functions are not inlined unless optimization is specified.
2338 For functions declared inline, this attribute inlines the function
2339 independent of any restrictions that otherwise apply to inlining.
2340 Failure to inline such a function is diagnosed as an error.
2341 Note that if such a function is called indirectly the compiler may
2342 or may not inline it depending on optimization level and a failure
2343 to inline an indirect call may or may not be diagnosed.
2344
2345 @item gnu_inline
2346 @cindex @code{gnu_inline} function attribute
2347 This attribute should be used with a function that is also declared
2348 with the @code{inline} keyword.  It directs GCC to treat the function
2349 as if it were defined in gnu90 mode even when compiling in C99 or
2350 gnu99 mode.
2351
2352 If the function is declared @code{extern}, then this definition of the
2353 function is used only for inlining.  In no case is the function
2354 compiled as a standalone function, not even if you take its address
2355 explicitly.  Such an address becomes an external reference, as if you
2356 had only declared the function, and had not defined it.  This has
2357 almost the effect of a macro.  The way to use this is to put a
2358 function definition in a header file with this attribute, and put
2359 another copy of the function, without @code{extern}, in a library
2360 file.  The definition in the header file causes most calls to the
2361 function to be inlined.  If any uses of the function remain, they
2362 refer to the single copy in the library.  Note that the two
2363 definitions of the functions need not be precisely the same, although
2364 if they do not have the same effect your program may behave oddly.
2365
2366 In C, if the function is neither @code{extern} nor @code{static}, then
2367 the function is compiled as a standalone function, as well as being
2368 inlined where possible.
2369
2370 This is how GCC traditionally handled functions declared
2371 @code{inline}.  Since ISO C99 specifies a different semantics for
2372 @code{inline}, this function attribute is provided as a transition
2373 measure and as a useful feature in its own right.  This attribute is
2374 available in GCC 4.1.3 and later.  It is available if either of the
2375 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2376 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2377 Function is As Fast As a Macro}.
2378
2379 In C++, this attribute does not depend on @code{extern} in any way,
2380 but it still requires the @code{inline} keyword to enable its special
2381 behavior.
2382
2383 @item artificial
2384 @cindex @code{artificial} function attribute
2385 This attribute is useful for small inline wrappers that if possible
2386 should appear during debugging as a unit.  Depending on the debug
2387 info format it either means marking the function as artificial
2388 or using the caller location for all instructions within the inlined
2389 body.
2390
2391 @item bank_switch
2392 @cindex interrupt handler functions
2393 When added to an interrupt handler with the M32C port, causes the
2394 prologue and epilogue to use bank switching to preserve the registers
2395 rather than saving them on the stack.
2396
2397 @item flatten
2398 @cindex @code{flatten} function attribute
2399 Generally, inlining into a function is limited.  For a function marked with
2400 this attribute, every call inside this function is inlined, if possible.
2401 Whether the function itself is considered for inlining depends on its size and
2402 the current inlining parameters.
2403
2404 @item error ("@var{message}")
2405 @cindex @code{error} function attribute
2406 If this attribute is used on a function declaration and a call to such a function
2407 is not eliminated through dead code elimination or other optimizations, an error
2408 that includes @var{message} is diagnosed.  This is useful
2409 for compile-time checking, especially together with @code{__builtin_constant_p}
2410 and inline functions where checking the inline function arguments is not
2411 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2412 While it is possible to leave the function undefined and thus invoke
2413 a link failure, when using this attribute the problem is diagnosed
2414 earlier and with exact location of the call even in presence of inline
2415 functions or when not emitting debugging information.
2416
2417 @item warning ("@var{message}")
2418 @cindex @code{warning} function attribute
2419 If this attribute is used on a function declaration and a call to such a function
2420 is not eliminated through dead code elimination or other optimizations, a warning
2421 that includes @var{message} is diagnosed.  This is useful
2422 for compile-time checking, especially together with @code{__builtin_constant_p}
2423 and inline functions.  While it is possible to define the function with
2424 a message in @code{.gnu.warning*} section, when using this attribute the problem
2425 is diagnosed earlier and with exact location of the call even in presence
2426 of inline functions or when not emitting debugging information.
2427
2428 @item cdecl
2429 @cindex functions that do pop the argument stack on x86-32
2430 @opindex mrtd
2431 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
2432 assume that the calling function pops off the stack space used to
2433 pass arguments.  This is
2434 useful to override the effects of the @option{-mrtd} switch.
2435
2436 @item const
2437 @cindex @code{const} function attribute
2438 Many functions do not examine any values except their arguments, and
2439 have no effects except the return value.  Basically this is just slightly
2440 more strict class than the @code{pure} attribute below, since function is not
2441 allowed to read global memory.
2442
2443 @cindex pointer arguments
2444 Note that a function that has pointer arguments and examines the data
2445 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2446 function that calls a non-@code{const} function usually must not be
2447 @code{const}.  It does not make sense for a @code{const} function to
2448 return @code{void}.
2449
2450 The attribute @code{const} is not implemented in GCC versions earlier
2451 than 2.5.  An alternative way to declare that a function has no side
2452 effects, which works in the current version and in some older versions,
2453 is as follows:
2454
2455 @smallexample
2456 typedef int intfn ();
2457
2458 extern const intfn square;
2459 @end smallexample
2460
2461 @noindent
2462 This approach does not work in GNU C++ from 2.6.0 on, since the language
2463 specifies that the @samp{const} must be attached to the return value.
2464
2465 @item constructor
2466 @itemx destructor
2467 @itemx constructor (@var{priority})
2468 @itemx destructor (@var{priority})
2469 @cindex @code{constructor} function attribute
2470 @cindex @code{destructor} function attribute
2471 The @code{constructor} attribute causes the function to be called
2472 automatically before execution enters @code{main ()}.  Similarly, the
2473 @code{destructor} attribute causes the function to be called
2474 automatically after @code{main ()} completes or @code{exit ()} is
2475 called.  Functions with these attributes are useful for
2476 initializing data that is used implicitly during the execution of
2477 the program.
2478
2479 You may provide an optional integer priority to control the order in
2480 which constructor and destructor functions are run.  A constructor
2481 with a smaller priority number runs before a constructor with a larger
2482 priority number; the opposite relationship holds for destructors.  So,
2483 if you have a constructor that allocates a resource and a destructor
2484 that deallocates the same resource, both functions typically have the
2485 same priority.  The priorities for constructor and destructor
2486 functions are the same as those specified for namespace-scope C++
2487 objects (@pxref{C++ Attributes}).
2488
2489 These attributes are not currently implemented for Objective-C@.
2490
2491 @item deprecated
2492 @itemx deprecated (@var{msg})
2493 @cindex @code{deprecated} attribute.
2494 The @code{deprecated} attribute results in a warning if the function
2495 is used anywhere in the source file.  This is useful when identifying
2496 functions that are expected to be removed in a future version of a
2497 program.  The warning also includes the location of the declaration
2498 of the deprecated function, to enable users to easily find further
2499 information about why the function is deprecated, or what they should
2500 do instead.  Note that the warnings only occurs for uses:
2501
2502 @smallexample
2503 int old_fn () __attribute__ ((deprecated));
2504 int old_fn ();
2505 int (*fn_ptr)() = old_fn;
2506 @end smallexample
2507
2508 @noindent
2509 results in a warning on line 3 but not line 2.  The optional @var{msg}
2510 argument, which must be a string, is printed in the warning if
2511 present.
2512
2513 The @code{deprecated} attribute can also be used for variables and
2514 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2515
2516 @item disinterrupt
2517 @cindex @code{disinterrupt} attribute
2518 On Epiphany and MeP targets, this attribute causes the compiler to emit
2519 instructions to disable interrupts for the duration of the given
2520 function.
2521
2522 @item dllexport
2523 @cindex @code{__declspec(dllexport)}
2524 On Microsoft Windows targets and Symbian OS targets the
2525 @code{dllexport} attribute causes the compiler to provide a global
2526 pointer to a pointer in a DLL, so that it can be referenced with the
2527 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
2528 name is formed by combining @code{_imp__} and the function or variable
2529 name.
2530
2531 You can use @code{__declspec(dllexport)} as a synonym for
2532 @code{__attribute__ ((dllexport))} for compatibility with other
2533 compilers.
2534
2535 On systems that support the @code{visibility} attribute, this
2536 attribute also implies ``default'' visibility.  It is an error to
2537 explicitly specify any other visibility.
2538
2539 In previous versions of GCC, the @code{dllexport} attribute was ignored
2540 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2541 had been used.  The default behavior now is to emit all dllexported
2542 inline functions; however, this can cause object file-size bloat, in
2543 which case the old behavior can be restored by using
2544 @option{-fno-keep-inline-dllexport}.
2545
2546 The attribute is also ignored for undefined symbols.
2547
2548 When applied to C++ classes, the attribute marks defined non-inlined
2549 member functions and static data members as exports.  Static consts
2550 initialized in-class are not marked unless they are also defined
2551 out-of-class.
2552
2553 For Microsoft Windows targets there are alternative methods for
2554 including the symbol in the DLL's export table such as using a
2555 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2556 the @option{--export-all} linker flag.
2557
2558 @item dllimport
2559 @cindex @code{__declspec(dllimport)}
2560 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2561 attribute causes the compiler to reference a function or variable via
2562 a global pointer to a pointer that is set up by the DLL exporting the
2563 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
2564 targets, the pointer name is formed by combining @code{_imp__} and the
2565 function or variable name.
2566
2567 You can use @code{__declspec(dllimport)} as a synonym for
2568 @code{__attribute__ ((dllimport))} for compatibility with other
2569 compilers.
2570
2571 On systems that support the @code{visibility} attribute, this
2572 attribute also implies ``default'' visibility.  It is an error to
2573 explicitly specify any other visibility.
2574
2575 Currently, the attribute is ignored for inlined functions.  If the
2576 attribute is applied to a symbol @emph{definition}, an error is reported.
2577 If a symbol previously declared @code{dllimport} is later defined, the
2578 attribute is ignored in subsequent references, and a warning is emitted.
2579 The attribute is also overridden by a subsequent declaration as
2580 @code{dllexport}.
2581
2582 When applied to C++ classes, the attribute marks non-inlined
2583 member functions and static data members as imports.  However, the
2584 attribute is ignored for virtual methods to allow creation of vtables
2585 using thunks.
2586
2587 On the SH Symbian OS target the @code{dllimport} attribute also has
2588 another affect---it can cause the vtable and run-time type information
2589 for a class to be exported.  This happens when the class has a
2590 dllimported constructor or a non-inline, non-pure virtual function
2591 and, for either of those two conditions, the class also has an inline
2592 constructor or destructor and has a key function that is defined in
2593 the current translation unit.
2594
2595 For Microsoft Windows targets the use of the @code{dllimport}
2596 attribute on functions is not necessary, but provides a small
2597 performance benefit by eliminating a thunk in the DLL@.  The use of the
2598 @code{dllimport} attribute on imported variables was required on older
2599 versions of the GNU linker, but can now be avoided by passing the
2600 @option{--enable-auto-import} switch to the GNU linker.  As with
2601 functions, using the attribute for a variable eliminates a thunk in
2602 the DLL@.
2603
2604 One drawback to using this attribute is that a pointer to a
2605 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2606 address. However, a pointer to a @emph{function} with the
2607 @code{dllimport} attribute can be used as a constant initializer; in
2608 this case, the address of a stub function in the import lib is
2609 referenced.  On Microsoft Windows targets, the attribute can be disabled
2610 for functions by setting the @option{-mnop-fun-dllimport} flag.
2611
2612 @item eightbit_data
2613 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2614 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2615 variable should be placed into the eight-bit data section.
2616 The compiler generates more efficient code for certain operations
2617 on data in the eight-bit data area.  Note the eight-bit data area is limited to
2618 256 bytes of data.
2619
2620 You must use GAS and GLD from GNU binutils version 2.7 or later for
2621 this attribute to work correctly.
2622
2623 @item exception
2624 @cindex exception handler functions
2625 Use this attribute on the NDS32 target to indicate that the specified function
2626 is an exception handler.  The compiler will generate corresponding sections
2627 for use in an exception handler.
2628
2629 @item exception_handler
2630 @cindex exception handler functions on the Blackfin processor
2631 Use this attribute on the Blackfin to indicate that the specified function
2632 is an exception handler.  The compiler generates function entry and
2633 exit sequences suitable for use in an exception handler when this
2634 attribute is present.
2635
2636 @item externally_visible
2637 @cindex @code{externally_visible} attribute.
2638 This attribute, attached to a global variable or function, nullifies
2639 the effect of the @option{-fwhole-program} command-line option, so the
2640 object remains visible outside the current compilation unit.
2641
2642 If @option{-fwhole-program} is used together with @option{-flto} and 
2643 @command{gold} is used as the linker plugin, 
2644 @code{externally_visible} attributes are automatically added to functions 
2645 (not variable yet due to a current @command{gold} issue) 
2646 that are accessed outside of LTO objects according to resolution file
2647 produced by @command{gold}.
2648 For other linkers that cannot generate resolution file,
2649 explicit @code{externally_visible} attributes are still necessary.
2650
2651 @item far
2652 @cindex functions that handle memory bank switching
2653 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2654 use a calling convention that takes care of switching memory banks when
2655 entering and leaving a function.  This calling convention is also the
2656 default when using the @option{-mlong-calls} option.
2657
2658 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2659 to call and return from a function.
2660
2661 On 68HC11 the compiler generates a sequence of instructions
2662 to invoke a board-specific routine to switch the memory bank and call the
2663 real function.  The board-specific routine simulates a @code{call}.
2664 At the end of a function, it jumps to a board-specific routine
2665 instead of using @code{rts}.  The board-specific return routine simulates
2666 the @code{rtc}.
2667
2668 On MeP targets this causes the compiler to use a calling convention
2669 that assumes the called function is too far away for the built-in
2670 addressing modes.
2671
2672 @item fast_interrupt
2673 @cindex interrupt handler functions
2674 Use this attribute on the M32C and RX ports to indicate that the specified
2675 function is a fast interrupt handler.  This is just like the
2676 @code{interrupt} attribute, except that @code{freit} is used to return
2677 instead of @code{reit}.
2678
2679 @item fastcall
2680 @cindex functions that pop the argument stack on x86-32
2681 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
2682 pass the first argument (if of integral type) in the register ECX and
2683 the second argument (if of integral type) in the register EDX@.  Subsequent
2684 and other typed arguments are passed on the stack.  The called function
2685 pops the arguments off the stack.  If the number of arguments is variable all
2686 arguments are pushed on the stack.
2687
2688 @item thiscall
2689 @cindex functions that pop the argument stack on x86-32
2690 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
2691 pass the first argument (if of integral type) in the register ECX.
2692 Subsequent and other typed arguments are passed on the stack. The called
2693 function pops the arguments off the stack.
2694 If the number of arguments is variable all arguments are pushed on the
2695 stack.
2696 The @code{thiscall} attribute is intended for C++ non-static member functions.
2697 As a GCC extension, this calling convention can be used for C functions
2698 and for static member methods.
2699
2700 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2701 @cindex @code{format} function attribute
2702 @opindex Wformat
2703 The @code{format} attribute specifies that a function takes @code{printf},
2704 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2705 should be type-checked against a format string.  For example, the
2706 declaration:
2707
2708 @smallexample
2709 extern int
2710 my_printf (void *my_object, const char *my_format, ...)
2711       __attribute__ ((format (printf, 2, 3)));
2712 @end smallexample
2713
2714 @noindent
2715 causes the compiler to check the arguments in calls to @code{my_printf}
2716 for consistency with the @code{printf} style format string argument
2717 @code{my_format}.
2718
2719 The parameter @var{archetype} determines how the format string is
2720 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2721 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2722 @code{strfmon}.  (You can also use @code{__printf__},
2723 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2724 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2725 @code{ms_strftime} are also present.
2726 @var{archetype} values such as @code{printf} refer to the formats accepted
2727 by the system's C runtime library,
2728 while values prefixed with @samp{gnu_} always refer
2729 to the formats accepted by the GNU C Library.  On Microsoft Windows
2730 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2731 @file{msvcrt.dll} library.
2732 The parameter @var{string-index}
2733 specifies which argument is the format string argument (starting
2734 from 1), while @var{first-to-check} is the number of the first
2735 argument to check against the format string.  For functions
2736 where the arguments are not available to be checked (such as
2737 @code{vprintf}), specify the third parameter as zero.  In this case the
2738 compiler only checks the format string for consistency.  For
2739 @code{strftime} formats, the third parameter is required to be zero.
2740 Since non-static C++ methods have an implicit @code{this} argument, the
2741 arguments of such methods should be counted from two, not one, when
2742 giving values for @var{string-index} and @var{first-to-check}.
2743
2744 In the example above, the format string (@code{my_format}) is the second
2745 argument of the function @code{my_print}, and the arguments to check
2746 start with the third argument, so the correct parameters for the format
2747 attribute are 2 and 3.
2748
2749 @opindex ffreestanding
2750 @opindex fno-builtin
2751 The @code{format} attribute allows you to identify your own functions
2752 that take format strings as arguments, so that GCC can check the
2753 calls to these functions for errors.  The compiler always (unless
2754 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2755 for the standard library functions @code{printf}, @code{fprintf},
2756 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2757 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2758 warnings are requested (using @option{-Wformat}), so there is no need to
2759 modify the header file @file{stdio.h}.  In C99 mode, the functions
2760 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2761 @code{vsscanf} are also checked.  Except in strictly conforming C
2762 standard modes, the X/Open function @code{strfmon} is also checked as
2763 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2764 @xref{C Dialect Options,,Options Controlling C Dialect}.
2765
2766 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2767 recognized in the same context.  Declarations including these format attributes
2768 are parsed for correct syntax, however the result of checking of such format
2769 strings is not yet defined, and is not carried out by this version of the
2770 compiler.
2771
2772 The target may also provide additional types of format checks.
2773 @xref{Target Format Checks,,Format Checks Specific to Particular
2774 Target Machines}.
2775
2776 @item format_arg (@var{string-index})
2777 @cindex @code{format_arg} function attribute
2778 @opindex Wformat-nonliteral
2779 The @code{format_arg} attribute specifies that a function takes a format
2780 string for a @code{printf}, @code{scanf}, @code{strftime} or
2781 @code{strfmon} style function and modifies it (for example, to translate
2782 it into another language), so the result can be passed to a
2783 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2784 function (with the remaining arguments to the format function the same
2785 as they would have been for the unmodified string).  For example, the
2786 declaration:
2787
2788 @smallexample
2789 extern char *
2790 my_dgettext (char *my_domain, const char *my_format)
2791       __attribute__ ((format_arg (2)));
2792 @end smallexample
2793
2794 @noindent
2795 causes the compiler to check the arguments in calls to a @code{printf},
2796 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2797 format string argument is a call to the @code{my_dgettext} function, for
2798 consistency with the format string argument @code{my_format}.  If the
2799 @code{format_arg} attribute had not been specified, all the compiler
2800 could tell in such calls to format functions would be that the format
2801 string argument is not constant; this would generate a warning when
2802 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2803 without the attribute.
2804
2805 The parameter @var{string-index} specifies which argument is the format
2806 string argument (starting from one).  Since non-static C++ methods have
2807 an implicit @code{this} argument, the arguments of such methods should
2808 be counted from two.
2809
2810 The @code{format_arg} attribute allows you to identify your own
2811 functions that modify format strings, so that GCC can check the
2812 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2813 type function whose operands are a call to one of your own function.
2814 The compiler always treats @code{gettext}, @code{dgettext}, and
2815 @code{dcgettext} in this manner except when strict ISO C support is
2816 requested by @option{-ansi} or an appropriate @option{-std} option, or
2817 @option{-ffreestanding} or @option{-fno-builtin}
2818 is used.  @xref{C Dialect Options,,Options
2819 Controlling C Dialect}.
2820
2821 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2822 @code{NSString} reference for compatibility with the @code{format} attribute
2823 above.
2824
2825 The target may also allow additional types in @code{format-arg} attributes.
2826 @xref{Target Format Checks,,Format Checks Specific to Particular
2827 Target Machines}.
2828
2829 @item function_vector
2830 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2831 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2832 function should be called through the function vector.  Calling a
2833 function through the function vector reduces code size, however;
2834 the function vector has a limited size (maximum 128 entries on the H8/300
2835 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2836
2837 On SH2A targets, this attribute declares a function to be called using the
2838 TBR relative addressing mode.  The argument to this attribute is the entry
2839 number of the same function in a vector table containing all the TBR
2840 relative addressable functions.  For correct operation the TBR must be setup
2841 accordingly to point to the start of the vector table before any functions with
2842 this attribute are invoked.  Usually a good place to do the initialization is
2843 the startup routine.  The TBR relative vector table can have at max 256 function
2844 entries.  The jumps to these functions are generated using a SH2A specific,
2845 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
2846 from GNU binutils version 2.7 or later for this attribute to work correctly.
2847
2848 Please refer the example of M16C target, to see the use of this
2849 attribute while declaring a function,
2850
2851 In an application, for a function being called once, this attribute
2852 saves at least 8 bytes of code; and if other successive calls are being
2853 made to the same function, it saves 2 bytes of code per each of these
2854 calls.
2855
2856 On M16C/M32C targets, the @code{function_vector} attribute declares a
2857 special page subroutine call function. Use of this attribute reduces
2858 the code size by 2 bytes for each call generated to the
2859 subroutine. The argument to the attribute is the vector number entry
2860 from the special page vector table which contains the 16 low-order
2861 bits of the subroutine's entry address. Each vector table has special
2862 page number (18 to 255) that is used in @code{jsrs} instructions.
2863 Jump addresses of the routines are generated by adding 0x0F0000 (in
2864 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2865 2-byte addresses set in the vector table. Therefore you need to ensure
2866 that all the special page vector routines should get mapped within the
2867 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2868 (for M32C).
2869
2870 In the following example 2 bytes are saved for each call to
2871 function @code{foo}.
2872
2873 @smallexample
2874 void foo (void) __attribute__((function_vector(0x18)));
2875 void foo (void)
2876 @{
2877 @}
2878
2879 void bar (void)
2880 @{
2881     foo();
2882 @}
2883 @end smallexample
2884
2885 If functions are defined in one file and are called in another file,
2886 then be sure to write this declaration in both files.
2887
2888 This attribute is ignored for R8C target.
2889
2890 @item ifunc ("@var{resolver}")
2891 @cindex @code{ifunc} attribute
2892 The @code{ifunc} attribute is used to mark a function as an indirect
2893 function using the STT_GNU_IFUNC symbol type extension to the ELF
2894 standard.  This allows the resolution of the symbol value to be
2895 determined dynamically at load time, and an optimized version of the
2896 routine can be selected for the particular processor or other system
2897 characteristics determined then.  To use this attribute, first define
2898 the implementation functions available, and a resolver function that
2899 returns a pointer to the selected implementation function.  The
2900 implementation functions' declarations must match the API of the
2901 function being implemented, the resolver's declaration is be a
2902 function returning pointer to void function returning void:
2903
2904 @smallexample
2905 void *my_memcpy (void *dst, const void *src, size_t len)
2906 @{
2907   @dots{}
2908 @}
2909
2910 static void (*resolve_memcpy (void)) (void)
2911 @{
2912   return my_memcpy; // we'll just always select this routine
2913 @}
2914 @end smallexample
2915
2916 @noindent
2917 The exported header file declaring the function the user calls would
2918 contain:
2919
2920 @smallexample
2921 extern void *memcpy (void *, const void *, size_t);
2922 @end smallexample
2923
2924 @noindent
2925 allowing the user to call this as a regular function, unaware of the
2926 implementation.  Finally, the indirect function needs to be defined in
2927 the same translation unit as the resolver function:
2928
2929 @smallexample
2930 void *memcpy (void *, const void *, size_t)
2931      __attribute__ ((ifunc ("resolve_memcpy")));
2932 @end smallexample
2933
2934 Indirect functions cannot be weak, and require a recent binutils (at
2935 least version 2.20.1), and GNU C library (at least version 2.11.1).
2936
2937 @item interrupt
2938 @cindex interrupt handler functions
2939 Use this attribute on the ARC, ARM, AVR, CR16, Epiphany, M32C, M32R/D,
2940 m68k, MeP, MIPS, MSP430, RL78, RX, Visium and Xstormy16 ports to indicate
2941 that the specified function is an interrupt handler.  The compiler generates
2942 function entry and exit sequences suitable for use in an interrupt handler
2943 when this attribute is present.  With Epiphany targets it may also generate
2944 a special section with code to initialize the interrupt vector table.
2945
2946 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2947 and SH processors can be specified via the @code{interrupt_handler} attribute.
2948
2949 Note, on the ARC, you must specify the kind of interrupt to be handled
2950 in a parameter to the interrupt attribute like this:
2951
2952 @smallexample
2953 void f () __attribute__ ((interrupt ("ilink1")));
2954 @end smallexample
2955
2956 Permissible values for this parameter are: @w{@code{ilink1}} and
2957 @w{@code{ilink2}}.
2958
2959 Note, on the AVR, the hardware globally disables interrupts when an
2960 interrupt is executed.  The first instruction of an interrupt handler
2961 declared with this attribute is a @code{SEI} instruction to
2962 re-enable interrupts.  See also the @code{signal} function attribute
2963 that does not insert a @code{SEI} instruction.  If both @code{signal} and
2964 @code{interrupt} are specified for the same function, @code{signal}
2965 is silently ignored.
2966
2967 Note, for the ARM, you can specify the kind of interrupt to be handled by
2968 adding an optional parameter to the interrupt attribute like this:
2969
2970 @smallexample
2971 void f () __attribute__ ((interrupt ("IRQ")));
2972 @end smallexample
2973
2974 @noindent
2975 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2976 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2977
2978 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2979 may be called with a word-aligned stack pointer.
2980
2981 Note, for the MSP430 you can provide an argument to the interrupt
2982 attribute which specifies a name or number.  If the argument is a
2983 number it indicates the slot in the interrupt vector table (0 - 31) to
2984 which this handler should be assigned.  If the argument is a name it
2985 is treated as a symbolic name for the vector slot.  These names should
2986 match up with appropriate entries in the linker script.  By default
2987 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
2988 @code{reset} for vector 31 are recognised.
2989
2990 You can also use the following function attributes to modify how
2991 normal functions interact with interrupt functions:
2992
2993 @table @code
2994 @item critical
2995 @cindex @code{critical} attribute
2996 Critical functions disable interrupts upon entry and restore the
2997 previous interrupt state upon exit.  Critical functions cannot also
2998 have the @code{naked} or @code{reentrant} attributes.  They can have
2999 the @code{interrupt} attribute.
3000
3001 @item reentrant
3002 @cindex @code{reentrant} attribute
3003 Reentrant functions disable interrupts upon entry and enable them
3004 upon exit.  Reentrant functions cannot also have the @code{naked}
3005 or @code{critical} attributes.  They can have the @code{interrupt}
3006 attribute.
3007
3008 @item wakeup
3009 @cindex @code{wakeup} attribute
3010 This attribute only applies to interrupt functions.  It is silently
3011 ignored if applied to a non-interrupt function.  A wakeup interrupt
3012 function will rouse the processor from any low-power state that it
3013 might be in when the function exits.
3014
3015 @end table
3016
3017 On Epiphany targets one or more optional parameters can be added like this:
3018
3019 @smallexample
3020 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3021 @end smallexample
3022
3023 Permissible values for these parameters are: @w{@code{reset}},
3024 @w{@code{software_exception}}, @w{@code{page_miss}},
3025 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3026 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3027 Multiple parameters indicate that multiple entries in the interrupt
3028 vector table should be initialized for this function, i.e.@: for each
3029 parameter @w{@var{name}}, a jump to the function is emitted in
3030 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
3031 entirely, in which case no interrupt vector table entry is provided.
3032
3033 Note, on Epiphany targets, interrupts are enabled inside the function
3034 unless the @code{disinterrupt} attribute is also specified.
3035
3036 On Epiphany targets, you can also use the following attribute to
3037 modify the behavior of an interrupt handler:
3038 @table @code
3039 @item forwarder_section
3040 @cindex @code{forwarder_section} attribute
3041 The interrupt handler may be in external memory which cannot be
3042 reached by a branch instruction, so generate a local memory trampoline
3043 to transfer control.  The single parameter identifies the section where
3044 the trampoline is placed.
3045 @end table
3046
3047 The following examples are all valid uses of these attributes on
3048 Epiphany targets:
3049 @smallexample
3050 void __attribute__ ((interrupt)) universal_handler ();
3051 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3052 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3053 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3054   fast_timer_handler ();
3055 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
3056   external_dma_handler ();
3057 @end smallexample
3058
3059 On MIPS targets, you can use the following attributes to modify the behavior
3060 of an interrupt handler:
3061 @table @code
3062 @item use_shadow_register_set
3063 @cindex @code{use_shadow_register_set} attribute
3064 Assume that the handler uses a shadow register set, instead of
3065 the main general-purpose registers.
3066
3067 @item keep_interrupts_masked
3068 @cindex @code{keep_interrupts_masked} attribute
3069 Keep interrupts masked for the whole function.  Without this attribute,
3070 GCC tries to reenable interrupts for as much of the function as it can.
3071
3072 @item use_debug_exception_return
3073 @cindex @code{use_debug_exception_return} attribute
3074 Return using the @code{deret} instruction.  Interrupt handlers that don't
3075 have this attribute return using @code{eret} instead.
3076 @end table
3077
3078 You can use any combination of these attributes, as shown below:
3079 @smallexample
3080 void __attribute__ ((interrupt)) v0 ();
3081 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
3082 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
3083 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
3084 void __attribute__ ((interrupt, use_shadow_register_set,
3085                      keep_interrupts_masked)) v4 ();
3086 void __attribute__ ((interrupt, use_shadow_register_set,
3087                      use_debug_exception_return)) v5 ();
3088 void __attribute__ ((interrupt, keep_interrupts_masked,
3089                      use_debug_exception_return)) v6 ();
3090 void __attribute__ ((interrupt, use_shadow_register_set,
3091                      keep_interrupts_masked,
3092                      use_debug_exception_return)) v7 ();
3093 @end smallexample
3094
3095 On NDS32 target, this attribute is to indicate that the specified function
3096 is an interrupt handler.  The compiler will generate corresponding sections
3097 for use in an interrupt handler.  You can use the following attributes
3098 to modify the behavior:
3099 @table @code
3100 @item nested
3101 @cindex @code{nested} attribute
3102 This interrupt service routine is interruptible.
3103 @item not_nested
3104 @cindex @code{not_nested} attribute
3105 This interrupt service routine is not interruptible.
3106 @item nested_ready
3107 @cindex @code{nested_ready} attribute
3108 This interrupt service routine is interruptible after @code{PSW.GIE}
3109 (global interrupt enable) is set.  This allows interrupt service routine to
3110 finish some short critical code before enabling interrupts.
3111 @item save_all
3112 @cindex @code{save_all} attribute
3113 The system will help save all registers into stack before entering
3114 interrupt handler.
3115 @item partial_save
3116 @cindex @code{partial_save} attribute
3117 The system will help save caller registers into stack before entering
3118 interrupt handler.
3119 @end table
3120
3121 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
3122 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
3123 that must end with @code{RETB} instead of @code{RETI}).
3124
3125 On RX targets, you may specify one or more vector numbers as arguments
3126 to the attribute, as well as naming an alternate table name.
3127 Parameters are handled sequentially, so one handler can be assigned to
3128 multiple entries in multiple tables.  One may also pass the magic
3129 string @code{"$default"} which causes the function to be used for any
3130 unfilled slots in the current table.
3131
3132 This example shows a simple assignment of a function to one vector in
3133 the default table (note that preprocessor macros may be used for
3134 chip-specific symbolic vector names):
3135 @smallexample
3136 void __attribute__ ((interrupt (5))) txd1_handler ();
3137 @end smallexample
3138
3139 This example assigns a function to two slots in the default table
3140 (using preprocessor macros defined elsewhere) and makes it the default
3141 for the @code{dct} table:
3142 @smallexample
3143 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
3144         txd1_handler ();
3145 @end smallexample
3146
3147 @item interrupt_handler
3148 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
3149 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
3150 indicate that the specified function is an interrupt handler.  The compiler
3151 generates function entry and exit sequences suitable for use in an
3152 interrupt handler when this attribute is present.
3153
3154 @item interrupt_thread
3155 @cindex interrupt thread functions on fido
3156 Use this attribute on fido, a subarchitecture of the m68k, to indicate
3157 that the specified function is an interrupt handler that is designed
3158 to run as a thread.  The compiler omits generate prologue/epilogue
3159 sequences and replaces the return instruction with a @code{sleep}
3160 instruction.  This attribute is available only on fido.
3161
3162 @item isr
3163 @cindex interrupt service routines on ARM
3164 Use this attribute on ARM to write Interrupt Service Routines. This is an
3165 alias to the @code{interrupt} attribute above.
3166
3167 @item kspisusp
3168 @cindex User stack pointer in interrupts on the Blackfin
3169 When used together with @code{interrupt_handler}, @code{exception_handler}
3170 or @code{nmi_handler}, code is generated to load the stack pointer
3171 from the USP register in the function prologue.
3172
3173 @item l1_text
3174 @cindex @code{l1_text} function attribute
3175 This attribute specifies a function to be placed into L1 Instruction
3176 SRAM@. The function is put into a specific section named @code{.l1.text}.
3177 With @option{-mfdpic}, function calls with a such function as the callee
3178 or caller uses inlined PLT.
3179
3180 @item l2
3181 @cindex @code{l2} function attribute
3182 On the Blackfin, this attribute specifies a function to be placed into L2
3183 SRAM. The function is put into a specific section named
3184 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
3185 an inlined PLT.
3186
3187 @item leaf
3188 @cindex @code{leaf} function attribute
3189 Calls to external functions with this attribute must return to the current
3190 compilation unit only by return or by exception handling.  In particular, leaf
3191 functions are not allowed to call callback function passed to it from the current
3192 compilation unit or directly call functions exported by the unit or longjmp
3193 into the unit.  Leaf function might still call functions from other compilation
3194 units and thus they are not necessarily leaf in the sense that they contain no
3195 function calls at all.
3196
3197 The attribute is intended for library functions to improve dataflow analysis.
3198 The compiler takes the hint that any data not escaping the current compilation unit can
3199 not be used or modified by the leaf function.  For example, the @code{sin} function
3200 is a leaf function, but @code{qsort} is not.
3201
3202 Note that leaf functions might invoke signals and signal handlers might be
3203 defined in the current compilation unit and use static variables.  The only
3204 compliant way to write such a signal handler is to declare such variables
3205 @code{volatile}.
3206
3207 The attribute has no effect on functions defined within the current compilation
3208 unit.  This is to allow easy merging of multiple compilation units into one,
3209 for example, by using the link-time optimization.  For this reason the
3210 attribute is not allowed on types to annotate indirect calls.
3211
3212 @item long_call/medium_call/short_call
3213 @cindex indirect calls on ARC
3214 @cindex indirect calls on ARM
3215 @cindex indirect calls on Epiphany
3216 These attributes specify how a particular function is called on
3217 ARC, ARM and Epiphany - with @code{medium_call} being specific to ARC.
3218 These attributes override the
3219 @option{-mlong-calls} (@pxref{ARM Options} and @ref{ARC Options})
3220 and @option{-mmedium-calls} (@pxref{ARC Options})
3221 command-line switches and @code{#pragma long_calls} settings.  For ARM, the
3222 @code{long_call} attribute indicates that the function might be far
3223 away from the call site and require a different (more expensive)
3224 calling sequence.   The @code{short_call} attribute always places
3225 the offset to the function from the call site into the @samp{BL}
3226 instruction directly.
3227
3228 For ARC, a function marked with the @code{long_call} attribute is
3229 always called using register-indirect jump-and-link instructions,
3230 thereby enabling the called function to be placed anywhere within the
3231 32-bit address space.  A function marked with the @code{medium_call}
3232 attribute will always be close enough to be called with an unconditional
3233 branch-and-link instruction, which has a 25-bit offset from
3234 the call site.  A function marked with the @code{short_call}
3235 attribute will always be close enough to be called with a conditional
3236 branch-and-link instruction, which has a 21-bit offset from
3237 the call site.
3238
3239 @item longcall/shortcall
3240 @cindex functions called via pointer on the RS/6000 and PowerPC
3241 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3242 indicates that the function might be far away from the call site and
3243 require a different (more expensive) calling sequence.  The
3244 @code{shortcall} attribute indicates that the function is always close
3245 enough for the shorter calling sequence to be used.  These attributes
3246 override both the @option{-mlongcall} switch and, on the RS/6000 and
3247 PowerPC, the @code{#pragma longcall} setting.
3248
3249 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3250 calls are necessary.
3251
3252 @item long_call/near/far
3253 @cindex indirect calls on MIPS
3254 These attributes specify how a particular function is called on MIPS@.
3255 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3256 command-line switch.  The @code{long_call} and @code{far} attributes are
3257 synonyms, and cause the compiler to always call
3258 the function by first loading its address into a register, and then using
3259 the contents of that register.  The @code{near} attribute has the opposite
3260 effect; it specifies that non-PIC calls should be made using the more
3261 efficient @code{jal} instruction.
3262
3263 @item malloc
3264 @cindex @code{malloc} attribute
3265 This tells the compiler that a function is @code{malloc}-like, i.e.,
3266 that the pointer @var{P} returned by the function cannot alias any
3267 other pointer valid when the function returns, and moreover no
3268 pointers to valid objects occur in any storage addressed by @var{P}.
3269
3270 Using this attribute can improve optimization.  Functions like
3271 @code{malloc} and @code{calloc} have this property because they return
3272 a pointer to uninitialized or zeroed-out storage.  However, functions
3273 like @code{realloc} do not have this property, as they can return a
3274 pointer to storage containing pointers.
3275
3276 @item mips16/nomips16
3277 @cindex @code{mips16} attribute
3278 @cindex @code{nomips16} attribute
3279
3280 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3281 function attributes to locally select or turn off MIPS16 code generation.
3282 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3283 while MIPS16 code generation is disabled for functions with the
3284 @code{nomips16} attribute.  These attributes override the
3285 @option{-mips16} and @option{-mno-mips16} options on the command line
3286 (@pxref{MIPS Options}).
3287
3288 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3289 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3290 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
3291 may interact badly with some GCC extensions such as @code{__builtin_apply}
3292 (@pxref{Constructing Calls}).
3293
3294 @item micromips/nomicromips
3295 @cindex @code{micromips} attribute
3296 @cindex @code{nomicromips} attribute
3297
3298 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3299 function attributes to locally select or turn off microMIPS code generation.
3300 A function with the @code{micromips} attribute is emitted as microMIPS code,
3301 while microMIPS code generation is disabled for functions with the
3302 @code{nomicromips} attribute.  These attributes override the
3303 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3304 (@pxref{MIPS Options}).
3305
3306 When compiling files containing mixed microMIPS and non-microMIPS code, the
3307 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3308 command line,
3309 not that within individual functions.  Mixed microMIPS and non-microMIPS code
3310 may interact badly with some GCC extensions such as @code{__builtin_apply}
3311 (@pxref{Constructing Calls}).
3312
3313 @item model (@var{model-name})
3314 @cindex function addressability on the M32R/D
3315 @cindex variable addressability on the IA-64
3316
3317 On the M32R/D, use this attribute to set the addressability of an
3318 object, and of the code generated for a function.  The identifier
3319 @var{model-name} is one of @code{small}, @code{medium}, or
3320 @code{large}, representing each of the code models.
3321
3322 Small model objects live in the lower 16MB of memory (so that their
3323 addresses can be loaded with the @code{ld24} instruction), and are
3324 callable with the @code{bl} instruction.
3325
3326 Medium model objects may live anywhere in the 32-bit address space (the
3327 compiler generates @code{seth/add3} instructions to load their addresses),
3328 and are callable with the @code{bl} instruction.
3329
3330 Large model objects may live anywhere in the 32-bit address space (the
3331 compiler generates @code{seth/add3} instructions to load their addresses),
3332 and may not be reachable with the @code{bl} instruction (the compiler
3333 generates the much slower @code{seth/add3/jl} instruction sequence).
3334
3335 On IA-64, use this attribute to set the addressability of an object.
3336 At present, the only supported identifier for @var{model-name} is
3337 @code{small}, indicating addressability via ``small'' (22-bit)
3338 addresses (so that their addresses can be loaded with the @code{addl}
3339 instruction).  Caveat: such addressing is by definition not position
3340 independent and hence this attribute must not be used for objects
3341 defined by shared libraries.
3342
3343 @item ms_abi/sysv_abi
3344 @cindex @code{ms_abi} attribute
3345 @cindex @code{sysv_abi} attribute
3346
3347 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
3348 to indicate which calling convention should be used for a function.  The
3349 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3350 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3351 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
3352 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
3353
3354 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3355 requires the @option{-maccumulate-outgoing-args} option.
3356
3357 @item callee_pop_aggregate_return (@var{number})
3358 @cindex @code{callee_pop_aggregate_return} attribute
3359
3360 On x86-32 targets, you can use this attribute to control how
3361 aggregates are returned in memory.  If the caller is responsible for
3362 popping the hidden pointer together with the rest of the arguments, specify
3363 @var{number} equal to zero.  If callee is responsible for popping the
3364 hidden pointer, specify @var{number} equal to one.  
3365
3366 The default x86-32 ABI assumes that the callee pops the
3367 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
3368 the compiler assumes that the
3369 caller pops the stack for hidden pointer.
3370
3371 @item ms_hook_prologue
3372 @cindex @code{ms_hook_prologue} attribute
3373
3374 On 32-bit and 64-bit x86 targets, you can use
3375 this function attribute to make GCC generate the ``hot-patching'' function
3376 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3377 and newer.
3378
3379 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
3380 @cindex @code{hotpatch} attribute
3381
3382 On S/390 System z targets, you can use this function attribute to
3383 make GCC generate a ``hot-patching'' function prologue.  If the
3384 @option{-mhotpatch=} command-line option is used at the same time,
3385 the @code{hotpatch} attribute takes precedence.  The first of the
3386 two arguments specifies the number of halfwords to be added before
3387 the function label.  A second argument can be used to specify the
3388 number of halfwords to be added after the function label.  For
3389 both arguments the maximum allowed value is 1000000.
3390
3391 If both ar guments are zero, hotpatching is disabled.
3392
3393 @item naked
3394 @cindex function without a prologue/epilogue code
3395 This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
3396 RL78, RX and SPU ports.  It allows the compiler to construct the
3397 requisite function declaration, while allowing the body of the
3398 function to be assembly code. The specified function will not have
3399 prologue/epilogue sequences generated by the compiler. Only Basic
3400 @code{asm} statements can safely be included in naked functions
3401 (@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
3402 Basic @code{asm} and ``C'' code may appear to work, they cannot be
3403 depended upon to work reliably and are not supported.
3404
3405 @item near
3406 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3407 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3408 use the normal calling convention based on @code{jsr} and @code{rts}.
3409 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3410 option.
3411
3412 On MeP targets this attribute causes the compiler to assume the called
3413 function is close enough to use the normal calling convention,
3414 overriding the @option{-mtf} command-line option.
3415
3416 @item nesting
3417 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3418 Use this attribute together with @code{interrupt_handler},
3419 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3420 entry code should enable nested interrupts or exceptions.
3421
3422 @item nmi_handler
3423 @cindex NMI handler functions on the Blackfin processor
3424 Use this attribute on the Blackfin to indicate that the specified function
3425 is an NMI handler.  The compiler generates function entry and
3426 exit sequences suitable for use in an NMI handler when this
3427 attribute is present.
3428
3429 @item nocompression
3430 @cindex @code{nocompression} attribute
3431 On MIPS targets, you can use the @code{nocompression} function attribute
3432 to locally turn off MIPS16 and microMIPS code generation.  This attribute
3433 overrides the @option{-mips16} and @option{-mmicromips} options on the
3434 command line (@pxref{MIPS Options}).
3435
3436 @item no_instrument_function
3437 @cindex @code{no_instrument_function} function attribute
3438 @opindex finstrument-functions
3439 If @option{-finstrument-functions} is given, profiling function calls are
3440 generated at entry and exit of most user-compiled functions.
3441 Functions with this attribute are not so instrumented.
3442
3443 @item no_split_stack
3444 @cindex @code{no_split_stack} function attribute
3445 @opindex fsplit-stack
3446 If @option{-fsplit-stack} is given, functions have a small
3447 prologue which decides whether to split the stack.  Functions with the
3448 @code{no_split_stack} attribute do not have that prologue, and thus
3449 may run with only a small amount of stack space available.
3450
3451 @item stack_protect
3452 @cindex @code{stack_protect} function attribute
3453 This function attribute make a stack protection of the function if 
3454 flags @option{fstack-protector} or @option{fstack-protector-strong}
3455 or @option{fstack-protector-explicit} are set.
3456
3457 @item noinline
3458 @cindex @code{noinline} function attribute
3459 This function attribute prevents a function from being considered for
3460 inlining.
3461 @c Don't enumerate the optimizations by name here; we try to be
3462 @c future-compatible with this mechanism.
3463 If the function does not have side-effects, there are optimizations
3464 other than inlining that cause function calls to be optimized away,
3465 although the function call is live.  To keep such calls from being
3466 optimized away, put
3467 @smallexample
3468 asm ("");
3469 @end smallexample
3470
3471 @noindent
3472 (@pxref{Extended Asm}) in the called function, to serve as a special
3473 side-effect.
3474
3475 @item noclone
3476 @cindex @code{noclone} function attribute
3477 This function attribute prevents a function from being considered for
3478 cloning---a mechanism that produces specialized copies of functions
3479 and which is (currently) performed by interprocedural constant
3480 propagation.
3481
3482 @item no_icf
3483 @cindex @code{no_icf} function attribute
3484 This function attribute prevents a functions from being merged with another
3485 semantically equivalent function.
3486
3487 @item nonnull (@var{arg-index}, @dots{})
3488 @cindex @code{nonnull} function attribute
3489 The @code{nonnull} attribute specifies that some function parameters should
3490 be non-null pointers.  For instance, the declaration:
3491
3492 @smallexample
3493 extern void *
3494 my_memcpy (void *dest, const void *src, size_t len)
3495         __attribute__((nonnull (1, 2)));
3496 @end smallexample
3497
3498 @noindent
3499 causes the compiler to check that, in calls to @code{my_memcpy},
3500 arguments @var{dest} and @var{src} are non-null.  If the compiler
3501 determines that a null pointer is passed in an argument slot marked
3502 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3503 is issued.  The compiler may also choose to make optimizations based
3504 on the knowledge that certain function arguments will never be null.
3505
3506 If no argument index list is given to the @code{nonnull} attribute,
3507 all pointer arguments are marked as non-null.  To illustrate, the
3508 following declaration is equivalent to the previous example:
3509
3510 @smallexample
3511 extern void *
3512 my_memcpy (void *dest, const void *src, size_t len)
3513         __attribute__((nonnull));
3514 @end smallexample
3515
3516 @item no_reorder
3517 @cindex @code{no_reorder} function or variable attribute
3518 Do not reorder functions or variables marked @code{no_reorder}
3519 against each other or top level assembler statements the executable.
3520 The actual order in the program will depend on the linker command
3521 line. Static variables marked like this are also not removed.
3522 This has a similar effect
3523 as the @option{-fno-toplevel-reorder} option, but only applies to the
3524 marked symbols.
3525
3526 @item returns_nonnull
3527 @cindex @code{returns_nonnull} function attribute
3528 The @code{returns_nonnull} attribute specifies that the function
3529 return value should be a non-null pointer.  For instance, the declaration:
3530
3531 @smallexample
3532 extern void *
3533 mymalloc (size_t len) __attribute__((returns_nonnull));
3534 @end smallexample
3535
3536 @noindent
3537 lets the compiler optimize callers based on the knowledge
3538 that the return value will never be null.
3539
3540 @item noreturn
3541 @cindex @code{noreturn} function attribute
3542 A few standard library functions, such as @code{abort} and @code{exit},
3543 cannot return.  GCC knows this automatically.  Some programs define
3544 their own functions that never return.  You can declare them
3545 @code{noreturn} to tell the compiler this fact.  For example,
3546
3547 @smallexample
3548 @group
3549 void fatal () __attribute__ ((noreturn));
3550
3551 void
3552 fatal (/* @r{@dots{}} */)
3553 @{
3554   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3555   exit (1);
3556 @}
3557 @end group
3558 @end smallexample
3559
3560 The @code{noreturn} keyword tells the compiler to assume that
3561 @code{fatal} cannot return.  It can then optimize without regard to what
3562 would happen if @code{fatal} ever did return.  This makes slightly
3563 better code.  More importantly, it helps avoid spurious warnings of
3564 uninitialized variables.
3565
3566 The @code{noreturn} keyword does not affect the exceptional path when that
3567 applies: a @code{noreturn}-marked function may still return to the caller
3568 by throwing an exception or calling @code{longjmp}.
3569
3570 Do not assume that registers saved by the calling function are
3571 restored before calling the @code{noreturn} function.
3572
3573 It does not make sense for a @code{noreturn} function to have a return
3574 type other than @code{void}.
3575
3576 The attribute @code{noreturn} is not implemented in GCC versions
3577 earlier than 2.5.  An alternative way to declare that a function does
3578 not return, which works in the current version and in some older
3579 versions, is as follows:
3580
3581 @smallexample
3582 typedef void voidfn ();
3583
3584 volatile voidfn fatal;
3585 @end smallexample
3586
3587 @noindent
3588 This approach does not work in GNU C++.
3589
3590 @item nothrow
3591 @cindex @code{nothrow} function attribute
3592 The @code{nothrow} attribute is used to inform the compiler that a
3593 function cannot throw an exception.  For example, most functions in
3594 the standard C library can be guaranteed not to throw an exception
3595 with the notable exceptions of @code{qsort} and @code{bsearch} that
3596 take function pointer arguments.  The @code{nothrow} attribute is not
3597 implemented in GCC versions earlier than 3.3.
3598
3599 @item nosave_low_regs
3600 @cindex @code{nosave_low_regs} attribute
3601 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3602 function should not save and restore registers R0..R7.  This can be used on SH3*
3603 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3604 interrupt handlers.
3605
3606 @item optimize
3607 @cindex @code{optimize} function attribute
3608 The @code{optimize} attribute is used to specify that a function is to
3609 be compiled with different optimization options than specified on the
3610 command line.  Arguments can either be numbers or strings.  Numbers
3611 are assumed to be an optimization level.  Strings that begin with
3612 @code{O} are assumed to be an optimization option, while other options
3613 are assumed to be used with a @code{-f} prefix.  You can also use the
3614 @samp{#pragma GCC optimize} pragma to set the optimization options
3615 that affect more than one function.
3616 @xref{Function Specific Option Pragmas}, for details about the
3617 @samp{#pragma GCC optimize} pragma.
3618
3619 This can be used for instance to have frequently-executed functions
3620 compiled with more aggressive optimization options that produce faster
3621 and larger code, while other functions can be compiled with less
3622 aggressive options.
3623
3624 @item OS_main/OS_task
3625 @cindex @code{OS_main} AVR function attribute
3626 @cindex @code{OS_task} AVR function attribute
3627 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3628 do not save/restore any call-saved register in their prologue/epilogue.
3629
3630 The @code{OS_main} attribute can be used when there @emph{is
3631 guarantee} that interrupts are disabled at the time when the function
3632 is entered.  This saves resources when the stack pointer has to be
3633 changed to set up a frame for local variables.
3634
3635 The @code{OS_task} attribute can be used when there is @emph{no
3636 guarantee} that interrupts are disabled at that time when the function
3637 is entered like for, e@.g@. task functions in a multi-threading operating
3638 system. In that case, changing the stack pointer register is
3639 guarded by save/clear/restore of the global interrupt enable flag.
3640
3641 The differences to the @code{naked} function attribute are:
3642 @itemize @bullet
3643 @item @code{naked} functions do not have a return instruction whereas 
3644 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3645 @code{RETI} return instruction.
3646 @item @code{naked} functions do not set up a frame for local variables
3647 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3648 as needed.
3649 @end itemize
3650
3651 @item pcs
3652 @cindex @code{pcs} function attribute
3653
3654 The @code{pcs} attribute can be used to control the calling convention
3655 used for a function on ARM.  The attribute takes an argument that specifies
3656 the calling convention to use.
3657
3658 When compiling using the AAPCS ABI (or a variant of it) then valid
3659 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3660 order to use a variant other than @code{"aapcs"} then the compiler must
3661 be permitted to use the appropriate co-processor registers (i.e., the
3662 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3663 For example,
3664
3665 @smallexample
3666 /* Argument passed in r0, and result returned in r0+r1.  */
3667 double f2d (float) __attribute__((pcs("aapcs")));
3668 @end smallexample
3669
3670 Variadic functions always use the @code{"aapcs"} calling convention and
3671 the compiler rejects attempts to specify an alternative.
3672
3673 @item pure
3674 @cindex @code{pure} function attribute
3675 Many functions have no effects except the return value and their
3676 return value depends only on the parameters and/or global variables.
3677 Such a function can be subject
3678 to common subexpression elimination and loop optimization just as an
3679 arithmetic operator would be.  These functions should be declared
3680 with the attribute @code{pure}.  For example,
3681
3682 @smallexample
3683 int square (int) __attribute__ ((pure));
3684 @end smallexample
3685
3686 @noindent
3687 says that the hypothetical function @code{square} is safe to call
3688 fewer times than the program says.
3689
3690 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3691 Interesting non-pure functions are functions with infinite loops or those
3692 depending on volatile memory or other system resource, that may change between
3693 two consecutive calls (such as @code{feof} in a multithreading environment).
3694
3695 The attribute @code{pure} is not implemented in GCC versions earlier
3696 than 2.96.
3697
3698 @item hot
3699 @cindex @code{hot} function attribute
3700 The @code{hot} attribute on a function is used to inform the compiler that
3701 the function is a hot spot of the compiled program.  The function is
3702 optimized more aggressively and on many targets it is placed into a special
3703 subsection of the text section so all hot functions appear close together,
3704 improving locality.
3705
3706 When profile feedback is available, via @option{-fprofile-use}, hot functions
3707 are automatically detected and this attribute is ignored.
3708
3709 The @code{hot} attribute on functions is not implemented in GCC versions
3710 earlier than 4.3.
3711
3712 @item cold
3713 @cindex @code{cold} function attribute
3714 The @code{cold} attribute on functions is used to inform the compiler that
3715 the function is unlikely to be executed.  The function is optimized for
3716 size rather than speed and on many targets it is placed into a special
3717 subsection of the text section so all cold functions appear close together,
3718 improving code locality of non-cold parts of program.  The paths leading
3719 to calls of cold functions within code are marked as unlikely by the branch
3720 prediction mechanism.  It is thus useful to mark functions used to handle
3721 unlikely conditions, such as @code{perror}, as cold to improve optimization
3722 of hot functions that do call marked functions in rare occasions.
3723
3724 When profile feedback is available, via @option{-fprofile-use}, cold functions
3725 are automatically detected and this attribute is ignored.
3726
3727 The @code{cold} attribute on functions is not implemented in GCC versions
3728 earlier than 4.3.
3729
3730 @item no_sanitize_address
3731 @itemx no_address_safety_analysis
3732 @cindex @code{no_sanitize_address} function attribute
3733 The @code{no_sanitize_address} attribute on functions is used
3734 to inform the compiler that it should not instrument memory accesses
3735 in the function when compiling with the @option{-fsanitize=address} option.
3736 The @code{no_address_safety_analysis} is a deprecated alias of the
3737 @code{no_sanitize_address} attribute, new code should use
3738 @code{no_sanitize_address}.
3739
3740 @item no_sanitize_thread
3741 @cindex @code{no_sanitize_thread} function attribute
3742 The @code{no_sanitize_thread} attribute on functions is used
3743 to inform the compiler that it should not instrument memory accesses
3744 in the function when compiling with the @option{-fsanitize=thread} option.
3745
3746 @item no_sanitize_undefined
3747 @cindex @code{no_sanitize_undefined} function attribute
3748 The @code{no_sanitize_undefined} attribute on functions is used
3749 to inform the compiler that it should not check for undefined behavior
3750 in the function when compiling with the @option{-fsanitize=undefined} option.
3751
3752 @item bnd_legacy
3753 @cindex @code{bnd_legacy} function attribute
3754 The @code{bnd_legacy} attribute on functions is used to inform
3755 compiler that function should not be instrumented when compiled
3756 with @option{-fcheck-pointer-bounds} option.
3757
3758 @item bnd_instrument
3759 @cindex @code{bnd_instrument} function attribute
3760 The @code{bnd_instrument} attribute on functions is used to inform
3761 compiler that function should be instrumented when compiled
3762 with @option{-fchkp-instrument-marked-only} option.
3763
3764 @item regparm (@var{number})
3765 @cindex @code{regparm} attribute
3766 @cindex functions that are passed arguments in registers on x86-32
3767 On x86-32 targets, the @code{regparm} attribute causes the compiler to
3768 pass arguments number one to @var{number} if they are of integral type
3769 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
3770 take a variable number of arguments continue to be passed all of their
3771 arguments on the stack.
3772
3773 Beware that on some ELF systems this attribute is unsuitable for
3774 global functions in shared libraries with lazy binding (which is the
3775 default).  Lazy binding sends the first call via resolving code in
3776 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3777 per the standard calling conventions.  Solaris 8 is affected by this.
3778 Systems with the GNU C Library version 2.1 or higher
3779 and FreeBSD are believed to be
3780 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
3781 disabled with the linker or the loader if desired, to avoid the
3782 problem.)
3783
3784 @item reset
3785 @cindex reset handler functions
3786 Use this attribute on the NDS32 target to indicate that the specified function
3787 is a reset handler.  The compiler will generate corresponding sections
3788 for use in a reset handler.  You can use the following attributes
3789 to provide extra exception handling:
3790 @table @code
3791 @item nmi
3792 @cindex @code{nmi} attribute
3793 Provide a user-defined function to handle NMI exception.
3794 @item warm
3795 @cindex @code{warm} attribute
3796 Provide a user-defined function to handle warm reset exception.
3797 @end table
3798
3799 @item sseregparm
3800 @cindex @code{sseregparm} attribute
3801 On x86-32 targets with SSE support, the @code{sseregparm} attribute
3802 causes the compiler to pass up to 3 floating-point arguments in
3803 SSE registers instead of on the stack.  Functions that take a
3804 variable number of arguments continue to pass all of their
3805 floating-point arguments on the stack.
3806
3807 @item force_align_arg_pointer
3808 @cindex @code{force_align_arg_pointer} attribute
3809 On x86 targets, the @code{force_align_arg_pointer} attribute may be
3810 applied to individual function definitions, generating an alternate
3811 prologue and epilogue that realigns the run-time stack if necessary.
3812 This supports mixing legacy codes that run with a 4-byte aligned stack
3813 with modern codes that keep a 16-byte stack for SSE compatibility.
3814
3815 @item renesas
3816 @cindex @code{renesas} attribute
3817 On SH targets this attribute specifies that the function or struct follows the
3818 Renesas ABI.
3819
3820 @item resbank
3821 @cindex @code{resbank} attribute
3822 On the SH2A target, this attribute enables the high-speed register
3823 saving and restoration using a register bank for @code{interrupt_handler}
3824 routines.  Saving to the bank is performed automatically after the CPU
3825 accepts an interrupt that uses a register bank.
3826
3827 The nineteen 32-bit registers comprising general register R0 to R14,
3828 control register GBR, and system registers MACH, MACL, and PR and the
3829 vector table address offset are saved into a register bank.  Register
3830 banks are stacked in first-in last-out (FILO) sequence.  Restoration
3831 from the bank is executed by issuing a RESBANK instruction.
3832
3833 @item returns_twice
3834 @cindex @code{returns_twice} attribute
3835 The @code{returns_twice} attribute tells the compiler that a function may
3836 return more than one time.  The compiler ensures that all registers
3837 are dead before calling such a function and emits a warning about
3838 the variables that may be clobbered after the second return from the
3839 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3840 The @code{longjmp}-like counterpart of such function, if any, might need
3841 to be marked with the @code{noreturn} attribute.
3842
3843 @item saveall
3844 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3845 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3846 all registers except the stack pointer should be saved in the prologue
3847 regardless of whether they are used or not.
3848
3849 @item save_volatiles
3850 @cindex save volatile registers on the MicroBlaze
3851 Use this attribute on the MicroBlaze to indicate that the function is
3852 an interrupt handler.  All volatile registers (in addition to non-volatile
3853 registers) are saved in the function prologue.  If the function is a leaf
3854 function, only volatiles used by the function are saved.  A normal function
3855 return is generated instead of a return from interrupt.
3856
3857 @item break_handler
3858 @cindex break handler functions
3859 Use this attribute on the MicroBlaze ports to indicate that
3860 the specified function is an break handler.  The compiler generates function
3861 entry and exit sequences suitable for use in an break handler when this
3862 attribute is present. The return from @code{break_handler} is done through
3863 the @code{rtbd} instead of @code{rtsd}.
3864
3865 @smallexample
3866 void f () __attribute__ ((break_handler));
3867 @end smallexample
3868
3869 @item section ("@var{section-name}")
3870 @cindex @code{section} function attribute
3871 Normally, the compiler places the code it generates in the @code{text} section.
3872 Sometimes, however, you need additional sections, or you need certain
3873 particular functions to appear in special sections.  The @code{section}
3874 attribute specifies that a function lives in a particular section.
3875 For example, the declaration:
3876
3877 @smallexample
3878 extern void foobar (void) __attribute__ ((section ("bar")));
3879 @end smallexample
3880
3881 @noindent
3882 puts the function @code{foobar} in the @code{bar} section.
3883
3884 Some file formats do not support arbitrary sections so the @code{section}
3885 attribute is not available on all platforms.
3886 If you need to map the entire contents of a module to a particular
3887 section, consider using the facilities of the linker instead.
3888
3889 @item sentinel
3890 @cindex @code{sentinel} function attribute
3891 This function attribute ensures that a parameter in a function call is
3892 an explicit @code{NULL}.  The attribute is only valid on variadic
3893 functions.  By default, the sentinel is located at position zero, the
3894 last parameter of the function call.  If an optional integer position
3895 argument P is supplied to the attribute, the sentinel must be located at
3896 position P counting backwards from the end of the argument list.
3897
3898 @smallexample
3899 __attribute__ ((sentinel))
3900 is equivalent to
3901 __attribute__ ((sentinel(0)))
3902 @end smallexample
3903
3904 The attribute is automatically set with a position of 0 for the built-in
3905 functions @code{execl} and @code{execlp}.  The built-in function
3906 @code{execle} has the attribute set with a position of 1.
3907
3908 A valid @code{NULL} in this context is defined as zero with any pointer
3909 type.  If your system defines the @code{NULL} macro with an integer type
3910 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3911 with a copy that redefines NULL appropriately.
3912
3913 The warnings for missing or incorrect sentinels are enabled with
3914 @option{-Wformat}.
3915
3916 @item short_call
3917 See @code{long_call/short_call}.
3918
3919 @item shortcall
3920 See @code{longcall/shortcall}.
3921
3922 @item signal
3923 @cindex interrupt handler functions on the AVR processors
3924 Use this attribute on the AVR to indicate that the specified
3925 function is an interrupt handler.  The compiler generates function
3926 entry and exit sequences suitable for use in an interrupt handler when this
3927 attribute is present.
3928
3929 See also the @code{interrupt} function attribute. 
3930
3931 The AVR hardware globally disables interrupts when an interrupt is executed.
3932 Interrupt handler functions defined with the @code{signal} attribute
3933 do not re-enable interrupts.  It is save to enable interrupts in a
3934 @code{signal} handler.  This ``save'' only applies to the code
3935 generated by the compiler and not to the IRQ layout of the
3936 application which is responsibility of the application.
3937
3938 If both @code{signal} and @code{interrupt} are specified for the same
3939 function, @code{signal} is silently ignored.
3940
3941 @item sp_switch
3942 @cindex @code{sp_switch} attribute
3943 Use this attribute on the SH to indicate an @code{interrupt_handler}
3944 function should switch to an alternate stack.  It expects a string
3945 argument that names a global variable holding the address of the
3946 alternate stack.
3947
3948 @smallexample
3949 void *alt_stack;
3950 void f () __attribute__ ((interrupt_handler,
3951                           sp_switch ("alt_stack")));
3952 @end smallexample
3953
3954 @item stdcall
3955 @cindex functions that pop the argument stack on x86-32
3956 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
3957 assume that the called function pops off the stack space used to
3958 pass arguments, unless it takes a variable number of arguments.
3959
3960 @item syscall_linkage
3961 @cindex @code{syscall_linkage} attribute
3962 This attribute is used to modify the IA-64 calling convention by marking
3963 all input registers as live at all function exits.  This makes it possible
3964 to restart a system call after an interrupt without having to save/restore
3965 the input registers.  This also prevents kernel data from leaking into
3966 application code.
3967
3968 @item target
3969 @cindex @code{target} function attribute
3970 The @code{target} attribute is used to specify that a function is to
3971 be compiled with different target options than specified on the
3972 command line.  This can be used for instance to have functions
3973 compiled with a different ISA (instruction set architecture) than the
3974 default.  You can also use the @samp{#pragma GCC target} pragma to set
3975 more than one function to be compiled with specific target options.
3976 @xref{Function Specific Option Pragmas}, for details about the
3977 @samp{#pragma GCC target} pragma.
3978
3979 For instance on an x86, you could compile one function with
3980 @code{target("sse4.1,arch=core2")} and another with
3981 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3982 compiling the first function with @option{-msse4.1} and
3983 @option{-march=core2} options, and the second function with
3984 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to the
3985 user to make sure that a function is only invoked on a machine that
3986 supports the particular ISA it is compiled for (for example by using
3987 @code{cpuid} on x86 to determine what feature bits and architecture
3988 family are used).
3989
3990 @smallexample
3991 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3992 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3993 @end smallexample
3994
3995 You can either use multiple
3996 strings to specify multiple options, or separate the options
3997 with a comma (@samp{,}).
3998
3999 The @code{target} attribute is presently implemented for
4000 x86, PowerPC, and Nios II targets only.
4001 The options supported are specific to each target.
4002
4003 On the x86, the following options are allowed:
4004
4005 @table @samp
4006 @item abm
4007 @itemx no-abm
4008 @cindex @code{target("abm")} attribute
4009 Enable/disable the generation of the advanced bit instructions.
4010
4011 @item aes
4012 @itemx no-aes
4013 @cindex @code{target("aes")} attribute
4014 Enable/disable the generation of the AES instructions.
4015
4016 @item default
4017 @cindex @code{target("default")} attribute
4018 @xref{Function Multiversioning}, where it is used to specify the
4019 default function version.
4020
4021 @item mmx
4022 @itemx no-mmx
4023 @cindex @code{target("mmx")} attribute
4024 Enable/disable the generation of the MMX instructions.
4025
4026 @item pclmul
4027 @itemx no-pclmul
4028 @cindex @code{target("pclmul")} attribute
4029 Enable/disable the generation of the PCLMUL instructions.
4030
4031 @item popcnt
4032 @itemx no-popcnt
4033 @cindex @code{target("popcnt")} attribute
4034 Enable/disable the generation of the POPCNT instruction.
4035
4036 @item sse
4037 @itemx no-sse
4038 @cindex @code{target("sse")} attribute
4039 Enable/disable the generation of the SSE instructions.
4040
4041 @item sse2
4042 @itemx no-sse2
4043 @cindex @code{target("sse2")} attribute
4044 Enable/disable the generation of the SSE2 instructions.
4045
4046 @item sse3
4047 @itemx no-sse3
4048 @cindex @code{target("sse3")} attribute
4049 Enable/disable the generation of the SSE3 instructions.
4050
4051 @item sse4
4052 @itemx no-sse4
4053 @cindex @code{target("sse4")} attribute
4054 Enable/disable the generation of the SSE4 instructions (both SSE4.1
4055 and SSE4.2).
4056
4057 @item sse4.1
4058 @itemx no-sse4.1
4059 @cindex @code{target("sse4.1")} attribute
4060 Enable/disable the generation of the sse4.1 instructions.
4061
4062 @item sse4.2
4063 @itemx no-sse4.2
4064 @cindex @code{target("sse4.2")} attribute
4065 Enable/disable the generation of the sse4.2 instructions.
4066
4067 @item sse4a
4068 @itemx no-sse4a
4069 @cindex @code{target("sse4a")} attribute
4070 Enable/disable the generation of the SSE4A instructions.
4071
4072 @item fma4
4073 @itemx no-fma4
4074 @cindex @code{target("fma4")} attribute
4075 Enable/disable the generation of the FMA4 instructions.
4076
4077 @item xop
4078 @itemx no-xop
4079 @cindex @code{target("xop")} attribute
4080 Enable/disable the generation of the XOP instructions.
4081
4082 @item lwp
4083 @itemx no-lwp
4084 @cindex @code{target("lwp")} attribute
4085 Enable/disable the generation of the LWP instructions.
4086
4087 @item ssse3
4088 @itemx no-ssse3
4089 @cindex @code{target("ssse3")} attribute
4090 Enable/disable the generation of the SSSE3 instructions.
4091
4092 @item cld
4093 @itemx no-cld
4094 @cindex @code{target("cld")} attribute
4095 Enable/disable the generation of the CLD before string moves.
4096
4097 @item fancy-math-387
4098 @itemx no-fancy-math-387
4099 @cindex @code{target("fancy-math-387")} attribute
4100 Enable/disable the generation of the @code{sin}, @code{cos}, and
4101 @code{sqrt} instructions on the 387 floating-point unit.
4102
4103 @item fused-madd
4104 @itemx no-fused-madd
4105 @cindex @code{target("fused-madd")} attribute
4106 Enable/disable the generation of the fused multiply/add instructions.
4107
4108 @item ieee-fp
4109 @itemx no-ieee-fp
4110 @cindex @code{target("ieee-fp")} attribute
4111 Enable/disable the generation of floating point that depends on IEEE arithmetic.
4112
4113 @item inline-all-stringops
4114 @itemx no-inline-all-stringops
4115 @cindex @code{target("inline-all-stringops")} attribute
4116 Enable/disable inlining of string operations.
4117
4118 @item inline-stringops-dynamically
4119 @itemx no-inline-stringops-dynamically
4120 @cindex @code{target("inline-stringops-dynamically")} attribute
4121 Enable/disable the generation of the inline code to do small string
4122 operations and calling the library routines for large operations.
4123
4124 @item align-stringops
4125 @itemx no-align-stringops
4126 @cindex @code{target("align-stringops")} attribute
4127 Do/do not align destination of inlined string operations.
4128
4129 @item recip
4130 @itemx no-recip
4131 @cindex @code{target("recip")} attribute
4132 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
4133 instructions followed an additional Newton-Raphson step instead of
4134 doing a floating-point division.
4135
4136 @item arch=@var{ARCH}
4137 @cindex @code{target("arch=@var{ARCH}")} attribute
4138 Specify the architecture to generate code for in compiling the function.
4139
4140 @item tune=@var{TUNE}
4141 @cindex @code{target("tune=@var{TUNE}")} attribute
4142 Specify the architecture to tune for in compiling the function.
4143
4144 @item fpmath=@var{FPMATH}
4145 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
4146 Specify which floating-point unit to use.  The
4147 @code{target("fpmath=sse,387")} option must be specified as
4148 @code{target("fpmath=sse+387")} because the comma would separate
4149 different options.
4150 @end table
4151
4152 On the PowerPC, the following options are allowed:
4153
4154 @table @samp
4155 @item altivec
4156 @itemx no-altivec
4157 @cindex @code{target("altivec")} attribute
4158 Generate code that uses (does not use) AltiVec instructions.  In
4159 32-bit code, you cannot enable AltiVec instructions unless
4160 @option{-mabi=altivec} is used on the command line.
4161
4162 @item cmpb
4163 @itemx no-cmpb
4164 @cindex @code{target("cmpb")} attribute
4165 Generate code that uses (does not use) the compare bytes instruction
4166 implemented on the POWER6 processor and other processors that support
4167 the PowerPC V2.05 architecture.
4168
4169 @item dlmzb
4170 @itemx no-dlmzb
4171 @cindex @code{target("dlmzb")} attribute
4172 Generate code that uses (does not use) the string-search @samp{dlmzb}
4173 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4174 generated by default when targeting those processors.
4175
4176 @item fprnd
4177 @itemx no-fprnd
4178 @cindex @code{target("fprnd")} attribute
4179 Generate code that uses (does not use) the FP round to integer
4180 instructions implemented on the POWER5+ processor and other processors
4181 that support the PowerPC V2.03 architecture.
4182
4183 @item hard-dfp
4184 @itemx no-hard-dfp
4185 @cindex @code{target("hard-dfp")} attribute
4186 Generate code that uses (does not use) the decimal floating-point
4187 instructions implemented on some POWER processors.
4188
4189 @item isel
4190 @itemx no-isel
4191 @cindex @code{target("isel")} attribute
4192 Generate code that uses (does not use) ISEL instruction.
4193
4194 @item mfcrf
4195 @itemx no-mfcrf
4196 @cindex @code{target("mfcrf")} attribute
4197 Generate code that uses (does not use) the move from condition
4198 register field instruction implemented on the POWER4 processor and
4199 other processors that support the PowerPC V2.01 architecture.
4200
4201 @item mfpgpr
4202 @itemx no-mfpgpr
4203 @cindex @code{target("mfpgpr")} attribute
4204 Generate code that uses (does not use) the FP move to/from general
4205 purpose register instructions implemented on the POWER6X processor and
4206 other processors that support the extended PowerPC V2.05 architecture.
4207
4208 @item mulhw
4209 @itemx no-mulhw
4210 @cindex @code{target("mulhw")} attribute
4211 Generate code that uses (does not use) the half-word multiply and
4212 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4213 These instructions are generated by default when targeting those
4214 processors.
4215
4216 @item multiple
4217 @itemx no-multiple
4218 @cindex @code{target("multiple")} attribute
4219 Generate code that uses (does not use) the load multiple word
4220 instructions and the store multiple word instructions.
4221
4222 @item update
4223 @itemx no-update
4224 @cindex @code{target("update")} attribute
4225 Generate code that uses (does not use) the load or store instructions
4226 that update the base register to the address of the calculated memory
4227 location.
4228
4229 @item popcntb
4230 @itemx no-popcntb
4231 @cindex @code{target("popcntb")} attribute
4232 Generate code that uses (does not use) the popcount and double-precision
4233 FP reciprocal estimate instruction implemented on the POWER5
4234 processor and other processors that support the PowerPC V2.02
4235 architecture.
4236
4237 @item popcntd
4238 @itemx no-popcntd
4239 @cindex @code{target("popcntd")} attribute
4240 Generate code that uses (does not use) the popcount instruction
4241 implemented on the POWER7 processor and other processors that support
4242 the PowerPC V2.06 architecture.
4243
4244 @item powerpc-gfxopt
4245 @itemx no-powerpc-gfxopt
4246 @cindex @code{target("powerpc-gfxopt")} attribute
4247 Generate code that uses (does not use) the optional PowerPC
4248 architecture instructions in the Graphics group, including
4249 floating-point select.
4250
4251 @item powerpc-gpopt
4252 @itemx no-powerpc-gpopt
4253 @cindex @code{target("powerpc-gpopt")} attribute
4254 Generate code that uses (does not use) the optional PowerPC
4255 architecture instructions in the General Purpose group, including
4256 floating-point square root.
4257
4258 @item recip-precision
4259 @itemx no-recip-precision
4260 @cindex @code{target("recip-precision")} attribute
4261 Assume (do not assume) that the reciprocal estimate instructions
4262 provide higher-precision estimates than is mandated by the powerpc
4263 ABI.
4264
4265 @item string
4266 @itemx no-string
4267 @cindex @code{target("string")} attribute
4268 Generate code that uses (does not use) the load string instructions
4269 and the store string word instructions to save multiple registers and
4270 do small block moves.
4271
4272 @item vsx
4273 @itemx no-vsx
4274 @cindex @code{target("vsx")} attribute
4275 Generate code that uses (does not use) vector/scalar (VSX)
4276 instructions, and also enable the use of built-in functions that allow
4277 more direct access to the VSX instruction set.  In 32-bit code, you
4278 cannot enable VSX or AltiVec instructions unless
4279 @option{-mabi=altivec} is used on the command line.
4280
4281 @item friz
4282 @itemx no-friz
4283 @cindex @code{target("friz")} attribute
4284 Generate (do not generate) the @code{friz} instruction when the
4285 @option{-funsafe-math-optimizations} option is used to optimize
4286 rounding a floating-point value to 64-bit integer and back to floating
4287 point.  The @code{friz} instruction does not return the same value if
4288 the floating-point number is too large to fit in an integer.
4289
4290 @item avoid-indexed-addresses
4291 @itemx no-avoid-indexed-addresses
4292 @cindex @code{target("avoid-indexed-addresses")} attribute
4293 Generate code that tries to avoid (not avoid) the use of indexed load
4294 or store instructions.
4295
4296 @item paired
4297 @itemx no-paired
4298 @cindex @code{target("paired")} attribute
4299 Generate code that uses (does not use) the generation of PAIRED simd
4300 instructions.
4301
4302 @item longcall
4303 @itemx no-longcall
4304 @cindex @code{target("longcall")} attribute
4305 Generate code that assumes (does not assume) that all calls are far
4306 away so that a longer more expensive calling sequence is required.
4307
4308 @item cpu=@var{CPU}
4309 @cindex @code{target("cpu=@var{CPU}")} attribute
4310 Specify the architecture to generate code for when compiling the
4311 function.  If you select the @code{target("cpu=power7")} attribute when
4312 generating 32-bit code, VSX and AltiVec instructions are not generated
4313 unless you use the @option{-mabi=altivec} option on the command line.
4314
4315 @item tune=@var{TUNE}
4316 @cindex @code{target("tune=@var{TUNE}")} attribute
4317 Specify the architecture to tune for when compiling the function.  If
4318 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4319 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4320 compilation tunes for the @var{CPU} architecture, and not the
4321 default tuning specified on the command line.
4322 @end table
4323
4324 When compiling for Nios II, the following options are allowed:
4325
4326 @table @samp
4327 @item custom-@var{insn}=@var{N}
4328 @itemx no-custom-@var{insn}
4329 @cindex @code{target("custom-@var{insn}=@var{N}")} attribute
4330 @cindex @code{target("no-custom-@var{insn}")} attribute
4331 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4332 custom instruction with encoding @var{N} when generating code that uses 
4333 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4334 the custom instruction @var{insn}.
4335 These target attributes correspond to the
4336 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4337 command-line options, and support the same set of @var{insn} keywords.
4338 @xref{Nios II Options}, for more information.
4339
4340 @item custom-fpu-cfg=@var{name}
4341 @cindex @code{target("custom-fpu-cfg=@var{name}")} attribute
4342 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4343 command-line option, to select a predefined set of custom instructions
4344 named @var{name}.
4345 @xref{Nios II Options}, for more information.
4346 @end table
4347
4348 On the x86 and PowerPC back ends, the inliner does not inline a
4349 function that has different target options than the caller, unless the
4350 callee has a subset of the target options of the caller.  For example
4351 a function declared with @code{target("sse3")} can inline a function
4352 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4353
4354 @item tiny_data
4355 @cindex tiny data section on the H8/300H and H8S
4356 Use this attribute on the H8/300H and H8S to indicate that the specified
4357 variable should be placed into the tiny data section.
4358 The compiler generates more efficient code for loads and stores
4359 on data in the tiny data section.  Note the tiny data area is limited to
4360 slightly under 32KB of data.
4361
4362 @item trap_exit
4363 @cindex @code{trap_exit} attribute
4364 Use this attribute on the SH for an @code{interrupt_handler} to return using
4365 @code{trapa} instead of @code{rte}.  This attribute expects an integer
4366 argument specifying the trap number to be used.
4367
4368 @item trapa_handler
4369 @cindex @code{trapa_handler} attribute
4370 On SH targets this function attribute is similar to @code{interrupt_handler}
4371 but it does not save and restore all registers.
4372
4373 @item unused
4374 @cindex @code{unused} attribute.
4375 This attribute, attached to a function, means that the function is meant
4376 to be possibly unused.  GCC does not produce a warning for this
4377 function.
4378
4379 @item used
4380 @cindex @code{used} attribute.
4381 This attribute, attached to a function, means that code must be emitted
4382 for the function even if it appears that the function is not referenced.
4383 This is useful, for example, when the function is referenced only in
4384 inline assembly.
4385
4386 When applied to a member function of a C++ class template, the
4387 attribute also means that the function is instantiated if the
4388 class itself is instantiated.
4389
4390 @item vector
4391 @cindex @code{vector} attribute
4392 This RX attribute is similar to the @code{interrupt} attribute, including its
4393 parameters, but does not make the function an interrupt-handler type
4394 function (i.e. it retains the normal C function calling ABI).  See the
4395 @code{interrupt} attribute for a description of its arguments.
4396
4397 @item version_id
4398 @cindex @code{version_id} attribute
4399 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4400 symbol to contain a version string, thus allowing for function level
4401 versioning.  HP-UX system header files may use function level versioning
4402 for some system calls.
4403
4404 @smallexample
4405 extern int foo () __attribute__((version_id ("20040821")));
4406 @end smallexample
4407
4408 @noindent
4409 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4410
4411 @item visibility ("@var{visibility_type}")
4412 @cindex @code{visibility} attribute
4413 This attribute affects the linkage of the declaration to which it is attached.
4414 There are four supported @var{visibility_type} values: default,
4415 hidden, protected or internal visibility.
4416
4417 @smallexample
4418 void __attribute__ ((visibility ("protected")))
4419 f () @{ /* @r{Do something.} */; @}
4420 int i __attribute__ ((visibility ("hidden")));
4421 @end smallexample
4422
4423 The possible values of @var{visibility_type} correspond to the
4424 visibility settings in the ELF gABI.
4425
4426 @table @dfn
4427 @c keep this list of visibilities in alphabetical order.
4428
4429 @item default
4430 Default visibility is the normal case for the object file format.
4431 This value is available for the visibility attribute to override other
4432 options that may change the assumed visibility of entities.
4433
4434 On ELF, default visibility means that the declaration is visible to other
4435 modules and, in shared libraries, means that the declared entity may be
4436 overridden.
4437
4438 On Darwin, default visibility means that the declaration is visible to
4439 other modules.
4440
4441 Default visibility corresponds to ``external linkage'' in the language.
4442
4443 @item hidden
4444 Hidden visibility indicates that the entity declared has a new
4445 form of linkage, which we call ``hidden linkage''.  Two
4446 declarations of an object with hidden linkage refer to the same object
4447 if they are in the same shared object.
4448
4449 @item internal
4450 Internal visibility is like hidden visibility, but with additional
4451 processor specific semantics.  Unless otherwise specified by the
4452 psABI, GCC defines internal visibility to mean that a function is
4453 @emph{never} called from another module.  Compare this with hidden
4454 functions which, while they cannot be referenced directly by other
4455 modules, can be referenced indirectly via function pointers.  By
4456 indicating that a function cannot be called from outside the module,
4457 GCC may for instance omit the load of a PIC register since it is known
4458 that the calling function loaded the correct value.
4459
4460 @item protected
4461 Protected visibility is like default visibility except that it
4462 indicates that references within the defining module bind to the
4463 definition in that module.  That is, the declared entity cannot be
4464 overridden by another module.
4465
4466 @end table
4467
4468 All visibilities are supported on many, but not all, ELF targets
4469 (supported when the assembler supports the @samp{.visibility}
4470 pseudo-op).  Default visibility is supported everywhere.  Hidden
4471 visibility is supported on Darwin targets.
4472
4473 The visibility attribute should be applied only to declarations that
4474 would otherwise have external linkage.  The attribute should be applied
4475 consistently, so that the same entity should not be declared with
4476 different settings of the attribute.
4477
4478 In C++, the visibility attribute applies to types as well as functions
4479 and objects, because in C++ types have linkage.  A class must not have
4480 greater visibility than its non-static data member types and bases,
4481 and class members default to the visibility of their class.  Also, a
4482 declaration without explicit visibility is limited to the visibility
4483 of its type.
4484
4485 In C++, you can mark member functions and static member variables of a
4486 class with the visibility attribute.  This is useful if you know a
4487 particular method or static member variable should only be used from
4488 one shared object; then you can mark it hidden while the rest of the
4489 class has default visibility.  Care must be taken to avoid breaking
4490 the One Definition Rule; for example, it is usually not useful to mark
4491 an inline method as hidden without marking the whole class as hidden.
4492
4493 A C++ namespace declaration can also have the visibility attribute.
4494
4495 @smallexample
4496 namespace nspace1 __attribute__ ((visibility ("protected")))
4497 @{ /* @r{Do something.} */; @}
4498 @end smallexample
4499
4500 This attribute applies only to the particular namespace body, not to
4501 other definitions of the same namespace; it is equivalent to using
4502 @samp{#pragma GCC visibility} before and after the namespace
4503 definition (@pxref{Visibility Pragmas}).
4504
4505 In C++, if a template argument has limited visibility, this
4506 restriction is implicitly propagated to the template instantiation.
4507 Otherwise, template instantiations and specializations default to the
4508 visibility of their template.
4509
4510 If both the template and enclosing class have explicit visibility, the
4511 visibility from the template is used.
4512
4513 @item vliw
4514 @cindex @code{vliw} attribute
4515 On MeP, the @code{vliw} attribute tells the compiler to emit
4516 instructions in VLIW mode instead of core mode.  Note that this
4517 attribute is not allowed unless a VLIW coprocessor has been configured
4518 and enabled through command-line options.
4519
4520 @item warn_unused_result
4521 @cindex @code{warn_unused_result} attribute
4522 The @code{warn_unused_result} attribute causes a warning to be emitted
4523 if a caller of the function with this attribute does not use its
4524 return value.  This is useful for functions where not checking
4525 the result is either a security problem or always a bug, such as
4526 @code{realloc}.
4527
4528 @smallexample
4529 int fn () __attribute__ ((warn_unused_result));
4530 int foo ()
4531 @{
4532   if (fn () < 0) return -1;
4533   fn ();
4534   return 0;
4535 @}
4536 @end smallexample
4537
4538 @noindent
4539 results in warning on line 5.
4540
4541 @item weak
4542 @cindex @code{weak} attribute
4543 The @code{weak} attribute causes the declaration to be emitted as a weak
4544 symbol rather than a global.  This is primarily useful in defining
4545 library functions that can be overridden in user code, though it can
4546 also be used with non-function declarations.  Weak symbols are supported
4547 for ELF targets, and also for a.out targets when using the GNU assembler
4548 and linker.
4549
4550 @item weakref
4551 @itemx weakref ("@var{target}")
4552 @cindex @code{weakref} attribute
4553 The @code{weakref} attribute marks a declaration as a weak reference.
4554 Without arguments, it should be accompanied by an @code{alias} attribute
4555 naming the target symbol.  Optionally, the @var{target} may be given as
4556 an argument to @code{weakref} itself.  In either case, @code{weakref}
4557 implicitly marks the declaration as @code{weak}.  Without a
4558 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4559 @code{weakref} is equivalent to @code{weak}.
4560
4561 @smallexample
4562 static int x() __attribute__ ((weakref ("y")));
4563 /* is equivalent to... */
4564 static int x() __attribute__ ((weak, weakref, alias ("y")));
4565 /* and to... */
4566 static int x() __attribute__ ((weakref));
4567 static int x() __attribute__ ((alias ("y")));
4568 @end smallexample
4569
4570 A weak reference is an alias that does not by itself require a
4571 definition to be given for the target symbol.  If the target symbol is
4572 only referenced through weak references, then it becomes a @code{weak}
4573 undefined symbol.  If it is directly referenced, however, then such
4574 strong references prevail, and a definition is required for the
4575 symbol, not necessarily in the same translation unit.
4576
4577 The effect is equivalent to moving all references to the alias to a
4578 separate translation unit, renaming the alias to the aliased symbol,
4579 declaring it as weak, compiling the two separate translation units and
4580 performing a reloadable link on them.
4581
4582 At present, a declaration to which @code{weakref} is attached can
4583 only be @code{static}.
4584
4585 @end table
4586
4587 You can specify multiple attributes in a declaration by separating them
4588 by commas within the double parentheses or by immediately following an
4589 attribute declaration with another attribute declaration.
4590
4591 @cindex @code{#pragma}, reason for not using
4592 @cindex pragma, reason for not using
4593 Some people object to the @code{__attribute__} feature, suggesting that
4594 ISO C's @code{#pragma} should be used instead.  At the time
4595 @code{__attribute__} was designed, there were two reasons for not doing
4596 this.
4597
4598 @enumerate
4599 @item
4600 It is impossible to generate @code{#pragma} commands from a macro.
4601
4602 @item
4603 There is no telling what the same @code{#pragma} might mean in another
4604 compiler.
4605 @end enumerate
4606
4607 These two reasons applied to almost any application that might have been
4608 proposed for @code{#pragma}.  It was basically a mistake to use
4609 @code{#pragma} for @emph{anything}.
4610
4611 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4612 to be generated from macros.  In addition, a @code{#pragma GCC}
4613 namespace is now in use for GCC-specific pragmas.  However, it has been
4614 found convenient to use @code{__attribute__} to achieve a natural
4615 attachment of attributes to their corresponding declarations, whereas
4616 @code{#pragma GCC} is of use for constructs that do not naturally form
4617 part of the grammar.  @xref{Pragmas,,Pragmas Accepted by GCC}.
4618
4619 @node Label Attributes
4620 @section Label Attributes
4621 @cindex Label Attributes
4622
4623 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
4624 details of the exact syntax for using attributes.  Other attributes are 
4625 available for functions (@pxref{Function Attributes}), variables 
4626 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
4627
4628 This example uses the @code{cold} label attribute to indicate the 
4629 @code{ErrorHandling} branch is unlikely to be taken and that the
4630 @code{ErrorHandling} label is unused:
4631
4632 @smallexample
4633
4634    asm goto ("some asm" : : : : NoError);
4635
4636 /* This branch (the fallthru from the asm) is less commonly used */
4637 ErrorHandling: 
4638    __attribute__((cold, unused)); /* Semi-colon is required here */
4639    printf("error\n");
4640    return 0;
4641
4642 NoError:
4643    printf("no error\n");
4644    return 1;
4645 @end smallexample
4646
4647 @table @code
4648 @item unused
4649 @cindex @code{unused} label attribute
4650 This feature is intended for program-generated code that may contain 
4651 unused labels, but which is compiled with @option{-Wall}.  It is
4652 not normally appropriate to use in it human-written code, though it
4653 could be useful in cases where the code that jumps to the label is
4654 contained within an @code{#ifdef} conditional.
4655
4656 @item hot
4657 @cindex @code{hot} label attribute
4658 The @code{hot} attribute on a label is used to inform the compiler that
4659 the path following the label is more likely than paths that are not so
4660 annotated.  This attribute is used in cases where @code{__builtin_expect}
4661 cannot be used, for instance with computed goto or @code{asm goto}.
4662
4663 The @code{hot} attribute on labels is not implemented in GCC versions
4664 earlier than 4.8.
4665
4666 @item cold
4667 @cindex @code{cold} label attribute
4668 The @code{cold} attribute on labels is used to inform the compiler that
4669 the path following the label is unlikely to be executed.  This attribute
4670 is used in cases where @code{__builtin_expect} cannot be used, for instance
4671 with computed goto or @code{asm goto}.
4672
4673 The @code{cold} attribute on labels is not implemented in GCC versions
4674 earlier than 4.8.
4675
4676 @end table
4677
4678 @node Attribute Syntax
4679 @section Attribute Syntax
4680 @cindex attribute syntax
4681
4682 This section describes the syntax with which @code{__attribute__} may be
4683 used, and the constructs to which attribute specifiers bind, for the C
4684 language.  Some details may vary for C++ and Objective-C@.  Because of
4685 infelicities in the grammar for attributes, some forms described here
4686 may not be successfully parsed in all cases.
4687
4688 There are some problems with the semantics of attributes in C++.  For
4689 example, there are no manglings for attributes, although they may affect
4690 code generation, so problems may arise when attributed types are used in
4691 conjunction with templates or overloading.  Similarly, @code{typeid}
4692 does not distinguish between types with different attributes.  Support
4693 for attributes in C++ may be restricted in future to attributes on
4694 declarations only, but not on nested declarators.
4695
4696 @xref{Function Attributes}, for details of the semantics of attributes
4697 applying to functions.  @xref{Variable Attributes}, for details of the
4698 semantics of attributes applying to variables.  @xref{Type Attributes},
4699 for details of the semantics of attributes applying to structure, union
4700 and enumerated types.
4701 @xref{Label Attributes}, for details of the semantics of attributes 
4702 applying to labels.
4703
4704 An @dfn{attribute specifier} is of the form
4705 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
4706 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4707 each attribute is one of the following:
4708
4709 @itemize @bullet
4710 @item
4711 Empty.  Empty attributes are ignored.
4712
4713 @item
4714 A word (which may be an identifier such as @code{unused}, or a reserved
4715 word such as @code{const}).
4716
4717 @item
4718 A word, followed by, in parentheses, parameters for the attribute.
4719 These parameters take one of the following forms:
4720
4721 @itemize @bullet
4722 @item
4723 An identifier.  For example, @code{mode} attributes use this form.
4724
4725 @item
4726 An identifier followed by a comma and a non-empty comma-separated list
4727 of expressions.  For example, @code{format} attributes use this form.
4728
4729 @item
4730 A possibly empty comma-separated list of expressions.  For example,
4731 @code{format_arg} attributes use this form with the list being a single
4732 integer constant expression, and @code{alias} attributes use this form
4733 with the list being a single string constant.
4734 @end itemize
4735 @end itemize
4736
4737 An @dfn{attribute specifier list} is a sequence of one or more attribute
4738 specifiers, not separated by any other tokens.
4739
4740 @subsubheading Label Attributes
4741
4742 In GNU C, an attribute specifier list may appear after the colon following a
4743 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
4744 attributes on labels if the attribute specifier is immediately
4745 followed by a semicolon (i.e., the label applies to an empty
4746 statement).  If the semicolon is missing, C++ label attributes are
4747 ambiguous, as it is permissible for a declaration, which could begin
4748 with an attribute list, to be labelled in C++.  Declarations cannot be
4749 labelled in C90 or C99, so the ambiguity does not arise there.
4750
4751 @subsubheading Type Attributes
4752
4753 An attribute specifier list may appear as part of a @code{struct},
4754 @code{union} or @code{enum} specifier.  It may go either immediately
4755 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4756 the closing brace.  The former syntax is preferred.
4757 Where attribute specifiers follow the closing brace, they are considered
4758 to relate to the structure, union or enumerated type defined, not to any
4759 enclosing declaration the type specifier appears in, and the type
4760 defined is not complete until after the attribute specifiers.
4761 @c Otherwise, there would be the following problems: a shift/reduce
4762 @c conflict between attributes binding the struct/union/enum and
4763 @c binding to the list of specifiers/qualifiers; and "aligned"
4764 @c attributes could use sizeof for the structure, but the size could be
4765 @c changed later by "packed" attributes.
4766
4767
4768 @subsubheading All other attributes
4769
4770 Otherwise, an attribute specifier appears as part of a declaration,
4771 counting declarations of unnamed parameters and type names, and relates
4772 to that declaration (which may be nested in another declaration, for
4773 example in the case of a parameter declaration), or to a particular declarator
4774 within a declaration.  Where an
4775 attribute specifier is applied to a parameter declared as a function or
4776 an array, it should apply to the function or array rather than the
4777 pointer to which the parameter is implicitly converted, but this is not
4778 yet correctly implemented.
4779
4780 Any list of specifiers and qualifiers at the start of a declaration may
4781 contain attribute specifiers, whether or not such a list may in that
4782 context contain storage class specifiers.  (Some attributes, however,
4783 are essentially in the nature of storage class specifiers, and only make
4784 sense where storage class specifiers may be used; for example,
4785 @code{section}.)  There is one necessary limitation to this syntax: the
4786 first old-style parameter declaration in a function definition cannot
4787 begin with an attribute specifier, because such an attribute applies to
4788 the function instead by syntax described below (which, however, is not
4789 yet implemented in this case).  In some other cases, attribute
4790 specifiers are permitted by this grammar but not yet supported by the
4791 compiler.  All attribute specifiers in this place relate to the
4792 declaration as a whole.  In the obsolescent usage where a type of
4793 @code{int} is implied by the absence of type specifiers, such a list of
4794 specifiers and qualifiers may be an attribute specifier list with no
4795 other specifiers or qualifiers.
4796
4797 At present, the first parameter in a function prototype must have some
4798 type specifier that is not an attribute specifier; this resolves an
4799 ambiguity in the interpretation of @code{void f(int
4800 (__attribute__((foo)) x))}, but is subject to change.  At present, if
4801 the parentheses of a function declarator contain only attributes then
4802 those attributes are ignored, rather than yielding an error or warning
4803 or implying a single parameter of type int, but this is subject to
4804 change.
4805
4806 An attribute specifier list may appear immediately before a declarator
4807 (other than the first) in a comma-separated list of declarators in a
4808 declaration of more than one identifier using a single list of
4809 specifiers and qualifiers.  Such attribute specifiers apply
4810 only to the identifier before whose declarator they appear.  For
4811 example, in
4812
4813 @smallexample
4814 __attribute__((noreturn)) void d0 (void),
4815     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4816      d2 (void)
4817 @end smallexample
4818
4819 @noindent
4820 the @code{noreturn} attribute applies to all the functions
4821 declared; the @code{format} attribute only applies to @code{d1}.
4822
4823 An attribute specifier list may appear immediately before the comma,
4824 @code{=} or semicolon terminating the declaration of an identifier other
4825 than a function definition.  Such attribute specifiers apply
4826 to the declared object or function.  Where an
4827 assembler name for an object or function is specified (@pxref{Asm
4828 Labels}), the attribute must follow the @code{asm}
4829 specification.
4830
4831 An attribute specifier list may, in future, be permitted to appear after
4832 the declarator in a function definition (before any old-style parameter
4833 declarations or the function body).
4834
4835 Attribute specifiers may be mixed with type qualifiers appearing inside
4836 the @code{[]} of a parameter array declarator, in the C99 construct by
4837 which such qualifiers are applied to the pointer to which the array is
4838 implicitly converted.  Such attribute specifiers apply to the pointer,
4839 not to the array, but at present this is not implemented and they are
4840 ignored.
4841
4842 An attribute specifier list may appear at the start of a nested
4843 declarator.  At present, there are some limitations in this usage: the
4844 attributes correctly apply to the declarator, but for most individual
4845 attributes the semantics this implies are not implemented.
4846 When attribute specifiers follow the @code{*} of a pointer
4847 declarator, they may be mixed with any type qualifiers present.
4848 The following describes the formal semantics of this syntax.  It makes the
4849 most sense if you are familiar with the formal specification of
4850 declarators in the ISO C standard.
4851
4852 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4853 D1}, where @code{T} contains declaration specifiers that specify a type
4854 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4855 contains an identifier @var{ident}.  The type specified for @var{ident}
4856 for derived declarators whose type does not include an attribute
4857 specifier is as in the ISO C standard.
4858
4859 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4860 and the declaration @code{T D} specifies the type
4861 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4862 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4863 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4864
4865 If @code{D1} has the form @code{*
4866 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4867 declaration @code{T D} specifies the type
4868 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4869 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4870 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4871 @var{ident}.
4872
4873 For example,
4874
4875 @smallexample
4876 void (__attribute__((noreturn)) ****f) (void);
4877 @end smallexample
4878
4879 @noindent
4880 specifies the type ``pointer to pointer to pointer to pointer to
4881 non-returning function returning @code{void}''.  As another example,
4882
4883 @smallexample
4884 char *__attribute__((aligned(8))) *f;
4885 @end smallexample
4886
4887 @noindent
4888 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4889 Note again that this does not work with most attributes; for example,
4890 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4891 is not yet supported.
4892
4893 For compatibility with existing code written for compiler versions that
4894 did not implement attributes on nested declarators, some laxity is
4895 allowed in the placing of attributes.  If an attribute that only applies
4896 to types is applied to a declaration, it is treated as applying to
4897 the type of that declaration.  If an attribute that only applies to
4898 declarations is applied to the type of a declaration, it is treated
4899 as applying to that declaration; and, for compatibility with code
4900 placing the attributes immediately before the identifier declared, such
4901 an attribute applied to a function return type is treated as
4902 applying to the function type, and such an attribute applied to an array
4903 element type is treated as applying to the array type.  If an
4904 attribute that only applies to function types is applied to a
4905 pointer-to-function type, it is treated as applying to the pointer
4906 target type; if such an attribute is applied to a function return type
4907 that is not a pointer-to-function type, it is treated as applying
4908 to the function type.
4909
4910 @node Function Prototypes
4911 @section Prototypes and Old-Style Function Definitions
4912 @cindex function prototype declarations
4913 @cindex old-style function definitions
4914 @cindex promotion of formal parameters
4915
4916 GNU C extends ISO C to allow a function prototype to override a later
4917 old-style non-prototype definition.  Consider the following example:
4918
4919 @smallexample
4920 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
4921 #ifdef __STDC__
4922 #define P(x) x
4923 #else
4924 #define P(x) ()
4925 #endif
4926
4927 /* @r{Prototype function declaration.}  */
4928 int isroot P((uid_t));
4929
4930 /* @r{Old-style function definition.}  */
4931 int
4932 isroot (x)   /* @r{??? lossage here ???} */
4933      uid_t x;
4934 @{
4935   return x == 0;
4936 @}
4937 @end smallexample
4938
4939 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
4940 not allow this example, because subword arguments in old-style
4941 non-prototype definitions are promoted.  Therefore in this example the
4942 function definition's argument is really an @code{int}, which does not
4943 match the prototype argument type of @code{short}.
4944
4945 This restriction of ISO C makes it hard to write code that is portable
4946 to traditional C compilers, because the programmer does not know
4947 whether the @code{uid_t} type is @code{short}, @code{int}, or
4948 @code{long}.  Therefore, in cases like these GNU C allows a prototype
4949 to override a later old-style definition.  More precisely, in GNU C, a
4950 function prototype argument type overrides the argument type specified
4951 by a later old-style definition if the former type is the same as the
4952 latter type before promotion.  Thus in GNU C the above example is
4953 equivalent to the following:
4954
4955 @smallexample
4956 int isroot (uid_t);
4957
4958 int
4959 isroot (uid_t x)
4960 @{
4961   return x == 0;
4962 @}
4963 @end smallexample
4964
4965 @noindent
4966 GNU C++ does not support old-style function definitions, so this
4967 extension is irrelevant.
4968
4969 @node C++ Comments
4970 @section C++ Style Comments
4971 @cindex @code{//}
4972 @cindex C++ comments
4973 @cindex comments, C++ style
4974
4975 In GNU C, you may use C++ style comments, which start with @samp{//} and
4976 continue until the end of the line.  Many other C implementations allow
4977 such comments, and they are included in the 1999 C standard.  However,
4978 C++ style comments are not recognized if you specify an @option{-std}
4979 option specifying a version of ISO C before C99, or @option{-ansi}
4980 (equivalent to @option{-std=c90}).
4981
4982 @node Dollar Signs
4983 @section Dollar Signs in Identifier Names
4984 @cindex $
4985 @cindex dollar signs in identifier names
4986 @cindex identifier names, dollar signs in
4987
4988 In GNU C, you may normally use dollar signs in identifier names.
4989 This is because many traditional C implementations allow such identifiers.
4990 However, dollar signs in identifiers are not supported on a few target
4991 machines, typically because the target assembler does not allow them.
4992
4993 @node Character Escapes
4994 @section The Character @key{ESC} in Constants
4995
4996 You can use the sequence @samp{\e} in a string or character constant to
4997 stand for the ASCII character @key{ESC}.
4998
4999 @node Variable Attributes
5000 @section Specifying Attributes of Variables
5001 @cindex attribute of variables
5002 @cindex variable attributes
5003
5004 The keyword @code{__attribute__} allows you to specify special
5005 attributes of variables or structure fields.  This keyword is followed
5006 by an attribute specification inside double parentheses.  Some
5007 attributes are currently defined generically for variables.
5008 Other attributes are defined for variables on particular target
5009 systems.  Other attributes are available for functions
5010 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}) and for 
5011 types (@pxref{Type Attributes}).
5012 Other front ends might define more attributes
5013 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5014
5015 You may also specify attributes with @samp{__} preceding and following
5016 each keyword.  This allows you to use them in header files without
5017 being concerned about a possible macro of the same name.  For example,
5018 you may use @code{__aligned__} instead of @code{aligned}.
5019
5020 @xref{Attribute Syntax}, for details of the exact syntax for using
5021 attributes.
5022
5023 @table @code
5024 @cindex @code{aligned} attribute
5025 @item aligned (@var{alignment})
5026 This attribute specifies a minimum alignment for the variable or
5027 structure field, measured in bytes.  For example, the declaration:
5028
5029 @smallexample
5030 int x __attribute__ ((aligned (16))) = 0;
5031 @end smallexample
5032
5033 @noindent
5034 causes the compiler to allocate the global variable @code{x} on a
5035 16-byte boundary.  On a 68040, this could be used in conjunction with
5036 an @code{asm} expression to access the @code{move16} instruction which
5037 requires 16-byte aligned operands.
5038
5039 You can also specify the alignment of structure fields.  For example, to
5040 create a double-word aligned @code{int} pair, you could write:
5041
5042 @smallexample
5043 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5044 @end smallexample
5045
5046 @noindent
5047 This is an alternative to creating a union with a @code{double} member,
5048 which forces the union to be double-word aligned.
5049
5050 As in the preceding examples, you can explicitly specify the alignment
5051 (in bytes) that you wish the compiler to use for a given variable or
5052 structure field.  Alternatively, you can leave out the alignment factor
5053 and just ask the compiler to align a variable or field to the
5054 default alignment for the target architecture you are compiling for.
5055 The default alignment is sufficient for all scalar types, but may not be
5056 enough for all vector types on a target that supports vector operations.
5057 The default alignment is fixed for a particular target ABI.
5058
5059 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5060 which is the largest alignment ever used for any data type on the
5061 target machine you are compiling for.  For example, you could write:
5062
5063 @smallexample
5064 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5065 @end smallexample
5066
5067 The compiler automatically sets the alignment for the declared
5068 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5069 often make copy operations more efficient, because the compiler can
5070 use whatever instructions copy the biggest chunks of memory when
5071 performing copies to or from the variables or fields that you have
5072 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5073 may change depending on command-line options.
5074
5075 When used on a struct, or struct member, the @code{aligned} attribute can
5076 only increase the alignment; in order to decrease it, the @code{packed}
5077 attribute must be specified as well.  When used as part of a typedef, the
5078 @code{aligned} attribute can both increase and decrease alignment, and
5079 specifying the @code{packed} attribute generates a warning.
5080
5081 Note that the effectiveness of @code{aligned} attributes may be limited
5082 by inherent limitations in your linker.  On many systems, the linker is
5083 only able to arrange for variables to be aligned up to a certain maximum
5084 alignment.  (For some linkers, the maximum supported alignment may
5085 be very very small.)  If your linker is only able to align variables
5086 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5087 in an @code{__attribute__} still only provides you with 8-byte
5088 alignment.  See your linker documentation for further information.
5089
5090 The @code{aligned} attribute can also be used for functions
5091 (@pxref{Function Attributes}.)
5092
5093 @item cleanup (@var{cleanup_function})
5094 @cindex @code{cleanup} attribute
5095 The @code{cleanup} attribute runs a function when the variable goes
5096 out of scope.  This attribute can only be applied to auto function
5097 scope variables; it may not be applied to parameters or variables
5098 with static storage duration.  The function must take one parameter,
5099 a pointer to a type compatible with the variable.  The return value
5100 of the function (if any) is ignored.
5101
5102 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5103 is run during the stack unwinding that happens during the
5104 processing of the exception.  Note that the @code{cleanup} attribute
5105 does not allow the exception to be caught, only to perform an action.
5106 It is undefined what happens if @var{cleanup_function} does not
5107 return normally.
5108
5109 @item common
5110 @itemx nocommon
5111 @cindex @code{common} attribute
5112 @cindex @code{nocommon} attribute
5113 @opindex fcommon
5114 @opindex fno-common
5115 The @code{common} attribute requests GCC to place a variable in
5116 ``common'' storage.  The @code{nocommon} attribute requests the
5117 opposite---to allocate space for it directly.
5118
5119 These attributes override the default chosen by the
5120 @option{-fno-common} and @option{-fcommon} flags respectively.
5121
5122 @item deprecated
5123 @itemx deprecated (@var{msg})
5124 @cindex @code{deprecated} attribute
5125 The @code{deprecated} attribute results in a warning if the variable
5126 is used anywhere in the source file.  This is useful when identifying
5127 variables that are expected to be removed in a future version of a
5128 program.  The warning also includes the location of the declaration
5129 of the deprecated variable, to enable users to easily find further
5130 information about why the variable is deprecated, or what they should
5131 do instead.  Note that the warning only occurs for uses:
5132
5133 @smallexample
5134 extern int old_var __attribute__ ((deprecated));
5135 extern int old_var;
5136 int new_fn () @{ return old_var; @}
5137 @end smallexample
5138
5139 @noindent
5140 results in a warning on line 3 but not line 2.  The optional @var{msg}
5141 argument, which must be a string, is printed in the warning if
5142 present.
5143
5144 The @code{deprecated} attribute can also be used for functions and
5145 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
5146
5147 @item mode (@var{mode})
5148 @cindex @code{mode} attribute
5149 This attribute specifies the data type for the declaration---whichever
5150 type corresponds to the mode @var{mode}.  This in effect lets you
5151 request an integer or floating-point type according to its width.
5152
5153 You may also specify a mode of @code{byte} or @code{__byte__} to
5154 indicate the mode corresponding to a one-byte integer, @code{word} or
5155 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5156 or @code{__pointer__} for the mode used to represent pointers.
5157
5158 @item packed
5159 @cindex @code{packed} attribute
5160 The @code{packed} attribute specifies that a variable or structure field
5161 should have the smallest possible alignment---one byte for a variable,
5162 and one bit for a field, unless you specify a larger value with the
5163 @code{aligned} attribute.
5164
5165 Here is a structure in which the field @code{x} is packed, so that it
5166 immediately follows @code{a}:
5167
5168 @smallexample
5169 struct foo
5170 @{
5171   char a;
5172   int x[2] __attribute__ ((packed));
5173 @};
5174 @end smallexample
5175
5176 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5177 @code{packed} attribute on bit-fields of type @code{char}.  This has
5178 been fixed in GCC 4.4 but the change can lead to differences in the
5179 structure layout.  See the documentation of
5180 @option{-Wpacked-bitfield-compat} for more information.
5181
5182 @item section ("@var{section-name}")
5183 @cindex @code{section} variable attribute
5184 Normally, the compiler places the objects it generates in sections like
5185 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
5186 or you need certain particular variables to appear in special sections,
5187 for example to map to special hardware.  The @code{section}
5188 attribute specifies that a variable (or function) lives in a particular
5189 section.  For example, this small program uses several specific section names:
5190
5191 @smallexample
5192 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5193 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5194 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5195 int init_data __attribute__ ((section ("INITDATA")));
5196
5197 main()
5198 @{
5199   /* @r{Initialize stack pointer} */
5200   init_sp (stack + sizeof (stack));
5201
5202   /* @r{Initialize initialized data} */
5203   memcpy (&init_data, &data, &edata - &data);
5204
5205   /* @r{Turn on the serial ports} */
5206   init_duart (&a);
5207   init_duart (&b);
5208 @}
5209 @end smallexample
5210
5211 @noindent
5212 Use the @code{section} attribute with
5213 @emph{global} variables and not @emph{local} variables,
5214 as shown in the example.
5215
5216 You may use the @code{section} attribute with initialized or
5217 uninitialized global variables but the linker requires
5218 each object be defined once, with the exception that uninitialized
5219 variables tentatively go in the @code{common} (or @code{bss}) section
5220 and can be multiply ``defined''.  Using the @code{section} attribute
5221 changes what section the variable goes into and may cause the
5222 linker to issue an error if an uninitialized variable has multiple
5223 definitions.  You can force a variable to be initialized with the
5224 @option{-fno-common} flag or the @code{nocommon} attribute.
5225
5226 Some file formats do not support arbitrary sections so the @code{section}
5227 attribute is not available on all platforms.
5228 If you need to map the entire contents of a module to a particular
5229 section, consider using the facilities of the linker instead.
5230
5231 @item shared
5232 @cindex @code{shared} variable attribute
5233 On Microsoft Windows, in addition to putting variable definitions in a named
5234 section, the section can also be shared among all running copies of an
5235 executable or DLL@.  For example, this small program defines shared data
5236 by putting it in a named section @code{shared} and marking the section
5237 shareable:
5238
5239 @smallexample
5240 int foo __attribute__((section ("shared"), shared)) = 0;
5241
5242 int
5243 main()
5244 @{
5245   /* @r{Read and write foo.  All running
5246      copies see the same value.}  */
5247   return 0;
5248 @}
5249 @end smallexample
5250
5251 @noindent
5252 You may only use the @code{shared} attribute along with @code{section}
5253 attribute with a fully-initialized global definition because of the way
5254 linkers work.  See @code{section} attribute for more information.
5255
5256 The @code{shared} attribute is only available on Microsoft Windows@.
5257
5258 @item tls_model ("@var{tls_model}")
5259 @cindex @code{tls_model} attribute
5260 The @code{tls_model} attribute sets thread-local storage model
5261 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5262 overriding @option{-ftls-model=} command-line switch on a per-variable
5263 basis.
5264 The @var{tls_model} argument should be one of @code{global-dynamic},
5265 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5266
5267 Not all targets support this attribute.
5268
5269 @item unused
5270 This attribute, attached to a variable, means that the variable is meant
5271 to be possibly unused.  GCC does not produce a warning for this
5272 variable.
5273
5274 @item used
5275 This attribute, attached to a variable with the static storage, means that
5276 the variable must be emitted even if it appears that the variable is not
5277 referenced.
5278
5279 When applied to a static data member of a C++ class template, the
5280 attribute also means that the member is instantiated if the
5281 class itself is instantiated.
5282
5283 @item vector_size (@var{bytes})
5284 This attribute specifies the vector size for the variable, measured in
5285 bytes.  For example, the declaration:
5286
5287 @smallexample
5288 int foo __attribute__ ((vector_size (16)));
5289 @end smallexample
5290
5291 @noindent
5292 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5293 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
5294 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5295
5296 This attribute is only applicable to integral and float scalars,
5297 although arrays, pointers, and function return values are allowed in
5298 conjunction with this construct.
5299
5300 Aggregates with this attribute are invalid, even if they are of the same
5301 size as a corresponding scalar.  For example, the declaration:
5302
5303 @smallexample
5304 struct S @{ int a; @};
5305 struct S  __attribute__ ((vector_size (16))) foo;
5306 @end smallexample
5307
5308 @noindent
5309 is invalid even if the size of the structure is the same as the size of
5310 the @code{int}.
5311
5312 @item selectany
5313 The @code{selectany} attribute causes an initialized global variable to
5314 have link-once semantics.  When multiple definitions of the variable are
5315 encountered by the linker, the first is selected and the remainder are
5316 discarded.  Following usage by the Microsoft compiler, the linker is told
5317 @emph{not} to warn about size or content differences of the multiple
5318 definitions.
5319
5320 Although the primary usage of this attribute is for POD types, the
5321 attribute can also be applied to global C++ objects that are initialized
5322 by a constructor.  In this case, the static initialization and destruction
5323 code for the object is emitted in each translation defining the object,
5324 but the calls to the constructor and destructor are protected by a
5325 link-once guard variable.
5326
5327 The @code{selectany} attribute is only available on Microsoft Windows
5328 targets.  You can use @code{__declspec (selectany)} as a synonym for
5329 @code{__attribute__ ((selectany))} for compatibility with other
5330 compilers.
5331
5332 @item weak
5333 The @code{weak} attribute is described in @ref{Function Attributes}.
5334
5335 @item dllimport
5336 The @code{dllimport} attribute is described in @ref{Function Attributes}.
5337
5338 @item dllexport
5339 The @code{dllexport} attribute is described in @ref{Function Attributes}.
5340
5341 @end table
5342
5343 @anchor{AVR Variable Attributes}
5344 @subsection AVR Variable Attributes
5345
5346 @table @code
5347 @item progmem
5348 @cindex @code{progmem} AVR variable attribute
5349 The @code{progmem} attribute is used on the AVR to place read-only
5350 data in the non-volatile program memory (flash). The @code{progmem}
5351 attribute accomplishes this by putting respective variables into a
5352 section whose name starts with @code{.progmem}.
5353
5354 This attribute works similar to the @code{section} attribute
5355 but adds additional checking. Notice that just like the
5356 @code{section} attribute, @code{progmem} affects the location
5357 of the data but not how this data is accessed.
5358
5359 In order to read data located with the @code{progmem} attribute
5360 (inline) assembler must be used.
5361 @smallexample
5362 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5363 #include <avr/pgmspace.h> 
5364
5365 /* Locate var in flash memory */
5366 const int var[2] PROGMEM = @{ 1, 2 @};
5367
5368 int read_var (int i)
5369 @{
5370     /* Access var[] by accessor macro from avr/pgmspace.h */
5371     return (int) pgm_read_word (& var[i]);
5372 @}
5373 @end smallexample
5374
5375 AVR is a Harvard architecture processor and data and read-only data
5376 normally resides in the data memory (RAM).
5377
5378 See also the @ref{AVR Named Address Spaces} section for
5379 an alternate way to locate and access data in flash memory.
5380
5381 @item io
5382 @itemx io (@var{addr})
5383 Variables with the @code{io} attribute are used to address
5384 memory-mapped peripherals in the io address range.
5385 If an address is specified, the variable
5386 is assigned that address, and the value is interpreted as an
5387 address in the data address space.
5388 Example:
5389
5390 @smallexample
5391 volatile int porta __attribute__((io (0x22)));
5392 @end smallexample
5393
5394 The address specified in the address in the data address range.
5395
5396 Otherwise, the variable it is not assigned an address, but the
5397 compiler will still use in/out instructions where applicable,
5398 assuming some other module assigns an address in the io address range.
5399 Example:
5400
5401 @smallexample
5402 extern volatile int porta __attribute__((io));
5403 @end smallexample
5404
5405 @item io_low
5406 @itemx io_low (@var{addr})
5407 This is like the @code{io} attribute, but additionally it informs the
5408 compiler that the object lies in the lower half of the I/O area,
5409 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5410 instructions.
5411
5412 @item address
5413 @itemx address (@var{addr})
5414 Variables with the @code{address} attribute are used to address
5415 memory-mapped peripherals that may lie outside the io address range.
5416
5417 @smallexample
5418 volatile int porta __attribute__((address (0x600)));
5419 @end smallexample
5420
5421 @end table
5422
5423 @subsection Blackfin Variable Attributes
5424
5425 Three attributes are currently defined for the Blackfin.
5426
5427 @table @code
5428 @item l1_data
5429 @itemx l1_data_A
5430 @itemx l1_data_B
5431 @cindex @code{l1_data} variable attribute
5432 @cindex @code{l1_data_A} variable attribute
5433 @cindex @code{l1_data_B} variable attribute
5434 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5435 Variables with @code{l1_data} attribute are put into the specific section
5436 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5437 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5438 attribute are put into the specific section named @code{.l1.data.B}.
5439
5440 @item l2
5441 @cindex @code{l2} variable attribute
5442 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5443 Variables with @code{l2} attribute are put into the specific section
5444 named @code{.l2.data}.
5445 @end table
5446
5447 @subsection M32R/D Variable Attributes
5448
5449 One attribute is currently defined for the M32R/D@.
5450
5451 @table @code
5452 @item model (@var{model-name})
5453 @cindex variable addressability on the M32R/D
5454 Use this attribute on the M32R/D to set the addressability of an object.
5455 The identifier @var{model-name} is one of @code{small}, @code{medium},
5456 or @code{large}, representing each of the code models.
5457
5458 Small model objects live in the lower 16MB of memory (so that their
5459 addresses can be loaded with the @code{ld24} instruction).
5460
5461 Medium and large model objects may live anywhere in the 32-bit address space
5462 (the compiler generates @code{seth/add3} instructions to load their
5463 addresses).
5464 @end table
5465
5466 @anchor{MeP Variable Attributes}
5467 @subsection MeP Variable Attributes
5468
5469 The MeP target has a number of addressing modes and busses.  The
5470 @code{near} space spans the standard memory space's first 16 megabytes
5471 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
5472 The @code{based} space is a 128-byte region in the memory space that
5473 is addressed relative to the @code{$tp} register.  The @code{tiny}
5474 space is a 65536-byte region relative to the @code{$gp} register.  In
5475 addition to these memory regions, the MeP target has a separate 16-bit
5476 control bus which is specified with @code{cb} attributes.
5477
5478 @table @code
5479
5480 @item based
5481 Any variable with the @code{based} attribute is assigned to the
5482 @code{.based} section, and is accessed with relative to the
5483 @code{$tp} register.
5484
5485 @item tiny
5486 Likewise, the @code{tiny} attribute assigned variables to the
5487 @code{.tiny} section, relative to the @code{$gp} register.
5488
5489 @item near
5490 Variables with the @code{near} attribute are assumed to have addresses
5491 that fit in a 24-bit addressing mode.  This is the default for large
5492 variables (@code{-mtiny=4} is the default) but this attribute can
5493 override @code{-mtiny=} for small variables, or override @code{-ml}.
5494
5495 @item far
5496 Variables with the @code{far} attribute are addressed using a full
5497 32-bit address.  Since this covers the entire memory space, this
5498 allows modules to make no assumptions about where variables might be
5499 stored.
5500
5501 @item io
5502 @itemx io (@var{addr})
5503 Variables with the @code{io} attribute are used to address
5504 memory-mapped peripherals.  If an address is specified, the variable
5505 is assigned that address, else it is not assigned an address (it is
5506 assumed some other module assigns an address).  Example:
5507
5508 @smallexample
5509 int timer_count __attribute__((io(0x123)));
5510 @end smallexample
5511
5512 @item cb
5513 @itemx cb (@var{addr})
5514 Variables with the @code{cb} attribute are used to access the control
5515 bus, using special instructions.  @code{addr} indicates the control bus
5516 address.  Example:
5517
5518 @smallexample
5519 int cpu_clock __attribute__((cb(0x123)));
5520 @end smallexample
5521
5522 @end table
5523
5524 @subsection PowerPC Variable Attributes
5525
5526 Three attributes currently are defined for PowerPC configurations:
5527 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5528
5529 For full documentation of the struct attributes please see the
5530 documentation in @ref{x86 Variable Attributes}.
5531
5532 For documentation of @code{altivec} attribute please see the
5533 documentation in @ref{PowerPC Type Attributes}.
5534
5535 @subsection SPU Variable Attributes
5536
5537 The SPU supports the @code{spu_vector} attribute for variables.  For
5538 documentation of this attribute please see the documentation in
5539 @ref{SPU Type Attributes}.
5540
5541 @anchor{x86 Variable Attributes}
5542 @subsection x86 Variable Attributes
5543
5544 Two attributes are currently defined for x86 configurations:
5545 @code{ms_struct} and @code{gcc_struct}.
5546
5547 @table @code
5548 @item ms_struct
5549 @itemx gcc_struct
5550 @cindex @code{ms_struct} attribute
5551 @cindex @code{gcc_struct} attribute
5552
5553 If @code{packed} is used on a structure, or if bit-fields are used,
5554 it may be that the Microsoft ABI lays out the structure differently
5555 than the way GCC normally does.  Particularly when moving packed
5556 data between functions compiled with GCC and the native Microsoft compiler
5557 (either via function call or as data in a file), it may be necessary to access
5558 either format.
5559
5560 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
5561 compilers to match the native Microsoft compiler.
5562
5563 The Microsoft structure layout algorithm is fairly simple with the exception
5564 of the bit-field packing.  
5565 The padding and alignment of members of structures and whether a bit-field 
5566 can straddle a storage-unit boundary are determine by these rules:
5567
5568 @enumerate
5569 @item Structure members are stored sequentially in the order in which they are
5570 declared: the first member has the lowest memory address and the last member
5571 the highest.
5572
5573 @item Every data object has an alignment requirement.  The alignment requirement
5574 for all data except structures, unions, and arrays is either the size of the
5575 object or the current packing size (specified with either the
5576 @code{aligned} attribute or the @code{pack} pragma),
5577 whichever is less.  For structures, unions, and arrays,
5578 the alignment requirement is the largest alignment requirement of its members.
5579 Every object is allocated an offset so that:
5580
5581 @smallexample
5582 offset % alignment_requirement == 0
5583 @end smallexample
5584
5585 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5586 unit if the integral types are the same size and if the next bit-field fits
5587 into the current allocation unit without crossing the boundary imposed by the
5588 common alignment requirements of the bit-fields.
5589 @end enumerate
5590
5591 MSVC interprets zero-length bit-fields in the following ways:
5592
5593 @enumerate
5594 @item If a zero-length bit-field is inserted between two bit-fields that
5595 are normally coalesced, the bit-fields are not coalesced.
5596
5597 For example:
5598
5599 @smallexample
5600 struct
5601  @{
5602    unsigned long bf_1 : 12;
5603    unsigned long : 0;
5604    unsigned long bf_2 : 12;
5605  @} t1;
5606 @end smallexample
5607
5608 @noindent
5609 The size of @code{t1} is 8 bytes with the zero-length bit-field.  If the
5610 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5611
5612 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5613 alignment of the zero-length bit-field is greater than the member that follows it,
5614 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5615
5616 For example:
5617
5618 @smallexample
5619 struct
5620  @{
5621    char foo : 4;
5622    short : 0;
5623    char bar;
5624  @} t2;
5625
5626 struct
5627  @{
5628    char foo : 4;
5629    short : 0;
5630    double bar;
5631  @} t3;
5632 @end smallexample
5633
5634 @noindent
5635 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5636 Accordingly, the size of @code{t2} is 4.  For @code{t3}, the zero-length
5637 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5638 of the structure.
5639
5640 Taking this into account, it is important to note the following:
5641
5642 @enumerate
5643 @item If a zero-length bit-field follows a normal bit-field, the type of the
5644 zero-length bit-field may affect the alignment of the structure as whole. For
5645 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5646 normal bit-field, and is of type short.
5647
5648 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5649 still affect the alignment of the structure:
5650
5651 @smallexample
5652 struct
5653  @{
5654    char foo : 6;
5655    long : 0;
5656  @} t4;
5657 @end smallexample
5658
5659 @noindent
5660 Here, @code{t4} takes up 4 bytes.
5661 @end enumerate
5662
5663 @item Zero-length bit-fields following non-bit-field members are ignored:
5664
5665 @smallexample
5666 struct
5667  @{
5668    char foo;
5669    long : 0;
5670    char bar;
5671  @} t5;
5672 @end smallexample
5673
5674 @noindent
5675 Here, @code{t5} takes up 2 bytes.
5676 @end enumerate
5677 @end table
5678
5679 @subsection Xstormy16 Variable Attributes
5680
5681 One attribute is currently defined for xstormy16 configurations:
5682 @code{below100}.
5683
5684 @table @code
5685 @item below100
5686 @cindex @code{below100} attribute
5687
5688 If a variable has the @code{below100} attribute (@code{BELOW100} is
5689 allowed also), GCC places the variable in the first 0x100 bytes of
5690 memory and use special opcodes to access it.  Such variables are
5691 placed in either the @code{.bss_below100} section or the
5692 @code{.data_below100} section.
5693
5694 @end table
5695
5696 @node Type Attributes
5697 @section Specifying Attributes of Types
5698 @cindex attribute of types
5699 @cindex type attributes
5700
5701 The keyword @code{__attribute__} allows you to specify special
5702 attributes of @code{struct} and @code{union} types when you define
5703 such types.  This keyword is followed by an attribute specification
5704 inside double parentheses.  Eight attributes are currently defined for
5705 types: @code{aligned}, @code{packed}, @code{transparent_union},
5706 @code{unused}, @code{deprecated}, @code{visibility}, @code{may_alias}
5707 and @code{bnd_variable_size}.  Other attributes are defined for
5708 functions (@pxref{Function Attributes}), labels (@pxref{Label 
5709 Attributes}) and for variables (@pxref{Variable Attributes}).
5710
5711 You may also specify any one of these attributes with @samp{__}
5712 preceding and following its keyword.  This allows you to use these
5713 attributes in header files without being concerned about a possible
5714 macro of the same name.  For example, you may use @code{__aligned__}
5715 instead of @code{aligned}.
5716
5717 You may specify type attributes in an enum, struct or union type
5718 declaration or definition, or for other types in a @code{typedef}
5719 declaration.
5720
5721 For an enum, struct or union type, you may specify attributes either
5722 between the enum, struct or union tag and the name of the type, or
5723 just past the closing curly brace of the @emph{definition}.  The
5724 former syntax is preferred.
5725
5726 @xref{Attribute Syntax}, for details of the exact syntax for using
5727 attributes.
5728
5729 @table @code
5730 @cindex @code{aligned} attribute
5731 @item aligned (@var{alignment})
5732 This attribute specifies a minimum alignment (in bytes) for variables
5733 of the specified type.  For example, the declarations:
5734
5735 @smallexample
5736 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5737 typedef int more_aligned_int __attribute__ ((aligned (8)));
5738 @end smallexample
5739
5740 @noindent
5741 force the compiler to ensure (as far as it can) that each variable whose
5742 type is @code{struct S} or @code{more_aligned_int} is allocated and
5743 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
5744 variables of type @code{struct S} aligned to 8-byte boundaries allows
5745 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5746 store) instructions when copying one variable of type @code{struct S} to
5747 another, thus improving run-time efficiency.
5748
5749 Note that the alignment of any given @code{struct} or @code{union} type
5750 is required by the ISO C standard to be at least a perfect multiple of
5751 the lowest common multiple of the alignments of all of the members of
5752 the @code{struct} or @code{union} in question.  This means that you @emph{can}
5753 effectively adjust the alignment of a @code{struct} or @code{union}
5754 type by attaching an @code{aligned} attribute to any one of the members
5755 of such a type, but the notation illustrated in the example above is a
5756 more obvious, intuitive, and readable way to request the compiler to
5757 adjust the alignment of an entire @code{struct} or @code{union} type.
5758
5759 As in the preceding example, you can explicitly specify the alignment
5760 (in bytes) that you wish the compiler to use for a given @code{struct}
5761 or @code{union} type.  Alternatively, you can leave out the alignment factor
5762 and just ask the compiler to align a type to the maximum
5763 useful alignment for the target machine you are compiling for.  For
5764 example, you could write:
5765
5766 @smallexample
5767 struct S @{ short f[3]; @} __attribute__ ((aligned));
5768 @end smallexample
5769
5770 Whenever you leave out the alignment factor in an @code{aligned}
5771 attribute specification, the compiler automatically sets the alignment
5772 for the type to the largest alignment that is ever used for any data
5773 type on the target machine you are compiling for.  Doing this can often
5774 make copy operations more efficient, because the compiler can use
5775 whatever instructions copy the biggest chunks of memory when performing
5776 copies to or from the variables that have types that you have aligned
5777 this way.
5778
5779 In the example above, if the size of each @code{short} is 2 bytes, then
5780 the size of the entire @code{struct S} type is 6 bytes.  The smallest
5781 power of two that is greater than or equal to that is 8, so the
5782 compiler sets the alignment for the entire @code{struct S} type to 8
5783 bytes.
5784
5785 Note that although you can ask the compiler to select a time-efficient
5786 alignment for a given type and then declare only individual stand-alone
5787 objects of that type, the compiler's ability to select a time-efficient
5788 alignment is primarily useful only when you plan to create arrays of
5789 variables having the relevant (efficiently aligned) type.  If you
5790 declare or use arrays of variables of an efficiently-aligned type, then
5791 it is likely that your program also does pointer arithmetic (or
5792 subscripting, which amounts to the same thing) on pointers to the
5793 relevant type, and the code that the compiler generates for these
5794 pointer arithmetic operations is often more efficient for
5795 efficiently-aligned types than for other types.
5796
5797 The @code{aligned} attribute can only increase the alignment; but you
5798 can decrease it by specifying @code{packed} as well.  See below.
5799
5800 Note that the effectiveness of @code{aligned} attributes may be limited
5801 by inherent limitations in your linker.  On many systems, the linker is
5802 only able to arrange for variables to be aligned up to a certain maximum
5803 alignment.  (For some linkers, the maximum supported alignment may
5804 be very very small.)  If your linker is only able to align variables
5805 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5806 in an @code{__attribute__} still only provides you with 8-byte
5807 alignment.  See your linker documentation for further information.
5808
5809 @item packed
5810 This attribute, attached to @code{struct} or @code{union} type
5811 definition, specifies that each member (other than zero-width bit-fields)
5812 of the structure or union is placed to minimize the memory required.  When
5813 attached to an @code{enum} definition, it indicates that the smallest
5814 integral type should be used.
5815
5816 @opindex fshort-enums
5817 Specifying this attribute for @code{struct} and @code{union} types is
5818 equivalent to specifying the @code{packed} attribute on each of the
5819 structure or union members.  Specifying the @option{-fshort-enums}
5820 flag on the line is equivalent to specifying the @code{packed}
5821 attribute on all @code{enum} definitions.
5822
5823 In the following example @code{struct my_packed_struct}'s members are
5824 packed closely together, but the internal layout of its @code{s} member
5825 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5826 be packed too.
5827
5828 @smallexample
5829 struct my_unpacked_struct
5830  @{
5831     char c;
5832     int i;
5833  @};
5834
5835 struct __attribute__ ((__packed__)) my_packed_struct
5836   @{
5837      char c;
5838      int  i;
5839      struct my_unpacked_struct s;
5840   @};
5841 @end smallexample
5842
5843 You may only specify this attribute on the definition of an @code{enum},
5844 @code{struct} or @code{union}, not on a @code{typedef} that does not
5845 also define the enumerated type, structure or union.
5846
5847 @item transparent_union
5848 @cindex @code{transparent_union} attribute
5849
5850 This attribute, attached to a @code{union} type definition, indicates
5851 that any function parameter having that union type causes calls to that
5852 function to be treated in a special way.
5853
5854 First, the argument corresponding to a transparent union type can be of
5855 any type in the union; no cast is required.  Also, if the union contains
5856 a pointer type, the corresponding argument can be a null pointer
5857 constant or a void pointer expression; and if the union contains a void
5858 pointer type, the corresponding argument can be any pointer expression.
5859 If the union member type is a pointer, qualifiers like @code{const} on
5860 the referenced type must be respected, just as with normal pointer
5861 conversions.
5862
5863 Second, the argument is passed to the function using the calling
5864 conventions of the first member of the transparent union, not the calling
5865 conventions of the union itself.  All members of the union must have the
5866 same machine representation; this is necessary for this argument passing
5867 to work properly.
5868
5869 Transparent unions are designed for library functions that have multiple
5870 interfaces for compatibility reasons.  For example, suppose the
5871 @code{wait} function must accept either a value of type @code{int *} to
5872 comply with POSIX, or a value of type @code{union wait *} to comply with
5873 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
5874 @code{wait} would accept both kinds of arguments, but it would also
5875 accept any other pointer type and this would make argument type checking
5876 less useful.  Instead, @code{<sys/wait.h>} might define the interface
5877 as follows:
5878
5879 @smallexample
5880 typedef union __attribute__ ((__transparent_union__))
5881   @{
5882     int *__ip;
5883     union wait *__up;
5884   @} wait_status_ptr_t;
5885
5886 pid_t wait (wait_status_ptr_t);
5887 @end smallexample
5888
5889 @noindent
5890 This interface allows either @code{int *} or @code{union wait *}
5891 arguments to be passed, using the @code{int *} calling convention.
5892 The program can call @code{wait} with arguments of either type:
5893
5894 @smallexample
5895 int w1 () @{ int w; return wait (&w); @}
5896 int w2 () @{ union wait w; return wait (&w); @}
5897 @end smallexample
5898
5899 @noindent
5900 With this interface, @code{wait}'s implementation might look like this:
5901
5902 @smallexample
5903 pid_t wait (wait_status_ptr_t p)
5904 @{
5905   return waitpid (-1, p.__ip, 0);
5906 @}
5907 @end smallexample
5908
5909 @item unused
5910 When attached to a type (including a @code{union} or a @code{struct}),
5911 this attribute means that variables of that type are meant to appear
5912 possibly unused.  GCC does not produce a warning for any variables of
5913 that type, even if the variable appears to do nothing.  This is often
5914 the case with lock or thread classes, which are usually defined and then
5915 not referenced, but contain constructors and destructors that have
5916 nontrivial bookkeeping functions.
5917
5918 @item deprecated
5919 @itemx deprecated (@var{msg})
5920 The @code{deprecated} attribute results in a warning if the type
5921 is used anywhere in the source file.  This is useful when identifying
5922 types that are expected to be removed in a future version of a program.
5923 If possible, the warning also includes the location of the declaration
5924 of the deprecated type, to enable users to easily find further
5925 information about why the type is deprecated, or what they should do
5926 instead.  Note that the warnings only occur for uses and then only
5927 if the type is being applied to an identifier that itself is not being
5928 declared as deprecated.
5929
5930 @smallexample
5931 typedef int T1 __attribute__ ((deprecated));
5932 T1 x;
5933 typedef T1 T2;
5934 T2 y;
5935 typedef T1 T3 __attribute__ ((deprecated));
5936 T3 z __attribute__ ((deprecated));
5937 @end smallexample
5938
5939 @noindent
5940 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
5941 warning is issued for line 4 because T2 is not explicitly
5942 deprecated.  Line 5 has no warning because T3 is explicitly
5943 deprecated.  Similarly for line 6.  The optional @var{msg}
5944 argument, which must be a string, is printed in the warning if
5945 present.
5946
5947 The @code{deprecated} attribute can also be used for functions and
5948 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5949
5950 @item may_alias
5951 Accesses through pointers to types with this attribute are not subject
5952 to type-based alias analysis, but are instead assumed to be able to alias
5953 any other type of objects.
5954 In the context of section 6.5 paragraph 7 of the C99 standard,
5955 an lvalue expression
5956 dereferencing such a pointer is treated like having a character type.
5957 See @option{-fstrict-aliasing} for more information on aliasing issues.
5958 This extension exists to support some vector APIs, in which pointers to
5959 one vector type are permitted to alias pointers to a different vector type.
5960
5961 Note that an object of a type with this attribute does not have any
5962 special semantics.
5963
5964 Example of use:
5965
5966 @smallexample
5967 typedef short __attribute__((__may_alias__)) short_a;
5968
5969 int
5970 main (void)
5971 @{
5972   int a = 0x12345678;
5973   short_a *b = (short_a *) &a;
5974
5975   b[1] = 0;
5976
5977   if (a == 0x12345678)
5978     abort();
5979
5980   exit(0);
5981 @}
5982 @end smallexample
5983
5984 @noindent
5985 If you replaced @code{short_a} with @code{short} in the variable
5986 declaration, the above program would abort when compiled with
5987 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5988 above in recent GCC versions.
5989
5990 @item visibility
5991 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5992 applied to class, struct, union and enum types.  Unlike other type
5993 attributes, the attribute must appear between the initial keyword and
5994 the name of the type; it cannot appear after the body of the type.
5995
5996 Note that the type visibility is applied to vague linkage entities
5997 associated with the class (vtable, typeinfo node, etc.).  In
5998 particular, if a class is thrown as an exception in one shared object
5999 and caught in another, the class must have default visibility.
6000 Otherwise the two shared objects are unable to use the same
6001 typeinfo node and exception handling will break.
6002
6003 @item designated_init
6004 This attribute may only be applied to structure types.  It indicates
6005 that any initialization of an object of this type must use designated
6006 initializers rather than positional initializers.  The intent of this
6007 attribute is to allow the programmer to indicate that a structure's
6008 layout may change, and that therefore relying on positional
6009 initialization will result in future breakage.
6010
6011 GCC emits warnings based on this attribute by default; use
6012 @option{-Wno-designated-init} to suppress them.
6013
6014 @item bnd_variable_size
6015 When applied to a structure field, this attribute tells Pointer
6016 Bounds Checker that the size of this field should not be computed
6017 using static type information.  It may be used to mark variable
6018 sized static array fields placed at the end of a structure.
6019
6020 @smallexample
6021 struct S
6022 @{
6023   int size;
6024   char data[1];
6025 @}
6026 S *p = (S *)malloc (sizeof(S) + 100);
6027 p->data[10] = 0; //Bounds violation
6028 @end smallexample
6029
6030 By using an attribute for a field we may avoid bound violation
6031 we most probably do not want to see:
6032
6033 @smallexample
6034 struct S
6035 @{
6036   int size;
6037   char data[1] __attribute__((bnd_variable_size));
6038 @}
6039 S *p = (S *)malloc (sizeof(S) + 100);
6040 p->data[10] = 0; //OK
6041 @end smallexample
6042
6043 @end table
6044
6045 To specify multiple attributes, separate them by commas within the
6046 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6047 packed))}.
6048
6049 @subsection ARM Type Attributes
6050
6051 On those ARM targets that support @code{dllimport} (such as Symbian
6052 OS), you can use the @code{notshared} attribute to indicate that the
6053 virtual table and other similar data for a class should not be
6054 exported from a DLL@.  For example:
6055
6056 @smallexample
6057 class __declspec(notshared) C @{
6058 public:
6059   __declspec(dllimport) C();
6060   virtual void f();
6061 @}
6062
6063 __declspec(dllexport)
6064 C::C() @{@}
6065 @end smallexample
6066
6067 @noindent
6068 In this code, @code{C::C} is exported from the current DLL, but the
6069 virtual table for @code{C} is not exported.  (You can use
6070 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6071 most Symbian OS code uses @code{__declspec}.)
6072
6073 @anchor{MeP Type Attributes}
6074 @subsection MeP Type Attributes
6075
6076 Many of the MeP variable attributes may be applied to types as well.
6077 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6078 @code{far} attributes may be applied to either.  The @code{io} and
6079 @code{cb} attributes may not be applied to types.
6080
6081 @anchor{PowerPC Type Attributes}
6082 @subsection PowerPC Type Attributes
6083
6084 Three attributes currently are defined for PowerPC configurations:
6085 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6086
6087 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6088 attributes please see the documentation in @ref{x86 Type Attributes}.
6089
6090 The @code{altivec} attribute allows one to declare AltiVec vector data
6091 types supported by the AltiVec Programming Interface Manual.  The
6092 attribute requires an argument to specify one of three vector types:
6093 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6094 and @code{bool__} (always followed by unsigned).
6095
6096 @smallexample
6097 __attribute__((altivec(vector__)))
6098 __attribute__((altivec(pixel__))) unsigned short
6099 __attribute__((altivec(bool__))) unsigned
6100 @end smallexample
6101
6102 These attributes mainly are intended to support the @code{__vector},
6103 @code{__pixel}, and @code{__bool} AltiVec keywords.
6104
6105 @anchor{SPU Type Attributes}
6106 @subsection SPU Type Attributes
6107
6108 The SPU supports the @code{spu_vector} attribute for types.  This attribute
6109 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6110 Language Extensions Specification.  It is intended to support the
6111 @code{__vector} keyword.
6112
6113 @anchor{x86 Type Attributes}
6114 @subsection x86 Type Attributes
6115
6116 Two attributes are currently defined for x86 configurations:
6117 @code{ms_struct} and @code{gcc_struct}.
6118
6119 @table @code
6120
6121 @item ms_struct
6122 @itemx gcc_struct
6123 @cindex @code{ms_struct}
6124 @cindex @code{gcc_struct}
6125
6126 If @code{packed} is used on a structure, or if bit-fields are used
6127 it may be that the Microsoft ABI packs them differently
6128 than GCC normally packs them.  Particularly when moving packed
6129 data between functions compiled with GCC and the native Microsoft compiler
6130 (either via function call or as data in a file), it may be necessary to access
6131 either format.
6132
6133 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6134 compilers to match the native Microsoft compiler.
6135 @end table
6136
6137 @node Alignment
6138 @section Inquiring on Alignment of Types or Variables
6139 @cindex alignment
6140 @cindex type alignment
6141 @cindex variable alignment
6142
6143 The keyword @code{__alignof__} allows you to inquire about how an object
6144 is aligned, or the minimum alignment usually required by a type.  Its
6145 syntax is just like @code{sizeof}.
6146
6147 For example, if the target machine requires a @code{double} value to be
6148 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
6149 This is true on many RISC machines.  On more traditional machine
6150 designs, @code{__alignof__ (double)} is 4 or even 2.
6151
6152 Some machines never actually require alignment; they allow reference to any
6153 data type even at an odd address.  For these machines, @code{__alignof__}
6154 reports the smallest alignment that GCC gives the data type, usually as
6155 mandated by the target ABI.
6156
6157 If the operand of @code{__alignof__} is an lvalue rather than a type,
6158 its value is the required alignment for its type, taking into account
6159 any minimum alignment specified with GCC's @code{__attribute__}
6160 extension (@pxref{Variable Attributes}).  For example, after this
6161 declaration:
6162
6163 @smallexample
6164 struct foo @{ int x; char y; @} foo1;
6165 @end smallexample
6166
6167 @noindent
6168 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
6169 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
6170
6171 It is an error to ask for the alignment of an incomplete type.
6172
6173
6174 @node Inline
6175 @section An Inline Function is As Fast As a Macro
6176 @cindex inline functions
6177 @cindex integrating function code
6178 @cindex open coding
6179 @cindex macros, inline alternative
6180
6181 By declaring a function inline, you can direct GCC to make
6182 calls to that function faster.  One way GCC can achieve this is to
6183 integrate that function's code into the code for its callers.  This
6184 makes execution faster by eliminating the function-call overhead; in
6185 addition, if any of the actual argument values are constant, their
6186 known values may permit simplifications at compile time so that not
6187 all of the inline function's code needs to be included.  The effect on
6188 code size is less predictable; object code may be larger or smaller
6189 with function inlining, depending on the particular case.  You can
6190 also direct GCC to try to integrate all ``simple enough'' functions
6191 into their callers with the option @option{-finline-functions}.
6192
6193 GCC implements three different semantics of declaring a function
6194 inline.  One is available with @option{-std=gnu89} or
6195 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
6196 on all inline declarations, another when
6197 @option{-std=c99}, @option{-std=c11},
6198 @option{-std=gnu99} or @option{-std=gnu11}
6199 (without @option{-fgnu89-inline}), and the third
6200 is used when compiling C++.
6201
6202 To declare a function inline, use the @code{inline} keyword in its
6203 declaration, like this:
6204
6205 @smallexample
6206 static inline int
6207 inc (int *a)
6208 @{
6209   return (*a)++;
6210 @}
6211 @end smallexample
6212
6213 If you are writing a header file to be included in ISO C90 programs, write
6214 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
6215
6216 The three types of inlining behave similarly in two important cases:
6217 when the @code{inline} keyword is used on a @code{static} function,
6218 like the example above, and when a function is first declared without
6219 using the @code{inline} keyword and then is defined with
6220 @code{inline}, like this:
6221
6222 @smallexample
6223 extern int inc (int *a);
6224 inline int
6225 inc (int *a)
6226 @{
6227   return (*a)++;
6228 @}
6229 @end smallexample
6230
6231 In both of these common cases, the program behaves the same as if you
6232 had not used the @code{inline} keyword, except for its speed.
6233
6234 @cindex inline functions, omission of
6235 @opindex fkeep-inline-functions
6236 When a function is both inline and @code{static}, if all calls to the
6237 function are integrated into the caller, and the function's address is
6238 never used, then the function's own assembler code is never referenced.
6239 In this case, GCC does not actually output assembler code for the
6240 function, unless you specify the option @option{-fkeep-inline-functions}.
6241 Some calls cannot be integrated for various reasons (in particular,
6242 calls that precede the function's definition cannot be integrated, and
6243 neither can recursive calls within the definition).  If there is a
6244 nonintegrated call, then the function is compiled to assembler code as
6245 usual.  The function must also be compiled as usual if the program
6246 refers to its address, because that can't be inlined.
6247
6248 @opindex Winline
6249 Note that certain usages in a function definition can make it unsuitable
6250 for inline substitution.  Among these usages are: variadic functions, use of
6251 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
6252 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
6253 and nested functions (@pxref{Nested Functions}).  Using @option{-Winline}
6254 warns when a function marked @code{inline} could not be substituted,
6255 and gives the reason for the failure.
6256
6257 @cindex automatic @code{inline} for C++ member fns
6258 @cindex @code{inline} automatic for C++ member fns
6259 @cindex member fns, automatically @code{inline}
6260 @cindex C++ member fns, automatically @code{inline}
6261 @opindex fno-default-inline
6262 As required by ISO C++, GCC considers member functions defined within
6263 the body of a class to be marked inline even if they are
6264 not explicitly declared with the @code{inline} keyword.  You can
6265 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
6266 Options,,Options Controlling C++ Dialect}.
6267
6268 GCC does not inline any functions when not optimizing unless you specify
6269 the @samp{always_inline} attribute for the function, like this:
6270
6271 @smallexample
6272 /* @r{Prototype.}  */
6273 inline void foo (const char) __attribute__((always_inline));
6274 @end smallexample
6275
6276 The remainder of this section is specific to GNU C90 inlining.
6277
6278 @cindex non-static inline function
6279 When an inline function is not @code{static}, then the compiler must assume
6280 that there may be calls from other source files; since a global symbol can
6281 be defined only once in any program, the function must not be defined in
6282 the other source files, so the calls therein cannot be integrated.
6283 Therefore, a non-@code{static} inline function is always compiled on its
6284 own in the usual fashion.
6285
6286 If you specify both @code{inline} and @code{extern} in the function
6287 definition, then the definition is used only for inlining.  In no case
6288 is the function compiled on its own, not even if you refer to its
6289 address explicitly.  Such an address becomes an external reference, as
6290 if you had only declared the function, and had not defined it.
6291
6292 This combination of @code{inline} and @code{extern} has almost the
6293 effect of a macro.  The way to use it is to put a function definition in
6294 a header file with these keywords, and put another copy of the
6295 definition (lacking @code{inline} and @code{extern}) in a library file.
6296 The definition in the header file causes most calls to the function
6297 to be inlined.  If any uses of the function remain, they refer to
6298 the single copy in the library.
6299
6300 @node Volatiles
6301 @section When is a Volatile Object Accessed?
6302 @cindex accessing volatiles
6303 @cindex volatile read
6304 @cindex volatile write
6305 @cindex volatile access
6306
6307 C has the concept of volatile objects.  These are normally accessed by
6308 pointers and used for accessing hardware or inter-thread
6309 communication.  The standard encourages compilers to refrain from
6310 optimizations concerning accesses to volatile objects, but leaves it
6311 implementation defined as to what constitutes a volatile access.  The
6312 minimum requirement is that at a sequence point all previous accesses
6313 to volatile objects have stabilized and no subsequent accesses have
6314 occurred.  Thus an implementation is free to reorder and combine
6315 volatile accesses that occur between sequence points, but cannot do
6316 so for accesses across a sequence point.  The use of volatile does
6317 not allow you to violate the restriction on updating objects multiple
6318 times between two sequence points.
6319
6320 Accesses to non-volatile objects are not ordered with respect to
6321 volatile accesses.  You cannot use a volatile object as a memory
6322 barrier to order a sequence of writes to non-volatile memory.  For
6323 instance:
6324
6325 @smallexample
6326 int *ptr = @var{something};
6327 volatile int vobj;
6328 *ptr = @var{something};
6329 vobj = 1;
6330 @end smallexample
6331
6332 @noindent
6333 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
6334 that the write to @var{*ptr} occurs by the time the update
6335 of @var{vobj} happens.  If you need this guarantee, you must use
6336 a stronger memory barrier such as:
6337
6338 @smallexample
6339 int *ptr = @var{something};
6340 volatile int vobj;
6341 *ptr = @var{something};
6342 asm volatile ("" : : : "memory");
6343 vobj = 1;
6344 @end smallexample
6345
6346 A scalar volatile object is read when it is accessed in a void context:
6347
6348 @smallexample
6349 volatile int *src = @var{somevalue};
6350 *src;
6351 @end smallexample
6352
6353 Such expressions are rvalues, and GCC implements this as a
6354 read of the volatile object being pointed to.
6355
6356 Assignments are also expressions and have an rvalue.  However when
6357 assigning to a scalar volatile, the volatile object is not reread,
6358 regardless of whether the assignment expression's rvalue is used or
6359 not.  If the assignment's rvalue is used, the value is that assigned
6360 to the volatile object.  For instance, there is no read of @var{vobj}
6361 in all the following cases:
6362
6363 @smallexample
6364 int obj;
6365 volatile int vobj;
6366 vobj = @var{something};
6367 obj = vobj = @var{something};
6368 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
6369 obj = (@var{something}, vobj = @var{anotherthing});
6370 @end smallexample
6371
6372 If you need to read the volatile object after an assignment has
6373 occurred, you must use a separate expression with an intervening
6374 sequence point.
6375
6376 As bit-fields are not individually addressable, volatile bit-fields may
6377 be implicitly read when written to, or when adjacent bit-fields are
6378 accessed.  Bit-field operations may be optimized such that adjacent
6379 bit-fields are only partially accessed, if they straddle a storage unit
6380 boundary.  For these reasons it is unwise to use volatile bit-fields to
6381 access hardware.
6382
6383 @node Using Assembly Language with C
6384 @section How to Use Inline Assembly Language in C Code
6385
6386 GCC provides various extensions that allow you to embed assembler within 
6387 C code.
6388
6389 @menu
6390 * Basic Asm::          Inline assembler with no operands.
6391 * Extended Asm::       Inline assembler with operands.
6392 * Constraints::        Constraints for @code{asm} operands
6393 * Asm Labels::         Specifying the assembler name to use for a C symbol.
6394 * Explicit Reg Vars::  Defining variables residing in specified registers.
6395 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
6396 @end menu
6397
6398 @node Basic Asm
6399 @subsection Basic Asm --- Assembler Instructions with No Operands
6400 @cindex basic @code{asm}
6401
6402 The @code{asm} keyword allows you to embed assembler instructions within 
6403 C code.
6404
6405 @example
6406 asm [ volatile ] ( AssemblerInstructions )
6407 @end example
6408
6409 To create headers compatible with ISO C, write @code{__asm__} instead of 
6410 @code{asm} (@pxref{Alternate Keywords}).
6411
6412 By definition, a Basic @code{asm} statement is one with no operands. 
6413 @code{asm} statements that contain one or more colons (used to delineate 
6414 operands) are considered to be Extended (for example, @code{asm("int $3")} 
6415 is Basic, and @code{asm("int $3" : )} is Extended). @xref{Extended Asm}.
6416
6417 @subsubheading Qualifiers
6418 @emph{volatile}
6419 @*
6420 This optional qualifier has no effect. All Basic @code{asm} blocks are 
6421 implicitly volatile.
6422
6423 @subsubheading Parameters
6424 @emph{AssemblerInstructions}
6425 @*
6426 This is a literal string that specifies the assembler code. The string can 
6427 contain any instructions recognized by the assembler, including directives. 
6428 GCC does not parse the assembler instructions themselves and 
6429 does not know what they mean or even whether they are valid assembler input. 
6430 The compiler copies it verbatim to the assembly language output file, without 
6431 processing dialects or any of the "%" operators that are available with
6432 Extended @code{asm}. This results in minor differences between Basic 
6433 @code{asm} strings and Extended @code{asm} templates. For example, to refer to 
6434 registers you might use %%eax in Extended @code{asm} and %eax in Basic 
6435 @code{asm}.
6436
6437 You may place multiple assembler instructions together in a single @code{asm} 
6438 string, separated by the characters normally used in assembly code for the 
6439 system. A combination that works in most places is a newline to break the 
6440 line, plus a tab character (written as "\n\t").
6441 Some assemblers allow semicolons as a line separator. However, 
6442 note that some assembler dialects use semicolons to start a comment. 
6443
6444 Do not expect a sequence of @code{asm} statements to remain perfectly 
6445 consecutive after compilation. If certain instructions need to remain 
6446 consecutive in the output, put them in a single multi-instruction asm 
6447 statement. Note that GCC's optimizers can move @code{asm} statements 
6448 relative to other code, including across jumps.
6449
6450 @code{asm} statements may not perform jumps into other @code{asm} statements. 
6451 GCC does not know about these jumps, and therefore cannot take 
6452 account of them when deciding how to optimize. Jumps from @code{asm} to C 
6453 labels are only supported in Extended @code{asm}.
6454
6455 @subsubheading Remarks
6456 Using Extended @code{asm} will typically produce smaller, safer, and more 
6457 efficient code, and in most cases it is a better solution. When writing 
6458 inline assembly language outside of C functions, however, you must use Basic 
6459 @code{asm}. Extended @code{asm} statements have to be inside a C function.
6460 Functions declared with the @code{naked} attribute also require Basic 
6461 @code{asm} (@pxref{Function Attributes}).
6462
6463 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6464 assembly code when optimizing. This can lead to unexpected duplicate 
6465 symbol errors during compilation if your assembly code defines symbols or 
6466 labels.
6467
6468 Safely accessing C data and calling functions from Basic @code{asm} is more 
6469 complex than it may appear. To access C data, it is better to use Extended 
6470 @code{asm}.
6471
6472 Since GCC does not parse the AssemblerInstructions, it has no 
6473 visibility of any symbols it references. This may result in GCC discarding 
6474 those symbols as unreferenced.
6475
6476 Unlike Extended @code{asm}, all Basic @code{asm} blocks are implicitly 
6477 volatile. @xref{Volatile}.  Similarly, Basic @code{asm} blocks are not treated 
6478 as though they used a "memory" clobber (@pxref{Clobbers}).
6479
6480 All Basic @code{asm} blocks use the assembler dialect specified by the 
6481 @option{-masm} command-line option. Basic @code{asm} provides no
6482 mechanism to provide different assembler strings for different dialects.
6483
6484 Here is an example of Basic @code{asm} for i386:
6485
6486 @example
6487 /* Note that this code will not compile with -masm=intel */
6488 #define DebugBreak() asm("int $3")
6489 @end example
6490
6491 @node Extended Asm
6492 @subsection Extended Asm - Assembler Instructions with C Expression Operands
6493 @cindex @code{asm} keyword
6494 @cindex extended @code{asm}
6495 @cindex assembler instructions
6496
6497 The @code{asm} keyword allows you to embed assembler instructions within C 
6498 code. With Extended @code{asm} you can read and write C variables from 
6499 assembler and perform jumps from assembler code to C labels.
6500
6501 @example
6502 @ifhtml
6503 asm [volatile] ( AssemblerTemplate : [OutputOperands] [ : [InputOperands] [ : [Clobbers] ] ] )
6504
6505 asm [volatile] goto ( AssemblerTemplate : : [InputOperands] : [Clobbers] : GotoLabels )
6506 @end ifhtml
6507 @ifnothtml
6508 asm [volatile] ( AssemblerTemplate 
6509                  : [OutputOperands] 
6510                  [ : [InputOperands] 
6511                  [ : [Clobbers] ] ])
6512
6513 asm [volatile] goto ( AssemblerTemplate 
6514                       : 
6515                       : [InputOperands] 
6516                       : [Clobbers] 
6517                       : GotoLabels)
6518 @end ifnothtml
6519 @end example
6520
6521 To create headers compatible with ISO C, write @code{__asm__} instead of 
6522 @code{asm} and @code{__volatile__} instead of @code{volatile} 
6523 (@pxref{Alternate Keywords}). There is no alternate for @code{goto}.
6524
6525 By definition, Extended @code{asm} is an @code{asm} statement that contains 
6526 operands. To separate the classes of operands, you use colons. Basic 
6527 @code{asm} statements contain no colons. (So, for example, 
6528 @code{asm("int $3")} is Basic @code{asm}, and @code{asm("int $3" : )} is 
6529 Extended @code{asm}. @pxref{Basic Asm}.)
6530
6531 @subsubheading Qualifiers
6532 @emph{volatile}
6533 @*
6534 The typical use of Extended @code{asm} statements is to manipulate input 
6535 values to produce output values. However, your @code{asm} statements may 
6536 also produce side effects. If so, you may need to use the @code{volatile} 
6537 qualifier to disable certain optimizations. @xref{Volatile}.
6538
6539 @emph{goto}
6540 @*
6541 This qualifier informs the compiler that the @code{asm} statement may 
6542 perform a jump to one of the labels listed in the GotoLabels section. 
6543 @xref{GotoLabels}.
6544
6545 @subsubheading Parameters
6546 @emph{AssemblerTemplate}
6547 @*
6548 This is a literal string that contains the assembler code. It is a 
6549 combination of fixed text and tokens that refer to the input, output, 
6550 and goto parameters. @xref{AssemblerTemplate}.
6551
6552 @emph{OutputOperands}
6553 @*
6554 A comma-separated list of the C variables modified by the instructions in the 
6555 AssemblerTemplate. @xref{OutputOperands}.
6556
6557 @emph{InputOperands}
6558 @*
6559 A comma-separated list of C expressions read by the instructions in the 
6560 AssemblerTemplate. @xref{InputOperands}.
6561
6562 @emph{Clobbers}
6563 @*
6564 A comma-separated list of registers or other values changed by the 
6565 AssemblerTemplate, beyond those listed as outputs. @xref{Clobbers}.
6566
6567 @emph{GotoLabels}
6568 @*
6569 When you are using the @code{goto} form of @code{asm}, this section contains 
6570 the list of all C labels to which the AssemblerTemplate may jump. 
6571 @xref{GotoLabels}.
6572
6573 @subsubheading Remarks
6574 The @code{asm} statement allows you to include assembly instructions directly 
6575 within C code. This may help you to maximize performance in time-sensitive 
6576 code or to access assembly instructions that are not readily available to C 
6577 programs.
6578
6579 Note that Extended @code{asm} statements must be inside a function. Only 
6580 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
6581 Functions declared with the @code{naked} attribute also require Basic 
6582 @code{asm} (@pxref{Function Attributes}).
6583
6584 While the uses of @code{asm} are many and varied, it may help to think of an 
6585 @code{asm} statement as a series of low-level instructions that convert input 
6586 parameters to output parameters. So a simple (if not particularly useful) 
6587 example for i386 using @code{asm} might look like this:
6588
6589 @example
6590 int src = 1;
6591 int dst;   
6592
6593 asm ("mov %1, %0\n\t"
6594     "add $1, %0"
6595     : "=r" (dst) 
6596     : "r" (src));
6597
6598 printf("%d\n", dst);
6599 @end example
6600
6601 This code will copy @var{src} to @var{dst} and add 1 to @var{dst}.
6602
6603 @anchor{Volatile}
6604 @subsubsection Volatile
6605 @cindex volatile @code{asm}
6606 @cindex @code{asm} volatile
6607
6608 GCC's optimizers sometimes discard @code{asm} statements if they determine 
6609 there is no need for the output variables. Also, the optimizers may move 
6610 code out of loops if they believe that the code will always return the same 
6611 result (i.e. none of its input values change between calls). Using the 
6612 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
6613 that have no output operands are implicitly volatile.
6614
6615 Examples:
6616
6617 This i386 code demonstrates a case that does not use (or require) the 
6618 @code{volatile} qualifier. If it is performing assertion checking, this code 
6619 uses @code{asm} to perform the validation. Otherwise, @var{dwRes} is 
6620 unreferenced by any code. As a result, the optimizers can discard the 
6621 @code{asm} statement, which in turn removes the need for the entire 
6622 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
6623 isn't needed you allow the optimizers to produce the most efficient code 
6624 possible.
6625
6626 @example
6627 void DoCheck(uint32_t dwSomeValue)
6628 @{
6629    uint32_t dwRes;
6630
6631    // Assumes dwSomeValue is not zero.
6632    asm ("bsfl %1,%0"
6633      : "=r" (dwRes)
6634      : "r" (dwSomeValue)
6635      : "cc");
6636
6637    assert(dwRes > 3);
6638 @}
6639 @end example
6640
6641 The next example shows a case where the optimizers can recognize that the input 
6642 (@var{dwSomeValue}) never changes during the execution of the function and can 
6643 therefore move the @code{asm} outside the loop to produce more efficient code. 
6644 Again, using @code{volatile} disables this type of optimization.
6645
6646 @example
6647 void do_print(uint32_t dwSomeValue)
6648 @{
6649    uint32_t dwRes;
6650
6651    for (uint32_t x=0; x < 5; x++)
6652    @{
6653       // Assumes dwSomeValue is not zero.
6654       asm ("bsfl %1,%0"
6655         : "=r" (dwRes)
6656         : "r" (dwSomeValue)
6657         : "cc");
6658
6659       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
6660    @}
6661 @}
6662 @end example
6663
6664 The following example demonstrates a case where you need to use the 
6665 @code{volatile} qualifier. It uses the x86 RDTSC instruction, which reads 
6666 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
6667 the optimizers might assume that the @code{asm} block will always return the 
6668 same value and therefore optimize away the second call.
6669
6670 @example
6671 uint64_t msr;
6672
6673 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6674         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6675         "or %%rdx, %0"        // 'Or' in the lower bits.
6676         : "=a" (msr)
6677         : 
6678         : "rdx");
6679
6680 printf("msr: %llx\n", msr);
6681
6682 // Do other work...
6683
6684 // Reprint the timestamp
6685 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
6686         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
6687         "or %%rdx, %0"        // 'Or' in the lower bits.
6688         : "=a" (msr)
6689         : 
6690         : "rdx");
6691
6692 printf("msr: %llx\n", msr);
6693 @end example
6694
6695 GCC's optimizers will not treat this code like the non-volatile code in the 
6696 earlier examples. They do not move it out of loops or omit it on the 
6697 assumption that the result from a previous call is still valid.
6698
6699 Note that the compiler can move even volatile @code{asm} instructions relative 
6700 to other code, including across jump instructions. For example, on many 
6701 targets there is a system register that controls the rounding mode of 
6702 floating-point operations. Setting it with a volatile @code{asm}, as in the 
6703 following PowerPC example, will not work reliably.
6704
6705 @example
6706 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
6707 sum = x + y;
6708 @end example
6709
6710 The compiler may move the addition back before the volatile @code{asm}. To 
6711 make it work as expected, add an artificial dependency to the @code{asm} by 
6712 referencing a variable in the subsequent code, for example: 
6713
6714 @example
6715 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
6716 sum = x + y;
6717 @end example
6718
6719 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
6720 assembly code when optimizing. This can lead to unexpected duplicate symbol 
6721 errors during compilation if your asm code defines symbols or labels. Using %= 
6722 (@pxref{AssemblerTemplate}) may help resolve this problem.
6723
6724 @anchor{AssemblerTemplate}
6725 @subsubsection Assembler Template
6726 @cindex @code{asm} assembler template
6727
6728 An assembler template is a literal string containing assembler instructions. 
6729 The compiler will replace any references to inputs, outputs, and goto labels 
6730 in the template, and then output the resulting string to the assembler. The 
6731 string can contain any instructions recognized by the assembler, including 
6732 directives. GCC does not parse the assembler instructions 
6733 themselves and does not know what they mean or even whether they are valid 
6734 assembler input. However, it does count the statements 
6735 (@pxref{Size of an asm}).
6736
6737 You may place multiple assembler instructions together in a single @code{asm} 
6738 string, separated by the characters normally used in assembly code for the 
6739 system. A combination that works in most places is a newline to break the 
6740 line, plus a tab character to move to the instruction field (written as 
6741 "\n\t"). Some assemblers allow semicolons as a line separator. However, note 
6742 that some assembler dialects use semicolons to start a comment. 
6743
6744 Do not expect a sequence of @code{asm} statements to remain perfectly 
6745 consecutive after compilation, even when you are using the @code{volatile} 
6746 qualifier. If certain instructions need to remain consecutive in the output, 
6747 put them in a single multi-instruction asm statement.
6748
6749 Accessing data from C programs without using input/output operands (such as 
6750 by using global symbols directly from the assembler template) may not work as 
6751 expected. Similarly, calling functions directly from an assembler template 
6752 requires a detailed understanding of the target assembler and ABI.
6753
6754 Since GCC does not parse the AssemblerTemplate, it has no visibility of any 
6755 symbols it references. This may result in GCC discarding those symbols as 
6756 unreferenced unless they are also listed as input, output, or goto operands.
6757
6758 GCC can support multiple assembler dialects (for example, GCC for x86 
6759 supports "att" and "intel" dialects) for inline assembler. In builds that 
6760 support this capability, the @option{-masm} option controls which dialect 
6761 GCC uses as its default. The hardware-specific documentation for the 
6762 @option{-masm} option contains the list of supported dialects, as well as the 
6763 default dialect if the option is not specified. This information may be 
6764 important to understand, since assembler code that works correctly when 
6765 compiled using one dialect will likely fail if compiled using another.
6766
6767 @subsubheading Using braces in @code{asm} templates
6768
6769 If your code needs to support multiple assembler dialects (for example, if 
6770 you are writing public headers that need to support a variety of compilation 
6771 options), use constructs of this form:
6772
6773 @example
6774 @{ dialect0 | dialect1 | dialect2... @}
6775 @end example
6776
6777 This construct outputs 'dialect0' when using dialect #0 to compile the code, 
6778 'dialect1' for dialect #1, etc. If there are fewer alternatives within the 
6779 braces than the number of dialects the compiler supports, the construct 
6780 outputs nothing.
6781
6782 For example, if an x86 compiler supports two dialects (att, intel), an 
6783 assembler template such as this:
6784
6785 @example
6786 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
6787 @end example
6788
6789 would produce the output:
6790
6791 @example
6792 For att: "btl %[Offset],%[Base] ; jc %l2"
6793 For intel: "bt %[Base],%[Offset]; jc %l2"
6794 @end example
6795
6796 Using that same compiler, this code:
6797
6798 @example
6799 "xchg@{l@}\t@{%%@}ebx, %1"
6800 @end example
6801
6802 would produce 
6803
6804 @example
6805 For att: "xchgl\t%%ebx, %1"
6806 For intel: "xchg\tebx, %1"
6807 @end example
6808
6809 There is no support for nesting dialect alternatives. Also, there is no 
6810 ``escape'' for an open brace (@{), so do not use open braces in an Extended 
6811 @code{asm} template other than as a dialect indicator.
6812
6813 @subsubheading Other format strings
6814
6815 In addition to the tokens described by the input, output, and goto operands, 
6816 there are a few special cases:
6817
6818 @itemize
6819 @item
6820 "%%" outputs a single "%" into the assembler code.
6821
6822 @item
6823 "%=" outputs a number that is unique to each instance of the @code{asm} 
6824 statement in the entire compilation. This option is useful when creating local 
6825 labels and referring to them multiple times in a single template that 
6826 generates multiple assembler instructions. 
6827
6828 @end itemize
6829
6830 @anchor{OutputOperands}
6831 @subsubsection Output Operands
6832 @cindex @code{asm} output operands
6833
6834 An @code{asm} statement has zero or more output operands indicating the names
6835 of C variables modified by the assembler code.
6836
6837 In this i386 example, @var{old} (referred to in the template string as 
6838 @code{%0}) and @var{*Base} (as @code{%1}) are outputs and @var{Offset} 
6839 (@code{%2}) is an input:
6840
6841 @example
6842 bool old;
6843
6844 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
6845          "sbb %0,%0"      // Use the CF to calculate old.
6846    : "=r" (old), "+rm" (*Base)
6847    : "Ir" (Offset)
6848    : "cc");
6849
6850 return old;
6851 @end example
6852
6853 Operands use this format:
6854
6855 @example
6856 [ [asmSymbolicName] ] "constraint" (cvariablename)
6857 @end example
6858
6859 @emph{asmSymbolicName}
6860 @*
6861
6862 When not using asmSymbolicNames, use the (zero-based) position of the operand 
6863 in the list of operands in the assembler template. For example if there are 
6864 three output operands, use @code{%0} in the template to refer to the first, 
6865 @code{%1} for the second, and @code{%2} for the third. When using an 
6866 asmSymbolicName, reference it by enclosing the name in square brackets 
6867 (i.e. @code{%[Value]}). The scope of the name is the @code{asm} statement 
6868 that contains the definition. Any valid C variable name is acceptable, 
6869 including names already defined in the surrounding code. No two operands 
6870 within the same @code{asm} statement can use the same symbolic name.
6871
6872 @emph{constraint}
6873 @*
6874 Output constraints must begin with either @code{"="} (a variable overwriting an 
6875 existing value) or @code{"+"} (when reading and writing). When using 
6876 @code{"="}, do not assume the location will contain the existing value (except 
6877 when tying the variable to an input; @pxref{InputOperands,,Input Operands}).
6878
6879 After the prefix, there must be one or more additional constraints 
6880 (@pxref{Constraints}) that describe where the value resides. Common 
6881 constraints include @code{"r"} for register and @code{"m"} for memory. 
6882 When you list more than one possible location (for example @code{"=rm"}), the 
6883 compiler chooses the most efficient one based on the current context. If you 
6884 list as many alternates as the @code{asm} statement allows, you will permit 
6885 the optimizers to produce the best possible code. If you must use a specific
6886 register, but your Machine Constraints do not provide sufficient 
6887 control to select the specific register you want, Local Reg Vars may provide 
6888 a solution (@pxref{Local Reg Vars}).
6889
6890 @emph{cvariablename}
6891 @*
6892 Specifies the C variable name of the output (enclosed by parentheses). Accepts 
6893 any (non-constant) variable within scope.
6894
6895 Remarks:
6896
6897 The total number of input + output + goto operands has a limit of 30. Commas 
6898 separate the operands. When the compiler selects the registers to use to 
6899 represent the output operands, it will not use any of the clobbered registers 
6900 (@pxref{Clobbers}).
6901
6902 Output operand expressions must be lvalues. The compiler cannot check whether 
6903 the operands have data types that are reasonable for the instruction being 
6904 executed. For output expressions that are not directly addressable (for 
6905 example a bit-field), the constraint must allow a register. In that case, GCC 
6906 uses the register as the output of the @code{asm}, and then stores that 
6907 register into the output. 
6908
6909 Unless an output operand has the '@code{&}' constraint modifier 
6910 (@pxref{Modifiers}), GCC may allocate it in the same register as an unrelated 
6911 input operand, on the assumption that the assembler code will consume its 
6912 inputs before producing outputs. This assumption may be false if the assembler 
6913 code actually consists of more than one instruction. In this case, use 
6914 '@code{&}' on each output operand that must not overlap an input.
6915
6916 The same problem can occur if one output parameter (@var{a}) allows a register 
6917 constraint and another output parameter (@var{b}) allows a memory constraint.
6918 The code generated by GCC to access the memory address in @var{b} can contain
6919 registers which @emph{might} be shared by @var{a}, and GCC considers those 
6920 registers to be inputs to the asm. As above, GCC assumes that such input
6921 registers are consumed before any outputs are written. This assumption may 
6922 result in incorrect behavior if the asm writes to @var{a} before using 
6923 @var{b}. Combining the `@code{&}' constraint with the register constraint 
6924 ensures that modifying @var{a} will not affect what address is referenced by 
6925 @var{b}. Omitting the `@code{&}' constraint means that the location of @var{b} 
6926 will be undefined if @var{a} is modified before using @var{b}.
6927
6928 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
6929 instead of simply @code{%2}). Typically these qualifiers are hardware 
6930 dependent. The list of supported modifiers for x86 is found at 
6931 @ref{x86Operandmodifiers,x86 Operand modifiers}.
6932
6933 If the C code that follows the @code{asm} makes no use of any of the output 
6934 operands, use @code{volatile} for the @code{asm} statement to prevent the 
6935 optimizers from discarding the @code{asm} statement as unneeded 
6936 (see @ref{Volatile}).
6937
6938 Examples:
6939
6940 This code makes no use of the optional asmSymbolicName. Therefore it 
6941 references the first output operand as @code{%0} (were there a second, it 
6942 would be @code{%1}, etc). The number of the first input operand is one greater 
6943 than that of the last output operand. In this i386 example, that makes 
6944 @var{Mask} @code{%1}:
6945
6946 @example
6947 uint32_t Mask = 1234;
6948 uint32_t Index;
6949
6950   asm ("bsfl %1, %0"
6951      : "=r" (Index)
6952      : "r" (Mask)
6953      : "cc");
6954 @end example
6955
6956 That code overwrites the variable Index ("="), placing the value in a register 
6957 ("r"). The generic "r" constraint instead of a constraint for a specific 
6958 register allows the compiler to pick the register to use, which can result 
6959 in more efficient code. This may not be possible if an assembler instruction 
6960 requires a specific register.
6961
6962 The following i386 example uses the asmSymbolicName operand. It produces the 
6963 same result as the code above, but some may consider it more readable or more 
6964 maintainable since reordering index numbers is not necessary when adding or 
6965 removing operands. The names aIndex and aMask are only used to emphasize which 
6966 names get used where. It is acceptable to reuse the names Index and Mask.
6967
6968 @example
6969 uint32_t Mask = 1234;
6970 uint32_t Index;
6971
6972   asm ("bsfl %[aMask], %[aIndex]"
6973      : [aIndex] "=r" (Index)
6974      : [aMask] "r" (Mask)
6975      : "cc");
6976 @end example
6977
6978 Here are some more examples of output operands.
6979
6980 @example
6981 uint32_t c = 1;
6982 uint32_t d;
6983 uint32_t *e = &c;
6984
6985 asm ("mov %[e], %[d]"
6986    : [d] "=rm" (d)
6987    : [e] "rm" (*e));
6988 @end example
6989
6990 Here, @var{d} may either be in a register or in memory. Since the compiler 
6991 might already have the current value of the uint32_t pointed to by @var{e} 
6992 in a register, you can enable it to choose the best location
6993 for @var{d} by specifying both constraints.
6994
6995 @anchor{InputOperands}
6996 @subsubsection Input Operands
6997 @cindex @code{asm} input operands
6998 @cindex @code{asm} expressions
6999
7000 Input operands make inputs from C variables and expressions available to the 
7001 assembly code.
7002
7003 Specify input operands by using the format:
7004
7005 @example
7006 [ [asmSymbolicName] ] "constraint" (cexpression)
7007 @end example
7008
7009 @emph{asmSymbolicName}
7010 @*
7011 When not using asmSymbolicNames, use the (zero-based) position of the operand 
7012 in the list of operands, including outputs, in the assembler template. For 
7013 example, if there are two output parameters and three inputs, @code{%2} refers 
7014 to the first input, @code{%3} to the second, and @code{%4} to the third.
7015 When using an asmSymbolicName, reference it by enclosing the name in square 
7016 brackets (e.g. @code{%[Value]}). The scope of the name is the @code{asm} 
7017 statement that contains the definition. Any valid C variable name is 
7018 acceptable, including names already defined in the surrounding code. No two 
7019 operands within the same @code{asm} statement can use the same symbolic name.
7020
7021 @emph{constraint}
7022 @*
7023 Input constraints must be a string containing one or more constraints 
7024 (@pxref{Constraints}). When you give more than one possible constraint 
7025 (for example, @code{"irm"}), the compiler will choose the most efficient 
7026 method based on the current context. Input constraints may not begin with 
7027 either "=" or "+". If you must use a specific register, but your Machine
7028 Constraints do not provide sufficient control to select the specific 
7029 register you want, Local Reg Vars may provide a solution 
7030 (@pxref{Local Reg Vars}).
7031
7032 Input constraints can also be digits (for example, @code{"0"}). This indicates 
7033 that the specified input will be in the same place as the output constraint 
7034 at the (zero-based) index in the output constraint list. When using 
7035 asmSymbolicNames for the output operands, you may use these names (enclosed 
7036 in brackets []) instead of digits.
7037
7038 @emph{cexpression}
7039 @*
7040 This is the C variable or expression being passed to the @code{asm} statement 
7041 as input.
7042
7043 When the compiler selects the registers to use to represent the input 
7044 operands, it will not use any of the clobbered registers (@pxref{Clobbers}).
7045
7046 If there are no output operands but there are input operands, place two 
7047 consecutive colons where the output operands would go:
7048
7049 @example
7050 __asm__ ("some instructions"
7051    : /* No outputs. */
7052    : "r" (Offset / 8);
7053 @end example
7054
7055 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
7056 (except for inputs tied to outputs). The compiler assumes that on exit from 
7057 the @code{asm} statement these operands will contain the same values as they 
7058 had before executing the assembler. It is @emph{not} possible to use Clobbers 
7059 to inform the compiler that the values in these inputs are changing. One 
7060 common work-around is to tie the changing input variable to an output variable 
7061 that never gets used. Note, however, that if the code that follows the 
7062 @code{asm} statement makes no use of any of the output operands, the GCC 
7063 optimizers may discard the @code{asm} statement as unneeded 
7064 (see @ref{Volatile}).
7065
7066 Remarks:
7067
7068 The total number of input + output + goto operands has a limit of 30.
7069
7070 @code{asm} supports operand modifiers on operands (for example @code{%k2} 
7071 instead of simply @code{%2}). Typically these qualifiers are hardware 
7072 dependent. The list of supported modifiers for x86 is found at 
7073 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7074
7075 Examples:
7076
7077 In this example using the fictitious @code{combine} instruction, the 
7078 constraint @code{"0"} for input operand 1 says that it must occupy the same 
7079 location as output operand 0. Only input operands may use numbers in 
7080 constraints, and they must each refer to an output operand. Only a number (or 
7081 the symbolic assembler name) in the constraint can guarantee that one operand 
7082 is in the same place as another. The mere fact that @var{foo} is the value of 
7083 both operands is not enough to guarantee that they are in the same place in 
7084 the generated assembler code.
7085
7086 @example
7087 asm ("combine %2, %0" 
7088    : "=r" (foo) 
7089    : "0" (foo), "g" (bar));
7090 @end example
7091
7092 Here is an example using symbolic names.
7093
7094 @example
7095 asm ("cmoveq %1, %2, %[result]" 
7096    : [result] "=r"(result) 
7097    : "r" (test), "r" (new), "[result]" (old));
7098 @end example
7099
7100 @anchor{Clobbers}
7101 @subsubsection Clobbers
7102 @cindex @code{asm} clobbers
7103
7104 While the compiler is aware of changes to entries listed in the output 
7105 operands, the assembler code may modify more than just the outputs. For 
7106 example, calculations may require additional registers, or the processor may 
7107 overwrite a register as a side effect of a particular assembler instruction. 
7108 In order to inform the compiler of these changes, list them in the clobber 
7109 list. Clobber list items are either register names or the special clobbers 
7110 (listed below). Each clobber list item is enclosed in double quotes and 
7111 separated by commas.
7112
7113 Clobber descriptions may not in any way overlap with an input or output 
7114 operand. For example, you may not have an operand describing a register class 
7115 with one member when listing that register in the clobber list. Variables 
7116 declared to live in specific registers (@pxref{Explicit Reg Vars}), and used 
7117 as @code{asm} input or output operands, must have no part mentioned in the 
7118 clobber description. In particular, there is no way to specify that input 
7119 operands get modified without also specifying them as output operands.
7120
7121 When the compiler selects which registers to use to represent input and output 
7122 operands, it will not use any of the clobbered registers. As a result, 
7123 clobbered registers are available for any use in the assembler code.
7124
7125 Here is a realistic example for the VAX showing the use of clobbered 
7126 registers: 
7127
7128 @example
7129 asm volatile ("movc3 %0, %1, %2"
7130                    : /* No outputs. */
7131                    : "g" (from), "g" (to), "g" (count)
7132                    : "r0", "r1", "r2", "r3", "r4", "r5");
7133 @end example
7134
7135 Also, there are two special clobber arguments:
7136
7137 @enumerate
7138 @item
7139 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
7140 register. On some machines, GCC represents the condition codes as a specific 
7141 hardware register; "cc" serves to name this register. On other machines, 
7142 condition code handling is different, and specifying "cc" has no effect. But 
7143 it is valid no matter what the machine.
7144
7145 @item
7146 The "memory" clobber tells the compiler that the assembly code performs memory 
7147 reads or writes to items other than those listed in the input and output 
7148 operands (for example accessing the memory pointed to by one of the input 
7149 parameters). To ensure memory contains correct values, GCC may need to flush 
7150 specific register values to memory before executing the @code{asm}. Further, 
7151 the compiler will not assume that any values read from memory before an 
7152 @code{asm} will remain unchanged after that @code{asm}; it will reload them as 
7153 needed. This effectively forms a read/write memory barrier for the compiler.
7154
7155 Note that this clobber does not prevent the @emph{processor} from doing 
7156 speculative reads past the @code{asm} statement. To prevent that, you need 
7157 processor-specific fence instructions.
7158
7159 Flushing registers to memory has performance implications and may be an issue 
7160 for time-sensitive code. One trick to avoid this is available if the size of 
7161 the memory being accessed is known at compile time. For example, if accessing 
7162 ten bytes of a string, use a memory input like: 
7163
7164 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
7165
7166 @end enumerate
7167
7168 @anchor{GotoLabels}
7169 @subsubsection Goto Labels
7170 @cindex @code{asm} goto labels
7171
7172 @code{asm goto} allows assembly code to jump to one or more C labels. The 
7173 GotoLabels section in an @code{asm goto} statement contains a comma-separated 
7174 list of all C labels to which the assembler code may jump. GCC assumes that 
7175 @code{asm} execution falls through to the next statement (if this is not the 
7176 case, consider using the @code{__builtin_unreachable} intrinsic after the 
7177 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
7178 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
7179 Attributes}). The total number of input + output + goto operands has 
7180 a limit of 30.
7181
7182 An @code{asm goto} statement can not have outputs (which means that the 
7183 statement is implicitly volatile). This is due to an internal restriction of 
7184 the compiler: control transfer instructions cannot have outputs. If the 
7185 assembler code does modify anything, use the "memory" clobber to force the 
7186 optimizers to flush all register values to memory, and reload them if 
7187 necessary, after the @code{asm} statement.
7188
7189 To reference a label, prefix it with @code{%l} (that's a lowercase L) followed 
7190 by its (zero-based) position in GotoLabels plus the number of input 
7191 arguments.  For example, if the @code{asm} has three inputs and references two 
7192 labels, refer to the first label as @code{%l3} and the second as @code{%l4}).
7193
7194 @code{asm} statements may not perform jumps into other @code{asm} statements. 
7195 GCC's optimizers do not know about these jumps; therefore they cannot take 
7196 account of them when deciding how to optimize.
7197
7198 Example code for i386 might look like:
7199
7200 @example
7201 asm goto (
7202     "btl %1, %0\n\t"
7203     "jc %l2"
7204     : /* No outputs. */
7205     : "r" (p1), "r" (p2) 
7206     : "cc" 
7207     : carry);
7208
7209 return 0;
7210
7211 carry:
7212 return 1;
7213 @end example
7214
7215 The following example shows an @code{asm goto} that uses the memory clobber.
7216
7217 @example
7218 int frob(int x)
7219 @{
7220   int y;
7221   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
7222             : /* No outputs. */
7223             : "r"(x), "r"(&y)
7224             : "r5", "memory" 
7225             : error);
7226   return y;
7227 error:
7228   return -1;
7229 @}
7230 @end example
7231
7232 @anchor{x86Operandmodifiers}
7233 @subsubsection x86 Operand modifiers
7234
7235 Input, output, and goto operands for extended @code{asm} statements can use 
7236 modifiers to affect the code output to the assembler. For example, the 
7237 following code uses the "h" and "b" modifiers for x86:
7238
7239 @example
7240 uint16_t  num;
7241 asm volatile ("xchg %h0, %b0" : "+a" (num) );
7242 @end example
7243
7244 These modifiers generate this assembler code:
7245
7246 @example
7247 xchg %ah, %al
7248 @end example
7249
7250 The rest of this discussion uses the following code for illustrative purposes.
7251
7252 @example
7253 int main()
7254 @{
7255    int iInt = 1;
7256
7257 top:
7258
7259    asm volatile goto ("some assembler instructions here"
7260    : /* No outputs. */
7261    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
7262    : /* No clobbers. */
7263    : top);
7264 @}
7265 @end example
7266
7267 With no modifiers, this is what the output from the operands would be for the 
7268 att and intel dialects of assembler:
7269
7270 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
7271 @headitem Operand @tab masm=att @tab masm=intel
7272 @item @code{%0}
7273 @tab @code{%eax}
7274 @tab @code{eax}
7275 @item @code{%1}
7276 @tab @code{$2}
7277 @tab @code{2}
7278 @item @code{%2}
7279 @tab @code{$.L2}
7280 @tab @code{OFFSET FLAT:.L2}
7281 @end multitable
7282
7283 The table below shows the list of supported modifiers and their effects.
7284
7285 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
7286 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
7287 @item @code{z}
7288 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
7289 @tab @code{%z0}
7290 @tab @code{l}
7291 @tab 
7292 @item @code{b}
7293 @tab Print the QImode name of the register.
7294 @tab @code{%b0}
7295 @tab @code{%al}
7296 @tab @code{al}
7297 @item @code{h}
7298 @tab Print the QImode name for a ``high'' register.
7299 @tab @code{%h0}
7300 @tab @code{%ah}
7301 @tab @code{ah}
7302 @item @code{w}
7303 @tab Print the HImode name of the register.
7304 @tab @code{%w0}
7305 @tab @code{%ax}
7306 @tab @code{ax}
7307 @item @code{k}
7308 @tab Print the SImode name of the register.
7309 @tab @code{%k0}
7310 @tab @code{%eax}
7311 @tab @code{eax}
7312 @item @code{q}
7313 @tab Print the DImode name of the register.
7314 @tab @code{%q0}
7315 @tab @code{%rax}
7316 @tab @code{rax}
7317 @item @code{l}
7318 @tab Print the label name with no punctuation.
7319 @tab @code{%l2}
7320 @tab @code{.L2}
7321 @tab @code{.L2}
7322 @item @code{c}
7323 @tab Require a constant operand and print the constant expression with no punctuation.
7324 @tab @code{%c1}
7325 @tab @code{2}
7326 @tab @code{2}
7327 @end multitable
7328
7329 @anchor{x86floatingpointasmoperands}
7330 @subsubsection x86 floating-point asm operands
7331
7332 On x86 targets, there are several rules on the usage of stack-like registers
7333 in the operands of an @code{asm}.  These rules apply only to the operands
7334 that are stack-like registers:
7335
7336 @enumerate
7337 @item
7338 Given a set of input registers that die in an @code{asm}, it is
7339 necessary to know which are implicitly popped by the @code{asm}, and
7340 which must be explicitly popped by GCC@.
7341
7342 An input register that is implicitly popped by the @code{asm} must be
7343 explicitly clobbered, unless it is constrained to match an
7344 output operand.
7345
7346 @item
7347 For any input register that is implicitly popped by an @code{asm}, it is
7348 necessary to know how to adjust the stack to compensate for the pop.
7349 If any non-popped input is closer to the top of the reg-stack than
7350 the implicitly popped register, it would not be possible to know what the
7351 stack looked like---it's not clear how the rest of the stack ``slides
7352 up''.
7353
7354 All implicitly popped input registers must be closer to the top of
7355 the reg-stack than any input that is not implicitly popped.
7356
7357 It is possible that if an input dies in an @code{asm}, the compiler might
7358 use the input register for an output reload.  Consider this example:
7359
7360 @smallexample
7361 asm ("foo" : "=t" (a) : "f" (b));
7362 @end smallexample
7363
7364 @noindent
7365 This code says that input @code{b} is not popped by the @code{asm}, and that
7366 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
7367 deeper after the @code{asm} than it was before.  But, it is possible that
7368 reload may think that it can use the same register for both the input and
7369 the output.
7370
7371 To prevent this from happening,
7372 if any input operand uses the @code{f} constraint, all output register
7373 constraints must use the @code{&} early-clobber modifier.
7374
7375 The example above would be correctly written as:
7376
7377 @smallexample
7378 asm ("foo" : "=&t" (a) : "f" (b));
7379 @end smallexample
7380
7381 @item
7382 Some operands need to be in particular places on the stack.  All
7383 output operands fall in this category---GCC has no other way to
7384 know which registers the outputs appear in unless you indicate
7385 this in the constraints.
7386
7387 Output operands must specifically indicate which register an output
7388 appears in after an @code{asm}.  @code{=f} is not allowed: the operand
7389 constraints must select a class with a single register.
7390
7391 @item
7392 Output operands may not be ``inserted'' between existing stack registers.
7393 Since no 387 opcode uses a read/write operand, all output operands
7394 are dead before the @code{asm}, and are pushed by the @code{asm}.
7395 It makes no sense to push anywhere but the top of the reg-stack.
7396
7397 Output operands must start at the top of the reg-stack: output
7398 operands may not ``skip'' a register.
7399
7400 @item
7401 Some @code{asm} statements may need extra stack space for internal
7402 calculations.  This can be guaranteed by clobbering stack registers
7403 unrelated to the inputs and outputs.
7404
7405 @end enumerate
7406
7407 Here are a couple of reasonable @code{asm}s to want to write.  This
7408 @code{asm}
7409 takes one input, which is internally popped, and produces two outputs.
7410
7411 @smallexample
7412 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
7413 @end smallexample
7414
7415 @noindent
7416 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
7417 and replaces them with one output.  The @code{st(1)} clobber is necessary 
7418 for the compiler to know that @code{fyl2xp1} pops both inputs.
7419
7420 @smallexample
7421 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
7422 @end smallexample
7423
7424 @lowersections
7425 @include md.texi
7426 @raisesections
7427
7428 @node Asm Labels
7429 @subsection Controlling Names Used in Assembler Code
7430 @cindex assembler names for identifiers
7431 @cindex names used in assembler code
7432 @cindex identifiers, names in assembler code
7433
7434 You can specify the name to be used in the assembler code for a C
7435 function or variable by writing the @code{asm} (or @code{__asm__})
7436 keyword after the declarator as follows:
7437
7438 @smallexample
7439 int foo asm ("myfoo") = 2;
7440 @end smallexample
7441
7442 @noindent
7443 This specifies that the name to be used for the variable @code{foo} in
7444 the assembler code should be @samp{myfoo} rather than the usual
7445 @samp{_foo}.
7446
7447 On systems where an underscore is normally prepended to the name of a C
7448 function or variable, this feature allows you to define names for the
7449 linker that do not start with an underscore.
7450
7451 It does not make sense to use this feature with a non-static local
7452 variable since such variables do not have assembler names.  If you are
7453 trying to put the variable in a particular register, see @ref{Explicit
7454 Reg Vars}.  GCC presently accepts such code with a warning, but will
7455 probably be changed to issue an error, rather than a warning, in the
7456 future.
7457
7458 You cannot use @code{asm} in this way in a function @emph{definition}; but
7459 you can get the same effect by writing a declaration for the function
7460 before its definition and putting @code{asm} there, like this:
7461
7462 @smallexample
7463 extern func () asm ("FUNC");
7464
7465 func (x, y)
7466      int x, y;
7467 /* @r{@dots{}} */
7468 @end smallexample
7469
7470 It is up to you to make sure that the assembler names you choose do not
7471 conflict with any other assembler symbols.  Also, you must not use a
7472 register name; that would produce completely invalid assembler code.  GCC
7473 does not as yet have the ability to store static variables in registers.
7474 Perhaps that will be added.
7475
7476 @node Explicit Reg Vars
7477 @subsection Variables in Specified Registers
7478 @cindex explicit register variables
7479 @cindex variables in specified registers
7480 @cindex specified registers
7481 @cindex registers, global allocation
7482
7483 GNU C allows you to put a few global variables into specified hardware
7484 registers.  You can also specify the register in which an ordinary
7485 register variable should be allocated.
7486
7487 @itemize @bullet
7488 @item
7489 Global register variables reserve registers throughout the program.
7490 This may be useful in programs such as programming language
7491 interpreters that have a couple of global variables that are accessed
7492 very often.
7493
7494 @item
7495 Local register variables in specific registers do not reserve the
7496 registers, except at the point where they are used as input or output
7497 operands in an @code{asm} statement and the @code{asm} statement itself is
7498 not deleted.  The compiler's data flow analysis is capable of determining
7499 where the specified registers contain live values, and where they are
7500 available for other uses.  Stores into local register variables may be deleted
7501 when they appear to be dead according to dataflow analysis.  References
7502 to local register variables may be deleted or moved or simplified.
7503
7504 These local variables are sometimes convenient for use with the extended
7505 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
7506 output of the assembler instruction directly into a particular register.
7507 (This works provided the register you specify fits the constraints
7508 specified for that operand in the @code{asm}.)
7509 @end itemize
7510
7511 @menu
7512 * Global Reg Vars::
7513 * Local Reg Vars::
7514 @end menu
7515
7516 @node Global Reg Vars
7517 @subsubsection Defining Global Register Variables
7518 @cindex global register variables
7519 @cindex registers, global variables in
7520
7521 You can define a global register variable in GNU C like this:
7522
7523 @smallexample
7524 register int *foo asm ("a5");
7525 @end smallexample
7526
7527 @noindent
7528 Here @code{a5} is the name of the register that should be used.  Choose a
7529 register that is normally saved and restored by function calls on your
7530 machine, so that library routines will not clobber it.
7531
7532 Naturally the register name is cpu-dependent, so you need to
7533 conditionalize your program according to cpu type.  The register
7534 @code{a5} is a good choice on a 68000 for a variable of pointer
7535 type.  On machines with register windows, be sure to choose a ``global''
7536 register that is not affected magically by the function call mechanism.
7537
7538 In addition, different operating systems on the same CPU may differ in how they
7539 name the registers; then you need additional conditionals.  For
7540 example, some 68000 operating systems call this register @code{%a5}.
7541
7542 Eventually there may be a way of asking the compiler to choose a register
7543 automatically, but first we need to figure out how it should choose and
7544 how to enable you to guide the choice.  No solution is evident.
7545
7546 Defining a global register variable in a certain register reserves that
7547 register entirely for this use, at least within the current compilation.
7548 The register is not allocated for any other purpose in the functions
7549 in the current compilation, and is not saved and restored by
7550 these functions.  Stores into this register are never deleted even if they
7551 appear to be dead, but references may be deleted or moved or
7552 simplified.
7553
7554 It is not safe to access the global register variables from signal
7555 handlers, or from more than one thread of control, because the system
7556 library routines may temporarily use the register for other things (unless
7557 you recompile them specially for the task at hand).
7558
7559 @cindex @code{qsort}, and global register variables
7560 It is not safe for one function that uses a global register variable to
7561 call another such function @code{foo} by way of a third function
7562 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
7563 different source file in which the variable isn't declared).  This is
7564 because @code{lose} might save the register and put some other value there.
7565 For example, you can't expect a global register variable to be available in
7566 the comparison-function that you pass to @code{qsort}, since @code{qsort}
7567 might have put something else in that register.  (If you are prepared to
7568 recompile @code{qsort} with the same global register variable, you can
7569 solve this problem.)
7570
7571 If you want to recompile @code{qsort} or other source files that do not
7572 actually use your global register variable, so that they do not use that
7573 register for any other purpose, then it suffices to specify the compiler
7574 option @option{-ffixed-@var{reg}}.  You need not actually add a global
7575 register declaration to their source code.
7576
7577 A function that can alter the value of a global register variable cannot
7578 safely be called from a function compiled without this variable, because it
7579 could clobber the value the caller expects to find there on return.
7580 Therefore, the function that is the entry point into the part of the
7581 program that uses the global register variable must explicitly save and
7582 restore the value that belongs to its caller.
7583
7584 @cindex register variable after @code{longjmp}
7585 @cindex global register after @code{longjmp}
7586 @cindex value after @code{longjmp}
7587 @findex longjmp
7588 @findex setjmp
7589 On most machines, @code{longjmp} restores to each global register
7590 variable the value it had at the time of the @code{setjmp}.  On some
7591 machines, however, @code{longjmp} does not change the value of global
7592 register variables.  To be portable, the function that called @code{setjmp}
7593 should make other arrangements to save the values of the global register
7594 variables, and to restore them in a @code{longjmp}.  This way, the same
7595 thing happens regardless of what @code{longjmp} does.
7596
7597 All global register variable declarations must precede all function
7598 definitions.  If such a declaration could appear after function
7599 definitions, the declaration would be too late to prevent the register from
7600 being used for other purposes in the preceding functions.
7601
7602 Global register variables may not have initial values, because an
7603 executable file has no means to supply initial contents for a register.
7604
7605 On the SPARC, there are reports that g3 @dots{} g7 are suitable
7606 registers, but certain library functions, such as @code{getwd}, as well
7607 as the subroutines for division and remainder, modify g3 and g4.  g1 and
7608 g2 are local temporaries.
7609
7610 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
7611 Of course, it does not do to use more than a few of those.
7612
7613 @node Local Reg Vars
7614 @subsubsection Specifying Registers for Local Variables
7615 @cindex local variables, specifying registers
7616 @cindex specifying registers for local variables
7617 @cindex registers for local variables
7618
7619 You can define a local register variable with a specified register
7620 like this:
7621
7622 @smallexample
7623 register int *foo asm ("a5");
7624 @end smallexample
7625
7626 @noindent
7627 Here @code{a5} is the name of the register that should be used.  Note
7628 that this is the same syntax used for defining global register
7629 variables, but for a local variable it appears within a function.
7630
7631 Naturally the register name is cpu-dependent, but this is not a
7632 problem, since specific registers are most often useful with explicit
7633 assembler instructions (@pxref{Extended Asm}).  Both of these things
7634 generally require that you conditionalize your program according to
7635 cpu type.
7636
7637 In addition, operating systems on one type of cpu may differ in how they
7638 name the registers; then you need additional conditionals.  For
7639 example, some 68000 operating systems call this register @code{%a5}.
7640
7641 Defining such a register variable does not reserve the register; it
7642 remains available for other uses in places where flow control determines
7643 the variable's value is not live.
7644
7645 This option does not guarantee that GCC generates code that has
7646 this variable in the register you specify at all times.  You may not
7647 code an explicit reference to this register in the @emph{assembler
7648 instruction template} part of an @code{asm} statement and assume it
7649 always refers to this variable.  However, using the variable as an
7650 @code{asm} @emph{operand} guarantees that the specified register is used
7651 for the operand.
7652
7653 Stores into local register variables may be deleted when they appear to be dead
7654 according to dataflow analysis.  References to local register variables may
7655 be deleted or moved or simplified.
7656
7657 As with global register variables, it is recommended that you choose a
7658 register that is normally saved and restored by function calls on
7659 your machine, so that library routines will not clobber it.  
7660
7661 Sometimes when writing inline @code{asm} code, you need to make an operand be a 
7662 specific register, but there's no matching constraint letter for that 
7663 register. To force the operand into that register, create a local variable 
7664 and specify the register in the variable's declaration. Then use the local 
7665 variable for the asm operand and specify any constraint letter that matches 
7666 the register:
7667
7668 @smallexample
7669 register int *p1 asm ("r0") = @dots{};
7670 register int *p2 asm ("r1") = @dots{};
7671 register int *result asm ("r0");
7672 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7673 @end smallexample
7674
7675 @emph{Warning:} In the above example, be aware that a register (for example r0) can be 
7676 call-clobbered by subsequent code, including function calls and library calls 
7677 for arithmetic operators on other variables (for example the initialization 
7678 of p2). In this case, use temporary variables for expressions between the 
7679 register assignments:
7680
7681 @smallexample
7682 int t1 = @dots{};
7683 register int *p1 asm ("r0") = @dots{};
7684 register int *p2 asm ("r1") = t1;
7685 register int *result asm ("r0");
7686 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
7687 @end smallexample
7688
7689 @node Size of an asm
7690 @subsection Size of an @code{asm}
7691
7692 Some targets require that GCC track the size of each instruction used
7693 in order to generate correct code.  Because the final length of the
7694 code produced by an @code{asm} statement is only known by the
7695 assembler, GCC must make an estimate as to how big it will be.  It
7696 does this by counting the number of instructions in the pattern of the
7697 @code{asm} and multiplying that by the length of the longest
7698 instruction supported by that processor.  (When working out the number
7699 of instructions, it assumes that any occurrence of a newline or of
7700 whatever statement separator character is supported by the assembler --
7701 typically @samp{;} --- indicates the end of an instruction.)
7702
7703 Normally, GCC's estimate is adequate to ensure that correct
7704 code is generated, but it is possible to confuse the compiler if you use
7705 pseudo instructions or assembler macros that expand into multiple real
7706 instructions, or if you use assembler directives that expand to more
7707 space in the object file than is needed for a single instruction.
7708 If this happens then the assembler may produce a diagnostic saying that
7709 a label is unreachable.
7710
7711 @node Alternate Keywords
7712 @section Alternate Keywords
7713 @cindex alternate keywords
7714 @cindex keywords, alternate
7715
7716 @option{-ansi} and the various @option{-std} options disable certain
7717 keywords.  This causes trouble when you want to use GNU C extensions, or
7718 a general-purpose header file that should be usable by all programs,
7719 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
7720 @code{inline} are not available in programs compiled with
7721 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
7722 program compiled with @option{-std=c99} or @option{-std=c11}).  The
7723 ISO C99 keyword
7724 @code{restrict} is only available when @option{-std=gnu99} (which will
7725 eventually be the default) or @option{-std=c99} (or the equivalent
7726 @option{-std=iso9899:1999}), or an option for a later standard
7727 version, is used.
7728
7729 The way to solve these problems is to put @samp{__} at the beginning and
7730 end of each problematical keyword.  For example, use @code{__asm__}
7731 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
7732
7733 Other C compilers won't accept these alternative keywords; if you want to
7734 compile with another compiler, you can define the alternate keywords as
7735 macros to replace them with the customary keywords.  It looks like this:
7736
7737 @smallexample
7738 #ifndef __GNUC__
7739 #define __asm__ asm
7740 #endif
7741 @end smallexample
7742
7743 @findex __extension__
7744 @opindex pedantic
7745 @option{-pedantic} and other options cause warnings for many GNU C extensions.
7746 You can
7747 prevent such warnings within one expression by writing
7748 @code{__extension__} before the expression.  @code{__extension__} has no
7749 effect aside from this.
7750
7751 @node Incomplete Enums
7752 @section Incomplete @code{enum} Types
7753
7754 You can define an @code{enum} tag without specifying its possible values.
7755 This results in an incomplete type, much like what you get if you write
7756 @code{struct foo} without describing the elements.  A later declaration
7757 that does specify the possible values completes the type.
7758
7759 You can't allocate variables or storage using the type while it is
7760 incomplete.  However, you can work with pointers to that type.
7761
7762 This extension may not be very useful, but it makes the handling of
7763 @code{enum} more consistent with the way @code{struct} and @code{union}
7764 are handled.
7765
7766 This extension is not supported by GNU C++.
7767
7768 @node Function Names
7769 @section Function Names as Strings
7770 @cindex @code{__func__} identifier
7771 @cindex @code{__FUNCTION__} identifier
7772 @cindex @code{__PRETTY_FUNCTION__} identifier
7773
7774 GCC provides three magic variables that hold the name of the current
7775 function, as a string.  The first of these is @code{__func__}, which
7776 is part of the C99 standard:
7777
7778 The identifier @code{__func__} is implicitly declared by the translator
7779 as if, immediately following the opening brace of each function
7780 definition, the declaration
7781
7782 @smallexample
7783 static const char __func__[] = "function-name";
7784 @end smallexample
7785
7786 @noindent
7787 appeared, where function-name is the name of the lexically-enclosing
7788 function.  This name is the unadorned name of the function.
7789
7790 @code{__FUNCTION__} is another name for @code{__func__}.  Older
7791 versions of GCC recognize only this name.  However, it is not
7792 standardized.  For maximum portability, we recommend you use
7793 @code{__func__}, but provide a fallback definition with the
7794 preprocessor:
7795
7796 @smallexample
7797 #if __STDC_VERSION__ < 199901L
7798 # if __GNUC__ >= 2
7799 #  define __func__ __FUNCTION__
7800 # else
7801 #  define __func__ "<unknown>"
7802 # endif
7803 #endif
7804 @end smallexample
7805
7806 In C, @code{__PRETTY_FUNCTION__} is yet another name for
7807 @code{__func__}.  However, in C++, @code{__PRETTY_FUNCTION__} contains
7808 the type signature of the function as well as its bare name.  For
7809 example, this program:
7810
7811 @smallexample
7812 extern "C" @{
7813 extern int printf (char *, ...);
7814 @}
7815
7816 class a @{
7817  public:
7818   void sub (int i)
7819     @{
7820       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
7821       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
7822     @}
7823 @};
7824
7825 int
7826 main (void)
7827 @{
7828   a ax;
7829   ax.sub (0);
7830   return 0;
7831 @}
7832 @end smallexample
7833
7834 @noindent
7835 gives this output:
7836
7837 @smallexample
7838 __FUNCTION__ = sub
7839 __PRETTY_FUNCTION__ = void a::sub(int)
7840 @end smallexample
7841
7842 These identifiers are not preprocessor macros.  In GCC 3.3 and
7843 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
7844 were treated as string literals; they could be used to initialize
7845 @code{char} arrays, and they could be concatenated with other string
7846 literals.  GCC 3.4 and later treat them as variables, like
7847 @code{__func__}.  In C++, @code{__FUNCTION__} and
7848 @code{__PRETTY_FUNCTION__} have always been variables.
7849
7850 @node Return Address
7851 @section Getting the Return or Frame Address of a Function
7852
7853 These functions may be used to get information about the callers of a
7854 function.
7855
7856 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
7857 This function returns the return address of the current function, or of
7858 one of its callers.  The @var{level} argument is number of frames to
7859 scan up the call stack.  A value of @code{0} yields the return address
7860 of the current function, a value of @code{1} yields the return address
7861 of the caller of the current function, and so forth.  When inlining
7862 the expected behavior is that the function returns the address of
7863 the function that is returned to.  To work around this behavior use
7864 the @code{noinline} function attribute.
7865
7866 The @var{level} argument must be a constant integer.
7867
7868 On some machines it may be impossible to determine the return address of
7869 any function other than the current one; in such cases, or when the top
7870 of the stack has been reached, this function returns @code{0} or a
7871 random value.  In addition, @code{__builtin_frame_address} may be used
7872 to determine if the top of the stack has been reached.
7873
7874 Additional post-processing of the returned value may be needed, see
7875 @code{__builtin_extract_return_addr}.
7876
7877 This function should only be used with a nonzero argument for debugging
7878 purposes.
7879 @end deftypefn
7880
7881 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
7882 The address as returned by @code{__builtin_return_address} may have to be fed
7883 through this function to get the actual encoded address.  For example, on the
7884 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
7885 platforms an offset has to be added for the true next instruction to be
7886 executed.
7887
7888 If no fixup is needed, this function simply passes through @var{addr}.
7889 @end deftypefn
7890
7891 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
7892 This function does the reverse of @code{__builtin_extract_return_addr}.
7893 @end deftypefn
7894
7895 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
7896 This function is similar to @code{__builtin_return_address}, but it
7897 returns the address of the function frame rather than the return address
7898 of the function.  Calling @code{__builtin_frame_address} with a value of
7899 @code{0} yields the frame address of the current function, a value of
7900 @code{1} yields the frame address of the caller of the current function,
7901 and so forth.
7902
7903 The frame is the area on the stack that holds local variables and saved
7904 registers.  The frame address is normally the address of the first word
7905 pushed on to the stack by the function.  However, the exact definition
7906 depends upon the processor and the calling convention.  If the processor
7907 has a dedicated frame pointer register, and the function has a frame,
7908 then @code{__builtin_frame_address} returns the value of the frame
7909 pointer register.
7910
7911 On some machines it may be impossible to determine the frame address of
7912 any function other than the current one; in such cases, or when the top
7913 of the stack has been reached, this function returns @code{0} if
7914 the first frame pointer is properly initialized by the startup code.
7915
7916 This function should only be used with a nonzero argument for debugging
7917 purposes.
7918 @end deftypefn
7919
7920 @node Vector Extensions
7921 @section Using Vector Instructions through Built-in Functions
7922
7923 On some targets, the instruction set contains SIMD vector instructions which
7924 operate on multiple values contained in one large register at the same time.
7925 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
7926 this way.
7927
7928 The first step in using these extensions is to provide the necessary data
7929 types.  This should be done using an appropriate @code{typedef}:
7930
7931 @smallexample
7932 typedef int v4si __attribute__ ((vector_size (16)));
7933 @end smallexample
7934
7935 @noindent
7936 The @code{int} type specifies the base type, while the attribute specifies
7937 the vector size for the variable, measured in bytes.  For example, the
7938 declaration above causes the compiler to set the mode for the @code{v4si}
7939 type to be 16 bytes wide and divided into @code{int} sized units.  For
7940 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
7941 corresponding mode of @code{foo} is @acronym{V4SI}.
7942
7943 The @code{vector_size} attribute is only applicable to integral and
7944 float scalars, although arrays, pointers, and function return values
7945 are allowed in conjunction with this construct. Only sizes that are
7946 a power of two are currently allowed.
7947
7948 All the basic integer types can be used as base types, both as signed
7949 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
7950 @code{long long}.  In addition, @code{float} and @code{double} can be
7951 used to build floating-point vector types.
7952
7953 Specifying a combination that is not valid for the current architecture
7954 causes GCC to synthesize the instructions using a narrower mode.
7955 For example, if you specify a variable of type @code{V4SI} and your
7956 architecture does not allow for this specific SIMD type, GCC
7957 produces code that uses 4 @code{SIs}.
7958
7959 The types defined in this manner can be used with a subset of normal C
7960 operations.  Currently, GCC allows using the following operators
7961 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
7962
7963 The operations behave like C++ @code{valarrays}.  Addition is defined as
7964 the addition of the corresponding elements of the operands.  For
7965 example, in the code below, each of the 4 elements in @var{a} is
7966 added to the corresponding 4 elements in @var{b} and the resulting
7967 vector is stored in @var{c}.
7968
7969 @smallexample
7970 typedef int v4si __attribute__ ((vector_size (16)));
7971
7972 v4si a, b, c;
7973
7974 c = a + b;
7975 @end smallexample
7976
7977 Subtraction, multiplication, division, and the logical operations
7978 operate in a similar manner.  Likewise, the result of using the unary
7979 minus or complement operators on a vector type is a vector whose
7980 elements are the negative or complemented values of the corresponding
7981 elements in the operand.
7982
7983 It is possible to use shifting operators @code{<<}, @code{>>} on
7984 integer-type vectors. The operation is defined as following: @code{@{a0,
7985 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
7986 @dots{}, an >> bn@}}@. Vector operands must have the same number of
7987 elements. 
7988
7989 For convenience, it is allowed to use a binary vector operation
7990 where one operand is a scalar. In that case the compiler transforms
7991 the scalar operand into a vector where each element is the scalar from
7992 the operation. The transformation happens only if the scalar could be
7993 safely converted to the vector-element type.
7994 Consider the following code.
7995
7996 @smallexample
7997 typedef int v4si __attribute__ ((vector_size (16)));
7998
7999 v4si a, b, c;
8000 long l;
8001
8002 a = b + 1;    /* a = b + @{1,1,1,1@}; */
8003 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
8004
8005 a = l + a;    /* Error, cannot convert long to int. */
8006 @end smallexample
8007
8008 Vectors can be subscripted as if the vector were an array with
8009 the same number of elements and base type.  Out of bound accesses
8010 invoke undefined behavior at run time.  Warnings for out of bound
8011 accesses for vector subscription can be enabled with
8012 @option{-Warray-bounds}.
8013
8014 Vector comparison is supported with standard comparison
8015 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
8016 vector expressions of integer-type or real-type. Comparison between
8017 integer-type vectors and real-type vectors are not supported.  The
8018 result of the comparison is a vector of the same width and number of
8019 elements as the comparison operands with a signed integral element
8020 type.
8021
8022 Vectors are compared element-wise producing 0 when comparison is false
8023 and -1 (constant of the appropriate type where all bits are set)
8024 otherwise. Consider the following example.
8025
8026 @smallexample
8027 typedef int v4si __attribute__ ((vector_size (16)));
8028
8029 v4si a = @{1,2,3,4@};
8030 v4si b = @{3,2,1,4@};
8031 v4si c;
8032
8033 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
8034 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
8035 @end smallexample
8036
8037 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
8038 @code{b} and @code{c} are vectors of the same type and @code{a} is an
8039 integer vector with the same number of elements of the same size as @code{b}
8040 and @code{c}, computes all three arguments and creates a vector
8041 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
8042 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
8043 As in the case of binary operations, this syntax is also accepted when
8044 one of @code{b} or @code{c} is a scalar that is then transformed into a
8045 vector. If both @code{b} and @code{c} are scalars and the type of
8046 @code{true?b:c} has the same size as the element type of @code{a}, then
8047 @code{b} and @code{c} are converted to a vector type whose elements have
8048 this type and with the same number of elements as @code{a}.
8049
8050 In C++, the logic operators @code{!, &&, ||} are available for vectors.
8051 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
8052 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
8053 For mixed operations between a scalar @code{s} and a vector @code{v},
8054 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
8055 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
8056
8057 Vector shuffling is available using functions
8058 @code{__builtin_shuffle (vec, mask)} and
8059 @code{__builtin_shuffle (vec0, vec1, mask)}.
8060 Both functions construct a permutation of elements from one or two
8061 vectors and return a vector of the same type as the input vector(s).
8062 The @var{mask} is an integral vector with the same width (@var{W})
8063 and element count (@var{N}) as the output vector.
8064
8065 The elements of the input vectors are numbered in memory ordering of
8066 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
8067 elements of @var{mask} are considered modulo @var{N} in the single-operand
8068 case and modulo @math{2*@var{N}} in the two-operand case.
8069
8070 Consider the following example,
8071
8072 @smallexample
8073 typedef int v4si __attribute__ ((vector_size (16)));
8074
8075 v4si a = @{1,2,3,4@};
8076 v4si b = @{5,6,7,8@};
8077 v4si mask1 = @{0,1,1,3@};
8078 v4si mask2 = @{0,4,2,5@};
8079 v4si res;
8080
8081 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
8082 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
8083 @end smallexample
8084
8085 Note that @code{__builtin_shuffle} is intentionally semantically
8086 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
8087
8088 You can declare variables and use them in function calls and returns, as
8089 well as in assignments and some casts.  You can specify a vector type as
8090 a return type for a function.  Vector types can also be used as function
8091 arguments.  It is possible to cast from one vector type to another,
8092 provided they are of the same size (in fact, you can also cast vectors
8093 to and from other datatypes of the same size).
8094
8095 You cannot operate between vectors of different lengths or different
8096 signedness without a cast.
8097
8098 @node Offsetof
8099 @section Offsetof
8100 @findex __builtin_offsetof
8101
8102 GCC implements for both C and C++ a syntactic extension to implement
8103 the @code{offsetof} macro.
8104
8105 @smallexample
8106 primary:
8107         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
8108
8109 offsetof_member_designator:
8110           @code{identifier}
8111         | offsetof_member_designator "." @code{identifier}
8112         | offsetof_member_designator "[" @code{expr} "]"
8113 @end smallexample
8114
8115 This extension is sufficient such that
8116
8117 @smallexample
8118 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
8119 @end smallexample
8120
8121 @noindent
8122 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
8123 may be dependent.  In either case, @var{member} may consist of a single
8124 identifier, or a sequence of member accesses and array references.
8125
8126 @node __sync Builtins
8127 @section Legacy __sync Built-in Functions for Atomic Memory Access
8128
8129 The following built-in functions
8130 are intended to be compatible with those described
8131 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
8132 section 7.4.  As such, they depart from the normal GCC practice of using
8133 the @samp{__builtin_} prefix, and further that they are overloaded such that
8134 they work on multiple types.
8135
8136 The definition given in the Intel documentation allows only for the use of
8137 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
8138 counterparts.  GCC allows any integral scalar or pointer type that is
8139 1, 2, 4 or 8 bytes in length.
8140
8141 Not all operations are supported by all target processors.  If a particular
8142 operation cannot be implemented on the target processor, a warning is
8143 generated and a call an external function is generated.  The external
8144 function carries the same name as the built-in version,
8145 with an additional suffix
8146 @samp{_@var{n}} where @var{n} is the size of the data type.
8147
8148 @c ??? Should we have a mechanism to suppress this warning?  This is almost
8149 @c useful for implementing the operation under the control of an external
8150 @c mutex.
8151
8152 In most cases, these built-in functions are considered a @dfn{full barrier}.
8153 That is,
8154 no memory operand is moved across the operation, either forward or
8155 backward.  Further, instructions are issued as necessary to prevent the
8156 processor from speculating loads across the operation and from queuing stores
8157 after the operation.
8158
8159 All of the routines are described in the Intel documentation to take
8160 ``an optional list of variables protected by the memory barrier''.  It's
8161 not clear what is meant by that; it could mean that @emph{only} the
8162 following variables are protected, or it could mean that these variables
8163 should in addition be protected.  At present GCC ignores this list and
8164 protects all variables that are globally accessible.  If in the future
8165 we make some use of this list, an empty list will continue to mean all
8166 globally accessible variables.
8167
8168 @table @code
8169 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
8170 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
8171 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
8172 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
8173 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
8174 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
8175 @findex __sync_fetch_and_add
8176 @findex __sync_fetch_and_sub
8177 @findex __sync_fetch_and_or
8178 @findex __sync_fetch_and_and
8179 @findex __sync_fetch_and_xor
8180 @findex __sync_fetch_and_nand
8181 These built-in functions perform the operation suggested by the name, and
8182 returns the value that had previously been in memory.  That is,
8183
8184 @smallexample
8185 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
8186 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
8187 @end smallexample
8188
8189 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
8190 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
8191
8192 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
8193 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
8194 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
8195 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
8196 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
8197 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
8198 @findex __sync_add_and_fetch
8199 @findex __sync_sub_and_fetch
8200 @findex __sync_or_and_fetch
8201 @findex __sync_and_and_fetch
8202 @findex __sync_xor_and_fetch
8203 @findex __sync_nand_and_fetch
8204 These built-in functions perform the operation suggested by the name, and
8205 return the new value.  That is,
8206
8207 @smallexample
8208 @{ *ptr @var{op}= value; return *ptr; @}
8209 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
8210 @end smallexample
8211
8212 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
8213 as @code{*ptr = ~(*ptr & value)} instead of
8214 @code{*ptr = ~*ptr & value}.
8215
8216 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8217 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
8218 @findex __sync_bool_compare_and_swap
8219 @findex __sync_val_compare_and_swap
8220 These built-in functions perform an atomic compare and swap.
8221 That is, if the current
8222 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
8223 @code{*@var{ptr}}.
8224
8225 The ``bool'' version returns true if the comparison is successful and
8226 @var{newval} is written.  The ``val'' version returns the contents
8227 of @code{*@var{ptr}} before the operation.
8228
8229 @item __sync_synchronize (...)
8230 @findex __sync_synchronize
8231 This built-in function issues a full memory barrier.
8232
8233 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
8234 @findex __sync_lock_test_and_set
8235 This built-in function, as described by Intel, is not a traditional test-and-set
8236 operation, but rather an atomic exchange operation.  It writes @var{value}
8237 into @code{*@var{ptr}}, and returns the previous contents of
8238 @code{*@var{ptr}}.
8239
8240 Many targets have only minimal support for such locks, and do not support
8241 a full exchange operation.  In this case, a target may support reduced
8242 functionality here by which the @emph{only} valid value to store is the
8243 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
8244 is implementation defined.
8245
8246 This built-in function is not a full barrier,
8247 but rather an @dfn{acquire barrier}.
8248 This means that references after the operation cannot move to (or be
8249 speculated to) before the operation, but previous memory stores may not
8250 be globally visible yet, and previous memory loads may not yet be
8251 satisfied.
8252
8253 @item void __sync_lock_release (@var{type} *ptr, ...)
8254 @findex __sync_lock_release
8255 This built-in function releases the lock acquired by
8256 @code{__sync_lock_test_and_set}.
8257 Normally this means writing the constant 0 to @code{*@var{ptr}}.
8258
8259 This built-in function is not a full barrier,
8260 but rather a @dfn{release barrier}.
8261 This means that all previous memory stores are globally visible, and all
8262 previous memory loads have been satisfied, but following memory reads
8263 are not prevented from being speculated to before the barrier.
8264 @end table
8265
8266 @node __atomic Builtins
8267 @section Built-in functions for memory model aware atomic operations
8268
8269 The following built-in functions approximately match the requirements for
8270 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
8271 functions, but all also have a memory model parameter.  These are all
8272 identified by being prefixed with @samp{__atomic}, and most are overloaded
8273 such that they work with multiple types.
8274
8275 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
8276 bytes in length. 16-byte integral types are also allowed if
8277 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
8278
8279 Target architectures are encouraged to provide their own patterns for
8280 each of these built-in functions.  If no target is provided, the original 
8281 non-memory model set of @samp{__sync} atomic built-in functions are
8282 utilized, along with any required synchronization fences surrounding it in
8283 order to achieve the proper behavior.  Execution in this case is subject
8284 to the same restrictions as those built-in functions.
8285
8286 If there is no pattern or mechanism to provide a lock free instruction
8287 sequence, a call is made to an external routine with the same parameters
8288 to be resolved at run time.
8289
8290 The four non-arithmetic functions (load, store, exchange, and 
8291 compare_exchange) all have a generic version as well.  This generic
8292 version works on any data type.  If the data type size maps to one
8293 of the integral sizes that may have lock free support, the generic
8294 version utilizes the lock free built-in function.  Otherwise an
8295 external call is left to be resolved at run time.  This external call is
8296 the same format with the addition of a @samp{size_t} parameter inserted
8297 as the first parameter indicating the size of the object being pointed to.
8298 All objects must be the same size.
8299
8300 There are 6 different memory models that can be specified.  These map
8301 to the same names in the C++11 standard.  Refer there or to the
8302 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
8303 atomic synchronization} for more detailed definitions.  These memory
8304 models integrate both barriers to code motion as well as synchronization
8305 requirements with other threads. These are listed in approximately
8306 ascending order of strength. It is also possible to use target specific
8307 flags for memory model flags, like Hardware Lock Elision.
8308
8309 @table  @code
8310 @item __ATOMIC_RELAXED
8311 No barriers or synchronization.
8312 @item __ATOMIC_CONSUME
8313 Data dependency only for both barrier and synchronization with another
8314 thread.
8315 @item __ATOMIC_ACQUIRE
8316 Barrier to hoisting of code and synchronizes with release (or stronger)
8317 semantic stores from another thread.
8318 @item __ATOMIC_RELEASE
8319 Barrier to sinking of code and synchronizes with acquire (or stronger)
8320 semantic loads from another thread.
8321 @item __ATOMIC_ACQ_REL
8322 Full barrier in both directions and synchronizes with acquire loads and
8323 release stores in another thread.
8324 @item __ATOMIC_SEQ_CST
8325 Full barrier in both directions and synchronizes with acquire loads and
8326 release stores in all threads.
8327 @end table
8328
8329 When implementing patterns for these built-in functions, the memory model
8330 parameter can be ignored as long as the pattern implements the most
8331 restrictive @code{__ATOMIC_SEQ_CST} model.  Any of the other memory models
8332 execute correctly with this memory model but they may not execute as
8333 efficiently as they could with a more appropriate implementation of the
8334 relaxed requirements.
8335
8336 Note that the C++11 standard allows for the memory model parameter to be
8337 determined at run time rather than at compile time.  These built-in
8338 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
8339 than invoke a runtime library call or inline a switch statement.  This is
8340 standard compliant, safe, and the simplest approach for now.
8341
8342 The memory model parameter is a signed int, but only the lower 8 bits are
8343 reserved for the memory model.  The remainder of the signed int is reserved
8344 for future use and should be 0.  Use of the predefined atomic values
8345 ensures proper usage.
8346
8347 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
8348 This built-in function implements an atomic load operation.  It returns the
8349 contents of @code{*@var{ptr}}.
8350
8351 The valid memory model variants are
8352 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8353 and @code{__ATOMIC_CONSUME}.
8354
8355 @end deftypefn
8356
8357 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
8358 This is the generic version of an atomic load.  It returns the
8359 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
8360
8361 @end deftypefn
8362
8363 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
8364 This built-in function implements an atomic store operation.  It writes 
8365 @code{@var{val}} into @code{*@var{ptr}}.  
8366
8367 The valid memory model variants are
8368 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
8369
8370 @end deftypefn
8371
8372 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
8373 This is the generic version of an atomic store.  It stores the value
8374 of @code{*@var{val}} into @code{*@var{ptr}}.
8375
8376 @end deftypefn
8377
8378 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
8379 This built-in function implements an atomic exchange operation.  It writes
8380 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
8381 @code{*@var{ptr}}.
8382
8383 The valid memory model variants are
8384 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
8385 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
8386
8387 @end deftypefn
8388
8389 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
8390 This is the generic version of an atomic exchange.  It stores the
8391 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
8392 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
8393
8394 @end deftypefn
8395
8396 @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)
8397 This built-in function implements an atomic compare and exchange operation.
8398 This compares the contents of @code{*@var{ptr}} with the contents of
8399 @code{*@var{expected}} and if equal, writes @var{desired} into
8400 @code{*@var{ptr}}.  If they are not equal, the current contents of
8401 @code{*@var{ptr}} is written into @code{*@var{expected}}.  @var{weak} is true
8402 for weak compare_exchange, and false for the strong variation.  Many targets 
8403 only offer the strong variation and ignore the parameter.  When in doubt, use
8404 the strong variation.
8405
8406 True is returned if @var{desired} is written into
8407 @code{*@var{ptr}} and the execution is considered to conform to the
8408 memory model specified by @var{success_memmodel}.  There are no
8409 restrictions on what memory model can be used here.
8410
8411 False is returned otherwise, and the execution is considered to conform
8412 to @var{failure_memmodel}. This memory model cannot be
8413 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
8414 stronger model than that specified by @var{success_memmodel}.
8415
8416 @end deftypefn
8417
8418 @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)
8419 This built-in function implements the generic version of
8420 @code{__atomic_compare_exchange}.  The function is virtually identical to
8421 @code{__atomic_compare_exchange_n}, except the desired value is also a
8422 pointer.
8423
8424 @end deftypefn
8425
8426 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8427 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8428 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8429 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8430 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8431 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
8432 These built-in functions perform the operation suggested by the name, and
8433 return the result of the operation. That is,
8434
8435 @smallexample
8436 @{ *ptr @var{op}= val; return *ptr; @}
8437 @end smallexample
8438
8439 All memory models are valid.
8440
8441 @end deftypefn
8442
8443 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
8444 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
8445 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
8446 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
8447 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
8448 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
8449 These built-in functions perform the operation suggested by the name, and
8450 return the value that had previously been in @code{*@var{ptr}}.  That is,
8451
8452 @smallexample
8453 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
8454 @end smallexample
8455
8456 All memory models are valid.
8457
8458 @end deftypefn
8459
8460 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
8461
8462 This built-in function performs an atomic test-and-set operation on
8463 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
8464 defined nonzero ``set'' value and the return value is @code{true} if and only
8465 if the previous contents were ``set''.
8466 It should be only used for operands of type @code{bool} or @code{char}. For 
8467 other types only part of the value may be set.
8468
8469 All memory models are valid.
8470
8471 @end deftypefn
8472
8473 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
8474
8475 This built-in function performs an atomic clear operation on
8476 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
8477 It should be only used for operands of type @code{bool} or @code{char} and 
8478 in conjunction with @code{__atomic_test_and_set}.
8479 For other types it may only clear partially. If the type is not @code{bool}
8480 prefer using @code{__atomic_store}.
8481
8482 The valid memory model variants are
8483 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
8484 @code{__ATOMIC_RELEASE}.
8485
8486 @end deftypefn
8487
8488 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
8489
8490 This built-in function acts as a synchronization fence between threads
8491 based on the specified memory model.
8492
8493 All memory orders are valid.
8494
8495 @end deftypefn
8496
8497 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
8498
8499 This built-in function acts as a synchronization fence between a thread
8500 and signal handlers based in the same thread.
8501
8502 All memory orders are valid.
8503
8504 @end deftypefn
8505
8506 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
8507
8508 This built-in function returns true if objects of @var{size} bytes always
8509 generate lock free atomic instructions for the target architecture.  
8510 @var{size} must resolve to a compile-time constant and the result also
8511 resolves to a compile-time constant.
8512
8513 @var{ptr} is an optional pointer to the object that may be used to determine
8514 alignment.  A value of 0 indicates typical alignment should be used.  The 
8515 compiler may also ignore this parameter.
8516
8517 @smallexample
8518 if (_atomic_always_lock_free (sizeof (long long), 0))
8519 @end smallexample
8520
8521 @end deftypefn
8522
8523 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
8524
8525 This built-in function returns true if objects of @var{size} bytes always
8526 generate lock free atomic instructions for the target architecture.  If
8527 it is not known to be lock free a call is made to a runtime routine named
8528 @code{__atomic_is_lock_free}.
8529
8530 @var{ptr} is an optional pointer to the object that may be used to determine
8531 alignment.  A value of 0 indicates typical alignment should be used.  The 
8532 compiler may also ignore this parameter.
8533 @end deftypefn
8534
8535 @node Integer Overflow Builtins
8536 @section Built-in functions to perform arithmetics and arithmetic overflow checking.
8537
8538 The following built-in functions allow performing simple arithmetic operations
8539 together with checking whether the operations overflowed.
8540
8541 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8542 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
8543 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
8544 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
8545 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
8546 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8547 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8548
8549 These built-in functions promote the first two operands into infinite precision signed
8550 type and perform addition on those promoted operands.  The result is then
8551 cast to the type the third pointer argument points to and stored there.
8552 If the stored result is equal to the infinite precision result, the built-in
8553 functions return false, otherwise they return true.  As the addition is
8554 performed in infinite signed precision, these built-in functions have fully defined
8555 behavior for all argument values.
8556
8557 The first built-in function allows arbitrary integral types for operands and
8558 the result type must be pointer to some integer type, the rest of the built-in
8559 functions have explicit integer types.
8560
8561 The compiler will attempt to use hardware instructions to implement
8562 these built-in functions where possible, like conditional jump on overflow
8563 after addition, conditional jump on carry etc.
8564
8565 @end deftypefn
8566
8567 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8568 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
8569 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
8570 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
8571 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
8572 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8573 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8574
8575 These built-in functions are similar to the add overflow checking built-in
8576 functions above, except they perform subtraction, subtract the second argument
8577 from the first one, instead of addition.
8578
8579 @end deftypefn
8580
8581 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
8582 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
8583 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
8584 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
8585 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
8586 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
8587 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
8588
8589 These built-in functions are similar to the add overflow checking built-in
8590 functions above, except they perform multiplication, instead of addition.
8591
8592 @end deftypefn
8593
8594 @node x86 specific memory model extensions for transactional memory
8595 @section x86 specific memory model extensions for transactional memory
8596
8597 The x86 architecture supports additional memory ordering flags
8598 to mark lock critical sections for hardware lock elision. 
8599 These must be specified in addition to an existing memory model to 
8600 atomic intrinsics.
8601
8602 @table @code
8603 @item __ATOMIC_HLE_ACQUIRE
8604 Start lock elision on a lock variable.
8605 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
8606 @item __ATOMIC_HLE_RELEASE
8607 End lock elision on a lock variable.
8608 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
8609 @end table
8610
8611 When a lock acquire fails it is required for good performance to abort
8612 the transaction quickly. This can be done with a @code{_mm_pause}
8613
8614 @smallexample
8615 #include <immintrin.h> // For _mm_pause
8616
8617 int lockvar;
8618
8619 /* Acquire lock with lock elision */
8620 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
8621     _mm_pause(); /* Abort failed transaction */
8622 ...
8623 /* Free lock with lock elision */
8624 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
8625 @end smallexample
8626
8627 @node Object Size Checking
8628 @section Object Size Checking Built-in Functions
8629 @findex __builtin_object_size
8630 @findex __builtin___memcpy_chk
8631 @findex __builtin___mempcpy_chk
8632 @findex __builtin___memmove_chk
8633 @findex __builtin___memset_chk
8634 @findex __builtin___strcpy_chk
8635 @findex __builtin___stpcpy_chk
8636 @findex __builtin___strncpy_chk
8637 @findex __builtin___strcat_chk
8638 @findex __builtin___strncat_chk
8639 @findex __builtin___sprintf_chk
8640 @findex __builtin___snprintf_chk
8641 @findex __builtin___vsprintf_chk
8642 @findex __builtin___vsnprintf_chk
8643 @findex __builtin___printf_chk
8644 @findex __builtin___vprintf_chk
8645 @findex __builtin___fprintf_chk
8646 @findex __builtin___vfprintf_chk
8647
8648 GCC implements a limited buffer overflow protection mechanism
8649 that can prevent some buffer overflow attacks.
8650
8651 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
8652 is a built-in construct that returns a constant number of bytes from
8653 @var{ptr} to the end of the object @var{ptr} pointer points to
8654 (if known at compile time).  @code{__builtin_object_size} never evaluates
8655 its arguments for side-effects.  If there are any side-effects in them, it
8656 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8657 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
8658 point to and all of them are known at compile time, the returned number
8659 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
8660 0 and minimum if nonzero.  If it is not possible to determine which objects
8661 @var{ptr} points to at compile time, @code{__builtin_object_size} should
8662 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
8663 for @var{type} 2 or 3.
8664
8665 @var{type} is an integer constant from 0 to 3.  If the least significant
8666 bit is clear, objects are whole variables, if it is set, a closest
8667 surrounding subobject is considered the object a pointer points to.
8668 The second bit determines if maximum or minimum of remaining bytes
8669 is computed.
8670
8671 @smallexample
8672 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
8673 char *p = &var.buf1[1], *q = &var.b;
8674
8675 /* Here the object p points to is var.  */
8676 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
8677 /* The subobject p points to is var.buf1.  */
8678 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
8679 /* The object q points to is var.  */
8680 assert (__builtin_object_size (q, 0)
8681         == (char *) (&var + 1) - (char *) &var.b);
8682 /* The subobject q points to is var.b.  */
8683 assert (__builtin_object_size (q, 1) == sizeof (var.b));
8684 @end smallexample
8685 @end deftypefn
8686
8687 There are built-in functions added for many common string operation
8688 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
8689 built-in is provided.  This built-in has an additional last argument,
8690 which is the number of bytes remaining in object the @var{dest}
8691 argument points to or @code{(size_t) -1} if the size is not known.
8692
8693 The built-in functions are optimized into the normal string functions
8694 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
8695 it is known at compile time that the destination object will not
8696 be overflown.  If the compiler can determine at compile time the
8697 object will be always overflown, it issues a warning.
8698
8699 The intended use can be e.g.@:
8700
8701 @smallexample
8702 #undef memcpy
8703 #define bos0(dest) __builtin_object_size (dest, 0)
8704 #define memcpy(dest, src, n) \
8705   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
8706
8707 char *volatile p;
8708 char buf[10];
8709 /* It is unknown what object p points to, so this is optimized
8710    into plain memcpy - no checking is possible.  */
8711 memcpy (p, "abcde", n);
8712 /* Destination is known and length too.  It is known at compile
8713    time there will be no overflow.  */
8714 memcpy (&buf[5], "abcde", 5);
8715 /* Destination is known, but the length is not known at compile time.
8716    This will result in __memcpy_chk call that can check for overflow
8717    at run time.  */
8718 memcpy (&buf[5], "abcde", n);
8719 /* Destination is known and it is known at compile time there will
8720    be overflow.  There will be a warning and __memcpy_chk call that
8721    will abort the program at run time.  */
8722 memcpy (&buf[6], "abcde", 5);
8723 @end smallexample
8724
8725 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
8726 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
8727 @code{strcat} and @code{strncat}.
8728
8729 There are also checking built-in functions for formatted output functions.
8730 @smallexample
8731 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
8732 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8733                               const char *fmt, ...);
8734 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
8735                               va_list ap);
8736 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
8737                                const char *fmt, va_list ap);
8738 @end smallexample
8739
8740 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
8741 etc.@: functions and can contain implementation specific flags on what
8742 additional security measures the checking function might take, such as
8743 handling @code{%n} differently.
8744
8745 The @var{os} argument is the object size @var{s} points to, like in the
8746 other built-in functions.  There is a small difference in the behavior
8747 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
8748 optimized into the non-checking functions only if @var{flag} is 0, otherwise
8749 the checking function is called with @var{os} argument set to
8750 @code{(size_t) -1}.
8751
8752 In addition to this, there are checking built-in functions
8753 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
8754 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
8755 These have just one additional argument, @var{flag}, right before
8756 format string @var{fmt}.  If the compiler is able to optimize them to
8757 @code{fputc} etc.@: functions, it does, otherwise the checking function
8758 is called and the @var{flag} argument passed to it.
8759
8760 @node Pointer Bounds Checker builtins
8761 @section Pointer Bounds Checker Built-in Functions
8762 @findex __builtin___bnd_set_ptr_bounds
8763 @findex __builtin___bnd_narrow_ptr_bounds
8764 @findex __builtin___bnd_copy_ptr_bounds
8765 @findex __builtin___bnd_init_ptr_bounds
8766 @findex __builtin___bnd_null_ptr_bounds
8767 @findex __builtin___bnd_store_ptr_bounds
8768 @findex __builtin___bnd_chk_ptr_lbounds
8769 @findex __builtin___bnd_chk_ptr_ubounds
8770 @findex __builtin___bnd_chk_ptr_bounds
8771 @findex __builtin___bnd_get_ptr_lbound
8772 @findex __builtin___bnd_get_ptr_ubound
8773
8774 GCC provides a set of built-in functions to control Pointer Bounds Checker
8775 instrumentation.  Note that all Pointer Bounds Checker builtins are allowed
8776 to use even if you compile with Pointer Bounds Checker off.  The builtins
8777 behavior may differ in such case as documented below.
8778
8779 @deftypefn {Built-in Function} void * __builtin___bnd_set_ptr_bounds (const void * @var{q}, size_t @var{size})
8780
8781 This built-in function returns a new pointer with the value of @var{q}, and
8782 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
8783 Bounds Checker off built-in function just returns the first argument.
8784
8785 @smallexample
8786 extern void *__wrap_malloc (size_t n)
8787 @{
8788   void *p = (void *)__real_malloc (n);
8789   if (!p) return __builtin___bnd_null_ptr_bounds (p);
8790   return __builtin___bnd_set_ptr_bounds (p, n);
8791 @}
8792 @end smallexample
8793
8794 @end deftypefn
8795
8796 @deftypefn {Built-in Function} void * __builtin___bnd_narrow_ptr_bounds (const void * @var{p}, const void * @var{q}, size_t  @var{size})
8797
8798 This built-in function returns a new pointer with the value of @var{p}
8799 and associate it with the narrowed bounds formed by the intersection
8800 of bounds associated with @var{q} and the [@var{p}, @var{p} + @var{size} - 1].
8801 With Pointer Bounds Checker off built-in function just returns the first
8802 argument.
8803
8804 @smallexample
8805 void init_objects (object *objs, size_t size)
8806 @{
8807   size_t i;
8808   /* Initialize objects one-by-one passing pointers with bounds of an object,
8809      not the full array of objects.  */
8810   for (i = 0; i < size; i++)
8811     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs, sizeof(object)));
8812 @}
8813 @end smallexample
8814
8815 @end deftypefn
8816
8817 @deftypefn {Built-in Function} void * __builtin___bnd_copy_ptr_bounds (const void * @var{q}, const void * @var{r})
8818
8819 This built-in function returns a new pointer with the value of @var{q},
8820 and associate it with the bounds already associated with pointer @var{r}.
8821 With Pointer Bounds Checker off built-in function just returns the first
8822 argument.
8823
8824 @smallexample
8825 /* Here is a way to get pointer to object's field but
8826    still with the full object's bounds.  */
8827 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_filed, objptr);
8828 @end smallexample
8829
8830 @end deftypefn
8831
8832 @deftypefn {Built-in Function} void * __builtin___bnd_init_ptr_bounds (const void * @var{q})
8833
8834 This built-in function returns a new pointer with the value of @var{q}, and
8835 associate it with INIT (allowing full memory access) bounds. With Pointer
8836 Bounds Checker off built-in function just returns the first argument.
8837
8838 @end deftypefn
8839
8840 @deftypefn {Built-in Function} void * __builtin___bnd_null_ptr_bounds (const void * @var{q})
8841
8842 This built-in function returns a new pointer with the value of @var{q}, and
8843 associate it with NULL (allowing no memory access) bounds. With Pointer
8844 Bounds Checker off built-in function just returns the first argument.
8845
8846 @end deftypefn
8847
8848 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void ** @var{ptr_addr}, const void * @var{ptr_val})
8849
8850 This built-in function stores the bounds associated with pointer @var{ptr_val}
8851 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
8852 bounds from legacy code without touching the associated pointer's memory when
8853 pointers were copied as integers.  With Pointer Bounds Checker off built-in
8854 function call is ignored.
8855
8856 @end deftypefn
8857
8858 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void * @var{q})
8859
8860 This built-in function checks if the pointer @var{q} is within the lower
8861 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8862 function call is ignored.
8863
8864 @smallexample
8865 extern void *__wrap_memset (void *dst, int c, size_t len)
8866 @{
8867   if (len > 0)
8868     @{
8869       __builtin___bnd_chk_ptr_lbounds (dst);
8870       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
8871       __real_memset (dst, c, len);
8872     @}
8873   return dst;
8874 @}
8875 @end smallexample
8876
8877 @end deftypefn
8878
8879 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void * @var{q})
8880
8881 This built-in function checks if the pointer @var{q} is within the upper
8882 bound of its associated bounds.  With Pointer Bounds Checker off built-in
8883 function call is ignored.
8884
8885 @end deftypefn
8886
8887 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void * @var{q}, size_t @var{size})
8888
8889 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
8890 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
8891 off built-in function call is ignored.
8892
8893 @smallexample
8894 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
8895 @{
8896   if (n > 0)
8897     @{
8898       __bnd_chk_ptr_bounds (dst, n);
8899       __bnd_chk_ptr_bounds (src, n);
8900       __real_memcpy (dst, src, n);
8901     @}
8902   return dst;
8903 @}
8904 @end smallexample
8905
8906 @end deftypefn
8907
8908 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_lbound (const void * @var{q})
8909
8910 This built-in function returns the lower bound (which is a pointer) associated
8911 with the pointer @var{q}.  This is at least useful for debugging using printf.
8912 With Pointer Bounds Checker off built-in function returns 0.
8913
8914 @smallexample
8915 void *lb = __builtin___bnd_get_ptr_lbound (q);
8916 void *ub = __builtin___bnd_get_ptr_ubound (q);
8917 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
8918 @end smallexample
8919
8920 @end deftypefn
8921
8922 @deftypefn {Built-in Function} const void * __builtin___bnd_get_ptr_ubound (const void * @var{q})
8923
8924 This built-in function returns the upper bound (which is a pointer) associated
8925 with the pointer @var{q}.  With Pointer Bounds Checker off built-in function
8926 returns -1.
8927
8928 @end deftypefn
8929
8930 @node Cilk Plus Builtins
8931 @section Cilk Plus C/C++ language extension Built-in Functions.
8932
8933 GCC provides support for the following built-in reduction funtions if Cilk Plus
8934 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8935
8936 @itemize @bullet
8937 @item __sec_implicit_index
8938 @item __sec_reduce
8939 @item __sec_reduce_add
8940 @item __sec_reduce_all_nonzero
8941 @item __sec_reduce_all_zero
8942 @item __sec_reduce_any_nonzero
8943 @item __sec_reduce_any_zero
8944 @item __sec_reduce_max
8945 @item __sec_reduce_min
8946 @item __sec_reduce_max_ind
8947 @item __sec_reduce_min_ind
8948 @item __sec_reduce_mul
8949 @item __sec_reduce_mutating
8950 @end itemize
8951
8952 Further details and examples about these built-in functions are described 
8953 in the Cilk Plus language manual which can be found at 
8954 @uref{http://www.cilkplus.org}.
8955
8956 @node Other Builtins
8957 @section Other Built-in Functions Provided by GCC
8958 @cindex built-in functions
8959 @findex __builtin_call_with_static_chain
8960 @findex __builtin_fpclassify
8961 @findex __builtin_isfinite
8962 @findex __builtin_isnormal
8963 @findex __builtin_isgreater
8964 @findex __builtin_isgreaterequal
8965 @findex __builtin_isinf_sign
8966 @findex __builtin_isless
8967 @findex __builtin_islessequal
8968 @findex __builtin_islessgreater
8969 @findex __builtin_isunordered
8970 @findex __builtin_powi
8971 @findex __builtin_powif
8972 @findex __builtin_powil
8973 @findex _Exit
8974 @findex _exit
8975 @findex abort
8976 @findex abs
8977 @findex acos
8978 @findex acosf
8979 @findex acosh
8980 @findex acoshf
8981 @findex acoshl
8982 @findex acosl
8983 @findex alloca
8984 @findex asin
8985 @findex asinf
8986 @findex asinh
8987 @findex asinhf
8988 @findex asinhl
8989 @findex asinl
8990 @findex atan
8991 @findex atan2
8992 @findex atan2f
8993 @findex atan2l
8994 @findex atanf
8995 @findex atanh
8996 @findex atanhf
8997 @findex atanhl
8998 @findex atanl
8999 @findex bcmp
9000 @findex bzero
9001 @findex cabs
9002 @findex cabsf
9003 @findex cabsl
9004 @findex cacos
9005 @findex cacosf
9006 @findex cacosh
9007 @findex cacoshf
9008 @findex cacoshl
9009 @findex cacosl
9010 @findex calloc
9011 @findex carg
9012 @findex cargf
9013 @findex cargl
9014 @findex casin
9015 @findex casinf
9016 @findex casinh
9017 @findex casinhf
9018 @findex casinhl
9019 @findex casinl
9020 @findex catan
9021 @findex catanf
9022 @findex catanh
9023 @findex catanhf
9024 @findex catanhl
9025 @findex catanl
9026 @findex cbrt
9027 @findex cbrtf
9028 @findex cbrtl
9029 @findex ccos
9030 @findex ccosf
9031 @findex ccosh
9032 @findex ccoshf
9033 @findex ccoshl
9034 @findex ccosl
9035 @findex ceil
9036 @findex ceilf
9037 @findex ceill
9038 @findex cexp
9039 @findex cexpf
9040 @findex cexpl
9041 @findex cimag
9042 @findex cimagf
9043 @findex cimagl
9044 @findex clog
9045 @findex clogf
9046 @findex clogl
9047 @findex conj
9048 @findex conjf
9049 @findex conjl
9050 @findex copysign
9051 @findex copysignf
9052 @findex copysignl
9053 @findex cos
9054 @findex cosf
9055 @findex cosh
9056 @findex coshf
9057 @findex coshl
9058 @findex cosl
9059 @findex cpow
9060 @findex cpowf
9061 @findex cpowl
9062 @findex cproj
9063 @findex cprojf
9064 @findex cprojl
9065 @findex creal
9066 @findex crealf
9067 @findex creall
9068 @findex csin
9069 @findex csinf
9070 @findex csinh
9071 @findex csinhf
9072 @findex csinhl
9073 @findex csinl
9074 @findex csqrt
9075 @findex csqrtf
9076 @findex csqrtl
9077 @findex ctan
9078 @findex ctanf
9079 @findex ctanh
9080 @findex ctanhf
9081 @findex ctanhl
9082 @findex ctanl
9083 @findex dcgettext
9084 @findex dgettext
9085 @findex drem
9086 @findex dremf
9087 @findex dreml
9088 @findex erf
9089 @findex erfc
9090 @findex erfcf
9091 @findex erfcl
9092 @findex erff
9093 @findex erfl
9094 @findex exit
9095 @findex exp
9096 @findex exp10
9097 @findex exp10f
9098 @findex exp10l
9099 @findex exp2
9100 @findex exp2f
9101 @findex exp2l
9102 @findex expf
9103 @findex expl
9104 @findex expm1
9105 @findex expm1f
9106 @findex expm1l
9107 @findex fabs
9108 @findex fabsf
9109 @findex fabsl
9110 @findex fdim
9111 @findex fdimf
9112 @findex fdiml
9113 @findex ffs
9114 @findex floor
9115 @findex floorf
9116 @findex floorl
9117 @findex fma
9118 @findex fmaf
9119 @findex fmal
9120 @findex fmax
9121 @findex fmaxf
9122 @findex fmaxl
9123 @findex fmin
9124 @findex fminf
9125 @findex fminl
9126 @findex fmod
9127 @findex fmodf
9128 @findex fmodl
9129 @findex fprintf
9130 @findex fprintf_unlocked
9131 @findex fputs
9132 @findex fputs_unlocked
9133 @findex frexp
9134 @findex frexpf
9135 @findex frexpl
9136 @findex fscanf
9137 @findex gamma
9138 @findex gammaf
9139 @findex gammal
9140 @findex gamma_r
9141 @findex gammaf_r
9142 @findex gammal_r
9143 @findex gettext
9144 @findex hypot
9145 @findex hypotf
9146 @findex hypotl
9147 @findex ilogb
9148 @findex ilogbf
9149 @findex ilogbl
9150 @findex imaxabs
9151 @findex index
9152 @findex isalnum
9153 @findex isalpha
9154 @findex isascii
9155 @findex isblank
9156 @findex iscntrl
9157 @findex isdigit
9158 @findex isgraph
9159 @findex islower
9160 @findex isprint
9161 @findex ispunct
9162 @findex isspace
9163 @findex isupper
9164 @findex iswalnum
9165 @findex iswalpha
9166 @findex iswblank
9167 @findex iswcntrl
9168 @findex iswdigit
9169 @findex iswgraph
9170 @findex iswlower
9171 @findex iswprint
9172 @findex iswpunct
9173 @findex iswspace
9174 @findex iswupper
9175 @findex iswxdigit
9176 @findex isxdigit
9177 @findex j0
9178 @findex j0f
9179 @findex j0l
9180 @findex j1
9181 @findex j1f
9182 @findex j1l
9183 @findex jn
9184 @findex jnf
9185 @findex jnl
9186 @findex labs
9187 @findex ldexp
9188 @findex ldexpf
9189 @findex ldexpl
9190 @findex lgamma
9191 @findex lgammaf
9192 @findex lgammal
9193 @findex lgamma_r
9194 @findex lgammaf_r
9195 @findex lgammal_r
9196 @findex llabs
9197 @findex llrint
9198 @findex llrintf
9199 @findex llrintl
9200 @findex llround
9201 @findex llroundf
9202 @findex llroundl
9203 @findex log
9204 @findex log10
9205 @findex log10f
9206 @findex log10l
9207 @findex log1p
9208 @findex log1pf
9209 @findex log1pl
9210 @findex log2
9211 @findex log2f
9212 @findex log2l
9213 @findex logb
9214 @findex logbf
9215 @findex logbl
9216 @findex logf
9217 @findex logl
9218 @findex lrint
9219 @findex lrintf
9220 @findex lrintl
9221 @findex lround
9222 @findex lroundf
9223 @findex lroundl
9224 @findex malloc
9225 @findex memchr
9226 @findex memcmp
9227 @findex memcpy
9228 @findex mempcpy
9229 @findex memset
9230 @findex modf
9231 @findex modff
9232 @findex modfl
9233 @findex nearbyint
9234 @findex nearbyintf
9235 @findex nearbyintl
9236 @findex nextafter
9237 @findex nextafterf
9238 @findex nextafterl
9239 @findex nexttoward
9240 @findex nexttowardf
9241 @findex nexttowardl
9242 @findex pow
9243 @findex pow10
9244 @findex pow10f
9245 @findex pow10l
9246 @findex powf
9247 @findex powl
9248 @findex printf
9249 @findex printf_unlocked
9250 @findex putchar
9251 @findex puts
9252 @findex remainder
9253 @findex remainderf
9254 @findex remainderl
9255 @findex remquo
9256 @findex remquof
9257 @findex remquol
9258 @findex rindex
9259 @findex rint
9260 @findex rintf
9261 @findex rintl
9262 @findex round
9263 @findex roundf
9264 @findex roundl
9265 @findex scalb
9266 @findex scalbf
9267 @findex scalbl
9268 @findex scalbln
9269 @findex scalblnf
9270 @findex scalblnf
9271 @findex scalbn
9272 @findex scalbnf
9273 @findex scanfnl
9274 @findex signbit
9275 @findex signbitf
9276 @findex signbitl
9277 @findex signbitd32
9278 @findex signbitd64
9279 @findex signbitd128
9280 @findex significand
9281 @findex significandf
9282 @findex significandl
9283 @findex sin
9284 @findex sincos
9285 @findex sincosf
9286 @findex sincosl
9287 @findex sinf
9288 @findex sinh
9289 @findex sinhf
9290 @findex sinhl
9291 @findex sinl
9292 @findex snprintf
9293 @findex sprintf
9294 @findex sqrt
9295 @findex sqrtf
9296 @findex sqrtl
9297 @findex sscanf
9298 @findex stpcpy
9299 @findex stpncpy
9300 @findex strcasecmp
9301 @findex strcat
9302 @findex strchr
9303 @findex strcmp
9304 @findex strcpy
9305 @findex strcspn
9306 @findex strdup
9307 @findex strfmon
9308 @findex strftime
9309 @findex strlen
9310 @findex strncasecmp
9311 @findex strncat
9312 @findex strncmp
9313 @findex strncpy
9314 @findex strndup
9315 @findex strpbrk
9316 @findex strrchr
9317 @findex strspn
9318 @findex strstr
9319 @findex tan
9320 @findex tanf
9321 @findex tanh
9322 @findex tanhf
9323 @findex tanhl
9324 @findex tanl
9325 @findex tgamma
9326 @findex tgammaf
9327 @findex tgammal
9328 @findex toascii
9329 @findex tolower
9330 @findex toupper
9331 @findex towlower
9332 @findex towupper
9333 @findex trunc
9334 @findex truncf
9335 @findex truncl
9336 @findex vfprintf
9337 @findex vfscanf
9338 @findex vprintf
9339 @findex vscanf
9340 @findex vsnprintf
9341 @findex vsprintf
9342 @findex vsscanf
9343 @findex y0
9344 @findex y0f
9345 @findex y0l
9346 @findex y1
9347 @findex y1f
9348 @findex y1l
9349 @findex yn
9350 @findex ynf
9351 @findex ynl
9352
9353 GCC provides a large number of built-in functions other than the ones
9354 mentioned above.  Some of these are for internal use in the processing
9355 of exceptions or variable-length argument lists and are not
9356 documented here because they may change from time to time; we do not
9357 recommend general use of these functions.
9358
9359 The remaining functions are provided for optimization purposes.
9360
9361 @opindex fno-builtin
9362 GCC includes built-in versions of many of the functions in the standard
9363 C library.  The versions prefixed with @code{__builtin_} are always
9364 treated as having the same meaning as the C library function even if you
9365 specify the @option{-fno-builtin} option.  (@pxref{C Dialect Options})
9366 Many of these functions are only optimized in certain cases; if they are
9367 not optimized in a particular case, a call to the library function is
9368 emitted.
9369
9370 @opindex ansi
9371 @opindex std
9372 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
9373 @option{-std=c99} or @option{-std=c11}), the functions
9374 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
9375 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
9376 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
9377 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
9378 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
9379 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
9380 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
9381 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
9382 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
9383 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
9384 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
9385 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
9386 @code{signbitd64}, @code{signbitd128}, @code{significandf},
9387 @code{significandl}, @code{significand}, @code{sincosf},
9388 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
9389 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
9390 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
9391 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
9392 @code{yn}
9393 may be handled as built-in functions.
9394 All these functions have corresponding versions
9395 prefixed with @code{__builtin_}, which may be used even in strict C90
9396 mode.
9397
9398 The ISO C99 functions
9399 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
9400 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
9401 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
9402 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
9403 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
9404 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
9405 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
9406 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
9407 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
9408 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
9409 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
9410 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
9411 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
9412 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
9413 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
9414 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
9415 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
9416 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
9417 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
9418 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
9419 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
9420 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
9421 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
9422 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
9423 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
9424 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
9425 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
9426 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
9427 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
9428 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
9429 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
9430 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
9431 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
9432 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
9433 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
9434 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
9435 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
9436 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
9437 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
9438 are handled as built-in functions
9439 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9440
9441 There are also built-in versions of the ISO C99 functions
9442 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
9443 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
9444 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
9445 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
9446 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
9447 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
9448 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
9449 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
9450 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
9451 that are recognized in any mode since ISO C90 reserves these names for
9452 the purpose to which ISO C99 puts them.  All these functions have
9453 corresponding versions prefixed with @code{__builtin_}.
9454
9455 The ISO C94 functions
9456 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
9457 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
9458 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
9459 @code{towupper}
9460 are handled as built-in functions
9461 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
9462
9463 The ISO C90 functions
9464 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
9465 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
9466 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
9467 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
9468 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
9469 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
9470 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
9471 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
9472 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
9473 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
9474 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
9475 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
9476 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
9477 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
9478 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
9479 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
9480 are all recognized as built-in functions unless
9481 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
9482 is specified for an individual function).  All of these functions have
9483 corresponding versions prefixed with @code{__builtin_}.
9484
9485 GCC provides built-in versions of the ISO C99 floating-point comparison
9486 macros that avoid raising exceptions for unordered operands.  They have
9487 the same names as the standard macros ( @code{isgreater},
9488 @code{isgreaterequal}, @code{isless}, @code{islessequal},
9489 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
9490 prefixed.  We intend for a library implementor to be able to simply
9491 @code{#define} each standard macro to its built-in equivalent.
9492 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
9493 @code{isinf_sign} and @code{isnormal} built-ins used with
9494 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
9495 built-in functions appear both with and without the @code{__builtin_} prefix.
9496
9497 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
9498
9499 You can use the built-in function @code{__builtin_types_compatible_p} to
9500 determine whether two types are the same.
9501
9502 This built-in function returns 1 if the unqualified versions of the
9503 types @var{type1} and @var{type2} (which are types, not expressions) are
9504 compatible, 0 otherwise.  The result of this built-in function can be
9505 used in integer constant expressions.
9506
9507 This built-in function ignores top level qualifiers (e.g., @code{const},
9508 @code{volatile}).  For example, @code{int} is equivalent to @code{const
9509 int}.
9510
9511 The type @code{int[]} and @code{int[5]} are compatible.  On the other
9512 hand, @code{int} and @code{char *} are not compatible, even if the size
9513 of their types, on the particular architecture are the same.  Also, the
9514 amount of pointer indirection is taken into account when determining
9515 similarity.  Consequently, @code{short *} is not similar to
9516 @code{short **}.  Furthermore, two types that are typedefed are
9517 considered compatible if their underlying types are compatible.
9518
9519 An @code{enum} type is not considered to be compatible with another
9520 @code{enum} type even if both are compatible with the same integer
9521 type; this is what the C standard specifies.
9522 For example, @code{enum @{foo, bar@}} is not similar to
9523 @code{enum @{hot, dog@}}.
9524
9525 You typically use this function in code whose execution varies
9526 depending on the arguments' types.  For example:
9527
9528 @smallexample
9529 #define foo(x)                                                  \
9530   (@{                                                           \
9531     typeof (x) tmp = (x);                                       \
9532     if (__builtin_types_compatible_p (typeof (x), long double)) \
9533       tmp = foo_long_double (tmp);                              \
9534     else if (__builtin_types_compatible_p (typeof (x), double)) \
9535       tmp = foo_double (tmp);                                   \
9536     else if (__builtin_types_compatible_p (typeof (x), float))  \
9537       tmp = foo_float (tmp);                                    \
9538     else                                                        \
9539       abort ();                                                 \
9540     tmp;                                                        \
9541   @})
9542 @end smallexample
9543
9544 @emph{Note:} This construct is only available for C@.
9545
9546 @end deftypefn
9547
9548 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
9549
9550 The @var{call_exp} expression must be a function call, and the
9551 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
9552 is passed to the function call in the target's static chain location.
9553 The result of builtin is the result of the function call.
9554
9555 @emph{Note:} This builtin is only available for C@.
9556 This builtin can be used to call Go closures from C.
9557
9558 @end deftypefn
9559
9560 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
9561
9562 You can use the built-in function @code{__builtin_choose_expr} to
9563 evaluate code depending on the value of a constant expression.  This
9564 built-in function returns @var{exp1} if @var{const_exp}, which is an
9565 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
9566
9567 This built-in function is analogous to the @samp{? :} operator in C,
9568 except that the expression returned has its type unaltered by promotion
9569 rules.  Also, the built-in function does not evaluate the expression
9570 that is not chosen.  For example, if @var{const_exp} evaluates to true,
9571 @var{exp2} is not evaluated even if it has side-effects.
9572
9573 This built-in function can return an lvalue if the chosen argument is an
9574 lvalue.
9575
9576 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
9577 type.  Similarly, if @var{exp2} is returned, its return type is the same
9578 as @var{exp2}.
9579
9580 Example:
9581
9582 @smallexample
9583 #define foo(x)                                                    \
9584   __builtin_choose_expr (                                         \
9585     __builtin_types_compatible_p (typeof (x), double),            \
9586     foo_double (x),                                               \
9587     __builtin_choose_expr (                                       \
9588       __builtin_types_compatible_p (typeof (x), float),           \
9589       foo_float (x),                                              \
9590       /* @r{The void expression results in a compile-time error}  \
9591          @r{when assigning the result to something.}  */          \
9592       (void)0))
9593 @end smallexample
9594
9595 @emph{Note:} This construct is only available for C@.  Furthermore, the
9596 unused expression (@var{exp1} or @var{exp2} depending on the value of
9597 @var{const_exp}) may still generate syntax errors.  This may change in
9598 future revisions.
9599
9600 @end deftypefn
9601
9602 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
9603
9604 The built-in function @code{__builtin_complex} is provided for use in
9605 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
9606 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
9607 real binary floating-point type, and the result has the corresponding
9608 complex type with real and imaginary parts @var{real} and @var{imag}.
9609 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
9610 infinities, NaNs and negative zeros are involved.
9611
9612 @end deftypefn
9613
9614 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
9615 You can use the built-in function @code{__builtin_constant_p} to
9616 determine if a value is known to be constant at compile time and hence
9617 that GCC can perform constant-folding on expressions involving that
9618 value.  The argument of the function is the value to test.  The function
9619 returns the integer 1 if the argument is known to be a compile-time
9620 constant and 0 if it is not known to be a compile-time constant.  A
9621 return of 0 does not indicate that the value is @emph{not} a constant,
9622 but merely that GCC cannot prove it is a constant with the specified
9623 value of the @option{-O} option.
9624
9625 You typically use this function in an embedded application where
9626 memory is a critical resource.  If you have some complex calculation,
9627 you may want it to be folded if it involves constants, but need to call
9628 a function if it does not.  For example:
9629
9630 @smallexample
9631 #define Scale_Value(X)      \
9632   (__builtin_constant_p (X) \
9633   ? ((X) * SCALE + OFFSET) : Scale (X))
9634 @end smallexample
9635
9636 You may use this built-in function in either a macro or an inline
9637 function.  However, if you use it in an inlined function and pass an
9638 argument of the function as the argument to the built-in, GCC 
9639 never returns 1 when you call the inline function with a string constant
9640 or compound literal (@pxref{Compound Literals}) and does not return 1
9641 when you pass a constant numeric value to the inline function unless you
9642 specify the @option{-O} option.
9643
9644 You may also use @code{__builtin_constant_p} in initializers for static
9645 data.  For instance, you can write
9646
9647 @smallexample
9648 static const int table[] = @{
9649    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
9650    /* @r{@dots{}} */
9651 @};
9652 @end smallexample
9653
9654 @noindent
9655 This is an acceptable initializer even if @var{EXPRESSION} is not a
9656 constant expression, including the case where
9657 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
9658 folded to a constant but @var{EXPRESSION} contains operands that are
9659 not otherwise permitted in a static initializer (for example,
9660 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
9661 built-in in this case, because it has no opportunity to perform
9662 optimization.
9663
9664 Previous versions of GCC did not accept this built-in in data
9665 initializers.  The earliest version where it is completely safe is
9666 3.0.1.
9667 @end deftypefn
9668
9669 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
9670 @opindex fprofile-arcs
9671 You may use @code{__builtin_expect} to provide the compiler with
9672 branch prediction information.  In general, you should prefer to
9673 use actual profile feedback for this (@option{-fprofile-arcs}), as
9674 programmers are notoriously bad at predicting how their programs
9675 actually perform.  However, there are applications in which this
9676 data is hard to collect.
9677
9678 The return value is the value of @var{exp}, which should be an integral
9679 expression.  The semantics of the built-in are that it is expected that
9680 @var{exp} == @var{c}.  For example:
9681
9682 @smallexample
9683 if (__builtin_expect (x, 0))
9684   foo ();
9685 @end smallexample
9686
9687 @noindent
9688 indicates that we do not expect to call @code{foo}, since
9689 we expect @code{x} to be zero.  Since you are limited to integral
9690 expressions for @var{exp}, you should use constructions such as
9691
9692 @smallexample
9693 if (__builtin_expect (ptr != NULL, 1))
9694   foo (*ptr);
9695 @end smallexample
9696
9697 @noindent
9698 when testing pointer or floating-point values.
9699 @end deftypefn
9700
9701 @deftypefn {Built-in Function} void __builtin_trap (void)
9702 This function causes the program to exit abnormally.  GCC implements
9703 this function by using a target-dependent mechanism (such as
9704 intentionally executing an illegal instruction) or by calling
9705 @code{abort}.  The mechanism used may vary from release to release so
9706 you should not rely on any particular implementation.
9707 @end deftypefn
9708
9709 @deftypefn {Built-in Function} void __builtin_unreachable (void)
9710 If control flow reaches the point of the @code{__builtin_unreachable},
9711 the program is undefined.  It is useful in situations where the
9712 compiler cannot deduce the unreachability of the code.
9713
9714 One such case is immediately following an @code{asm} statement that
9715 either never terminates, or one that transfers control elsewhere
9716 and never returns.  In this example, without the
9717 @code{__builtin_unreachable}, GCC issues a warning that control
9718 reaches the end of a non-void function.  It also generates code
9719 to return after the @code{asm}.
9720
9721 @smallexample
9722 int f (int c, int v)
9723 @{
9724   if (c)
9725     @{
9726       return v;
9727     @}
9728   else
9729     @{
9730       asm("jmp error_handler");
9731       __builtin_unreachable ();
9732     @}
9733 @}
9734 @end smallexample
9735
9736 @noindent
9737 Because the @code{asm} statement unconditionally transfers control out
9738 of the function, control never reaches the end of the function
9739 body.  The @code{__builtin_unreachable} is in fact unreachable and
9740 communicates this fact to the compiler.
9741
9742 Another use for @code{__builtin_unreachable} is following a call a
9743 function that never returns but that is not declared
9744 @code{__attribute__((noreturn))}, as in this example:
9745
9746 @smallexample
9747 void function_that_never_returns (void);
9748
9749 int g (int c)
9750 @{
9751   if (c)
9752     @{
9753       return 1;
9754     @}
9755   else
9756     @{
9757       function_that_never_returns ();
9758       __builtin_unreachable ();
9759     @}
9760 @}
9761 @end smallexample
9762
9763 @end deftypefn
9764
9765 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
9766 This function returns its first argument, and allows the compiler
9767 to assume that the returned pointer is at least @var{align} bytes
9768 aligned.  This built-in can have either two or three arguments,
9769 if it has three, the third argument should have integer type, and
9770 if it is nonzero means misalignment offset.  For example:
9771
9772 @smallexample
9773 void *x = __builtin_assume_aligned (arg, 16);
9774 @end smallexample
9775
9776 @noindent
9777 means that the compiler can assume @code{x}, set to @code{arg}, is at least
9778 16-byte aligned, while:
9779
9780 @smallexample
9781 void *x = __builtin_assume_aligned (arg, 32, 8);
9782 @end smallexample
9783
9784 @noindent
9785 means that the compiler can assume for @code{x}, set to @code{arg}, that
9786 @code{(char *) x - 8} is 32-byte aligned.
9787 @end deftypefn
9788
9789 @deftypefn {Built-in Function} int __builtin_LINE ()
9790 This function is the equivalent to the preprocessor @code{__LINE__}
9791 macro and returns the line number of the invocation of the built-in.
9792 In a C++ default argument for a function @var{F}, it gets the line number of
9793 the call to @var{F}.
9794 @end deftypefn
9795
9796 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
9797 This function is the equivalent to the preprocessor @code{__FUNCTION__}
9798 macro and returns the function name the invocation of the built-in is in.
9799 @end deftypefn
9800
9801 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
9802 This function is the equivalent to the preprocessor @code{__FILE__}
9803 macro and returns the file name the invocation of the built-in is in.
9804 In a C++ default argument for a function @var{F}, it gets the file name of
9805 the call to @var{F}.
9806 @end deftypefn
9807
9808 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
9809 This function is used to flush the processor's instruction cache for
9810 the region of memory between @var{begin} inclusive and @var{end}
9811 exclusive.  Some targets require that the instruction cache be
9812 flushed, after modifying memory containing code, in order to obtain
9813 deterministic behavior.
9814
9815 If the target does not require instruction cache flushes,
9816 @code{__builtin___clear_cache} has no effect.  Otherwise either
9817 instructions are emitted in-line to clear the instruction cache or a
9818 call to the @code{__clear_cache} function in libgcc is made.
9819 @end deftypefn
9820
9821 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
9822 This function is used to minimize cache-miss latency by moving data into
9823 a cache before it is accessed.
9824 You can insert calls to @code{__builtin_prefetch} into code for which
9825 you know addresses of data in memory that is likely to be accessed soon.
9826 If the target supports them, data prefetch instructions are generated.
9827 If the prefetch is done early enough before the access then the data will
9828 be in the cache by the time it is accessed.
9829
9830 The value of @var{addr} is the address of the memory to prefetch.
9831 There are two optional arguments, @var{rw} and @var{locality}.
9832 The value of @var{rw} is a compile-time constant one or zero; one
9833 means that the prefetch is preparing for a write to the memory address
9834 and zero, the default, means that the prefetch is preparing for a read.
9835 The value @var{locality} must be a compile-time constant integer between
9836 zero and three.  A value of zero means that the data has no temporal
9837 locality, so it need not be left in the cache after the access.  A value
9838 of three means that the data has a high degree of temporal locality and
9839 should be left in all levels of cache possible.  Values of one and two
9840 mean, respectively, a low or moderate degree of temporal locality.  The
9841 default is three.
9842
9843 @smallexample
9844 for (i = 0; i < n; i++)
9845   @{
9846     a[i] = a[i] + b[i];
9847     __builtin_prefetch (&a[i+j], 1, 1);
9848     __builtin_prefetch (&b[i+j], 0, 1);
9849     /* @r{@dots{}} */
9850   @}
9851 @end smallexample
9852
9853 Data prefetch does not generate faults if @var{addr} is invalid, but
9854 the address expression itself must be valid.  For example, a prefetch
9855 of @code{p->next} does not fault if @code{p->next} is not a valid
9856 address, but evaluation faults if @code{p} is not a valid address.
9857
9858 If the target does not support data prefetch, the address expression
9859 is evaluated if it includes side effects but no other code is generated
9860 and GCC does not issue a warning.
9861 @end deftypefn
9862
9863 @deftypefn {Built-in Function} double __builtin_huge_val (void)
9864 Returns a positive infinity, if supported by the floating-point format,
9865 else @code{DBL_MAX}.  This function is suitable for implementing the
9866 ISO C macro @code{HUGE_VAL}.
9867 @end deftypefn
9868
9869 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
9870 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
9871 @end deftypefn
9872
9873 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
9874 Similar to @code{__builtin_huge_val}, except the return
9875 type is @code{long double}.
9876 @end deftypefn
9877
9878 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
9879 This built-in implements the C99 fpclassify functionality.  The first
9880 five int arguments should be the target library's notion of the
9881 possible FP classes and are used for return values.  They must be
9882 constant values and they must appear in this order: @code{FP_NAN},
9883 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
9884 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
9885 to classify.  GCC treats the last argument as type-generic, which
9886 means it does not do default promotion from float to double.
9887 @end deftypefn
9888
9889 @deftypefn {Built-in Function} double __builtin_inf (void)
9890 Similar to @code{__builtin_huge_val}, except a warning is generated
9891 if the target floating-point format does not support infinities.
9892 @end deftypefn
9893
9894 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
9895 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
9896 @end deftypefn
9897
9898 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
9899 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
9900 @end deftypefn
9901
9902 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
9903 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
9904 @end deftypefn
9905
9906 @deftypefn {Built-in Function} float __builtin_inff (void)
9907 Similar to @code{__builtin_inf}, except the return type is @code{float}.
9908 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
9909 @end deftypefn
9910
9911 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
9912 Similar to @code{__builtin_inf}, except the return
9913 type is @code{long double}.
9914 @end deftypefn
9915
9916 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
9917 Similar to @code{isinf}, except the return value is -1 for
9918 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
9919 Note while the parameter list is an
9920 ellipsis, this function only accepts exactly one floating-point
9921 argument.  GCC treats this parameter as type-generic, which means it
9922 does not do default promotion from float to double.
9923 @end deftypefn
9924
9925 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
9926 This is an implementation of the ISO C99 function @code{nan}.
9927
9928 Since ISO C99 defines this function in terms of @code{strtod}, which we
9929 do not implement, a description of the parsing is in order.  The string
9930 is parsed as by @code{strtol}; that is, the base is recognized by
9931 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
9932 in the significand such that the least significant bit of the number
9933 is at the least significant bit of the significand.  The number is
9934 truncated to fit the significand field provided.  The significand is
9935 forced to be a quiet NaN@.
9936
9937 This function, if given a string literal all of which would have been
9938 consumed by @code{strtol}, is evaluated early enough that it is considered a
9939 compile-time constant.
9940 @end deftypefn
9941
9942 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
9943 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
9944 @end deftypefn
9945
9946 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
9947 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
9948 @end deftypefn
9949
9950 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
9951 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
9952 @end deftypefn
9953
9954 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
9955 Similar to @code{__builtin_nan}, except the return type is @code{float}.
9956 @end deftypefn
9957
9958 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
9959 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
9960 @end deftypefn
9961
9962 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
9963 Similar to @code{__builtin_nan}, except the significand is forced
9964 to be a signaling NaN@.  The @code{nans} function is proposed by
9965 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
9966 @end deftypefn
9967
9968 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
9969 Similar to @code{__builtin_nans}, except the return type is @code{float}.
9970 @end deftypefn
9971
9972 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
9973 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
9974 @end deftypefn
9975
9976 @deftypefn {Built-in Function} int __builtin_ffs (int x)
9977 Returns one plus the index of the least significant 1-bit of @var{x}, or
9978 if @var{x} is zero, returns zero.
9979 @end deftypefn
9980
9981 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
9982 Returns the number of leading 0-bits in @var{x}, starting at the most
9983 significant bit position.  If @var{x} is 0, the result is undefined.
9984 @end deftypefn
9985
9986 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
9987 Returns the number of trailing 0-bits in @var{x}, starting at the least
9988 significant bit position.  If @var{x} is 0, the result is undefined.
9989 @end deftypefn
9990
9991 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
9992 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
9993 number of bits following the most significant bit that are identical
9994 to it.  There are no special cases for 0 or other values. 
9995 @end deftypefn
9996
9997 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
9998 Returns the number of 1-bits in @var{x}.
9999 @end deftypefn
10000
10001 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
10002 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
10003 modulo 2.
10004 @end deftypefn
10005
10006 @deftypefn {Built-in Function} int __builtin_ffsl (long)
10007 Similar to @code{__builtin_ffs}, except the argument type is
10008 @code{long}.
10009 @end deftypefn
10010
10011 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
10012 Similar to @code{__builtin_clz}, except the argument type is
10013 @code{unsigned long}.
10014 @end deftypefn
10015
10016 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
10017 Similar to @code{__builtin_ctz}, except the argument type is
10018 @code{unsigned long}.
10019 @end deftypefn
10020
10021 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
10022 Similar to @code{__builtin_clrsb}, except the argument type is
10023 @code{long}.
10024 @end deftypefn
10025
10026 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
10027 Similar to @code{__builtin_popcount}, except the argument type is
10028 @code{unsigned long}.
10029 @end deftypefn
10030
10031 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
10032 Similar to @code{__builtin_parity}, except the argument type is
10033 @code{unsigned long}.
10034 @end deftypefn
10035
10036 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
10037 Similar to @code{__builtin_ffs}, except the argument type is
10038 @code{long long}.
10039 @end deftypefn
10040
10041 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
10042 Similar to @code{__builtin_clz}, except the argument type is
10043 @code{unsigned long long}.
10044 @end deftypefn
10045
10046 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
10047 Similar to @code{__builtin_ctz}, except the argument type is
10048 @code{unsigned long long}.
10049 @end deftypefn
10050
10051 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
10052 Similar to @code{__builtin_clrsb}, except the argument type is
10053 @code{long long}.
10054 @end deftypefn
10055
10056 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
10057 Similar to @code{__builtin_popcount}, except the argument type is
10058 @code{unsigned long long}.
10059 @end deftypefn
10060
10061 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
10062 Similar to @code{__builtin_parity}, except the argument type is
10063 @code{unsigned long long}.
10064 @end deftypefn
10065
10066 @deftypefn {Built-in Function} double __builtin_powi (double, int)
10067 Returns the first argument raised to the power of the second.  Unlike the
10068 @code{pow} function no guarantees about precision and rounding are made.
10069 @end deftypefn
10070
10071 @deftypefn {Built-in Function} float __builtin_powif (float, int)
10072 Similar to @code{__builtin_powi}, except the argument and return types
10073 are @code{float}.
10074 @end deftypefn
10075
10076 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
10077 Similar to @code{__builtin_powi}, except the argument and return types
10078 are @code{long double}.
10079 @end deftypefn
10080
10081 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
10082 Returns @var{x} with the order of the bytes reversed; for example,
10083 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
10084 exactly 8 bits.
10085 @end deftypefn
10086
10087 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
10088 Similar to @code{__builtin_bswap16}, except the argument and return types
10089 are 32 bit.
10090 @end deftypefn
10091
10092 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
10093 Similar to @code{__builtin_bswap32}, except the argument and return types
10094 are 64 bit.
10095 @end deftypefn
10096
10097 @node Target Builtins
10098 @section Built-in Functions Specific to Particular Target Machines
10099
10100 On some target machines, GCC supports many built-in functions specific
10101 to those machines.  Generally these generate calls to specific machine
10102 instructions, but allow the compiler to schedule those calls.
10103
10104 @menu
10105 * AArch64 Built-in Functions::
10106 * Alpha Built-in Functions::
10107 * Altera Nios II Built-in Functions::
10108 * ARC Built-in Functions::
10109 * ARC SIMD Built-in Functions::
10110 * ARM iWMMXt Built-in Functions::
10111 * ARM C Language Extensions (ACLE)::
10112 * ARM Floating Point Status and Control Intrinsics::
10113 * AVR Built-in Functions::
10114 * Blackfin Built-in Functions::
10115 * FR-V Built-in Functions::
10116 * MIPS DSP Built-in Functions::
10117 * MIPS Paired-Single Support::
10118 * MIPS Loongson Built-in Functions::
10119 * Other MIPS Built-in Functions::
10120 * MSP430 Built-in Functions::
10121 * NDS32 Built-in Functions::
10122 * picoChip Built-in Functions::
10123 * PowerPC Built-in Functions::
10124 * PowerPC AltiVec/VSX Built-in Functions::
10125 * PowerPC Hardware Transactional Memory Built-in Functions::
10126 * RX Built-in Functions::
10127 * S/390 System z Built-in Functions::
10128 * SH Built-in Functions::
10129 * SPARC VIS Built-in Functions::
10130 * SPU Built-in Functions::
10131 * TI C6X Built-in Functions::
10132 * TILE-Gx Built-in Functions::
10133 * TILEPro Built-in Functions::
10134 * x86 Built-in Functions::
10135 * x86 transactional memory intrinsics::
10136 @end menu
10137
10138 @node AArch64 Built-in Functions
10139 @subsection AArch64 Built-in Functions
10140
10141 These built-in functions are available for the AArch64 family of
10142 processors.
10143 @smallexample
10144 unsigned int __builtin_aarch64_get_fpcr ()
10145 void __builtin_aarch64_set_fpcr (unsigned int)
10146 unsigned int __builtin_aarch64_get_fpsr ()
10147 void __builtin_aarch64_set_fpsr (unsigned int)
10148 @end smallexample
10149
10150 @node Alpha Built-in Functions
10151 @subsection Alpha Built-in Functions
10152
10153 These built-in functions are available for the Alpha family of
10154 processors, depending on the command-line switches used.
10155
10156 The following built-in functions are always available.  They
10157 all generate the machine instruction that is part of the name.
10158
10159 @smallexample
10160 long __builtin_alpha_implver (void)
10161 long __builtin_alpha_rpcc (void)
10162 long __builtin_alpha_amask (long)
10163 long __builtin_alpha_cmpbge (long, long)
10164 long __builtin_alpha_extbl (long, long)
10165 long __builtin_alpha_extwl (long, long)
10166 long __builtin_alpha_extll (long, long)
10167 long __builtin_alpha_extql (long, long)
10168 long __builtin_alpha_extwh (long, long)
10169 long __builtin_alpha_extlh (long, long)
10170 long __builtin_alpha_extqh (long, long)
10171 long __builtin_alpha_insbl (long, long)
10172 long __builtin_alpha_inswl (long, long)
10173 long __builtin_alpha_insll (long, long)
10174 long __builtin_alpha_insql (long, long)
10175 long __builtin_alpha_inswh (long, long)
10176 long __builtin_alpha_inslh (long, long)
10177 long __builtin_alpha_insqh (long, long)
10178 long __builtin_alpha_mskbl (long, long)
10179 long __builtin_alpha_mskwl (long, long)
10180 long __builtin_alpha_mskll (long, long)
10181 long __builtin_alpha_mskql (long, long)
10182 long __builtin_alpha_mskwh (long, long)
10183 long __builtin_alpha_msklh (long, long)
10184 long __builtin_alpha_mskqh (long, long)
10185 long __builtin_alpha_umulh (long, long)
10186 long __builtin_alpha_zap (long, long)
10187 long __builtin_alpha_zapnot (long, long)
10188 @end smallexample
10189
10190 The following built-in functions are always with @option{-mmax}
10191 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
10192 later.  They all generate the machine instruction that is part
10193 of the name.
10194
10195 @smallexample
10196 long __builtin_alpha_pklb (long)
10197 long __builtin_alpha_pkwb (long)
10198 long __builtin_alpha_unpkbl (long)
10199 long __builtin_alpha_unpkbw (long)
10200 long __builtin_alpha_minub8 (long, long)
10201 long __builtin_alpha_minsb8 (long, long)
10202 long __builtin_alpha_minuw4 (long, long)
10203 long __builtin_alpha_minsw4 (long, long)
10204 long __builtin_alpha_maxub8 (long, long)
10205 long __builtin_alpha_maxsb8 (long, long)
10206 long __builtin_alpha_maxuw4 (long, long)
10207 long __builtin_alpha_maxsw4 (long, long)
10208 long __builtin_alpha_perr (long, long)
10209 @end smallexample
10210
10211 The following built-in functions are always with @option{-mcix}
10212 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
10213 later.  They all generate the machine instruction that is part
10214 of the name.
10215
10216 @smallexample
10217 long __builtin_alpha_cttz (long)
10218 long __builtin_alpha_ctlz (long)
10219 long __builtin_alpha_ctpop (long)
10220 @end smallexample
10221
10222 The following built-in functions are available on systems that use the OSF/1
10223 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
10224 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
10225 @code{rdval} and @code{wrval}.
10226
10227 @smallexample
10228 void *__builtin_thread_pointer (void)
10229 void __builtin_set_thread_pointer (void *)
10230 @end smallexample
10231
10232 @node Altera Nios II Built-in Functions
10233 @subsection Altera Nios II Built-in Functions
10234
10235 These built-in functions are available for the Altera Nios II
10236 family of processors.
10237
10238 The following built-in functions are always available.  They
10239 all generate the machine instruction that is part of the name.
10240
10241 @example
10242 int __builtin_ldbio (volatile const void *)
10243 int __builtin_ldbuio (volatile const void *)
10244 int __builtin_ldhio (volatile const void *)
10245 int __builtin_ldhuio (volatile const void *)
10246 int __builtin_ldwio (volatile const void *)
10247 void __builtin_stbio (volatile void *, int)
10248 void __builtin_sthio (volatile void *, int)
10249 void __builtin_stwio (volatile void *, int)
10250 void __builtin_sync (void)
10251 int __builtin_rdctl (int) 
10252 void __builtin_wrctl (int, int)
10253 @end example
10254
10255 The following built-in functions are always available.  They
10256 all generate a Nios II Custom Instruction. The name of the
10257 function represents the types that the function takes and
10258 returns. The letter before the @code{n} is the return type
10259 or void if absent. The @code{n} represents the first parameter
10260 to all the custom instructions, the custom instruction number.
10261 The two letters after the @code{n} represent the up to two
10262 parameters to the function.
10263
10264 The letters represent the following data types:
10265 @table @code
10266 @item <no letter>
10267 @code{void} for return type and no parameter for parameter types.
10268
10269 @item i
10270 @code{int} for return type and parameter type
10271
10272 @item f
10273 @code{float} for return type and parameter type
10274
10275 @item p
10276 @code{void *} for return type and parameter type
10277
10278 @end table
10279
10280 And the function names are:
10281 @example
10282 void __builtin_custom_n (void)
10283 void __builtin_custom_ni (int)
10284 void __builtin_custom_nf (float)
10285 void __builtin_custom_np (void *)
10286 void __builtin_custom_nii (int, int)
10287 void __builtin_custom_nif (int, float)
10288 void __builtin_custom_nip (int, void *)
10289 void __builtin_custom_nfi (float, int)
10290 void __builtin_custom_nff (float, float)
10291 void __builtin_custom_nfp (float, void *)
10292 void __builtin_custom_npi (void *, int)
10293 void __builtin_custom_npf (void *, float)
10294 void __builtin_custom_npp (void *, void *)
10295 int __builtin_custom_in (void)
10296 int __builtin_custom_ini (int)
10297 int __builtin_custom_inf (float)
10298 int __builtin_custom_inp (void *)
10299 int __builtin_custom_inii (int, int)
10300 int __builtin_custom_inif (int, float)
10301 int __builtin_custom_inip (int, void *)
10302 int __builtin_custom_infi (float, int)
10303 int __builtin_custom_inff (float, float)
10304 int __builtin_custom_infp (float, void *)
10305 int __builtin_custom_inpi (void *, int)
10306 int __builtin_custom_inpf (void *, float)
10307 int __builtin_custom_inpp (void *, void *)
10308 float __builtin_custom_fn (void)
10309 float __builtin_custom_fni (int)
10310 float __builtin_custom_fnf (float)
10311 float __builtin_custom_fnp (void *)
10312 float __builtin_custom_fnii (int, int)
10313 float __builtin_custom_fnif (int, float)
10314 float __builtin_custom_fnip (int, void *)
10315 float __builtin_custom_fnfi (float, int)
10316 float __builtin_custom_fnff (float, float)
10317 float __builtin_custom_fnfp (float, void *)
10318 float __builtin_custom_fnpi (void *, int)
10319 float __builtin_custom_fnpf (void *, float)
10320 float __builtin_custom_fnpp (void *, void *)
10321 void * __builtin_custom_pn (void)
10322 void * __builtin_custom_pni (int)
10323 void * __builtin_custom_pnf (float)
10324 void * __builtin_custom_pnp (void *)
10325 void * __builtin_custom_pnii (int, int)
10326 void * __builtin_custom_pnif (int, float)
10327 void * __builtin_custom_pnip (int, void *)
10328 void * __builtin_custom_pnfi (float, int)
10329 void * __builtin_custom_pnff (float, float)
10330 void * __builtin_custom_pnfp (float, void *)
10331 void * __builtin_custom_pnpi (void *, int)
10332 void * __builtin_custom_pnpf (void *, float)
10333 void * __builtin_custom_pnpp (void *, void *)
10334 @end example
10335
10336 @node ARC Built-in Functions
10337 @subsection ARC Built-in Functions
10338
10339 The following built-in functions are provided for ARC targets.  The
10340 built-ins generate the corresponding assembly instructions.  In the
10341 examples given below, the generated code often requires an operand or
10342 result to be in a register.  Where necessary further code will be
10343 generated to ensure this is true, but for brevity this is not
10344 described in each case.
10345
10346 @emph{Note:} Using a built-in to generate an instruction not supported
10347 by a target may cause problems. At present the compiler is not
10348 guaranteed to detect such misuse, and as a result an internal compiler
10349 error may be generated.
10350
10351 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
10352 Return 1 if @var{val} is known to have the byte alignment given
10353 by @var{alignval}, otherwise return 0.
10354 Note that this is different from
10355 @smallexample
10356 __alignof__(*(char *)@var{val}) >= alignval
10357 @end smallexample
10358 because __alignof__ sees only the type of the dereference, whereas
10359 __builtin_arc_align uses alignment information from the pointer
10360 as well as from the pointed-to type.
10361 The information available will depend on optimization level.
10362 @end deftypefn
10363
10364 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
10365 Generates
10366 @example
10367 brk
10368 @end example
10369 @end deftypefn
10370
10371 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
10372 The operand is the number of a register to be read.  Generates:
10373 @example
10374 mov  @var{dest}, r@var{regno}
10375 @end example
10376 where the value in @var{dest} will be the result returned from the
10377 built-in.
10378 @end deftypefn
10379
10380 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
10381 The first operand is the number of a register to be written, the
10382 second operand is a compile time constant to write into that
10383 register.  Generates:
10384 @example
10385 mov  r@var{regno}, @var{val}
10386 @end example
10387 @end deftypefn
10388
10389 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
10390 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
10391 Generates:
10392 @example
10393 divaw  @var{dest}, @var{a}, @var{b}
10394 @end example
10395 where the value in @var{dest} will be the result returned from the
10396 built-in.
10397 @end deftypefn
10398
10399 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
10400 Generates
10401 @example
10402 flag  @var{a}
10403 @end example
10404 @end deftypefn
10405
10406 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
10407 The operand, @var{auxv}, is the address of an auxiliary register and
10408 must be a compile time constant.  Generates:
10409 @example
10410 lr  @var{dest}, [@var{auxr}]
10411 @end example
10412 Where the value in @var{dest} will be the result returned from the
10413 built-in.
10414 @end deftypefn
10415
10416 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
10417 Only available with @option{-mmul64}.  Generates:
10418 @example
10419 mul64  @var{a}, @var{b}
10420 @end example
10421 @end deftypefn
10422
10423 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
10424 Only available with @option{-mmul64}.  Generates:
10425 @example
10426 mulu64  @var{a}, @var{b}
10427 @end example
10428 @end deftypefn
10429
10430 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
10431 Generates:
10432 @example
10433 nop
10434 @end example
10435 @end deftypefn
10436
10437 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
10438 Only valid if the @samp{norm} instruction is available through the
10439 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10440 Generates:
10441 @example
10442 norm  @var{dest}, @var{src}
10443 @end example
10444 Where the value in @var{dest} will be the result returned from the
10445 built-in.
10446 @end deftypefn
10447
10448 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
10449 Only valid if the @samp{normw} instruction is available through the
10450 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
10451 Generates:
10452 @example
10453 normw  @var{dest}, @var{src}
10454 @end example
10455 Where the value in @var{dest} will be the result returned from the
10456 built-in.
10457 @end deftypefn
10458
10459 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
10460 Generates:
10461 @example
10462 rtie
10463 @end example
10464 @end deftypefn
10465
10466 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
10467 Generates:
10468 @example
10469 sleep  @var{a}
10470 @end example
10471 @end deftypefn
10472
10473 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
10474 The first argument, @var{auxv}, is the address of an auxiliary
10475 register, the second argument, @var{val}, is a compile time constant
10476 to be written to the register.  Generates:
10477 @example
10478 sr  @var{auxr}, [@var{val}]
10479 @end example
10480 @end deftypefn
10481
10482 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
10483 Only valid with @option{-mswap}.  Generates:
10484 @example
10485 swap  @var{dest}, @var{src}
10486 @end example
10487 Where the value in @var{dest} will be the result returned from the
10488 built-in.
10489 @end deftypefn
10490
10491 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
10492 Generates:
10493 @example
10494 swi
10495 @end example
10496 @end deftypefn
10497
10498 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
10499 Only available with @option{-mcpu=ARC700}.  Generates:
10500 @example
10501 sync
10502 @end example
10503 @end deftypefn
10504
10505 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
10506 Only available with @option{-mcpu=ARC700}.  Generates:
10507 @example
10508 trap_s  @var{c}
10509 @end example
10510 @end deftypefn
10511
10512 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
10513 Only available with @option{-mcpu=ARC700}.  Generates:
10514 @example
10515 unimp_s
10516 @end example
10517 @end deftypefn
10518
10519 The instructions generated by the following builtins are not
10520 considered as candidates for scheduling.  They are not moved around by
10521 the compiler during scheduling, and thus can be expected to appear
10522 where they are put in the C code:
10523 @example
10524 __builtin_arc_brk()
10525 __builtin_arc_core_read()
10526 __builtin_arc_core_write()
10527 __builtin_arc_flag()
10528 __builtin_arc_lr()
10529 __builtin_arc_sleep()
10530 __builtin_arc_sr()
10531 __builtin_arc_swi()
10532 @end example
10533
10534 @node ARC SIMD Built-in Functions
10535 @subsection ARC SIMD Built-in Functions
10536
10537 SIMD builtins provided by the compiler can be used to generate the
10538 vector instructions.  This section describes the available builtins
10539 and their usage in programs.  With the @option{-msimd} option, the
10540 compiler provides 128-bit vector types, which can be specified using
10541 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
10542 can be included to use the following predefined types:
10543 @example
10544 typedef int __v4si   __attribute__((vector_size(16)));
10545 typedef short __v8hi __attribute__((vector_size(16)));
10546 @end example
10547
10548 These types can be used to define 128-bit variables.  The built-in
10549 functions listed in the following section can be used on these
10550 variables to generate the vector operations.
10551
10552 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
10553 @file{arc-simd.h} also provides equivalent macros called
10554 @code{_@var{someinsn}} that can be used for programming ease and
10555 improved readability.  The following macros for DMA control are also
10556 provided:
10557 @example
10558 #define _setup_dma_in_channel_reg _vdiwr
10559 #define _setup_dma_out_channel_reg _vdowr
10560 @end example
10561
10562 The following is a complete list of all the SIMD built-ins provided
10563 for ARC, grouped by calling signature.
10564
10565 The following take two @code{__v8hi} arguments and return a
10566 @code{__v8hi} result:
10567 @example
10568 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
10569 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
10570 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
10571 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
10572 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
10573 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
10574 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
10575 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
10576 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
10577 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
10578 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
10579 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
10580 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
10581 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
10582 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
10583 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
10584 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
10585 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
10586 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
10587 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
10588 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
10589 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
10590 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
10591 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
10592 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
10593 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
10594 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
10595 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
10596 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
10597 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
10598 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
10599 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
10600 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
10601 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
10602 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
10603 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
10604 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
10605 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
10606 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
10607 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
10608 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
10609 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
10610 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
10611 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
10612 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
10613 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
10614 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
10615 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
10616 @end example
10617
10618 The following take one @code{__v8hi} and one @code{int} argument and return a
10619 @code{__v8hi} result:
10620
10621 @example
10622 __v8hi __builtin_arc_vbaddw (__v8hi, int)
10623 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
10624 __v8hi __builtin_arc_vbminw (__v8hi, int)
10625 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
10626 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
10627 __v8hi __builtin_arc_vbmulw (__v8hi, int)
10628 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
10629 __v8hi __builtin_arc_vbsubw (__v8hi, int)
10630 @end example
10631
10632 The following take one @code{__v8hi} argument and one @code{int} argument which
10633 must be a 3-bit compile time constant indicating a register number
10634 I0-I7.  They return a @code{__v8hi} result.
10635 @example
10636 __v8hi __builtin_arc_vasrw (__v8hi, const int)
10637 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
10638 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
10639 @end example
10640
10641 The following take one @code{__v8hi} argument and one @code{int}
10642 argument which must be a 6-bit compile time constant.  They return a
10643 @code{__v8hi} result.
10644 @example
10645 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
10646 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
10647 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
10648 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
10649 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
10650 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
10651 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
10652 @end example
10653
10654 The following take one @code{__v8hi} argument and one @code{int} argument which
10655 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10656 result.
10657 @example
10658 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
10659 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
10660 __v8hi __builtin_arc_vmvw (__v8hi, const int)
10661 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
10662 @end example
10663
10664 The following take two @code{int} arguments, the second of which which
10665 must be a 8-bit compile time constant.  They return a @code{__v8hi}
10666 result:
10667 @example
10668 __v8hi __builtin_arc_vmovaw (int, const int)
10669 __v8hi __builtin_arc_vmovw (int, const int)
10670 __v8hi __builtin_arc_vmovzw (int, const int)
10671 @end example
10672
10673 The following take a single @code{__v8hi} argument and return a
10674 @code{__v8hi} result:
10675 @example
10676 __v8hi __builtin_arc_vabsaw (__v8hi)
10677 __v8hi __builtin_arc_vabsw (__v8hi)
10678 __v8hi __builtin_arc_vaddsuw (__v8hi)
10679 __v8hi __builtin_arc_vexch1 (__v8hi)
10680 __v8hi __builtin_arc_vexch2 (__v8hi)
10681 __v8hi __builtin_arc_vexch4 (__v8hi)
10682 __v8hi __builtin_arc_vsignw (__v8hi)
10683 __v8hi __builtin_arc_vupbaw (__v8hi)
10684 __v8hi __builtin_arc_vupbw (__v8hi)
10685 __v8hi __builtin_arc_vupsbaw (__v8hi)
10686 __v8hi __builtin_arc_vupsbw (__v8hi)
10687 @end example
10688
10689 The followign take two @code{int} arguments and return no result:
10690 @example
10691 void __builtin_arc_vdirun (int, int)
10692 void __builtin_arc_vdorun (int, int)
10693 @end example
10694
10695 The following take two @code{int} arguments and return no result.  The
10696 first argument must a 3-bit compile time constant indicating one of
10697 the DR0-DR7 DMA setup channels:
10698 @example
10699 void __builtin_arc_vdiwr (const int, int)
10700 void __builtin_arc_vdowr (const int, int)
10701 @end example
10702
10703 The following take an @code{int} argument and return no result:
10704 @example
10705 void __builtin_arc_vendrec (int)
10706 void __builtin_arc_vrec (int)
10707 void __builtin_arc_vrecrun (int)
10708 void __builtin_arc_vrun (int)
10709 @end example
10710
10711 The following take a @code{__v8hi} argument and two @code{int}
10712 arguments and return a @code{__v8hi} result.  The second argument must
10713 be a 3-bit compile time constants, indicating one the registers I0-I7,
10714 and the third argument must be an 8-bit compile time constant.
10715
10716 @emph{Note:} Although the equivalent hardware instructions do not take
10717 an SIMD register as an operand, these builtins overwrite the relevant
10718 bits of the @code{__v8hi} register provided as the first argument with
10719 the value loaded from the @code{[Ib, u8]} location in the SDM.
10720
10721 @example
10722 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
10723 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
10724 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
10725 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
10726 @end example
10727
10728 The following take two @code{int} arguments and return a @code{__v8hi}
10729 result.  The first argument must be a 3-bit compile time constants,
10730 indicating one the registers I0-I7, and the second argument must be an
10731 8-bit compile time constant.
10732
10733 @example
10734 __v8hi __builtin_arc_vld128 (const int, const int)
10735 __v8hi __builtin_arc_vld64w (const int, const int)
10736 @end example
10737
10738 The following take a @code{__v8hi} argument and two @code{int}
10739 arguments and return no result.  The second argument must be a 3-bit
10740 compile time constants, indicating one the registers I0-I7, and the
10741 third argument must be an 8-bit compile time constant.
10742
10743 @example
10744 void __builtin_arc_vst128 (__v8hi, const int, const int)
10745 void __builtin_arc_vst64 (__v8hi, const int, const int)
10746 @end example
10747
10748 The following take a @code{__v8hi} argument and three @code{int}
10749 arguments and return no result.  The second argument must be a 3-bit
10750 compile-time constant, identifying the 16-bit sub-register to be
10751 stored, the third argument must be a 3-bit compile time constants,
10752 indicating one the registers I0-I7, and the fourth argument must be an
10753 8-bit compile time constant.
10754
10755 @example
10756 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
10757 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
10758 @end example
10759
10760 @node ARM iWMMXt Built-in Functions
10761 @subsection ARM iWMMXt Built-in Functions
10762
10763 These built-in functions are available for the ARM family of
10764 processors when the @option{-mcpu=iwmmxt} switch is used:
10765
10766 @smallexample
10767 typedef int v2si __attribute__ ((vector_size (8)));
10768 typedef short v4hi __attribute__ ((vector_size (8)));
10769 typedef char v8qi __attribute__ ((vector_size (8)));
10770
10771 int __builtin_arm_getwcgr0 (void)
10772 void __builtin_arm_setwcgr0 (int)
10773 int __builtin_arm_getwcgr1 (void)
10774 void __builtin_arm_setwcgr1 (int)
10775 int __builtin_arm_getwcgr2 (void)
10776 void __builtin_arm_setwcgr2 (int)
10777 int __builtin_arm_getwcgr3 (void)
10778 void __builtin_arm_setwcgr3 (int)
10779 int __builtin_arm_textrmsb (v8qi, int)
10780 int __builtin_arm_textrmsh (v4hi, int)
10781 int __builtin_arm_textrmsw (v2si, int)
10782 int __builtin_arm_textrmub (v8qi, int)
10783 int __builtin_arm_textrmuh (v4hi, int)
10784 int __builtin_arm_textrmuw (v2si, int)
10785 v8qi __builtin_arm_tinsrb (v8qi, int, int)
10786 v4hi __builtin_arm_tinsrh (v4hi, int, int)
10787 v2si __builtin_arm_tinsrw (v2si, int, int)
10788 long long __builtin_arm_tmia (long long, int, int)
10789 long long __builtin_arm_tmiabb (long long, int, int)
10790 long long __builtin_arm_tmiabt (long long, int, int)
10791 long long __builtin_arm_tmiaph (long long, int, int)
10792 long long __builtin_arm_tmiatb (long long, int, int)
10793 long long __builtin_arm_tmiatt (long long, int, int)
10794 int __builtin_arm_tmovmskb (v8qi)
10795 int __builtin_arm_tmovmskh (v4hi)
10796 int __builtin_arm_tmovmskw (v2si)
10797 long long __builtin_arm_waccb (v8qi)
10798 long long __builtin_arm_wacch (v4hi)
10799 long long __builtin_arm_waccw (v2si)
10800 v8qi __builtin_arm_waddb (v8qi, v8qi)
10801 v8qi __builtin_arm_waddbss (v8qi, v8qi)
10802 v8qi __builtin_arm_waddbus (v8qi, v8qi)
10803 v4hi __builtin_arm_waddh (v4hi, v4hi)
10804 v4hi __builtin_arm_waddhss (v4hi, v4hi)
10805 v4hi __builtin_arm_waddhus (v4hi, v4hi)
10806 v2si __builtin_arm_waddw (v2si, v2si)
10807 v2si __builtin_arm_waddwss (v2si, v2si)
10808 v2si __builtin_arm_waddwus (v2si, v2si)
10809 v8qi __builtin_arm_walign (v8qi, v8qi, int)
10810 long long __builtin_arm_wand(long long, long long)
10811 long long __builtin_arm_wandn (long long, long long)
10812 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
10813 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
10814 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
10815 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
10816 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
10817 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
10818 v2si __builtin_arm_wcmpeqw (v2si, v2si)
10819 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
10820 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
10821 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
10822 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
10823 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
10824 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
10825 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
10826 long long __builtin_arm_wmacsz (v4hi, v4hi)
10827 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
10828 long long __builtin_arm_wmacuz (v4hi, v4hi)
10829 v4hi __builtin_arm_wmadds (v4hi, v4hi)
10830 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
10831 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
10832 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
10833 v2si __builtin_arm_wmaxsw (v2si, v2si)
10834 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
10835 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
10836 v2si __builtin_arm_wmaxuw (v2si, v2si)
10837 v8qi __builtin_arm_wminsb (v8qi, v8qi)
10838 v4hi __builtin_arm_wminsh (v4hi, v4hi)
10839 v2si __builtin_arm_wminsw (v2si, v2si)
10840 v8qi __builtin_arm_wminub (v8qi, v8qi)
10841 v4hi __builtin_arm_wminuh (v4hi, v4hi)
10842 v2si __builtin_arm_wminuw (v2si, v2si)
10843 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
10844 v4hi __builtin_arm_wmulul (v4hi, v4hi)
10845 v4hi __builtin_arm_wmulum (v4hi, v4hi)
10846 long long __builtin_arm_wor (long long, long long)
10847 v2si __builtin_arm_wpackdss (long long, long long)
10848 v2si __builtin_arm_wpackdus (long long, long long)
10849 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
10850 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
10851 v4hi __builtin_arm_wpackwss (v2si, v2si)
10852 v4hi __builtin_arm_wpackwus (v2si, v2si)
10853 long long __builtin_arm_wrord (long long, long long)
10854 long long __builtin_arm_wrordi (long long, int)
10855 v4hi __builtin_arm_wrorh (v4hi, long long)
10856 v4hi __builtin_arm_wrorhi (v4hi, int)
10857 v2si __builtin_arm_wrorw (v2si, long long)
10858 v2si __builtin_arm_wrorwi (v2si, int)
10859 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
10860 v2si __builtin_arm_wsadbz (v8qi, v8qi)
10861 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
10862 v2si __builtin_arm_wsadhz (v4hi, v4hi)
10863 v4hi __builtin_arm_wshufh (v4hi, int)
10864 long long __builtin_arm_wslld (long long, long long)
10865 long long __builtin_arm_wslldi (long long, int)
10866 v4hi __builtin_arm_wsllh (v4hi, long long)
10867 v4hi __builtin_arm_wsllhi (v4hi, int)
10868 v2si __builtin_arm_wsllw (v2si, long long)
10869 v2si __builtin_arm_wsllwi (v2si, int)
10870 long long __builtin_arm_wsrad (long long, long long)
10871 long long __builtin_arm_wsradi (long long, int)
10872 v4hi __builtin_arm_wsrah (v4hi, long long)
10873 v4hi __builtin_arm_wsrahi (v4hi, int)
10874 v2si __builtin_arm_wsraw (v2si, long long)
10875 v2si __builtin_arm_wsrawi (v2si, int)
10876 long long __builtin_arm_wsrld (long long, long long)
10877 long long __builtin_arm_wsrldi (long long, int)
10878 v4hi __builtin_arm_wsrlh (v4hi, long long)
10879 v4hi __builtin_arm_wsrlhi (v4hi, int)
10880 v2si __builtin_arm_wsrlw (v2si, long long)
10881 v2si __builtin_arm_wsrlwi (v2si, int)
10882 v8qi __builtin_arm_wsubb (v8qi, v8qi)
10883 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
10884 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
10885 v4hi __builtin_arm_wsubh (v4hi, v4hi)
10886 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
10887 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
10888 v2si __builtin_arm_wsubw (v2si, v2si)
10889 v2si __builtin_arm_wsubwss (v2si, v2si)
10890 v2si __builtin_arm_wsubwus (v2si, v2si)
10891 v4hi __builtin_arm_wunpckehsb (v8qi)
10892 v2si __builtin_arm_wunpckehsh (v4hi)
10893 long long __builtin_arm_wunpckehsw (v2si)
10894 v4hi __builtin_arm_wunpckehub (v8qi)
10895 v2si __builtin_arm_wunpckehuh (v4hi)
10896 long long __builtin_arm_wunpckehuw (v2si)
10897 v4hi __builtin_arm_wunpckelsb (v8qi)
10898 v2si __builtin_arm_wunpckelsh (v4hi)
10899 long long __builtin_arm_wunpckelsw (v2si)
10900 v4hi __builtin_arm_wunpckelub (v8qi)
10901 v2si __builtin_arm_wunpckeluh (v4hi)
10902 long long __builtin_arm_wunpckeluw (v2si)
10903 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
10904 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
10905 v2si __builtin_arm_wunpckihw (v2si, v2si)
10906 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
10907 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
10908 v2si __builtin_arm_wunpckilw (v2si, v2si)
10909 long long __builtin_arm_wxor (long long, long long)
10910 long long __builtin_arm_wzero ()
10911 @end smallexample
10912
10913
10914 @node ARM C Language Extensions (ACLE)
10915 @subsection ARM C Language Extensions (ACLE)
10916
10917 GCC implements extensions for C as described in the ARM C Language
10918 Extensions (ACLE) specification, which can be found at
10919 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
10920
10921 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
10922 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
10923 intrinsics can be found at
10924 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
10925 The built-in intrinsics for the Advanced SIMD extension are available when
10926 NEON is enabled.
10927
10928 Currently, ARM and AArch64 back-ends do not support ACLE 2.0 fully.  Both
10929 back-ends support CRC32 intrinsics from @file{arm_acle.h}.  The ARM backend's
10930 16-bit floating-point Advanded SIMD Intrinsics currently comply to ACLE v1.1.
10931 AArch64's backend does not have support for 16-bit floating point Advanced SIMD
10932 Intrinsics yet.
10933
10934 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
10935 availability of extensions.
10936
10937 @node ARM Floating Point Status and Control Intrinsics
10938 @subsection ARM Floating Point Status and Control Intrinsics
10939
10940 These built-in functions are available for the ARM family of
10941 processors with floating-point unit.
10942
10943 @smallexample
10944 unsigned int __builtin_arm_get_fpscr ()
10945 void __builtin_arm_set_fpscr (unsigned int)
10946 @end smallexample
10947
10948 @node AVR Built-in Functions
10949 @subsection AVR Built-in Functions
10950
10951 For each built-in function for AVR, there is an equally named,
10952 uppercase built-in macro defined. That way users can easily query if
10953 or if not a specific built-in is implemented or not. For example, if
10954 @code{__builtin_avr_nop} is available the macro
10955 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
10956
10957 The following built-in functions map to the respective machine
10958 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
10959 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
10960 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
10961 as library call if no hardware multiplier is available.
10962
10963 @smallexample
10964 void __builtin_avr_nop (void)
10965 void __builtin_avr_sei (void)
10966 void __builtin_avr_cli (void)
10967 void __builtin_avr_sleep (void)
10968 void __builtin_avr_wdr (void)
10969 unsigned char __builtin_avr_swap (unsigned char)
10970 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
10971 int __builtin_avr_fmuls (char, char)
10972 int __builtin_avr_fmulsu (char, unsigned char)
10973 @end smallexample
10974
10975 In order to delay execution for a specific number of cycles, GCC
10976 implements
10977 @smallexample
10978 void __builtin_avr_delay_cycles (unsigned long ticks)
10979 @end smallexample
10980
10981 @noindent
10982 @code{ticks} is the number of ticks to delay execution. Note that this
10983 built-in does not take into account the effect of interrupts that
10984 might increase delay time. @code{ticks} must be a compile-time
10985 integer constant; delays with a variable number of cycles are not supported.
10986
10987 @smallexample
10988 char __builtin_avr_flash_segment (const __memx void*)
10989 @end smallexample
10990
10991 @noindent
10992 This built-in takes a byte address to the 24-bit
10993 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
10994 the number of the flash segment (the 64 KiB chunk) where the address
10995 points to.  Counting starts at @code{0}.
10996 If the address does not point to flash memory, return @code{-1}.
10997
10998 @smallexample
10999 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
11000 @end smallexample
11001
11002 @noindent
11003 Insert bits from @var{bits} into @var{val} and return the resulting
11004 value. The nibbles of @var{map} determine how the insertion is
11005 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
11006 @enumerate
11007 @item If @var{X} is @code{0xf},
11008 then the @var{n}-th bit of @var{val} is returned unaltered.
11009
11010 @item If X is in the range 0@dots{}7,
11011 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
11012
11013 @item If X is in the range 8@dots{}@code{0xe},
11014 then the @var{n}-th result bit is undefined.
11015 @end enumerate
11016
11017 @noindent
11018 One typical use case for this built-in is adjusting input and
11019 output values to non-contiguous port layouts. Some examples:
11020
11021 @smallexample
11022 // same as val, bits is unused
11023 __builtin_avr_insert_bits (0xffffffff, bits, val)
11024 @end smallexample
11025
11026 @smallexample
11027 // same as bits, val is unused
11028 __builtin_avr_insert_bits (0x76543210, bits, val)
11029 @end smallexample
11030
11031 @smallexample
11032 // same as rotating bits by 4
11033 __builtin_avr_insert_bits (0x32107654, bits, 0)
11034 @end smallexample
11035
11036 @smallexample
11037 // high nibble of result is the high nibble of val
11038 // low nibble of result is the low nibble of bits
11039 __builtin_avr_insert_bits (0xffff3210, bits, val)
11040 @end smallexample
11041
11042 @smallexample
11043 // reverse the bit order of bits
11044 __builtin_avr_insert_bits (0x01234567, bits, 0)
11045 @end smallexample
11046
11047 @node Blackfin Built-in Functions
11048 @subsection Blackfin Built-in Functions
11049
11050 Currently, there are two Blackfin-specific built-in functions.  These are
11051 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
11052 using inline assembly; by using these built-in functions the compiler can
11053 automatically add workarounds for hardware errata involving these
11054 instructions.  These functions are named as follows:
11055
11056 @smallexample
11057 void __builtin_bfin_csync (void)
11058 void __builtin_bfin_ssync (void)
11059 @end smallexample
11060
11061 @node FR-V Built-in Functions
11062 @subsection FR-V Built-in Functions
11063
11064 GCC provides many FR-V-specific built-in functions.  In general,
11065 these functions are intended to be compatible with those described
11066 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
11067 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
11068 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
11069 pointer rather than by value.
11070
11071 Most of the functions are named after specific FR-V instructions.
11072 Such functions are said to be ``directly mapped'' and are summarized
11073 here in tabular form.
11074
11075 @menu
11076 * Argument Types::
11077 * Directly-mapped Integer Functions::
11078 * Directly-mapped Media Functions::
11079 * Raw read/write Functions::
11080 * Other Built-in Functions::
11081 @end menu
11082
11083 @node Argument Types
11084 @subsubsection Argument Types
11085
11086 The arguments to the built-in functions can be divided into three groups:
11087 register numbers, compile-time constants and run-time values.  In order
11088 to make this classification clear at a glance, the arguments and return
11089 values are given the following pseudo types:
11090
11091 @multitable @columnfractions .20 .30 .15 .35
11092 @item Pseudo type @tab Real C type @tab Constant? @tab Description
11093 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
11094 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
11095 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
11096 @item @code{uw2} @tab @code{unsigned long long} @tab No
11097 @tab an unsigned doubleword
11098 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
11099 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
11100 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
11101 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
11102 @end multitable
11103
11104 These pseudo types are not defined by GCC, they are simply a notational
11105 convenience used in this manual.
11106
11107 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
11108 and @code{sw2} are evaluated at run time.  They correspond to
11109 register operands in the underlying FR-V instructions.
11110
11111 @code{const} arguments represent immediate operands in the underlying
11112 FR-V instructions.  They must be compile-time constants.
11113
11114 @code{acc} arguments are evaluated at compile time and specify the number
11115 of an accumulator register.  For example, an @code{acc} argument of 2
11116 selects the ACC2 register.
11117
11118 @code{iacc} arguments are similar to @code{acc} arguments but specify the
11119 number of an IACC register.  See @pxref{Other Built-in Functions}
11120 for more details.
11121
11122 @node Directly-mapped Integer Functions
11123 @subsubsection Directly-mapped Integer Functions
11124
11125 The functions listed below map directly to FR-V I-type instructions.
11126
11127 @multitable @columnfractions .45 .32 .23
11128 @item Function prototype @tab Example usage @tab Assembly output
11129 @item @code{sw1 __ADDSS (sw1, sw1)}
11130 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
11131 @tab @code{ADDSS @var{a},@var{b},@var{c}}
11132 @item @code{sw1 __SCAN (sw1, sw1)}
11133 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
11134 @tab @code{SCAN @var{a},@var{b},@var{c}}
11135 @item @code{sw1 __SCUTSS (sw1)}
11136 @tab @code{@var{b} = __SCUTSS (@var{a})}
11137 @tab @code{SCUTSS @var{a},@var{b}}
11138 @item @code{sw1 __SLASS (sw1, sw1)}
11139 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
11140 @tab @code{SLASS @var{a},@var{b},@var{c}}
11141 @item @code{void __SMASS (sw1, sw1)}
11142 @tab @code{__SMASS (@var{a}, @var{b})}
11143 @tab @code{SMASS @var{a},@var{b}}
11144 @item @code{void __SMSSS (sw1, sw1)}
11145 @tab @code{__SMSSS (@var{a}, @var{b})}
11146 @tab @code{SMSSS @var{a},@var{b}}
11147 @item @code{void __SMU (sw1, sw1)}
11148 @tab @code{__SMU (@var{a}, @var{b})}
11149 @tab @code{SMU @var{a},@var{b}}
11150 @item @code{sw2 __SMUL (sw1, sw1)}
11151 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
11152 @tab @code{SMUL @var{a},@var{b},@var{c}}
11153 @item @code{sw1 __SUBSS (sw1, sw1)}
11154 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
11155 @tab @code{SUBSS @var{a},@var{b},@var{c}}
11156 @item @code{uw2 __UMUL (uw1, uw1)}
11157 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
11158 @tab @code{UMUL @var{a},@var{b},@var{c}}
11159 @end multitable
11160
11161 @node Directly-mapped Media Functions
11162 @subsubsection Directly-mapped Media Functions
11163
11164 The functions listed below map directly to FR-V M-type instructions.
11165
11166 @multitable @columnfractions .45 .32 .23
11167 @item Function prototype @tab Example usage @tab Assembly output
11168 @item @code{uw1 __MABSHS (sw1)}
11169 @tab @code{@var{b} = __MABSHS (@var{a})}
11170 @tab @code{MABSHS @var{a},@var{b}}
11171 @item @code{void __MADDACCS (acc, acc)}
11172 @tab @code{__MADDACCS (@var{b}, @var{a})}
11173 @tab @code{MADDACCS @var{a},@var{b}}
11174 @item @code{sw1 __MADDHSS (sw1, sw1)}
11175 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
11176 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
11177 @item @code{uw1 __MADDHUS (uw1, uw1)}
11178 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
11179 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
11180 @item @code{uw1 __MAND (uw1, uw1)}
11181 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
11182 @tab @code{MAND @var{a},@var{b},@var{c}}
11183 @item @code{void __MASACCS (acc, acc)}
11184 @tab @code{__MASACCS (@var{b}, @var{a})}
11185 @tab @code{MASACCS @var{a},@var{b}}
11186 @item @code{uw1 __MAVEH (uw1, uw1)}
11187 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
11188 @tab @code{MAVEH @var{a},@var{b},@var{c}}
11189 @item @code{uw2 __MBTOH (uw1)}
11190 @tab @code{@var{b} = __MBTOH (@var{a})}
11191 @tab @code{MBTOH @var{a},@var{b}}
11192 @item @code{void __MBTOHE (uw1 *, uw1)}
11193 @tab @code{__MBTOHE (&@var{b}, @var{a})}
11194 @tab @code{MBTOHE @var{a},@var{b}}
11195 @item @code{void __MCLRACC (acc)}
11196 @tab @code{__MCLRACC (@var{a})}
11197 @tab @code{MCLRACC @var{a}}
11198 @item @code{void __MCLRACCA (void)}
11199 @tab @code{__MCLRACCA ()}
11200 @tab @code{MCLRACCA}
11201 @item @code{uw1 __Mcop1 (uw1, uw1)}
11202 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
11203 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
11204 @item @code{uw1 __Mcop2 (uw1, uw1)}
11205 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
11206 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
11207 @item @code{uw1 __MCPLHI (uw2, const)}
11208 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
11209 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
11210 @item @code{uw1 __MCPLI (uw2, const)}
11211 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
11212 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
11213 @item @code{void __MCPXIS (acc, sw1, sw1)}
11214 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
11215 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
11216 @item @code{void __MCPXIU (acc, uw1, uw1)}
11217 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
11218 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
11219 @item @code{void __MCPXRS (acc, sw1, sw1)}
11220 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
11221 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
11222 @item @code{void __MCPXRU (acc, uw1, uw1)}
11223 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
11224 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
11225 @item @code{uw1 __MCUT (acc, uw1)}
11226 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
11227 @tab @code{MCUT @var{a},@var{b},@var{c}}
11228 @item @code{uw1 __MCUTSS (acc, sw1)}
11229 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
11230 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
11231 @item @code{void __MDADDACCS (acc, acc)}
11232 @tab @code{__MDADDACCS (@var{b}, @var{a})}
11233 @tab @code{MDADDACCS @var{a},@var{b}}
11234 @item @code{void __MDASACCS (acc, acc)}
11235 @tab @code{__MDASACCS (@var{b}, @var{a})}
11236 @tab @code{MDASACCS @var{a},@var{b}}
11237 @item @code{uw2 __MDCUTSSI (acc, const)}
11238 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
11239 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
11240 @item @code{uw2 __MDPACKH (uw2, uw2)}
11241 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
11242 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
11243 @item @code{uw2 __MDROTLI (uw2, const)}
11244 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
11245 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
11246 @item @code{void __MDSUBACCS (acc, acc)}
11247 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
11248 @tab @code{MDSUBACCS @var{a},@var{b}}
11249 @item @code{void __MDUNPACKH (uw1 *, uw2)}
11250 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
11251 @tab @code{MDUNPACKH @var{a},@var{b}}
11252 @item @code{uw2 __MEXPDHD (uw1, const)}
11253 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
11254 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
11255 @item @code{uw1 __MEXPDHW (uw1, const)}
11256 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
11257 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
11258 @item @code{uw1 __MHDSETH (uw1, const)}
11259 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
11260 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
11261 @item @code{sw1 __MHDSETS (const)}
11262 @tab @code{@var{b} = __MHDSETS (@var{a})}
11263 @tab @code{MHDSETS #@var{a},@var{b}}
11264 @item @code{uw1 __MHSETHIH (uw1, const)}
11265 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
11266 @tab @code{MHSETHIH #@var{a},@var{b}}
11267 @item @code{sw1 __MHSETHIS (sw1, const)}
11268 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
11269 @tab @code{MHSETHIS #@var{a},@var{b}}
11270 @item @code{uw1 __MHSETLOH (uw1, const)}
11271 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
11272 @tab @code{MHSETLOH #@var{a},@var{b}}
11273 @item @code{sw1 __MHSETLOS (sw1, const)}
11274 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
11275 @tab @code{MHSETLOS #@var{a},@var{b}}
11276 @item @code{uw1 __MHTOB (uw2)}
11277 @tab @code{@var{b} = __MHTOB (@var{a})}
11278 @tab @code{MHTOB @var{a},@var{b}}
11279 @item @code{void __MMACHS (acc, sw1, sw1)}
11280 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
11281 @tab @code{MMACHS @var{a},@var{b},@var{c}}
11282 @item @code{void __MMACHU (acc, uw1, uw1)}
11283 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
11284 @tab @code{MMACHU @var{a},@var{b},@var{c}}
11285 @item @code{void __MMRDHS (acc, sw1, sw1)}
11286 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
11287 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
11288 @item @code{void __MMRDHU (acc, uw1, uw1)}
11289 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
11290 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
11291 @item @code{void __MMULHS (acc, sw1, sw1)}
11292 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
11293 @tab @code{MMULHS @var{a},@var{b},@var{c}}
11294 @item @code{void __MMULHU (acc, uw1, uw1)}
11295 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
11296 @tab @code{MMULHU @var{a},@var{b},@var{c}}
11297 @item @code{void __MMULXHS (acc, sw1, sw1)}
11298 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
11299 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
11300 @item @code{void __MMULXHU (acc, uw1, uw1)}
11301 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
11302 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
11303 @item @code{uw1 __MNOT (uw1)}
11304 @tab @code{@var{b} = __MNOT (@var{a})}
11305 @tab @code{MNOT @var{a},@var{b}}
11306 @item @code{uw1 __MOR (uw1, uw1)}
11307 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
11308 @tab @code{MOR @var{a},@var{b},@var{c}}
11309 @item @code{uw1 __MPACKH (uh, uh)}
11310 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
11311 @tab @code{MPACKH @var{a},@var{b},@var{c}}
11312 @item @code{sw2 __MQADDHSS (sw2, sw2)}
11313 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
11314 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
11315 @item @code{uw2 __MQADDHUS (uw2, uw2)}
11316 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
11317 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
11318 @item @code{void __MQCPXIS (acc, sw2, sw2)}
11319 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
11320 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
11321 @item @code{void __MQCPXIU (acc, uw2, uw2)}
11322 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
11323 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
11324 @item @code{void __MQCPXRS (acc, sw2, sw2)}
11325 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
11326 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
11327 @item @code{void __MQCPXRU (acc, uw2, uw2)}
11328 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
11329 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
11330 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
11331 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
11332 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
11333 @item @code{sw2 __MQLMTHS (sw2, sw2)}
11334 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
11335 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
11336 @item @code{void __MQMACHS (acc, sw2, sw2)}
11337 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
11338 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
11339 @item @code{void __MQMACHU (acc, uw2, uw2)}
11340 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
11341 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
11342 @item @code{void __MQMACXHS (acc, sw2, sw2)}
11343 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
11344 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
11345 @item @code{void __MQMULHS (acc, sw2, sw2)}
11346 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
11347 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
11348 @item @code{void __MQMULHU (acc, uw2, uw2)}
11349 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
11350 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
11351 @item @code{void __MQMULXHS (acc, sw2, sw2)}
11352 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
11353 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
11354 @item @code{void __MQMULXHU (acc, uw2, uw2)}
11355 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
11356 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
11357 @item @code{sw2 __MQSATHS (sw2, sw2)}
11358 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
11359 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
11360 @item @code{uw2 __MQSLLHI (uw2, int)}
11361 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
11362 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
11363 @item @code{sw2 __MQSRAHI (sw2, int)}
11364 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
11365 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
11366 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
11367 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
11368 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
11369 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
11370 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
11371 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
11372 @item @code{void __MQXMACHS (acc, sw2, sw2)}
11373 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
11374 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
11375 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
11376 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
11377 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
11378 @item @code{uw1 __MRDACC (acc)}
11379 @tab @code{@var{b} = __MRDACC (@var{a})}
11380 @tab @code{MRDACC @var{a},@var{b}}
11381 @item @code{uw1 __MRDACCG (acc)}
11382 @tab @code{@var{b} = __MRDACCG (@var{a})}
11383 @tab @code{MRDACCG @var{a},@var{b}}
11384 @item @code{uw1 __MROTLI (uw1, const)}
11385 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
11386 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
11387 @item @code{uw1 __MROTRI (uw1, const)}
11388 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
11389 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
11390 @item @code{sw1 __MSATHS (sw1, sw1)}
11391 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
11392 @tab @code{MSATHS @var{a},@var{b},@var{c}}
11393 @item @code{uw1 __MSATHU (uw1, uw1)}
11394 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
11395 @tab @code{MSATHU @var{a},@var{b},@var{c}}
11396 @item @code{uw1 __MSLLHI (uw1, const)}
11397 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
11398 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
11399 @item @code{sw1 __MSRAHI (sw1, const)}
11400 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
11401 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
11402 @item @code{uw1 __MSRLHI (uw1, const)}
11403 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
11404 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
11405 @item @code{void __MSUBACCS (acc, acc)}
11406 @tab @code{__MSUBACCS (@var{b}, @var{a})}
11407 @tab @code{MSUBACCS @var{a},@var{b}}
11408 @item @code{sw1 __MSUBHSS (sw1, sw1)}
11409 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
11410 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
11411 @item @code{uw1 __MSUBHUS (uw1, uw1)}
11412 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
11413 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
11414 @item @code{void __MTRAP (void)}
11415 @tab @code{__MTRAP ()}
11416 @tab @code{MTRAP}
11417 @item @code{uw2 __MUNPACKH (uw1)}
11418 @tab @code{@var{b} = __MUNPACKH (@var{a})}
11419 @tab @code{MUNPACKH @var{a},@var{b}}
11420 @item @code{uw1 __MWCUT (uw2, uw1)}
11421 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
11422 @tab @code{MWCUT @var{a},@var{b},@var{c}}
11423 @item @code{void __MWTACC (acc, uw1)}
11424 @tab @code{__MWTACC (@var{b}, @var{a})}
11425 @tab @code{MWTACC @var{a},@var{b}}
11426 @item @code{void __MWTACCG (acc, uw1)}
11427 @tab @code{__MWTACCG (@var{b}, @var{a})}
11428 @tab @code{MWTACCG @var{a},@var{b}}
11429 @item @code{uw1 __MXOR (uw1, uw1)}
11430 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
11431 @tab @code{MXOR @var{a},@var{b},@var{c}}
11432 @end multitable
11433
11434 @node Raw read/write Functions
11435 @subsubsection Raw read/write Functions
11436
11437 This sections describes built-in functions related to read and write
11438 instructions to access memory.  These functions generate
11439 @code{membar} instructions to flush the I/O load and stores where
11440 appropriate, as described in Fujitsu's manual described above.
11441
11442 @table @code
11443
11444 @item unsigned char __builtin_read8 (void *@var{data})
11445 @item unsigned short __builtin_read16 (void *@var{data})
11446 @item unsigned long __builtin_read32 (void *@var{data})
11447 @item unsigned long long __builtin_read64 (void *@var{data})
11448
11449 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
11450 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
11451 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
11452 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
11453 @end table
11454
11455 @node Other Built-in Functions
11456 @subsubsection Other Built-in Functions
11457
11458 This section describes built-in functions that are not named after
11459 a specific FR-V instruction.
11460
11461 @table @code
11462 @item sw2 __IACCreadll (iacc @var{reg})
11463 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
11464 for future expansion and must be 0.
11465
11466 @item sw1 __IACCreadl (iacc @var{reg})
11467 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
11468 Other values of @var{reg} are rejected as invalid.
11469
11470 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
11471 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
11472 is reserved for future expansion and must be 0.
11473
11474 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
11475 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
11476 is 1.  Other values of @var{reg} are rejected as invalid.
11477
11478 @item void __data_prefetch0 (const void *@var{x})
11479 Use the @code{dcpl} instruction to load the contents of address @var{x}
11480 into the data cache.
11481
11482 @item void __data_prefetch (const void *@var{x})
11483 Use the @code{nldub} instruction to load the contents of address @var{x}
11484 into the data cache.  The instruction is issued in slot I1@.
11485 @end table
11486
11487 @node MIPS DSP Built-in Functions
11488 @subsection MIPS DSP Built-in Functions
11489
11490 The MIPS DSP Application-Specific Extension (ASE) includes new
11491 instructions that are designed to improve the performance of DSP and
11492 media applications.  It provides instructions that operate on packed
11493 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11494
11495 GCC supports MIPS DSP operations using both the generic
11496 vector extensions (@pxref{Vector Extensions}) and a collection of
11497 MIPS-specific built-in functions.  Both kinds of support are
11498 enabled by the @option{-mdsp} command-line option.
11499
11500 Revision 2 of the ASE was introduced in the second half of 2006.
11501 This revision adds extra instructions to the original ASE, but is
11502 otherwise backwards-compatible with it.  You can select revision 2
11503 using the command-line option @option{-mdspr2}; this option implies
11504 @option{-mdsp}.
11505
11506 The SCOUNT and POS bits of the DSP control register are global.  The
11507 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11508 POS bits.  During optimization, the compiler does not delete these
11509 instructions and it does not delete calls to functions containing
11510 these instructions.
11511
11512 At present, GCC only provides support for operations on 32-bit
11513 vectors.  The vector type associated with 8-bit integer data is
11514 usually called @code{v4i8}, the vector type associated with Q7
11515 is usually called @code{v4q7}, the vector type associated with 16-bit
11516 integer data is usually called @code{v2i16}, and the vector type
11517 associated with Q15 is usually called @code{v2q15}.  They can be
11518 defined in C as follows:
11519
11520 @smallexample
11521 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11522 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11523 typedef short v2i16 __attribute__ ((vector_size(4)));
11524 typedef short v2q15 __attribute__ ((vector_size(4)));
11525 @end smallexample
11526
11527 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11528 initialized in the same way as aggregates.  For example:
11529
11530 @smallexample
11531 v4i8 a = @{1, 2, 3, 4@};
11532 v4i8 b;
11533 b = (v4i8) @{5, 6, 7, 8@};
11534
11535 v2q15 c = @{0x0fcb, 0x3a75@};
11536 v2q15 d;
11537 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11538 @end smallexample
11539
11540 @emph{Note:} The CPU's endianness determines the order in which values
11541 are packed.  On little-endian targets, the first value is the least
11542 significant and the last value is the most significant.  The opposite
11543 order applies to big-endian targets.  For example, the code above
11544 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11545 and @code{4} on big-endian targets.
11546
11547 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11548 representation.  As shown in this example, the integer representation
11549 of a Q7 value can be obtained by multiplying the fractional value by
11550 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
11551 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
11552 @code{0x1.0p31}.
11553
11554 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11555 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
11556 and @code{c} and @code{d} are @code{v2q15} values.
11557
11558 @multitable @columnfractions .50 .50
11559 @item C code @tab MIPS instruction
11560 @item @code{a + b} @tab @code{addu.qb}
11561 @item @code{c + d} @tab @code{addq.ph}
11562 @item @code{a - b} @tab @code{subu.qb}
11563 @item @code{c - d} @tab @code{subq.ph}
11564 @end multitable
11565
11566 The table below lists the @code{v2i16} operation for which
11567 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
11568 @code{v2i16} values.
11569
11570 @multitable @columnfractions .50 .50
11571 @item C code @tab MIPS instruction
11572 @item @code{e * f} @tab @code{mul.ph}
11573 @end multitable
11574
11575 It is easier to describe the DSP built-in functions if we first define
11576 the following types:
11577
11578 @smallexample
11579 typedef int q31;
11580 typedef int i32;
11581 typedef unsigned int ui32;
11582 typedef long long a64;
11583 @end smallexample
11584
11585 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11586 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11587 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
11588 @code{long long}, but we use @code{a64} to indicate values that are
11589 placed in one of the four DSP accumulators (@code{$ac0},
11590 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11591
11592 Also, some built-in functions prefer or require immediate numbers as
11593 parameters, because the corresponding DSP instructions accept both immediate
11594 numbers and register operands, or accept immediate numbers only.  The
11595 immediate parameters are listed as follows.
11596
11597 @smallexample
11598 imm0_3: 0 to 3.
11599 imm0_7: 0 to 7.
11600 imm0_15: 0 to 15.
11601 imm0_31: 0 to 31.
11602 imm0_63: 0 to 63.
11603 imm0_255: 0 to 255.
11604 imm_n32_31: -32 to 31.
11605 imm_n512_511: -512 to 511.
11606 @end smallexample
11607
11608 The following built-in functions map directly to a particular MIPS DSP
11609 instruction.  Please refer to the architecture specification
11610 for details on what each instruction does.
11611
11612 @smallexample
11613 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11614 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11615 q31 __builtin_mips_addq_s_w (q31, q31)
11616 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11617 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11618 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11619 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11620 q31 __builtin_mips_subq_s_w (q31, q31)
11621 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11622 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11623 i32 __builtin_mips_addsc (i32, i32)
11624 i32 __builtin_mips_addwc (i32, i32)
11625 i32 __builtin_mips_modsub (i32, i32)
11626 i32 __builtin_mips_raddu_w_qb (v4i8)
11627 v2q15 __builtin_mips_absq_s_ph (v2q15)
11628 q31 __builtin_mips_absq_s_w (q31)
11629 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11630 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11631 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11632 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11633 q31 __builtin_mips_preceq_w_phl (v2q15)
11634 q31 __builtin_mips_preceq_w_phr (v2q15)
11635 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11636 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11637 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11638 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11639 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11640 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11641 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11642 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11643 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11644 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11645 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11646 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11647 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11648 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11649 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11650 q31 __builtin_mips_shll_s_w (q31, i32)
11651 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11652 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11653 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11654 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11655 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11656 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11657 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11658 q31 __builtin_mips_shra_r_w (q31, i32)
11659 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11660 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11661 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11662 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11663 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11664 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11665 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11666 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11667 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11668 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11669 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11670 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11671 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11672 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11673 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11674 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11675 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11676 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11677 i32 __builtin_mips_bitrev (i32)
11678 i32 __builtin_mips_insv (i32, i32)
11679 v4i8 __builtin_mips_repl_qb (imm0_255)
11680 v4i8 __builtin_mips_repl_qb (i32)
11681 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11682 v2q15 __builtin_mips_repl_ph (i32)
11683 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11684 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11685 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11686 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11687 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11688 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11689 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11690 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11691 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11692 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11693 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11694 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11695 i32 __builtin_mips_extr_w (a64, imm0_31)
11696 i32 __builtin_mips_extr_w (a64, i32)
11697 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11698 i32 __builtin_mips_extr_s_h (a64, i32)
11699 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11700 i32 __builtin_mips_extr_rs_w (a64, i32)
11701 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11702 i32 __builtin_mips_extr_r_w (a64, i32)
11703 i32 __builtin_mips_extp (a64, imm0_31)
11704 i32 __builtin_mips_extp (a64, i32)
11705 i32 __builtin_mips_extpdp (a64, imm0_31)
11706 i32 __builtin_mips_extpdp (a64, i32)
11707 a64 __builtin_mips_shilo (a64, imm_n32_31)
11708 a64 __builtin_mips_shilo (a64, i32)
11709 a64 __builtin_mips_mthlip (a64, i32)
11710 void __builtin_mips_wrdsp (i32, imm0_63)
11711 i32 __builtin_mips_rddsp (imm0_63)
11712 i32 __builtin_mips_lbux (void *, i32)
11713 i32 __builtin_mips_lhx (void *, i32)
11714 i32 __builtin_mips_lwx (void *, i32)
11715 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11716 i32 __builtin_mips_bposge32 (void)
11717 a64 __builtin_mips_madd (a64, i32, i32);
11718 a64 __builtin_mips_maddu (a64, ui32, ui32);
11719 a64 __builtin_mips_msub (a64, i32, i32);
11720 a64 __builtin_mips_msubu (a64, ui32, ui32);
11721 a64 __builtin_mips_mult (i32, i32);
11722 a64 __builtin_mips_multu (ui32, ui32);
11723 @end smallexample
11724
11725 The following built-in functions map directly to a particular MIPS DSP REV 2
11726 instruction.  Please refer to the architecture specification
11727 for details on what each instruction does.
11728
11729 @smallexample
11730 v4q7 __builtin_mips_absq_s_qb (v4q7);
11731 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11732 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11733 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11734 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11735 i32 __builtin_mips_append (i32, i32, imm0_31);
11736 i32 __builtin_mips_balign (i32, i32, imm0_3);
11737 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11738 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11739 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11740 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11741 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11742 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11743 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11744 q31 __builtin_mips_mulq_rs_w (q31, q31);
11745 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11746 q31 __builtin_mips_mulq_s_w (q31, q31);
11747 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11748 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11749 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11750 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11751 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11752 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11753 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11754 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11755 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11756 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11757 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11758 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11759 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11760 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11761 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11762 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11763 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11764 q31 __builtin_mips_addqh_w (q31, q31);
11765 q31 __builtin_mips_addqh_r_w (q31, q31);
11766 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11767 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11768 q31 __builtin_mips_subqh_w (q31, q31);
11769 q31 __builtin_mips_subqh_r_w (q31, q31);
11770 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11771 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11772 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11773 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11774 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11775 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11776 @end smallexample
11777
11778
11779 @node MIPS Paired-Single Support
11780 @subsection MIPS Paired-Single Support
11781
11782 The MIPS64 architecture includes a number of instructions that
11783 operate on pairs of single-precision floating-point values.
11784 Each pair is packed into a 64-bit floating-point register,
11785 with one element being designated the ``upper half'' and
11786 the other being designated the ``lower half''.
11787
11788 GCC supports paired-single operations using both the generic
11789 vector extensions (@pxref{Vector Extensions}) and a collection of
11790 MIPS-specific built-in functions.  Both kinds of support are
11791 enabled by the @option{-mpaired-single} command-line option.
11792
11793 The vector type associated with paired-single values is usually
11794 called @code{v2sf}.  It can be defined in C as follows:
11795
11796 @smallexample
11797 typedef float v2sf __attribute__ ((vector_size (8)));
11798 @end smallexample
11799
11800 @code{v2sf} values are initialized in the same way as aggregates.
11801 For example:
11802
11803 @smallexample
11804 v2sf a = @{1.5, 9.1@};
11805 v2sf b;
11806 float e, f;
11807 b = (v2sf) @{e, f@};
11808 @end smallexample
11809
11810 @emph{Note:} The CPU's endianness determines which value is stored in
11811 the upper half of a register and which value is stored in the lower half.
11812 On little-endian targets, the first value is the lower one and the second
11813 value is the upper one.  The opposite order applies to big-endian targets.
11814 For example, the code above sets the lower half of @code{a} to
11815 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11816
11817 @node MIPS Loongson Built-in Functions
11818 @subsection MIPS Loongson Built-in Functions
11819
11820 GCC provides intrinsics to access the SIMD instructions provided by the
11821 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
11822 available after inclusion of the @code{loongson.h} header file,
11823 operate on the following 64-bit vector types:
11824
11825 @itemize
11826 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11827 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11828 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11829 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11830 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11831 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11832 @end itemize
11833
11834 The intrinsics provided are listed below; each is named after the
11835 machine instruction to which it corresponds, with suffixes added as
11836 appropriate to distinguish intrinsics that expand to the same machine
11837 instruction yet have different argument types.  Refer to the architecture
11838 documentation for a description of the functionality of each
11839 instruction.
11840
11841 @smallexample
11842 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11843 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11844 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11845 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11846 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11847 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11848 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11849 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11850 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11851 uint64_t paddd_u (uint64_t s, uint64_t t);
11852 int64_t paddd_s (int64_t s, int64_t t);
11853 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11854 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11855 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11856 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11857 uint64_t pandn_ud (uint64_t s, uint64_t t);
11858 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11859 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11860 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11861 int64_t pandn_sd (int64_t s, int64_t t);
11862 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11863 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11864 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11865 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11866 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11867 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11868 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11869 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11870 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11871 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11872 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11873 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11874 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11875 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11876 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11877 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11878 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11879 uint16x4_t pextrh_u (uint16x4_t s, int field);
11880 int16x4_t pextrh_s (int16x4_t s, int field);
11881 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11882 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11883 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11884 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11885 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11886 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11887 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11888 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11889 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11890 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11891 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11892 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11893 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11894 uint8x8_t pmovmskb_u (uint8x8_t s);
11895 int8x8_t pmovmskb_s (int8x8_t s);
11896 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11897 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11898 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11899 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11900 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11901 uint16x4_t biadd (uint8x8_t s);
11902 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11903 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11904 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11905 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11906 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11907 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11908 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11909 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11910 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
11911 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
11912 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
11913 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
11914 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
11915 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
11916 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
11917 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
11918 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
11919 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
11920 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
11921 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
11922 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
11923 uint64_t psubd_u (uint64_t s, uint64_t t);
11924 int64_t psubd_s (int64_t s, int64_t t);
11925 int16x4_t psubsh (int16x4_t s, int16x4_t t);
11926 int8x8_t psubsb (int8x8_t s, int8x8_t t);
11927 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
11928 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
11929 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
11930 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
11931 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
11932 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
11933 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
11934 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
11935 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
11936 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
11937 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
11938 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
11939 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
11940 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
11941 @end smallexample
11942
11943 @menu
11944 * Paired-Single Arithmetic::
11945 * Paired-Single Built-in Functions::
11946 * MIPS-3D Built-in Functions::
11947 @end menu
11948
11949 @node Paired-Single Arithmetic
11950 @subsubsection Paired-Single Arithmetic
11951
11952 The table below lists the @code{v2sf} operations for which hardware
11953 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
11954 values and @code{x} is an integral value.
11955
11956 @multitable @columnfractions .50 .50
11957 @item C code @tab MIPS instruction
11958 @item @code{a + b} @tab @code{add.ps}
11959 @item @code{a - b} @tab @code{sub.ps}
11960 @item @code{-a} @tab @code{neg.ps}
11961 @item @code{a * b} @tab @code{mul.ps}
11962 @item @code{a * b + c} @tab @code{madd.ps}
11963 @item @code{a * b - c} @tab @code{msub.ps}
11964 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
11965 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
11966 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
11967 @end multitable
11968
11969 Note that the multiply-accumulate instructions can be disabled
11970 using the command-line option @code{-mno-fused-madd}.
11971
11972 @node Paired-Single Built-in Functions
11973 @subsubsection Paired-Single Built-in Functions
11974
11975 The following paired-single functions map directly to a particular
11976 MIPS instruction.  Please refer to the architecture specification
11977 for details on what each instruction does.
11978
11979 @table @code
11980 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
11981 Pair lower lower (@code{pll.ps}).
11982
11983 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
11984 Pair upper lower (@code{pul.ps}).
11985
11986 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
11987 Pair lower upper (@code{plu.ps}).
11988
11989 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
11990 Pair upper upper (@code{puu.ps}).
11991
11992 @item v2sf __builtin_mips_cvt_ps_s (float, float)
11993 Convert pair to paired single (@code{cvt.ps.s}).
11994
11995 @item float __builtin_mips_cvt_s_pl (v2sf)
11996 Convert pair lower to single (@code{cvt.s.pl}).
11997
11998 @item float __builtin_mips_cvt_s_pu (v2sf)
11999 Convert pair upper to single (@code{cvt.s.pu}).
12000
12001 @item v2sf __builtin_mips_abs_ps (v2sf)
12002 Absolute value (@code{abs.ps}).
12003
12004 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
12005 Align variable (@code{alnv.ps}).
12006
12007 @emph{Note:} The value of the third parameter must be 0 or 4
12008 modulo 8, otherwise the result is unpredictable.  Please read the
12009 instruction description for details.
12010 @end table
12011
12012 The following multi-instruction functions are also available.
12013 In each case, @var{cond} can be any of the 16 floating-point conditions:
12014 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12015 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
12016 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12017
12018 @table @code
12019 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12020 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12021 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
12022 @code{movt.ps}/@code{movf.ps}).
12023
12024 The @code{movt} functions return the value @var{x} computed by:
12025
12026 @smallexample
12027 c.@var{cond}.ps @var{cc},@var{a},@var{b}
12028 mov.ps @var{x},@var{c}
12029 movt.ps @var{x},@var{d},@var{cc}
12030 @end smallexample
12031
12032 The @code{movf} functions are similar but use @code{movf.ps} instead
12033 of @code{movt.ps}.
12034
12035 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12036 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12037 Comparison of two paired-single values (@code{c.@var{cond}.ps},
12038 @code{bc1t}/@code{bc1f}).
12039
12040 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12041 and return either the upper or lower half of the result.  For example:
12042
12043 @smallexample
12044 v2sf a, b;
12045 if (__builtin_mips_upper_c_eq_ps (a, b))
12046   upper_halves_are_equal ();
12047 else
12048   upper_halves_are_unequal ();
12049
12050 if (__builtin_mips_lower_c_eq_ps (a, b))
12051   lower_halves_are_equal ();
12052 else
12053   lower_halves_are_unequal ();
12054 @end smallexample
12055 @end table
12056
12057 @node MIPS-3D Built-in Functions
12058 @subsubsection MIPS-3D Built-in Functions
12059
12060 The MIPS-3D Application-Specific Extension (ASE) includes additional
12061 paired-single instructions that are designed to improve the performance
12062 of 3D graphics operations.  Support for these instructions is controlled
12063 by the @option{-mips3d} command-line option.
12064
12065 The functions listed below map directly to a particular MIPS-3D
12066 instruction.  Please refer to the architecture specification for
12067 more details on what each instruction does.
12068
12069 @table @code
12070 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
12071 Reduction add (@code{addr.ps}).
12072
12073 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
12074 Reduction multiply (@code{mulr.ps}).
12075
12076 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
12077 Convert paired single to paired word (@code{cvt.pw.ps}).
12078
12079 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
12080 Convert paired word to paired single (@code{cvt.ps.pw}).
12081
12082 @item float __builtin_mips_recip1_s (float)
12083 @itemx double __builtin_mips_recip1_d (double)
12084 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
12085 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
12086
12087 @item float __builtin_mips_recip2_s (float, float)
12088 @itemx double __builtin_mips_recip2_d (double, double)
12089 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
12090 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
12091
12092 @item float __builtin_mips_rsqrt1_s (float)
12093 @itemx double __builtin_mips_rsqrt1_d (double)
12094 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
12095 Reduced-precision reciprocal square root (sequence step 1)
12096 (@code{rsqrt1.@var{fmt}}).
12097
12098 @item float __builtin_mips_rsqrt2_s (float, float)
12099 @itemx double __builtin_mips_rsqrt2_d (double, double)
12100 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
12101 Reduced-precision reciprocal square root (sequence step 2)
12102 (@code{rsqrt2.@var{fmt}}).
12103 @end table
12104
12105 The following multi-instruction functions are also available.
12106 In each case, @var{cond} can be any of the 16 floating-point conditions:
12107 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
12108 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
12109 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
12110
12111 @table @code
12112 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
12113 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
12114 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
12115 @code{bc1t}/@code{bc1f}).
12116
12117 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
12118 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
12119 For example:
12120
12121 @smallexample
12122 float a, b;
12123 if (__builtin_mips_cabs_eq_s (a, b))
12124   true ();
12125 else
12126   false ();
12127 @end smallexample
12128
12129 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12130 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12131 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
12132 @code{bc1t}/@code{bc1f}).
12133
12134 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
12135 and return either the upper or lower half of the result.  For example:
12136
12137 @smallexample
12138 v2sf a, b;
12139 if (__builtin_mips_upper_cabs_eq_ps (a, b))
12140   upper_halves_are_equal ();
12141 else
12142   upper_halves_are_unequal ();
12143
12144 if (__builtin_mips_lower_cabs_eq_ps (a, b))
12145   lower_halves_are_equal ();
12146 else
12147   lower_halves_are_unequal ();
12148 @end smallexample
12149
12150 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12151 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12152 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
12153 @code{movt.ps}/@code{movf.ps}).
12154
12155 The @code{movt} functions return the value @var{x} computed by:
12156
12157 @smallexample
12158 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
12159 mov.ps @var{x},@var{c}
12160 movt.ps @var{x},@var{d},@var{cc}
12161 @end smallexample
12162
12163 The @code{movf} functions are similar but use @code{movf.ps} instead
12164 of @code{movt.ps}.
12165
12166 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12167 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12168 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12169 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
12170 Comparison of two paired-single values
12171 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12172 @code{bc1any2t}/@code{bc1any2f}).
12173
12174 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
12175 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
12176 result is true and the @code{all} forms return true if both results are true.
12177 For example:
12178
12179 @smallexample
12180 v2sf a, b;
12181 if (__builtin_mips_any_c_eq_ps (a, b))
12182   one_is_true ();
12183 else
12184   both_are_false ();
12185
12186 if (__builtin_mips_all_c_eq_ps (a, b))
12187   both_are_true ();
12188 else
12189   one_is_false ();
12190 @end smallexample
12191
12192 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12193 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12194 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12195 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
12196 Comparison of four paired-single values
12197 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
12198 @code{bc1any4t}/@code{bc1any4f}).
12199
12200 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
12201 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
12202 The @code{any} forms return true if any of the four results are true
12203 and the @code{all} forms return true if all four results are true.
12204 For example:
12205
12206 @smallexample
12207 v2sf a, b, c, d;
12208 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
12209   some_are_true ();
12210 else
12211   all_are_false ();
12212
12213 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
12214   all_are_true ();
12215 else
12216   some_are_false ();
12217 @end smallexample
12218 @end table
12219
12220 @node Other MIPS Built-in Functions
12221 @subsection Other MIPS Built-in Functions
12222
12223 GCC provides other MIPS-specific built-in functions:
12224
12225 @table @code
12226 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
12227 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
12228 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
12229 when this function is available.
12230
12231 @item unsigned int __builtin_mips_get_fcsr (void)
12232 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
12233 Get and set the contents of the floating-point control and status register
12234 (FPU control register 31).  These functions are only available in hard-float
12235 code but can be called in both MIPS16 and non-MIPS16 contexts.
12236
12237 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
12238 register except the condition codes, which GCC assumes are preserved.
12239 @end table
12240
12241 @node MSP430 Built-in Functions
12242 @subsection MSP430 Built-in Functions
12243
12244 GCC provides a couple of special builtin functions to aid in the
12245 writing of interrupt handlers in C.
12246
12247 @table @code
12248 @item __bic_SR_register_on_exit (int @var{mask})
12249 This clears the indicated bits in the saved copy of the status register
12250 currently residing on the stack.  This only works inside interrupt
12251 handlers and the changes to the status register will only take affect
12252 once the handler returns.
12253
12254 @item __bis_SR_register_on_exit (int @var{mask})
12255 This sets the indicated bits in the saved copy of the status register
12256 currently residing on the stack.  This only works inside interrupt
12257 handlers and the changes to the status register will only take affect
12258 once the handler returns.
12259
12260 @item __delay_cycles (long long @var{cycles})
12261 This inserts an instruction sequence that takes exactly @var{cycles}
12262 cycles (between 0 and about 17E9) to complete.  The inserted sequence
12263 may use jumps, loops, or no-ops, and does not interfere with any other
12264 instructions.  Note that @var{cycles} must be a compile-time constant
12265 integer - that is, you must pass a number, not a variable that may be
12266 optimized to a constant later.  The number of cycles delayed by this
12267 builtin is exact.
12268 @end table
12269
12270 @node NDS32 Built-in Functions
12271 @subsection NDS32 Built-in Functions
12272
12273 These built-in functions are available for the NDS32 target:
12274
12275 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
12276 Insert an ISYNC instruction into the instruction stream where
12277 @var{addr} is an instruction address for serialization.
12278 @end deftypefn
12279
12280 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
12281 Insert an ISB instruction into the instruction stream.
12282 @end deftypefn
12283
12284 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
12285 Return the content of a system register which is mapped by @var{sr}.
12286 @end deftypefn
12287
12288 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
12289 Return the content of a user space register which is mapped by @var{usr}.
12290 @end deftypefn
12291
12292 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
12293 Move the @var{value} to a system register which is mapped by @var{sr}.
12294 @end deftypefn
12295
12296 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
12297 Move the @var{value} to a user space register which is mapped by @var{usr}.
12298 @end deftypefn
12299
12300 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
12301 Enable global interrupt.
12302 @end deftypefn
12303
12304 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
12305 Disable global interrupt.
12306 @end deftypefn
12307
12308 @node picoChip Built-in Functions
12309 @subsection picoChip Built-in Functions
12310
12311 GCC provides an interface to selected machine instructions from the
12312 picoChip instruction set.
12313
12314 @table @code
12315 @item int __builtin_sbc (int @var{value})
12316 Sign bit count.  Return the number of consecutive bits in @var{value}
12317 that have the same value as the sign bit.  The result is the number of
12318 leading sign bits minus one, giving the number of redundant sign bits in
12319 @var{value}.
12320
12321 @item int __builtin_byteswap (int @var{value})
12322 Byte swap.  Return the result of swapping the upper and lower bytes of
12323 @var{value}.
12324
12325 @item int __builtin_brev (int @var{value})
12326 Bit reversal.  Return the result of reversing the bits in
12327 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
12328 and so on.
12329
12330 @item int __builtin_adds (int @var{x}, int @var{y})
12331 Saturating addition.  Return the result of adding @var{x} and @var{y},
12332 storing the value 32767 if the result overflows.
12333
12334 @item int __builtin_subs (int @var{x}, int @var{y})
12335 Saturating subtraction.  Return the result of subtracting @var{y} from
12336 @var{x}, storing the value @minus{}32768 if the result overflows.
12337
12338 @item void __builtin_halt (void)
12339 Halt.  The processor stops execution.  This built-in is useful for
12340 implementing assertions.
12341
12342 @end table
12343
12344 @node PowerPC Built-in Functions
12345 @subsection PowerPC Built-in Functions
12346
12347 These built-in functions are available for the PowerPC family of
12348 processors:
12349 @smallexample
12350 float __builtin_recipdivf (float, float);
12351 float __builtin_rsqrtf (float);
12352 double __builtin_recipdiv (double, double);
12353 double __builtin_rsqrt (double);
12354 uint64_t __builtin_ppc_get_timebase ();
12355 unsigned long __builtin_ppc_mftb ();
12356 double __builtin_unpack_longdouble (long double, int);
12357 long double __builtin_pack_longdouble (double, double);
12358 @end smallexample
12359
12360 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
12361 @code{__builtin_rsqrtf} functions generate multiple instructions to
12362 implement the reciprocal sqrt functionality using reciprocal sqrt
12363 estimate instructions.
12364
12365 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
12366 functions generate multiple instructions to implement division using
12367 the reciprocal estimate instructions.
12368
12369 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
12370 functions generate instructions to read the Time Base Register.  The
12371 @code{__builtin_ppc_get_timebase} function may generate multiple
12372 instructions and always returns the 64 bits of the Time Base Register.
12373 The @code{__builtin_ppc_mftb} function always generates one instruction and
12374 returns the Time Base Register value as an unsigned long, throwing away
12375 the most significant word on 32-bit environments.
12376
12377 The following built-in functions are available for the PowerPC family
12378 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
12379 or @option{-mpopcntd}):
12380 @smallexample
12381 long __builtin_bpermd (long, long);
12382 int __builtin_divwe (int, int);
12383 int __builtin_divweo (int, int);
12384 unsigned int __builtin_divweu (unsigned int, unsigned int);
12385 unsigned int __builtin_divweuo (unsigned int, unsigned int);
12386 long __builtin_divde (long, long);
12387 long __builtin_divdeo (long, long);
12388 unsigned long __builtin_divdeu (unsigned long, unsigned long);
12389 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
12390 unsigned int cdtbcd (unsigned int);
12391 unsigned int cbcdtd (unsigned int);
12392 unsigned int addg6s (unsigned int, unsigned int);
12393 @end smallexample
12394
12395 The @code{__builtin_divde}, @code{__builtin_divdeo},
12396 @code{__builitin_divdeu}, @code{__builtin_divdeou} functions require a
12397 64-bit environment support ISA 2.06 or later.
12398
12399 The following built-in functions are available for the PowerPC family
12400 of processors when hardware decimal floating point
12401 (@option{-mhard-dfp}) is available:
12402 @smallexample
12403 _Decimal64 __builtin_dxex (_Decimal64);
12404 _Decimal128 __builtin_dxexq (_Decimal128);
12405 _Decimal64 __builtin_ddedpd (int, _Decimal64);
12406 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
12407 _Decimal64 __builtin_denbcd (int, _Decimal64);
12408 _Decimal128 __builtin_denbcdq (int, _Decimal128);
12409 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
12410 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
12411 _Decimal64 __builtin_dscli (_Decimal64, int);
12412 _Decimal128 __builitn_dscliq (_Decimal128, int);
12413 _Decimal64 __builtin_dscri (_Decimal64, int);
12414 _Decimal128 __builitn_dscriq (_Decimal128, int);
12415 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
12416 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
12417 @end smallexample
12418
12419 The following built-in functions are available for the PowerPC family
12420 of processors when the Vector Scalar (vsx) instruction set is
12421 available:
12422 @smallexample
12423 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
12424 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
12425                                                 unsigned long long);
12426 @end smallexample
12427
12428 @node PowerPC AltiVec/VSX Built-in Functions
12429 @subsection PowerPC AltiVec Built-in Functions
12430
12431 GCC provides an interface for the PowerPC family of processors to access
12432 the AltiVec operations described in Motorola's AltiVec Programming
12433 Interface Manual.  The interface is made available by including
12434 @code{<altivec.h>} and using @option{-maltivec} and
12435 @option{-mabi=altivec}.  The interface supports the following vector
12436 types.
12437
12438 @smallexample
12439 vector unsigned char
12440 vector signed char
12441 vector bool char
12442
12443 vector unsigned short
12444 vector signed short
12445 vector bool short
12446 vector pixel
12447
12448 vector unsigned int
12449 vector signed int
12450 vector bool int
12451 vector float
12452 @end smallexample
12453
12454 If @option{-mvsx} is used the following additional vector types are
12455 implemented.
12456
12457 @smallexample
12458 vector unsigned long
12459 vector signed long
12460 vector double
12461 @end smallexample
12462
12463 The long types are only implemented for 64-bit code generation, and
12464 the long type is only used in the floating point/integer conversion
12465 instructions.
12466
12467 GCC's implementation of the high-level language interface available from
12468 C and C++ code differs from Motorola's documentation in several ways.
12469
12470 @itemize @bullet
12471
12472 @item
12473 A vector constant is a list of constant expressions within curly braces.
12474
12475 @item
12476 A vector initializer requires no cast if the vector constant is of the
12477 same type as the variable it is initializing.
12478
12479 @item
12480 If @code{signed} or @code{unsigned} is omitted, the signedness of the
12481 vector type is the default signedness of the base type.  The default
12482 varies depending on the operating system, so a portable program should
12483 always specify the signedness.
12484
12485 @item
12486 Compiling with @option{-maltivec} adds keywords @code{__vector},
12487 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
12488 @code{bool}.  When compiling ISO C, the context-sensitive substitution
12489 of the keywords @code{vector}, @code{pixel} and @code{bool} is
12490 disabled.  To use them, you must include @code{<altivec.h>} instead.
12491
12492 @item
12493 GCC allows using a @code{typedef} name as the type specifier for a
12494 vector type.
12495
12496 @item
12497 For C, overloaded functions are implemented with macros so the following
12498 does not work:
12499
12500 @smallexample
12501   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
12502 @end smallexample
12503
12504 @noindent
12505 Since @code{vec_add} is a macro, the vector constant in the example
12506 is treated as four separate arguments.  Wrap the entire argument in
12507 parentheses for this to work.
12508 @end itemize
12509
12510 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
12511 Internally, GCC uses built-in functions to achieve the functionality in
12512 the aforementioned header file, but they are not supported and are
12513 subject to change without notice.
12514
12515 The following interfaces are supported for the generic and specific
12516 AltiVec operations and the AltiVec predicates.  In cases where there
12517 is a direct mapping between generic and specific operations, only the
12518 generic names are shown here, although the specific operations can also
12519 be used.
12520
12521 Arguments that are documented as @code{const int} require literal
12522 integral values within the range required for that operation.
12523
12524 @smallexample
12525 vector signed char vec_abs (vector signed char);
12526 vector signed short vec_abs (vector signed short);
12527 vector signed int vec_abs (vector signed int);
12528 vector float vec_abs (vector float);
12529
12530 vector signed char vec_abss (vector signed char);
12531 vector signed short vec_abss (vector signed short);
12532 vector signed int vec_abss (vector signed int);
12533
12534 vector signed char vec_add (vector bool char, vector signed char);
12535 vector signed char vec_add (vector signed char, vector bool char);
12536 vector signed char vec_add (vector signed char, vector signed char);
12537 vector unsigned char vec_add (vector bool char, vector unsigned char);
12538 vector unsigned char vec_add (vector unsigned char, vector bool char);
12539 vector unsigned char vec_add (vector unsigned char,
12540                               vector unsigned char);
12541 vector signed short vec_add (vector bool short, vector signed short);
12542 vector signed short vec_add (vector signed short, vector bool short);
12543 vector signed short vec_add (vector signed short, vector signed short);
12544 vector unsigned short vec_add (vector bool short,
12545                                vector unsigned short);
12546 vector unsigned short vec_add (vector unsigned short,
12547                                vector bool short);
12548 vector unsigned short vec_add (vector unsigned short,
12549                                vector unsigned short);
12550 vector signed int vec_add (vector bool int, vector signed int);
12551 vector signed int vec_add (vector signed int, vector bool int);
12552 vector signed int vec_add (vector signed int, vector signed int);
12553 vector unsigned int vec_add (vector bool int, vector unsigned int);
12554 vector unsigned int vec_add (vector unsigned int, vector bool int);
12555 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12556 vector float vec_add (vector float, vector float);
12557
12558 vector float vec_vaddfp (vector float, vector float);
12559
12560 vector signed int vec_vadduwm (vector bool int, vector signed int);
12561 vector signed int vec_vadduwm (vector signed int, vector bool int);
12562 vector signed int vec_vadduwm (vector signed int, vector signed int);
12563 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12564 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12565 vector unsigned int vec_vadduwm (vector unsigned int,
12566                                  vector unsigned int);
12567
12568 vector signed short vec_vadduhm (vector bool short,
12569                                  vector signed short);
12570 vector signed short vec_vadduhm (vector signed short,
12571                                  vector bool short);
12572 vector signed short vec_vadduhm (vector signed short,
12573                                  vector signed short);
12574 vector unsigned short vec_vadduhm (vector bool short,
12575                                    vector unsigned short);
12576 vector unsigned short vec_vadduhm (vector unsigned short,
12577                                    vector bool short);
12578 vector unsigned short vec_vadduhm (vector unsigned short,
12579                                    vector unsigned short);
12580
12581 vector signed char vec_vaddubm (vector bool char, vector signed char);
12582 vector signed char vec_vaddubm (vector signed char, vector bool char);
12583 vector signed char vec_vaddubm (vector signed char, vector signed char);
12584 vector unsigned char vec_vaddubm (vector bool char,
12585                                   vector unsigned char);
12586 vector unsigned char vec_vaddubm (vector unsigned char,
12587                                   vector bool char);
12588 vector unsigned char vec_vaddubm (vector unsigned char,
12589                                   vector unsigned char);
12590
12591 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12592
12593 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12594 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12595 vector unsigned char vec_adds (vector unsigned char,
12596                                vector unsigned char);
12597 vector signed char vec_adds (vector bool char, vector signed char);
12598 vector signed char vec_adds (vector signed char, vector bool char);
12599 vector signed char vec_adds (vector signed char, vector signed char);
12600 vector unsigned short vec_adds (vector bool short,
12601                                 vector unsigned short);
12602 vector unsigned short vec_adds (vector unsigned short,
12603                                 vector bool short);
12604 vector unsigned short vec_adds (vector unsigned short,
12605                                 vector unsigned short);
12606 vector signed short vec_adds (vector bool short, vector signed short);
12607 vector signed short vec_adds (vector signed short, vector bool short);
12608 vector signed short vec_adds (vector signed short, vector signed short);
12609 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12610 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12611 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12612 vector signed int vec_adds (vector bool int, vector signed int);
12613 vector signed int vec_adds (vector signed int, vector bool int);
12614 vector signed int vec_adds (vector signed int, vector signed int);
12615
12616 vector signed int vec_vaddsws (vector bool int, vector signed int);
12617 vector signed int vec_vaddsws (vector signed int, vector bool int);
12618 vector signed int vec_vaddsws (vector signed int, vector signed int);
12619
12620 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12621 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12622 vector unsigned int vec_vadduws (vector unsigned int,
12623                                  vector unsigned int);
12624
12625 vector signed short vec_vaddshs (vector bool short,
12626                                  vector signed short);
12627 vector signed short vec_vaddshs (vector signed short,
12628                                  vector bool short);
12629 vector signed short vec_vaddshs (vector signed short,
12630                                  vector signed short);
12631
12632 vector unsigned short vec_vadduhs (vector bool short,
12633                                    vector unsigned short);
12634 vector unsigned short vec_vadduhs (vector unsigned short,
12635                                    vector bool short);
12636 vector unsigned short vec_vadduhs (vector unsigned short,
12637                                    vector unsigned short);
12638
12639 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12640 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12641 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12642
12643 vector unsigned char vec_vaddubs (vector bool char,
12644                                   vector unsigned char);
12645 vector unsigned char vec_vaddubs (vector unsigned char,
12646                                   vector bool char);
12647 vector unsigned char vec_vaddubs (vector unsigned char,
12648                                   vector unsigned char);
12649
12650 vector float vec_and (vector float, vector float);
12651 vector float vec_and (vector float, vector bool int);
12652 vector float vec_and (vector bool int, vector float);
12653 vector bool int vec_and (vector bool int, vector bool int);
12654 vector signed int vec_and (vector bool int, vector signed int);
12655 vector signed int vec_and (vector signed int, vector bool int);
12656 vector signed int vec_and (vector signed int, vector signed int);
12657 vector unsigned int vec_and (vector bool int, vector unsigned int);
12658 vector unsigned int vec_and (vector unsigned int, vector bool int);
12659 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12660 vector bool short vec_and (vector bool short, vector bool short);
12661 vector signed short vec_and (vector bool short, vector signed short);
12662 vector signed short vec_and (vector signed short, vector bool short);
12663 vector signed short vec_and (vector signed short, vector signed short);
12664 vector unsigned short vec_and (vector bool short,
12665                                vector unsigned short);
12666 vector unsigned short vec_and (vector unsigned short,
12667                                vector bool short);
12668 vector unsigned short vec_and (vector unsigned short,
12669                                vector unsigned short);
12670 vector signed char vec_and (vector bool char, vector signed char);
12671 vector bool char vec_and (vector bool char, vector bool char);
12672 vector signed char vec_and (vector signed char, vector bool char);
12673 vector signed char vec_and (vector signed char, vector signed char);
12674 vector unsigned char vec_and (vector bool char, vector unsigned char);
12675 vector unsigned char vec_and (vector unsigned char, vector bool char);
12676 vector unsigned char vec_and (vector unsigned char,
12677                               vector unsigned char);
12678
12679 vector float vec_andc (vector float, vector float);
12680 vector float vec_andc (vector float, vector bool int);
12681 vector float vec_andc (vector bool int, vector float);
12682 vector bool int vec_andc (vector bool int, vector bool int);
12683 vector signed int vec_andc (vector bool int, vector signed int);
12684 vector signed int vec_andc (vector signed int, vector bool int);
12685 vector signed int vec_andc (vector signed int, vector signed int);
12686 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12687 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12688 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12689 vector bool short vec_andc (vector bool short, vector bool short);
12690 vector signed short vec_andc (vector bool short, vector signed short);
12691 vector signed short vec_andc (vector signed short, vector bool short);
12692 vector signed short vec_andc (vector signed short, vector signed short);
12693 vector unsigned short vec_andc (vector bool short,
12694                                 vector unsigned short);
12695 vector unsigned short vec_andc (vector unsigned short,
12696                                 vector bool short);
12697 vector unsigned short vec_andc (vector unsigned short,
12698                                 vector unsigned short);
12699 vector signed char vec_andc (vector bool char, vector signed char);
12700 vector bool char vec_andc (vector bool char, vector bool char);
12701 vector signed char vec_andc (vector signed char, vector bool char);
12702 vector signed char vec_andc (vector signed char, vector signed char);
12703 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12704 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12705 vector unsigned char vec_andc (vector unsigned char,
12706                                vector unsigned char);
12707
12708 vector unsigned char vec_avg (vector unsigned char,
12709                               vector unsigned char);
12710 vector signed char vec_avg (vector signed char, vector signed char);
12711 vector unsigned short vec_avg (vector unsigned short,
12712                                vector unsigned short);
12713 vector signed short vec_avg (vector signed short, vector signed short);
12714 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12715 vector signed int vec_avg (vector signed int, vector signed int);
12716
12717 vector signed int vec_vavgsw (vector signed int, vector signed int);
12718
12719 vector unsigned int vec_vavguw (vector unsigned int,
12720                                 vector unsigned int);
12721
12722 vector signed short vec_vavgsh (vector signed short,
12723                                 vector signed short);
12724
12725 vector unsigned short vec_vavguh (vector unsigned short,
12726                                   vector unsigned short);
12727
12728 vector signed char vec_vavgsb (vector signed char, vector signed char);
12729
12730 vector unsigned char vec_vavgub (vector unsigned char,
12731                                  vector unsigned char);
12732
12733 vector float vec_copysign (vector float);
12734
12735 vector float vec_ceil (vector float);
12736
12737 vector signed int vec_cmpb (vector float, vector float);
12738
12739 vector bool char vec_cmpeq (vector signed char, vector signed char);
12740 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12741 vector bool short vec_cmpeq (vector signed short, vector signed short);
12742 vector bool short vec_cmpeq (vector unsigned short,
12743                              vector unsigned short);
12744 vector bool int vec_cmpeq (vector signed int, vector signed int);
12745 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12746 vector bool int vec_cmpeq (vector float, vector float);
12747
12748 vector bool int vec_vcmpeqfp (vector float, vector float);
12749
12750 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12751 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12752
12753 vector bool short vec_vcmpequh (vector signed short,
12754                                 vector signed short);
12755 vector bool short vec_vcmpequh (vector unsigned short,
12756                                 vector unsigned short);
12757
12758 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12759 vector bool char vec_vcmpequb (vector unsigned char,
12760                                vector unsigned char);
12761
12762 vector bool int vec_cmpge (vector float, vector float);
12763
12764 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12765 vector bool char vec_cmpgt (vector signed char, vector signed char);
12766 vector bool short vec_cmpgt (vector unsigned short,
12767                              vector unsigned short);
12768 vector bool short vec_cmpgt (vector signed short, vector signed short);
12769 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12770 vector bool int vec_cmpgt (vector signed int, vector signed int);
12771 vector bool int vec_cmpgt (vector float, vector float);
12772
12773 vector bool int vec_vcmpgtfp (vector float, vector float);
12774
12775 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12776
12777 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12778
12779 vector bool short vec_vcmpgtsh (vector signed short,
12780                                 vector signed short);
12781
12782 vector bool short vec_vcmpgtuh (vector unsigned short,
12783                                 vector unsigned short);
12784
12785 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12786
12787 vector bool char vec_vcmpgtub (vector unsigned char,
12788                                vector unsigned char);
12789
12790 vector bool int vec_cmple (vector float, vector float);
12791
12792 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12793 vector bool char vec_cmplt (vector signed char, vector signed char);
12794 vector bool short vec_cmplt (vector unsigned short,
12795                              vector unsigned short);
12796 vector bool short vec_cmplt (vector signed short, vector signed short);
12797 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12798 vector bool int vec_cmplt (vector signed int, vector signed int);
12799 vector bool int vec_cmplt (vector float, vector float);
12800
12801 vector float vec_cpsgn (vector float, vector float);
12802
12803 vector float vec_ctf (vector unsigned int, const int);
12804 vector float vec_ctf (vector signed int, const int);
12805 vector double vec_ctf (vector unsigned long, const int);
12806 vector double vec_ctf (vector signed long, const int);
12807
12808 vector float vec_vcfsx (vector signed int, const int);
12809
12810 vector float vec_vcfux (vector unsigned int, const int);
12811
12812 vector signed int vec_cts (vector float, const int);
12813 vector signed long vec_cts (vector double, const int);
12814
12815 vector unsigned int vec_ctu (vector float, const int);
12816 vector unsigned long vec_ctu (vector double, const int);
12817
12818 void vec_dss (const int);
12819
12820 void vec_dssall (void);
12821
12822 void vec_dst (const vector unsigned char *, int, const int);
12823 void vec_dst (const vector signed char *, int, const int);
12824 void vec_dst (const vector bool char *, int, const int);
12825 void vec_dst (const vector unsigned short *, int, const int);
12826 void vec_dst (const vector signed short *, int, const int);
12827 void vec_dst (const vector bool short *, int, const int);
12828 void vec_dst (const vector pixel *, int, const int);
12829 void vec_dst (const vector unsigned int *, int, const int);
12830 void vec_dst (const vector signed int *, int, const int);
12831 void vec_dst (const vector bool int *, int, const int);
12832 void vec_dst (const vector float *, int, const int);
12833 void vec_dst (const unsigned char *, int, const int);
12834 void vec_dst (const signed char *, int, const int);
12835 void vec_dst (const unsigned short *, int, const int);
12836 void vec_dst (const short *, int, const int);
12837 void vec_dst (const unsigned int *, int, const int);
12838 void vec_dst (const int *, int, const int);
12839 void vec_dst (const unsigned long *, int, const int);
12840 void vec_dst (const long *, int, const int);
12841 void vec_dst (const float *, int, const int);
12842
12843 void vec_dstst (const vector unsigned char *, int, const int);
12844 void vec_dstst (const vector signed char *, int, const int);
12845 void vec_dstst (const vector bool char *, int, const int);
12846 void vec_dstst (const vector unsigned short *, int, const int);
12847 void vec_dstst (const vector signed short *, int, const int);
12848 void vec_dstst (const vector bool short *, int, const int);
12849 void vec_dstst (const vector pixel *, int, const int);
12850 void vec_dstst (const vector unsigned int *, int, const int);
12851 void vec_dstst (const vector signed int *, int, const int);
12852 void vec_dstst (const vector bool int *, int, const int);
12853 void vec_dstst (const vector float *, int, const int);
12854 void vec_dstst (const unsigned char *, int, const int);
12855 void vec_dstst (const signed char *, int, const int);
12856 void vec_dstst (const unsigned short *, int, const int);
12857 void vec_dstst (const short *, int, const int);
12858 void vec_dstst (const unsigned int *, int, const int);
12859 void vec_dstst (const int *, int, const int);
12860 void vec_dstst (const unsigned long *, int, const int);
12861 void vec_dstst (const long *, int, const int);
12862 void vec_dstst (const float *, int, const int);
12863
12864 void vec_dststt (const vector unsigned char *, int, const int);
12865 void vec_dststt (const vector signed char *, int, const int);
12866 void vec_dststt (const vector bool char *, int, const int);
12867 void vec_dststt (const vector unsigned short *, int, const int);
12868 void vec_dststt (const vector signed short *, int, const int);
12869 void vec_dststt (const vector bool short *, int, const int);
12870 void vec_dststt (const vector pixel *, int, const int);
12871 void vec_dststt (const vector unsigned int *, int, const int);
12872 void vec_dststt (const vector signed int *, int, const int);
12873 void vec_dststt (const vector bool int *, int, const int);
12874 void vec_dststt (const vector float *, int, const int);
12875 void vec_dststt (const unsigned char *, int, const int);
12876 void vec_dststt (const signed char *, int, const int);
12877 void vec_dststt (const unsigned short *, int, const int);
12878 void vec_dststt (const short *, int, const int);
12879 void vec_dststt (const unsigned int *, int, const int);
12880 void vec_dststt (const int *, int, const int);
12881 void vec_dststt (const unsigned long *, int, const int);
12882 void vec_dststt (const long *, int, const int);
12883 void vec_dststt (const float *, int, const int);
12884
12885 void vec_dstt (const vector unsigned char *, int, const int);
12886 void vec_dstt (const vector signed char *, int, const int);
12887 void vec_dstt (const vector bool char *, int, const int);
12888 void vec_dstt (const vector unsigned short *, int, const int);
12889 void vec_dstt (const vector signed short *, int, const int);
12890 void vec_dstt (const vector bool short *, int, const int);
12891 void vec_dstt (const vector pixel *, int, const int);
12892 void vec_dstt (const vector unsigned int *, int, const int);
12893 void vec_dstt (const vector signed int *, int, const int);
12894 void vec_dstt (const vector bool int *, int, const int);
12895 void vec_dstt (const vector float *, int, const int);
12896 void vec_dstt (const unsigned char *, int, const int);
12897 void vec_dstt (const signed char *, int, const int);
12898 void vec_dstt (const unsigned short *, int, const int);
12899 void vec_dstt (const short *, int, const int);
12900 void vec_dstt (const unsigned int *, int, const int);
12901 void vec_dstt (const int *, int, const int);
12902 void vec_dstt (const unsigned long *, int, const int);
12903 void vec_dstt (const long *, int, const int);
12904 void vec_dstt (const float *, int, const int);
12905
12906 vector float vec_expte (vector float);
12907
12908 vector float vec_floor (vector float);
12909
12910 vector float vec_ld (int, const vector float *);
12911 vector float vec_ld (int, const float *);
12912 vector bool int vec_ld (int, const vector bool int *);
12913 vector signed int vec_ld (int, const vector signed int *);
12914 vector signed int vec_ld (int, const int *);
12915 vector signed int vec_ld (int, const long *);
12916 vector unsigned int vec_ld (int, const vector unsigned int *);
12917 vector unsigned int vec_ld (int, const unsigned int *);
12918 vector unsigned int vec_ld (int, const unsigned long *);
12919 vector bool short vec_ld (int, const vector bool short *);
12920 vector pixel vec_ld (int, const vector pixel *);
12921 vector signed short vec_ld (int, const vector signed short *);
12922 vector signed short vec_ld (int, const short *);
12923 vector unsigned short vec_ld (int, const vector unsigned short *);
12924 vector unsigned short vec_ld (int, const unsigned short *);
12925 vector bool char vec_ld (int, const vector bool char *);
12926 vector signed char vec_ld (int, const vector signed char *);
12927 vector signed char vec_ld (int, const signed char *);
12928 vector unsigned char vec_ld (int, const vector unsigned char *);
12929 vector unsigned char vec_ld (int, const unsigned char *);
12930
12931 vector signed char vec_lde (int, const signed char *);
12932 vector unsigned char vec_lde (int, const unsigned char *);
12933 vector signed short vec_lde (int, const short *);
12934 vector unsigned short vec_lde (int, const unsigned short *);
12935 vector float vec_lde (int, const float *);
12936 vector signed int vec_lde (int, const int *);
12937 vector unsigned int vec_lde (int, const unsigned int *);
12938 vector signed int vec_lde (int, const long *);
12939 vector unsigned int vec_lde (int, const unsigned long *);
12940
12941 vector float vec_lvewx (int, float *);
12942 vector signed int vec_lvewx (int, int *);
12943 vector unsigned int vec_lvewx (int, unsigned int *);
12944 vector signed int vec_lvewx (int, long *);
12945 vector unsigned int vec_lvewx (int, unsigned long *);
12946
12947 vector signed short vec_lvehx (int, short *);
12948 vector unsigned short vec_lvehx (int, unsigned short *);
12949
12950 vector signed char vec_lvebx (int, char *);
12951 vector unsigned char vec_lvebx (int, unsigned char *);
12952
12953 vector float vec_ldl (int, const vector float *);
12954 vector float vec_ldl (int, const float *);
12955 vector bool int vec_ldl (int, const vector bool int *);
12956 vector signed int vec_ldl (int, const vector signed int *);
12957 vector signed int vec_ldl (int, const int *);
12958 vector signed int vec_ldl (int, const long *);
12959 vector unsigned int vec_ldl (int, const vector unsigned int *);
12960 vector unsigned int vec_ldl (int, const unsigned int *);
12961 vector unsigned int vec_ldl (int, const unsigned long *);
12962 vector bool short vec_ldl (int, const vector bool short *);
12963 vector pixel vec_ldl (int, const vector pixel *);
12964 vector signed short vec_ldl (int, const vector signed short *);
12965 vector signed short vec_ldl (int, const short *);
12966 vector unsigned short vec_ldl (int, const vector unsigned short *);
12967 vector unsigned short vec_ldl (int, const unsigned short *);
12968 vector bool char vec_ldl (int, const vector bool char *);
12969 vector signed char vec_ldl (int, const vector signed char *);
12970 vector signed char vec_ldl (int, const signed char *);
12971 vector unsigned char vec_ldl (int, const vector unsigned char *);
12972 vector unsigned char vec_ldl (int, const unsigned char *);
12973
12974 vector float vec_loge (vector float);
12975
12976 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12977 vector unsigned char vec_lvsl (int, const volatile signed char *);
12978 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12979 vector unsigned char vec_lvsl (int, const volatile short *);
12980 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12981 vector unsigned char vec_lvsl (int, const volatile int *);
12982 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12983 vector unsigned char vec_lvsl (int, const volatile long *);
12984 vector unsigned char vec_lvsl (int, const volatile float *);
12985
12986 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
12987 vector unsigned char vec_lvsr (int, const volatile signed char *);
12988 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
12989 vector unsigned char vec_lvsr (int, const volatile short *);
12990 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
12991 vector unsigned char vec_lvsr (int, const volatile int *);
12992 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
12993 vector unsigned char vec_lvsr (int, const volatile long *);
12994 vector unsigned char vec_lvsr (int, const volatile float *);
12995
12996 vector float vec_madd (vector float, vector float, vector float);
12997
12998 vector signed short vec_madds (vector signed short,
12999                                vector signed short,
13000                                vector signed short);
13001
13002 vector unsigned char vec_max (vector bool char, vector unsigned char);
13003 vector unsigned char vec_max (vector unsigned char, vector bool char);
13004 vector unsigned char vec_max (vector unsigned char,
13005                               vector unsigned char);
13006 vector signed char vec_max (vector bool char, vector signed char);
13007 vector signed char vec_max (vector signed char, vector bool char);
13008 vector signed char vec_max (vector signed char, vector signed char);
13009 vector unsigned short vec_max (vector bool short,
13010                                vector unsigned short);
13011 vector unsigned short vec_max (vector unsigned short,
13012                                vector bool short);
13013 vector unsigned short vec_max (vector unsigned short,
13014                                vector unsigned short);
13015 vector signed short vec_max (vector bool short, vector signed short);
13016 vector signed short vec_max (vector signed short, vector bool short);
13017 vector signed short vec_max (vector signed short, vector signed short);
13018 vector unsigned int vec_max (vector bool int, vector unsigned int);
13019 vector unsigned int vec_max (vector unsigned int, vector bool int);
13020 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
13021 vector signed int vec_max (vector bool int, vector signed int);
13022 vector signed int vec_max (vector signed int, vector bool int);
13023 vector signed int vec_max (vector signed int, vector signed int);
13024 vector float vec_max (vector float, vector float);
13025
13026 vector float vec_vmaxfp (vector float, vector float);
13027
13028 vector signed int vec_vmaxsw (vector bool int, vector signed int);
13029 vector signed int vec_vmaxsw (vector signed int, vector bool int);
13030 vector signed int vec_vmaxsw (vector signed int, vector signed int);
13031
13032 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
13033 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
13034 vector unsigned int vec_vmaxuw (vector unsigned int,
13035                                 vector unsigned int);
13036
13037 vector signed short vec_vmaxsh (vector bool short, vector signed short);
13038 vector signed short vec_vmaxsh (vector signed short, vector bool short);
13039 vector signed short vec_vmaxsh (vector signed short,
13040                                 vector signed short);
13041
13042 vector unsigned short vec_vmaxuh (vector bool short,
13043                                   vector unsigned short);
13044 vector unsigned short vec_vmaxuh (vector unsigned short,
13045                                   vector bool short);
13046 vector unsigned short vec_vmaxuh (vector unsigned short,
13047                                   vector unsigned short);
13048
13049 vector signed char vec_vmaxsb (vector bool char, vector signed char);
13050 vector signed char vec_vmaxsb (vector signed char, vector bool char);
13051 vector signed char vec_vmaxsb (vector signed char, vector signed char);
13052
13053 vector unsigned char vec_vmaxub (vector bool char,
13054                                  vector unsigned char);
13055 vector unsigned char vec_vmaxub (vector unsigned char,
13056                                  vector bool char);
13057 vector unsigned char vec_vmaxub (vector unsigned char,
13058                                  vector unsigned char);
13059
13060 vector bool char vec_mergeh (vector bool char, vector bool char);
13061 vector signed char vec_mergeh (vector signed char, vector signed char);
13062 vector unsigned char vec_mergeh (vector unsigned char,
13063                                  vector unsigned char);
13064 vector bool short vec_mergeh (vector bool short, vector bool short);
13065 vector pixel vec_mergeh (vector pixel, vector pixel);
13066 vector signed short vec_mergeh (vector signed short,
13067                                 vector signed short);
13068 vector unsigned short vec_mergeh (vector unsigned short,
13069                                   vector unsigned short);
13070 vector float vec_mergeh (vector float, vector float);
13071 vector bool int vec_mergeh (vector bool int, vector bool int);
13072 vector signed int vec_mergeh (vector signed int, vector signed int);
13073 vector unsigned int vec_mergeh (vector unsigned int,
13074                                 vector unsigned int);
13075
13076 vector float vec_vmrghw (vector float, vector float);
13077 vector bool int vec_vmrghw (vector bool int, vector bool int);
13078 vector signed int vec_vmrghw (vector signed int, vector signed int);
13079 vector unsigned int vec_vmrghw (vector unsigned int,
13080                                 vector unsigned int);
13081
13082 vector bool short vec_vmrghh (vector bool short, vector bool short);
13083 vector signed short vec_vmrghh (vector signed short,
13084                                 vector signed short);
13085 vector unsigned short vec_vmrghh (vector unsigned short,
13086                                   vector unsigned short);
13087 vector pixel vec_vmrghh (vector pixel, vector pixel);
13088
13089 vector bool char vec_vmrghb (vector bool char, vector bool char);
13090 vector signed char vec_vmrghb (vector signed char, vector signed char);
13091 vector unsigned char vec_vmrghb (vector unsigned char,
13092                                  vector unsigned char);
13093
13094 vector bool char vec_mergel (vector bool char, vector bool char);
13095 vector signed char vec_mergel (vector signed char, vector signed char);
13096 vector unsigned char vec_mergel (vector unsigned char,
13097                                  vector unsigned char);
13098 vector bool short vec_mergel (vector bool short, vector bool short);
13099 vector pixel vec_mergel (vector pixel, vector pixel);
13100 vector signed short vec_mergel (vector signed short,
13101                                 vector signed short);
13102 vector unsigned short vec_mergel (vector unsigned short,
13103                                   vector unsigned short);
13104 vector float vec_mergel (vector float, vector float);
13105 vector bool int vec_mergel (vector bool int, vector bool int);
13106 vector signed int vec_mergel (vector signed int, vector signed int);
13107 vector unsigned int vec_mergel (vector unsigned int,
13108                                 vector unsigned int);
13109
13110 vector float vec_vmrglw (vector float, vector float);
13111 vector signed int vec_vmrglw (vector signed int, vector signed int);
13112 vector unsigned int vec_vmrglw (vector unsigned int,
13113                                 vector unsigned int);
13114 vector bool int vec_vmrglw (vector bool int, vector bool int);
13115
13116 vector bool short vec_vmrglh (vector bool short, vector bool short);
13117 vector signed short vec_vmrglh (vector signed short,
13118                                 vector signed short);
13119 vector unsigned short vec_vmrglh (vector unsigned short,
13120                                   vector unsigned short);
13121 vector pixel vec_vmrglh (vector pixel, vector pixel);
13122
13123 vector bool char vec_vmrglb (vector bool char, vector bool char);
13124 vector signed char vec_vmrglb (vector signed char, vector signed char);
13125 vector unsigned char vec_vmrglb (vector unsigned char,
13126                                  vector unsigned char);
13127
13128 vector unsigned short vec_mfvscr (void);
13129
13130 vector unsigned char vec_min (vector bool char, vector unsigned char);
13131 vector unsigned char vec_min (vector unsigned char, vector bool char);
13132 vector unsigned char vec_min (vector unsigned char,
13133                               vector unsigned char);
13134 vector signed char vec_min (vector bool char, vector signed char);
13135 vector signed char vec_min (vector signed char, vector bool char);
13136 vector signed char vec_min (vector signed char, vector signed char);
13137 vector unsigned short vec_min (vector bool short,
13138                                vector unsigned short);
13139 vector unsigned short vec_min (vector unsigned short,
13140                                vector bool short);
13141 vector unsigned short vec_min (vector unsigned short,
13142                                vector unsigned short);
13143 vector signed short vec_min (vector bool short, vector signed short);
13144 vector signed short vec_min (vector signed short, vector bool short);
13145 vector signed short vec_min (vector signed short, vector signed short);
13146 vector unsigned int vec_min (vector bool int, vector unsigned int);
13147 vector unsigned int vec_min (vector unsigned int, vector bool int);
13148 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
13149 vector signed int vec_min (vector bool int, vector signed int);
13150 vector signed int vec_min (vector signed int, vector bool int);
13151 vector signed int vec_min (vector signed int, vector signed int);
13152 vector float vec_min (vector float, vector float);
13153
13154 vector float vec_vminfp (vector float, vector float);
13155
13156 vector signed int vec_vminsw (vector bool int, vector signed int);
13157 vector signed int vec_vminsw (vector signed int, vector bool int);
13158 vector signed int vec_vminsw (vector signed int, vector signed int);
13159
13160 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
13161 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
13162 vector unsigned int vec_vminuw (vector unsigned int,
13163                                 vector unsigned int);
13164
13165 vector signed short vec_vminsh (vector bool short, vector signed short);
13166 vector signed short vec_vminsh (vector signed short, vector bool short);
13167 vector signed short vec_vminsh (vector signed short,
13168                                 vector signed short);
13169
13170 vector unsigned short vec_vminuh (vector bool short,
13171                                   vector unsigned short);
13172 vector unsigned short vec_vminuh (vector unsigned short,
13173                                   vector bool short);
13174 vector unsigned short vec_vminuh (vector unsigned short,
13175                                   vector unsigned short);
13176
13177 vector signed char vec_vminsb (vector bool char, vector signed char);
13178 vector signed char vec_vminsb (vector signed char, vector bool char);
13179 vector signed char vec_vminsb (vector signed char, vector signed char);
13180
13181 vector unsigned char vec_vminub (vector bool char,
13182                                  vector unsigned char);
13183 vector unsigned char vec_vminub (vector unsigned char,
13184                                  vector bool char);
13185 vector unsigned char vec_vminub (vector unsigned char,
13186                                  vector unsigned char);
13187
13188 vector signed short vec_mladd (vector signed short,
13189                                vector signed short,
13190                                vector signed short);
13191 vector signed short vec_mladd (vector signed short,
13192                                vector unsigned short,
13193                                vector unsigned short);
13194 vector signed short vec_mladd (vector unsigned short,
13195                                vector signed short,
13196                                vector signed short);
13197 vector unsigned short vec_mladd (vector unsigned short,
13198                                  vector unsigned short,
13199                                  vector unsigned short);
13200
13201 vector signed short vec_mradds (vector signed short,
13202                                 vector signed short,
13203                                 vector signed short);
13204
13205 vector unsigned int vec_msum (vector unsigned char,
13206                               vector unsigned char,
13207                               vector unsigned int);
13208 vector signed int vec_msum (vector signed char,
13209                             vector unsigned char,
13210                             vector signed int);
13211 vector unsigned int vec_msum (vector unsigned short,
13212                               vector unsigned short,
13213                               vector unsigned int);
13214 vector signed int vec_msum (vector signed short,
13215                             vector signed short,
13216                             vector signed int);
13217
13218 vector signed int vec_vmsumshm (vector signed short,
13219                                 vector signed short,
13220                                 vector signed int);
13221
13222 vector unsigned int vec_vmsumuhm (vector unsigned short,
13223                                   vector unsigned short,
13224                                   vector unsigned int);
13225
13226 vector signed int vec_vmsummbm (vector signed char,
13227                                 vector unsigned char,
13228                                 vector signed int);
13229
13230 vector unsigned int vec_vmsumubm (vector unsigned char,
13231                                   vector unsigned char,
13232                                   vector unsigned int);
13233
13234 vector unsigned int vec_msums (vector unsigned short,
13235                                vector unsigned short,
13236                                vector unsigned int);
13237 vector signed int vec_msums (vector signed short,
13238                              vector signed short,
13239                              vector signed int);
13240
13241 vector signed int vec_vmsumshs (vector signed short,
13242                                 vector signed short,
13243                                 vector signed int);
13244
13245 vector unsigned int vec_vmsumuhs (vector unsigned short,
13246                                   vector unsigned short,
13247                                   vector unsigned int);
13248
13249 void vec_mtvscr (vector signed int);
13250 void vec_mtvscr (vector unsigned int);
13251 void vec_mtvscr (vector bool int);
13252 void vec_mtvscr (vector signed short);
13253 void vec_mtvscr (vector unsigned short);
13254 void vec_mtvscr (vector bool short);
13255 void vec_mtvscr (vector pixel);
13256 void vec_mtvscr (vector signed char);
13257 void vec_mtvscr (vector unsigned char);
13258 void vec_mtvscr (vector bool char);
13259
13260 vector unsigned short vec_mule (vector unsigned char,
13261                                 vector unsigned char);
13262 vector signed short vec_mule (vector signed char,
13263                               vector signed char);
13264 vector unsigned int vec_mule (vector unsigned short,
13265                               vector unsigned short);
13266 vector signed int vec_mule (vector signed short, vector signed short);
13267
13268 vector signed int vec_vmulesh (vector signed short,
13269                                vector signed short);
13270
13271 vector unsigned int vec_vmuleuh (vector unsigned short,
13272                                  vector unsigned short);
13273
13274 vector signed short vec_vmulesb (vector signed char,
13275                                  vector signed char);
13276
13277 vector unsigned short vec_vmuleub (vector unsigned char,
13278                                   vector unsigned char);
13279
13280 vector unsigned short vec_mulo (vector unsigned char,
13281                                 vector unsigned char);
13282 vector signed short vec_mulo (vector signed char, vector signed char);
13283 vector unsigned int vec_mulo (vector unsigned short,
13284                               vector unsigned short);
13285 vector signed int vec_mulo (vector signed short, vector signed short);
13286
13287 vector signed int vec_vmulosh (vector signed short,
13288                                vector signed short);
13289
13290 vector unsigned int vec_vmulouh (vector unsigned short,
13291                                  vector unsigned short);
13292
13293 vector signed short vec_vmulosb (vector signed char,
13294                                  vector signed char);
13295
13296 vector unsigned short vec_vmuloub (vector unsigned char,
13297                                    vector unsigned char);
13298
13299 vector float vec_nmsub (vector float, vector float, vector float);
13300
13301 vector float vec_nor (vector float, vector float);
13302 vector signed int vec_nor (vector signed int, vector signed int);
13303 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
13304 vector bool int vec_nor (vector bool int, vector bool int);
13305 vector signed short vec_nor (vector signed short, vector signed short);
13306 vector unsigned short vec_nor (vector unsigned short,
13307                                vector unsigned short);
13308 vector bool short vec_nor (vector bool short, vector bool short);
13309 vector signed char vec_nor (vector signed char, vector signed char);
13310 vector unsigned char vec_nor (vector unsigned char,
13311                               vector unsigned char);
13312 vector bool char vec_nor (vector bool char, vector bool char);
13313
13314 vector float vec_or (vector float, vector float);
13315 vector float vec_or (vector float, vector bool int);
13316 vector float vec_or (vector bool int, vector float);
13317 vector bool int vec_or (vector bool int, vector bool int);
13318 vector signed int vec_or (vector bool int, vector signed int);
13319 vector signed int vec_or (vector signed int, vector bool int);
13320 vector signed int vec_or (vector signed int, vector signed int);
13321 vector unsigned int vec_or (vector bool int, vector unsigned int);
13322 vector unsigned int vec_or (vector unsigned int, vector bool int);
13323 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
13324 vector bool short vec_or (vector bool short, vector bool short);
13325 vector signed short vec_or (vector bool short, vector signed short);
13326 vector signed short vec_or (vector signed short, vector bool short);
13327 vector signed short vec_or (vector signed short, vector signed short);
13328 vector unsigned short vec_or (vector bool short, vector unsigned short);
13329 vector unsigned short vec_or (vector unsigned short, vector bool short);
13330 vector unsigned short vec_or (vector unsigned short,
13331                               vector unsigned short);
13332 vector signed char vec_or (vector bool char, vector signed char);
13333 vector bool char vec_or (vector bool char, vector bool char);
13334 vector signed char vec_or (vector signed char, vector bool char);
13335 vector signed char vec_or (vector signed char, vector signed char);
13336 vector unsigned char vec_or (vector bool char, vector unsigned char);
13337 vector unsigned char vec_or (vector unsigned char, vector bool char);
13338 vector unsigned char vec_or (vector unsigned char,
13339                              vector unsigned char);
13340
13341 vector signed char vec_pack (vector signed short, vector signed short);
13342 vector unsigned char vec_pack (vector unsigned short,
13343                                vector unsigned short);
13344 vector bool char vec_pack (vector bool short, vector bool short);
13345 vector signed short vec_pack (vector signed int, vector signed int);
13346 vector unsigned short vec_pack (vector unsigned int,
13347                                 vector unsigned int);
13348 vector bool short vec_pack (vector bool int, vector bool int);
13349
13350 vector bool short vec_vpkuwum (vector bool int, vector bool int);
13351 vector signed short vec_vpkuwum (vector signed int, vector signed int);
13352 vector unsigned short vec_vpkuwum (vector unsigned int,
13353                                    vector unsigned int);
13354
13355 vector bool char vec_vpkuhum (vector bool short, vector bool short);
13356 vector signed char vec_vpkuhum (vector signed short,
13357                                 vector signed short);
13358 vector unsigned char vec_vpkuhum (vector unsigned short,
13359                                   vector unsigned short);
13360
13361 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
13362
13363 vector unsigned char vec_packs (vector unsigned short,
13364                                 vector unsigned short);
13365 vector signed char vec_packs (vector signed short, vector signed short);
13366 vector unsigned short vec_packs (vector unsigned int,
13367                                  vector unsigned int);
13368 vector signed short vec_packs (vector signed int, vector signed int);
13369
13370 vector signed short vec_vpkswss (vector signed int, vector signed int);
13371
13372 vector unsigned short vec_vpkuwus (vector unsigned int,
13373                                    vector unsigned int);
13374
13375 vector signed char vec_vpkshss (vector signed short,
13376                                 vector signed short);
13377
13378 vector unsigned char vec_vpkuhus (vector unsigned short,
13379                                   vector unsigned short);
13380
13381 vector unsigned char vec_packsu (vector unsigned short,
13382                                  vector unsigned short);
13383 vector unsigned char vec_packsu (vector signed short,
13384                                  vector signed short);
13385 vector unsigned short vec_packsu (vector unsigned int,
13386                                   vector unsigned int);
13387 vector unsigned short vec_packsu (vector signed int, vector signed int);
13388
13389 vector unsigned short vec_vpkswus (vector signed int,
13390                                    vector signed int);
13391
13392 vector unsigned char vec_vpkshus (vector signed short,
13393                                   vector signed short);
13394
13395 vector float vec_perm (vector float,
13396                        vector float,
13397                        vector unsigned char);
13398 vector signed int vec_perm (vector signed int,
13399                             vector signed int,
13400                             vector unsigned char);
13401 vector unsigned int vec_perm (vector unsigned int,
13402                               vector unsigned int,
13403                               vector unsigned char);
13404 vector bool int vec_perm (vector bool int,
13405                           vector bool int,
13406                           vector unsigned char);
13407 vector signed short vec_perm (vector signed short,
13408                               vector signed short,
13409                               vector unsigned char);
13410 vector unsigned short vec_perm (vector unsigned short,
13411                                 vector unsigned short,
13412                                 vector unsigned char);
13413 vector bool short vec_perm (vector bool short,
13414                             vector bool short,
13415                             vector unsigned char);
13416 vector pixel vec_perm (vector pixel,
13417                        vector pixel,
13418                        vector unsigned char);
13419 vector signed char vec_perm (vector signed char,
13420                              vector signed char,
13421                              vector unsigned char);
13422 vector unsigned char vec_perm (vector unsigned char,
13423                                vector unsigned char,
13424                                vector unsigned char);
13425 vector bool char vec_perm (vector bool char,
13426                            vector bool char,
13427                            vector unsigned char);
13428
13429 vector float vec_re (vector float);
13430
13431 vector signed char vec_rl (vector signed char,
13432                            vector unsigned char);
13433 vector unsigned char vec_rl (vector unsigned char,
13434                              vector unsigned char);
13435 vector signed short vec_rl (vector signed short, vector unsigned short);
13436 vector unsigned short vec_rl (vector unsigned short,
13437                               vector unsigned short);
13438 vector signed int vec_rl (vector signed int, vector unsigned int);
13439 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
13440
13441 vector signed int vec_vrlw (vector signed int, vector unsigned int);
13442 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
13443
13444 vector signed short vec_vrlh (vector signed short,
13445                               vector unsigned short);
13446 vector unsigned short vec_vrlh (vector unsigned short,
13447                                 vector unsigned short);
13448
13449 vector signed char vec_vrlb (vector signed char, vector unsigned char);
13450 vector unsigned char vec_vrlb (vector unsigned char,
13451                                vector unsigned char);
13452
13453 vector float vec_round (vector float);
13454
13455 vector float vec_recip (vector float, vector float);
13456
13457 vector float vec_rsqrt (vector float);
13458
13459 vector float vec_rsqrte (vector float);
13460
13461 vector float vec_sel (vector float, vector float, vector bool int);
13462 vector float vec_sel (vector float, vector float, vector unsigned int);
13463 vector signed int vec_sel (vector signed int,
13464                            vector signed int,
13465                            vector bool int);
13466 vector signed int vec_sel (vector signed int,
13467                            vector signed int,
13468                            vector unsigned int);
13469 vector unsigned int vec_sel (vector unsigned int,
13470                              vector unsigned int,
13471                              vector bool int);
13472 vector unsigned int vec_sel (vector unsigned int,
13473                              vector unsigned int,
13474                              vector unsigned int);
13475 vector bool int vec_sel (vector bool int,
13476                          vector bool int,
13477                          vector bool int);
13478 vector bool int vec_sel (vector bool int,
13479                          vector bool int,
13480                          vector unsigned int);
13481 vector signed short vec_sel (vector signed short,
13482                              vector signed short,
13483                              vector bool short);
13484 vector signed short vec_sel (vector signed short,
13485                              vector signed short,
13486                              vector unsigned short);
13487 vector unsigned short vec_sel (vector unsigned short,
13488                                vector unsigned short,
13489                                vector bool short);
13490 vector unsigned short vec_sel (vector unsigned short,
13491                                vector unsigned short,
13492                                vector unsigned short);
13493 vector bool short vec_sel (vector bool short,
13494                            vector bool short,
13495                            vector bool short);
13496 vector bool short vec_sel (vector bool short,
13497                            vector bool short,
13498                            vector unsigned short);
13499 vector signed char vec_sel (vector signed char,
13500                             vector signed char,
13501                             vector bool char);
13502 vector signed char vec_sel (vector signed char,
13503                             vector signed char,
13504                             vector unsigned char);
13505 vector unsigned char vec_sel (vector unsigned char,
13506                               vector unsigned char,
13507                               vector bool char);
13508 vector unsigned char vec_sel (vector unsigned char,
13509                               vector unsigned char,
13510                               vector unsigned char);
13511 vector bool char vec_sel (vector bool char,
13512                           vector bool char,
13513                           vector bool char);
13514 vector bool char vec_sel (vector bool char,
13515                           vector bool char,
13516                           vector unsigned char);
13517
13518 vector signed char vec_sl (vector signed char,
13519                            vector unsigned char);
13520 vector unsigned char vec_sl (vector unsigned char,
13521                              vector unsigned char);
13522 vector signed short vec_sl (vector signed short, vector unsigned short);
13523 vector unsigned short vec_sl (vector unsigned short,
13524                               vector unsigned short);
13525 vector signed int vec_sl (vector signed int, vector unsigned int);
13526 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13527
13528 vector signed int vec_vslw (vector signed int, vector unsigned int);
13529 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13530
13531 vector signed short vec_vslh (vector signed short,
13532                               vector unsigned short);
13533 vector unsigned short vec_vslh (vector unsigned short,
13534                                 vector unsigned short);
13535
13536 vector signed char vec_vslb (vector signed char, vector unsigned char);
13537 vector unsigned char vec_vslb (vector unsigned char,
13538                                vector unsigned char);
13539
13540 vector float vec_sld (vector float, vector float, const int);
13541 vector signed int vec_sld (vector signed int,
13542                            vector signed int,
13543                            const int);
13544 vector unsigned int vec_sld (vector unsigned int,
13545                              vector unsigned int,
13546                              const int);
13547 vector bool int vec_sld (vector bool int,
13548                          vector bool int,
13549                          const int);
13550 vector signed short vec_sld (vector signed short,
13551                              vector signed short,
13552                              const int);
13553 vector unsigned short vec_sld (vector unsigned short,
13554                                vector unsigned short,
13555                                const int);
13556 vector bool short vec_sld (vector bool short,
13557                            vector bool short,
13558                            const int);
13559 vector pixel vec_sld (vector pixel,
13560                       vector pixel,
13561                       const int);
13562 vector signed char vec_sld (vector signed char,
13563                             vector signed char,
13564                             const int);
13565 vector unsigned char vec_sld (vector unsigned char,
13566                               vector unsigned char,
13567                               const int);
13568 vector bool char vec_sld (vector bool char,
13569                           vector bool char,
13570                           const int);
13571
13572 vector signed int vec_sll (vector signed int,
13573                            vector unsigned int);
13574 vector signed int vec_sll (vector signed int,
13575                            vector unsigned short);
13576 vector signed int vec_sll (vector signed int,
13577                            vector unsigned char);
13578 vector unsigned int vec_sll (vector unsigned int,
13579                              vector unsigned int);
13580 vector unsigned int vec_sll (vector unsigned int,
13581                              vector unsigned short);
13582 vector unsigned int vec_sll (vector unsigned int,
13583                              vector unsigned char);
13584 vector bool int vec_sll (vector bool int,
13585                          vector unsigned int);
13586 vector bool int vec_sll (vector bool int,
13587                          vector unsigned short);
13588 vector bool int vec_sll (vector bool int,
13589                          vector unsigned char);
13590 vector signed short vec_sll (vector signed short,
13591                              vector unsigned int);
13592 vector signed short vec_sll (vector signed short,
13593                              vector unsigned short);
13594 vector signed short vec_sll (vector signed short,
13595                              vector unsigned char);
13596 vector unsigned short vec_sll (vector unsigned short,
13597                                vector unsigned int);
13598 vector unsigned short vec_sll (vector unsigned short,
13599                                vector unsigned short);
13600 vector unsigned short vec_sll (vector unsigned short,
13601                                vector unsigned char);
13602 vector bool short vec_sll (vector bool short, vector unsigned int);
13603 vector bool short vec_sll (vector bool short, vector unsigned short);
13604 vector bool short vec_sll (vector bool short, vector unsigned char);
13605 vector pixel vec_sll (vector pixel, vector unsigned int);
13606 vector pixel vec_sll (vector pixel, vector unsigned short);
13607 vector pixel vec_sll (vector pixel, vector unsigned char);
13608 vector signed char vec_sll (vector signed char, vector unsigned int);
13609 vector signed char vec_sll (vector signed char, vector unsigned short);
13610 vector signed char vec_sll (vector signed char, vector unsigned char);
13611 vector unsigned char vec_sll (vector unsigned char,
13612                               vector unsigned int);
13613 vector unsigned char vec_sll (vector unsigned char,
13614                               vector unsigned short);
13615 vector unsigned char vec_sll (vector unsigned char,
13616                               vector unsigned char);
13617 vector bool char vec_sll (vector bool char, vector unsigned int);
13618 vector bool char vec_sll (vector bool char, vector unsigned short);
13619 vector bool char vec_sll (vector bool char, vector unsigned char);
13620
13621 vector float vec_slo (vector float, vector signed char);
13622 vector float vec_slo (vector float, vector unsigned char);
13623 vector signed int vec_slo (vector signed int, vector signed char);
13624 vector signed int vec_slo (vector signed int, vector unsigned char);
13625 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13626 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13627 vector signed short vec_slo (vector signed short, vector signed char);
13628 vector signed short vec_slo (vector signed short, vector unsigned char);
13629 vector unsigned short vec_slo (vector unsigned short,
13630                                vector signed char);
13631 vector unsigned short vec_slo (vector unsigned short,
13632                                vector unsigned char);
13633 vector pixel vec_slo (vector pixel, vector signed char);
13634 vector pixel vec_slo (vector pixel, vector unsigned char);
13635 vector signed char vec_slo (vector signed char, vector signed char);
13636 vector signed char vec_slo (vector signed char, vector unsigned char);
13637 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13638 vector unsigned char vec_slo (vector unsigned char,
13639                               vector unsigned char);
13640
13641 vector signed char vec_splat (vector signed char, const int);
13642 vector unsigned char vec_splat (vector unsigned char, const int);
13643 vector bool char vec_splat (vector bool char, const int);
13644 vector signed short vec_splat (vector signed short, const int);
13645 vector unsigned short vec_splat (vector unsigned short, const int);
13646 vector bool short vec_splat (vector bool short, const int);
13647 vector pixel vec_splat (vector pixel, const int);
13648 vector float vec_splat (vector float, const int);
13649 vector signed int vec_splat (vector signed int, const int);
13650 vector unsigned int vec_splat (vector unsigned int, const int);
13651 vector bool int vec_splat (vector bool int, const int);
13652 vector signed long vec_splat (vector signed long, const int);
13653 vector unsigned long vec_splat (vector unsigned long, const int);
13654
13655 vector signed char vec_splats (signed char);
13656 vector unsigned char vec_splats (unsigned char);
13657 vector signed short vec_splats (signed short);
13658 vector unsigned short vec_splats (unsigned short);
13659 vector signed int vec_splats (signed int);
13660 vector unsigned int vec_splats (unsigned int);
13661 vector float vec_splats (float);
13662
13663 vector float vec_vspltw (vector float, const int);
13664 vector signed int vec_vspltw (vector signed int, const int);
13665 vector unsigned int vec_vspltw (vector unsigned int, const int);
13666 vector bool int vec_vspltw (vector bool int, const int);
13667
13668 vector bool short vec_vsplth (vector bool short, const int);
13669 vector signed short vec_vsplth (vector signed short, const int);
13670 vector unsigned short vec_vsplth (vector unsigned short, const int);
13671 vector pixel vec_vsplth (vector pixel, const int);
13672
13673 vector signed char vec_vspltb (vector signed char, const int);
13674 vector unsigned char vec_vspltb (vector unsigned char, const int);
13675 vector bool char vec_vspltb (vector bool char, const int);
13676
13677 vector signed char vec_splat_s8 (const int);
13678
13679 vector signed short vec_splat_s16 (const int);
13680
13681 vector signed int vec_splat_s32 (const int);
13682
13683 vector unsigned char vec_splat_u8 (const int);
13684
13685 vector unsigned short vec_splat_u16 (const int);
13686
13687 vector unsigned int vec_splat_u32 (const int);
13688
13689 vector signed char vec_sr (vector signed char, vector unsigned char);
13690 vector unsigned char vec_sr (vector unsigned char,
13691                              vector unsigned char);
13692 vector signed short vec_sr (vector signed short,
13693                             vector unsigned short);
13694 vector unsigned short vec_sr (vector unsigned short,
13695                               vector unsigned short);
13696 vector signed int vec_sr (vector signed int, vector unsigned int);
13697 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13698
13699 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13700 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13701
13702 vector signed short vec_vsrh (vector signed short,
13703                               vector unsigned short);
13704 vector unsigned short vec_vsrh (vector unsigned short,
13705                                 vector unsigned short);
13706
13707 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13708 vector unsigned char vec_vsrb (vector unsigned char,
13709                                vector unsigned char);
13710
13711 vector signed char vec_sra (vector signed char, vector unsigned char);
13712 vector unsigned char vec_sra (vector unsigned char,
13713                               vector unsigned char);
13714 vector signed short vec_sra (vector signed short,
13715                              vector unsigned short);
13716 vector unsigned short vec_sra (vector unsigned short,
13717                                vector unsigned short);
13718 vector signed int vec_sra (vector signed int, vector unsigned int);
13719 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13720
13721 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13722 vector unsigned int vec_vsraw (vector unsigned int,
13723                                vector unsigned int);
13724
13725 vector signed short vec_vsrah (vector signed short,
13726                                vector unsigned short);
13727 vector unsigned short vec_vsrah (vector unsigned short,
13728                                  vector unsigned short);
13729
13730 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13731 vector unsigned char vec_vsrab (vector unsigned char,
13732                                 vector unsigned char);
13733
13734 vector signed int vec_srl (vector signed int, vector unsigned int);
13735 vector signed int vec_srl (vector signed int, vector unsigned short);
13736 vector signed int vec_srl (vector signed int, vector unsigned char);
13737 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13738 vector unsigned int vec_srl (vector unsigned int,
13739                              vector unsigned short);
13740 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13741 vector bool int vec_srl (vector bool int, vector unsigned int);
13742 vector bool int vec_srl (vector bool int, vector unsigned short);
13743 vector bool int vec_srl (vector bool int, vector unsigned char);
13744 vector signed short vec_srl (vector signed short, vector unsigned int);
13745 vector signed short vec_srl (vector signed short,
13746                              vector unsigned short);
13747 vector signed short vec_srl (vector signed short, vector unsigned char);
13748 vector unsigned short vec_srl (vector unsigned short,
13749                                vector unsigned int);
13750 vector unsigned short vec_srl (vector unsigned short,
13751                                vector unsigned short);
13752 vector unsigned short vec_srl (vector unsigned short,
13753                                vector unsigned char);
13754 vector bool short vec_srl (vector bool short, vector unsigned int);
13755 vector bool short vec_srl (vector bool short, vector unsigned short);
13756 vector bool short vec_srl (vector bool short, vector unsigned char);
13757 vector pixel vec_srl (vector pixel, vector unsigned int);
13758 vector pixel vec_srl (vector pixel, vector unsigned short);
13759 vector pixel vec_srl (vector pixel, vector unsigned char);
13760 vector signed char vec_srl (vector signed char, vector unsigned int);
13761 vector signed char vec_srl (vector signed char, vector unsigned short);
13762 vector signed char vec_srl (vector signed char, vector unsigned char);
13763 vector unsigned char vec_srl (vector unsigned char,
13764                               vector unsigned int);
13765 vector unsigned char vec_srl (vector unsigned char,
13766                               vector unsigned short);
13767 vector unsigned char vec_srl (vector unsigned char,
13768                               vector unsigned char);
13769 vector bool char vec_srl (vector bool char, vector unsigned int);
13770 vector bool char vec_srl (vector bool char, vector unsigned short);
13771 vector bool char vec_srl (vector bool char, vector unsigned char);
13772
13773 vector float vec_sro (vector float, vector signed char);
13774 vector float vec_sro (vector float, vector unsigned char);
13775 vector signed int vec_sro (vector signed int, vector signed char);
13776 vector signed int vec_sro (vector signed int, vector unsigned char);
13777 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13778 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13779 vector signed short vec_sro (vector signed short, vector signed char);
13780 vector signed short vec_sro (vector signed short, vector unsigned char);
13781 vector unsigned short vec_sro (vector unsigned short,
13782                                vector signed char);
13783 vector unsigned short vec_sro (vector unsigned short,
13784                                vector unsigned char);
13785 vector pixel vec_sro (vector pixel, vector signed char);
13786 vector pixel vec_sro (vector pixel, vector unsigned char);
13787 vector signed char vec_sro (vector signed char, vector signed char);
13788 vector signed char vec_sro (vector signed char, vector unsigned char);
13789 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13790 vector unsigned char vec_sro (vector unsigned char,
13791                               vector unsigned char);
13792
13793 void vec_st (vector float, int, vector float *);
13794 void vec_st (vector float, int, float *);
13795 void vec_st (vector signed int, int, vector signed int *);
13796 void vec_st (vector signed int, int, int *);
13797 void vec_st (vector unsigned int, int, vector unsigned int *);
13798 void vec_st (vector unsigned int, int, unsigned int *);
13799 void vec_st (vector bool int, int, vector bool int *);
13800 void vec_st (vector bool int, int, unsigned int *);
13801 void vec_st (vector bool int, int, int *);
13802 void vec_st (vector signed short, int, vector signed short *);
13803 void vec_st (vector signed short, int, short *);
13804 void vec_st (vector unsigned short, int, vector unsigned short *);
13805 void vec_st (vector unsigned short, int, unsigned short *);
13806 void vec_st (vector bool short, int, vector bool short *);
13807 void vec_st (vector bool short, int, unsigned short *);
13808 void vec_st (vector pixel, int, vector pixel *);
13809 void vec_st (vector pixel, int, unsigned short *);
13810 void vec_st (vector pixel, int, short *);
13811 void vec_st (vector bool short, int, short *);
13812 void vec_st (vector signed char, int, vector signed char *);
13813 void vec_st (vector signed char, int, signed char *);
13814 void vec_st (vector unsigned char, int, vector unsigned char *);
13815 void vec_st (vector unsigned char, int, unsigned char *);
13816 void vec_st (vector bool char, int, vector bool char *);
13817 void vec_st (vector bool char, int, unsigned char *);
13818 void vec_st (vector bool char, int, signed char *);
13819
13820 void vec_ste (vector signed char, int, signed char *);
13821 void vec_ste (vector unsigned char, int, unsigned char *);
13822 void vec_ste (vector bool char, int, signed char *);
13823 void vec_ste (vector bool char, int, unsigned char *);
13824 void vec_ste (vector signed short, int, short *);
13825 void vec_ste (vector unsigned short, int, unsigned short *);
13826 void vec_ste (vector bool short, int, short *);
13827 void vec_ste (vector bool short, int, unsigned short *);
13828 void vec_ste (vector pixel, int, short *);
13829 void vec_ste (vector pixel, int, unsigned short *);
13830 void vec_ste (vector float, int, float *);
13831 void vec_ste (vector signed int, int, int *);
13832 void vec_ste (vector unsigned int, int, unsigned int *);
13833 void vec_ste (vector bool int, int, int *);
13834 void vec_ste (vector bool int, int, unsigned int *);
13835
13836 void vec_stvewx (vector float, int, float *);
13837 void vec_stvewx (vector signed int, int, int *);
13838 void vec_stvewx (vector unsigned int, int, unsigned int *);
13839 void vec_stvewx (vector bool int, int, int *);
13840 void vec_stvewx (vector bool int, int, unsigned int *);
13841
13842 void vec_stvehx (vector signed short, int, short *);
13843 void vec_stvehx (vector unsigned short, int, unsigned short *);
13844 void vec_stvehx (vector bool short, int, short *);
13845 void vec_stvehx (vector bool short, int, unsigned short *);
13846 void vec_stvehx (vector pixel, int, short *);
13847 void vec_stvehx (vector pixel, int, unsigned short *);
13848
13849 void vec_stvebx (vector signed char, int, signed char *);
13850 void vec_stvebx (vector unsigned char, int, unsigned char *);
13851 void vec_stvebx (vector bool char, int, signed char *);
13852 void vec_stvebx (vector bool char, int, unsigned char *);
13853
13854 void vec_stl (vector float, int, vector float *);
13855 void vec_stl (vector float, int, float *);
13856 void vec_stl (vector signed int, int, vector signed int *);
13857 void vec_stl (vector signed int, int, int *);
13858 void vec_stl (vector unsigned int, int, vector unsigned int *);
13859 void vec_stl (vector unsigned int, int, unsigned int *);
13860 void vec_stl (vector bool int, int, vector bool int *);
13861 void vec_stl (vector bool int, int, unsigned int *);
13862 void vec_stl (vector bool int, int, int *);
13863 void vec_stl (vector signed short, int, vector signed short *);
13864 void vec_stl (vector signed short, int, short *);
13865 void vec_stl (vector unsigned short, int, vector unsigned short *);
13866 void vec_stl (vector unsigned short, int, unsigned short *);
13867 void vec_stl (vector bool short, int, vector bool short *);
13868 void vec_stl (vector bool short, int, unsigned short *);
13869 void vec_stl (vector bool short, int, short *);
13870 void vec_stl (vector pixel, int, vector pixel *);
13871 void vec_stl (vector pixel, int, unsigned short *);
13872 void vec_stl (vector pixel, int, short *);
13873 void vec_stl (vector signed char, int, vector signed char *);
13874 void vec_stl (vector signed char, int, signed char *);
13875 void vec_stl (vector unsigned char, int, vector unsigned char *);
13876 void vec_stl (vector unsigned char, int, unsigned char *);
13877 void vec_stl (vector bool char, int, vector bool char *);
13878 void vec_stl (vector bool char, int, unsigned char *);
13879 void vec_stl (vector bool char, int, signed char *);
13880
13881 vector signed char vec_sub (vector bool char, vector signed char);
13882 vector signed char vec_sub (vector signed char, vector bool char);
13883 vector signed char vec_sub (vector signed char, vector signed char);
13884 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13885 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13886 vector unsigned char vec_sub (vector unsigned char,
13887                               vector unsigned char);
13888 vector signed short vec_sub (vector bool short, vector signed short);
13889 vector signed short vec_sub (vector signed short, vector bool short);
13890 vector signed short vec_sub (vector signed short, vector signed short);
13891 vector unsigned short vec_sub (vector bool short,
13892                                vector unsigned short);
13893 vector unsigned short vec_sub (vector unsigned short,
13894                                vector bool short);
13895 vector unsigned short vec_sub (vector unsigned short,
13896                                vector unsigned short);
13897 vector signed int vec_sub (vector bool int, vector signed int);
13898 vector signed int vec_sub (vector signed int, vector bool int);
13899 vector signed int vec_sub (vector signed int, vector signed int);
13900 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13901 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13902 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13903 vector float vec_sub (vector float, vector float);
13904
13905 vector float vec_vsubfp (vector float, vector float);
13906
13907 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13908 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13909 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13910 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13911 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13912 vector unsigned int vec_vsubuwm (vector unsigned int,
13913                                  vector unsigned int);
13914
13915 vector signed short vec_vsubuhm (vector bool short,
13916                                  vector signed short);
13917 vector signed short vec_vsubuhm (vector signed short,
13918                                  vector bool short);
13919 vector signed short vec_vsubuhm (vector signed short,
13920                                  vector signed short);
13921 vector unsigned short vec_vsubuhm (vector bool short,
13922                                    vector unsigned short);
13923 vector unsigned short vec_vsubuhm (vector unsigned short,
13924                                    vector bool short);
13925 vector unsigned short vec_vsubuhm (vector unsigned short,
13926                                    vector unsigned short);
13927
13928 vector signed char vec_vsububm (vector bool char, vector signed char);
13929 vector signed char vec_vsububm (vector signed char, vector bool char);
13930 vector signed char vec_vsububm (vector signed char, vector signed char);
13931 vector unsigned char vec_vsububm (vector bool char,
13932                                   vector unsigned char);
13933 vector unsigned char vec_vsububm (vector unsigned char,
13934                                   vector bool char);
13935 vector unsigned char vec_vsububm (vector unsigned char,
13936                                   vector unsigned char);
13937
13938 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13939
13940 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13941 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13942 vector unsigned char vec_subs (vector unsigned char,
13943                                vector unsigned char);
13944 vector signed char vec_subs (vector bool char, vector signed char);
13945 vector signed char vec_subs (vector signed char, vector bool char);
13946 vector signed char vec_subs (vector signed char, vector signed char);
13947 vector unsigned short vec_subs (vector bool short,
13948                                 vector unsigned short);
13949 vector unsigned short vec_subs (vector unsigned short,
13950                                 vector bool short);
13951 vector unsigned short vec_subs (vector unsigned short,
13952                                 vector unsigned short);
13953 vector signed short vec_subs (vector bool short, vector signed short);
13954 vector signed short vec_subs (vector signed short, vector bool short);
13955 vector signed short vec_subs (vector signed short, vector signed short);
13956 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13957 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13958 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13959 vector signed int vec_subs (vector bool int, vector signed int);
13960 vector signed int vec_subs (vector signed int, vector bool int);
13961 vector signed int vec_subs (vector signed int, vector signed int);
13962
13963 vector signed int vec_vsubsws (vector bool int, vector signed int);
13964 vector signed int vec_vsubsws (vector signed int, vector bool int);
13965 vector signed int vec_vsubsws (vector signed int, vector signed int);
13966
13967 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13968 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13969 vector unsigned int vec_vsubuws (vector unsigned int,
13970                                  vector unsigned int);
13971
13972 vector signed short vec_vsubshs (vector bool short,
13973                                  vector signed short);
13974 vector signed short vec_vsubshs (vector signed short,
13975                                  vector bool short);
13976 vector signed short vec_vsubshs (vector signed short,
13977                                  vector signed short);
13978
13979 vector unsigned short vec_vsubuhs (vector bool short,
13980                                    vector unsigned short);
13981 vector unsigned short vec_vsubuhs (vector unsigned short,
13982                                    vector bool short);
13983 vector unsigned short vec_vsubuhs (vector unsigned short,
13984                                    vector unsigned short);
13985
13986 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13987 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13988 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13989
13990 vector unsigned char vec_vsububs (vector bool char,
13991                                   vector unsigned char);
13992 vector unsigned char vec_vsububs (vector unsigned char,
13993                                   vector bool char);
13994 vector unsigned char vec_vsububs (vector unsigned char,
13995                                   vector unsigned char);
13996
13997 vector unsigned int vec_sum4s (vector unsigned char,
13998                                vector unsigned int);
13999 vector signed int vec_sum4s (vector signed char, vector signed int);
14000 vector signed int vec_sum4s (vector signed short, vector signed int);
14001
14002 vector signed int vec_vsum4shs (vector signed short, vector signed int);
14003
14004 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
14005
14006 vector unsigned int vec_vsum4ubs (vector unsigned char,
14007                                   vector unsigned int);
14008
14009 vector signed int vec_sum2s (vector signed int, vector signed int);
14010
14011 vector signed int vec_sums (vector signed int, vector signed int);
14012
14013 vector float vec_trunc (vector float);
14014
14015 vector signed short vec_unpackh (vector signed char);
14016 vector bool short vec_unpackh (vector bool char);
14017 vector signed int vec_unpackh (vector signed short);
14018 vector bool int vec_unpackh (vector bool short);
14019 vector unsigned int vec_unpackh (vector pixel);
14020
14021 vector bool int vec_vupkhsh (vector bool short);
14022 vector signed int vec_vupkhsh (vector signed short);
14023
14024 vector unsigned int vec_vupkhpx (vector pixel);
14025
14026 vector bool short vec_vupkhsb (vector bool char);
14027 vector signed short vec_vupkhsb (vector signed char);
14028
14029 vector signed short vec_unpackl (vector signed char);
14030 vector bool short vec_unpackl (vector bool char);
14031 vector unsigned int vec_unpackl (vector pixel);
14032 vector signed int vec_unpackl (vector signed short);
14033 vector bool int vec_unpackl (vector bool short);
14034
14035 vector unsigned int vec_vupklpx (vector pixel);
14036
14037 vector bool int vec_vupklsh (vector bool short);
14038 vector signed int vec_vupklsh (vector signed short);
14039
14040 vector bool short vec_vupklsb (vector bool char);
14041 vector signed short vec_vupklsb (vector signed char);
14042
14043 vector float vec_xor (vector float, vector float);
14044 vector float vec_xor (vector float, vector bool int);
14045 vector float vec_xor (vector bool int, vector float);
14046 vector bool int vec_xor (vector bool int, vector bool int);
14047 vector signed int vec_xor (vector bool int, vector signed int);
14048 vector signed int vec_xor (vector signed int, vector bool int);
14049 vector signed int vec_xor (vector signed int, vector signed int);
14050 vector unsigned int vec_xor (vector bool int, vector unsigned int);
14051 vector unsigned int vec_xor (vector unsigned int, vector bool int);
14052 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
14053 vector bool short vec_xor (vector bool short, vector bool short);
14054 vector signed short vec_xor (vector bool short, vector signed short);
14055 vector signed short vec_xor (vector signed short, vector bool short);
14056 vector signed short vec_xor (vector signed short, vector signed short);
14057 vector unsigned short vec_xor (vector bool short,
14058                                vector unsigned short);
14059 vector unsigned short vec_xor (vector unsigned short,
14060                                vector bool short);
14061 vector unsigned short vec_xor (vector unsigned short,
14062                                vector unsigned short);
14063 vector signed char vec_xor (vector bool char, vector signed char);
14064 vector bool char vec_xor (vector bool char, vector bool char);
14065 vector signed char vec_xor (vector signed char, vector bool char);
14066 vector signed char vec_xor (vector signed char, vector signed char);
14067 vector unsigned char vec_xor (vector bool char, vector unsigned char);
14068 vector unsigned char vec_xor (vector unsigned char, vector bool char);
14069 vector unsigned char vec_xor (vector unsigned char,
14070                               vector unsigned char);
14071
14072 int vec_all_eq (vector signed char, vector bool char);
14073 int vec_all_eq (vector signed char, vector signed char);
14074 int vec_all_eq (vector unsigned char, vector bool char);
14075 int vec_all_eq (vector unsigned char, vector unsigned char);
14076 int vec_all_eq (vector bool char, vector bool char);
14077 int vec_all_eq (vector bool char, vector unsigned char);
14078 int vec_all_eq (vector bool char, vector signed char);
14079 int vec_all_eq (vector signed short, vector bool short);
14080 int vec_all_eq (vector signed short, vector signed short);
14081 int vec_all_eq (vector unsigned short, vector bool short);
14082 int vec_all_eq (vector unsigned short, vector unsigned short);
14083 int vec_all_eq (vector bool short, vector bool short);
14084 int vec_all_eq (vector bool short, vector unsigned short);
14085 int vec_all_eq (vector bool short, vector signed short);
14086 int vec_all_eq (vector pixel, vector pixel);
14087 int vec_all_eq (vector signed int, vector bool int);
14088 int vec_all_eq (vector signed int, vector signed int);
14089 int vec_all_eq (vector unsigned int, vector bool int);
14090 int vec_all_eq (vector unsigned int, vector unsigned int);
14091 int vec_all_eq (vector bool int, vector bool int);
14092 int vec_all_eq (vector bool int, vector unsigned int);
14093 int vec_all_eq (vector bool int, vector signed int);
14094 int vec_all_eq (vector float, vector float);
14095
14096 int vec_all_ge (vector bool char, vector unsigned char);
14097 int vec_all_ge (vector unsigned char, vector bool char);
14098 int vec_all_ge (vector unsigned char, vector unsigned char);
14099 int vec_all_ge (vector bool char, vector signed char);
14100 int vec_all_ge (vector signed char, vector bool char);
14101 int vec_all_ge (vector signed char, vector signed char);
14102 int vec_all_ge (vector bool short, vector unsigned short);
14103 int vec_all_ge (vector unsigned short, vector bool short);
14104 int vec_all_ge (vector unsigned short, vector unsigned short);
14105 int vec_all_ge (vector signed short, vector signed short);
14106 int vec_all_ge (vector bool short, vector signed short);
14107 int vec_all_ge (vector signed short, vector bool short);
14108 int vec_all_ge (vector bool int, vector unsigned int);
14109 int vec_all_ge (vector unsigned int, vector bool int);
14110 int vec_all_ge (vector unsigned int, vector unsigned int);
14111 int vec_all_ge (vector bool int, vector signed int);
14112 int vec_all_ge (vector signed int, vector bool int);
14113 int vec_all_ge (vector signed int, vector signed int);
14114 int vec_all_ge (vector float, vector float);
14115
14116 int vec_all_gt (vector bool char, vector unsigned char);
14117 int vec_all_gt (vector unsigned char, vector bool char);
14118 int vec_all_gt (vector unsigned char, vector unsigned char);
14119 int vec_all_gt (vector bool char, vector signed char);
14120 int vec_all_gt (vector signed char, vector bool char);
14121 int vec_all_gt (vector signed char, vector signed char);
14122 int vec_all_gt (vector bool short, vector unsigned short);
14123 int vec_all_gt (vector unsigned short, vector bool short);
14124 int vec_all_gt (vector unsigned short, vector unsigned short);
14125 int vec_all_gt (vector bool short, vector signed short);
14126 int vec_all_gt (vector signed short, vector bool short);
14127 int vec_all_gt (vector signed short, vector signed short);
14128 int vec_all_gt (vector bool int, vector unsigned int);
14129 int vec_all_gt (vector unsigned int, vector bool int);
14130 int vec_all_gt (vector unsigned int, vector unsigned int);
14131 int vec_all_gt (vector bool int, vector signed int);
14132 int vec_all_gt (vector signed int, vector bool int);
14133 int vec_all_gt (vector signed int, vector signed int);
14134 int vec_all_gt (vector float, vector float);
14135
14136 int vec_all_in (vector float, vector float);
14137
14138 int vec_all_le (vector bool char, vector unsigned char);
14139 int vec_all_le (vector unsigned char, vector bool char);
14140 int vec_all_le (vector unsigned char, vector unsigned char);
14141 int vec_all_le (vector bool char, vector signed char);
14142 int vec_all_le (vector signed char, vector bool char);
14143 int vec_all_le (vector signed char, vector signed char);
14144 int vec_all_le (vector bool short, vector unsigned short);
14145 int vec_all_le (vector unsigned short, vector bool short);
14146 int vec_all_le (vector unsigned short, vector unsigned short);
14147 int vec_all_le (vector bool short, vector signed short);
14148 int vec_all_le (vector signed short, vector bool short);
14149 int vec_all_le (vector signed short, vector signed short);
14150 int vec_all_le (vector bool int, vector unsigned int);
14151 int vec_all_le (vector unsigned int, vector bool int);
14152 int vec_all_le (vector unsigned int, vector unsigned int);
14153 int vec_all_le (vector bool int, vector signed int);
14154 int vec_all_le (vector signed int, vector bool int);
14155 int vec_all_le (vector signed int, vector signed int);
14156 int vec_all_le (vector float, vector float);
14157
14158 int vec_all_lt (vector bool char, vector unsigned char);
14159 int vec_all_lt (vector unsigned char, vector bool char);
14160 int vec_all_lt (vector unsigned char, vector unsigned char);
14161 int vec_all_lt (vector bool char, vector signed char);
14162 int vec_all_lt (vector signed char, vector bool char);
14163 int vec_all_lt (vector signed char, vector signed char);
14164 int vec_all_lt (vector bool short, vector unsigned short);
14165 int vec_all_lt (vector unsigned short, vector bool short);
14166 int vec_all_lt (vector unsigned short, vector unsigned short);
14167 int vec_all_lt (vector bool short, vector signed short);
14168 int vec_all_lt (vector signed short, vector bool short);
14169 int vec_all_lt (vector signed short, vector signed short);
14170 int vec_all_lt (vector bool int, vector unsigned int);
14171 int vec_all_lt (vector unsigned int, vector bool int);
14172 int vec_all_lt (vector unsigned int, vector unsigned int);
14173 int vec_all_lt (vector bool int, vector signed int);
14174 int vec_all_lt (vector signed int, vector bool int);
14175 int vec_all_lt (vector signed int, vector signed int);
14176 int vec_all_lt (vector float, vector float);
14177
14178 int vec_all_nan (vector float);
14179
14180 int vec_all_ne (vector signed char, vector bool char);
14181 int vec_all_ne (vector signed char, vector signed char);
14182 int vec_all_ne (vector unsigned char, vector bool char);
14183 int vec_all_ne (vector unsigned char, vector unsigned char);
14184 int vec_all_ne (vector bool char, vector bool char);
14185 int vec_all_ne (vector bool char, vector unsigned char);
14186 int vec_all_ne (vector bool char, vector signed char);
14187 int vec_all_ne (vector signed short, vector bool short);
14188 int vec_all_ne (vector signed short, vector signed short);
14189 int vec_all_ne (vector unsigned short, vector bool short);
14190 int vec_all_ne (vector unsigned short, vector unsigned short);
14191 int vec_all_ne (vector bool short, vector bool short);
14192 int vec_all_ne (vector bool short, vector unsigned short);
14193 int vec_all_ne (vector bool short, vector signed short);
14194 int vec_all_ne (vector pixel, vector pixel);
14195 int vec_all_ne (vector signed int, vector bool int);
14196 int vec_all_ne (vector signed int, vector signed int);
14197 int vec_all_ne (vector unsigned int, vector bool int);
14198 int vec_all_ne (vector unsigned int, vector unsigned int);
14199 int vec_all_ne (vector bool int, vector bool int);
14200 int vec_all_ne (vector bool int, vector unsigned int);
14201 int vec_all_ne (vector bool int, vector signed int);
14202 int vec_all_ne (vector float, vector float);
14203
14204 int vec_all_nge (vector float, vector float);
14205
14206 int vec_all_ngt (vector float, vector float);
14207
14208 int vec_all_nle (vector float, vector float);
14209
14210 int vec_all_nlt (vector float, vector float);
14211
14212 int vec_all_numeric (vector float);
14213
14214 int vec_any_eq (vector signed char, vector bool char);
14215 int vec_any_eq (vector signed char, vector signed char);
14216 int vec_any_eq (vector unsigned char, vector bool char);
14217 int vec_any_eq (vector unsigned char, vector unsigned char);
14218 int vec_any_eq (vector bool char, vector bool char);
14219 int vec_any_eq (vector bool char, vector unsigned char);
14220 int vec_any_eq (vector bool char, vector signed char);
14221 int vec_any_eq (vector signed short, vector bool short);
14222 int vec_any_eq (vector signed short, vector signed short);
14223 int vec_any_eq (vector unsigned short, vector bool short);
14224 int vec_any_eq (vector unsigned short, vector unsigned short);
14225 int vec_any_eq (vector bool short, vector bool short);
14226 int vec_any_eq (vector bool short, vector unsigned short);
14227 int vec_any_eq (vector bool short, vector signed short);
14228 int vec_any_eq (vector pixel, vector pixel);
14229 int vec_any_eq (vector signed int, vector bool int);
14230 int vec_any_eq (vector signed int, vector signed int);
14231 int vec_any_eq (vector unsigned int, vector bool int);
14232 int vec_any_eq (vector unsigned int, vector unsigned int);
14233 int vec_any_eq (vector bool int, vector bool int);
14234 int vec_any_eq (vector bool int, vector unsigned int);
14235 int vec_any_eq (vector bool int, vector signed int);
14236 int vec_any_eq (vector float, vector float);
14237
14238 int vec_any_ge (vector signed char, vector bool char);
14239 int vec_any_ge (vector unsigned char, vector bool char);
14240 int vec_any_ge (vector unsigned char, vector unsigned char);
14241 int vec_any_ge (vector signed char, vector signed char);
14242 int vec_any_ge (vector bool char, vector unsigned char);
14243 int vec_any_ge (vector bool char, vector signed char);
14244 int vec_any_ge (vector unsigned short, vector bool short);
14245 int vec_any_ge (vector unsigned short, vector unsigned short);
14246 int vec_any_ge (vector signed short, vector signed short);
14247 int vec_any_ge (vector signed short, vector bool short);
14248 int vec_any_ge (vector bool short, vector unsigned short);
14249 int vec_any_ge (vector bool short, vector signed short);
14250 int vec_any_ge (vector signed int, vector bool int);
14251 int vec_any_ge (vector unsigned int, vector bool int);
14252 int vec_any_ge (vector unsigned int, vector unsigned int);
14253 int vec_any_ge (vector signed int, vector signed int);
14254 int vec_any_ge (vector bool int, vector unsigned int);
14255 int vec_any_ge (vector bool int, vector signed int);
14256 int vec_any_ge (vector float, vector float);
14257
14258 int vec_any_gt (vector bool char, vector unsigned char);
14259 int vec_any_gt (vector unsigned char, vector bool char);
14260 int vec_any_gt (vector unsigned char, vector unsigned char);
14261 int vec_any_gt (vector bool char, vector signed char);
14262 int vec_any_gt (vector signed char, vector bool char);
14263 int vec_any_gt (vector signed char, vector signed char);
14264 int vec_any_gt (vector bool short, vector unsigned short);
14265 int vec_any_gt (vector unsigned short, vector bool short);
14266 int vec_any_gt (vector unsigned short, vector unsigned short);
14267 int vec_any_gt (vector bool short, vector signed short);
14268 int vec_any_gt (vector signed short, vector bool short);
14269 int vec_any_gt (vector signed short, vector signed short);
14270 int vec_any_gt (vector bool int, vector unsigned int);
14271 int vec_any_gt (vector unsigned int, vector bool int);
14272 int vec_any_gt (vector unsigned int, vector unsigned int);
14273 int vec_any_gt (vector bool int, vector signed int);
14274 int vec_any_gt (vector signed int, vector bool int);
14275 int vec_any_gt (vector signed int, vector signed int);
14276 int vec_any_gt (vector float, vector float);
14277
14278 int vec_any_le (vector bool char, vector unsigned char);
14279 int vec_any_le (vector unsigned char, vector bool char);
14280 int vec_any_le (vector unsigned char, vector unsigned char);
14281 int vec_any_le (vector bool char, vector signed char);
14282 int vec_any_le (vector signed char, vector bool char);
14283 int vec_any_le (vector signed char, vector signed char);
14284 int vec_any_le (vector bool short, vector unsigned short);
14285 int vec_any_le (vector unsigned short, vector bool short);
14286 int vec_any_le (vector unsigned short, vector unsigned short);
14287 int vec_any_le (vector bool short, vector signed short);
14288 int vec_any_le (vector signed short, vector bool short);
14289 int vec_any_le (vector signed short, vector signed short);
14290 int vec_any_le (vector bool int, vector unsigned int);
14291 int vec_any_le (vector unsigned int, vector bool int);
14292 int vec_any_le (vector unsigned int, vector unsigned int);
14293 int vec_any_le (vector bool int, vector signed int);
14294 int vec_any_le (vector signed int, vector bool int);
14295 int vec_any_le (vector signed int, vector signed int);
14296 int vec_any_le (vector float, vector float);
14297
14298 int vec_any_lt (vector bool char, vector unsigned char);
14299 int vec_any_lt (vector unsigned char, vector bool char);
14300 int vec_any_lt (vector unsigned char, vector unsigned char);
14301 int vec_any_lt (vector bool char, vector signed char);
14302 int vec_any_lt (vector signed char, vector bool char);
14303 int vec_any_lt (vector signed char, vector signed char);
14304 int vec_any_lt (vector bool short, vector unsigned short);
14305 int vec_any_lt (vector unsigned short, vector bool short);
14306 int vec_any_lt (vector unsigned short, vector unsigned short);
14307 int vec_any_lt (vector bool short, vector signed short);
14308 int vec_any_lt (vector signed short, vector bool short);
14309 int vec_any_lt (vector signed short, vector signed short);
14310 int vec_any_lt (vector bool int, vector unsigned int);
14311 int vec_any_lt (vector unsigned int, vector bool int);
14312 int vec_any_lt (vector unsigned int, vector unsigned int);
14313 int vec_any_lt (vector bool int, vector signed int);
14314 int vec_any_lt (vector signed int, vector bool int);
14315 int vec_any_lt (vector signed int, vector signed int);
14316 int vec_any_lt (vector float, vector float);
14317
14318 int vec_any_nan (vector float);
14319
14320 int vec_any_ne (vector signed char, vector bool char);
14321 int vec_any_ne (vector signed char, vector signed char);
14322 int vec_any_ne (vector unsigned char, vector bool char);
14323 int vec_any_ne (vector unsigned char, vector unsigned char);
14324 int vec_any_ne (vector bool char, vector bool char);
14325 int vec_any_ne (vector bool char, vector unsigned char);
14326 int vec_any_ne (vector bool char, vector signed char);
14327 int vec_any_ne (vector signed short, vector bool short);
14328 int vec_any_ne (vector signed short, vector signed short);
14329 int vec_any_ne (vector unsigned short, vector bool short);
14330 int vec_any_ne (vector unsigned short, vector unsigned short);
14331 int vec_any_ne (vector bool short, vector bool short);
14332 int vec_any_ne (vector bool short, vector unsigned short);
14333 int vec_any_ne (vector bool short, vector signed short);
14334 int vec_any_ne (vector pixel, vector pixel);
14335 int vec_any_ne (vector signed int, vector bool int);
14336 int vec_any_ne (vector signed int, vector signed int);
14337 int vec_any_ne (vector unsigned int, vector bool int);
14338 int vec_any_ne (vector unsigned int, vector unsigned int);
14339 int vec_any_ne (vector bool int, vector bool int);
14340 int vec_any_ne (vector bool int, vector unsigned int);
14341 int vec_any_ne (vector bool int, vector signed int);
14342 int vec_any_ne (vector float, vector float);
14343
14344 int vec_any_nge (vector float, vector float);
14345
14346 int vec_any_ngt (vector float, vector float);
14347
14348 int vec_any_nle (vector float, vector float);
14349
14350 int vec_any_nlt (vector float, vector float);
14351
14352 int vec_any_numeric (vector float);
14353
14354 int vec_any_out (vector float, vector float);
14355 @end smallexample
14356
14357 If the vector/scalar (VSX) instruction set is available, the following
14358 additional functions are available:
14359
14360 @smallexample
14361 vector double vec_abs (vector double);
14362 vector double vec_add (vector double, vector double);
14363 vector double vec_and (vector double, vector double);
14364 vector double vec_and (vector double, vector bool long);
14365 vector double vec_and (vector bool long, vector double);
14366 vector long vec_and (vector long, vector long);
14367 vector long vec_and (vector long, vector bool long);
14368 vector long vec_and (vector bool long, vector long);
14369 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
14370 vector unsigned long vec_and (vector unsigned long, vector bool long);
14371 vector unsigned long vec_and (vector bool long, vector unsigned long);
14372 vector double vec_andc (vector double, vector double);
14373 vector double vec_andc (vector double, vector bool long);
14374 vector double vec_andc (vector bool long, vector double);
14375 vector long vec_andc (vector long, vector long);
14376 vector long vec_andc (vector long, vector bool long);
14377 vector long vec_andc (vector bool long, vector long);
14378 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
14379 vector unsigned long vec_andc (vector unsigned long, vector bool long);
14380 vector unsigned long vec_andc (vector bool long, vector unsigned long);
14381 vector double vec_ceil (vector double);
14382 vector bool long vec_cmpeq (vector double, vector double);
14383 vector bool long vec_cmpge (vector double, vector double);
14384 vector bool long vec_cmpgt (vector double, vector double);
14385 vector bool long vec_cmple (vector double, vector double);
14386 vector bool long vec_cmplt (vector double, vector double);
14387 vector double vec_cpsgn (vector double, vector double);
14388 vector float vec_div (vector float, vector float);
14389 vector double vec_div (vector double, vector double);
14390 vector long vec_div (vector long, vector long);
14391 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
14392 vector double vec_floor (vector double);
14393 vector double vec_ld (int, const vector double *);
14394 vector double vec_ld (int, const double *);
14395 vector double vec_ldl (int, const vector double *);
14396 vector double vec_ldl (int, const double *);
14397 vector unsigned char vec_lvsl (int, const volatile double *);
14398 vector unsigned char vec_lvsr (int, const volatile double *);
14399 vector double vec_madd (vector double, vector double, vector double);
14400 vector double vec_max (vector double, vector double);
14401 vector signed long vec_mergeh (vector signed long, vector signed long);
14402 vector signed long vec_mergeh (vector signed long, vector bool long);
14403 vector signed long vec_mergeh (vector bool long, vector signed long);
14404 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
14405 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
14406 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
14407 vector signed long vec_mergel (vector signed long, vector signed long);
14408 vector signed long vec_mergel (vector signed long, vector bool long);
14409 vector signed long vec_mergel (vector bool long, vector signed long);
14410 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
14411 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
14412 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
14413 vector double vec_min (vector double, vector double);
14414 vector float vec_msub (vector float, vector float, vector float);
14415 vector double vec_msub (vector double, vector double, vector double);
14416 vector float vec_mul (vector float, vector float);
14417 vector double vec_mul (vector double, vector double);
14418 vector long vec_mul (vector long, vector long);
14419 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
14420 vector float vec_nearbyint (vector float);
14421 vector double vec_nearbyint (vector double);
14422 vector float vec_nmadd (vector float, vector float, vector float);
14423 vector double vec_nmadd (vector double, vector double, vector double);
14424 vector double vec_nmsub (vector double, vector double, vector double);
14425 vector double vec_nor (vector double, vector double);
14426 vector long vec_nor (vector long, vector long);
14427 vector long vec_nor (vector long, vector bool long);
14428 vector long vec_nor (vector bool long, vector long);
14429 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
14430 vector unsigned long vec_nor (vector unsigned long, vector bool long);
14431 vector unsigned long vec_nor (vector bool long, vector unsigned long);
14432 vector double vec_or (vector double, vector double);
14433 vector double vec_or (vector double, vector bool long);
14434 vector double vec_or (vector bool long, vector double);
14435 vector long vec_or (vector long, vector long);
14436 vector long vec_or (vector long, vector bool long);
14437 vector long vec_or (vector bool long, vector long);
14438 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
14439 vector unsigned long vec_or (vector unsigned long, vector bool long);
14440 vector unsigned long vec_or (vector bool long, vector unsigned long);
14441 vector double vec_perm (vector double, vector double, vector unsigned char);
14442 vector long vec_perm (vector long, vector long, vector unsigned char);
14443 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
14444                                vector unsigned char);
14445 vector double vec_rint (vector double);
14446 vector double vec_recip (vector double, vector double);
14447 vector double vec_rsqrt (vector double);
14448 vector double vec_rsqrte (vector double);
14449 vector double vec_sel (vector double, vector double, vector bool long);
14450 vector double vec_sel (vector double, vector double, vector unsigned long);
14451 vector long vec_sel (vector long, vector long, vector long);
14452 vector long vec_sel (vector long, vector long, vector unsigned long);
14453 vector long vec_sel (vector long, vector long, vector bool long);
14454 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14455                               vector long);
14456 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14457                               vector unsigned long);
14458 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
14459                               vector bool long);
14460 vector double vec_splats (double);
14461 vector signed long vec_splats (signed long);
14462 vector unsigned long vec_splats (unsigned long);
14463 vector float vec_sqrt (vector float);
14464 vector double vec_sqrt (vector double);
14465 void vec_st (vector double, int, vector double *);
14466 void vec_st (vector double, int, double *);
14467 vector double vec_sub (vector double, vector double);
14468 vector double vec_trunc (vector double);
14469 vector double vec_xor (vector double, vector double);
14470 vector double vec_xor (vector double, vector bool long);
14471 vector double vec_xor (vector bool long, vector double);
14472 vector long vec_xor (vector long, vector long);
14473 vector long vec_xor (vector long, vector bool long);
14474 vector long vec_xor (vector bool long, vector long);
14475 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
14476 vector unsigned long vec_xor (vector unsigned long, vector bool long);
14477 vector unsigned long vec_xor (vector bool long, vector unsigned long);
14478 int vec_all_eq (vector double, vector double);
14479 int vec_all_ge (vector double, vector double);
14480 int vec_all_gt (vector double, vector double);
14481 int vec_all_le (vector double, vector double);
14482 int vec_all_lt (vector double, vector double);
14483 int vec_all_nan (vector double);
14484 int vec_all_ne (vector double, vector double);
14485 int vec_all_nge (vector double, vector double);
14486 int vec_all_ngt (vector double, vector double);
14487 int vec_all_nle (vector double, vector double);
14488 int vec_all_nlt (vector double, vector double);
14489 int vec_all_numeric (vector double);
14490 int vec_any_eq (vector double, vector double);
14491 int vec_any_ge (vector double, vector double);
14492 int vec_any_gt (vector double, vector double);
14493 int vec_any_le (vector double, vector double);
14494 int vec_any_lt (vector double, vector double);
14495 int vec_any_nan (vector double);
14496 int vec_any_ne (vector double, vector double);
14497 int vec_any_nge (vector double, vector double);
14498 int vec_any_ngt (vector double, vector double);
14499 int vec_any_nle (vector double, vector double);
14500 int vec_any_nlt (vector double, vector double);
14501 int vec_any_numeric (vector double);
14502
14503 vector double vec_vsx_ld (int, const vector double *);
14504 vector double vec_vsx_ld (int, const double *);
14505 vector float vec_vsx_ld (int, const vector float *);
14506 vector float vec_vsx_ld (int, const float *);
14507 vector bool int vec_vsx_ld (int, const vector bool int *);
14508 vector signed int vec_vsx_ld (int, const vector signed int *);
14509 vector signed int vec_vsx_ld (int, const int *);
14510 vector signed int vec_vsx_ld (int, const long *);
14511 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
14512 vector unsigned int vec_vsx_ld (int, const unsigned int *);
14513 vector unsigned int vec_vsx_ld (int, const unsigned long *);
14514 vector bool short vec_vsx_ld (int, const vector bool short *);
14515 vector pixel vec_vsx_ld (int, const vector pixel *);
14516 vector signed short vec_vsx_ld (int, const vector signed short *);
14517 vector signed short vec_vsx_ld (int, const short *);
14518 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
14519 vector unsigned short vec_vsx_ld (int, const unsigned short *);
14520 vector bool char vec_vsx_ld (int, const vector bool char *);
14521 vector signed char vec_vsx_ld (int, const vector signed char *);
14522 vector signed char vec_vsx_ld (int, const signed char *);
14523 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
14524 vector unsigned char vec_vsx_ld (int, const unsigned char *);
14525
14526 void vec_vsx_st (vector double, int, vector double *);
14527 void vec_vsx_st (vector double, int, double *);
14528 void vec_vsx_st (vector float, int, vector float *);
14529 void vec_vsx_st (vector float, int, float *);
14530 void vec_vsx_st (vector signed int, int, vector signed int *);
14531 void vec_vsx_st (vector signed int, int, int *);
14532 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
14533 void vec_vsx_st (vector unsigned int, int, unsigned int *);
14534 void vec_vsx_st (vector bool int, int, vector bool int *);
14535 void vec_vsx_st (vector bool int, int, unsigned int *);
14536 void vec_vsx_st (vector bool int, int, int *);
14537 void vec_vsx_st (vector signed short, int, vector signed short *);
14538 void vec_vsx_st (vector signed short, int, short *);
14539 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
14540 void vec_vsx_st (vector unsigned short, int, unsigned short *);
14541 void vec_vsx_st (vector bool short, int, vector bool short *);
14542 void vec_vsx_st (vector bool short, int, unsigned short *);
14543 void vec_vsx_st (vector pixel, int, vector pixel *);
14544 void vec_vsx_st (vector pixel, int, unsigned short *);
14545 void vec_vsx_st (vector pixel, int, short *);
14546 void vec_vsx_st (vector bool short, int, short *);
14547 void vec_vsx_st (vector signed char, int, vector signed char *);
14548 void vec_vsx_st (vector signed char, int, signed char *);
14549 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
14550 void vec_vsx_st (vector unsigned char, int, unsigned char *);
14551 void vec_vsx_st (vector bool char, int, vector bool char *);
14552 void vec_vsx_st (vector bool char, int, unsigned char *);
14553 void vec_vsx_st (vector bool char, int, signed char *);
14554
14555 vector double vec_xxpermdi (vector double, vector double, int);
14556 vector float vec_xxpermdi (vector float, vector float, int);
14557 vector long long vec_xxpermdi (vector long long, vector long long, int);
14558 vector unsigned long long vec_xxpermdi (vector unsigned long long,
14559                                         vector unsigned long long, int);
14560 vector int vec_xxpermdi (vector int, vector int, int);
14561 vector unsigned int vec_xxpermdi (vector unsigned int,
14562                                   vector unsigned int, int);
14563 vector short vec_xxpermdi (vector short, vector short, int);
14564 vector unsigned short vec_xxpermdi (vector unsigned short,
14565                                     vector unsigned short, int);
14566 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
14567 vector unsigned char vec_xxpermdi (vector unsigned char,
14568                                    vector unsigned char, int);
14569
14570 vector double vec_xxsldi (vector double, vector double, int);
14571 vector float vec_xxsldi (vector float, vector float, int);
14572 vector long long vec_xxsldi (vector long long, vector long long, int);
14573 vector unsigned long long vec_xxsldi (vector unsigned long long,
14574                                       vector unsigned long long, int);
14575 vector int vec_xxsldi (vector int, vector int, int);
14576 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
14577 vector short vec_xxsldi (vector short, vector short, int);
14578 vector unsigned short vec_xxsldi (vector unsigned short,
14579                                   vector unsigned short, int);
14580 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
14581 vector unsigned char vec_xxsldi (vector unsigned char,
14582                                  vector unsigned char, int);
14583 @end smallexample
14584
14585 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
14586 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
14587 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
14588 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
14589 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
14590
14591 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14592 instruction set is available, the following additional functions are
14593 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
14594 can use @var{vector long} instead of @var{vector long long},
14595 @var{vector bool long} instead of @var{vector bool long long}, and
14596 @var{vector unsigned long} instead of @var{vector unsigned long long}.
14597
14598 @smallexample
14599 vector long long vec_abs (vector long long);
14600
14601 vector long long vec_add (vector long long, vector long long);
14602 vector unsigned long long vec_add (vector unsigned long long,
14603                                    vector unsigned long long);
14604
14605 int vec_all_eq (vector long long, vector long long);
14606 int vec_all_eq (vector unsigned long long, vector unsigned long long);
14607 int vec_all_ge (vector long long, vector long long);
14608 int vec_all_ge (vector unsigned long long, vector unsigned long long);
14609 int vec_all_gt (vector long long, vector long long);
14610 int vec_all_gt (vector unsigned long long, vector unsigned long long);
14611 int vec_all_le (vector long long, vector long long);
14612 int vec_all_le (vector unsigned long long, vector unsigned long long);
14613 int vec_all_lt (vector long long, vector long long);
14614 int vec_all_lt (vector unsigned long long, vector unsigned long long);
14615 int vec_all_ne (vector long long, vector long long);
14616 int vec_all_ne (vector unsigned long long, vector unsigned long long);
14617
14618 int vec_any_eq (vector long long, vector long long);
14619 int vec_any_eq (vector unsigned long long, vector unsigned long long);
14620 int vec_any_ge (vector long long, vector long long);
14621 int vec_any_ge (vector unsigned long long, vector unsigned long long);
14622 int vec_any_gt (vector long long, vector long long);
14623 int vec_any_gt (vector unsigned long long, vector unsigned long long);
14624 int vec_any_le (vector long long, vector long long);
14625 int vec_any_le (vector unsigned long long, vector unsigned long long);
14626 int vec_any_lt (vector long long, vector long long);
14627 int vec_any_lt (vector unsigned long long, vector unsigned long long);
14628 int vec_any_ne (vector long long, vector long long);
14629 int vec_any_ne (vector unsigned long long, vector unsigned long long);
14630
14631 vector long long vec_eqv (vector long long, vector long long);
14632 vector long long vec_eqv (vector bool long long, vector long long);
14633 vector long long vec_eqv (vector long long, vector bool long long);
14634 vector unsigned long long vec_eqv (vector unsigned long long,
14635                                    vector unsigned long long);
14636 vector unsigned long long vec_eqv (vector bool long long,
14637                                    vector unsigned long long);
14638 vector unsigned long long vec_eqv (vector unsigned long long,
14639                                    vector bool long long);
14640 vector int vec_eqv (vector int, vector int);
14641 vector int vec_eqv (vector bool int, vector int);
14642 vector int vec_eqv (vector int, vector bool int);
14643 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14644 vector unsigned int vec_eqv (vector bool unsigned int,
14645                              vector unsigned int);
14646 vector unsigned int vec_eqv (vector unsigned int,
14647                              vector bool unsigned int);
14648 vector short vec_eqv (vector short, vector short);
14649 vector short vec_eqv (vector bool short, vector short);
14650 vector short vec_eqv (vector short, vector bool short);
14651 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14652 vector unsigned short vec_eqv (vector bool unsigned short,
14653                                vector unsigned short);
14654 vector unsigned short vec_eqv (vector unsigned short,
14655                                vector bool unsigned short);
14656 vector signed char vec_eqv (vector signed char, vector signed char);
14657 vector signed char vec_eqv (vector bool signed char, vector signed char);
14658 vector signed char vec_eqv (vector signed char, vector bool signed char);
14659 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14660 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14661 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14662
14663 vector long long vec_max (vector long long, vector long long);
14664 vector unsigned long long vec_max (vector unsigned long long,
14665                                    vector unsigned long long);
14666
14667 vector signed int vec_mergee (vector signed int, vector signed int);
14668 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
14669 vector bool int vec_mergee (vector bool int, vector bool int);
14670
14671 vector signed int vec_mergeo (vector signed int, vector signed int);
14672 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
14673 vector bool int vec_mergeo (vector bool int, vector bool int);
14674
14675 vector long long vec_min (vector long long, vector long long);
14676 vector unsigned long long vec_min (vector unsigned long long,
14677                                    vector unsigned long long);
14678
14679 vector long long vec_nand (vector long long, vector long long);
14680 vector long long vec_nand (vector bool long long, vector long long);
14681 vector long long vec_nand (vector long long, vector bool long long);
14682 vector unsigned long long vec_nand (vector unsigned long long,
14683                                     vector unsigned long long);
14684 vector unsigned long long vec_nand (vector bool long long,
14685                                    vector unsigned long long);
14686 vector unsigned long long vec_nand (vector unsigned long long,
14687                                     vector bool long long);
14688 vector int vec_nand (vector int, vector int);
14689 vector int vec_nand (vector bool int, vector int);
14690 vector int vec_nand (vector int, vector bool int);
14691 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14692 vector unsigned int vec_nand (vector bool unsigned int,
14693                               vector unsigned int);
14694 vector unsigned int vec_nand (vector unsigned int,
14695                               vector bool unsigned int);
14696 vector short vec_nand (vector short, vector short);
14697 vector short vec_nand (vector bool short, vector short);
14698 vector short vec_nand (vector short, vector bool short);
14699 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14700 vector unsigned short vec_nand (vector bool unsigned short,
14701                                 vector unsigned short);
14702 vector unsigned short vec_nand (vector unsigned short,
14703                                 vector bool unsigned short);
14704 vector signed char vec_nand (vector signed char, vector signed char);
14705 vector signed char vec_nand (vector bool signed char, vector signed char);
14706 vector signed char vec_nand (vector signed char, vector bool signed char);
14707 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14708 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14709 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14710
14711 vector long long vec_orc (vector long long, vector long long);
14712 vector long long vec_orc (vector bool long long, vector long long);
14713 vector long long vec_orc (vector long long, vector bool long long);
14714 vector unsigned long long vec_orc (vector unsigned long long,
14715                                    vector unsigned long long);
14716 vector unsigned long long vec_orc (vector bool long long,
14717                                    vector unsigned long long);
14718 vector unsigned long long vec_orc (vector unsigned long long,
14719                                    vector bool long long);
14720 vector int vec_orc (vector int, vector int);
14721 vector int vec_orc (vector bool int, vector int);
14722 vector int vec_orc (vector int, vector bool int);
14723 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14724 vector unsigned int vec_orc (vector bool unsigned int,
14725                              vector unsigned int);
14726 vector unsigned int vec_orc (vector unsigned int,
14727                              vector bool unsigned int);
14728 vector short vec_orc (vector short, vector short);
14729 vector short vec_orc (vector bool short, vector short);
14730 vector short vec_orc (vector short, vector bool short);
14731 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14732 vector unsigned short vec_orc (vector bool unsigned short,
14733                                vector unsigned short);
14734 vector unsigned short vec_orc (vector unsigned short,
14735                                vector bool unsigned short);
14736 vector signed char vec_orc (vector signed char, vector signed char);
14737 vector signed char vec_orc (vector bool signed char, vector signed char);
14738 vector signed char vec_orc (vector signed char, vector bool signed char);
14739 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14740 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14741 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14742
14743 vector int vec_pack (vector long long, vector long long);
14744 vector unsigned int vec_pack (vector unsigned long long,
14745                               vector unsigned long long);
14746 vector bool int vec_pack (vector bool long long, vector bool long long);
14747
14748 vector int vec_packs (vector long long, vector long long);
14749 vector unsigned int vec_packs (vector unsigned long long,
14750                                vector unsigned long long);
14751
14752 vector unsigned int vec_packsu (vector long long, vector long long);
14753 vector unsigned int vec_packsu (vector unsigned long long,
14754                                 vector unsigned long long);
14755
14756 vector long long vec_rl (vector long long,
14757                          vector unsigned long long);
14758 vector long long vec_rl (vector unsigned long long,
14759                          vector unsigned long long);
14760
14761 vector long long vec_sl (vector long long, vector unsigned long long);
14762 vector long long vec_sl (vector unsigned long long,
14763                          vector unsigned long long);
14764
14765 vector long long vec_sr (vector long long, vector unsigned long long);
14766 vector unsigned long long char vec_sr (vector unsigned long long,
14767                                        vector unsigned long long);
14768
14769 vector long long vec_sra (vector long long, vector unsigned long long);
14770 vector unsigned long long vec_sra (vector unsigned long long,
14771                                    vector unsigned long long);
14772
14773 vector long long vec_sub (vector long long, vector long long);
14774 vector unsigned long long vec_sub (vector unsigned long long,
14775                                    vector unsigned long long);
14776
14777 vector long long vec_unpackh (vector int);
14778 vector unsigned long long vec_unpackh (vector unsigned int);
14779
14780 vector long long vec_unpackl (vector int);
14781 vector unsigned long long vec_unpackl (vector unsigned int);
14782
14783 vector long long vec_vaddudm (vector long long, vector long long);
14784 vector long long vec_vaddudm (vector bool long long, vector long long);
14785 vector long long vec_vaddudm (vector long long, vector bool long long);
14786 vector unsigned long long vec_vaddudm (vector unsigned long long,
14787                                        vector unsigned long long);
14788 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14789                                        vector unsigned long long);
14790 vector unsigned long long vec_vaddudm (vector unsigned long long,
14791                                        vector bool unsigned long long);
14792
14793 vector long long vec_vbpermq (vector signed char, vector signed char);
14794 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
14795
14796 vector long long vec_cntlz (vector long long);
14797 vector unsigned long long vec_cntlz (vector unsigned long long);
14798 vector int vec_cntlz (vector int);
14799 vector unsigned int vec_cntlz (vector int);
14800 vector short vec_cntlz (vector short);
14801 vector unsigned short vec_cntlz (vector unsigned short);
14802 vector signed char vec_cntlz (vector signed char);
14803 vector unsigned char vec_cntlz (vector unsigned char);
14804
14805 vector long long vec_vclz (vector long long);
14806 vector unsigned long long vec_vclz (vector unsigned long long);
14807 vector int vec_vclz (vector int);
14808 vector unsigned int vec_vclz (vector int);
14809 vector short vec_vclz (vector short);
14810 vector unsigned short vec_vclz (vector unsigned short);
14811 vector signed char vec_vclz (vector signed char);
14812 vector unsigned char vec_vclz (vector unsigned char);
14813
14814 vector signed char vec_vclzb (vector signed char);
14815 vector unsigned char vec_vclzb (vector unsigned char);
14816
14817 vector long long vec_vclzd (vector long long);
14818 vector unsigned long long vec_vclzd (vector unsigned long long);
14819
14820 vector short vec_vclzh (vector short);
14821 vector unsigned short vec_vclzh (vector unsigned short);
14822
14823 vector int vec_vclzw (vector int);
14824 vector unsigned int vec_vclzw (vector int);
14825
14826 vector signed char vec_vgbbd (vector signed char);
14827 vector unsigned char vec_vgbbd (vector unsigned char);
14828
14829 vector long long vec_vmaxsd (vector long long, vector long long);
14830
14831 vector unsigned long long vec_vmaxud (vector unsigned long long,
14832                                       unsigned vector long long);
14833
14834 vector long long vec_vminsd (vector long long, vector long long);
14835
14836 vector unsigned long long vec_vminud (vector long long,
14837                                       vector long long);
14838
14839 vector int vec_vpksdss (vector long long, vector long long);
14840 vector unsigned int vec_vpksdss (vector long long, vector long long);
14841
14842 vector unsigned int vec_vpkudus (vector unsigned long long,
14843                                  vector unsigned long long);
14844
14845 vector int vec_vpkudum (vector long long, vector long long);
14846 vector unsigned int vec_vpkudum (vector unsigned long long,
14847                                  vector unsigned long long);
14848 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
14849
14850 vector long long vec_vpopcnt (vector long long);
14851 vector unsigned long long vec_vpopcnt (vector unsigned long long);
14852 vector int vec_vpopcnt (vector int);
14853 vector unsigned int vec_vpopcnt (vector int);
14854 vector short vec_vpopcnt (vector short);
14855 vector unsigned short vec_vpopcnt (vector unsigned short);
14856 vector signed char vec_vpopcnt (vector signed char);
14857 vector unsigned char vec_vpopcnt (vector unsigned char);
14858
14859 vector signed char vec_vpopcntb (vector signed char);
14860 vector unsigned char vec_vpopcntb (vector unsigned char);
14861
14862 vector long long vec_vpopcntd (vector long long);
14863 vector unsigned long long vec_vpopcntd (vector unsigned long long);
14864
14865 vector short vec_vpopcnth (vector short);
14866 vector unsigned short vec_vpopcnth (vector unsigned short);
14867
14868 vector int vec_vpopcntw (vector int);
14869 vector unsigned int vec_vpopcntw (vector int);
14870
14871 vector long long vec_vrld (vector long long, vector unsigned long long);
14872 vector unsigned long long vec_vrld (vector unsigned long long,
14873                                     vector unsigned long long);
14874
14875 vector long long vec_vsld (vector long long, vector unsigned long long);
14876 vector long long vec_vsld (vector unsigned long long,
14877                            vector unsigned long long);
14878
14879 vector long long vec_vsrad (vector long long, vector unsigned long long);
14880 vector unsigned long long vec_vsrad (vector unsigned long long,
14881                                      vector unsigned long long);
14882
14883 vector long long vec_vsrd (vector long long, vector unsigned long long);
14884 vector unsigned long long char vec_vsrd (vector unsigned long long,
14885                                          vector unsigned long long);
14886
14887 vector long long vec_vsubudm (vector long long, vector long long);
14888 vector long long vec_vsubudm (vector bool long long, vector long long);
14889 vector long long vec_vsubudm (vector long long, vector bool long long);
14890 vector unsigned long long vec_vsubudm (vector unsigned long long,
14891                                        vector unsigned long long);
14892 vector unsigned long long vec_vsubudm (vector bool long long,
14893                                        vector unsigned long long);
14894 vector unsigned long long vec_vsubudm (vector unsigned long long,
14895                                        vector bool long long);
14896
14897 vector long long vec_vupkhsw (vector int);
14898 vector unsigned long long vec_vupkhsw (vector unsigned int);
14899
14900 vector long long vec_vupklsw (vector int);
14901 vector unsigned long long vec_vupklsw (vector int);
14902 @end smallexample
14903
14904 If the ISA 2.07 additions to the vector/scalar (power8-vector)
14905 instruction set is available, the following additional functions are
14906 available for 64-bit targets.  New vector types
14907 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
14908 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
14909 builtins.
14910
14911 The normal vector extract, and set operations work on
14912 @var{vector __int128_t} and @var{vector __uint128_t} types,
14913 but the index value must be 0.
14914
14915 @smallexample
14916 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
14917 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
14918
14919 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
14920 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
14921
14922 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
14923                                 vector __int128_t);
14924 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t, 
14925                                  vector __uint128_t);
14926
14927 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
14928                                 vector __int128_t);
14929 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t, 
14930                                  vector __uint128_t);
14931
14932 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
14933                                 vector __int128_t);
14934 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t, 
14935                                  vector __uint128_t);
14936
14937 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
14938                                 vector __int128_t);
14939 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
14940                                  vector __uint128_t);
14941
14942 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
14943 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
14944
14945 __int128_t vec_vsubuqm (__int128_t, __int128_t);
14946 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
14947
14948 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
14949 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
14950 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
14951 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
14952 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
14953 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
14954 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
14955 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
14956 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
14957 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
14958 @end smallexample
14959
14960 If the cryptographic instructions are enabled (@option{-mcrypto} or
14961 @option{-mcpu=power8}), the following builtins are enabled.
14962
14963 @smallexample
14964 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
14965
14966 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
14967                                                     vector unsigned long long);
14968
14969 vector unsigned long long __builtin_crypto_vcipherlast
14970                                      (vector unsigned long long,
14971                                       vector unsigned long long);
14972
14973 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
14974                                                      vector unsigned long long);
14975
14976 vector unsigned long long __builtin_crypto_vncipherlast
14977                                      (vector unsigned long long,
14978                                       vector unsigned long long);
14979
14980 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
14981                                                 vector unsigned char,
14982                                                 vector unsigned char);
14983
14984 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
14985                                                  vector unsigned short,
14986                                                  vector unsigned short);
14987
14988 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
14989                                                vector unsigned int,
14990                                                vector unsigned int);
14991
14992 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
14993                                                      vector unsigned long long,
14994                                                      vector unsigned long long);
14995
14996 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
14997                                                vector unsigned char);
14998
14999 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
15000                                                 vector unsigned short);
15001
15002 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
15003                                               vector unsigned int);
15004
15005 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
15006                                                     vector unsigned long long);
15007
15008 vector unsigned long long __builtin_crypto_vshasigmad
15009                                (vector unsigned long long, int, int);
15010
15011 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
15012                                                  int, int);
15013 @end smallexample
15014
15015 The second argument to the @var{__builtin_crypto_vshasigmad} and
15016 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
15017 integer that is 0 or 1.  The third argument to these builtin functions
15018 must be a constant integer in the range of 0 to 15.
15019
15020 @node PowerPC Hardware Transactional Memory Built-in Functions
15021 @subsection PowerPC Hardware Transactional Memory Built-in Functions
15022 GCC provides two interfaces for accessing the Hardware Transactional
15023 Memory (HTM) instructions available on some of the PowerPC family
15024 of prcoessors (eg, POWER8).  The two interfaces come in a low level
15025 interface, consisting of built-in functions specific to PowerPC and a
15026 higher level interface consisting of inline functions that are common
15027 between PowerPC and S/390.
15028
15029 @subsubsection PowerPC HTM Low Level Built-in Functions
15030
15031 The following low level built-in functions are available with
15032 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
15033 They all generate the machine instruction that is part of the name.
15034
15035 The HTM built-ins return true or false depending on their success and
15036 their arguments match exactly the type and order of the associated
15037 hardware instruction's operands.  Refer to the ISA manual for a
15038 description of each instruction's operands.
15039
15040 @smallexample
15041 unsigned int __builtin_tbegin (unsigned int)
15042 unsigned int __builtin_tend (unsigned int)
15043
15044 unsigned int __builtin_tabort (unsigned int)
15045 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
15046 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
15047 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
15048 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
15049
15050 unsigned int __builtin_tcheck (unsigned int)
15051 unsigned int __builtin_treclaim (unsigned int)
15052 unsigned int __builtin_trechkpt (void)
15053 unsigned int __builtin_tsr (unsigned int)
15054 @end smallexample
15055
15056 In addition to the above HTM built-ins, we have added built-ins for
15057 some common extended mnemonics of the HTM instructions:
15058
15059 @smallexample
15060 unsigned int __builtin_tendall (void)
15061 unsigned int __builtin_tresume (void)
15062 unsigned int __builtin_tsuspend (void)
15063 @end smallexample
15064
15065 The following set of built-in functions are available to gain access
15066 to the HTM specific special purpose registers.
15067
15068 @smallexample
15069 unsigned long __builtin_get_texasr (void)
15070 unsigned long __builtin_get_texasru (void)
15071 unsigned long __builtin_get_tfhar (void)
15072 unsigned long __builtin_get_tfiar (void)
15073
15074 void __builtin_set_texasr (unsigned long);
15075 void __builtin_set_texasru (unsigned long);
15076 void __builtin_set_tfhar (unsigned long);
15077 void __builtin_set_tfiar (unsigned long);
15078 @end smallexample
15079
15080 Example usage of these low level built-in functions may look like:
15081
15082 @smallexample
15083 #include <htmintrin.h>
15084
15085 int num_retries = 10;
15086
15087 while (1)
15088   @{
15089     if (__builtin_tbegin (0))
15090       @{
15091         /* Transaction State Initiated.  */
15092         if (is_locked (lock))
15093           __builtin_tabort (0);
15094         ... transaction code...
15095         __builtin_tend (0);
15096         break;
15097       @}
15098     else
15099       @{
15100         /* Transaction State Failed.  Use locks if the transaction
15101            failure is "persistent" or we've tried too many times.  */
15102         if (num_retries-- <= 0
15103             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
15104           @{
15105             acquire_lock (lock);
15106             ... non transactional fallback path...
15107             release_lock (lock);
15108             break;
15109           @}
15110       @}
15111   @}
15112 @end smallexample
15113
15114 One final built-in function has been added that returns the value of
15115 the 2-bit Transaction State field of the Machine Status Register (MSR)
15116 as stored in @code{CR0}.
15117
15118 @smallexample
15119 unsigned long __builtin_ttest (void)
15120 @end smallexample
15121
15122 This built-in can be used to determine the current transaction state
15123 using the following code example:
15124
15125 @smallexample
15126 #include <htmintrin.h>
15127
15128 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
15129
15130 if (tx_state == _HTM_TRANSACTIONAL)
15131   @{
15132     /* Code to use in transactional state.  */
15133   @}
15134 else if (tx_state == _HTM_NONTRANSACTIONAL)
15135   @{
15136     /* Code to use in non-transactional state.  */
15137   @}
15138 else if (tx_state == _HTM_SUSPENDED)
15139   @{
15140     /* Code to use in transaction suspended state.  */
15141   @}
15142 @end smallexample
15143
15144 @subsubsection PowerPC HTM High Level Inline Functions
15145
15146 The following high level HTM interface is made available by including
15147 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
15148 where CPU is `power8' or later.  This interface is common between PowerPC
15149 and S/390, allowing users to write one HTM source implementation that
15150 can be compiled and executed on either system.
15151
15152 @smallexample
15153 long __TM_simple_begin (void)
15154 long __TM_begin (void* const TM_buff)
15155 long __TM_end (void)
15156 void __TM_abort (void)
15157 void __TM_named_abort (unsigned char const code)
15158 void __TM_resume (void)
15159 void __TM_suspend (void)
15160
15161 long __TM_is_user_abort (void* const TM_buff)
15162 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
15163 long __TM_is_illegal (void* const TM_buff)
15164 long __TM_is_footprint_exceeded (void* const TM_buff)
15165 long __TM_nesting_depth (void* const TM_buff)
15166 long __TM_is_nested_too_deep(void* const TM_buff)
15167 long __TM_is_conflict(void* const TM_buff)
15168 long __TM_is_failure_persistent(void* const TM_buff)
15169 long __TM_failure_address(void* const TM_buff)
15170 long long __TM_failure_code(void* const TM_buff)
15171 @end smallexample
15172
15173 Using these common set of HTM inline functions, we can create
15174 a more portable version of the HTM example in the previous
15175 section that will work on either PowerPC or S/390:
15176
15177 @smallexample
15178 #include <htmxlintrin.h>
15179
15180 int num_retries = 10;
15181 TM_buff_type TM_buff;
15182
15183 while (1)
15184   @{
15185     if (__TM_begin (TM_buff))
15186       @{
15187         /* Transaction State Initiated.  */
15188         if (is_locked (lock))
15189           __TM_abort ();
15190         ... transaction code...
15191         __TM_end ();
15192         break;
15193       @}
15194     else
15195       @{
15196         /* Transaction State Failed.  Use locks if the transaction
15197            failure is "persistent" or we've tried too many times.  */
15198         if (num_retries-- <= 0
15199             || __TM_is_failure_persistent (TM_buff))
15200           @{
15201             acquire_lock (lock);
15202             ... non transactional fallback path...
15203             release_lock (lock);
15204             break;
15205           @}
15206       @}
15207   @}
15208 @end smallexample
15209
15210 @node RX Built-in Functions
15211 @subsection RX Built-in Functions
15212 GCC supports some of the RX instructions which cannot be expressed in
15213 the C programming language via the use of built-in functions.  The
15214 following functions are supported:
15215
15216 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
15217 Generates the @code{brk} machine instruction.
15218 @end deftypefn
15219
15220 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
15221 Generates the @code{clrpsw} machine instruction to clear the specified
15222 bit in the processor status word.
15223 @end deftypefn
15224
15225 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
15226 Generates the @code{int} machine instruction to generate an interrupt
15227 with the specified value.
15228 @end deftypefn
15229
15230 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
15231 Generates the @code{machi} machine instruction to add the result of
15232 multiplying the top 16 bits of the two arguments into the
15233 accumulator.
15234 @end deftypefn
15235
15236 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
15237 Generates the @code{maclo} machine instruction to add the result of
15238 multiplying the bottom 16 bits of the two arguments into the
15239 accumulator.
15240 @end deftypefn
15241
15242 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
15243 Generates the @code{mulhi} machine instruction to place the result of
15244 multiplying the top 16 bits of the two arguments into the
15245 accumulator.
15246 @end deftypefn
15247
15248 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
15249 Generates the @code{mullo} machine instruction to place the result of
15250 multiplying the bottom 16 bits of the two arguments into the
15251 accumulator.
15252 @end deftypefn
15253
15254 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
15255 Generates the @code{mvfachi} machine instruction to read the top
15256 32 bits of the accumulator.
15257 @end deftypefn
15258
15259 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
15260 Generates the @code{mvfacmi} machine instruction to read the middle
15261 32 bits of the accumulator.
15262 @end deftypefn
15263
15264 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
15265 Generates the @code{mvfc} machine instruction which reads the control
15266 register specified in its argument and returns its value.
15267 @end deftypefn
15268
15269 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
15270 Generates the @code{mvtachi} machine instruction to set the top
15271 32 bits of the accumulator.
15272 @end deftypefn
15273
15274 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
15275 Generates the @code{mvtaclo} machine instruction to set the bottom
15276 32 bits of the accumulator.
15277 @end deftypefn
15278
15279 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
15280 Generates the @code{mvtc} machine instruction which sets control
15281 register number @code{reg} to @code{val}.
15282 @end deftypefn
15283
15284 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
15285 Generates the @code{mvtipl} machine instruction set the interrupt
15286 priority level.
15287 @end deftypefn
15288
15289 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
15290 Generates the @code{racw} machine instruction to round the accumulator
15291 according to the specified mode.
15292 @end deftypefn
15293
15294 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
15295 Generates the @code{revw} machine instruction which swaps the bytes in
15296 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
15297 and also bits 16--23 occupy bits 24--31 and vice versa.
15298 @end deftypefn
15299
15300 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
15301 Generates the @code{rmpa} machine instruction which initiates a
15302 repeated multiply and accumulate sequence.
15303 @end deftypefn
15304
15305 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
15306 Generates the @code{round} machine instruction which returns the
15307 floating-point argument rounded according to the current rounding mode
15308 set in the floating-point status word register.
15309 @end deftypefn
15310
15311 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
15312 Generates the @code{sat} machine instruction which returns the
15313 saturated value of the argument.
15314 @end deftypefn
15315
15316 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
15317 Generates the @code{setpsw} machine instruction to set the specified
15318 bit in the processor status word.
15319 @end deftypefn
15320
15321 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
15322 Generates the @code{wait} machine instruction.
15323 @end deftypefn
15324
15325 @node S/390 System z Built-in Functions
15326 @subsection S/390 System z Built-in Functions
15327 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
15328 Generates the @code{tbegin} machine instruction starting a
15329 non-constraint hardware transaction.  If the parameter is non-NULL the
15330 memory area is used to store the transaction diagnostic buffer and
15331 will be passed as first operand to @code{tbegin}.  This buffer can be
15332 defined using the @code{struct __htm_tdb} C struct defined in
15333 @code{htmintrin.h} and must reside on a double-word boundary.  The
15334 second tbegin operand is set to @code{0xff0c}. This enables
15335 save/restore of all GPRs and disables aborts for FPR and AR
15336 manipulations inside the transaction body.  The condition code set by
15337 the tbegin instruction is returned as integer value.  The tbegin
15338 instruction by definition overwrites the content of all FPRs.  The
15339 compiler will generate code which saves and restores the FPRs.  For
15340 soft-float code it is recommended to used the @code{*_nofloat}
15341 variant.  In order to prevent a TDB from being written it is required
15342 to pass an constant zero value as parameter.  Passing the zero value
15343 through a variable is not sufficient.  Although modifications of
15344 access registers inside the transaction will not trigger an
15345 transaction abort it is not supported to actually modify them.  Access
15346 registers do not get saved when entering a transaction. They will have
15347 undefined state when reaching the abort code.
15348 @end deftypefn
15349
15350 Macros for the possible return codes of tbegin are defined in the
15351 @code{htmintrin.h} header file:
15352
15353 @table @code
15354 @item _HTM_TBEGIN_STARTED
15355 @code{tbegin} has been executed as part of normal processing.  The
15356 transaction body is supposed to be executed.
15357 @item _HTM_TBEGIN_INDETERMINATE
15358 The transaction was aborted due to an indeterminate condition which
15359 might be persistent.
15360 @item _HTM_TBEGIN_TRANSIENT
15361 The transaction aborted due to a transient failure.  The transaction
15362 should be re-executed in that case.
15363 @item _HTM_TBEGIN_PERSISTENT
15364 The transaction aborted due to a persistent failure.  Re-execution
15365 under same circumstances will not be productive.
15366 @end table
15367
15368 @defmac _HTM_FIRST_USER_ABORT_CODE
15369 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
15370 specifies the first abort code which can be used for
15371 @code{__builtin_tabort}.  Values below this threshold are reserved for
15372 machine use.
15373 @end defmac
15374
15375 @deftp {Data type} {struct __htm_tdb}
15376 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
15377 the structure of the transaction diagnostic block as specified in the
15378 Principles of Operation manual chapter 5-91.
15379 @end deftp
15380
15381 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
15382 Same as @code{__builtin_tbegin} but without FPR saves and restores.
15383 Using this variant in code making use of FPRs will leave the FPRs in
15384 undefined state when entering the transaction abort handler code.
15385 @end deftypefn
15386
15387 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
15388 In addition to @code{__builtin_tbegin} a loop for transient failures
15389 is generated.  If tbegin returns a condition code of 2 the transaction
15390 will be retried as often as specified in the second argument.  The
15391 perform processor assist instruction is used to tell the CPU about the
15392 number of fails so far.
15393 @end deftypefn
15394
15395 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
15396 Same as @code{__builtin_tbegin_retry} but without FPR saves and
15397 restores.  Using this variant in code making use of FPRs will leave
15398 the FPRs in undefined state when entering the transaction abort
15399 handler code.
15400 @end deftypefn
15401
15402 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
15403 Generates the @code{tbeginc} machine instruction starting a constraint
15404 hardware transaction.  The second operand is set to @code{0xff08}.
15405 @end deftypefn
15406
15407 @deftypefn {Built-in Function} int __builtin_tend (void)
15408 Generates the @code{tend} machine instruction finishing a transaction
15409 and making the changes visible to other threads.  The condition code
15410 generated by tend is returned as integer value.
15411 @end deftypefn
15412
15413 @deftypefn {Built-in Function} void __builtin_tabort (int)
15414 Generates the @code{tabort} machine instruction with the specified
15415 abort code.  Abort codes from 0 through 255 are reserved and will
15416 result in an error message.
15417 @end deftypefn
15418
15419 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
15420 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
15421 integer parameter is loaded into rX and a value of zero is loaded into
15422 rY.  The integer parameter specifies the number of times the
15423 transaction repeatedly aborted.
15424 @end deftypefn
15425
15426 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
15427 Generates the @code{etnd} machine instruction.  The current nesting
15428 depth is returned as integer value.  For a nesting depth of 0 the code
15429 is not executed as part of an transaction.
15430 @end deftypefn
15431
15432 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
15433
15434 Generates the @code{ntstg} machine instruction.  The second argument
15435 is written to the first arguments location.  The store operation will
15436 not be rolled-back in case of an transaction abort.
15437 @end deftypefn
15438
15439 @node SH Built-in Functions
15440 @subsection SH Built-in Functions
15441 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
15442 families of processors:
15443
15444 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
15445 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
15446 used by system code that manages threads and execution contexts.  The compiler
15447 normally does not generate code that modifies the contents of @samp{GBR} and
15448 thus the value is preserved across function calls.  Changing the @samp{GBR}
15449 value in user code must be done with caution, since the compiler might use
15450 @samp{GBR} in order to access thread local variables.
15451
15452 @end deftypefn
15453
15454 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
15455 Returns the value that is currently set in the @samp{GBR} register.
15456 Memory loads and stores that use the thread pointer as a base address are
15457 turned into @samp{GBR} based displacement loads and stores, if possible.
15458 For example:
15459 @smallexample
15460 struct my_tcb
15461 @{
15462    int a, b, c, d, e;
15463 @};
15464
15465 int get_tcb_value (void)
15466 @{
15467   // Generate @samp{mov.l @@(8,gbr),r0} instruction
15468   return ((my_tcb*)__builtin_thread_pointer ())->c;
15469 @}
15470
15471 @end smallexample
15472 @end deftypefn
15473
15474 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
15475 Returns the value that is currently set in the @samp{FPSCR} register.
15476 @end deftypefn
15477
15478 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
15479 Sets the @samp{FPSCR} register to the specified value @var{val}, while
15480 preserving the current values of the FR, SZ and PR bits.
15481 @end deftypefn
15482
15483 @node SPARC VIS Built-in Functions
15484 @subsection SPARC VIS Built-in Functions
15485
15486 GCC supports SIMD operations on the SPARC using both the generic vector
15487 extensions (@pxref{Vector Extensions}) as well as built-in functions for
15488 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
15489 switch, the VIS extension is exposed as the following built-in functions:
15490
15491 @smallexample
15492 typedef int v1si __attribute__ ((vector_size (4)));
15493 typedef int v2si __attribute__ ((vector_size (8)));
15494 typedef short v4hi __attribute__ ((vector_size (8)));
15495 typedef short v2hi __attribute__ ((vector_size (4)));
15496 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
15497 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
15498
15499 void __builtin_vis_write_gsr (int64_t);
15500 int64_t __builtin_vis_read_gsr (void);
15501
15502 void * __builtin_vis_alignaddr (void *, long);
15503 void * __builtin_vis_alignaddrl (void *, long);
15504 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
15505 v2si __builtin_vis_faligndatav2si (v2si, v2si);
15506 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
15507 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
15508
15509 v4hi __builtin_vis_fexpand (v4qi);
15510
15511 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
15512 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
15513 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
15514 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
15515 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
15516 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
15517 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
15518
15519 v4qi __builtin_vis_fpack16 (v4hi);
15520 v8qi __builtin_vis_fpack32 (v2si, v8qi);
15521 v2hi __builtin_vis_fpackfix (v2si);
15522 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
15523
15524 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
15525
15526 long __builtin_vis_edge8 (void *, void *);
15527 long __builtin_vis_edge8l (void *, void *);
15528 long __builtin_vis_edge16 (void *, void *);
15529 long __builtin_vis_edge16l (void *, void *);
15530 long __builtin_vis_edge32 (void *, void *);
15531 long __builtin_vis_edge32l (void *, void *);
15532
15533 long __builtin_vis_fcmple16 (v4hi, v4hi);
15534 long __builtin_vis_fcmple32 (v2si, v2si);
15535 long __builtin_vis_fcmpne16 (v4hi, v4hi);
15536 long __builtin_vis_fcmpne32 (v2si, v2si);
15537 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
15538 long __builtin_vis_fcmpgt32 (v2si, v2si);
15539 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
15540 long __builtin_vis_fcmpeq32 (v2si, v2si);
15541
15542 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
15543 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
15544 v2si __builtin_vis_fpadd32 (v2si, v2si);
15545 v1si __builtin_vis_fpadd32s (v1si, v1si);
15546 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
15547 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
15548 v2si __builtin_vis_fpsub32 (v2si, v2si);
15549 v1si __builtin_vis_fpsub32s (v1si, v1si);
15550
15551 long __builtin_vis_array8 (long, long);
15552 long __builtin_vis_array16 (long, long);
15553 long __builtin_vis_array32 (long, long);
15554 @end smallexample
15555
15556 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
15557 functions also become available:
15558
15559 @smallexample
15560 long __builtin_vis_bmask (long, long);
15561 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
15562 v2si __builtin_vis_bshufflev2si (v2si, v2si);
15563 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
15564 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
15565
15566 long __builtin_vis_edge8n (void *, void *);
15567 long __builtin_vis_edge8ln (void *, void *);
15568 long __builtin_vis_edge16n (void *, void *);
15569 long __builtin_vis_edge16ln (void *, void *);
15570 long __builtin_vis_edge32n (void *, void *);
15571 long __builtin_vis_edge32ln (void *, void *);
15572 @end smallexample
15573
15574 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
15575 functions also become available:
15576
15577 @smallexample
15578 void __builtin_vis_cmask8 (long);
15579 void __builtin_vis_cmask16 (long);
15580 void __builtin_vis_cmask32 (long);
15581
15582 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
15583
15584 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
15585 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
15586 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
15587 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
15588 v2si __builtin_vis_fsll16 (v2si, v2si);
15589 v2si __builtin_vis_fslas16 (v2si, v2si);
15590 v2si __builtin_vis_fsrl16 (v2si, v2si);
15591 v2si __builtin_vis_fsra16 (v2si, v2si);
15592
15593 long __builtin_vis_pdistn (v8qi, v8qi);
15594
15595 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
15596
15597 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
15598 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
15599
15600 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
15601 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
15602 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
15603 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
15604 v2si __builtin_vis_fpadds32 (v2si, v2si);
15605 v1si __builtin_vis_fpadds32s (v1si, v1si);
15606 v2si __builtin_vis_fpsubs32 (v2si, v2si);
15607 v1si __builtin_vis_fpsubs32s (v1si, v1si);
15608
15609 long __builtin_vis_fucmple8 (v8qi, v8qi);
15610 long __builtin_vis_fucmpne8 (v8qi, v8qi);
15611 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
15612 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
15613
15614 float __builtin_vis_fhadds (float, float);
15615 double __builtin_vis_fhaddd (double, double);
15616 float __builtin_vis_fhsubs (float, float);
15617 double __builtin_vis_fhsubd (double, double);
15618 float __builtin_vis_fnhadds (float, float);
15619 double __builtin_vis_fnhaddd (double, double);
15620
15621 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
15622 int64_t __builtin_vis_xmulx (int64_t, int64_t);
15623 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
15624 @end smallexample
15625
15626 @node SPU Built-in Functions
15627 @subsection SPU Built-in Functions
15628
15629 GCC provides extensions for the SPU processor as described in the
15630 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
15631 found at @uref{http://cell.scei.co.jp/} or
15632 @uref{http://www.ibm.com/developerworks/power/cell/}.  GCC's
15633 implementation differs in several ways.
15634
15635 @itemize @bullet
15636
15637 @item
15638 The optional extension of specifying vector constants in parentheses is
15639 not supported.
15640
15641 @item
15642 A vector initializer requires no cast if the vector constant is of the
15643 same type as the variable it is initializing.
15644
15645 @item
15646 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15647 vector type is the default signedness of the base type.  The default
15648 varies depending on the operating system, so a portable program should
15649 always specify the signedness.
15650
15651 @item
15652 By default, the keyword @code{__vector} is added. The macro
15653 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
15654 undefined.
15655
15656 @item
15657 GCC allows using a @code{typedef} name as the type specifier for a
15658 vector type.
15659
15660 @item
15661 For C, overloaded functions are implemented with macros so the following
15662 does not work:
15663
15664 @smallexample
15665   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15666 @end smallexample
15667
15668 @noindent
15669 Since @code{spu_add} is a macro, the vector constant in the example
15670 is treated as four separate arguments.  Wrap the entire argument in
15671 parentheses for this to work.
15672
15673 @item
15674 The extended version of @code{__builtin_expect} is not supported.
15675
15676 @end itemize
15677
15678 @emph{Note:} Only the interface described in the aforementioned
15679 specification is supported. Internally, GCC uses built-in functions to
15680 implement the required functionality, but these are not supported and
15681 are subject to change without notice.
15682
15683 @node TI C6X Built-in Functions
15684 @subsection TI C6X Built-in Functions
15685
15686 GCC provides intrinsics to access certain instructions of the TI C6X
15687 processors.  These intrinsics, listed below, are available after
15688 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
15689 to C6X instructions.
15690
15691 @smallexample
15692
15693 int _sadd (int, int)
15694 int _ssub (int, int)
15695 int _sadd2 (int, int)
15696 int _ssub2 (int, int)
15697 long long _mpy2 (int, int)
15698 long long _smpy2 (int, int)
15699 int _add4 (int, int)
15700 int _sub4 (int, int)
15701 int _saddu4 (int, int)
15702
15703 int _smpy (int, int)
15704 int _smpyh (int, int)
15705 int _smpyhl (int, int)
15706 int _smpylh (int, int)
15707
15708 int _sshl (int, int)
15709 int _subc (int, int)
15710
15711 int _avg2 (int, int)
15712 int _avgu4 (int, int)
15713
15714 int _clrr (int, int)
15715 int _extr (int, int)
15716 int _extru (int, int)
15717 int _abs (int)
15718 int _abs2 (int)
15719
15720 @end smallexample
15721
15722 @node TILE-Gx Built-in Functions
15723 @subsection TILE-Gx Built-in Functions
15724
15725 GCC provides intrinsics to access every instruction of the TILE-Gx
15726 processor.  The intrinsics are of the form:
15727
15728 @smallexample
15729
15730 unsigned long long __insn_@var{op} (...)
15731
15732 @end smallexample
15733
15734 Where @var{op} is the name of the instruction.  Refer to the ISA manual
15735 for the complete list of instructions.
15736
15737 GCC also provides intrinsics to directly access the network registers.
15738 The intrinsics are:
15739
15740 @smallexample
15741
15742 unsigned long long __tile_idn0_receive (void)
15743 unsigned long long __tile_idn1_receive (void)
15744 unsigned long long __tile_udn0_receive (void)
15745 unsigned long long __tile_udn1_receive (void)
15746 unsigned long long __tile_udn2_receive (void)
15747 unsigned long long __tile_udn3_receive (void)
15748 void __tile_idn_send (unsigned long long)
15749 void __tile_udn_send (unsigned long long)
15750
15751 @end smallexample
15752
15753 The intrinsic @code{void __tile_network_barrier (void)} is used to
15754 guarantee that no network operations before it are reordered with
15755 those after it.
15756
15757 @node TILEPro Built-in Functions
15758 @subsection TILEPro Built-in Functions
15759
15760 GCC provides intrinsics to access every instruction of the TILEPro
15761 processor.  The intrinsics are of the form:
15762
15763 @smallexample
15764
15765 unsigned __insn_@var{op} (...)
15766
15767 @end smallexample
15768
15769 @noindent
15770 where @var{op} is the name of the instruction.  Refer to the ISA manual
15771 for the complete list of instructions.
15772
15773 GCC also provides intrinsics to directly access the network registers.
15774 The intrinsics are:
15775
15776 @smallexample
15777
15778 unsigned __tile_idn0_receive (void)
15779 unsigned __tile_idn1_receive (void)
15780 unsigned __tile_sn_receive (void)
15781 unsigned __tile_udn0_receive (void)
15782 unsigned __tile_udn1_receive (void)
15783 unsigned __tile_udn2_receive (void)
15784 unsigned __tile_udn3_receive (void)
15785 void __tile_idn_send (unsigned)
15786 void __tile_sn_send (unsigned)
15787 void __tile_udn_send (unsigned)
15788
15789 @end smallexample
15790
15791 The intrinsic @code{void __tile_network_barrier (void)} is used to
15792 guarantee that no network operations before it are reordered with
15793 those after it.
15794
15795 @node x86 Built-in Functions
15796 @subsection x86 Built-in Functions
15797
15798 These built-in functions are available for the x86-32 and x86-64 family
15799 of computers, depending on the command-line switches used.
15800
15801 If you specify command-line switches such as @option{-msse},
15802 the compiler could use the extended instruction sets even if the built-ins
15803 are not used explicitly in the program.  For this reason, applications
15804 that perform run-time CPU detection must compile separate files for each
15805 supported architecture, using the appropriate flags.  In particular,
15806 the file containing the CPU detection code should be compiled without
15807 these options.
15808
15809 The following machine modes are available for use with MMX built-in functions
15810 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
15811 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
15812 vector of eight 8-bit integers.  Some of the built-in functions operate on
15813 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
15814
15815 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
15816 of two 32-bit floating-point values.
15817
15818 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
15819 floating-point values.  Some instructions use a vector of four 32-bit
15820 integers, these use @code{V4SI}.  Finally, some instructions operate on an
15821 entire vector register, interpreting it as a 128-bit integer, these use mode
15822 @code{TI}.
15823
15824 In 64-bit mode, the x86-64 family of processors uses additional built-in
15825 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
15826 floating point and @code{TC} 128-bit complex floating-point values.
15827
15828 The following floating-point built-in functions are available in 64-bit
15829 mode.  All of them implement the function that is part of the name.
15830
15831 @smallexample
15832 __float128 __builtin_fabsq (__float128)
15833 __float128 __builtin_copysignq (__float128, __float128)
15834 @end smallexample
15835
15836 The following built-in function is always available.
15837
15838 @table @code
15839 @item void __builtin_ia32_pause (void)
15840 Generates the @code{pause} machine instruction with a compiler memory
15841 barrier.
15842 @end table
15843
15844 The following floating-point built-in functions are made available in the
15845 64-bit mode.
15846
15847 @table @code
15848 @item __float128 __builtin_infq (void)
15849 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
15850 @findex __builtin_infq
15851
15852 @item __float128 __builtin_huge_valq (void)
15853 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
15854 @findex __builtin_huge_valq
15855 @end table
15856
15857 The following built-in functions are always available and can be used to
15858 check the target platform type.
15859
15860 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15861 This function runs the CPU detection code to check the type of CPU and the
15862 features supported.  This built-in function needs to be invoked along with the built-in functions
15863 to check CPU type and features, @code{__builtin_cpu_is} and
15864 @code{__builtin_cpu_supports}, only when used in a function that is
15865 executed before any constructors are called.  The CPU detection code is
15866 automatically executed in a very high priority constructor.
15867
15868 For example, this function has to be used in @code{ifunc} resolvers that
15869 check for CPU type using the built-in functions @code{__builtin_cpu_is}
15870 and @code{__builtin_cpu_supports}, or in constructors on targets that
15871 don't support constructor priority.
15872 @smallexample
15873
15874 static void (*resolve_memcpy (void)) (void)
15875 @{
15876   // ifunc resolvers fire before constructors, explicitly call the init
15877   // function.
15878   __builtin_cpu_init ();
15879   if (__builtin_cpu_supports ("ssse3"))
15880     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
15881   else
15882     return default_memcpy;
15883 @}
15884
15885 void *memcpy (void *, const void *, size_t)
15886      __attribute__ ((ifunc ("resolve_memcpy")));
15887 @end smallexample
15888
15889 @end deftypefn
15890
15891 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15892 This function returns a positive integer if the run-time CPU
15893 is of type @var{cpuname}
15894 and returns @code{0} otherwise. The following CPU names can be detected:
15895
15896 @table @samp
15897 @item intel
15898 Intel CPU.
15899
15900 @item atom
15901 Intel Atom CPU.
15902
15903 @item core2
15904 Intel Core 2 CPU.
15905
15906 @item corei7
15907 Intel Core i7 CPU.
15908
15909 @item nehalem
15910 Intel Core i7 Nehalem CPU.
15911
15912 @item westmere
15913 Intel Core i7 Westmere CPU.
15914
15915 @item sandybridge
15916 Intel Core i7 Sandy Bridge CPU.
15917
15918 @item amd
15919 AMD CPU.
15920
15921 @item amdfam10h
15922 AMD Family 10h CPU.
15923
15924 @item barcelona
15925 AMD Family 10h Barcelona CPU.
15926
15927 @item shanghai
15928 AMD Family 10h Shanghai CPU.
15929
15930 @item istanbul
15931 AMD Family 10h Istanbul CPU.
15932
15933 @item btver1
15934 AMD Family 14h CPU.
15935
15936 @item amdfam15h
15937 AMD Family 15h CPU.
15938
15939 @item bdver1
15940 AMD Family 15h Bulldozer version 1.
15941
15942 @item bdver2
15943 AMD Family 15h Bulldozer version 2.
15944
15945 @item bdver3
15946 AMD Family 15h Bulldozer version 3.
15947
15948 @item bdver4
15949 AMD Family 15h Bulldozer version 4.
15950
15951 @item btver2
15952 AMD Family 16h CPU.
15953 @end table
15954
15955 Here is an example:
15956 @smallexample
15957 if (__builtin_cpu_is ("corei7"))
15958   @{
15959      do_corei7 (); // Core i7 specific implementation.
15960   @}
15961 else
15962   @{
15963      do_generic (); // Generic implementation.
15964   @}
15965 @end smallexample
15966 @end deftypefn
15967
15968 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15969 This function returns a positive integer if the run-time CPU
15970 supports @var{feature}
15971 and returns @code{0} otherwise. The following features can be detected:
15972
15973 @table @samp
15974 @item cmov
15975 CMOV instruction.
15976 @item mmx
15977 MMX instructions.
15978 @item popcnt
15979 POPCNT instruction.
15980 @item sse
15981 SSE instructions.
15982 @item sse2
15983 SSE2 instructions.
15984 @item sse3
15985 SSE3 instructions.
15986 @item ssse3
15987 SSSE3 instructions.
15988 @item sse4.1
15989 SSE4.1 instructions.
15990 @item sse4.2
15991 SSE4.2 instructions.
15992 @item avx
15993 AVX instructions.
15994 @item avx2
15995 AVX2 instructions.
15996 @item avx512f
15997 AVX512F instructions.
15998 @end table
15999
16000 Here is an example:
16001 @smallexample
16002 if (__builtin_cpu_supports ("popcnt"))
16003   @{
16004      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
16005   @}
16006 else
16007   @{
16008      count = generic_countbits (n); //generic implementation.
16009   @}
16010 @end smallexample
16011 @end deftypefn
16012
16013
16014 The following built-in functions are made available by @option{-mmmx}.
16015 All of them generate the machine instruction that is part of the name.
16016
16017 @smallexample
16018 v8qi __builtin_ia32_paddb (v8qi, v8qi)
16019 v4hi __builtin_ia32_paddw (v4hi, v4hi)
16020 v2si __builtin_ia32_paddd (v2si, v2si)
16021 v8qi __builtin_ia32_psubb (v8qi, v8qi)
16022 v4hi __builtin_ia32_psubw (v4hi, v4hi)
16023 v2si __builtin_ia32_psubd (v2si, v2si)
16024 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
16025 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
16026 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
16027 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
16028 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
16029 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
16030 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
16031 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
16032 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
16033 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
16034 di __builtin_ia32_pand (di, di)
16035 di __builtin_ia32_pandn (di,di)
16036 di __builtin_ia32_por (di, di)
16037 di __builtin_ia32_pxor (di, di)
16038 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
16039 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
16040 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
16041 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
16042 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
16043 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
16044 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
16045 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
16046 v2si __builtin_ia32_punpckhdq (v2si, v2si)
16047 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
16048 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
16049 v2si __builtin_ia32_punpckldq (v2si, v2si)
16050 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
16051 v4hi __builtin_ia32_packssdw (v2si, v2si)
16052 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
16053
16054 v4hi __builtin_ia32_psllw (v4hi, v4hi)
16055 v2si __builtin_ia32_pslld (v2si, v2si)
16056 v1di __builtin_ia32_psllq (v1di, v1di)
16057 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
16058 v2si __builtin_ia32_psrld (v2si, v2si)
16059 v1di __builtin_ia32_psrlq (v1di, v1di)
16060 v4hi __builtin_ia32_psraw (v4hi, v4hi)
16061 v2si __builtin_ia32_psrad (v2si, v2si)
16062 v4hi __builtin_ia32_psllwi (v4hi, int)
16063 v2si __builtin_ia32_pslldi (v2si, int)
16064 v1di __builtin_ia32_psllqi (v1di, int)
16065 v4hi __builtin_ia32_psrlwi (v4hi, int)
16066 v2si __builtin_ia32_psrldi (v2si, int)
16067 v1di __builtin_ia32_psrlqi (v1di, int)
16068 v4hi __builtin_ia32_psrawi (v4hi, int)
16069 v2si __builtin_ia32_psradi (v2si, int)
16070
16071 @end smallexample
16072
16073 The following built-in functions are made available either with
16074 @option{-msse}, or with a combination of @option{-m3dnow} and
16075 @option{-march=athlon}.  All of them generate the machine
16076 instruction that is part of the name.
16077
16078 @smallexample
16079 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
16080 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
16081 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
16082 v1di __builtin_ia32_psadbw (v8qi, v8qi)
16083 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
16084 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
16085 v8qi __builtin_ia32_pminub (v8qi, v8qi)
16086 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
16087 int __builtin_ia32_pmovmskb (v8qi)
16088 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
16089 void __builtin_ia32_movntq (di *, di)
16090 void __builtin_ia32_sfence (void)
16091 @end smallexample
16092
16093 The following built-in functions are available when @option{-msse} is used.
16094 All of them generate the machine instruction that is part of the name.
16095
16096 @smallexample
16097 int __builtin_ia32_comieq (v4sf, v4sf)
16098 int __builtin_ia32_comineq (v4sf, v4sf)
16099 int __builtin_ia32_comilt (v4sf, v4sf)
16100 int __builtin_ia32_comile (v4sf, v4sf)
16101 int __builtin_ia32_comigt (v4sf, v4sf)
16102 int __builtin_ia32_comige (v4sf, v4sf)
16103 int __builtin_ia32_ucomieq (v4sf, v4sf)
16104 int __builtin_ia32_ucomineq (v4sf, v4sf)
16105 int __builtin_ia32_ucomilt (v4sf, v4sf)
16106 int __builtin_ia32_ucomile (v4sf, v4sf)
16107 int __builtin_ia32_ucomigt (v4sf, v4sf)
16108 int __builtin_ia32_ucomige (v4sf, v4sf)
16109 v4sf __builtin_ia32_addps (v4sf, v4sf)
16110 v4sf __builtin_ia32_subps (v4sf, v4sf)
16111 v4sf __builtin_ia32_mulps (v4sf, v4sf)
16112 v4sf __builtin_ia32_divps (v4sf, v4sf)
16113 v4sf __builtin_ia32_addss (v4sf, v4sf)
16114 v4sf __builtin_ia32_subss (v4sf, v4sf)
16115 v4sf __builtin_ia32_mulss (v4sf, v4sf)
16116 v4sf __builtin_ia32_divss (v4sf, v4sf)
16117 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
16118 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
16119 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
16120 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
16121 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
16122 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
16123 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
16124 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
16125 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
16126 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
16127 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
16128 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
16129 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
16130 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
16131 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
16132 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
16133 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
16134 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
16135 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
16136 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
16137 v4sf __builtin_ia32_maxps (v4sf, v4sf)
16138 v4sf __builtin_ia32_maxss (v4sf, v4sf)
16139 v4sf __builtin_ia32_minps (v4sf, v4sf)
16140 v4sf __builtin_ia32_minss (v4sf, v4sf)
16141 v4sf __builtin_ia32_andps (v4sf, v4sf)
16142 v4sf __builtin_ia32_andnps (v4sf, v4sf)
16143 v4sf __builtin_ia32_orps (v4sf, v4sf)
16144 v4sf __builtin_ia32_xorps (v4sf, v4sf)
16145 v4sf __builtin_ia32_movss (v4sf, v4sf)
16146 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
16147 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
16148 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
16149 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
16150 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
16151 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
16152 v2si __builtin_ia32_cvtps2pi (v4sf)
16153 int __builtin_ia32_cvtss2si (v4sf)
16154 v2si __builtin_ia32_cvttps2pi (v4sf)
16155 int __builtin_ia32_cvttss2si (v4sf)
16156 v4sf __builtin_ia32_rcpps (v4sf)
16157 v4sf __builtin_ia32_rsqrtps (v4sf)
16158 v4sf __builtin_ia32_sqrtps (v4sf)
16159 v4sf __builtin_ia32_rcpss (v4sf)
16160 v4sf __builtin_ia32_rsqrtss (v4sf)
16161 v4sf __builtin_ia32_sqrtss (v4sf)
16162 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
16163 void __builtin_ia32_movntps (float *, v4sf)
16164 int __builtin_ia32_movmskps (v4sf)
16165 @end smallexample
16166
16167 The following built-in functions are available when @option{-msse} is used.
16168
16169 @table @code
16170 @item v4sf __builtin_ia32_loadups (float *)
16171 Generates the @code{movups} machine instruction as a load from memory.
16172 @item void __builtin_ia32_storeups (float *, v4sf)
16173 Generates the @code{movups} machine instruction as a store to memory.
16174 @item v4sf __builtin_ia32_loadss (float *)
16175 Generates the @code{movss} machine instruction as a load from memory.
16176 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
16177 Generates the @code{movhps} machine instruction as a load from memory.
16178 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
16179 Generates the @code{movlps} machine instruction as a load from memory
16180 @item void __builtin_ia32_storehps (v2sf *, v4sf)
16181 Generates the @code{movhps} machine instruction as a store to memory.
16182 @item void __builtin_ia32_storelps (v2sf *, v4sf)
16183 Generates the @code{movlps} machine instruction as a store to memory.
16184 @end table
16185
16186 The following built-in functions are available when @option{-msse2} is used.
16187 All of them generate the machine instruction that is part of the name.
16188
16189 @smallexample
16190 int __builtin_ia32_comisdeq (v2df, v2df)
16191 int __builtin_ia32_comisdlt (v2df, v2df)
16192 int __builtin_ia32_comisdle (v2df, v2df)
16193 int __builtin_ia32_comisdgt (v2df, v2df)
16194 int __builtin_ia32_comisdge (v2df, v2df)
16195 int __builtin_ia32_comisdneq (v2df, v2df)
16196 int __builtin_ia32_ucomisdeq (v2df, v2df)
16197 int __builtin_ia32_ucomisdlt (v2df, v2df)
16198 int __builtin_ia32_ucomisdle (v2df, v2df)
16199 int __builtin_ia32_ucomisdgt (v2df, v2df)
16200 int __builtin_ia32_ucomisdge (v2df, v2df)
16201 int __builtin_ia32_ucomisdneq (v2df, v2df)
16202 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
16203 v2df __builtin_ia32_cmpltpd (v2df, v2df)
16204 v2df __builtin_ia32_cmplepd (v2df, v2df)
16205 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
16206 v2df __builtin_ia32_cmpgepd (v2df, v2df)
16207 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
16208 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
16209 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
16210 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
16211 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
16212 v2df __builtin_ia32_cmpngepd (v2df, v2df)
16213 v2df __builtin_ia32_cmpordpd (v2df, v2df)
16214 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
16215 v2df __builtin_ia32_cmpltsd (v2df, v2df)
16216 v2df __builtin_ia32_cmplesd (v2df, v2df)
16217 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
16218 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
16219 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
16220 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
16221 v2df __builtin_ia32_cmpordsd (v2df, v2df)
16222 v2di __builtin_ia32_paddq (v2di, v2di)
16223 v2di __builtin_ia32_psubq (v2di, v2di)
16224 v2df __builtin_ia32_addpd (v2df, v2df)
16225 v2df __builtin_ia32_subpd (v2df, v2df)
16226 v2df __builtin_ia32_mulpd (v2df, v2df)
16227 v2df __builtin_ia32_divpd (v2df, v2df)
16228 v2df __builtin_ia32_addsd (v2df, v2df)
16229 v2df __builtin_ia32_subsd (v2df, v2df)
16230 v2df __builtin_ia32_mulsd (v2df, v2df)
16231 v2df __builtin_ia32_divsd (v2df, v2df)
16232 v2df __builtin_ia32_minpd (v2df, v2df)
16233 v2df __builtin_ia32_maxpd (v2df, v2df)
16234 v2df __builtin_ia32_minsd (v2df, v2df)
16235 v2df __builtin_ia32_maxsd (v2df, v2df)
16236 v2df __builtin_ia32_andpd (v2df, v2df)
16237 v2df __builtin_ia32_andnpd (v2df, v2df)
16238 v2df __builtin_ia32_orpd (v2df, v2df)
16239 v2df __builtin_ia32_xorpd (v2df, v2df)
16240 v2df __builtin_ia32_movsd (v2df, v2df)
16241 v2df __builtin_ia32_unpckhpd (v2df, v2df)
16242 v2df __builtin_ia32_unpcklpd (v2df, v2df)
16243 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
16244 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
16245 v4si __builtin_ia32_paddd128 (v4si, v4si)
16246 v2di __builtin_ia32_paddq128 (v2di, v2di)
16247 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
16248 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
16249 v4si __builtin_ia32_psubd128 (v4si, v4si)
16250 v2di __builtin_ia32_psubq128 (v2di, v2di)
16251 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
16252 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
16253 v2di __builtin_ia32_pand128 (v2di, v2di)
16254 v2di __builtin_ia32_pandn128 (v2di, v2di)
16255 v2di __builtin_ia32_por128 (v2di, v2di)
16256 v2di __builtin_ia32_pxor128 (v2di, v2di)
16257 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
16258 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
16259 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
16260 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
16261 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
16262 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
16263 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
16264 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
16265 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
16266 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
16267 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
16268 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
16269 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
16270 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
16271 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
16272 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
16273 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
16274 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
16275 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
16276 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
16277 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
16278 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
16279 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
16280 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
16281 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
16282 v2df __builtin_ia32_loadupd (double *)
16283 void __builtin_ia32_storeupd (double *, v2df)
16284 v2df __builtin_ia32_loadhpd (v2df, double const *)
16285 v2df __builtin_ia32_loadlpd (v2df, double const *)
16286 int __builtin_ia32_movmskpd (v2df)
16287 int __builtin_ia32_pmovmskb128 (v16qi)
16288 void __builtin_ia32_movnti (int *, int)
16289 void __builtin_ia32_movnti64 (long long int *, long long int)
16290 void __builtin_ia32_movntpd (double *, v2df)
16291 void __builtin_ia32_movntdq (v2df *, v2df)
16292 v4si __builtin_ia32_pshufd (v4si, int)
16293 v8hi __builtin_ia32_pshuflw (v8hi, int)
16294 v8hi __builtin_ia32_pshufhw (v8hi, int)
16295 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
16296 v2df __builtin_ia32_sqrtpd (v2df)
16297 v2df __builtin_ia32_sqrtsd (v2df)
16298 v2df __builtin_ia32_shufpd (v2df, v2df, int)
16299 v2df __builtin_ia32_cvtdq2pd (v4si)
16300 v4sf __builtin_ia32_cvtdq2ps (v4si)
16301 v4si __builtin_ia32_cvtpd2dq (v2df)
16302 v2si __builtin_ia32_cvtpd2pi (v2df)
16303 v4sf __builtin_ia32_cvtpd2ps (v2df)
16304 v4si __builtin_ia32_cvttpd2dq (v2df)
16305 v2si __builtin_ia32_cvttpd2pi (v2df)
16306 v2df __builtin_ia32_cvtpi2pd (v2si)
16307 int __builtin_ia32_cvtsd2si (v2df)
16308 int __builtin_ia32_cvttsd2si (v2df)
16309 long long __builtin_ia32_cvtsd2si64 (v2df)
16310 long long __builtin_ia32_cvttsd2si64 (v2df)
16311 v4si __builtin_ia32_cvtps2dq (v4sf)
16312 v2df __builtin_ia32_cvtps2pd (v4sf)
16313 v4si __builtin_ia32_cvttps2dq (v4sf)
16314 v2df __builtin_ia32_cvtsi2sd (v2df, int)
16315 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
16316 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
16317 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
16318 void __builtin_ia32_clflush (const void *)
16319 void __builtin_ia32_lfence (void)
16320 void __builtin_ia32_mfence (void)
16321 v16qi __builtin_ia32_loaddqu (const char *)
16322 void __builtin_ia32_storedqu (char *, v16qi)
16323 v1di __builtin_ia32_pmuludq (v2si, v2si)
16324 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
16325 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
16326 v4si __builtin_ia32_pslld128 (v4si, v4si)
16327 v2di __builtin_ia32_psllq128 (v2di, v2di)
16328 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
16329 v4si __builtin_ia32_psrld128 (v4si, v4si)
16330 v2di __builtin_ia32_psrlq128 (v2di, v2di)
16331 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
16332 v4si __builtin_ia32_psrad128 (v4si, v4si)
16333 v2di __builtin_ia32_pslldqi128 (v2di, int)
16334 v8hi __builtin_ia32_psllwi128 (v8hi, int)
16335 v4si __builtin_ia32_pslldi128 (v4si, int)
16336 v2di __builtin_ia32_psllqi128 (v2di, int)
16337 v2di __builtin_ia32_psrldqi128 (v2di, int)
16338 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
16339 v4si __builtin_ia32_psrldi128 (v4si, int)
16340 v2di __builtin_ia32_psrlqi128 (v2di, int)
16341 v8hi __builtin_ia32_psrawi128 (v8hi, int)
16342 v4si __builtin_ia32_psradi128 (v4si, int)
16343 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
16344 v2di __builtin_ia32_movq128 (v2di)
16345 @end smallexample
16346
16347 The following built-in functions are available when @option{-msse3} is used.
16348 All of them generate the machine instruction that is part of the name.
16349
16350 @smallexample
16351 v2df __builtin_ia32_addsubpd (v2df, v2df)
16352 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
16353 v2df __builtin_ia32_haddpd (v2df, v2df)
16354 v4sf __builtin_ia32_haddps (v4sf, v4sf)
16355 v2df __builtin_ia32_hsubpd (v2df, v2df)
16356 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
16357 v16qi __builtin_ia32_lddqu (char const *)
16358 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
16359 v4sf __builtin_ia32_movshdup (v4sf)
16360 v4sf __builtin_ia32_movsldup (v4sf)
16361 void __builtin_ia32_mwait (unsigned int, unsigned int)
16362 @end smallexample
16363
16364 The following built-in functions are available when @option{-mssse3} is used.
16365 All of them generate the machine instruction that is part of the name.
16366
16367 @smallexample
16368 v2si __builtin_ia32_phaddd (v2si, v2si)
16369 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
16370 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
16371 v2si __builtin_ia32_phsubd (v2si, v2si)
16372 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
16373 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
16374 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
16375 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
16376 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
16377 v8qi __builtin_ia32_psignb (v8qi, v8qi)
16378 v2si __builtin_ia32_psignd (v2si, v2si)
16379 v4hi __builtin_ia32_psignw (v4hi, v4hi)
16380 v1di __builtin_ia32_palignr (v1di, v1di, int)
16381 v8qi __builtin_ia32_pabsb (v8qi)
16382 v2si __builtin_ia32_pabsd (v2si)
16383 v4hi __builtin_ia32_pabsw (v4hi)
16384 @end smallexample
16385
16386 The following built-in functions are available when @option{-mssse3} is used.
16387 All of them generate the machine instruction that is part of the name.
16388
16389 @smallexample
16390 v4si __builtin_ia32_phaddd128 (v4si, v4si)
16391 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
16392 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
16393 v4si __builtin_ia32_phsubd128 (v4si, v4si)
16394 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
16395 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
16396 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
16397 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
16398 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
16399 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
16400 v4si __builtin_ia32_psignd128 (v4si, v4si)
16401 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
16402 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
16403 v16qi __builtin_ia32_pabsb128 (v16qi)
16404 v4si __builtin_ia32_pabsd128 (v4si)
16405 v8hi __builtin_ia32_pabsw128 (v8hi)
16406 @end smallexample
16407
16408 The following built-in functions are available when @option{-msse4.1} is
16409 used.  All of them generate the machine instruction that is part of the
16410 name.
16411
16412 @smallexample
16413 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
16414 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
16415 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
16416 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
16417 v2df __builtin_ia32_dppd (v2df, v2df, const int)
16418 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
16419 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
16420 v2di __builtin_ia32_movntdqa (v2di *);
16421 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
16422 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
16423 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
16424 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
16425 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
16426 v8hi __builtin_ia32_phminposuw128 (v8hi)
16427 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
16428 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
16429 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
16430 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
16431 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
16432 v4si __builtin_ia32_pminsd128 (v4si, v4si)
16433 v4si __builtin_ia32_pminud128 (v4si, v4si)
16434 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
16435 v4si __builtin_ia32_pmovsxbd128 (v16qi)
16436 v2di __builtin_ia32_pmovsxbq128 (v16qi)
16437 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
16438 v2di __builtin_ia32_pmovsxdq128 (v4si)
16439 v4si __builtin_ia32_pmovsxwd128 (v8hi)
16440 v2di __builtin_ia32_pmovsxwq128 (v8hi)
16441 v4si __builtin_ia32_pmovzxbd128 (v16qi)
16442 v2di __builtin_ia32_pmovzxbq128 (v16qi)
16443 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
16444 v2di __builtin_ia32_pmovzxdq128 (v4si)
16445 v4si __builtin_ia32_pmovzxwd128 (v8hi)
16446 v2di __builtin_ia32_pmovzxwq128 (v8hi)
16447 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
16448 v4si __builtin_ia32_pmulld128 (v4si, v4si)
16449 int __builtin_ia32_ptestc128 (v2di, v2di)
16450 int __builtin_ia32_ptestnzc128 (v2di, v2di)
16451 int __builtin_ia32_ptestz128 (v2di, v2di)
16452 v2df __builtin_ia32_roundpd (v2df, const int)
16453 v4sf __builtin_ia32_roundps (v4sf, const int)
16454 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
16455 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
16456 @end smallexample
16457
16458 The following built-in functions are available when @option{-msse4.1} is
16459 used.
16460
16461 @table @code
16462 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
16463 Generates the @code{insertps} machine instruction.
16464 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
16465 Generates the @code{pextrb} machine instruction.
16466 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
16467 Generates the @code{pinsrb} machine instruction.
16468 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
16469 Generates the @code{pinsrd} machine instruction.
16470 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
16471 Generates the @code{pinsrq} machine instruction in 64bit mode.
16472 @end table
16473
16474 The following built-in functions are changed to generate new SSE4.1
16475 instructions when @option{-msse4.1} is used.
16476
16477 @table @code
16478 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
16479 Generates the @code{extractps} machine instruction.
16480 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
16481 Generates the @code{pextrd} machine instruction.
16482 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
16483 Generates the @code{pextrq} machine instruction in 64bit mode.
16484 @end table
16485
16486 The following built-in functions are available when @option{-msse4.2} is
16487 used.  All of them generate the machine instruction that is part of the
16488 name.
16489
16490 @smallexample
16491 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
16492 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
16493 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
16494 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
16495 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
16496 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
16497 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
16498 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
16499 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
16500 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
16501 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
16502 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
16503 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
16504 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
16505 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
16506 @end smallexample
16507
16508 The following built-in functions are available when @option{-msse4.2} is
16509 used.
16510
16511 @table @code
16512 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
16513 Generates the @code{crc32b} machine instruction.
16514 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
16515 Generates the @code{crc32w} machine instruction.
16516 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
16517 Generates the @code{crc32l} machine instruction.
16518 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
16519 Generates the @code{crc32q} machine instruction.
16520 @end table
16521
16522 The following built-in functions are changed to generate new SSE4.2
16523 instructions when @option{-msse4.2} is used.
16524
16525 @table @code
16526 @item int __builtin_popcount (unsigned int)
16527 Generates the @code{popcntl} machine instruction.
16528 @item int __builtin_popcountl (unsigned long)
16529 Generates the @code{popcntl} or @code{popcntq} machine instruction,
16530 depending on the size of @code{unsigned long}.
16531 @item int __builtin_popcountll (unsigned long long)
16532 Generates the @code{popcntq} machine instruction.
16533 @end table
16534
16535 The following built-in functions are available when @option{-mavx} is
16536 used. All of them generate the machine instruction that is part of the
16537 name.
16538
16539 @smallexample
16540 v4df __builtin_ia32_addpd256 (v4df,v4df)
16541 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
16542 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
16543 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
16544 v4df __builtin_ia32_andnpd256 (v4df,v4df)
16545 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
16546 v4df __builtin_ia32_andpd256 (v4df,v4df)
16547 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
16548 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
16549 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
16550 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
16551 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
16552 v2df __builtin_ia32_cmppd (v2df,v2df,int)
16553 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
16554 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
16555 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
16556 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
16557 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
16558 v4df __builtin_ia32_cvtdq2pd256 (v4si)
16559 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
16560 v4si __builtin_ia32_cvtpd2dq256 (v4df)
16561 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
16562 v8si __builtin_ia32_cvtps2dq256 (v8sf)
16563 v4df __builtin_ia32_cvtps2pd256 (v4sf)
16564 v4si __builtin_ia32_cvttpd2dq256 (v4df)
16565 v8si __builtin_ia32_cvttps2dq256 (v8sf)
16566 v4df __builtin_ia32_divpd256 (v4df,v4df)
16567 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
16568 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
16569 v4df __builtin_ia32_haddpd256 (v4df,v4df)
16570 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
16571 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
16572 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
16573 v32qi __builtin_ia32_lddqu256 (pcchar)
16574 v32qi __builtin_ia32_loaddqu256 (pcchar)
16575 v4df __builtin_ia32_loadupd256 (pcdouble)
16576 v8sf __builtin_ia32_loadups256 (pcfloat)
16577 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
16578 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
16579 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
16580 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
16581 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
16582 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
16583 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
16584 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
16585 v4df __builtin_ia32_maxpd256 (v4df,v4df)
16586 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
16587 v4df __builtin_ia32_minpd256 (v4df,v4df)
16588 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
16589 v4df __builtin_ia32_movddup256 (v4df)
16590 int __builtin_ia32_movmskpd256 (v4df)
16591 int __builtin_ia32_movmskps256 (v8sf)
16592 v8sf __builtin_ia32_movshdup256 (v8sf)
16593 v8sf __builtin_ia32_movsldup256 (v8sf)
16594 v4df __builtin_ia32_mulpd256 (v4df,v4df)
16595 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
16596 v4df __builtin_ia32_orpd256 (v4df,v4df)
16597 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
16598 v2df __builtin_ia32_pd_pd256 (v4df)
16599 v4df __builtin_ia32_pd256_pd (v2df)
16600 v4sf __builtin_ia32_ps_ps256 (v8sf)
16601 v8sf __builtin_ia32_ps256_ps (v4sf)
16602 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
16603 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
16604 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
16605 v8sf __builtin_ia32_rcpps256 (v8sf)
16606 v4df __builtin_ia32_roundpd256 (v4df,int)
16607 v8sf __builtin_ia32_roundps256 (v8sf,int)
16608 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
16609 v8sf __builtin_ia32_rsqrtps256 (v8sf)
16610 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
16611 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
16612 v4si __builtin_ia32_si_si256 (v8si)
16613 v8si __builtin_ia32_si256_si (v4si)
16614 v4df __builtin_ia32_sqrtpd256 (v4df)
16615 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
16616 v8sf __builtin_ia32_sqrtps256 (v8sf)
16617 void __builtin_ia32_storedqu256 (pchar,v32qi)
16618 void __builtin_ia32_storeupd256 (pdouble,v4df)
16619 void __builtin_ia32_storeups256 (pfloat,v8sf)
16620 v4df __builtin_ia32_subpd256 (v4df,v4df)
16621 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
16622 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
16623 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
16624 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
16625 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
16626 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
16627 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
16628 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
16629 v4sf __builtin_ia32_vbroadcastss (pcfloat)
16630 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
16631 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
16632 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
16633 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
16634 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
16635 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
16636 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
16637 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
16638 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
16639 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
16640 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
16641 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
16642 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
16643 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
16644 v2df __builtin_ia32_vpermilpd (v2df,int)
16645 v4df __builtin_ia32_vpermilpd256 (v4df,int)
16646 v4sf __builtin_ia32_vpermilps (v4sf,int)
16647 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
16648 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
16649 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
16650 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
16651 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
16652 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
16653 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
16654 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
16655 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
16656 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
16657 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
16658 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
16659 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
16660 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
16661 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
16662 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
16663 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
16664 void __builtin_ia32_vzeroall (void)
16665 void __builtin_ia32_vzeroupper (void)
16666 v4df __builtin_ia32_xorpd256 (v4df,v4df)
16667 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
16668 @end smallexample
16669
16670 The following built-in functions are available when @option{-mavx2} is
16671 used. All of them generate the machine instruction that is part of the
16672 name.
16673
16674 @smallexample
16675 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
16676 v32qi __builtin_ia32_pabsb256 (v32qi)
16677 v16hi __builtin_ia32_pabsw256 (v16hi)
16678 v8si __builtin_ia32_pabsd256 (v8si)
16679 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
16680 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
16681 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
16682 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
16683 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
16684 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
16685 v8si __builtin_ia32_paddd256 (v8si,v8si)
16686 v4di __builtin_ia32_paddq256 (v4di,v4di)
16687 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
16688 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
16689 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
16690 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
16691 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
16692 v4di __builtin_ia32_andsi256 (v4di,v4di)
16693 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
16694 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
16695 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
16696 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
16697 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
16698 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
16699 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
16700 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
16701 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
16702 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
16703 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
16704 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
16705 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
16706 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
16707 v8si __builtin_ia32_phaddd256 (v8si,v8si)
16708 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
16709 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
16710 v8si __builtin_ia32_phsubd256 (v8si,v8si)
16711 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
16712 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
16713 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
16714 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
16715 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
16716 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
16717 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
16718 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
16719 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
16720 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
16721 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
16722 v8si __builtin_ia32_pminsd256 (v8si,v8si)
16723 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
16724 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
16725 v8si __builtin_ia32_pminud256 (v8si,v8si)
16726 int __builtin_ia32_pmovmskb256 (v32qi)
16727 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
16728 v8si __builtin_ia32_pmovsxbd256 (v16qi)
16729 v4di __builtin_ia32_pmovsxbq256 (v16qi)
16730 v8si __builtin_ia32_pmovsxwd256 (v8hi)
16731 v4di __builtin_ia32_pmovsxwq256 (v8hi)
16732 v4di __builtin_ia32_pmovsxdq256 (v4si)
16733 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
16734 v8si __builtin_ia32_pmovzxbd256 (v16qi)
16735 v4di __builtin_ia32_pmovzxbq256 (v16qi)
16736 v8si __builtin_ia32_pmovzxwd256 (v8hi)
16737 v4di __builtin_ia32_pmovzxwq256 (v8hi)
16738 v4di __builtin_ia32_pmovzxdq256 (v4si)
16739 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
16740 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
16741 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
16742 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
16743 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
16744 v8si __builtin_ia32_pmulld256 (v8si,v8si)
16745 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
16746 v4di __builtin_ia32_por256 (v4di,v4di)
16747 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
16748 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
16749 v8si __builtin_ia32_pshufd256 (v8si,int)
16750 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
16751 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
16752 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
16753 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
16754 v8si __builtin_ia32_psignd256 (v8si,v8si)
16755 v4di __builtin_ia32_pslldqi256 (v4di,int)
16756 v16hi __builtin_ia32_psllwi256 (16hi,int)
16757 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
16758 v8si __builtin_ia32_pslldi256 (v8si,int)
16759 v8si __builtin_ia32_pslld256(v8si,v4si)
16760 v4di __builtin_ia32_psllqi256 (v4di,int)
16761 v4di __builtin_ia32_psllq256(v4di,v2di)
16762 v16hi __builtin_ia32_psrawi256 (v16hi,int)
16763 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
16764 v8si __builtin_ia32_psradi256 (v8si,int)
16765 v8si __builtin_ia32_psrad256 (v8si,v4si)
16766 v4di __builtin_ia32_psrldqi256 (v4di, int)
16767 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
16768 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
16769 v8si __builtin_ia32_psrldi256 (v8si,int)
16770 v8si __builtin_ia32_psrld256 (v8si,v4si)
16771 v4di __builtin_ia32_psrlqi256 (v4di,int)
16772 v4di __builtin_ia32_psrlq256(v4di,v2di)
16773 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
16774 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
16775 v8si __builtin_ia32_psubd256 (v8si,v8si)
16776 v4di __builtin_ia32_psubq256 (v4di,v4di)
16777 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
16778 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
16779 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
16780 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
16781 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
16782 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
16783 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
16784 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
16785 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
16786 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
16787 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
16788 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
16789 v4di __builtin_ia32_pxor256 (v4di,v4di)
16790 v4di __builtin_ia32_movntdqa256 (pv4di)
16791 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
16792 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
16793 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
16794 v4di __builtin_ia32_vbroadcastsi256 (v2di)
16795 v4si __builtin_ia32_pblendd128 (v4si,v4si)
16796 v8si __builtin_ia32_pblendd256 (v8si,v8si)
16797 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
16798 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
16799 v8si __builtin_ia32_pbroadcastd256 (v4si)
16800 v4di __builtin_ia32_pbroadcastq256 (v2di)
16801 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
16802 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
16803 v4si __builtin_ia32_pbroadcastd128 (v4si)
16804 v2di __builtin_ia32_pbroadcastq128 (v2di)
16805 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
16806 v4df __builtin_ia32_permdf256 (v4df,int)
16807 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
16808 v4di __builtin_ia32_permdi256 (v4di,int)
16809 v4di __builtin_ia32_permti256 (v4di,v4di,int)
16810 v4di __builtin_ia32_extract128i256 (v4di,int)
16811 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
16812 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
16813 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
16814 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
16815 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
16816 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
16817 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
16818 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
16819 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
16820 v8si __builtin_ia32_psllv8si (v8si,v8si)
16821 v4si __builtin_ia32_psllv4si (v4si,v4si)
16822 v4di __builtin_ia32_psllv4di (v4di,v4di)
16823 v2di __builtin_ia32_psllv2di (v2di,v2di)
16824 v8si __builtin_ia32_psrav8si (v8si,v8si)
16825 v4si __builtin_ia32_psrav4si (v4si,v4si)
16826 v8si __builtin_ia32_psrlv8si (v8si,v8si)
16827 v4si __builtin_ia32_psrlv4si (v4si,v4si)
16828 v4di __builtin_ia32_psrlv4di (v4di,v4di)
16829 v2di __builtin_ia32_psrlv2di (v2di,v2di)
16830 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
16831 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
16832 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
16833 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
16834 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
16835 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
16836 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
16837 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
16838 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
16839 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
16840 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
16841 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
16842 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
16843 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
16844 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
16845 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
16846 @end smallexample
16847
16848 The following built-in functions are available when @option{-maes} is
16849 used.  All of them generate the machine instruction that is part of the
16850 name.
16851
16852 @smallexample
16853 v2di __builtin_ia32_aesenc128 (v2di, v2di)
16854 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
16855 v2di __builtin_ia32_aesdec128 (v2di, v2di)
16856 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
16857 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
16858 v2di __builtin_ia32_aesimc128 (v2di)
16859 @end smallexample
16860
16861 The following built-in function is available when @option{-mpclmul} is
16862 used.
16863
16864 @table @code
16865 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
16866 Generates the @code{pclmulqdq} machine instruction.
16867 @end table
16868
16869 The following built-in function is available when @option{-mfsgsbase} is
16870 used.  All of them generate the machine instruction that is part of the
16871 name.
16872
16873 @smallexample
16874 unsigned int __builtin_ia32_rdfsbase32 (void)
16875 unsigned long long __builtin_ia32_rdfsbase64 (void)
16876 unsigned int __builtin_ia32_rdgsbase32 (void)
16877 unsigned long long __builtin_ia32_rdgsbase64 (void)
16878 void _writefsbase_u32 (unsigned int)
16879 void _writefsbase_u64 (unsigned long long)
16880 void _writegsbase_u32 (unsigned int)
16881 void _writegsbase_u64 (unsigned long long)
16882 @end smallexample
16883
16884 The following built-in function is available when @option{-mrdrnd} is
16885 used.  All of them generate the machine instruction that is part of the
16886 name.
16887
16888 @smallexample
16889 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
16890 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
16891 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
16892 @end smallexample
16893
16894 The following built-in functions are available when @option{-msse4a} is used.
16895 All of them generate the machine instruction that is part of the name.
16896
16897 @smallexample
16898 void __builtin_ia32_movntsd (double *, v2df)
16899 void __builtin_ia32_movntss (float *, v4sf)
16900 v2di __builtin_ia32_extrq  (v2di, v16qi)
16901 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
16902 v2di __builtin_ia32_insertq (v2di, v2di)
16903 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
16904 @end smallexample
16905
16906 The following built-in functions are available when @option{-mxop} is used.
16907 @smallexample
16908 v2df __builtin_ia32_vfrczpd (v2df)
16909 v4sf __builtin_ia32_vfrczps (v4sf)
16910 v2df __builtin_ia32_vfrczsd (v2df)
16911 v4sf __builtin_ia32_vfrczss (v4sf)
16912 v4df __builtin_ia32_vfrczpd256 (v4df)
16913 v8sf __builtin_ia32_vfrczps256 (v8sf)
16914 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
16915 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
16916 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
16917 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
16918 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
16919 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
16920 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
16921 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
16922 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
16923 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
16924 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
16925 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
16926 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
16927 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
16928 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
16929 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
16930 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
16931 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
16932 v4si __builtin_ia32_vpcomequd (v4si, v4si)
16933 v2di __builtin_ia32_vpcomequq (v2di, v2di)
16934 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
16935 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
16936 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
16937 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
16938 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
16939 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
16940 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
16941 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
16942 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
16943 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
16944 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
16945 v4si __builtin_ia32_vpcomged (v4si, v4si)
16946 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
16947 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
16948 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
16949 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
16950 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
16951 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
16952 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
16953 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
16954 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
16955 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
16956 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
16957 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
16958 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
16959 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
16960 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
16961 v4si __builtin_ia32_vpcomled (v4si, v4si)
16962 v2di __builtin_ia32_vpcomleq (v2di, v2di)
16963 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
16964 v4si __builtin_ia32_vpcomleud (v4si, v4si)
16965 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
16966 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
16967 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
16968 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
16969 v4si __builtin_ia32_vpcomltd (v4si, v4si)
16970 v2di __builtin_ia32_vpcomltq (v2di, v2di)
16971 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
16972 v4si __builtin_ia32_vpcomltud (v4si, v4si)
16973 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
16974 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
16975 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
16976 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
16977 v4si __builtin_ia32_vpcomned (v4si, v4si)
16978 v2di __builtin_ia32_vpcomneq (v2di, v2di)
16979 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
16980 v4si __builtin_ia32_vpcomneud (v4si, v4si)
16981 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
16982 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
16983 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
16984 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
16985 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
16986 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
16987 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
16988 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
16989 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
16990 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
16991 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
16992 v4si __builtin_ia32_vphaddbd (v16qi)
16993 v2di __builtin_ia32_vphaddbq (v16qi)
16994 v8hi __builtin_ia32_vphaddbw (v16qi)
16995 v2di __builtin_ia32_vphadddq (v4si)
16996 v4si __builtin_ia32_vphaddubd (v16qi)
16997 v2di __builtin_ia32_vphaddubq (v16qi)
16998 v8hi __builtin_ia32_vphaddubw (v16qi)
16999 v2di __builtin_ia32_vphaddudq (v4si)
17000 v4si __builtin_ia32_vphadduwd (v8hi)
17001 v2di __builtin_ia32_vphadduwq (v8hi)
17002 v4si __builtin_ia32_vphaddwd (v8hi)
17003 v2di __builtin_ia32_vphaddwq (v8hi)
17004 v8hi __builtin_ia32_vphsubbw (v16qi)
17005 v2di __builtin_ia32_vphsubdq (v4si)
17006 v4si __builtin_ia32_vphsubwd (v8hi)
17007 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
17008 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
17009 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
17010 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
17011 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
17012 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
17013 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
17014 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
17015 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
17016 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
17017 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
17018 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
17019 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
17020 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
17021 v4si __builtin_ia32_vprotd (v4si, v4si)
17022 v2di __builtin_ia32_vprotq (v2di, v2di)
17023 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
17024 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
17025 v4si __builtin_ia32_vpshad (v4si, v4si)
17026 v2di __builtin_ia32_vpshaq (v2di, v2di)
17027 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
17028 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
17029 v4si __builtin_ia32_vpshld (v4si, v4si)
17030 v2di __builtin_ia32_vpshlq (v2di, v2di)
17031 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
17032 @end smallexample
17033
17034 The following built-in functions are available when @option{-mfma4} is used.
17035 All of them generate the machine instruction that is part of the name.
17036
17037 @smallexample
17038 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
17039 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
17040 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
17041 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
17042 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
17043 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
17044 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
17045 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
17046 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
17047 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
17048 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
17049 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
17050 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
17051 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
17052 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
17053 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
17054 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
17055 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
17056 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
17057 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
17058 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
17059 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
17060 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
17061 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
17062 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
17063 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
17064 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
17065 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
17066 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
17067 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
17068 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
17069 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
17070
17071 @end smallexample
17072
17073 The following built-in functions are available when @option{-mlwp} is used.
17074
17075 @smallexample
17076 void __builtin_ia32_llwpcb16 (void *);
17077 void __builtin_ia32_llwpcb32 (void *);
17078 void __builtin_ia32_llwpcb64 (void *);
17079 void * __builtin_ia32_llwpcb16 (void);
17080 void * __builtin_ia32_llwpcb32 (void);
17081 void * __builtin_ia32_llwpcb64 (void);
17082 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
17083 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
17084 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
17085 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
17086 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
17087 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
17088 @end smallexample
17089
17090 The following built-in functions are available when @option{-mbmi} is used.
17091 All of them generate the machine instruction that is part of the name.
17092 @smallexample
17093 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
17094 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
17095 @end smallexample
17096
17097 The following built-in functions are available when @option{-mbmi2} is used.
17098 All of them generate the machine instruction that is part of the name.
17099 @smallexample
17100 unsigned int _bzhi_u32 (unsigned int, unsigned int)
17101 unsigned int _pdep_u32 (unsigned int, unsigned int)
17102 unsigned int _pext_u32 (unsigned int, unsigned int)
17103 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
17104 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
17105 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
17106 @end smallexample
17107
17108 The following built-in functions are available when @option{-mlzcnt} is used.
17109 All of them generate the machine instruction that is part of the name.
17110 @smallexample
17111 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
17112 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
17113 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
17114 @end smallexample
17115
17116 The following built-in functions are available when @option{-mfxsr} is used.
17117 All of them generate the machine instruction that is part of the name.
17118 @smallexample
17119 void __builtin_ia32_fxsave (void *)
17120 void __builtin_ia32_fxrstor (void *)
17121 void __builtin_ia32_fxsave64 (void *)
17122 void __builtin_ia32_fxrstor64 (void *)
17123 @end smallexample
17124
17125 The following built-in functions are available when @option{-mxsave} is used.
17126 All of them generate the machine instruction that is part of the name.
17127 @smallexample
17128 void __builtin_ia32_xsave (void *, long long)
17129 void __builtin_ia32_xrstor (void *, long long)
17130 void __builtin_ia32_xsave64 (void *, long long)
17131 void __builtin_ia32_xrstor64 (void *, long long)
17132 @end smallexample
17133
17134 The following built-in functions are available when @option{-mxsaveopt} is used.
17135 All of them generate the machine instruction that is part of the name.
17136 @smallexample
17137 void __builtin_ia32_xsaveopt (void *, long long)
17138 void __builtin_ia32_xsaveopt64 (void *, long long)
17139 @end smallexample
17140
17141 The following built-in functions are available when @option{-mtbm} is used.
17142 Both of them generate the immediate form of the bextr machine instruction.
17143 @smallexample
17144 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
17145 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
17146 @end smallexample
17147
17148
17149 The following built-in functions are available when @option{-m3dnow} is used.
17150 All of them generate the machine instruction that is part of the name.
17151
17152 @smallexample
17153 void __builtin_ia32_femms (void)
17154 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
17155 v2si __builtin_ia32_pf2id (v2sf)
17156 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
17157 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
17158 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
17159 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
17160 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
17161 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
17162 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
17163 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
17164 v2sf __builtin_ia32_pfrcp (v2sf)
17165 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
17166 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
17167 v2sf __builtin_ia32_pfrsqrt (v2sf)
17168 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
17169 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
17170 v2sf __builtin_ia32_pi2fd (v2si)
17171 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
17172 @end smallexample
17173
17174 The following built-in functions are available when both @option{-m3dnow}
17175 and @option{-march=athlon} are used.  All of them generate the machine
17176 instruction that is part of the name.
17177
17178 @smallexample
17179 v2si __builtin_ia32_pf2iw (v2sf)
17180 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
17181 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
17182 v2sf __builtin_ia32_pi2fw (v2si)
17183 v2sf __builtin_ia32_pswapdsf (v2sf)
17184 v2si __builtin_ia32_pswapdsi (v2si)
17185 @end smallexample
17186
17187 The following built-in functions are available when @option{-mrtm} is used
17188 They are used for restricted transactional memory. These are the internal
17189 low level functions. Normally the functions in 
17190 @ref{x86 transactional memory intrinsics} should be used instead.
17191
17192 @smallexample
17193 int __builtin_ia32_xbegin ()
17194 void __builtin_ia32_xend ()
17195 void __builtin_ia32_xabort (status)
17196 int __builtin_ia32_xtest ()
17197 @end smallexample
17198
17199 @node x86 transactional memory intrinsics
17200 @subsection x86 transaction memory intrinsics
17201
17202 Hardware transactional memory intrinsics for x86. These allow to use
17203 memory transactions with RTM (Restricted Transactional Memory).
17204 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
17205 This support is enabled with the @option{-mrtm} option.
17206
17207 A memory transaction commits all changes to memory in an atomic way,
17208 as visible to other threads. If the transaction fails it is rolled back
17209 and all side effects discarded.
17210
17211 Generally there is no guarantee that a memory transaction ever succeeds
17212 and suitable fallback code always needs to be supplied.
17213
17214 @deftypefn {RTM Function} {unsigned} _xbegin ()
17215 Start a RTM (Restricted Transactional Memory) transaction. 
17216 Returns _XBEGIN_STARTED when the transaction
17217 started successfully (note this is not 0, so the constant has to be 
17218 explicitely tested). When the transaction aborts all side effects
17219 are undone and an abort code is returned. There is no guarantee
17220 any transaction ever succeeds, so there always needs to be a valid
17221 tested fallback path.
17222 @end deftypefn
17223
17224 @smallexample
17225 #include <immintrin.h>
17226
17227 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
17228     ... transaction code...
17229     _xend ();
17230 @} else @{
17231     ... non transactional fallback path...
17232 @}
17233 @end smallexample
17234
17235 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
17236
17237 @table @code
17238 @item _XABORT_EXPLICIT
17239 Transaction explicitely aborted with @code{_xabort}. The parameter passed
17240 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
17241 @item _XABORT_RETRY
17242 Transaction retry is possible.
17243 @item _XABORT_CONFLICT
17244 Transaction abort due to a memory conflict with another thread
17245 @item _XABORT_CAPACITY
17246 Transaction abort due to the transaction using too much memory
17247 @item _XABORT_DEBUG
17248 Transaction abort due to a debug trap
17249 @item _XABORT_NESTED
17250 Transaction abort in a inner nested transaction
17251 @end table
17252
17253 @deftypefn {RTM Function} {void} _xend ()
17254 Commit the current transaction. When no transaction is active this will
17255 fault. All memory side effects of the transactions will become visible
17256 to other threads in an atomic matter.
17257 @end deftypefn
17258
17259 @deftypefn {RTM Function} {int} _xtest ()
17260 Return a value not zero when a transaction is currently active, otherwise 0.
17261 @end deftypefn
17262
17263 @deftypefn {RTM Function} {void} _xabort (status)
17264 Abort the current transaction. When no transaction is active this is a no-op.
17265 status must be a 8bit constant, that is included in the status code returned
17266 by @code{_xbegin}
17267 @end deftypefn
17268
17269 @node Target Format Checks
17270 @section Format Checks Specific to Particular Target Machines
17271
17272 For some target machines, GCC supports additional options to the
17273 format attribute
17274 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
17275
17276 @menu
17277 * Solaris Format Checks::
17278 * Darwin Format Checks::
17279 @end menu
17280
17281 @node Solaris Format Checks
17282 @subsection Solaris Format Checks
17283
17284 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
17285 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
17286 conversions, and the two-argument @code{%b} conversion for displaying
17287 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
17288
17289 @node Darwin Format Checks
17290 @subsection Darwin Format Checks
17291
17292 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
17293 attribute context.  Declarations made with such attribution are parsed for correct syntax
17294 and format argument types.  However, parsing of the format string itself is currently undefined
17295 and is not carried out by this version of the compiler.
17296
17297 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
17298 also be used as format arguments.  Note that the relevant headers are only likely to be
17299 available on Darwin (OSX) installations.  On such installations, the XCode and system
17300 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
17301 associated functions.
17302
17303 @node Pragmas
17304 @section Pragmas Accepted by GCC
17305 @cindex pragmas
17306 @cindex @code{#pragma}
17307
17308 GCC supports several types of pragmas, primarily in order to compile
17309 code originally written for other compilers.  Note that in general
17310 we do not recommend the use of pragmas; @xref{Function Attributes},
17311 for further explanation.
17312
17313 @menu
17314 * ARM Pragmas::
17315 * M32C Pragmas::
17316 * MeP Pragmas::
17317 * RS/6000 and PowerPC Pragmas::
17318 * Darwin Pragmas::
17319 * Solaris Pragmas::
17320 * Symbol-Renaming Pragmas::
17321 * Structure-Packing Pragmas::
17322 * Weak Pragmas::
17323 * Diagnostic Pragmas::
17324 * Visibility Pragmas::
17325 * Push/Pop Macro Pragmas::
17326 * Function Specific Option Pragmas::
17327 * Loop-Specific Pragmas::
17328 @end menu
17329
17330 @node ARM Pragmas
17331 @subsection ARM Pragmas
17332
17333 The ARM target defines pragmas for controlling the default addition of
17334 @code{long_call} and @code{short_call} attributes to functions.
17335 @xref{Function Attributes}, for information about the effects of these
17336 attributes.
17337
17338 @table @code
17339 @item long_calls
17340 @cindex pragma, long_calls
17341 Set all subsequent functions to have the @code{long_call} attribute.
17342
17343 @item no_long_calls
17344 @cindex pragma, no_long_calls
17345 Set all subsequent functions to have the @code{short_call} attribute.
17346
17347 @item long_calls_off
17348 @cindex pragma, long_calls_off
17349 Do not affect the @code{long_call} or @code{short_call} attributes of
17350 subsequent functions.
17351 @end table
17352
17353 @node M32C Pragmas
17354 @subsection M32C Pragmas
17355
17356 @table @code
17357 @item GCC memregs @var{number}
17358 @cindex pragma, memregs
17359 Overrides the command-line option @code{-memregs=} for the current
17360 file.  Use with care!  This pragma must be before any function in the
17361 file, and mixing different memregs values in different objects may
17362 make them incompatible.  This pragma is useful when a
17363 performance-critical function uses a memreg for temporary values,
17364 as it may allow you to reduce the number of memregs used.
17365
17366 @item ADDRESS @var{name} @var{address}
17367 @cindex pragma, address
17368 For any declared symbols matching @var{name}, this does three things
17369 to that symbol: it forces the symbol to be located at the given
17370 address (a number), it forces the symbol to be volatile, and it
17371 changes the symbol's scope to be static.  This pragma exists for
17372 compatibility with other compilers, but note that the common
17373 @code{1234H} numeric syntax is not supported (use @code{0x1234}
17374 instead).  Example:
17375
17376 @smallexample
17377 #pragma ADDRESS port3 0x103
17378 char port3;
17379 @end smallexample
17380
17381 @end table
17382
17383 @node MeP Pragmas
17384 @subsection MeP Pragmas
17385
17386 @table @code
17387
17388 @item custom io_volatile (on|off)
17389 @cindex pragma, custom io_volatile
17390 Overrides the command-line option @code{-mio-volatile} for the current
17391 file.  Note that for compatibility with future GCC releases, this
17392 option should only be used once before any @code{io} variables in each
17393 file.
17394
17395 @item GCC coprocessor available @var{registers}
17396 @cindex pragma, coprocessor available
17397 Specifies which coprocessor registers are available to the register
17398 allocator.  @var{registers} may be a single register, register range
17399 separated by ellipses, or comma-separated list of those.  Example:
17400
17401 @smallexample
17402 #pragma GCC coprocessor available $c0...$c10, $c28
17403 @end smallexample
17404
17405 @item GCC coprocessor call_saved @var{registers}
17406 @cindex pragma, coprocessor call_saved
17407 Specifies which coprocessor registers are to be saved and restored by
17408 any function using them.  @var{registers} may be a single register,
17409 register range separated by ellipses, or comma-separated list of
17410 those.  Example:
17411
17412 @smallexample
17413 #pragma GCC coprocessor call_saved $c4...$c6, $c31
17414 @end smallexample
17415
17416 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
17417 @cindex pragma, coprocessor subclass
17418 Creates and defines a register class.  These register classes can be
17419 used by inline @code{asm} constructs.  @var{registers} may be a single
17420 register, register range separated by ellipses, or comma-separated
17421 list of those.  Example:
17422
17423 @smallexample
17424 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
17425
17426 asm ("cpfoo %0" : "=B" (x));
17427 @end smallexample
17428
17429 @item GCC disinterrupt @var{name} , @var{name} @dots{}
17430 @cindex pragma, disinterrupt
17431 For the named functions, the compiler adds code to disable interrupts
17432 for the duration of those functions.  If any functions so named 
17433 are not encountered in the source, a warning is emitted that the pragma is
17434 not used.  Examples:
17435
17436 @smallexample
17437 #pragma disinterrupt foo
17438 #pragma disinterrupt bar, grill
17439 int foo () @{ @dots{} @}
17440 @end smallexample
17441
17442 @item GCC call @var{name} , @var{name} @dots{}
17443 @cindex pragma, call
17444 For the named functions, the compiler always uses a register-indirect
17445 call model when calling the named functions.  Examples:
17446
17447 @smallexample
17448 extern int foo ();
17449 #pragma call foo
17450 @end smallexample
17451
17452 @end table
17453
17454 @node RS/6000 and PowerPC Pragmas
17455 @subsection RS/6000 and PowerPC Pragmas
17456
17457 The RS/6000 and PowerPC targets define one pragma for controlling
17458 whether or not the @code{longcall} attribute is added to function
17459 declarations by default.  This pragma overrides the @option{-mlongcall}
17460 option, but not the @code{longcall} and @code{shortcall} attributes.
17461 @xref{RS/6000 and PowerPC Options}, for more information about when long
17462 calls are and are not necessary.
17463
17464 @table @code
17465 @item longcall (1)
17466 @cindex pragma, longcall
17467 Apply the @code{longcall} attribute to all subsequent function
17468 declarations.
17469
17470 @item longcall (0)
17471 Do not apply the @code{longcall} attribute to subsequent function
17472 declarations.
17473 @end table
17474
17475 @c Describe h8300 pragmas here.
17476 @c Describe sh pragmas here.
17477 @c Describe v850 pragmas here.
17478
17479 @node Darwin Pragmas
17480 @subsection Darwin Pragmas
17481
17482 The following pragmas are available for all architectures running the
17483 Darwin operating system.  These are useful for compatibility with other
17484 Mac OS compilers.
17485
17486 @table @code
17487 @item mark @var{tokens}@dots{}
17488 @cindex pragma, mark
17489 This pragma is accepted, but has no effect.
17490
17491 @item options align=@var{alignment}
17492 @cindex pragma, options align
17493 This pragma sets the alignment of fields in structures.  The values of
17494 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
17495 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
17496 properly; to restore the previous setting, use @code{reset} for the
17497 @var{alignment}.
17498
17499 @item segment @var{tokens}@dots{}
17500 @cindex pragma, segment
17501 This pragma is accepted, but has no effect.
17502
17503 @item unused (@var{var} [, @var{var}]@dots{})
17504 @cindex pragma, unused
17505 This pragma declares variables to be possibly unused.  GCC does not
17506 produce warnings for the listed variables.  The effect is similar to
17507 that of the @code{unused} attribute, except that this pragma may appear
17508 anywhere within the variables' scopes.
17509 @end table
17510
17511 @node Solaris Pragmas
17512 @subsection Solaris Pragmas
17513
17514 The Solaris target supports @code{#pragma redefine_extname}
17515 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
17516 @code{#pragma} directives for compatibility with the system compiler.
17517
17518 @table @code
17519 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
17520 @cindex pragma, align
17521
17522 Increase the minimum alignment of each @var{variable} to @var{alignment}.
17523 This is the same as GCC's @code{aligned} attribute @pxref{Variable
17524 Attributes}).  Macro expansion occurs on the arguments to this pragma
17525 when compiling C and Objective-C@.  It does not currently occur when
17526 compiling C++, but this is a bug which may be fixed in a future
17527 release.
17528
17529 @item fini (@var{function} [, @var{function}]...)
17530 @cindex pragma, fini
17531
17532 This pragma causes each listed @var{function} to be called after
17533 main, or during shared module unloading, by adding a call to the
17534 @code{.fini} section.
17535
17536 @item init (@var{function} [, @var{function}]...)
17537 @cindex pragma, init
17538
17539 This pragma causes each listed @var{function} to be called during
17540 initialization (before @code{main}) or during shared module loading, by
17541 adding a call to the @code{.init} section.
17542
17543 @end table
17544
17545 @node Symbol-Renaming Pragmas
17546 @subsection Symbol-Renaming Pragmas
17547
17548 GCC supports a @code{#pragma} directive that changes the name used in
17549 assembly for a given declaration. This effect can also be achieved
17550 using the asm labels extension (@pxref{Asm Labels}).
17551
17552 @table @code
17553 @item redefine_extname @var{oldname} @var{newname}
17554 @cindex pragma, redefine_extname
17555
17556 This pragma gives the C function @var{oldname} the assembly symbol
17557 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
17558 is defined if this pragma is available (currently on all platforms).
17559 @end table
17560
17561 This pragma and the asm labels extension interact in a complicated
17562 manner.  Here are some corner cases you may want to be aware of:
17563
17564 @enumerate
17565 @item This pragma silently applies only to declarations with external
17566 linkage.  Asm labels do not have this restriction.
17567
17568 @item In C++, this pragma silently applies only to declarations with
17569 ``C'' linkage.  Again, asm labels do not have this restriction.
17570
17571 @item If either of the ways of changing the assembly name of a
17572 declaration are applied to a declaration whose assembly name has
17573 already been determined (either by a previous use of one of these
17574 features, or because the compiler needed the assembly name in order to
17575 generate code), and the new name is different, a warning issues and
17576 the name does not change.
17577
17578 @item The @var{oldname} used by @code{#pragma redefine_extname} is
17579 always the C-language name.
17580 @end enumerate
17581
17582 @node Structure-Packing Pragmas
17583 @subsection Structure-Packing Pragmas
17584
17585 For compatibility with Microsoft Windows compilers, GCC supports a
17586 set of @code{#pragma} directives that change the maximum alignment of
17587 members of structures (other than zero-width bit-fields), unions, and
17588 classes subsequently defined. The @var{n} value below always is required
17589 to be a small power of two and specifies the new alignment in bytes.
17590
17591 @enumerate
17592 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
17593 @item @code{#pragma pack()} sets the alignment to the one that was in
17594 effect when compilation started (see also command-line option
17595 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
17596 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
17597 setting on an internal stack and then optionally sets the new alignment.
17598 @item @code{#pragma pack(pop)} restores the alignment setting to the one
17599 saved at the top of the internal stack (and removes that stack entry).
17600 Note that @code{#pragma pack([@var{n}])} does not influence this internal
17601 stack; thus it is possible to have @code{#pragma pack(push)} followed by
17602 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
17603 @code{#pragma pack(pop)}.
17604 @end enumerate
17605
17606 Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
17607 @code{#pragma} which lays out a structure as the documented
17608 @code{__attribute__ ((ms_struct))}.
17609 @enumerate
17610 @item @code{#pragma ms_struct on} turns on the layout for structures
17611 declared.
17612 @item @code{#pragma ms_struct off} turns off the layout for structures
17613 declared.
17614 @item @code{#pragma ms_struct reset} goes back to the default layout.
17615 @end enumerate
17616
17617 @node Weak Pragmas
17618 @subsection Weak Pragmas
17619
17620 For compatibility with SVR4, GCC supports a set of @code{#pragma}
17621 directives for declaring symbols to be weak, and defining weak
17622 aliases.
17623
17624 @table @code
17625 @item #pragma weak @var{symbol}
17626 @cindex pragma, weak
17627 This pragma declares @var{symbol} to be weak, as if the declaration
17628 had the attribute of the same name.  The pragma may appear before
17629 or after the declaration of @var{symbol}.  It is not an error for
17630 @var{symbol} to never be defined at all.
17631
17632 @item #pragma weak @var{symbol1} = @var{symbol2}
17633 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
17634 It is an error if @var{symbol2} is not defined in the current
17635 translation unit.
17636 @end table
17637
17638 @node Diagnostic Pragmas
17639 @subsection Diagnostic Pragmas
17640
17641 GCC allows the user to selectively enable or disable certain types of
17642 diagnostics, and change the kind of the diagnostic.  For example, a
17643 project's policy might require that all sources compile with
17644 @option{-Werror} but certain files might have exceptions allowing
17645 specific types of warnings.  Or, a project might selectively enable
17646 diagnostics and treat them as errors depending on which preprocessor
17647 macros are defined.
17648
17649 @table @code
17650 @item #pragma GCC diagnostic @var{kind} @var{option}
17651 @cindex pragma, diagnostic
17652
17653 Modifies the disposition of a diagnostic.  Note that not all
17654 diagnostics are modifiable; at the moment only warnings (normally
17655 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
17656 Use @option{-fdiagnostics-show-option} to determine which diagnostics
17657 are controllable and which option controls them.
17658
17659 @var{kind} is @samp{error} to treat this diagnostic as an error,
17660 @samp{warning} to treat it like a warning (even if @option{-Werror} is
17661 in effect), or @samp{ignored} if the diagnostic is to be ignored.
17662 @var{option} is a double quoted string that matches the command-line
17663 option.
17664
17665 @smallexample
17666 #pragma GCC diagnostic warning "-Wformat"
17667 #pragma GCC diagnostic error "-Wformat"
17668 #pragma GCC diagnostic ignored "-Wformat"
17669 @end smallexample
17670
17671 Note that these pragmas override any command-line options.  GCC keeps
17672 track of the location of each pragma, and issues diagnostics according
17673 to the state as of that point in the source file.  Thus, pragmas occurring
17674 after a line do not affect diagnostics caused by that line.
17675
17676 @item #pragma GCC diagnostic push
17677 @itemx #pragma GCC diagnostic pop
17678
17679 Causes GCC to remember the state of the diagnostics as of each
17680 @code{push}, and restore to that point at each @code{pop}.  If a
17681 @code{pop} has no matching @code{push}, the command-line options are
17682 restored.
17683
17684 @smallexample
17685 #pragma GCC diagnostic error "-Wuninitialized"
17686   foo(a);                       /* error is given for this one */
17687 #pragma GCC diagnostic push
17688 #pragma GCC diagnostic ignored "-Wuninitialized"
17689   foo(b);                       /* no diagnostic for this one */
17690 #pragma GCC diagnostic pop
17691   foo(c);                       /* error is given for this one */
17692 #pragma GCC diagnostic pop
17693   foo(d);                       /* depends on command-line options */
17694 @end smallexample
17695
17696 @end table
17697
17698 GCC also offers a simple mechanism for printing messages during
17699 compilation.
17700
17701 @table @code
17702 @item #pragma message @var{string}
17703 @cindex pragma, diagnostic
17704
17705 Prints @var{string} as a compiler message on compilation.  The message
17706 is informational only, and is neither a compilation warning nor an error.
17707
17708 @smallexample
17709 #pragma message "Compiling " __FILE__ "..."
17710 @end smallexample
17711
17712 @var{string} may be parenthesized, and is printed with location
17713 information.  For example,
17714
17715 @smallexample
17716 #define DO_PRAGMA(x) _Pragma (#x)
17717 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
17718
17719 TODO(Remember to fix this)
17720 @end smallexample
17721
17722 @noindent
17723 prints @samp{/tmp/file.c:4: note: #pragma message:
17724 TODO - Remember to fix this}.
17725
17726 @end table
17727
17728 @node Visibility Pragmas
17729 @subsection Visibility Pragmas
17730
17731 @table @code
17732 @item #pragma GCC visibility push(@var{visibility})
17733 @itemx #pragma GCC visibility pop
17734 @cindex pragma, visibility
17735
17736 This pragma allows the user to set the visibility for multiple
17737 declarations without having to give each a visibility attribute
17738 (@pxref{Function Attributes}).
17739
17740 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
17741 declarations.  Class members and template specializations are not
17742 affected; if you want to override the visibility for a particular
17743 member or instantiation, you must use an attribute.
17744
17745 @end table
17746
17747
17748 @node Push/Pop Macro Pragmas
17749 @subsection Push/Pop Macro Pragmas
17750
17751 For compatibility with Microsoft Windows compilers, GCC supports
17752 @samp{#pragma push_macro(@var{"macro_name"})}
17753 and @samp{#pragma pop_macro(@var{"macro_name"})}.
17754
17755 @table @code
17756 @item #pragma push_macro(@var{"macro_name"})
17757 @cindex pragma, push_macro
17758 This pragma saves the value of the macro named as @var{macro_name} to
17759 the top of the stack for this macro.
17760
17761 @item #pragma pop_macro(@var{"macro_name"})
17762 @cindex pragma, pop_macro
17763 This pragma sets the value of the macro named as @var{macro_name} to
17764 the value on top of the stack for this macro. If the stack for
17765 @var{macro_name} is empty, the value of the macro remains unchanged.
17766 @end table
17767
17768 For example:
17769
17770 @smallexample
17771 #define X  1
17772 #pragma push_macro("X")
17773 #undef X
17774 #define X -1
17775 #pragma pop_macro("X")
17776 int x [X];
17777 @end smallexample
17778
17779 @noindent
17780 In this example, the definition of X as 1 is saved by @code{#pragma
17781 push_macro} and restored by @code{#pragma pop_macro}.
17782
17783 @node Function Specific Option Pragmas
17784 @subsection Function Specific Option Pragmas
17785
17786 @table @code
17787 @item #pragma GCC target (@var{"string"}...)
17788 @cindex pragma GCC target
17789
17790 This pragma allows you to set target specific options for functions
17791 defined later in the source file.  One or more strings can be
17792 specified.  Each function that is defined after this point is as
17793 if @code{attribute((target("STRING")))} was specified for that
17794 function.  The parenthesis around the options is optional.
17795 @xref{Function Attributes}, for more information about the
17796 @code{target} attribute and the attribute syntax.
17797
17798 The @code{#pragma GCC target} pragma is presently implemented for
17799 x86, PowerPC, and Nios II targets only.
17800 @end table
17801
17802 @table @code
17803 @item #pragma GCC optimize (@var{"string"}...)
17804 @cindex pragma GCC optimize
17805
17806 This pragma allows you to set global optimization options for functions
17807 defined later in the source file.  One or more strings can be
17808 specified.  Each function that is defined after this point is as
17809 if @code{attribute((optimize("STRING")))} was specified for that
17810 function.  The parenthesis around the options is optional.
17811 @xref{Function Attributes}, for more information about the
17812 @code{optimize} attribute and the attribute syntax.
17813
17814 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
17815 versions earlier than 4.4.
17816 @end table
17817
17818 @table @code
17819 @item #pragma GCC push_options
17820 @itemx #pragma GCC pop_options
17821 @cindex pragma GCC push_options
17822 @cindex pragma GCC pop_options
17823
17824 These pragmas maintain a stack of the current target and optimization
17825 options.  It is intended for include files where you temporarily want
17826 to switch to using a different @samp{#pragma GCC target} or
17827 @samp{#pragma GCC optimize} and then to pop back to the previous
17828 options.
17829
17830 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
17831 pragmas are not implemented in GCC versions earlier than 4.4.
17832 @end table
17833
17834 @table @code
17835 @item #pragma GCC reset_options
17836 @cindex pragma GCC reset_options
17837
17838 This pragma clears the current @code{#pragma GCC target} and
17839 @code{#pragma GCC optimize} to use the default switches as specified
17840 on the command line.
17841
17842 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
17843 versions earlier than 4.4.
17844 @end table
17845
17846 @node Loop-Specific Pragmas
17847 @subsection Loop-Specific Pragmas
17848
17849 @table @code
17850 @item #pragma GCC ivdep
17851 @cindex pragma GCC ivdep
17852 @end table
17853
17854 With this pragma, the programmer asserts that there are no loop-carried
17855 dependencies which would prevent that consecutive iterations of
17856 the following loop can be executed concurrently with SIMD
17857 (single instruction multiple data) instructions.
17858
17859 For example, the compiler can only unconditionally vectorize the following
17860 loop with the pragma:
17861
17862 @smallexample
17863 void foo (int n, int *a, int *b, int *c)
17864 @{
17865   int i, j;
17866 #pragma GCC ivdep
17867   for (i = 0; i < n; ++i)
17868     a[i] = b[i] + c[i];
17869 @}
17870 @end smallexample
17871
17872 @noindent
17873 In this example, using the @code{restrict} qualifier had the same
17874 effect. In the following example, that would not be possible. Assume
17875 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
17876 that it can unconditionally vectorize the following loop:
17877
17878 @smallexample
17879 void ignore_vec_dep (int *a, int k, int c, int m)
17880 @{
17881 #pragma GCC ivdep
17882   for (int i = 0; i < m; i++)
17883     a[i] = a[i + k] * c;
17884 @}
17885 @end smallexample
17886
17887
17888 @node Unnamed Fields
17889 @section Unnamed struct/union fields within structs/unions
17890 @cindex @code{struct}
17891 @cindex @code{union}
17892
17893 As permitted by ISO C11 and for compatibility with other compilers,
17894 GCC allows you to define
17895 a structure or union that contains, as fields, structures and unions
17896 without names.  For example:
17897
17898 @smallexample
17899 struct @{
17900   int a;
17901   union @{
17902     int b;
17903     float c;
17904   @};
17905   int d;
17906 @} foo;
17907 @end smallexample
17908
17909 @noindent
17910 In this example, you are able to access members of the unnamed
17911 union with code like @samp{foo.b}.  Note that only unnamed structs and
17912 unions are allowed, you may not have, for example, an unnamed
17913 @code{int}.
17914
17915 You must never create such structures that cause ambiguous field definitions.
17916 For example, in this structure:
17917
17918 @smallexample
17919 struct @{
17920   int a;
17921   struct @{
17922     int a;
17923   @};
17924 @} foo;
17925 @end smallexample
17926
17927 @noindent
17928 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
17929 The compiler gives errors for such constructs.
17930
17931 @opindex fms-extensions
17932 Unless @option{-fms-extensions} is used, the unnamed field must be a
17933 structure or union definition without a tag (for example, @samp{struct
17934 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
17935 also be a definition with a tag such as @samp{struct foo @{ int a;
17936 @};}, a reference to a previously defined structure or union such as
17937 @samp{struct foo;}, or a reference to a @code{typedef} name for a
17938 previously defined structure or union type.
17939
17940 @opindex fplan9-extensions
17941 The option @option{-fplan9-extensions} enables
17942 @option{-fms-extensions} as well as two other extensions.  First, a
17943 pointer to a structure is automatically converted to a pointer to an
17944 anonymous field for assignments and function calls.  For example:
17945
17946 @smallexample
17947 struct s1 @{ int a; @};
17948 struct s2 @{ struct s1; @};
17949 extern void f1 (struct s1 *);
17950 void f2 (struct s2 *p) @{ f1 (p); @}
17951 @end smallexample
17952
17953 @noindent
17954 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
17955 converted into a pointer to the anonymous field.
17956
17957 Second, when the type of an anonymous field is a @code{typedef} for a
17958 @code{struct} or @code{union}, code may refer to the field using the
17959 name of the @code{typedef}.
17960
17961 @smallexample
17962 typedef struct @{ int a; @} s1;
17963 struct s2 @{ s1; @};
17964 s1 f1 (struct s2 *p) @{ return p->s1; @}
17965 @end smallexample
17966
17967 These usages are only permitted when they are not ambiguous.
17968
17969 @node Thread-Local
17970 @section Thread-Local Storage
17971 @cindex Thread-Local Storage
17972 @cindex @acronym{TLS}
17973 @cindex @code{__thread}
17974
17975 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
17976 are allocated such that there is one instance of the variable per extant
17977 thread.  The runtime model GCC uses to implement this originates
17978 in the IA-64 processor-specific ABI, but has since been migrated
17979 to other processors as well.  It requires significant support from
17980 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
17981 system libraries (@file{libc.so} and @file{libpthread.so}), so it
17982 is not available everywhere.
17983
17984 At the user level, the extension is visible with a new storage
17985 class keyword: @code{__thread}.  For example:
17986
17987 @smallexample
17988 __thread int i;
17989 extern __thread struct state s;
17990 static __thread char *p;
17991 @end smallexample
17992
17993 The @code{__thread} specifier may be used alone, with the @code{extern}
17994 or @code{static} specifiers, but with no other storage class specifier.
17995 When used with @code{extern} or @code{static}, @code{__thread} must appear
17996 immediately after the other storage class specifier.
17997
17998 The @code{__thread} specifier may be applied to any global, file-scoped
17999 static, function-scoped static, or static data member of a class.  It may
18000 not be applied to block-scoped automatic or non-static data member.
18001
18002 When the address-of operator is applied to a thread-local variable, it is
18003 evaluated at run time and returns the address of the current thread's
18004 instance of that variable.  An address so obtained may be used by any
18005 thread.  When a thread terminates, any pointers to thread-local variables
18006 in that thread become invalid.
18007
18008 No static initialization may refer to the address of a thread-local variable.
18009
18010 In C++, if an initializer is present for a thread-local variable, it must
18011 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
18012 standard.
18013
18014 See @uref{http://www.akkadia.org/drepper/tls.pdf,
18015 ELF Handling For Thread-Local Storage} for a detailed explanation of
18016 the four thread-local storage addressing models, and how the runtime
18017 is expected to function.
18018
18019 @menu
18020 * C99 Thread-Local Edits::
18021 * C++98 Thread-Local Edits::
18022 @end menu
18023
18024 @node C99 Thread-Local Edits
18025 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
18026
18027 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
18028 that document the exact semantics of the language extension.
18029
18030 @itemize @bullet
18031 @item
18032 @cite{5.1.2  Execution environments}
18033
18034 Add new text after paragraph 1
18035
18036 @quotation
18037 Within either execution environment, a @dfn{thread} is a flow of
18038 control within a program.  It is implementation defined whether
18039 or not there may be more than one thread associated with a program.
18040 It is implementation defined how threads beyond the first are
18041 created, the name and type of the function called at thread
18042 startup, and how threads may be terminated.  However, objects
18043 with thread storage duration shall be initialized before thread
18044 startup.
18045 @end quotation
18046
18047 @item
18048 @cite{6.2.4  Storage durations of objects}
18049
18050 Add new text before paragraph 3
18051
18052 @quotation
18053 An object whose identifier is declared with the storage-class
18054 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
18055 Its lifetime is the entire execution of the thread, and its
18056 stored value is initialized only once, prior to thread startup.
18057 @end quotation
18058
18059 @item
18060 @cite{6.4.1  Keywords}
18061
18062 Add @code{__thread}.
18063
18064 @item
18065 @cite{6.7.1  Storage-class specifiers}
18066
18067 Add @code{__thread} to the list of storage class specifiers in
18068 paragraph 1.
18069
18070 Change paragraph 2 to
18071
18072 @quotation
18073 With the exception of @code{__thread}, at most one storage-class
18074 specifier may be given [@dots{}].  The @code{__thread} specifier may
18075 be used alone, or immediately following @code{extern} or
18076 @code{static}.
18077 @end quotation
18078
18079 Add new text after paragraph 6
18080
18081 @quotation
18082 The declaration of an identifier for a variable that has
18083 block scope that specifies @code{__thread} shall also
18084 specify either @code{extern} or @code{static}.
18085
18086 The @code{__thread} specifier shall be used only with
18087 variables.
18088 @end quotation
18089 @end itemize
18090
18091 @node C++98 Thread-Local Edits
18092 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
18093
18094 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
18095 that document the exact semantics of the language extension.
18096
18097 @itemize @bullet
18098 @item
18099 @b{[intro.execution]}
18100
18101 New text after paragraph 4
18102
18103 @quotation
18104 A @dfn{thread} is a flow of control within the abstract machine.
18105 It is implementation defined whether or not there may be more than
18106 one thread.
18107 @end quotation
18108
18109 New text after paragraph 7
18110
18111 @quotation
18112 It is unspecified whether additional action must be taken to
18113 ensure when and whether side effects are visible to other threads.
18114 @end quotation
18115
18116 @item
18117 @b{[lex.key]}
18118
18119 Add @code{__thread}.
18120
18121 @item
18122 @b{[basic.start.main]}
18123
18124 Add after paragraph 5
18125
18126 @quotation
18127 The thread that begins execution at the @code{main} function is called
18128 the @dfn{main thread}.  It is implementation defined how functions
18129 beginning threads other than the main thread are designated or typed.
18130 A function so designated, as well as the @code{main} function, is called
18131 a @dfn{thread startup function}.  It is implementation defined what
18132 happens if a thread startup function returns.  It is implementation
18133 defined what happens to other threads when any thread calls @code{exit}.
18134 @end quotation
18135
18136 @item
18137 @b{[basic.start.init]}
18138
18139 Add after paragraph 4
18140
18141 @quotation
18142 The storage for an object of thread storage duration shall be
18143 statically initialized before the first statement of the thread startup
18144 function.  An object of thread storage duration shall not require
18145 dynamic initialization.
18146 @end quotation
18147
18148 @item
18149 @b{[basic.start.term]}
18150
18151 Add after paragraph 3
18152
18153 @quotation
18154 The type of an object with thread storage duration shall not have a
18155 non-trivial destructor, nor shall it be an array type whose elements
18156 (directly or indirectly) have non-trivial destructors.
18157 @end quotation
18158
18159 @item
18160 @b{[basic.stc]}
18161
18162 Add ``thread storage duration'' to the list in paragraph 1.
18163
18164 Change paragraph 2
18165
18166 @quotation
18167 Thread, static, and automatic storage durations are associated with
18168 objects introduced by declarations [@dots{}].
18169 @end quotation
18170
18171 Add @code{__thread} to the list of specifiers in paragraph 3.
18172
18173 @item
18174 @b{[basic.stc.thread]}
18175
18176 New section before @b{[basic.stc.static]}
18177
18178 @quotation
18179 The keyword @code{__thread} applied to a non-local object gives the
18180 object thread storage duration.
18181
18182 A local variable or class data member declared both @code{static}
18183 and @code{__thread} gives the variable or member thread storage
18184 duration.
18185 @end quotation
18186
18187 @item
18188 @b{[basic.stc.static]}
18189
18190 Change paragraph 1
18191
18192 @quotation
18193 All objects that have neither thread storage duration, dynamic
18194 storage duration nor are local [@dots{}].
18195 @end quotation
18196
18197 @item
18198 @b{[dcl.stc]}
18199
18200 Add @code{__thread} to the list in paragraph 1.
18201
18202 Change paragraph 1
18203
18204 @quotation
18205 With the exception of @code{__thread}, at most one
18206 @var{storage-class-specifier} shall appear in a given
18207 @var{decl-specifier-seq}.  The @code{__thread} specifier may
18208 be used alone, or immediately following the @code{extern} or
18209 @code{static} specifiers.  [@dots{}]
18210 @end quotation
18211
18212 Add after paragraph 5
18213
18214 @quotation
18215 The @code{__thread} specifier can be applied only to the names of objects
18216 and to anonymous unions.
18217 @end quotation
18218
18219 @item
18220 @b{[class.mem]}
18221
18222 Add after paragraph 6
18223
18224 @quotation
18225 Non-@code{static} members shall not be @code{__thread}.
18226 @end quotation
18227 @end itemize
18228
18229 @node Binary constants
18230 @section Binary constants using the @samp{0b} prefix
18231 @cindex Binary constants using the @samp{0b} prefix
18232
18233 Integer constants can be written as binary constants, consisting of a
18234 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
18235 @samp{0B}.  This is particularly useful in environments that operate a
18236 lot on the bit level (like microcontrollers).
18237
18238 The following statements are identical:
18239
18240 @smallexample
18241 i =       42;
18242 i =     0x2a;
18243 i =      052;
18244 i = 0b101010;
18245 @end smallexample
18246
18247 The type of these constants follows the same rules as for octal or
18248 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
18249 can be applied.
18250
18251 @node C++ Extensions
18252 @chapter Extensions to the C++ Language
18253 @cindex extensions, C++ language
18254 @cindex C++ language extensions
18255
18256 The GNU compiler provides these extensions to the C++ language (and you
18257 can also use most of the C language extensions in your C++ programs).  If you
18258 want to write code that checks whether these features are available, you can
18259 test for the GNU compiler the same way as for C programs: check for a
18260 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
18261 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
18262 Predefined Macros,cpp,The GNU C Preprocessor}).
18263
18264 @menu
18265 * C++ Volatiles::       What constitutes an access to a volatile object.
18266 * Restricted Pointers:: C99 restricted pointers and references.
18267 * Vague Linkage::       Where G++ puts inlines, vtables and such.
18268 * C++ Interface::       You can use a single C++ header file for both
18269                         declarations and definitions.
18270 * Template Instantiation:: Methods for ensuring that exactly one copy of
18271                         each needed template instantiation is emitted.
18272 * Bound member functions:: You can extract a function pointer to the
18273                         method denoted by a @samp{->*} or @samp{.*} expression.
18274 * C++ Attributes::      Variable, function, and type attributes for C++ only.
18275 * Function Multiversioning::   Declaring multiple function versions.
18276 * Namespace Association:: Strong using-directives for namespace association.
18277 * Type Traits::         Compiler support for type traits
18278 * Java Exceptions::     Tweaking exception handling to work with Java.
18279 * Deprecated Features:: Things will disappear from G++.
18280 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
18281 @end menu
18282
18283 @node C++ Volatiles
18284 @section When is a Volatile C++ Object Accessed?
18285 @cindex accessing volatiles
18286 @cindex volatile read
18287 @cindex volatile write
18288 @cindex volatile access
18289
18290 The C++ standard differs from the C standard in its treatment of
18291 volatile objects.  It fails to specify what constitutes a volatile
18292 access, except to say that C++ should behave in a similar manner to C
18293 with respect to volatiles, where possible.  However, the different
18294 lvalueness of expressions between C and C++ complicate the behavior.
18295 G++ behaves the same as GCC for volatile access, @xref{C
18296 Extensions,,Volatiles}, for a description of GCC's behavior.
18297
18298 The C and C++ language specifications differ when an object is
18299 accessed in a void context:
18300
18301 @smallexample
18302 volatile int *src = @var{somevalue};
18303 *src;
18304 @end smallexample
18305
18306 The C++ standard specifies that such expressions do not undergo lvalue
18307 to rvalue conversion, and that the type of the dereferenced object may
18308 be incomplete.  The C++ standard does not specify explicitly that it
18309 is lvalue to rvalue conversion that is responsible for causing an
18310 access.  There is reason to believe that it is, because otherwise
18311 certain simple expressions become undefined.  However, because it
18312 would surprise most programmers, G++ treats dereferencing a pointer to
18313 volatile object of complete type as GCC would do for an equivalent
18314 type in C@.  When the object has incomplete type, G++ issues a
18315 warning; if you wish to force an error, you must force a conversion to
18316 rvalue with, for instance, a static cast.
18317
18318 When using a reference to volatile, G++ does not treat equivalent
18319 expressions as accesses to volatiles, but instead issues a warning that
18320 no volatile is accessed.  The rationale for this is that otherwise it
18321 becomes difficult to determine where volatile access occur, and not
18322 possible to ignore the return value from functions returning volatile
18323 references.  Again, if you wish to force a read, cast the reference to
18324 an rvalue.
18325
18326 G++ implements the same behavior as GCC does when assigning to a
18327 volatile object---there is no reread of the assigned-to object, the
18328 assigned rvalue is reused.  Note that in C++ assignment expressions
18329 are lvalues, and if used as an lvalue, the volatile object is
18330 referred to.  For instance, @var{vref} refers to @var{vobj}, as
18331 expected, in the following example:
18332
18333 @smallexample
18334 volatile int vobj;
18335 volatile int &vref = vobj = @var{something};
18336 @end smallexample
18337
18338 @node Restricted Pointers
18339 @section Restricting Pointer Aliasing
18340 @cindex restricted pointers
18341 @cindex restricted references
18342 @cindex restricted this pointer
18343
18344 As with the C front end, G++ understands the C99 feature of restricted pointers,
18345 specified with the @code{__restrict__}, or @code{__restrict} type
18346 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
18347 language flag, @code{restrict} is not a keyword in C++.
18348
18349 In addition to allowing restricted pointers, you can specify restricted
18350 references, which indicate that the reference is not aliased in the local
18351 context.
18352
18353 @smallexample
18354 void fn (int *__restrict__ rptr, int &__restrict__ rref)
18355 @{
18356   /* @r{@dots{}} */
18357 @}
18358 @end smallexample
18359
18360 @noindent
18361 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
18362 @var{rref} refers to a (different) unaliased integer.
18363
18364 You may also specify whether a member function's @var{this} pointer is
18365 unaliased by using @code{__restrict__} as a member function qualifier.
18366
18367 @smallexample
18368 void T::fn () __restrict__
18369 @{
18370   /* @r{@dots{}} */
18371 @}
18372 @end smallexample
18373
18374 @noindent
18375 Within the body of @code{T::fn}, @var{this} has the effective
18376 definition @code{T *__restrict__ const this}.  Notice that the
18377 interpretation of a @code{__restrict__} member function qualifier is
18378 different to that of @code{const} or @code{volatile} qualifier, in that it
18379 is applied to the pointer rather than the object.  This is consistent with
18380 other compilers that implement restricted pointers.
18381
18382 As with all outermost parameter qualifiers, @code{__restrict__} is
18383 ignored in function definition matching.  This means you only need to
18384 specify @code{__restrict__} in a function definition, rather than
18385 in a function prototype as well.
18386
18387 @node Vague Linkage
18388 @section Vague Linkage
18389 @cindex vague linkage
18390
18391 There are several constructs in C++ that require space in the object
18392 file but are not clearly tied to a single translation unit.  We say that
18393 these constructs have ``vague linkage''.  Typically such constructs are
18394 emitted wherever they are needed, though sometimes we can be more
18395 clever.
18396
18397 @table @asis
18398 @item Inline Functions
18399 Inline functions are typically defined in a header file which can be
18400 included in many different compilations.  Hopefully they can usually be
18401 inlined, but sometimes an out-of-line copy is necessary, if the address
18402 of the function is taken or if inlining fails.  In general, we emit an
18403 out-of-line copy in all translation units where one is needed.  As an
18404 exception, we only emit inline virtual functions with the vtable, since
18405 it always requires a copy.
18406
18407 Local static variables and string constants used in an inline function
18408 are also considered to have vague linkage, since they must be shared
18409 between all inlined and out-of-line instances of the function.
18410
18411 @item VTables
18412 @cindex vtable
18413 C++ virtual functions are implemented in most compilers using a lookup
18414 table, known as a vtable.  The vtable contains pointers to the virtual
18415 functions provided by a class, and each object of the class contains a
18416 pointer to its vtable (or vtables, in some multiple-inheritance
18417 situations).  If the class declares any non-inline, non-pure virtual
18418 functions, the first one is chosen as the ``key method'' for the class,
18419 and the vtable is only emitted in the translation unit where the key
18420 method is defined.
18421
18422 @emph{Note:} If the chosen key method is later defined as inline, the
18423 vtable is still emitted in every translation unit that defines it.
18424 Make sure that any inline virtuals are declared inline in the class
18425 body, even if they are not defined there.
18426
18427 @item @code{type_info} objects
18428 @cindex @code{type_info}
18429 @cindex RTTI
18430 C++ requires information about types to be written out in order to
18431 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
18432 For polymorphic classes (classes with virtual functions), the @samp{type_info}
18433 object is written out along with the vtable so that @samp{dynamic_cast}
18434 can determine the dynamic type of a class object at run time.  For all
18435 other types, we write out the @samp{type_info} object when it is used: when
18436 applying @samp{typeid} to an expression, throwing an object, or
18437 referring to a type in a catch clause or exception specification.
18438
18439 @item Template Instantiations
18440 Most everything in this section also applies to template instantiations,
18441 but there are other options as well.
18442 @xref{Template Instantiation,,Where's the Template?}.
18443
18444 @end table
18445
18446 When used with GNU ld version 2.8 or later on an ELF system such as
18447 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
18448 these constructs will be discarded at link time.  This is known as
18449 COMDAT support.
18450
18451 On targets that don't support COMDAT, but do support weak symbols, GCC
18452 uses them.  This way one copy overrides all the others, but
18453 the unused copies still take up space in the executable.
18454
18455 For targets that do not support either COMDAT or weak symbols,
18456 most entities with vague linkage are emitted as local symbols to
18457 avoid duplicate definition errors from the linker.  This does not happen
18458 for local statics in inlines, however, as having multiple copies
18459 almost certainly breaks things.
18460
18461 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
18462 another way to control placement of these constructs.
18463
18464 @node C++ Interface
18465 @section #pragma interface and implementation
18466
18467 @cindex interface and implementation headers, C++
18468 @cindex C++ interface and implementation headers
18469 @cindex pragmas, interface and implementation
18470
18471 @code{#pragma interface} and @code{#pragma implementation} provide the
18472 user with a way of explicitly directing the compiler to emit entities
18473 with vague linkage (and debugging information) in a particular
18474 translation unit.
18475
18476 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
18477 most cases, because of COMDAT support and the ``key method'' heuristic
18478 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
18479 program to grow due to unnecessary out-of-line copies of inline
18480 functions.  Currently (3.4) the only benefit of these
18481 @code{#pragma}s is reduced duplication of debugging information, and
18482 that should be addressed soon on DWARF 2 targets with the use of
18483 COMDAT groups.
18484
18485 @table @code
18486 @item #pragma interface
18487 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
18488 @kindex #pragma interface
18489 Use this directive in @emph{header files} that define object classes, to save
18490 space in most of the object files that use those classes.  Normally,
18491 local copies of certain information (backup copies of inline member
18492 functions, debugging information, and the internal tables that implement
18493 virtual functions) must be kept in each object file that includes class
18494 definitions.  You can use this pragma to avoid such duplication.  When a
18495 header file containing @samp{#pragma interface} is included in a
18496 compilation, this auxiliary information is not generated (unless
18497 the main input source file itself uses @samp{#pragma implementation}).
18498 Instead, the object files contain references to be resolved at link
18499 time.
18500
18501 The second form of this directive is useful for the case where you have
18502 multiple headers with the same name in different directories.  If you
18503 use this form, you must specify the same string to @samp{#pragma
18504 implementation}.
18505
18506 @item #pragma implementation
18507 @itemx #pragma implementation "@var{objects}.h"
18508 @kindex #pragma implementation
18509 Use this pragma in a @emph{main input file}, when you want full output from
18510 included header files to be generated (and made globally visible).  The
18511 included header file, in turn, should use @samp{#pragma interface}.
18512 Backup copies of inline member functions, debugging information, and the
18513 internal tables used to implement virtual functions are all generated in
18514 implementation files.
18515
18516 @cindex implied @code{#pragma implementation}
18517 @cindex @code{#pragma implementation}, implied
18518 @cindex naming convention, implementation headers
18519 If you use @samp{#pragma implementation} with no argument, it applies to
18520 an include file with the same basename@footnote{A file's @dfn{basename}
18521 is the name stripped of all leading path information and of trailing
18522 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
18523 file.  For example, in @file{allclass.cc}, giving just
18524 @samp{#pragma implementation}
18525 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
18526
18527 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
18528 an implementation file whenever you would include it from
18529 @file{allclass.cc} even if you never specified @samp{#pragma
18530 implementation}.  This was deemed to be more trouble than it was worth,
18531 however, and disabled.
18532
18533 Use the string argument if you want a single implementation file to
18534 include code from multiple header files.  (You must also use
18535 @samp{#include} to include the header file; @samp{#pragma
18536 implementation} only specifies how to use the file---it doesn't actually
18537 include it.)
18538
18539 There is no way to split up the contents of a single header file into
18540 multiple implementation files.
18541 @end table
18542
18543 @cindex inlining and C++ pragmas
18544 @cindex C++ pragmas, effect on inlining
18545 @cindex pragmas in C++, effect on inlining
18546 @samp{#pragma implementation} and @samp{#pragma interface} also have an
18547 effect on function inlining.
18548
18549 If you define a class in a header file marked with @samp{#pragma
18550 interface}, the effect on an inline function defined in that class is
18551 similar to an explicit @code{extern} declaration---the compiler emits
18552 no code at all to define an independent version of the function.  Its
18553 definition is used only for inlining with its callers.
18554
18555 @opindex fno-implement-inlines
18556 Conversely, when you include the same header file in a main source file
18557 that declares it as @samp{#pragma implementation}, the compiler emits
18558 code for the function itself; this defines a version of the function
18559 that can be found via pointers (or by callers compiled without
18560 inlining).  If all calls to the function can be inlined, you can avoid
18561 emitting the function by compiling with @option{-fno-implement-inlines}.
18562 If any calls are not inlined, you will get linker errors.
18563
18564 @node Template Instantiation
18565 @section Where's the Template?
18566 @cindex template instantiation
18567
18568 C++ templates are the first language feature to require more
18569 intelligence from the environment than one usually finds on a UNIX
18570 system.  Somehow the compiler and linker have to make sure that each
18571 template instance occurs exactly once in the executable if it is needed,
18572 and not at all otherwise.  There are two basic approaches to this
18573 problem, which are referred to as the Borland model and the Cfront model.
18574
18575 @table @asis
18576 @item Borland model
18577 Borland C++ solved the template instantiation problem by adding the code
18578 equivalent of common blocks to their linker; the compiler emits template
18579 instances in each translation unit that uses them, and the linker
18580 collapses them together.  The advantage of this model is that the linker
18581 only has to consider the object files themselves; there is no external
18582 complexity to worry about.  This disadvantage is that compilation time
18583 is increased because the template code is being compiled repeatedly.
18584 Code written for this model tends to include definitions of all
18585 templates in the header file, since they must be seen to be
18586 instantiated.
18587
18588 @item Cfront model
18589 The AT&T C++ translator, Cfront, solved the template instantiation
18590 problem by creating the notion of a template repository, an
18591 automatically maintained place where template instances are stored.  A
18592 more modern version of the repository works as follows: As individual
18593 object files are built, the compiler places any template definitions and
18594 instantiations encountered in the repository.  At link time, the link
18595 wrapper adds in the objects in the repository and compiles any needed
18596 instances that were not previously emitted.  The advantages of this
18597 model are more optimal compilation speed and the ability to use the
18598 system linker; to implement the Borland model a compiler vendor also
18599 needs to replace the linker.  The disadvantages are vastly increased
18600 complexity, and thus potential for error; for some code this can be
18601 just as transparent, but in practice it can been very difficult to build
18602 multiple programs in one directory and one program in multiple
18603 directories.  Code written for this model tends to separate definitions
18604 of non-inline member templates into a separate file, which should be
18605 compiled separately.
18606 @end table
18607
18608 When used with GNU ld version 2.8 or later on an ELF system such as
18609 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
18610 Borland model.  On other systems, G++ implements neither automatic
18611 model.
18612
18613 You have the following options for dealing with template instantiations:
18614
18615 @enumerate
18616 @item
18617 @opindex frepo
18618 Compile your template-using code with @option{-frepo}.  The compiler
18619 generates files with the extension @samp{.rpo} listing all of the
18620 template instantiations used in the corresponding object files that
18621 could be instantiated there; the link wrapper, @samp{collect2},
18622 then updates the @samp{.rpo} files to tell the compiler where to place
18623 those instantiations and rebuild any affected object files.  The
18624 link-time overhead is negligible after the first pass, as the compiler
18625 continues to place the instantiations in the same files.
18626
18627 This is your best option for application code written for the Borland
18628 model, as it just works.  Code written for the Cfront model 
18629 needs to be modified so that the template definitions are available at
18630 one or more points of instantiation; usually this is as simple as adding
18631 @code{#include <tmethods.cc>} to the end of each template header.
18632
18633 For library code, if you want the library to provide all of the template
18634 instantiations it needs, just try to link all of its object files
18635 together; the link will fail, but cause the instantiations to be
18636 generated as a side effect.  Be warned, however, that this may cause
18637 conflicts if multiple libraries try to provide the same instantiations.
18638 For greater control, use explicit instantiation as described in the next
18639 option.
18640
18641 @item
18642 @opindex fno-implicit-templates
18643 Compile your code with @option{-fno-implicit-templates} to disable the
18644 implicit generation of template instances, and explicitly instantiate
18645 all the ones you use.  This approach requires more knowledge of exactly
18646 which instances you need than do the others, but it's less
18647 mysterious and allows greater control.  You can scatter the explicit
18648 instantiations throughout your program, perhaps putting them in the
18649 translation units where the instances are used or the translation units
18650 that define the templates themselves; you can put all of the explicit
18651 instantiations you need into one big file; or you can create small files
18652 like
18653
18654 @smallexample
18655 #include "Foo.h"
18656 #include "Foo.cc"
18657
18658 template class Foo<int>;
18659 template ostream& operator <<
18660                 (ostream&, const Foo<int>&);
18661 @end smallexample
18662
18663 @noindent
18664 for each of the instances you need, and create a template instantiation
18665 library from those.
18666
18667 If you are using Cfront-model code, you can probably get away with not
18668 using @option{-fno-implicit-templates} when compiling files that don't
18669 @samp{#include} the member template definitions.
18670
18671 If you use one big file to do the instantiations, you may want to
18672 compile it without @option{-fno-implicit-templates} so you get all of the
18673 instances required by your explicit instantiations (but not by any
18674 other files) without having to specify them as well.
18675
18676 The ISO C++ 2011 standard allows forward declaration of explicit
18677 instantiations (with @code{extern}). G++ supports explicit instantiation
18678 declarations in C++98 mode and has extended the template instantiation
18679 syntax to support instantiation of the compiler support data for a
18680 template class (i.e.@: the vtable) without instantiating any of its
18681 members (with @code{inline}), and instantiation of only the static data
18682 members of a template class, without the support data or member
18683 functions (with @code{static}):
18684
18685 @smallexample
18686 extern template int max (int, int);
18687 inline template class Foo<int>;
18688 static template class Foo<int>;
18689 @end smallexample
18690
18691 @item
18692 Do nothing.  Pretend G++ does implement automatic instantiation
18693 management.  Code written for the Borland model works fine, but
18694 each translation unit contains instances of each of the templates it
18695 uses.  In a large program, this can lead to an unacceptable amount of code
18696 duplication.
18697 @end enumerate
18698
18699 @node Bound member functions
18700 @section Extracting the function pointer from a bound pointer to member function
18701 @cindex pmf
18702 @cindex pointer to member function
18703 @cindex bound pointer to member function
18704
18705 In C++, pointer to member functions (PMFs) are implemented using a wide
18706 pointer of sorts to handle all the possible call mechanisms; the PMF
18707 needs to store information about how to adjust the @samp{this} pointer,
18708 and if the function pointed to is virtual, where to find the vtable, and
18709 where in the vtable to look for the member function.  If you are using
18710 PMFs in an inner loop, you should really reconsider that decision.  If
18711 that is not an option, you can extract the pointer to the function that
18712 would be called for a given object/PMF pair and call it directly inside
18713 the inner loop, to save a bit of time.
18714
18715 Note that you still pay the penalty for the call through a
18716 function pointer; on most modern architectures, such a call defeats the
18717 branch prediction features of the CPU@.  This is also true of normal
18718 virtual function calls.
18719
18720 The syntax for this extension is
18721
18722 @smallexample
18723 extern A a;
18724 extern int (A::*fp)();
18725 typedef int (*fptr)(A *);
18726
18727 fptr p = (fptr)(a.*fp);
18728 @end smallexample
18729
18730 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
18731 no object is needed to obtain the address of the function.  They can be
18732 converted to function pointers directly:
18733
18734 @smallexample
18735 fptr p1 = (fptr)(&A::foo);
18736 @end smallexample
18737
18738 @opindex Wno-pmf-conversions
18739 You must specify @option{-Wno-pmf-conversions} to use this extension.
18740
18741 @node C++ Attributes
18742 @section C++-Specific Variable, Function, and Type Attributes
18743
18744 Some attributes only make sense for C++ programs.
18745
18746 @table @code
18747 @item abi_tag ("@var{tag}", ...)
18748 @cindex @code{abi_tag} attribute
18749 The @code{abi_tag} attribute can be applied to a function or class
18750 declaration.  It modifies the mangled name of the function or class to
18751 incorporate the tag name, in order to distinguish the function or
18752 class from an earlier version with a different ABI; perhaps the class
18753 has changed size, or the function has a different return type that is
18754 not encoded in the mangled name.
18755
18756 The argument can be a list of strings of arbitrary length.  The
18757 strings are sorted on output, so the order of the list is
18758 unimportant.
18759
18760 A redeclaration of a function or class must not add new ABI tags,
18761 since doing so would change the mangled name.
18762
18763 The ABI tags apply to a name, so all instantiations and
18764 specializations of a template have the same tags.  The attribute will
18765 be ignored if applied to an explicit specialization or instantiation.
18766
18767 The @option{-Wabi-tag} flag enables a warning about a class which does
18768 not have all the ABI tags used by its subobjects and virtual functions; for users with code
18769 that needs to coexist with an earlier ABI, using this option can help
18770 to find all affected types that need to be tagged.
18771
18772 @item init_priority (@var{priority})
18773 @cindex @code{init_priority} attribute
18774
18775
18776 In Standard C++, objects defined at namespace scope are guaranteed to be
18777 initialized in an order in strict accordance with that of their definitions
18778 @emph{in a given translation unit}.  No guarantee is made for initializations
18779 across translation units.  However, GNU C++ allows users to control the
18780 order of initialization of objects defined at namespace scope with the
18781 @code{init_priority} attribute by specifying a relative @var{priority},
18782 a constant integral expression currently bounded between 101 and 65535
18783 inclusive.  Lower numbers indicate a higher priority.
18784
18785 In the following example, @code{A} would normally be created before
18786 @code{B}, but the @code{init_priority} attribute reverses that order:
18787
18788 @smallexample
18789 Some_Class  A  __attribute__ ((init_priority (2000)));
18790 Some_Class  B  __attribute__ ((init_priority (543)));
18791 @end smallexample
18792
18793 @noindent
18794 Note that the particular values of @var{priority} do not matter; only their
18795 relative ordering.
18796
18797 @item java_interface
18798 @cindex @code{java_interface} attribute
18799
18800 This type attribute informs C++ that the class is a Java interface.  It may
18801 only be applied to classes declared within an @code{extern "Java"} block.
18802 Calls to methods declared in this interface are dispatched using GCJ's
18803 interface table mechanism, instead of regular virtual table dispatch.
18804
18805 @item warn_unused
18806 @cindex @code{warn_unused} attribute
18807
18808 For C++ types with non-trivial constructors and/or destructors it is
18809 impossible for the compiler to determine whether a variable of this
18810 type is truly unused if it is not referenced. This type attribute
18811 informs the compiler that variables of this type should be warned
18812 about if they appear to be unused, just like variables of fundamental
18813 types.
18814
18815 This attribute is appropriate for types which just represent a value,
18816 such as @code{std::string}; it is not appropriate for types which
18817 control a resource, such as @code{std::mutex}.
18818
18819 This attribute is also accepted in C, but it is unnecessary because C
18820 does not have constructors or destructors.
18821
18822 @end table
18823
18824 See also @ref{Namespace Association}.
18825
18826 @node Function Multiversioning
18827 @section Function Multiversioning
18828 @cindex function versions
18829
18830 With the GNU C++ front end, for x86 targets, you may specify multiple
18831 versions of a function, where each function is specialized for a
18832 specific target feature.  At runtime, the appropriate version of the
18833 function is automatically executed depending on the characteristics of
18834 the execution platform.  Here is an example.
18835
18836 @smallexample
18837 __attribute__ ((target ("default")))
18838 int foo ()
18839 @{
18840   // The default version of foo.
18841   return 0;
18842 @}
18843
18844 __attribute__ ((target ("sse4.2")))
18845 int foo ()
18846 @{
18847   // foo version for SSE4.2
18848   return 1;
18849 @}
18850
18851 __attribute__ ((target ("arch=atom")))
18852 int foo ()
18853 @{
18854   // foo version for the Intel ATOM processor
18855   return 2;
18856 @}
18857
18858 __attribute__ ((target ("arch=amdfam10")))
18859 int foo ()
18860 @{
18861   // foo version for the AMD Family 0x10 processors.
18862   return 3;
18863 @}
18864
18865 int main ()
18866 @{
18867   int (*p)() = &foo;
18868   assert ((*p) () == foo ());
18869   return 0;
18870 @}
18871 @end smallexample
18872
18873 In the above example, four versions of function foo are created. The
18874 first version of foo with the target attribute "default" is the default
18875 version.  This version gets executed when no other target specific
18876 version qualifies for execution on a particular platform. A new version
18877 of foo is created by using the same function signature but with a
18878 different target string.  Function foo is called or a pointer to it is
18879 taken just like a regular function.  GCC takes care of doing the
18880 dispatching to call the right version at runtime.  Refer to the
18881 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
18882 Function Multiversioning} for more details.
18883
18884 @node Namespace Association
18885 @section Namespace Association
18886
18887 @strong{Caution:} The semantics of this extension are equivalent
18888 to C++ 2011 inline namespaces.  Users should use inline namespaces
18889 instead as this extension will be removed in future versions of G++.
18890
18891 A using-directive with @code{__attribute ((strong))} is stronger
18892 than a normal using-directive in two ways:
18893
18894 @itemize @bullet
18895 @item
18896 Templates from the used namespace can be specialized and explicitly
18897 instantiated as though they were members of the using namespace.
18898
18899 @item
18900 The using namespace is considered an associated namespace of all
18901 templates in the used namespace for purposes of argument-dependent
18902 name lookup.
18903 @end itemize
18904
18905 The used namespace must be nested within the using namespace so that
18906 normal unqualified lookup works properly.
18907
18908 This is useful for composing a namespace transparently from
18909 implementation namespaces.  For example:
18910
18911 @smallexample
18912 namespace std @{
18913   namespace debug @{
18914     template <class T> struct A @{ @};
18915   @}
18916   using namespace debug __attribute ((__strong__));
18917   template <> struct A<int> @{ @};   // @r{OK to specialize}
18918
18919   template <class T> void f (A<T>);
18920 @}
18921
18922 int main()
18923 @{
18924   f (std::A<float>());             // @r{lookup finds} std::f
18925   f (std::A<int>());
18926 @}
18927 @end smallexample
18928
18929 @node Type Traits
18930 @section Type Traits
18931
18932 The C++ front end implements syntactic extensions that allow
18933 compile-time determination of 
18934 various characteristics of a type (or of a
18935 pair of types).
18936
18937 @table @code
18938 @item __has_nothrow_assign (type)
18939 If @code{type} is const qualified or is a reference type then the trait is
18940 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
18941 is true, else if @code{type} is a cv class or union type with copy assignment
18942 operators that are known not to throw an exception then the trait is true,
18943 else it is false.  Requires: @code{type} shall be a complete type,
18944 (possibly cv-qualified) @code{void}, or an array of unknown bound.
18945
18946 @item __has_nothrow_copy (type)
18947 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
18948 @code{type} is a cv class or union type with copy constructors that
18949 are known not to throw an exception then the trait is true, else it is false.
18950 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
18951 @code{void}, or an array of unknown bound.
18952
18953 @item __has_nothrow_constructor (type)
18954 If @code{__has_trivial_constructor (type)} is true then the trait is
18955 true, else if @code{type} is a cv class or union type (or array
18956 thereof) with a default constructor that is known not to throw an
18957 exception then the trait is true, else it is false.  Requires:
18958 @code{type} shall be a complete type, (possibly cv-qualified)
18959 @code{void}, or an array of unknown bound.
18960
18961 @item __has_trivial_assign (type)
18962 If @code{type} is const qualified or is a reference type then the trait is
18963 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
18964 true, else if @code{type} is a cv class or union type with a trivial
18965 copy assignment ([class.copy]) then the trait is true, else it is
18966 false.  Requires: @code{type} shall be a complete type, (possibly
18967 cv-qualified) @code{void}, or an array of unknown bound.
18968
18969 @item __has_trivial_copy (type)
18970 If @code{__is_pod (type)} is true or @code{type} is a reference type
18971 then the trait is true, else if @code{type} is a cv class or union type
18972 with a trivial copy constructor ([class.copy]) then the trait
18973 is true, else it is false.  Requires: @code{type} shall be a complete
18974 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18975
18976 @item __has_trivial_constructor (type)
18977 If @code{__is_pod (type)} is true then the trait is true, else if
18978 @code{type} is a cv class or union type (or array thereof) with a
18979 trivial default constructor ([class.ctor]) then the trait is true,
18980 else it is false.  Requires: @code{type} shall be a complete
18981 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18982
18983 @item __has_trivial_destructor (type)
18984 If @code{__is_pod (type)} is true or @code{type} is a reference type then
18985 the trait is true, else if @code{type} is a cv class or union type (or
18986 array thereof) with a trivial destructor ([class.dtor]) then the trait
18987 is true, else it is false.  Requires: @code{type} shall be a complete
18988 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
18989
18990 @item __has_virtual_destructor (type)
18991 If @code{type} is a class type with a virtual destructor
18992 ([class.dtor]) then the trait is true, else it is false.  Requires:
18993 @code{type} shall be a complete type, (possibly cv-qualified)
18994 @code{void}, or an array of unknown bound.
18995
18996 @item __is_abstract (type)
18997 If @code{type} is an abstract class ([class.abstract]) then the trait
18998 is true, else it is false.  Requires: @code{type} shall be a complete
18999 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19000
19001 @item __is_base_of (base_type, derived_type)
19002 If @code{base_type} is a base class of @code{derived_type}
19003 ([class.derived]) then the trait is true, otherwise it is false.
19004 Top-level cv qualifications of @code{base_type} and
19005 @code{derived_type} are ignored.  For the purposes of this trait, a
19006 class type is considered is own base.  Requires: if @code{__is_class
19007 (base_type)} and @code{__is_class (derived_type)} are true and
19008 @code{base_type} and @code{derived_type} are not the same type
19009 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
19010 type.  Diagnostic is produced if this requirement is not met.
19011
19012 @item __is_class (type)
19013 If @code{type} is a cv class type, and not a union type
19014 ([basic.compound]) the trait is true, else it is false.
19015
19016 @item __is_empty (type)
19017 If @code{__is_class (type)} is false then the trait is false.
19018 Otherwise @code{type} is considered empty if and only if: @code{type}
19019 has no non-static data members, or all non-static data members, if
19020 any, are bit-fields of length 0, and @code{type} has no virtual
19021 members, and @code{type} has no virtual base classes, and @code{type}
19022 has no base classes @code{base_type} for which
19023 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
19024 be a complete type, (possibly cv-qualified) @code{void}, or an array
19025 of unknown bound.
19026
19027 @item __is_enum (type)
19028 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
19029 true, else it is false.
19030
19031 @item __is_literal_type (type)
19032 If @code{type} is a literal type ([basic.types]) the trait is
19033 true, else it is false.  Requires: @code{type} shall be a complete type,
19034 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19035
19036 @item __is_pod (type)
19037 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
19038 else it is false.  Requires: @code{type} shall be a complete type,
19039 (possibly cv-qualified) @code{void}, or an array of unknown bound.
19040
19041 @item __is_polymorphic (type)
19042 If @code{type} is a polymorphic class ([class.virtual]) then the trait
19043 is true, else it is false.  Requires: @code{type} shall be a complete
19044 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19045
19046 @item __is_standard_layout (type)
19047 If @code{type} is a standard-layout type ([basic.types]) the trait is
19048 true, else it is false.  Requires: @code{type} shall be a complete
19049 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19050
19051 @item __is_trivial (type)
19052 If @code{type} is a trivial type ([basic.types]) the trait is
19053 true, else it is false.  Requires: @code{type} shall be a complete
19054 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
19055
19056 @item __is_union (type)
19057 If @code{type} is a cv union type ([basic.compound]) the trait is
19058 true, else it is false.
19059
19060 @item __underlying_type (type)
19061 The underlying type of @code{type}.  Requires: @code{type} shall be
19062 an enumeration type ([dcl.enum]).
19063
19064 @end table
19065
19066 @node Java Exceptions
19067 @section Java Exceptions
19068
19069 The Java language uses a slightly different exception handling model
19070 from C++.  Normally, GNU C++ automatically detects when you are
19071 writing C++ code that uses Java exceptions, and handle them
19072 appropriately.  However, if C++ code only needs to execute destructors
19073 when Java exceptions are thrown through it, GCC guesses incorrectly.
19074 Sample problematic code is:
19075
19076 @smallexample
19077   struct S @{ ~S(); @};
19078   extern void bar();    // @r{is written in Java, and may throw exceptions}
19079   void foo()
19080   @{
19081     S s;
19082     bar();
19083   @}
19084 @end smallexample
19085
19086 @noindent
19087 The usual effect of an incorrect guess is a link failure, complaining of
19088 a missing routine called @samp{__gxx_personality_v0}.
19089
19090 You can inform the compiler that Java exceptions are to be used in a
19091 translation unit, irrespective of what it might think, by writing
19092 @samp{@w{#pragma GCC java_exceptions}} at the head of the file.  This
19093 @samp{#pragma} must appear before any functions that throw or catch
19094 exceptions, or run destructors when exceptions are thrown through them.
19095
19096 You cannot mix Java and C++ exceptions in the same translation unit.  It
19097 is believed to be safe to throw a C++ exception from one file through
19098 another file compiled for the Java exception model, or vice versa, but
19099 there may be bugs in this area.
19100
19101 @node Deprecated Features
19102 @section Deprecated Features
19103
19104 In the past, the GNU C++ compiler was extended to experiment with new
19105 features, at a time when the C++ language was still evolving.  Now that
19106 the C++ standard is complete, some of those features are superseded by
19107 superior alternatives.  Using the old features might cause a warning in
19108 some cases that the feature will be dropped in the future.  In other
19109 cases, the feature might be gone already.
19110
19111 While the list below is not exhaustive, it documents some of the options
19112 that are now deprecated:
19113
19114 @table @code
19115 @item -fexternal-templates
19116 @itemx -falt-external-templates
19117 These are two of the many ways for G++ to implement template
19118 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
19119 defines how template definitions have to be organized across
19120 implementation units.  G++ has an implicit instantiation mechanism that
19121 should work just fine for standard-conforming code.
19122
19123 @item -fstrict-prototype
19124 @itemx -fno-strict-prototype
19125 Previously it was possible to use an empty prototype parameter list to
19126 indicate an unspecified number of parameters (like C), rather than no
19127 parameters, as C++ demands.  This feature has been removed, except where
19128 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
19129 @end table
19130
19131 G++ allows a virtual function returning @samp{void *} to be overridden
19132 by one returning a different pointer type.  This extension to the
19133 covariant return type rules is now deprecated and will be removed from a
19134 future version.
19135
19136 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
19137 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
19138 and are now removed from G++.  Code using these operators should be
19139 modified to use @code{std::min} and @code{std::max} instead.
19140
19141 The named return value extension has been deprecated, and is now
19142 removed from G++.
19143
19144 The use of initializer lists with new expressions has been deprecated,
19145 and is now removed from G++.
19146
19147 Floating and complex non-type template parameters have been deprecated,
19148 and are now removed from G++.
19149
19150 The implicit typename extension has been deprecated and is now
19151 removed from G++.
19152
19153 The use of default arguments in function pointers, function typedefs
19154 and other places where they are not permitted by the standard is
19155 deprecated and will be removed from a future version of G++.
19156
19157 G++ allows floating-point literals to appear in integral constant expressions,
19158 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
19159 This extension is deprecated and will be removed from a future version.
19160
19161 G++ allows static data members of const floating-point type to be declared
19162 with an initializer in a class definition. The standard only allows
19163 initializers for static members of const integral types and const
19164 enumeration types so this extension has been deprecated and will be removed
19165 from a future version.
19166
19167 @node Backwards Compatibility
19168 @section Backwards Compatibility
19169 @cindex Backwards Compatibility
19170 @cindex ARM [Annotated C++ Reference Manual]
19171
19172 Now that there is a definitive ISO standard C++, G++ has a specification
19173 to adhere to.  The C++ language evolved over time, and features that
19174 used to be acceptable in previous drafts of the standard, such as the ARM
19175 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
19176 compilation of C++ written to such drafts, G++ contains some backwards
19177 compatibilities.  @emph{All such backwards compatibility features are
19178 liable to disappear in future versions of G++.} They should be considered
19179 deprecated.   @xref{Deprecated Features}.
19180
19181 @table @code
19182 @item For scope
19183 If a variable is declared at for scope, it used to remain in scope until
19184 the end of the scope that contained the for statement (rather than just
19185 within the for scope).  G++ retains this, but issues a warning, if such a
19186 variable is accessed outside the for scope.
19187
19188 @item Implicit C language
19189 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
19190 scope to set the language.  On such systems, all header files are
19191 implicitly scoped inside a C language scope.  Also, an empty prototype
19192 @code{()} is treated as an unspecified number of arguments, rather
19193 than no arguments, as C++ demands.
19194 @end table
19195
19196 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
19197 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr followign