f34f0f955e94a415bf17de620274ca4acfd38045
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001,
2 @c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 @c Free Software Foundation, Inc.
4
5 @c This is part of the GCC manual.
6 @c For copying conditions, see the file gcc.texi.
7
8 @node C Extensions
9 @chapter Extensions to the C Language Family
10 @cindex extensions, C language
11 @cindex C language extensions
12
13 @opindex pedantic
14 GNU C provides several language features not found in ISO standard C@.
15 (The @option{-pedantic} option directs GCC to print a warning message if
16 any of these features is used.) To test for the availability of these
17 features in conditional compilation, check for a predefined macro
18 @code{__GNUC__}, which is always defined under GCC@.
19
20 These extensions are available in C and Objective-C@. Most of them are
21 also available in C++. @xref{C++ Extensions,,Extensions to the
22 C++ Language}, for extensions that apply @emph{only} to C++.
23
24 Some features that are in ISO C99 but not C90 or C++ are also, as
25 extensions, accepted by GCC in C90 mode and in C++.
26
27 @menu
28 * Statement Exprs:: Putting statements and declarations inside expressions.
29 * Local Labels:: Labels local to a block.
30 * Labels as Values:: Getting pointers to labels, and computed gotos.
31 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
32 * Constructing Calls:: Dispatching a call to another function.
33 * Typeof:: @code{typeof}: referring to the type of an expression.
34 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
35 * Long Long:: Double-word integers---@code{long long int}.
36 * __int128:: 128-bit integers---@code{__int128}.
37 * Complex:: Data types for complex numbers.
38 * Floating Types:: Additional Floating Types.
39 * Half-Precision:: Half-Precision Floating Point.
40 * Decimal Float:: Decimal Floating Types.
41 * Hex Floats:: Hexadecimal floating-point constants.
42 * Fixed-Point:: Fixed-Point Types.
43 * Named Address Spaces::Named address spaces.
44 * Zero Length:: Zero-length arrays.
45 * Variable Length:: Arrays whose length is computed at run time.
46 * Empty Structures:: Structures with no members.
47 * Variadic Macros:: Macros with a variable number of arguments.
48 * Escaped Newlines:: Slightly looser rules for escaped newlines.
49 * Subscripting:: Any array can be subscripted, even if not an lvalue.
50 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
51 * Initializers:: Non-constant initializers.
52 * Compound Literals:: Compound literals give structures, unions
53 or arrays as values.
54 * Designated Inits:: Labeling elements of initializers.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Case Ranges:: `case 1 ... 9' and such.
57 * Mixed Declarations:: Mixing declarations and code.
58 * Function Attributes:: Declaring that functions have no side effects,
59 or that they can never return.
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 * Extended Asm:: Assembler instructions with C expressions as operands.
71 (With them you can define ``built-in'' functions.)
72 * Constraints:: Constraints for asm operands
73 * Asm Labels:: Specifying the assembler name to use for a C symbol.
74 * Explicit Reg Vars:: Defining variables residing in specified registers.
75 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
76 * Incomplete Enums:: @code{enum foo;}, with details to follow.
77 * Function Names:: Printable strings which are the name of the current
78 function.
79 * Return Address:: Getting the return or frame address of a function.
80 * Vector Extensions:: Using vector instructions through built-in functions.
81 * Offsetof:: Special syntax for implementing @code{offsetof}.
82 * __sync Builtins:: Legacy built-in functions for atomic memory access.
83 * __atomic Builtins:: Atomic built-in functions with memory model.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Other Builtins:: Other built-in functions.
87 * Target Builtins:: Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas:: Pragmas accepted by GCC.
90 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
91 * Thread-Local:: Per-thread variables.
92 * Binary constants:: Binary constants using the @samp{0b} prefix.
93 @end menu
94
95 @node Statement Exprs
96 @section Statements and Declarations in Expressions
97 @cindex statements inside expressions
98 @cindex declarations inside expressions
99 @cindex expressions containing statements
100 @cindex macros, statements in expressions
101
102 @c the above section title wrapped and causes an underfull hbox.. i
103 @c changed it from "within" to "in". --mew 4feb93
104 A compound statement enclosed in parentheses may appear as an expression
105 in GNU C@. This allows you to use loops, switches, and local variables
106 within an expression.
107
108 Recall that a compound statement is a sequence of statements surrounded
109 by braces; in this construct, parentheses go around the braces. For
110 example:
111
112 @smallexample
113 (@{ int y = foo (); int z;
114 if (y > 0) z = y;
115 else z = - y;
116 z; @})
117 @end smallexample
118
119 @noindent
120 is a valid (though slightly more complex than necessary) expression
121 for the absolute value of @code{foo ()}.
122
123 The last thing in the compound statement should be an expression
124 followed by a semicolon; the value of this subexpression serves as the
125 value of the entire construct. (If you use some other kind of statement
126 last within the braces, the construct has type @code{void}, and thus
127 effectively no value.)
128
129 This feature is especially useful in making macro definitions ``safe'' (so
130 that they evaluate each operand exactly once). For example, the
131 ``maximum'' function is commonly defined as a macro in standard C as
132 follows:
133
134 @smallexample
135 #define max(a,b) ((a) > (b) ? (a) : (b))
136 @end smallexample
137
138 @noindent
139 @cindex side effects, macro argument
140 But this definition computes either @var{a} or @var{b} twice, with bad
141 results if the operand has side effects. In GNU C, if you know the
142 type of the operands (here taken as @code{int}), you can define
143 the macro safely as follows:
144
145 @smallexample
146 #define maxint(a,b) \
147 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
148 @end smallexample
149
150 Embedded statements are not allowed in constant expressions, such as
151 the value of an enumeration constant, the width of a bit-field, or
152 the initial value of a static variable.
153
154 If you don't know the type of the operand, you can still do this, but you
155 must use @code{typeof} (@pxref{Typeof}).
156
157 In G++, the result value of a statement expression undergoes array and
158 function pointer decay, and is returned by value to the enclosing
159 expression. For instance, if @code{A} is a class, then
160
161 @smallexample
162 A a;
163
164 (@{a;@}).Foo ()
165 @end smallexample
166
167 @noindent
168 constructs a temporary @code{A} object to hold the result of the
169 statement expression, and that is used to invoke @code{Foo}.
170 Therefore the @code{this} pointer observed by @code{Foo} is not the
171 address of @code{a}.
172
173 Any temporaries created within a statement within a statement expression
174 are destroyed at the statement's end. This makes statement
175 expressions inside macros slightly different from function calls. In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call. In the statement expression case they are destroyed during
179 the statement expression. For instance,
180
181 @smallexample
182 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
183 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
184
185 void foo ()
186 @{
187 macro (X ());
188 function (X ());
189 @}
190 @end smallexample
191
192 @noindent
193 has different places where temporaries are destroyed. For the
194 @code{macro} case, the temporary @code{X} is destroyed just after
195 the initialization of @code{b}. In the @code{function} case that
196 temporary is destroyed when the function returns.
197
198 These considerations mean that it is probably a bad idea to use
199 statement-expressions of this form in header files that are designed to
200 work with C++. (Note that some versions of the GNU C Library contained
201 header files using statement-expression that lead to precisely this
202 bug.)
203
204 Jumping into a statement expression with @code{goto} or using a
205 @code{switch} statement outside the statement expression with a
206 @code{case} or @code{default} label inside the statement expression is
207 not permitted. Jumping into a statement expression with a computed
208 @code{goto} (@pxref{Labels as Values}) yields undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression. In any case, as with a function call the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression. For example,
217
218 @smallexample
219 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
221
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}. If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
226
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
231
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope. A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
236
237 A local label declaration looks like this:
238
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
242
243 @noindent
244 or
245
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
249
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
252
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself. You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
256
257 The local label feature is useful for complex macros. If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them. However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function. A
262 local label avoids this problem. For example:
263
264 @smallexample
265 #define SEARCH(value, array, target) \
266 do @{ \
267 __label__ found; \
268 typeof (target) _SEARCH_target = (target); \
269 typeof (*(array)) *_SEARCH_array = (array); \
270 int i, j; \
271 int value; \
272 for (i = 0; i < max; i++) \
273 for (j = 0; j < max; j++) \
274 if (_SEARCH_array[i][j] == _SEARCH_target) \
275 @{ (value) = i; goto found; @} \
276 (value) = -1; \
277 found:; \
278 @} while (0)
279 @end smallexample
280
281 This could also be written using a statement-expression:
282
283 @smallexample
284 #define SEARCH(array, target) \
285 (@{ \
286 __label__ found; \
287 typeof (target) _SEARCH_target = (target); \
288 typeof (*(array)) *_SEARCH_array = (array); \
289 int i, j; \
290 int value; \
291 for (i = 0; i < max; i++) \
292 for (j = 0; j < max; j++) \
293 if (_SEARCH_array[i][j] == _SEARCH_target) \
294 @{ value = i; goto found; @} \
295 value = -1; \
296 found: \
297 value; \
298 @})
299 @end smallexample
300
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any. @xref{Nested Functions}, for details.
303
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
310
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}. The
313 value has type @code{void *}. This value is a constant and can be used
314 wherever a constant of that type is valid. For example:
315
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
321
322 To use these values, you need to be able to jump to one. This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}. For example,
327
328 @smallexample
329 goto *ptr;
330 @end smallexample
331
332 @noindent
333 Any expression of type @code{void *} is allowed.
334
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
337
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
341
342 @noindent
343 Then you can select a label with indexing, like this:
344
345 @smallexample
346 goto *array[i];
347 @end smallexample
348
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
352
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement. The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
357
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
361
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen. The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
366
367 An alternate way to write the above example is
368
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371 &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
374
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
379
380 The @code{&&foo} expressions for the same label might have different
381 values if the containing function is inlined or cloned. If a program
382 relies on them being always the same,
383 @code{__attribute__((__noinline__,__noclone__))} should be used to
384 prevent inlining and cloning. If @code{&&foo} is used in a static
385 variable initializer, inlining and cloning is forbidden.
386
387 @node Nested Functions
388 @section Nested Functions
389 @cindex nested functions
390 @cindex downward funargs
391 @cindex thunks
392
393 A @dfn{nested function} is a function defined inside another function.
394 (Nested functions are not supported for GNU C++.) The nested function's
395 name is local to the block where it is defined. For example, here we
396 define a nested function named @code{square}, and call it twice:
397
398 @smallexample
399 @group
400 foo (double a, double b)
401 @{
402 double square (double z) @{ return z * z; @}
403
404 return square (a) + square (b);
405 @}
406 @end group
407 @end smallexample
408
409 The nested function can access all the variables of the containing
410 function that are visible at the point of its definition. This is
411 called @dfn{lexical scoping}. For example, here we show a nested
412 function which uses an inherited variable named @code{offset}:
413
414 @smallexample
415 @group
416 bar (int *array, int offset, int size)
417 @{
418 int access (int *array, int index)
419 @{ return array[index + offset]; @}
420 int i;
421 /* @r{@dots{}} */
422 for (i = 0; i < size; i++)
423 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
424 @}
425 @end group
426 @end smallexample
427
428 Nested function definitions are permitted within functions in the places
429 where variable definitions are allowed; that is, in any block, mixed
430 with the other declarations and statements in the block.
431
432 It is possible to call the nested function from outside the scope of its
433 name by storing its address or passing the address to another function:
434
435 @smallexample
436 hack (int *array, int size)
437 @{
438 void store (int index, int value)
439 @{ array[index] = value; @}
440
441 intermediate (store, size);
442 @}
443 @end smallexample
444
445 Here, the function @code{intermediate} receives the address of
446 @code{store} as an argument. If @code{intermediate} calls @code{store},
447 the arguments given to @code{store} are used to store into @code{array}.
448 But this technique works only so long as the containing function
449 (@code{hack}, in this example) does not exit.
450
451 If you try to call the nested function through its address after the
452 containing function exits, all hell breaks loose. If you try
453 to call it after a containing scope level exits, and if it refers
454 to some of the variables that are no longer in scope, you may be lucky,
455 but it's not wise to take the risk. If, however, the nested function
456 does not refer to anything that has gone out of scope, you should be
457 safe.
458
459 GCC implements taking the address of a nested function using a technique
460 called @dfn{trampolines}. This technique was described in
461 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
462 C++ Conference Proceedings, October 17-21, 1988).
463
464 A nested function can jump to a label inherited from a containing
465 function, provided the label is explicitly declared in the containing
466 function (@pxref{Local Labels}). Such a jump returns instantly to the
467 containing function, exiting the nested function that did the
468 @code{goto} and any intermediate functions as well. Here is an example:
469
470 @smallexample
471 @group
472 bar (int *array, int offset, int size)
473 @{
474 __label__ failure;
475 int access (int *array, int index)
476 @{
477 if (index > size)
478 goto failure;
479 return array[index + offset];
480 @}
481 int i;
482 /* @r{@dots{}} */
483 for (i = 0; i < size; i++)
484 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
485 /* @r{@dots{}} */
486 return 0;
487
488 /* @r{Control comes here from @code{access}
489 if it detects an error.} */
490 failure:
491 return -1;
492 @}
493 @end group
494 @end smallexample
495
496 A nested function always has no linkage. Declaring one with
497 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
498 before its definition, use @code{auto} (which is otherwise meaningless
499 for function declarations).
500
501 @smallexample
502 bar (int *array, int offset, int size)
503 @{
504 __label__ failure;
505 auto int access (int *, int);
506 /* @r{@dots{}} */
507 int access (int *array, int index)
508 @{
509 if (index > size)
510 goto failure;
511 return array[index + offset];
512 @}
513 /* @r{@dots{}} */
514 @}
515 @end smallexample
516
517 @node Constructing Calls
518 @section Constructing Function Calls
519 @cindex constructing calls
520 @cindex forwarding calls
521
522 Using the built-in functions described below, you can record
523 the arguments a function received, and call another function
524 with the same arguments, without knowing the number or types
525 of the arguments.
526
527 You can also record the return value of that function call,
528 and later return that value, without knowing what data type
529 the function tried to return (as long as your caller expects
530 that data type).
531
532 However, these built-in functions may interact badly with some
533 sophisticated features or other extensions of the language. It
534 is, therefore, not recommended to use them outside very simple
535 functions acting as mere forwarders for their arguments.
536
537 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
538 This built-in function returns a pointer to data
539 describing how to perform a call with the same arguments as are passed
540 to the current function.
541
542 The function saves the arg pointer register, structure value address,
543 and all registers that might be used to pass arguments to a function
544 into a block of memory allocated on the stack. Then it returns the
545 address of that block.
546 @end deftypefn
547
548 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
549 This built-in function invokes @var{function}
550 with a copy of the parameters described by @var{arguments}
551 and @var{size}.
552
553 The value of @var{arguments} should be the value returned by
554 @code{__builtin_apply_args}. The argument @var{size} specifies the size
555 of the stack argument data, in bytes.
556
557 This function returns a pointer to data describing
558 how to return whatever value is returned by @var{function}. The data
559 is saved in a block of memory allocated on the stack.
560
561 It is not always simple to compute the proper value for @var{size}. The
562 value is used by @code{__builtin_apply} to compute the amount of data
563 that should be pushed on the stack and copied from the incoming argument
564 area.
565 @end deftypefn
566
567 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
568 This built-in function returns the value described by @var{result} from
569 the containing function. You should specify, for @var{result}, a value
570 returned by @code{__builtin_apply}.
571 @end deftypefn
572
573 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
574 This built-in function represents all anonymous arguments of an inline
575 function. It can be used only in inline functions that are always
576 inlined, never compiled as a separate function, such as those using
577 @code{__attribute__ ((__always_inline__))} or
578 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
579 It must be only passed as last argument to some other function
580 with variable arguments. This is useful for writing small wrapper
581 inlines for variable argument functions, when using preprocessor
582 macros is undesirable. For example:
583 @smallexample
584 extern int myprintf (FILE *f, const char *format, ...);
585 extern inline __attribute__ ((__gnu_inline__)) int
586 myprintf (FILE *f, const char *format, ...)
587 @{
588 int r = fprintf (f, "myprintf: ");
589 if (r < 0)
590 return r;
591 int s = fprintf (f, format, __builtin_va_arg_pack ());
592 if (s < 0)
593 return s;
594 return r + s;
595 @}
596 @end smallexample
597 @end deftypefn
598
599 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
600 This built-in function returns the number of anonymous arguments of
601 an inline function. It can be used only in inline functions that
602 are always inlined, never compiled as a separate function, such
603 as those using @code{__attribute__ ((__always_inline__))} or
604 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
605 For example following does link- or run-time checking of open
606 arguments for optimized code:
607 @smallexample
608 #ifdef __OPTIMIZE__
609 extern inline __attribute__((__gnu_inline__)) int
610 myopen (const char *path, int oflag, ...)
611 @{
612 if (__builtin_va_arg_pack_len () > 1)
613 warn_open_too_many_arguments ();
614
615 if (__builtin_constant_p (oflag))
616 @{
617 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
618 @{
619 warn_open_missing_mode ();
620 return __open_2 (path, oflag);
621 @}
622 return open (path, oflag, __builtin_va_arg_pack ());
623 @}
624
625 if (__builtin_va_arg_pack_len () < 1)
626 return __open_2 (path, oflag);
627
628 return open (path, oflag, __builtin_va_arg_pack ());
629 @}
630 #endif
631 @end smallexample
632 @end deftypefn
633
634 @node Typeof
635 @section Referring to a Type with @code{typeof}
636 @findex typeof
637 @findex sizeof
638 @cindex macros, types of arguments
639
640 Another way to refer to the type of an expression is with @code{typeof}.
641 The syntax of using of this keyword looks like @code{sizeof}, but the
642 construct acts semantically like a type name defined with @code{typedef}.
643
644 There are two ways of writing the argument to @code{typeof}: with an
645 expression or with a type. Here is an example with an expression:
646
647 @smallexample
648 typeof (x[0](1))
649 @end smallexample
650
651 @noindent
652 This assumes that @code{x} is an array of pointers to functions;
653 the type described is that of the values of the functions.
654
655 Here is an example with a typename as the argument:
656
657 @smallexample
658 typeof (int *)
659 @end smallexample
660
661 @noindent
662 Here the type described is that of pointers to @code{int}.
663
664 If you are writing a header file that must work when included in ISO C
665 programs, write @code{__typeof__} instead of @code{typeof}.
666 @xref{Alternate Keywords}.
667
668 A @code{typeof}-construct can be used anywhere a typedef name could be
669 used. For example, you can use it in a declaration, in a cast, or inside
670 of @code{sizeof} or @code{typeof}.
671
672 The operand of @code{typeof} is evaluated for its side effects if and
673 only if it is an expression of variably modified type or the name of
674 such a type.
675
676 @code{typeof} is often useful in conjunction with the
677 statements-within-expressions feature. Here is how the two together can
678 be used to define a safe ``maximum'' macro which operates on any
679 arithmetic type and evaluates each of its arguments exactly once:
680
681 @smallexample
682 #define max(a,b) \
683 (@{ typeof (a) _a = (a); \
684 typeof (b) _b = (b); \
685 _a > _b ? _a : _b; @})
686 @end smallexample
687
688 @cindex underscores in variables in macros
689 @cindex @samp{_} in variables in macros
690 @cindex local variables in macros
691 @cindex variables, local, in macros
692 @cindex macros, local variables in
693
694 The reason for using names that start with underscores for the local
695 variables is to avoid conflicts with variable names that occur within the
696 expressions that are substituted for @code{a} and @code{b}. Eventually we
697 hope to design a new form of declaration syntax that allows you to declare
698 variables whose scopes start only after their initializers; this will be a
699 more reliable way to prevent such conflicts.
700
701 @noindent
702 Some more examples of the use of @code{typeof}:
703
704 @itemize @bullet
705 @item
706 This declares @code{y} with the type of what @code{x} points to.
707
708 @smallexample
709 typeof (*x) y;
710 @end smallexample
711
712 @item
713 This declares @code{y} as an array of such values.
714
715 @smallexample
716 typeof (*x) y[4];
717 @end smallexample
718
719 @item
720 This declares @code{y} as an array of pointers to characters:
721
722 @smallexample
723 typeof (typeof (char *)[4]) y;
724 @end smallexample
725
726 @noindent
727 It is equivalent to the following traditional C declaration:
728
729 @smallexample
730 char *y[4];
731 @end smallexample
732
733 To see the meaning of the declaration using @code{typeof}, and why it
734 might be a useful way to write, rewrite it with these macros:
735
736 @smallexample
737 #define pointer(T) typeof(T *)
738 #define array(T, N) typeof(T [N])
739 @end smallexample
740
741 @noindent
742 Now the declaration can be rewritten this way:
743
744 @smallexample
745 array (pointer (char), 4) y;
746 @end smallexample
747
748 @noindent
749 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
750 pointers to @code{char}.
751 @end itemize
752
753 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
754 a more limited extension that permitted one to write
755
756 @smallexample
757 typedef @var{T} = @var{expr};
758 @end smallexample
759
760 @noindent
761 with the effect of declaring @var{T} to have the type of the expression
762 @var{expr}. This extension does not work with GCC 3 (versions between
763 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
764 relies on it should be rewritten to use @code{typeof}:
765
766 @smallexample
767 typedef typeof(@var{expr}) @var{T};
768 @end smallexample
769
770 @noindent
771 This works with all versions of GCC@.
772
773 @node Conditionals
774 @section Conditionals with Omitted Operands
775 @cindex conditional expressions, extensions
776 @cindex omitted middle-operands
777 @cindex middle-operands, omitted
778 @cindex extensions, @code{?:}
779 @cindex @code{?:} extensions
780
781 The middle operand in a conditional expression may be omitted. Then
782 if the first operand is nonzero, its value is the value of the conditional
783 expression.
784
785 Therefore, the expression
786
787 @smallexample
788 x ? : y
789 @end smallexample
790
791 @noindent
792 has the value of @code{x} if that is nonzero; otherwise, the value of
793 @code{y}.
794
795 This example is perfectly equivalent to
796
797 @smallexample
798 x ? x : y
799 @end smallexample
800
801 @cindex side effect in @code{?:}
802 @cindex @code{?:} side effect
803 @noindent
804 In this simple case, the ability to omit the middle operand is not
805 especially useful. When it becomes useful is when the first operand does,
806 or may (if it is a macro argument), contain a side effect. Then repeating
807 the operand in the middle would perform the side effect twice. Omitting
808 the middle operand uses the value already computed without the undesirable
809 effects of recomputing it.
810
811 @node __int128
812 @section 128-bits integers
813 @cindex @code{__int128} data types
814
815 As an extension the integer scalar type @code{__int128} is supported for
816 targets having an integer mode wide enough to hold 128 bits.
817 Simply write @code{__int128} for a signed 128-bit integer, or
818 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
819 support in GCC to express an integer constant of type @code{__int128}
820 for targets having @code{long long} integer less than 128 bits wide.
821
822 @node Long Long
823 @section Double-Word Integers
824 @cindex @code{long long} data types
825 @cindex double-word arithmetic
826 @cindex multiprecision arithmetic
827 @cindex @code{LL} integer suffix
828 @cindex @code{ULL} integer suffix
829
830 ISO C99 supports data types for integers that are at least 64 bits wide,
831 and as an extension GCC supports them in C90 mode and in C++.
832 Simply write @code{long long int} for a signed integer, or
833 @code{unsigned long long int} for an unsigned integer. To make an
834 integer constant of type @code{long long int}, add the suffix @samp{LL}
835 to the integer. To make an integer constant of type @code{unsigned long
836 long int}, add the suffix @samp{ULL} to the integer.
837
838 You can use these types in arithmetic like any other integer types.
839 Addition, subtraction, and bitwise boolean operations on these types
840 are open-coded on all types of machines. Multiplication is open-coded
841 if the machine supports fullword-to-doubleword a widening multiply
842 instruction. Division and shifts are open-coded only on machines that
843 provide special support. The operations that are not open-coded use
844 special library routines that come with GCC@.
845
846 There may be pitfalls when you use @code{long long} types for function
847 arguments, unless you declare function prototypes. If a function
848 expects type @code{int} for its argument, and you pass a value of type
849 @code{long long int}, confusion results because the caller and the
850 subroutine disagree about the number of bytes for the argument.
851 Likewise, if the function expects @code{long long int} and you pass
852 @code{int}. The best way to avoid such problems is to use prototypes.
853
854 @node Complex
855 @section Complex Numbers
856 @cindex complex numbers
857 @cindex @code{_Complex} keyword
858 @cindex @code{__complex__} keyword
859
860 ISO C99 supports complex floating data types, and as an extension GCC
861 supports them in C90 mode and in C++, and supports complex integer data
862 types which are not part of ISO C99. You can declare complex types
863 using the keyword @code{_Complex}. As an extension, the older GNU
864 keyword @code{__complex__} is also supported.
865
866 For example, @samp{_Complex double x;} declares @code{x} as a
867 variable whose real part and imaginary part are both of type
868 @code{double}. @samp{_Complex short int y;} declares @code{y} to
869 have real and imaginary parts of type @code{short int}; this is not
870 likely to be useful, but it shows that the set of complex types is
871 complete.
872
873 To write a constant with a complex data type, use the suffix @samp{i} or
874 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
875 has type @code{_Complex float} and @code{3i} has type
876 @code{_Complex int}. Such a constant always has a pure imaginary
877 value, but you can form any complex value you like by adding one to a
878 real constant. This is a GNU extension; if you have an ISO C99
879 conforming C library (such as GNU libc), and want to construct complex
880 constants of floating type, you should include @code{<complex.h>} and
881 use the macros @code{I} or @code{_Complex_I} instead.
882
883 @cindex @code{__real__} keyword
884 @cindex @code{__imag__} keyword
885 To extract the real part of a complex-valued expression @var{exp}, write
886 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
887 extract the imaginary part. This is a GNU extension; for values of
888 floating type, you should use the ISO C99 functions @code{crealf},
889 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
890 @code{cimagl}, declared in @code{<complex.h>} and also provided as
891 built-in functions by GCC@.
892
893 @cindex complex conjugation
894 The operator @samp{~} performs complex conjugation when used on a value
895 with a complex type. This is a GNU extension; for values of
896 floating type, you should use the ISO C99 functions @code{conjf},
897 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
898 provided as built-in functions by GCC@.
899
900 GCC can allocate complex automatic variables in a noncontiguous
901 fashion; it's even possible for the real part to be in a register while
902 the imaginary part is on the stack (or vice-versa). Only the DWARF2
903 debug info format can represent this, so use of DWARF2 is recommended.
904 If you are using the stabs debug info format, GCC describes a noncontiguous
905 complex variable as if it were two separate variables of noncomplex type.
906 If the variable's actual name is @code{foo}, the two fictitious
907 variables are named @code{foo$real} and @code{foo$imag}. You can
908 examine and set these two fictitious variables with your debugger.
909
910 @node Floating Types
911 @section Additional Floating Types
912 @cindex additional floating types
913 @cindex @code{__float80} data type
914 @cindex @code{__float128} data type
915 @cindex @code{w} floating point suffix
916 @cindex @code{q} floating point suffix
917 @cindex @code{W} floating point suffix
918 @cindex @code{Q} floating point suffix
919
920 As an extension, GNU C supports additional floating
921 types, @code{__float80} and @code{__float128} to support 80-bit
922 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
923 Support for additional types includes the arithmetic operators:
924 add, subtract, multiply, divide; unary arithmetic operators;
925 relational operators; equality operators; and conversions to and from
926 integer and other floating types. Use a suffix @samp{w} or @samp{W}
927 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
928 for @code{_float128}. You can declare complex types using the
929 corresponding internal complex type, @code{XCmode} for @code{__float80}
930 type and @code{TCmode} for @code{__float128} type:
931
932 @smallexample
933 typedef _Complex float __attribute__((mode(TC))) _Complex128;
934 typedef _Complex float __attribute__((mode(XC))) _Complex80;
935 @end smallexample
936
937 Not all targets support additional floating-point types. @code{__float80}
938 and @code{__float128} types are supported on i386, x86_64 and ia64 targets.
939 The @code{__float128} type is supported on hppa HP-UX targets.
940
941 @node Half-Precision
942 @section Half-Precision Floating Point
943 @cindex half-precision floating point
944 @cindex @code{__fp16} data type
945
946 On ARM targets, GCC supports half-precision (16-bit) floating point via
947 the @code{__fp16} type. You must enable this type explicitly
948 with the @option{-mfp16-format} command-line option in order to use it.
949
950 ARM supports two incompatible representations for half-precision
951 floating-point values. You must choose one of the representations and
952 use it consistently in your program.
953
954 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
955 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
956 There are 11 bits of significand precision, approximately 3
957 decimal digits.
958
959 Specifying @option{-mfp16-format=alternative} selects the ARM
960 alternative format. This representation is similar to the IEEE
961 format, but does not support infinities or NaNs. Instead, the range
962 of exponents is extended, so that this format can represent normalized
963 values in the range of @math{2^{-14}} to 131008.
964
965 The @code{__fp16} type is a storage format only. For purposes
966 of arithmetic and other operations, @code{__fp16} values in C or C++
967 expressions are automatically promoted to @code{float}. In addition,
968 you cannot declare a function with a return value or parameters
969 of type @code{__fp16}.
970
971 Note that conversions from @code{double} to @code{__fp16}
972 involve an intermediate conversion to @code{float}. Because
973 of rounding, this can sometimes produce a different result than a
974 direct conversion.
975
976 ARM provides hardware support for conversions between
977 @code{__fp16} and @code{float} values
978 as an extension to VFP and NEON (Advanced SIMD). GCC generates
979 code using these hardware instructions if you compile with
980 options to select an FPU that provides them;
981 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
982 in addition to the @option{-mfp16-format} option to select
983 a half-precision format.
984
985 Language-level support for the @code{__fp16} data type is
986 independent of whether GCC generates code using hardware floating-point
987 instructions. In cases where hardware support is not specified, GCC
988 implements conversions between @code{__fp16} and @code{float} values
989 as library calls.
990
991 @node Decimal Float
992 @section Decimal Floating Types
993 @cindex decimal floating types
994 @cindex @code{_Decimal32} data type
995 @cindex @code{_Decimal64} data type
996 @cindex @code{_Decimal128} data type
997 @cindex @code{df} integer suffix
998 @cindex @code{dd} integer suffix
999 @cindex @code{dl} integer suffix
1000 @cindex @code{DF} integer suffix
1001 @cindex @code{DD} integer suffix
1002 @cindex @code{DL} integer suffix
1003
1004 As an extension, GNU C supports decimal floating types as
1005 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1006 floating types in GCC will evolve as the draft technical report changes.
1007 Calling conventions for any target might also change. Not all targets
1008 support decimal floating types.
1009
1010 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1011 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1012 @code{float}, @code{double}, and @code{long double} whose radix is not
1013 specified by the C standard but is usually two.
1014
1015 Support for decimal floating types includes the arithmetic operators
1016 add, subtract, multiply, divide; unary arithmetic operators;
1017 relational operators; equality operators; and conversions to and from
1018 integer and other floating types. Use a suffix @samp{df} or
1019 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1020 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1021 @code{_Decimal128}.
1022
1023 GCC support of decimal float as specified by the draft technical report
1024 is incomplete:
1025
1026 @itemize @bullet
1027 @item
1028 When the value of a decimal floating type cannot be represented in the
1029 integer type to which it is being converted, the result is undefined
1030 rather than the result value specified by the draft technical report.
1031
1032 @item
1033 GCC does not provide the C library functionality associated with
1034 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1035 @file{wchar.h}, which must come from a separate C library implementation.
1036 Because of this the GNU C compiler does not define macro
1037 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1038 the technical report.
1039 @end itemize
1040
1041 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1042 are supported by the DWARF2 debug information format.
1043
1044 @node Hex Floats
1045 @section Hex Floats
1046 @cindex hex floats
1047
1048 ISO C99 supports floating-point numbers written not only in the usual
1049 decimal notation, such as @code{1.55e1}, but also numbers such as
1050 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1051 supports this in C90 mode (except in some cases when strictly
1052 conforming) and in C++. In that format the
1053 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1054 mandatory. The exponent is a decimal number that indicates the power of
1055 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1056 @tex
1057 $1 {15\over16}$,
1058 @end tex
1059 @ifnottex
1060 1 15/16,
1061 @end ifnottex
1062 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1063 is the same as @code{1.55e1}.
1064
1065 Unlike for floating-point numbers in the decimal notation the exponent
1066 is always required in the hexadecimal notation. Otherwise the compiler
1067 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1068 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1069 extension for floating-point constants of type @code{float}.
1070
1071 @node Fixed-Point
1072 @section Fixed-Point Types
1073 @cindex fixed-point types
1074 @cindex @code{_Fract} data type
1075 @cindex @code{_Accum} data type
1076 @cindex @code{_Sat} data type
1077 @cindex @code{hr} fixed-suffix
1078 @cindex @code{r} fixed-suffix
1079 @cindex @code{lr} fixed-suffix
1080 @cindex @code{llr} fixed-suffix
1081 @cindex @code{uhr} fixed-suffix
1082 @cindex @code{ur} fixed-suffix
1083 @cindex @code{ulr} fixed-suffix
1084 @cindex @code{ullr} fixed-suffix
1085 @cindex @code{hk} fixed-suffix
1086 @cindex @code{k} fixed-suffix
1087 @cindex @code{lk} fixed-suffix
1088 @cindex @code{llk} fixed-suffix
1089 @cindex @code{uhk} fixed-suffix
1090 @cindex @code{uk} fixed-suffix
1091 @cindex @code{ulk} fixed-suffix
1092 @cindex @code{ullk} fixed-suffix
1093 @cindex @code{HR} fixed-suffix
1094 @cindex @code{R} fixed-suffix
1095 @cindex @code{LR} fixed-suffix
1096 @cindex @code{LLR} fixed-suffix
1097 @cindex @code{UHR} fixed-suffix
1098 @cindex @code{UR} fixed-suffix
1099 @cindex @code{ULR} fixed-suffix
1100 @cindex @code{ULLR} fixed-suffix
1101 @cindex @code{HK} fixed-suffix
1102 @cindex @code{K} fixed-suffix
1103 @cindex @code{LK} fixed-suffix
1104 @cindex @code{LLK} fixed-suffix
1105 @cindex @code{UHK} fixed-suffix
1106 @cindex @code{UK} fixed-suffix
1107 @cindex @code{ULK} fixed-suffix
1108 @cindex @code{ULLK} fixed-suffix
1109
1110 As an extension, GNU C supports fixed-point types as
1111 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1112 types in GCC will evolve as the draft technical report changes.
1113 Calling conventions for any target might also change. Not all targets
1114 support fixed-point types.
1115
1116 The fixed-point types are
1117 @code{short _Fract},
1118 @code{_Fract},
1119 @code{long _Fract},
1120 @code{long long _Fract},
1121 @code{unsigned short _Fract},
1122 @code{unsigned _Fract},
1123 @code{unsigned long _Fract},
1124 @code{unsigned long long _Fract},
1125 @code{_Sat short _Fract},
1126 @code{_Sat _Fract},
1127 @code{_Sat long _Fract},
1128 @code{_Sat long long _Fract},
1129 @code{_Sat unsigned short _Fract},
1130 @code{_Sat unsigned _Fract},
1131 @code{_Sat unsigned long _Fract},
1132 @code{_Sat unsigned long long _Fract},
1133 @code{short _Accum},
1134 @code{_Accum},
1135 @code{long _Accum},
1136 @code{long long _Accum},
1137 @code{unsigned short _Accum},
1138 @code{unsigned _Accum},
1139 @code{unsigned long _Accum},
1140 @code{unsigned long long _Accum},
1141 @code{_Sat short _Accum},
1142 @code{_Sat _Accum},
1143 @code{_Sat long _Accum},
1144 @code{_Sat long long _Accum},
1145 @code{_Sat unsigned short _Accum},
1146 @code{_Sat unsigned _Accum},
1147 @code{_Sat unsigned long _Accum},
1148 @code{_Sat unsigned long long _Accum}.
1149
1150 Fixed-point data values contain fractional and optional integral parts.
1151 The format of fixed-point data varies and depends on the target machine.
1152
1153 Support for fixed-point types includes:
1154 @itemize @bullet
1155 @item
1156 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1157 @item
1158 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1159 @item
1160 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1161 @item
1162 binary shift operators (@code{<<}, @code{>>})
1163 @item
1164 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1165 @item
1166 equality operators (@code{==}, @code{!=})
1167 @item
1168 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1169 @code{<<=}, @code{>>=})
1170 @item
1171 conversions to and from integer, floating-point, or fixed-point types
1172 @end itemize
1173
1174 Use a suffix in a fixed-point literal constant:
1175 @itemize
1176 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1177 @code{_Sat short _Fract}
1178 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1179 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1180 @code{_Sat long _Fract}
1181 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1182 @code{_Sat long long _Fract}
1183 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1184 @code{_Sat unsigned short _Fract}
1185 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1186 @code{_Sat unsigned _Fract}
1187 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1188 @code{_Sat unsigned long _Fract}
1189 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1190 and @code{_Sat unsigned long long _Fract}
1191 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1192 @code{_Sat short _Accum}
1193 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1194 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1195 @code{_Sat long _Accum}
1196 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1197 @code{_Sat long long _Accum}
1198 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1199 @code{_Sat unsigned short _Accum}
1200 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1201 @code{_Sat unsigned _Accum}
1202 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1203 @code{_Sat unsigned long _Accum}
1204 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1205 and @code{_Sat unsigned long long _Accum}
1206 @end itemize
1207
1208 GCC support of fixed-point types as specified by the draft technical report
1209 is incomplete:
1210
1211 @itemize @bullet
1212 @item
1213 Pragmas to control overflow and rounding behaviors are not implemented.
1214 @end itemize
1215
1216 Fixed-point types are supported by the DWARF2 debug information format.
1217
1218 @node Named Address Spaces
1219 @section Named Address Spaces
1220 @cindex Named Address Spaces
1221
1222 As an extension, GNU C supports named address spaces as
1223 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1224 address spaces in GCC will evolve as the draft technical report
1225 changes. Calling conventions for any target might also change. At
1226 present, only the AVR, SPU, M32C, and RL78 targets support address
1227 spaces other than the generic address space.
1228
1229 Address space identifiers may be used exactly like any other C type
1230 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1231 document for more details.
1232
1233 @anchor{AVR Named Address Spaces}
1234 @subsection AVR Named Address Spaces
1235
1236 On the AVR target, there are several address spaces that can be used
1237 in order to put read-only data into the flash memory and access that
1238 data by means of the special instructions @code{LPM} or @code{ELPM}
1239 needed to read from flash.
1240
1241 Per default, any data including read-only data is located in RAM
1242 (the generic address space) so that non-generic address spaces are
1243 needed to locate read-only data in flash memory
1244 @emph{and} to generate the right instructions to access this data
1245 without using (inline) assembler code.
1246
1247 @table @code
1248 @item __flash
1249 @cindex @code{__flash} AVR Named Address Spaces
1250 The @code{__flash} qualifier locates data in the
1251 @code{.progmem.data} section. Data is read using the @code{LPM}
1252 instruction. Pointers to this address space are 16 bits wide.
1253
1254 @item __flash1
1255 @itemx __flash2
1256 @itemx __flash3
1257 @itemx __flash4
1258 @itemx __flash5
1259 @cindex @code{__flash1} AVR Named Address Spaces
1260 @cindex @code{__flash2} AVR Named Address Spaces
1261 @cindex @code{__flash3} AVR Named Address Spaces
1262 @cindex @code{__flash4} AVR Named Address Spaces
1263 @cindex @code{__flash5} AVR Named Address Spaces
1264 These are 16-bit address spaces locating data in section
1265 @code{.progmem@var{N}.data} where @var{N} refers to
1266 address space @code{__flash@var{N}}.
1267 The compiler sets the @code{RAMPZ} segment register appropriately
1268 before reading data by means of the @code{ELPM} instruction.
1269
1270 @item __memx
1271 @cindex @code{__memx} AVR Named Address Spaces
1272 This is a 24-bit address space that linearizes flash and RAM:
1273 If the high bit of the address is set, data is read from
1274 RAM using the lower two bytes as RAM address.
1275 If the high bit of the address is clear, data is read from flash
1276 with @code{RAMPZ} set according to the high byte of the address.
1277 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1278
1279 Objects in this address space are located in @code{.progmem.data}.
1280 @end table
1281
1282 @b{Example}
1283
1284 @smallexample
1285 char my_read (const __flash char ** p)
1286 @{
1287 /* p is a pointer to RAM that points to a pointer to flash.
1288 The first indirection of p reads that flash pointer
1289 from RAM and the second indirection reads a char from this
1290 flash address. */
1291
1292 return **p;
1293 @}
1294
1295 /* Locate array[] in flash memory */
1296 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1297
1298 int i = 1;
1299
1300 int main (void)
1301 @{
1302 /* Return 17 by reading from flash memory */
1303 return array[array[i]];
1304 @}
1305 @end smallexample
1306
1307 @noindent
1308 For each named address space supported by avr-gcc there is an equally
1309 named but uppercase built-in macro defined.
1310 The purpose is to facilitate testing if respective address space
1311 support is available or not:
1312
1313 @smallexample
1314 #ifdef __FLASH
1315 const __flash int var = 1;
1316
1317 int read_var (void)
1318 @{
1319 return var;
1320 @}
1321 #else
1322 #include <avr/pgmspace.h> /* From AVR-LibC */
1323
1324 const int var PROGMEM = 1;
1325
1326 int read_var (void)
1327 @{
1328 return (int) pgm_read_word (&var);
1329 @}
1330 #endif /* __FLASH */
1331 @end smallexample
1332
1333 @noindent
1334 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1335 locates data in flash but
1336 accesses to these data read from generic address space, i.e.@:
1337 from RAM,
1338 so that you need special accessors like @code{pgm_read_byte}
1339 from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}}
1340 together with attribute @code{progmem}.
1341
1342 @noindent
1343 @b{Limitations and caveats}
1344
1345 @itemize
1346 @item
1347 Reading across the 64@tie{}KiB section boundary of
1348 the @code{__flash} or @code{__flash@var{N}} address spaces
1349 shows undefined behavior. The only address space that
1350 supports reading across the 64@tie{}KiB flash segment boundaries is
1351 @code{__memx}.
1352
1353 @item
1354 If you use one of the @code{__flash@var{N}} address spaces
1355 you must arrange your linker script to locate the
1356 @code{.progmem@var{N}.data} sections according to your needs.
1357
1358 @item
1359 Any data or pointers to the non-generic address spaces must
1360 be qualified as @code{const}, i.e.@: as read-only data.
1361 This still applies if the data in one of these address
1362 spaces like software version number or calibration lookup table are intended to
1363 be changed after load time by, say, a boot loader. In this case
1364 the right qualification is @code{const} @code{volatile} so that the compiler
1365 must not optimize away known values or insert them
1366 as immediates into operands of instructions.
1367
1368 @item
1369 The following code initializes a variable @code{pfoo}
1370 located in static storage with a 24-bit address:
1371 @smallexample
1372 extern const __memx char foo;
1373 const __memx void *pfoo = &foo;
1374 @end smallexample
1375
1376 @noindent
1377 Such code requires at least binutils 2.23, see
1378 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1379
1380 @end itemize
1381
1382 @subsection M32C Named Address Spaces
1383 @cindex @code{__far} M32C Named Address Spaces
1384
1385 On the M32C target, with the R8C and M16C cpu variants, variables
1386 qualified with @code{__far} are accessed using 32-bit addresses in
1387 order to access memory beyond the first 64@tie{}Ki bytes. If
1388 @code{__far} is used with the M32CM or M32C cpu variants, it has no
1389 effect.
1390
1391 @subsection RL78 Named Address Spaces
1392 @cindex @code{__far} RL78 Named Address Spaces
1393
1394 On the RL78 target, variables qualified with @code{__far} are accessed
1395 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1396 addresses. Non-far variables are assumed to appear in the topmost
1397 64@tie{}KiB of the address space.
1398
1399 @subsection SPU Named Address Spaces
1400 @cindex @code{__ea} SPU Named Address Spaces
1401
1402 On the SPU target variables may be declared as
1403 belonging to another address space by qualifying the type with the
1404 @code{__ea} address space identifier:
1405
1406 @smallexample
1407 extern int __ea i;
1408 @end smallexample
1409
1410 @noindent
1411 The compiler generates special code to access the variable @code{i}.
1412 It may use runtime library
1413 support, or generate special machine instructions to access that address
1414 space.
1415
1416 @node Zero Length
1417 @section Arrays of Length Zero
1418 @cindex arrays of length zero
1419 @cindex zero-length arrays
1420 @cindex length-zero arrays
1421 @cindex flexible array members
1422
1423 Zero-length arrays are allowed in GNU C@. They are very useful as the
1424 last element of a structure that is really a header for a variable-length
1425 object:
1426
1427 @smallexample
1428 struct line @{
1429 int length;
1430 char contents[0];
1431 @};
1432
1433 struct line *thisline = (struct line *)
1434 malloc (sizeof (struct line) + this_length);
1435 thisline->length = this_length;
1436 @end smallexample
1437
1438 In ISO C90, you would have to give @code{contents} a length of 1, which
1439 means either you waste space or complicate the argument to @code{malloc}.
1440
1441 In ISO C99, you would use a @dfn{flexible array member}, which is
1442 slightly different in syntax and semantics:
1443
1444 @itemize @bullet
1445 @item
1446 Flexible array members are written as @code{contents[]} without
1447 the @code{0}.
1448
1449 @item
1450 Flexible array members have incomplete type, and so the @code{sizeof}
1451 operator may not be applied. As a quirk of the original implementation
1452 of zero-length arrays, @code{sizeof} evaluates to zero.
1453
1454 @item
1455 Flexible array members may only appear as the last member of a
1456 @code{struct} that is otherwise non-empty.
1457
1458 @item
1459 A structure containing a flexible array member, or a union containing
1460 such a structure (possibly recursively), may not be a member of a
1461 structure or an element of an array. (However, these uses are
1462 permitted by GCC as extensions.)
1463 @end itemize
1464
1465 GCC versions before 3.0 allowed zero-length arrays to be statically
1466 initialized, as if they were flexible arrays. In addition to those
1467 cases that were useful, it also allowed initializations in situations
1468 that would corrupt later data. Non-empty initialization of zero-length
1469 arrays is now treated like any case where there are more initializer
1470 elements than the array holds, in that a suitable warning about ``excess
1471 elements in array'' is given, and the excess elements (all of them, in
1472 this case) are ignored.
1473
1474 Instead GCC allows static initialization of flexible array members.
1475 This is equivalent to defining a new structure containing the original
1476 structure followed by an array of sufficient size to contain the data.
1477 E.g.@: in the following, @code{f1} is constructed as if it were declared
1478 like @code{f2}.
1479
1480 @smallexample
1481 struct f1 @{
1482 int x; int y[];
1483 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1484
1485 struct f2 @{
1486 struct f1 f1; int data[3];
1487 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1488 @end smallexample
1489
1490 @noindent
1491 The convenience of this extension is that @code{f1} has the desired
1492 type, eliminating the need to consistently refer to @code{f2.f1}.
1493
1494 This has symmetry with normal static arrays, in that an array of
1495 unknown size is also written with @code{[]}.
1496
1497 Of course, this extension only makes sense if the extra data comes at
1498 the end of a top-level object, as otherwise we would be overwriting
1499 data at subsequent offsets. To avoid undue complication and confusion
1500 with initialization of deeply nested arrays, we simply disallow any
1501 non-empty initialization except when the structure is the top-level
1502 object. For example:
1503
1504 @smallexample
1505 struct foo @{ int x; int y[]; @};
1506 struct bar @{ struct foo z; @};
1507
1508 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1509 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1510 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1511 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1512 @end smallexample
1513
1514 @node Empty Structures
1515 @section Structures With No Members
1516 @cindex empty structures
1517 @cindex zero-size structures
1518
1519 GCC permits a C structure to have no members:
1520
1521 @smallexample
1522 struct empty @{
1523 @};
1524 @end smallexample
1525
1526 The structure has size zero. In C++, empty structures are part
1527 of the language. G++ treats empty structures as if they had a single
1528 member of type @code{char}.
1529
1530 @node Variable Length
1531 @section Arrays of Variable Length
1532 @cindex variable-length arrays
1533 @cindex arrays of variable length
1534 @cindex VLAs
1535
1536 Variable-length automatic arrays are allowed in ISO C99, and as an
1537 extension GCC accepts them in C90 mode and in C++. These arrays are
1538 declared like any other automatic arrays, but with a length that is not
1539 a constant expression. The storage is allocated at the point of
1540 declaration and deallocated when the brace-level is exited. For
1541 example:
1542
1543 @smallexample
1544 FILE *
1545 concat_fopen (char *s1, char *s2, char *mode)
1546 @{
1547 char str[strlen (s1) + strlen (s2) + 1];
1548 strcpy (str, s1);
1549 strcat (str, s2);
1550 return fopen (str, mode);
1551 @}
1552 @end smallexample
1553
1554 @cindex scope of a variable length array
1555 @cindex variable-length array scope
1556 @cindex deallocating variable length arrays
1557 Jumping or breaking out of the scope of the array name deallocates the
1558 storage. Jumping into the scope is not allowed; you get an error
1559 message for it.
1560
1561 @cindex @code{alloca} vs variable-length arrays
1562 You can use the function @code{alloca} to get an effect much like
1563 variable-length arrays. The function @code{alloca} is available in
1564 many other C implementations (but not in all). On the other hand,
1565 variable-length arrays are more elegant.
1566
1567 There are other differences between these two methods. Space allocated
1568 with @code{alloca} exists until the containing @emph{function} returns.
1569 The space for a variable-length array is deallocated as soon as the array
1570 name's scope ends. (If you use both variable-length arrays and
1571 @code{alloca} in the same function, deallocation of a variable-length array
1572 also deallocates anything more recently allocated with @code{alloca}.)
1573
1574 You can also use variable-length arrays as arguments to functions:
1575
1576 @smallexample
1577 struct entry
1578 tester (int len, char data[len][len])
1579 @{
1580 /* @r{@dots{}} */
1581 @}
1582 @end smallexample
1583
1584 The length of an array is computed once when the storage is allocated
1585 and is remembered for the scope of the array in case you access it with
1586 @code{sizeof}.
1587
1588 If you want to pass the array first and the length afterward, you can
1589 use a forward declaration in the parameter list---another GNU extension.
1590
1591 @smallexample
1592 struct entry
1593 tester (int len; char data[len][len], int len)
1594 @{
1595 /* @r{@dots{}} */
1596 @}
1597 @end smallexample
1598
1599 @cindex parameter forward declaration
1600 The @samp{int len} before the semicolon is a @dfn{parameter forward
1601 declaration}, and it serves the purpose of making the name @code{len}
1602 known when the declaration of @code{data} is parsed.
1603
1604 You can write any number of such parameter forward declarations in the
1605 parameter list. They can be separated by commas or semicolons, but the
1606 last one must end with a semicolon, which is followed by the ``real''
1607 parameter declarations. Each forward declaration must match a ``real''
1608 declaration in parameter name and data type. ISO C99 does not support
1609 parameter forward declarations.
1610
1611 @node Variadic Macros
1612 @section Macros with a Variable Number of Arguments.
1613 @cindex variable number of arguments
1614 @cindex macro with variable arguments
1615 @cindex rest argument (in macro)
1616 @cindex variadic macros
1617
1618 In the ISO C standard of 1999, a macro can be declared to accept a
1619 variable number of arguments much as a function can. The syntax for
1620 defining the macro is similar to that of a function. Here is an
1621 example:
1622
1623 @smallexample
1624 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1625 @end smallexample
1626
1627 @noindent
1628 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1629 such a macro, it represents the zero or more tokens until the closing
1630 parenthesis that ends the invocation, including any commas. This set of
1631 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1632 wherever it appears. See the CPP manual for more information.
1633
1634 GCC has long supported variadic macros, and used a different syntax that
1635 allowed you to give a name to the variable arguments just like any other
1636 argument. Here is an example:
1637
1638 @smallexample
1639 #define debug(format, args...) fprintf (stderr, format, args)
1640 @end smallexample
1641
1642 @noindent
1643 This is in all ways equivalent to the ISO C example above, but arguably
1644 more readable and descriptive.
1645
1646 GNU CPP has two further variadic macro extensions, and permits them to
1647 be used with either of the above forms of macro definition.
1648
1649 In standard C, you are not allowed to leave the variable argument out
1650 entirely; but you are allowed to pass an empty argument. For example,
1651 this invocation is invalid in ISO C, because there is no comma after
1652 the string:
1653
1654 @smallexample
1655 debug ("A message")
1656 @end smallexample
1657
1658 GNU CPP permits you to completely omit the variable arguments in this
1659 way. In the above examples, the compiler would complain, though since
1660 the expansion of the macro still has the extra comma after the format
1661 string.
1662
1663 To help solve this problem, CPP behaves specially for variable arguments
1664 used with the token paste operator, @samp{##}. If instead you write
1665
1666 @smallexample
1667 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1668 @end smallexample
1669
1670 @noindent
1671 and if the variable arguments are omitted or empty, the @samp{##}
1672 operator causes the preprocessor to remove the comma before it. If you
1673 do provide some variable arguments in your macro invocation, GNU CPP
1674 does not complain about the paste operation and instead places the
1675 variable arguments after the comma. Just like any other pasted macro
1676 argument, these arguments are not macro expanded.
1677
1678 @node Escaped Newlines
1679 @section Slightly Looser Rules for Escaped Newlines
1680 @cindex escaped newlines
1681 @cindex newlines (escaped)
1682
1683 Recently, the preprocessor has relaxed its treatment of escaped
1684 newlines. Previously, the newline had to immediately follow a
1685 backslash. The current implementation allows whitespace in the form
1686 of spaces, horizontal and vertical tabs, and form feeds between the
1687 backslash and the subsequent newline. The preprocessor issues a
1688 warning, but treats it as a valid escaped newline and combines the two
1689 lines to form a single logical line. This works within comments and
1690 tokens, as well as between tokens. Comments are @emph{not} treated as
1691 whitespace for the purposes of this relaxation, since they have not
1692 yet been replaced with spaces.
1693
1694 @node Subscripting
1695 @section Non-Lvalue Arrays May Have Subscripts
1696 @cindex subscripting
1697 @cindex arrays, non-lvalue
1698
1699 @cindex subscripting and function values
1700 In ISO C99, arrays that are not lvalues still decay to pointers, and
1701 may be subscripted, although they may not be modified or used after
1702 the next sequence point and the unary @samp{&} operator may not be
1703 applied to them. As an extension, GNU C allows such arrays to be
1704 subscripted in C90 mode, though otherwise they do not decay to
1705 pointers outside C99 mode. For example,
1706 this is valid in GNU C though not valid in C90:
1707
1708 @smallexample
1709 @group
1710 struct foo @{int a[4];@};
1711
1712 struct foo f();
1713
1714 bar (int index)
1715 @{
1716 return f().a[index];
1717 @}
1718 @end group
1719 @end smallexample
1720
1721 @node Pointer Arith
1722 @section Arithmetic on @code{void}- and Function-Pointers
1723 @cindex void pointers, arithmetic
1724 @cindex void, size of pointer to
1725 @cindex function pointers, arithmetic
1726 @cindex function, size of pointer to
1727
1728 In GNU C, addition and subtraction operations are supported on pointers to
1729 @code{void} and on pointers to functions. This is done by treating the
1730 size of a @code{void} or of a function as 1.
1731
1732 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1733 and on function types, and returns 1.
1734
1735 @opindex Wpointer-arith
1736 The option @option{-Wpointer-arith} requests a warning if these extensions
1737 are used.
1738
1739 @node Initializers
1740 @section Non-Constant Initializers
1741 @cindex initializers, non-constant
1742 @cindex non-constant initializers
1743
1744 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1745 automatic variable are not required to be constant expressions in GNU C@.
1746 Here is an example of an initializer with run-time varying elements:
1747
1748 @smallexample
1749 foo (float f, float g)
1750 @{
1751 float beat_freqs[2] = @{ f-g, f+g @};
1752 /* @r{@dots{}} */
1753 @}
1754 @end smallexample
1755
1756 @node Compound Literals
1757 @section Compound Literals
1758 @cindex constructor expressions
1759 @cindex initializations in expressions
1760 @cindex structures, constructor expression
1761 @cindex expressions, constructor
1762 @cindex compound literals
1763 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1764
1765 ISO C99 supports compound literals. A compound literal looks like
1766 a cast containing an initializer. Its value is an object of the
1767 type specified in the cast, containing the elements specified in
1768 the initializer; it is an lvalue. As an extension, GCC supports
1769 compound literals in C90 mode and in C++, though the semantics are
1770 somewhat different in C++.
1771
1772 Usually, the specified type is a structure. Assume that
1773 @code{struct foo} and @code{structure} are declared as shown:
1774
1775 @smallexample
1776 struct foo @{int a; char b[2];@} structure;
1777 @end smallexample
1778
1779 @noindent
1780 Here is an example of constructing a @code{struct foo} with a compound literal:
1781
1782 @smallexample
1783 structure = ((struct foo) @{x + y, 'a', 0@});
1784 @end smallexample
1785
1786 @noindent
1787 This is equivalent to writing the following:
1788
1789 @smallexample
1790 @{
1791 struct foo temp = @{x + y, 'a', 0@};
1792 structure = temp;
1793 @}
1794 @end smallexample
1795
1796 You can also construct an array, though this is dangerous in C++, as
1797 explained below. If all the elements of the compound literal are
1798 (made up of) simple constant expressions, suitable for use in
1799 initializers of objects of static storage duration, then the compound
1800 literal can be coerced to a pointer to its first element and used in
1801 such an initializer, as shown here:
1802
1803 @smallexample
1804 char **foo = (char *[]) @{ "x", "y", "z" @};
1805 @end smallexample
1806
1807 Compound literals for scalar types and union types are
1808 also allowed, but then the compound literal is equivalent
1809 to a cast.
1810
1811 As a GNU extension, GCC allows initialization of objects with static storage
1812 duration by compound literals (which is not possible in ISO C99, because
1813 the initializer is not a constant).
1814 It is handled as if the object is initialized only with the bracket
1815 enclosed list if the types of the compound literal and the object match.
1816 The initializer list of the compound literal must be constant.
1817 If the object being initialized has array type of unknown size, the size is
1818 determined by compound literal size.
1819
1820 @smallexample
1821 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1822 static int y[] = (int []) @{1, 2, 3@};
1823 static int z[] = (int [3]) @{1@};
1824 @end smallexample
1825
1826 @noindent
1827 The above lines are equivalent to the following:
1828 @smallexample
1829 static struct foo x = @{1, 'a', 'b'@};
1830 static int y[] = @{1, 2, 3@};
1831 static int z[] = @{1, 0, 0@};
1832 @end smallexample
1833
1834 In C, a compound literal designates an unnamed object with static or
1835 automatic storage duration. In C++, a compound literal designates a
1836 temporary object, which only lives until the end of its
1837 full-expression. As a result, well-defined C code that takes the
1838 address of a subobject of a compound literal can be undefined in C++.
1839 For instance, if the array compound literal example above appeared
1840 inside a function, any subsequent use of @samp{foo} in C++ has
1841 undefined behavior because the lifetime of the array ends after the
1842 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1843 the conversion of a temporary array to a pointer.
1844
1845 As an optimization, the C++ compiler sometimes gives array compound
1846 literals longer lifetimes: when the array either appears outside a
1847 function or has const-qualified type. If @samp{foo} and its
1848 initializer had elements of @samp{char *const} type rather than
1849 @samp{char *}, or if @samp{foo} were a global variable, the array
1850 would have static storage duration. But it is probably safest just to
1851 avoid the use of array compound literals in code compiled as C++.
1852
1853 @node Designated Inits
1854 @section Designated Initializers
1855 @cindex initializers with labeled elements
1856 @cindex labeled elements in initializers
1857 @cindex case labels in initializers
1858 @cindex designated initializers
1859
1860 Standard C90 requires the elements of an initializer to appear in a fixed
1861 order, the same as the order of the elements in the array or structure
1862 being initialized.
1863
1864 In ISO C99 you can give the elements in any order, specifying the array
1865 indices or structure field names they apply to, and GNU C allows this as
1866 an extension in C90 mode as well. This extension is not
1867 implemented in GNU C++.
1868
1869 To specify an array index, write
1870 @samp{[@var{index}] =} before the element value. For example,
1871
1872 @smallexample
1873 int a[6] = @{ [4] = 29, [2] = 15 @};
1874 @end smallexample
1875
1876 @noindent
1877 is equivalent to
1878
1879 @smallexample
1880 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1881 @end smallexample
1882
1883 @noindent
1884 The index values must be constant expressions, even if the array being
1885 initialized is automatic.
1886
1887 An alternative syntax for this that has been obsolete since GCC 2.5 but
1888 GCC still accepts is to write @samp{[@var{index}]} before the element
1889 value, with no @samp{=}.
1890
1891 To initialize a range of elements to the same value, write
1892 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1893 extension. For example,
1894
1895 @smallexample
1896 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1897 @end smallexample
1898
1899 @noindent
1900 If the value in it has side-effects, the side-effects happen only once,
1901 not for each initialized field by the range initializer.
1902
1903 @noindent
1904 Note that the length of the array is the highest value specified
1905 plus one.
1906
1907 In a structure initializer, specify the name of a field to initialize
1908 with @samp{.@var{fieldname} =} before the element value. For example,
1909 given the following structure,
1910
1911 @smallexample
1912 struct point @{ int x, y; @};
1913 @end smallexample
1914
1915 @noindent
1916 the following initialization
1917
1918 @smallexample
1919 struct point p = @{ .y = yvalue, .x = xvalue @};
1920 @end smallexample
1921
1922 @noindent
1923 is equivalent to
1924
1925 @smallexample
1926 struct point p = @{ xvalue, yvalue @};
1927 @end smallexample
1928
1929 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1930 @samp{@var{fieldname}:}, as shown here:
1931
1932 @smallexample
1933 struct point p = @{ y: yvalue, x: xvalue @};
1934 @end smallexample
1935
1936 @cindex designators
1937 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1938 @dfn{designator}. You can also use a designator (or the obsolete colon
1939 syntax) when initializing a union, to specify which element of the union
1940 should be used. For example,
1941
1942 @smallexample
1943 union foo @{ int i; double d; @};
1944
1945 union foo f = @{ .d = 4 @};
1946 @end smallexample
1947
1948 @noindent
1949 converts 4 to a @code{double} to store it in the union using
1950 the second element. By contrast, casting 4 to type @code{union foo}
1951 stores it into the union as the integer @code{i}, since it is
1952 an integer. (@xref{Cast to Union}.)
1953
1954 You can combine this technique of naming elements with ordinary C
1955 initialization of successive elements. Each initializer element that
1956 does not have a designator applies to the next consecutive element of the
1957 array or structure. For example,
1958
1959 @smallexample
1960 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1961 @end smallexample
1962
1963 @noindent
1964 is equivalent to
1965
1966 @smallexample
1967 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1968 @end smallexample
1969
1970 Labeling the elements of an array initializer is especially useful
1971 when the indices are characters or belong to an @code{enum} type.
1972 For example:
1973
1974 @smallexample
1975 int whitespace[256]
1976 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1977 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1978 @end smallexample
1979
1980 @cindex designator lists
1981 You can also write a series of @samp{.@var{fieldname}} and
1982 @samp{[@var{index}]} designators before an @samp{=} to specify a
1983 nested subobject to initialize; the list is taken relative to the
1984 subobject corresponding to the closest surrounding brace pair. For
1985 example, with the @samp{struct point} declaration above:
1986
1987 @smallexample
1988 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1989 @end smallexample
1990
1991 @noindent
1992 If the same field is initialized multiple times, it has the value from
1993 the last initialization. If any such overridden initialization has
1994 side-effect, it is unspecified whether the side-effect happens or not.
1995 Currently, GCC discards them and issues a warning.
1996
1997 @node Case Ranges
1998 @section Case Ranges
1999 @cindex case ranges
2000 @cindex ranges in case statements
2001
2002 You can specify a range of consecutive values in a single @code{case} label,
2003 like this:
2004
2005 @smallexample
2006 case @var{low} ... @var{high}:
2007 @end smallexample
2008
2009 @noindent
2010 This has the same effect as the proper number of individual @code{case}
2011 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2012
2013 This feature is especially useful for ranges of ASCII character codes:
2014
2015 @smallexample
2016 case 'A' ... 'Z':
2017 @end smallexample
2018
2019 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2020 it may be parsed wrong when you use it with integer values. For example,
2021 write this:
2022
2023 @smallexample
2024 case 1 ... 5:
2025 @end smallexample
2026
2027 @noindent
2028 rather than this:
2029
2030 @smallexample
2031 case 1...5:
2032 @end smallexample
2033
2034 @node Cast to Union
2035 @section Cast to a Union Type
2036 @cindex cast to a union
2037 @cindex union, casting to a
2038
2039 A cast to union type is similar to other casts, except that the type
2040 specified is a union type. You can specify the type either with
2041 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2042 a constructor though, not a cast, and hence does not yield an lvalue like
2043 normal casts. (@xref{Compound Literals}.)
2044
2045 The types that may be cast to the union type are those of the members
2046 of the union. Thus, given the following union and variables:
2047
2048 @smallexample
2049 union foo @{ int i; double d; @};
2050 int x;
2051 double y;
2052 @end smallexample
2053
2054 @noindent
2055 both @code{x} and @code{y} can be cast to type @code{union foo}.
2056
2057 Using the cast as the right-hand side of an assignment to a variable of
2058 union type is equivalent to storing in a member of the union:
2059
2060 @smallexample
2061 union foo u;
2062 /* @r{@dots{}} */
2063 u = (union foo) x @equiv{} u.i = x
2064 u = (union foo) y @equiv{} u.d = y
2065 @end smallexample
2066
2067 You can also use the union cast as a function argument:
2068
2069 @smallexample
2070 void hack (union foo);
2071 /* @r{@dots{}} */
2072 hack ((union foo) x);
2073 @end smallexample
2074
2075 @node Mixed Declarations
2076 @section Mixed Declarations and Code
2077 @cindex mixed declarations and code
2078 @cindex declarations, mixed with code
2079 @cindex code, mixed with declarations
2080
2081 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2082 within compound statements. As an extension, GNU C also allows this in
2083 C90 mode. For example, you could do:
2084
2085 @smallexample
2086 int i;
2087 /* @r{@dots{}} */
2088 i++;
2089 int j = i + 2;
2090 @end smallexample
2091
2092 Each identifier is visible from where it is declared until the end of
2093 the enclosing block.
2094
2095 @node Function Attributes
2096 @section Declaring Attributes of Functions
2097 @cindex function attributes
2098 @cindex declaring attributes of functions
2099 @cindex functions that never return
2100 @cindex functions that return more than once
2101 @cindex functions that have no side effects
2102 @cindex functions in arbitrary sections
2103 @cindex functions that behave like malloc
2104 @cindex @code{volatile} applied to function
2105 @cindex @code{const} applied to function
2106 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2107 @cindex functions with non-null pointer arguments
2108 @cindex functions that are passed arguments in registers on the 386
2109 @cindex functions that pop the argument stack on the 386
2110 @cindex functions that do not pop the argument stack on the 386
2111 @cindex functions that have different compilation options on the 386
2112 @cindex functions that have different optimization options
2113 @cindex functions that are dynamically resolved
2114
2115 In GNU C, you declare certain things about functions called in your program
2116 which help the compiler optimize function calls and check your code more
2117 carefully.
2118
2119 The keyword @code{__attribute__} allows you to specify special
2120 attributes when making a declaration. This keyword is followed by an
2121 attribute specification inside double parentheses. The following
2122 attributes are currently defined for functions on all targets:
2123 @code{aligned}, @code{alloc_size}, @code{noreturn},
2124 @code{returns_twice}, @code{noinline}, @code{noclone},
2125 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2126 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2127 @code{no_instrument_function}, @code{no_split_stack},
2128 @code{section}, @code{constructor},
2129 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2130 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2131 @code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
2132 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2133 @code{no_address_safety_analysis}, @code{error} and @code{warning}.
2134 Several other attributes are defined for functions on particular
2135 target systems. Other attributes, including @code{section} are
2136 supported for variables declarations (@pxref{Variable Attributes})
2137 and for types (@pxref{Type Attributes}).
2138
2139 GCC plugins may provide their own attributes.
2140
2141 You may also specify attributes with @samp{__} preceding and following
2142 each keyword. This allows you to use them in header files without
2143 being concerned about a possible macro of the same name. For example,
2144 you may use @code{__noreturn__} instead of @code{noreturn}.
2145
2146 @xref{Attribute Syntax}, for details of the exact syntax for using
2147 attributes.
2148
2149 @table @code
2150 @c Keep this table alphabetized by attribute name. Treat _ as space.
2151
2152 @item alias ("@var{target}")
2153 @cindex @code{alias} attribute
2154 The @code{alias} attribute causes the declaration to be emitted as an
2155 alias for another symbol, which must be specified. For instance,
2156
2157 @smallexample
2158 void __f () @{ /* @r{Do something.} */; @}
2159 void f () __attribute__ ((weak, alias ("__f")));
2160 @end smallexample
2161
2162 @noindent
2163 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2164 mangled name for the target must be used. It is an error if @samp{__f}
2165 is not defined in the same translation unit.
2166
2167 Not all target machines support this attribute.
2168
2169 @item aligned (@var{alignment})
2170 @cindex @code{aligned} attribute
2171 This attribute specifies a minimum alignment for the function,
2172 measured in bytes.
2173
2174 You cannot use this attribute to decrease the alignment of a function,
2175 only to increase it. However, when you explicitly specify a function
2176 alignment this overrides the effect of the
2177 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2178 function.
2179
2180 Note that the effectiveness of @code{aligned} attributes may be
2181 limited by inherent limitations in your linker. On many systems, the
2182 linker is only able to arrange for functions to be aligned up to a
2183 certain maximum alignment. (For some linkers, the maximum supported
2184 alignment may be very very small.) See your linker documentation for
2185 further information.
2186
2187 The @code{aligned} attribute can also be used for variables and fields
2188 (@pxref{Variable Attributes}.)
2189
2190 @item alloc_size
2191 @cindex @code{alloc_size} attribute
2192 The @code{alloc_size} attribute is used to tell the compiler that the
2193 function return value points to memory, where the size is given by
2194 one or two of the functions parameters. GCC uses this
2195 information to improve the correctness of @code{__builtin_object_size}.
2196
2197 The function parameter(s) denoting the allocated size are specified by
2198 one or two integer arguments supplied to the attribute. The allocated size
2199 is either the value of the single function argument specified or the product
2200 of the two function arguments specified. Argument numbering starts at
2201 one.
2202
2203 For instance,
2204
2205 @smallexample
2206 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2207 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2208 @end smallexample
2209
2210 @noindent
2211 declares that @code{my_calloc} returns memory of the size given by
2212 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2213 of the size given by parameter 2.
2214
2215 @item always_inline
2216 @cindex @code{always_inline} function attribute
2217 Generally, functions are not inlined unless optimization is specified.
2218 For functions declared inline, this attribute inlines the function even
2219 if no optimization level is specified.
2220
2221 @item gnu_inline
2222 @cindex @code{gnu_inline} function attribute
2223 This attribute should be used with a function that is also declared
2224 with the @code{inline} keyword. It directs GCC to treat the function
2225 as if it were defined in gnu90 mode even when compiling in C99 or
2226 gnu99 mode.
2227
2228 If the function is declared @code{extern}, then this definition of the
2229 function is used only for inlining. In no case is the function
2230 compiled as a standalone function, not even if you take its address
2231 explicitly. Such an address becomes an external reference, as if you
2232 had only declared the function, and had not defined it. This has
2233 almost the effect of a macro. The way to use this is to put a
2234 function definition in a header file with this attribute, and put
2235 another copy of the function, without @code{extern}, in a library
2236 file. The definition in the header file causes most calls to the
2237 function to be inlined. If any uses of the function remain, they
2238 refer to the single copy in the library. Note that the two
2239 definitions of the functions need not be precisely the same, although
2240 if they do not have the same effect your program may behave oddly.
2241
2242 In C, if the function is neither @code{extern} nor @code{static}, then
2243 the function is compiled as a standalone function, as well as being
2244 inlined where possible.
2245
2246 This is how GCC traditionally handled functions declared
2247 @code{inline}. Since ISO C99 specifies a different semantics for
2248 @code{inline}, this function attribute is provided as a transition
2249 measure and as a useful feature in its own right. This attribute is
2250 available in GCC 4.1.3 and later. It is available if either of the
2251 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2252 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2253 Function is As Fast As a Macro}.
2254
2255 In C++, this attribute does not depend on @code{extern} in any way,
2256 but it still requires the @code{inline} keyword to enable its special
2257 behavior.
2258
2259 @item artificial
2260 @cindex @code{artificial} function attribute
2261 This attribute is useful for small inline wrappers that if possible
2262 should appear during debugging as a unit. Depending on the debug
2263 info format it either means marking the function as artificial
2264 or using the caller location for all instructions within the inlined
2265 body.
2266
2267 @item bank_switch
2268 @cindex interrupt handler functions
2269 When added to an interrupt handler with the M32C port, causes the
2270 prologue and epilogue to use bank switching to preserve the registers
2271 rather than saving them on the stack.
2272
2273 @item flatten
2274 @cindex @code{flatten} function attribute
2275 Generally, inlining into a function is limited. For a function marked with
2276 this attribute, every call inside this function is inlined, if possible.
2277 Whether the function itself is considered for inlining depends on its size and
2278 the current inlining parameters.
2279
2280 @item error ("@var{message}")
2281 @cindex @code{error} function attribute
2282 If this attribute is used on a function declaration and a call to such a function
2283 is not eliminated through dead code elimination or other optimizations, an error
2284 that includes @var{message} is diagnosed. This is useful
2285 for compile-time checking, especially together with @code{__builtin_constant_p}
2286 and inline functions where checking the inline function arguments is not
2287 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2288 While it is possible to leave the function undefined and thus invoke
2289 a link failure, when using this attribute the problem is diagnosed
2290 earlier and with exact location of the call even in presence of inline
2291 functions or when not emitting debugging information.
2292
2293 @item warning ("@var{message}")
2294 @cindex @code{warning} function attribute
2295 If this attribute is used on a function declaration and a call to such a function
2296 is not eliminated through dead code elimination or other optimizations, a warning
2297 that includes @var{message} is diagnosed. This is useful
2298 for compile-time checking, especially together with @code{__builtin_constant_p}
2299 and inline functions. While it is possible to define the function with
2300 a message in @code{.gnu.warning*} section, when using this attribute the problem
2301 is diagnosed earlier and with exact location of the call even in presence
2302 of inline functions or when not emitting debugging information.
2303
2304 @item cdecl
2305 @cindex functions that do pop the argument stack on the 386
2306 @opindex mrtd
2307 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2308 assume that the calling function pops off the stack space used to
2309 pass arguments. This is
2310 useful to override the effects of the @option{-mrtd} switch.
2311
2312 @item const
2313 @cindex @code{const} function attribute
2314 Many functions do not examine any values except their arguments, and
2315 have no effects except the return value. Basically this is just slightly
2316 more strict class than the @code{pure} attribute below, since function is not
2317 allowed to read global memory.
2318
2319 @cindex pointer arguments
2320 Note that a function that has pointer arguments and examines the data
2321 pointed to must @emph{not} be declared @code{const}. Likewise, a
2322 function that calls a non-@code{const} function usually must not be
2323 @code{const}. It does not make sense for a @code{const} function to
2324 return @code{void}.
2325
2326 The attribute @code{const} is not implemented in GCC versions earlier
2327 than 2.5. An alternative way to declare that a function has no side
2328 effects, which works in the current version and in some older versions,
2329 is as follows:
2330
2331 @smallexample
2332 typedef int intfn ();
2333
2334 extern const intfn square;
2335 @end smallexample
2336
2337 @noindent
2338 This approach does not work in GNU C++ from 2.6.0 on, since the language
2339 specifies that the @samp{const} must be attached to the return value.
2340
2341 @item constructor
2342 @itemx destructor
2343 @itemx constructor (@var{priority})
2344 @itemx destructor (@var{priority})
2345 @cindex @code{constructor} function attribute
2346 @cindex @code{destructor} function attribute
2347 The @code{constructor} attribute causes the function to be called
2348 automatically before execution enters @code{main ()}. Similarly, the
2349 @code{destructor} attribute causes the function to be called
2350 automatically after @code{main ()} completes or @code{exit ()} is
2351 called. Functions with these attributes are useful for
2352 initializing data that is used implicitly during the execution of
2353 the program.
2354
2355 You may provide an optional integer priority to control the order in
2356 which constructor and destructor functions are run. A constructor
2357 with a smaller priority number runs before a constructor with a larger
2358 priority number; the opposite relationship holds for destructors. So,
2359 if you have a constructor that allocates a resource and a destructor
2360 that deallocates the same resource, both functions typically have the
2361 same priority. The priorities for constructor and destructor
2362 functions are the same as those specified for namespace-scope C++
2363 objects (@pxref{C++ Attributes}).
2364
2365 These attributes are not currently implemented for Objective-C@.
2366
2367 @item deprecated
2368 @itemx deprecated (@var{msg})
2369 @cindex @code{deprecated} attribute.
2370 The @code{deprecated} attribute results in a warning if the function
2371 is used anywhere in the source file. This is useful when identifying
2372 functions that are expected to be removed in a future version of a
2373 program. The warning also includes the location of the declaration
2374 of the deprecated function, to enable users to easily find further
2375 information about why the function is deprecated, or what they should
2376 do instead. Note that the warnings only occurs for uses:
2377
2378 @smallexample
2379 int old_fn () __attribute__ ((deprecated));
2380 int old_fn ();
2381 int (*fn_ptr)() = old_fn;
2382 @end smallexample
2383
2384 @noindent
2385 results in a warning on line 3 but not line 2. The optional @var{msg}
2386 argument, which must be a string, is printed in the warning if
2387 present.
2388
2389 The @code{deprecated} attribute can also be used for variables and
2390 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2391
2392 @item disinterrupt
2393 @cindex @code{disinterrupt} attribute
2394 On Epiphany and MeP targets, this attribute causes the compiler to emit
2395 instructions to disable interrupts for the duration of the given
2396 function.
2397
2398 @item dllexport
2399 @cindex @code{__declspec(dllexport)}
2400 On Microsoft Windows targets and Symbian OS targets the
2401 @code{dllexport} attribute causes the compiler to provide a global
2402 pointer to a pointer in a DLL, so that it can be referenced with the
2403 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2404 name is formed by combining @code{_imp__} and the function or variable
2405 name.
2406
2407 You can use @code{__declspec(dllexport)} as a synonym for
2408 @code{__attribute__ ((dllexport))} for compatibility with other
2409 compilers.
2410
2411 On systems that support the @code{visibility} attribute, this
2412 attribute also implies ``default'' visibility. It is an error to
2413 explicitly specify any other visibility.
2414
2415 In previous versions of GCC, the @code{dllexport} attribute was ignored
2416 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2417 had been used. The default behavior now is to emit all dllexported
2418 inline functions; however, this can cause object file-size bloat, in
2419 which case the old behavior can be restored by using
2420 @option{-fno-keep-inline-dllexport}.
2421
2422 The attribute is also ignored for undefined symbols.
2423
2424 When applied to C++ classes, the attribute marks defined non-inlined
2425 member functions and static data members as exports. Static consts
2426 initialized in-class are not marked unless they are also defined
2427 out-of-class.
2428
2429 For Microsoft Windows targets there are alternative methods for
2430 including the symbol in the DLL's export table such as using a
2431 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2432 the @option{--export-all} linker flag.
2433
2434 @item dllimport
2435 @cindex @code{__declspec(dllimport)}
2436 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2437 attribute causes the compiler to reference a function or variable via
2438 a global pointer to a pointer that is set up by the DLL exporting the
2439 symbol. The attribute implies @code{extern}. On Microsoft Windows
2440 targets, the pointer name is formed by combining @code{_imp__} and the
2441 function or variable name.
2442
2443 You can use @code{__declspec(dllimport)} as a synonym for
2444 @code{__attribute__ ((dllimport))} for compatibility with other
2445 compilers.
2446
2447 On systems that support the @code{visibility} attribute, this
2448 attribute also implies ``default'' visibility. It is an error to
2449 explicitly specify any other visibility.
2450
2451 Currently, the attribute is ignored for inlined functions. If the
2452 attribute is applied to a symbol @emph{definition}, an error is reported.
2453 If a symbol previously declared @code{dllimport} is later defined, the
2454 attribute is ignored in subsequent references, and a warning is emitted.
2455 The attribute is also overridden by a subsequent declaration as
2456 @code{dllexport}.
2457
2458 When applied to C++ classes, the attribute marks non-inlined
2459 member functions and static data members as imports. However, the
2460 attribute is ignored for virtual methods to allow creation of vtables
2461 using thunks.
2462
2463 On the SH Symbian OS target the @code{dllimport} attribute also has
2464 another affect---it can cause the vtable and run-time type information
2465 for a class to be exported. This happens when the class has a
2466 dllimport'ed constructor or a non-inline, non-pure virtual function
2467 and, for either of those two conditions, the class also has an inline
2468 constructor or destructor and has a key function that is defined in
2469 the current translation unit.
2470
2471 For Microsoft Windows targets the use of the @code{dllimport}
2472 attribute on functions is not necessary, but provides a small
2473 performance benefit by eliminating a thunk in the DLL@. The use of the
2474 @code{dllimport} attribute on imported variables was required on older
2475 versions of the GNU linker, but can now be avoided by passing the
2476 @option{--enable-auto-import} switch to the GNU linker. As with
2477 functions, using the attribute for a variable eliminates a thunk in
2478 the DLL@.
2479
2480 One drawback to using this attribute is that a pointer to a
2481 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2482 address. However, a pointer to a @emph{function} with the
2483 @code{dllimport} attribute can be used as a constant initializer; in
2484 this case, the address of a stub function in the import lib is
2485 referenced. On Microsoft Windows targets, the attribute can be disabled
2486 for functions by setting the @option{-mnop-fun-dllimport} flag.
2487
2488 @item eightbit_data
2489 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2490 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2491 variable should be placed into the eight-bit data section.
2492 The compiler generates more efficient code for certain operations
2493 on data in the eight-bit data area. Note the eight-bit data area is limited to
2494 256 bytes of data.
2495
2496 You must use GAS and GLD from GNU binutils version 2.7 or later for
2497 this attribute to work correctly.
2498
2499 @item exception_handler
2500 @cindex exception handler functions on the Blackfin processor
2501 Use this attribute on the Blackfin to indicate that the specified function
2502 is an exception handler. The compiler generates function entry and
2503 exit sequences suitable for use in an exception handler when this
2504 attribute is present.
2505
2506 @item externally_visible
2507 @cindex @code{externally_visible} attribute.
2508 This attribute, attached to a global variable or function, nullifies
2509 the effect of the @option{-fwhole-program} command-line option, so the
2510 object remains visible outside the current compilation unit. If @option{-fwhole-program} is used together with @option{-flto} and @command{gold} is used as the linker plugin, @code{externally_visible} attributes are automatically added to functions (not variable yet due to a current @command{gold} issue) that are accessed outside of LTO objects according to resolution file produced by @command{gold}. For other linkers that cannot generate resolution file, explicit @code{externally_visible} attributes are still necessary.
2511
2512 @item far
2513 @cindex functions that handle memory bank switching
2514 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2515 use a calling convention that takes care of switching memory banks when
2516 entering and leaving a function. This calling convention is also the
2517 default when using the @option{-mlong-calls} option.
2518
2519 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2520 to call and return from a function.
2521
2522 On 68HC11 the compiler generates a sequence of instructions
2523 to invoke a board-specific routine to switch the memory bank and call the
2524 real function. The board-specific routine simulates a @code{call}.
2525 At the end of a function, it jumps to a board-specific routine
2526 instead of using @code{rts}. The board-specific return routine simulates
2527 the @code{rtc}.
2528
2529 On MeP targets this causes the compiler to use a calling convention
2530 that assumes the called function is too far away for the built-in
2531 addressing modes.
2532
2533 @item fast_interrupt
2534 @cindex interrupt handler functions
2535 Use this attribute on the M32C and RX ports to indicate that the specified
2536 function is a fast interrupt handler. This is just like the
2537 @code{interrupt} attribute, except that @code{freit} is used to return
2538 instead of @code{reit}.
2539
2540 @item fastcall
2541 @cindex functions that pop the argument stack on the 386
2542 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2543 pass the first argument (if of integral type) in the register ECX and
2544 the second argument (if of integral type) in the register EDX@. Subsequent
2545 and other typed arguments are passed on the stack. The called function
2546 pops the arguments off the stack. If the number of arguments is variable all
2547 arguments are pushed on the stack.
2548
2549 @item thiscall
2550 @cindex functions that pop the argument stack on the 386
2551 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2552 pass the first argument (if of integral type) in the register ECX.
2553 Subsequent and other typed arguments are passed on the stack. The called
2554 function pops the arguments off the stack.
2555 If the number of arguments is variable all arguments are pushed on the
2556 stack.
2557 The @code{thiscall} attribute is intended for C++ non-static member functions.
2558 As a GCC extension, this calling convention can be used for C functions
2559 and for static member methods.
2560
2561 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2562 @cindex @code{format} function attribute
2563 @opindex Wformat
2564 The @code{format} attribute specifies that a function takes @code{printf},
2565 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2566 should be type-checked against a format string. For example, the
2567 declaration:
2568
2569 @smallexample
2570 extern int
2571 my_printf (void *my_object, const char *my_format, ...)
2572 __attribute__ ((format (printf, 2, 3)));
2573 @end smallexample
2574
2575 @noindent
2576 causes the compiler to check the arguments in calls to @code{my_printf}
2577 for consistency with the @code{printf} style format string argument
2578 @code{my_format}.
2579
2580 The parameter @var{archetype} determines how the format string is
2581 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2582 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2583 @code{strfmon}. (You can also use @code{__printf__},
2584 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2585 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2586 @code{ms_strftime} are also present.
2587 @var{archtype} values such as @code{printf} refer to the formats accepted
2588 by the system's C runtime library, while @code{gnu_} values always refer
2589 to the formats accepted by the GNU C Library. On Microsoft Windows
2590 targets, @code{ms_} values refer to the formats accepted by the
2591 @file{msvcrt.dll} library.
2592 The parameter @var{string-index}
2593 specifies which argument is the format string argument (starting
2594 from 1), while @var{first-to-check} is the number of the first
2595 argument to check against the format string. For functions
2596 where the arguments are not available to be checked (such as
2597 @code{vprintf}), specify the third parameter as zero. In this case the
2598 compiler only checks the format string for consistency. For
2599 @code{strftime} formats, the third parameter is required to be zero.
2600 Since non-static C++ methods have an implicit @code{this} argument, the
2601 arguments of such methods should be counted from two, not one, when
2602 giving values for @var{string-index} and @var{first-to-check}.
2603
2604 In the example above, the format string (@code{my_format}) is the second
2605 argument of the function @code{my_print}, and the arguments to check
2606 start with the third argument, so the correct parameters for the format
2607 attribute are 2 and 3.
2608
2609 @opindex ffreestanding
2610 @opindex fno-builtin
2611 The @code{format} attribute allows you to identify your own functions
2612 that take format strings as arguments, so that GCC can check the
2613 calls to these functions for errors. The compiler always (unless
2614 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2615 for the standard library functions @code{printf}, @code{fprintf},
2616 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2617 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2618 warnings are requested (using @option{-Wformat}), so there is no need to
2619 modify the header file @file{stdio.h}. In C99 mode, the functions
2620 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2621 @code{vsscanf} are also checked. Except in strictly conforming C
2622 standard modes, the X/Open function @code{strfmon} is also checked as
2623 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2624 @xref{C Dialect Options,,Options Controlling C Dialect}.
2625
2626 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2627 recognized in the same context. Declarations including these format attributes
2628 are parsed for correct syntax, however the result of checking of such format
2629 strings is not yet defined, and is not carried out by this version of the
2630 compiler.
2631
2632 The target may also provide additional types of format checks.
2633 @xref{Target Format Checks,,Format Checks Specific to Particular
2634 Target Machines}.
2635
2636 @item format_arg (@var{string-index})
2637 @cindex @code{format_arg} function attribute
2638 @opindex Wformat-nonliteral
2639 The @code{format_arg} attribute specifies that a function takes a format
2640 string for a @code{printf}, @code{scanf}, @code{strftime} or
2641 @code{strfmon} style function and modifies it (for example, to translate
2642 it into another language), so the result can be passed to a
2643 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2644 function (with the remaining arguments to the format function the same
2645 as they would have been for the unmodified string). For example, the
2646 declaration:
2647
2648 @smallexample
2649 extern char *
2650 my_dgettext (char *my_domain, const char *my_format)
2651 __attribute__ ((format_arg (2)));
2652 @end smallexample
2653
2654 @noindent
2655 causes the compiler to check the arguments in calls to a @code{printf},
2656 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2657 format string argument is a call to the @code{my_dgettext} function, for
2658 consistency with the format string argument @code{my_format}. If the
2659 @code{format_arg} attribute had not been specified, all the compiler
2660 could tell in such calls to format functions would be that the format
2661 string argument is not constant; this would generate a warning when
2662 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2663 without the attribute.
2664
2665 The parameter @var{string-index} specifies which argument is the format
2666 string argument (starting from one). Since non-static C++ methods have
2667 an implicit @code{this} argument, the arguments of such methods should
2668 be counted from two.
2669
2670 The @code{format-arg} attribute allows you to identify your own
2671 functions that modify format strings, so that GCC can check the
2672 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2673 type function whose operands are a call to one of your own function.
2674 The compiler always treats @code{gettext}, @code{dgettext}, and
2675 @code{dcgettext} in this manner except when strict ISO C support is
2676 requested by @option{-ansi} or an appropriate @option{-std} option, or
2677 @option{-ffreestanding} or @option{-fno-builtin}
2678 is used. @xref{C Dialect Options,,Options
2679 Controlling C Dialect}.
2680
2681 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2682 @code{NSString} reference for compatibility with the @code{format} attribute
2683 above.
2684
2685 The target may also allow additional types in @code{format-arg} attributes.
2686 @xref{Target Format Checks,,Format Checks Specific to Particular
2687 Target Machines}.
2688
2689 @item function_vector
2690 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2691 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2692 function should be called through the function vector. Calling a
2693 function through the function vector reduces code size, however;
2694 the function vector has a limited size (maximum 128 entries on the H8/300
2695 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2696
2697 On SH2A targets, this attribute declares a function to be called using the
2698 TBR relative addressing mode. The argument to this attribute is the entry
2699 number of the same function in a vector table containing all the TBR
2700 relative addressable functions. For correct operation the TBR must be setup
2701 accordingly to point to the start of the vector table before any functions with
2702 this attribute are invoked. Usually a good place to do the initialization is
2703 the startup routine. The TBR relative vector table can have at max 256 function
2704 entries. The jumps to these functions are generated using a SH2A specific,
2705 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2706 from GNU binutils version 2.7 or later for this attribute to work correctly.
2707
2708 Please refer the example of M16C target, to see the use of this
2709 attribute while declaring a function,
2710
2711 In an application, for a function being called once, this attribute
2712 saves at least 8 bytes of code; and if other successive calls are being
2713 made to the same function, it saves 2 bytes of code per each of these
2714 calls.
2715
2716 On M16C/M32C targets, the @code{function_vector} attribute declares a
2717 special page subroutine call function. Use of this attribute reduces
2718 the code size by 2 bytes for each call generated to the
2719 subroutine. The argument to the attribute is the vector number entry
2720 from the special page vector table which contains the 16 low-order
2721 bits of the subroutine's entry address. Each vector table has special
2722 page number (18 to 255) that is used in @code{jsrs} instructions.
2723 Jump addresses of the routines are generated by adding 0x0F0000 (in
2724 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2725 2-byte addresses set in the vector table. Therefore you need to ensure
2726 that all the special page vector routines should get mapped within the
2727 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2728 (for M32C).
2729
2730 In the following example 2 bytes are saved for each call to
2731 function @code{foo}.
2732
2733 @smallexample
2734 void foo (void) __attribute__((function_vector(0x18)));
2735 void foo (void)
2736 @{
2737 @}
2738
2739 void bar (void)
2740 @{
2741 foo();
2742 @}
2743 @end smallexample
2744
2745 If functions are defined in one file and are called in another file,
2746 then be sure to write this declaration in both files.
2747
2748 This attribute is ignored for R8C target.
2749
2750 @item ifunc ("@var{resolver}")
2751 @cindex @code{ifunc} attribute
2752 The @code{ifunc} attribute is used to mark a function as an indirect
2753 function using the STT_GNU_IFUNC symbol type extension to the ELF
2754 standard. This allows the resolution of the symbol value to be
2755 determined dynamically at load time, and an optimized version of the
2756 routine can be selected for the particular processor or other system
2757 characteristics determined then. To use this attribute, first define
2758 the implementation functions available, and a resolver function that
2759 returns a pointer to the selected implementation function. The
2760 implementation functions' declarations must match the API of the
2761 function being implemented, the resolver's declaration is be a
2762 function returning pointer to void function returning void:
2763
2764 @smallexample
2765 void *my_memcpy (void *dst, const void *src, size_t len)
2766 @{
2767 @dots{}
2768 @}
2769
2770 static void (*resolve_memcpy (void)) (void)
2771 @{
2772 return my_memcpy; // we'll just always select this routine
2773 @}
2774 @end smallexample
2775
2776 @noindent
2777 The exported header file declaring the function the user calls would
2778 contain:
2779
2780 @smallexample
2781 extern void *memcpy (void *, const void *, size_t);
2782 @end smallexample
2783
2784 @noindent
2785 allowing the user to call this as a regular function, unaware of the
2786 implementation. Finally, the indirect function needs to be defined in
2787 the same translation unit as the resolver function:
2788
2789 @smallexample
2790 void *memcpy (void *, const void *, size_t)
2791 __attribute__ ((ifunc ("resolve_memcpy")));
2792 @end smallexample
2793
2794 Indirect functions cannot be weak, and require a recent binutils (at
2795 least version 2.20.1), and GNU C library (at least version 2.11.1).
2796
2797 @item interrupt
2798 @cindex interrupt handler functions
2799 Use this attribute on the ARM, AVR, CR16, Epiphany, M32C, M32R/D, m68k, MeP, MIPS,
2800 RL78, RX and Xstormy16 ports to indicate that the specified function is an
2801 interrupt handler. The compiler generates function entry and exit
2802 sequences suitable for use in an interrupt handler when this attribute
2803 is present. With Epiphany targets it may also generate a special section with
2804 code to initialize the interrupt vector table.
2805
2806 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2807 and SH processors can be specified via the @code{interrupt_handler} attribute.
2808
2809 Note, on the AVR, the hardware globally disables interrupts when an
2810 interrupt is executed. The first instruction of an interrupt handler
2811 declared with this attribute is a @code{SEI} instruction to
2812 re-enable interrupts. See also the @code{signal} function attribute
2813 that does not insert a @code{SEI} instuction. If both @code{signal} and
2814 @code{interrupt} are specified for the same function, @code{signal}
2815 is silently ignored.
2816
2817 Note, for the ARM, you can specify the kind of interrupt to be handled by
2818 adding an optional parameter to the interrupt attribute like this:
2819
2820 @smallexample
2821 void f () __attribute__ ((interrupt ("IRQ")));
2822 @end smallexample
2823
2824 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
2825
2826 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2827 may be called with a word-aligned stack pointer.
2828
2829 On Epiphany targets one or more optional parameters can be added like this:
2830
2831 @smallexample
2832 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2833 @end smallexample
2834
2835 Permissible values for these parameters are: @w{@code{reset}},
2836 @w{@code{software_exception}}, @w{@code{page_miss}},
2837 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2838 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2839 Multiple parameters indicate that multiple entries in the interrupt
2840 vector table should be initialized for this function, i.e.@: for each
2841 parameter @w{@var{name}}, a jump to the function is emitted in
2842 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2843 entirely, in which case no interrupt vector table entry is provided.
2844
2845 Note, on Epiphany targets, interrupts are enabled inside the function
2846 unless the @code{disinterrupt} attribute is also specified.
2847
2848 On Epiphany targets, you can also use the following attribute to
2849 modify the behavior of an interrupt handler:
2850 @table @code
2851 @item forwarder_section
2852 @cindex @code{forwarder_section} attribute
2853 The interrupt handler may be in external memory which cannot be
2854 reached by a branch instruction, so generate a local memory trampoline
2855 to transfer control. The single parameter identifies the section where
2856 the trampoline is placed.
2857 @end table
2858
2859 The following examples are all valid uses of these attributes on
2860 Epiphany targets:
2861 @smallexample
2862 void __attribute__ ((interrupt)) universal_handler ();
2863 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2864 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2865 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2866 fast_timer_handler ();
2867 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2868 external_dma_handler ();
2869 @end smallexample
2870
2871 On MIPS targets, you can use the following attributes to modify the behavior
2872 of an interrupt handler:
2873 @table @code
2874 @item use_shadow_register_set
2875 @cindex @code{use_shadow_register_set} attribute
2876 Assume that the handler uses a shadow register set, instead of
2877 the main general-purpose registers.
2878
2879 @item keep_interrupts_masked
2880 @cindex @code{keep_interrupts_masked} attribute
2881 Keep interrupts masked for the whole function. Without this attribute,
2882 GCC tries to reenable interrupts for as much of the function as it can.
2883
2884 @item use_debug_exception_return
2885 @cindex @code{use_debug_exception_return} attribute
2886 Return using the @code{deret} instruction. Interrupt handlers that don't
2887 have this attribute return using @code{eret} instead.
2888 @end table
2889
2890 You can use any combination of these attributes, as shown below:
2891 @smallexample
2892 void __attribute__ ((interrupt)) v0 ();
2893 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2894 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2895 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2896 void __attribute__ ((interrupt, use_shadow_register_set,
2897 keep_interrupts_masked)) v4 ();
2898 void __attribute__ ((interrupt, use_shadow_register_set,
2899 use_debug_exception_return)) v5 ();
2900 void __attribute__ ((interrupt, keep_interrupts_masked,
2901 use_debug_exception_return)) v6 ();
2902 void __attribute__ ((interrupt, use_shadow_register_set,
2903 keep_interrupts_masked,
2904 use_debug_exception_return)) v7 ();
2905 @end smallexample
2906
2907 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
2908 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
2909 that must end with @code{RETB} instead of @code{RETI}).
2910
2911 @item interrupt_handler
2912 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2913 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2914 indicate that the specified function is an interrupt handler. The compiler
2915 generates function entry and exit sequences suitable for use in an
2916 interrupt handler when this attribute is present.
2917
2918 @item interrupt_thread
2919 @cindex interrupt thread functions on fido
2920 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2921 that the specified function is an interrupt handler that is designed
2922 to run as a thread. The compiler omits generate prologue/epilogue
2923 sequences and replaces the return instruction with a @code{sleep}
2924 instruction. This attribute is available only on fido.
2925
2926 @item isr
2927 @cindex interrupt service routines on ARM
2928 Use this attribute on ARM to write Interrupt Service Routines. This is an
2929 alias to the @code{interrupt} attribute above.
2930
2931 @item kspisusp
2932 @cindex User stack pointer in interrupts on the Blackfin
2933 When used together with @code{interrupt_handler}, @code{exception_handler}
2934 or @code{nmi_handler}, code is generated to load the stack pointer
2935 from the USP register in the function prologue.
2936
2937 @item l1_text
2938 @cindex @code{l1_text} function attribute
2939 This attribute specifies a function to be placed into L1 Instruction
2940 SRAM@. The function is put into a specific section named @code{.l1.text}.
2941 With @option{-mfdpic}, function calls with a such function as the callee
2942 or caller uses inlined PLT.
2943
2944 @item l2
2945 @cindex @code{l2} function attribute
2946 On the Blackfin, this attribute specifies a function to be placed into L2
2947 SRAM. The function is put into a specific section named
2948 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
2949 an inlined PLT.
2950
2951 @item leaf
2952 @cindex @code{leaf} function attribute
2953 Calls to external functions with this attribute must return to the current
2954 compilation unit only by return or by exception handling. In particular, leaf
2955 functions are not allowed to call callback function passed to it from the current
2956 compilation unit or directly call functions exported by the unit or longjmp
2957 into the unit. Leaf function might still call functions from other compilation
2958 units and thus they are not necessarily leaf in the sense that they contain no
2959 function calls at all.
2960
2961 The attribute is intended for library functions to improve dataflow analysis.
2962 The compiler takes the hint that any data not escaping the current compilation unit can
2963 not be used or modified by the leaf function. For example, the @code{sin} function
2964 is a leaf function, but @code{qsort} is not.
2965
2966 Note that leaf functions might invoke signals and signal handlers might be
2967 defined in the current compilation unit and use static variables. The only
2968 compliant way to write such a signal handler is to declare such variables
2969 @code{volatile}.
2970
2971 The attribute has no effect on functions defined within the current compilation
2972 unit. This is to allow easy merging of multiple compilation units into one,
2973 for example, by using the link-time optimization. For this reason the
2974 attribute is not allowed on types to annotate indirect calls.
2975
2976 @item long_call/short_call
2977 @cindex indirect calls on ARM
2978 This attribute specifies how a particular function is called on
2979 ARM and Epiphany. Both attributes override the
2980 @option{-mlong-calls} (@pxref{ARM Options})
2981 command-line switch and @code{#pragma long_calls} settings. The
2982 @code{long_call} attribute indicates that the function might be far
2983 away from the call site and require a different (more expensive)
2984 calling sequence. The @code{short_call} attribute always places
2985 the offset to the function from the call site into the @samp{BL}
2986 instruction directly.
2987
2988 @item longcall/shortcall
2989 @cindex functions called via pointer on the RS/6000 and PowerPC
2990 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
2991 indicates that the function might be far away from the call site and
2992 require a different (more expensive) calling sequence. The
2993 @code{shortcall} attribute indicates that the function is always close
2994 enough for the shorter calling sequence to be used. These attributes
2995 override both the @option{-mlongcall} switch and, on the RS/6000 and
2996 PowerPC, the @code{#pragma longcall} setting.
2997
2998 @xref{RS/6000 and PowerPC Options}, for more information on whether long
2999 calls are necessary.
3000
3001 @item long_call/near/far
3002 @cindex indirect calls on MIPS
3003 These attributes specify how a particular function is called on MIPS@.
3004 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3005 command-line switch. The @code{long_call} and @code{far} attributes are
3006 synonyms, and cause the compiler to always call
3007 the function by first loading its address into a register, and then using
3008 the contents of that register. The @code{near} attribute has the opposite
3009 effect; it specifies that non-PIC calls should be made using the more
3010 efficient @code{jal} instruction.
3011
3012 @item malloc
3013 @cindex @code{malloc} attribute
3014 The @code{malloc} attribute is used to tell the compiler that a function
3015 may be treated as if any non-@code{NULL} pointer it returns cannot
3016 alias any other pointer valid when the function returns and that the memory
3017 has undefined content.
3018 This often improves optimization.
3019 Standard functions with this property include @code{malloc} and
3020 @code{calloc}. @code{realloc}-like functions do not have this
3021 property as the memory pointed to does not have undefined content.
3022
3023 @item mips16/nomips16
3024 @cindex @code{mips16} attribute
3025 @cindex @code{nomips16} attribute
3026
3027 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3028 function attributes to locally select or turn off MIPS16 code generation.
3029 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3030 while MIPS16 code generation is disabled for functions with the
3031 @code{nomips16} attribute. These attributes override the
3032 @option{-mips16} and @option{-mno-mips16} options on the command line
3033 (@pxref{MIPS Options}).
3034
3035 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3036 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3037 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3038 may interact badly with some GCC extensions such as @code{__builtin_apply}
3039 (@pxref{Constructing Calls}).
3040
3041 @item model (@var{model-name})
3042 @cindex function addressability on the M32R/D
3043 @cindex variable addressability on the IA-64
3044
3045 On the M32R/D, use this attribute to set the addressability of an
3046 object, and of the code generated for a function. The identifier
3047 @var{model-name} is one of @code{small}, @code{medium}, or
3048 @code{large}, representing each of the code models.
3049
3050 Small model objects live in the lower 16MB of memory (so that their
3051 addresses can be loaded with the @code{ld24} instruction), and are
3052 callable with the @code{bl} instruction.
3053
3054 Medium model objects may live anywhere in the 32-bit address space (the
3055 compiler generates @code{seth/add3} instructions to load their addresses),
3056 and are callable with the @code{bl} instruction.
3057
3058 Large model objects may live anywhere in the 32-bit address space (the
3059 compiler generates @code{seth/add3} instructions to load their addresses),
3060 and may not be reachable with the @code{bl} instruction (the compiler
3061 generates the much slower @code{seth/add3/jl} instruction sequence).
3062
3063 On IA-64, use this attribute to set the addressability of an object.
3064 At present, the only supported identifier for @var{model-name} is
3065 @code{small}, indicating addressability via ``small'' (22-bit)
3066 addresses (so that their addresses can be loaded with the @code{addl}
3067 instruction). Caveat: such addressing is by definition not position
3068 independent and hence this attribute must not be used for objects
3069 defined by shared libraries.
3070
3071 @item ms_abi/sysv_abi
3072 @cindex @code{ms_abi} attribute
3073 @cindex @code{sysv_abi} attribute
3074
3075 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3076 to indicate which calling convention should be used for a function. The
3077 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3078 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3079 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3080 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3081
3082 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3083 requires the @option{-maccumulate-outgoing-args} option.
3084
3085 @item callee_pop_aggregate_return (@var{number})
3086 @cindex @code{callee_pop_aggregate_return} attribute
3087
3088 On 32-bit i?86-*-* targets, you can control by those attribute for
3089 aggregate return in memory, if the caller is responsible to pop the hidden
3090 pointer together with the rest of the arguments - @var{number} equal to
3091 zero -, or if the callee is responsible to pop hidden pointer - @var{number}
3092 equal to one. The default i386 ABI assumes that the callee pops the
3093 stack for hidden pointer.
3094
3095 Note that on 32-bit i386 Microsoft Windows targets,
3096 the compiler assumes that the
3097 caller pops the stack for hidden pointer.
3098
3099 @item ms_hook_prologue
3100 @cindex @code{ms_hook_prologue} attribute
3101
3102 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3103 this function attribute to make GCC generate the ``hot-patching'' function
3104 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3105 and newer.
3106
3107 @item naked
3108 @cindex function without a prologue/epilogue code
3109 Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
3110 the specified function does not need prologue/epilogue sequences generated by
3111 the compiler. It is up to the programmer to provide these sequences. The
3112 only statements that can be safely included in naked functions are
3113 @code{asm} statements that do not have operands. All other statements,
3114 including declarations of local variables, @code{if} statements, and so
3115 forth, should be avoided. Naked functions should be used to implement the
3116 body of an assembly function, while allowing the compiler to construct
3117 the requisite function declaration for the assembler.
3118
3119 @item near
3120 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3121 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3122 use the normal calling convention based on @code{jsr} and @code{rts}.
3123 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3124 option.
3125
3126 On MeP targets this attribute causes the compiler to assume the called
3127 function is close enough to use the normal calling convention,
3128 overriding the @code{-mtf} command-line option.
3129
3130 @item nesting
3131 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3132 Use this attribute together with @code{interrupt_handler},
3133 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3134 entry code should enable nested interrupts or exceptions.
3135
3136 @item nmi_handler
3137 @cindex NMI handler functions on the Blackfin processor
3138 Use this attribute on the Blackfin to indicate that the specified function
3139 is an NMI handler. The compiler generates function entry and
3140 exit sequences suitable for use in an NMI handler when this
3141 attribute is present.
3142
3143 @item no_instrument_function
3144 @cindex @code{no_instrument_function} function attribute
3145 @opindex finstrument-functions
3146 If @option{-finstrument-functions} is given, profiling function calls are
3147 generated at entry and exit of most user-compiled functions.
3148 Functions with this attribute are not so instrumented.
3149
3150 @item no_split_stack
3151 @cindex @code{no_split_stack} function attribute
3152 @opindex fsplit-stack
3153 If @option{-fsplit-stack} is given, functions have a small
3154 prologue which decides whether to split the stack. Functions with the
3155 @code{no_split_stack} attribute do not have that prologue, and thus
3156 may run with only a small amount of stack space available.
3157
3158 @item noinline
3159 @cindex @code{noinline} function attribute
3160 This function attribute prevents a function from being considered for
3161 inlining.
3162 @c Don't enumerate the optimizations by name here; we try to be
3163 @c future-compatible with this mechanism.
3164 If the function does not have side-effects, there are optimizations
3165 other than inlining that cause function calls to be optimized away,
3166 although the function call is live. To keep such calls from being
3167 optimized away, put
3168 @smallexample
3169 asm ("");
3170 @end smallexample
3171
3172 @noindent
3173 (@pxref{Extended Asm}) in the called function, to serve as a special
3174 side-effect.
3175
3176 @item noclone
3177 @cindex @code{noclone} function attribute
3178 This function attribute prevents a function from being considered for
3179 cloning---a mechanism that produces specialized copies of functions
3180 and which is (currently) performed by interprocedural constant
3181 propagation.
3182
3183 @item nonnull (@var{arg-index}, @dots{})
3184 @cindex @code{nonnull} function attribute
3185 The @code{nonnull} attribute specifies that some function parameters should
3186 be non-null pointers. For instance, the declaration:
3187
3188 @smallexample
3189 extern void *
3190 my_memcpy (void *dest, const void *src, size_t len)
3191 __attribute__((nonnull (1, 2)));
3192 @end smallexample
3193
3194 @noindent
3195 causes the compiler to check that, in calls to @code{my_memcpy},
3196 arguments @var{dest} and @var{src} are non-null. If the compiler
3197 determines that a null pointer is passed in an argument slot marked
3198 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3199 is issued. The compiler may also choose to make optimizations based
3200 on the knowledge that certain function arguments will never be null.
3201
3202 If no argument index list is given to the @code{nonnull} attribute,
3203 all pointer arguments are marked as non-null. To illustrate, the
3204 following declaration is equivalent to the previous example:
3205
3206 @smallexample
3207 extern void *
3208 my_memcpy (void *dest, const void *src, size_t len)
3209 __attribute__((nonnull));
3210 @end smallexample
3211
3212 @item noreturn
3213 @cindex @code{noreturn} function attribute
3214 A few standard library functions, such as @code{abort} and @code{exit},
3215 cannot return. GCC knows this automatically. Some programs define
3216 their own functions that never return. You can declare them
3217 @code{noreturn} to tell the compiler this fact. For example,
3218
3219 @smallexample
3220 @group
3221 void fatal () __attribute__ ((noreturn));
3222
3223 void
3224 fatal (/* @r{@dots{}} */)
3225 @{
3226 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3227 exit (1);
3228 @}
3229 @end group
3230 @end smallexample
3231
3232 The @code{noreturn} keyword tells the compiler to assume that
3233 @code{fatal} cannot return. It can then optimize without regard to what
3234 would happen if @code{fatal} ever did return. This makes slightly
3235 better code. More importantly, it helps avoid spurious warnings of
3236 uninitialized variables.
3237
3238 The @code{noreturn} keyword does not affect the exceptional path when that
3239 applies: a @code{noreturn}-marked function may still return to the caller
3240 by throwing an exception or calling @code{longjmp}.
3241
3242 Do not assume that registers saved by the calling function are
3243 restored before calling the @code{noreturn} function.
3244
3245 It does not make sense for a @code{noreturn} function to have a return
3246 type other than @code{void}.
3247
3248 The attribute @code{noreturn} is not implemented in GCC versions
3249 earlier than 2.5. An alternative way to declare that a function does
3250 not return, which works in the current version and in some older
3251 versions, is as follows:
3252
3253 @smallexample
3254 typedef void voidfn ();
3255
3256 volatile voidfn fatal;
3257 @end smallexample
3258
3259 @noindent
3260 This approach does not work in GNU C++.
3261
3262 @item nothrow
3263 @cindex @code{nothrow} function attribute
3264 The @code{nothrow} attribute is used to inform the compiler that a
3265 function cannot throw an exception. For example, most functions in
3266 the standard C library can be guaranteed not to throw an exception
3267 with the notable exceptions of @code{qsort} and @code{bsearch} that
3268 take function pointer arguments. The @code{nothrow} attribute is not
3269 implemented in GCC versions earlier than 3.3.
3270
3271 @item nosave_low_regs
3272 @cindex @code{nosave_low_regs} attribute
3273 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3274 function should not save and restore registers R0..R7. This can be used on SH3*
3275 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3276 interrupt handlers.
3277
3278 @item optimize
3279 @cindex @code{optimize} function attribute
3280 The @code{optimize} attribute is used to specify that a function is to
3281 be compiled with different optimization options than specified on the
3282 command line. Arguments can either be numbers or strings. Numbers
3283 are assumed to be an optimization level. Strings that begin with
3284 @code{O} are assumed to be an optimization option, while other options
3285 are assumed to be used with a @code{-f} prefix. You can also use the
3286 @samp{#pragma GCC optimize} pragma to set the optimization options
3287 that affect more than one function.
3288 @xref{Function Specific Option Pragmas}, for details about the
3289 @samp{#pragma GCC optimize} pragma.
3290
3291 This can be used for instance to have frequently executed functions
3292 compiled with more aggressive optimization options that produce faster
3293 and larger code, while other functions can be called with less
3294 aggressive options.
3295
3296 @item OS_main/OS_task
3297 @cindex @code{OS_main} AVR function attribute
3298 @cindex @code{OS_task} AVR function attribute
3299 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3300 do not save/restore any call-saved register in their prologue/epilogue.
3301
3302 The @code{OS_main} attribute can be used when there @emph{is
3303 guarantee} that interrupts are disabled at the time when the function
3304 is entered. This saves resources when the stack pointer has to be
3305 changed to set up a frame for local variables.
3306
3307 The @code{OS_task} attribute can be used when there is @emph{no
3308 guarantee} that interrupts are disabled at that time when the function
3309 is entered like for, e@.g@. task functions in a multi-threading operating
3310 system. In that case, changing the stack pointer register is
3311 guarded by save/clear/restore of the global interrupt enable flag.
3312
3313 The differences to the @code{naked} function attribute are:
3314 @itemize @bullet
3315 @item @code{naked} functions do not have a return instruction whereas
3316 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3317 @code{RETI} return instruction.
3318 @item @code{naked} functions do not set up a frame for local variables
3319 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3320 as needed.
3321 @end itemize
3322
3323 @item pcs
3324 @cindex @code{pcs} function attribute
3325
3326 The @code{pcs} attribute can be used to control the calling convention
3327 used for a function on ARM. The attribute takes an argument that specifies
3328 the calling convention to use.
3329
3330 When compiling using the AAPCS ABI (or a variant of it) then valid
3331 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3332 order to use a variant other than @code{"aapcs"} then the compiler must
3333 be permitted to use the appropriate co-processor registers (i.e., the
3334 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3335 For example,
3336
3337 @smallexample
3338 /* Argument passed in r0, and result returned in r0+r1. */
3339 double f2d (float) __attribute__((pcs("aapcs")));
3340 @end smallexample
3341
3342 Variadic functions always use the @code{"aapcs"} calling convention and
3343 the compiler rejects attempts to specify an alternative.
3344
3345 @item pure
3346 @cindex @code{pure} function attribute
3347 Many functions have no effects except the return value and their
3348 return value depends only on the parameters and/or global variables.
3349 Such a function can be subject
3350 to common subexpression elimination and loop optimization just as an
3351 arithmetic operator would be. These functions should be declared
3352 with the attribute @code{pure}. For example,
3353
3354 @smallexample
3355 int square (int) __attribute__ ((pure));
3356 @end smallexample
3357
3358 @noindent
3359 says that the hypothetical function @code{square} is safe to call
3360 fewer times than the program says.
3361
3362 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3363 Interesting non-pure functions are functions with infinite loops or those
3364 depending on volatile memory or other system resource, that may change between
3365 two consecutive calls (such as @code{feof} in a multithreading environment).
3366
3367 The attribute @code{pure} is not implemented in GCC versions earlier
3368 than 2.96.
3369
3370 @item hot
3371 @cindex @code{hot} function attribute
3372 The @code{hot} attribute on a function is used to inform the compiler that
3373 the function is a hot spot of the compiled program. The function is
3374 optimized more aggressively and on many target it is placed into special
3375 subsection of the text section so all hot functions appears close together
3376 improving locality.
3377
3378 When profile feedback is available, via @option{-fprofile-use}, hot functions
3379 are automatically detected and this attribute is ignored.
3380
3381 The @code{hot} attribute on functions is not implemented in GCC versions
3382 earlier than 4.3.
3383
3384 @cindex @code{hot} label attribute
3385 The @code{hot} attribute on a label is used to inform the compiler that
3386 path following the label are more likely than paths that are not so
3387 annotated. This attribute is used in cases where @code{__builtin_expect}
3388 cannot be used, for instance with computed goto or @code{asm goto}.
3389
3390 The @code{hot} attribute on labels is not implemented in GCC versions
3391 earlier than 4.8.
3392
3393 @item cold
3394 @cindex @code{cold} function attribute
3395 The @code{cold} attribute on functions is used to inform the compiler that
3396 the function is unlikely to be executed. The function is optimized for
3397 size rather than speed and on many targets it is placed into special
3398 subsection of the text section so all cold functions appears close together
3399 improving code locality of non-cold parts of program. The paths leading
3400 to call of cold functions within code are marked as unlikely by the branch
3401 prediction mechanism. It is thus useful to mark functions used to handle
3402 unlikely conditions, such as @code{perror}, as cold to improve optimization
3403 of hot functions that do call marked functions in rare occasions.
3404
3405 When profile feedback is available, via @option{-fprofile-use}, cold functions
3406 are automatically detected and this attribute is ignored.
3407
3408 The @code{cold} attribute on functions is not implemented in GCC versions
3409 earlier than 4.3.
3410
3411 @cindex @code{cold} label attribute
3412 The @code{cold} attribute on labels is used to inform the compiler that
3413 the path following the label is unlikely to be executed. This attribute
3414 is used in cases where @code{__builtin_expect} cannot be used, for instance
3415 with computed goto or @code{asm goto}.
3416
3417 The @code{cold} attribute on labels is not implemented in GCC versions
3418 earlier than 4.8.
3419
3420 @item no_address_safety_analysis
3421 @cindex @code{no_address_safety_analysis} function attribute
3422 The @code{no_address_safety_analysis} attribute on functions is used
3423 to inform the compiler that it should not instrument memory accesses
3424 in the function when compiling with the @option{-fsanitize=address} option.
3425
3426 @item regparm (@var{number})
3427 @cindex @code{regparm} attribute
3428 @cindex functions that are passed arguments in registers on the 386
3429 On the Intel 386, the @code{regparm} attribute causes the compiler to
3430 pass arguments number one to @var{number} if they are of integral type
3431 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3432 take a variable number of arguments continue to be passed all of their
3433 arguments on the stack.
3434
3435 Beware that on some ELF systems this attribute is unsuitable for
3436 global functions in shared libraries with lazy binding (which is the
3437 default). Lazy binding sends the first call via resolving code in
3438 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3439 per the standard calling conventions. Solaris 8 is affected by this.
3440 GNU systems with GLIBC 2.1 or higher, and FreeBSD, are believed to be
3441 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3442 disabled with the linker or the loader if desired, to avoid the
3443 problem.)
3444
3445 @item sseregparm
3446 @cindex @code{sseregparm} attribute
3447 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3448 causes the compiler to pass up to 3 floating-point arguments in
3449 SSE registers instead of on the stack. Functions that take a
3450 variable number of arguments continue to pass all of their
3451 floating-point arguments on the stack.
3452
3453 @item force_align_arg_pointer
3454 @cindex @code{force_align_arg_pointer} attribute
3455 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3456 applied to individual function definitions, generating an alternate
3457 prologue and epilogue that realigns the run-time stack if necessary.
3458 This supports mixing legacy codes that run with a 4-byte aligned stack
3459 with modern codes that keep a 16-byte stack for SSE compatibility.
3460
3461 @item renesas
3462 @cindex @code{renesas} attribute
3463 On SH targets this attribute specifies that the function or struct follows the
3464 Renesas ABI.
3465
3466 @item resbank
3467 @cindex @code{resbank} attribute
3468 On the SH2A target, this attribute enables the high-speed register
3469 saving and restoration using a register bank for @code{interrupt_handler}
3470 routines. Saving to the bank is performed automatically after the CPU
3471 accepts an interrupt that uses a register bank.
3472
3473 The nineteen 32-bit registers comprising general register R0 to R14,
3474 control register GBR, and system registers MACH, MACL, and PR and the
3475 vector table address offset are saved into a register bank. Register
3476 banks are stacked in first-in last-out (FILO) sequence. Restoration
3477 from the bank is executed by issuing a RESBANK instruction.
3478
3479 @item returns_twice
3480 @cindex @code{returns_twice} attribute
3481 The @code{returns_twice} attribute tells the compiler that a function may
3482 return more than one time. The compiler ensures that all registers
3483 are dead before calling such a function and emits a warning about
3484 the variables that may be clobbered after the second return from the
3485 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3486 The @code{longjmp}-like counterpart of such function, if any, might need
3487 to be marked with the @code{noreturn} attribute.
3488
3489 @item saveall
3490 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3491 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3492 all registers except the stack pointer should be saved in the prologue
3493 regardless of whether they are used or not.
3494
3495 @item save_volatiles
3496 @cindex save volatile registers on the MicroBlaze
3497 Use this attribute on the MicroBlaze to indicate that the function is
3498 an interrupt handler. All volatile registers (in addition to non-volatile
3499 registers) are saved in the function prologue. If the function is a leaf
3500 function, only volatiles used by the function are saved. A normal function
3501 return is generated instead of a return from interrupt.
3502
3503 @item section ("@var{section-name}")
3504 @cindex @code{section} function attribute
3505 Normally, the compiler places the code it generates in the @code{text} section.
3506 Sometimes, however, you need additional sections, or you need certain
3507 particular functions to appear in special sections. The @code{section}
3508 attribute specifies that a function lives in a particular section.
3509 For example, the declaration:
3510
3511 @smallexample
3512 extern void foobar (void) __attribute__ ((section ("bar")));
3513 @end smallexample
3514
3515 @noindent
3516 puts the function @code{foobar} in the @code{bar} section.
3517
3518 Some file formats do not support arbitrary sections so the @code{section}
3519 attribute is not available on all platforms.
3520 If you need to map the entire contents of a module to a particular
3521 section, consider using the facilities of the linker instead.
3522
3523 @item sentinel
3524 @cindex @code{sentinel} function attribute
3525 This function attribute ensures that a parameter in a function call is
3526 an explicit @code{NULL}. The attribute is only valid on variadic
3527 functions. By default, the sentinel is located at position zero, the
3528 last parameter of the function call. If an optional integer position
3529 argument P is supplied to the attribute, the sentinel must be located at
3530 position P counting backwards from the end of the argument list.
3531
3532 @smallexample
3533 __attribute__ ((sentinel))
3534 is equivalent to
3535 __attribute__ ((sentinel(0)))
3536 @end smallexample
3537
3538 The attribute is automatically set with a position of 0 for the built-in
3539 functions @code{execl} and @code{execlp}. The built-in function
3540 @code{execle} has the attribute set with a position of 1.
3541
3542 A valid @code{NULL} in this context is defined as zero with any pointer
3543 type. If your system defines the @code{NULL} macro with an integer type
3544 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3545 with a copy that redefines NULL appropriately.
3546
3547 The warnings for missing or incorrect sentinels are enabled with
3548 @option{-Wformat}.
3549
3550 @item short_call
3551 See long_call/short_call.
3552
3553 @item shortcall
3554 See longcall/shortcall.
3555
3556 @item signal
3557 @cindex interrupt handler functions on the AVR processors
3558 Use this attribute on the AVR to indicate that the specified
3559 function is an interrupt handler. The compiler generates function
3560 entry and exit sequences suitable for use in an interrupt handler when this
3561 attribute is present.
3562
3563 See also the @code{interrupt} function attribute.
3564
3565 The AVR hardware globally disables interrupts when an interrupt is executed.
3566 Interrupt handler functions defined with the @code{signal} attribute
3567 do not re-enable interrupts. It is save to enable interrupts in a
3568 @code{signal} handler. This ``save'' only applies to the code
3569 generated by the compiler and not to the IRQ-layout of the
3570 application which is responsibility of the application.
3571
3572 If both @code{signal} and @code{interrupt} are specified for the same
3573 function, @code{signal} is silently ignored.
3574
3575 @item sp_switch
3576 @cindex @code{sp_switch} attribute
3577 Use this attribute on the SH to indicate an @code{interrupt_handler}
3578 function should switch to an alternate stack. It expects a string
3579 argument that names a global variable holding the address of the
3580 alternate stack.
3581
3582 @smallexample
3583 void *alt_stack;
3584 void f () __attribute__ ((interrupt_handler,
3585 sp_switch ("alt_stack")));
3586 @end smallexample
3587
3588 @item stdcall
3589 @cindex functions that pop the argument stack on the 386
3590 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3591 assume that the called function pops off the stack space used to
3592 pass arguments, unless it takes a variable number of arguments.
3593
3594 @item syscall_linkage
3595 @cindex @code{syscall_linkage} attribute
3596 This attribute is used to modify the IA64 calling convention by marking
3597 all input registers as live at all function exits. This makes it possible
3598 to restart a system call after an interrupt without having to save/restore
3599 the input registers. This also prevents kernel data from leaking into
3600 application code.
3601
3602 @item target
3603 @cindex @code{target} function attribute
3604 The @code{target} attribute is used to specify that a function is to
3605 be compiled with different target options than specified on the
3606 command line. This can be used for instance to have functions
3607 compiled with a different ISA (instruction set architecture) than the
3608 default. You can also use the @samp{#pragma GCC target} pragma to set
3609 more than one function to be compiled with specific target options.
3610 @xref{Function Specific Option Pragmas}, for details about the
3611 @samp{#pragma GCC target} pragma.
3612
3613 For instance on a 386, you could compile one function with
3614 @code{target("sse4.1,arch=core2")} and another with
3615 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3616 compiling the first function with @option{-msse4.1} and
3617 @option{-march=core2} options, and the second function with
3618 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3619 user to make sure that a function is only invoked on a machine that
3620 supports the particular ISA it is compiled for (for example by using
3621 @code{cpuid} on 386 to determine what feature bits and architecture
3622 family are used).
3623
3624 @smallexample
3625 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3626 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3627 @end smallexample
3628
3629 On the 386, the following options are allowed:
3630
3631 @table @samp
3632 @item abm
3633 @itemx no-abm
3634 @cindex @code{target("abm")} attribute
3635 Enable/disable the generation of the advanced bit instructions.
3636
3637 @item aes
3638 @itemx no-aes
3639 @cindex @code{target("aes")} attribute
3640 Enable/disable the generation of the AES instructions.
3641
3642 @item mmx
3643 @itemx no-mmx
3644 @cindex @code{target("mmx")} attribute
3645 Enable/disable the generation of the MMX instructions.
3646
3647 @item pclmul
3648 @itemx no-pclmul
3649 @cindex @code{target("pclmul")} attribute
3650 Enable/disable the generation of the PCLMUL instructions.
3651
3652 @item popcnt
3653 @itemx no-popcnt
3654 @cindex @code{target("popcnt")} attribute
3655 Enable/disable the generation of the POPCNT instruction.
3656
3657 @item sse
3658 @itemx no-sse
3659 @cindex @code{target("sse")} attribute
3660 Enable/disable the generation of the SSE instructions.
3661
3662 @item sse2
3663 @itemx no-sse2
3664 @cindex @code{target("sse2")} attribute
3665 Enable/disable the generation of the SSE2 instructions.
3666
3667 @item sse3
3668 @itemx no-sse3
3669 @cindex @code{target("sse3")} attribute
3670 Enable/disable the generation of the SSE3 instructions.
3671
3672 @item sse4
3673 @itemx no-sse4
3674 @cindex @code{target("sse4")} attribute
3675 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3676 and SSE4.2).
3677
3678 @item sse4.1
3679 @itemx no-sse4.1
3680 @cindex @code{target("sse4.1")} attribute
3681 Enable/disable the generation of the sse4.1 instructions.
3682
3683 @item sse4.2
3684 @itemx no-sse4.2
3685 @cindex @code{target("sse4.2")} attribute
3686 Enable/disable the generation of the sse4.2 instructions.
3687
3688 @item sse4a
3689 @itemx no-sse4a
3690 @cindex @code{target("sse4a")} attribute
3691 Enable/disable the generation of the SSE4A instructions.
3692
3693 @item fma4
3694 @itemx no-fma4
3695 @cindex @code{target("fma4")} attribute
3696 Enable/disable the generation of the FMA4 instructions.
3697
3698 @item xop
3699 @itemx no-xop
3700 @cindex @code{target("xop")} attribute
3701 Enable/disable the generation of the XOP instructions.
3702
3703 @item lwp
3704 @itemx no-lwp
3705 @cindex @code{target("lwp")} attribute
3706 Enable/disable the generation of the LWP instructions.
3707
3708 @item ssse3
3709 @itemx no-ssse3
3710 @cindex @code{target("ssse3")} attribute
3711 Enable/disable the generation of the SSSE3 instructions.
3712
3713 @item cld
3714 @itemx no-cld
3715 @cindex @code{target("cld")} attribute
3716 Enable/disable the generation of the CLD before string moves.
3717
3718 @item fancy-math-387
3719 @itemx no-fancy-math-387
3720 @cindex @code{target("fancy-math-387")} attribute
3721 Enable/disable the generation of the @code{sin}, @code{cos}, and
3722 @code{sqrt} instructions on the 387 floating-point unit.
3723
3724 @item fused-madd
3725 @itemx no-fused-madd
3726 @cindex @code{target("fused-madd")} attribute
3727 Enable/disable the generation of the fused multiply/add instructions.
3728
3729 @item ieee-fp
3730 @itemx no-ieee-fp
3731 @cindex @code{target("ieee-fp")} attribute
3732 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3733
3734 @item inline-all-stringops
3735 @itemx no-inline-all-stringops
3736 @cindex @code{target("inline-all-stringops")} attribute
3737 Enable/disable inlining of string operations.
3738
3739 @item inline-stringops-dynamically
3740 @itemx no-inline-stringops-dynamically
3741 @cindex @code{target("inline-stringops-dynamically")} attribute
3742 Enable/disable the generation of the inline code to do small string
3743 operations and calling the library routines for large operations.
3744
3745 @item align-stringops
3746 @itemx no-align-stringops
3747 @cindex @code{target("align-stringops")} attribute
3748 Do/do not align destination of inlined string operations.
3749
3750 @item recip
3751 @itemx no-recip
3752 @cindex @code{target("recip")} attribute
3753 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3754 instructions followed an additional Newton-Raphson step instead of
3755 doing a floating-point division.
3756
3757 @item arch=@var{ARCH}
3758 @cindex @code{target("arch=@var{ARCH}")} attribute
3759 Specify the architecture to generate code for in compiling the function.
3760
3761 @item tune=@var{TUNE}
3762 @cindex @code{target("tune=@var{TUNE}")} attribute
3763 Specify the architecture to tune for in compiling the function.
3764
3765 @item fpmath=@var{FPMATH}
3766 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3767 Specify which floating-point unit to use. The
3768 @code{target("fpmath=sse,387")} option must be specified as
3769 @code{target("fpmath=sse+387")} because the comma would separate
3770 different options.
3771 @end table
3772
3773 On the PowerPC, the following options are allowed:
3774
3775 @table @samp
3776 @item altivec
3777 @itemx no-altivec
3778 @cindex @code{target("altivec")} attribute
3779 Generate code that uses (does not use) AltiVec instructions. In
3780 32-bit code, you cannot enable AltiVec instructions unless
3781 @option{-mabi=altivec} is used on the command line.
3782
3783 @item cmpb
3784 @itemx no-cmpb
3785 @cindex @code{target("cmpb")} attribute
3786 Generate code that uses (does not use) the compare bytes instruction
3787 implemented on the POWER6 processor and other processors that support
3788 the PowerPC V2.05 architecture.
3789
3790 @item dlmzb
3791 @itemx no-dlmzb
3792 @cindex @code{target("dlmzb")} attribute
3793 Generate code that uses (does not use) the string-search @samp{dlmzb}
3794 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
3795 generated by default when targeting those processors.
3796
3797 @item fprnd
3798 @itemx no-fprnd
3799 @cindex @code{target("fprnd")} attribute
3800 Generate code that uses (does not use) the FP round to integer
3801 instructions implemented on the POWER5+ processor and other processors
3802 that support the PowerPC V2.03 architecture.
3803
3804 @item hard-dfp
3805 @itemx no-hard-dfp
3806 @cindex @code{target("hard-dfp")} attribute
3807 Generate code that uses (does not use) the decimal floating-point
3808 instructions implemented on some POWER processors.
3809
3810 @item isel
3811 @itemx no-isel
3812 @cindex @code{target("isel")} attribute
3813 Generate code that uses (does not use) ISEL instruction.
3814
3815 @item mfcrf
3816 @itemx no-mfcrf
3817 @cindex @code{target("mfcrf")} attribute
3818 Generate code that uses (does not use) the move from condition
3819 register field instruction implemented on the POWER4 processor and
3820 other processors that support the PowerPC V2.01 architecture.
3821
3822 @item mfpgpr
3823 @itemx no-mfpgpr
3824 @cindex @code{target("mfpgpr")} attribute
3825 Generate code that uses (does not use) the FP move to/from general
3826 purpose register instructions implemented on the POWER6X processor and
3827 other processors that support the extended PowerPC V2.05 architecture.
3828
3829 @item mulhw
3830 @itemx no-mulhw
3831 @cindex @code{target("mulhw")} attribute
3832 Generate code that uses (does not use) the half-word multiply and
3833 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
3834 These instructions are generated by default when targeting those
3835 processors.
3836
3837 @item multiple
3838 @itemx no-multiple
3839 @cindex @code{target("multiple")} attribute
3840 Generate code that uses (does not use) the load multiple word
3841 instructions and the store multiple word instructions.
3842
3843 @item update
3844 @itemx no-update
3845 @cindex @code{target("update")} attribute
3846 Generate code that uses (does not use) the load or store instructions
3847 that update the base register to the address of the calculated memory
3848 location.
3849
3850 @item popcntb
3851 @itemx no-popcntb
3852 @cindex @code{target("popcntb")} attribute
3853 Generate code that uses (does not use) the popcount and double-precision
3854 FP reciprocal estimate instruction implemented on the POWER5
3855 processor and other processors that support the PowerPC V2.02
3856 architecture.
3857
3858 @item popcntd
3859 @itemx no-popcntd
3860 @cindex @code{target("popcntd")} attribute
3861 Generate code that uses (does not use) the popcount instruction
3862 implemented on the POWER7 processor and other processors that support
3863 the PowerPC V2.06 architecture.
3864
3865 @item powerpc-gfxopt
3866 @itemx no-powerpc-gfxopt
3867 @cindex @code{target("powerpc-gfxopt")} attribute
3868 Generate code that uses (does not use) the optional PowerPC
3869 architecture instructions in the Graphics group, including
3870 floating-point select.
3871
3872 @item powerpc-gpopt
3873 @itemx no-powerpc-gpopt
3874 @cindex @code{target("powerpc-gpopt")} attribute
3875 Generate code that uses (does not use) the optional PowerPC
3876 architecture instructions in the General Purpose group, including
3877 floating-point square root.
3878
3879 @item recip-precision
3880 @itemx no-recip-precision
3881 @cindex @code{target("recip-precision")} attribute
3882 Assume (do not assume) that the reciprocal estimate instructions
3883 provide higher-precision estimates than is mandated by the powerpc
3884 ABI.
3885
3886 @item string
3887 @itemx no-string
3888 @cindex @code{target("string")} attribute
3889 Generate code that uses (does not use) the load string instructions
3890 and the store string word instructions to save multiple registers and
3891 do small block moves.
3892
3893 @item vsx
3894 @itemx no-vsx
3895 @cindex @code{target("vsx")} attribute
3896 Generate code that uses (does not use) vector/scalar (VSX)
3897 instructions, and also enable the use of built-in functions that allow
3898 more direct access to the VSX instruction set. In 32-bit code, you
3899 cannot enable VSX or AltiVec instructions unless
3900 @option{-mabi=altivec} is used on the command line.
3901
3902 @item friz
3903 @itemx no-friz
3904 @cindex @code{target("friz")} attribute
3905 Generate (do not generate) the @code{friz} instruction when the
3906 @option{-funsafe-math-optimizations} option is used to optimize
3907 rounding a floating-point value to 64-bit integer and back to floating
3908 point. The @code{friz} instruction does not return the same value if
3909 the floating-point number is too large to fit in an integer.
3910
3911 @item avoid-indexed-addresses
3912 @itemx no-avoid-indexed-addresses
3913 @cindex @code{target("avoid-indexed-addresses")} attribute
3914 Generate code that tries to avoid (not avoid) the use of indexed load
3915 or store instructions.
3916
3917 @item paired
3918 @itemx no-paired
3919 @cindex @code{target("paired")} attribute
3920 Generate code that uses (does not use) the generation of PAIRED simd
3921 instructions.
3922
3923 @item longcall
3924 @itemx no-longcall
3925 @cindex @code{target("longcall")} attribute
3926 Generate code that assumes (does not assume) that all calls are far
3927 away so that a longer more expensive calling sequence is required.
3928
3929 @item cpu=@var{CPU}
3930 @cindex @code{target("cpu=@var{CPU}")} attribute
3931 Specify the architecture to generate code for when compiling the
3932 function. If you select the @code{target("cpu=power7")} attribute when
3933 generating 32-bit code, VSX and AltiVec instructions are not generated
3934 unless you use the @option{-mabi=altivec} option on the command line.
3935
3936 @item tune=@var{TUNE}
3937 @cindex @code{target("tune=@var{TUNE}")} attribute
3938 Specify the architecture to tune for when compiling the function. If
3939 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
3940 you do specify the @code{target("cpu=@var{CPU}")} attribute,
3941 compilation tunes for the @var{CPU} architecture, and not the
3942 default tuning specified on the command line.
3943 @end table
3944
3945 On the 386/x86_64 and PowerPC back ends, you can use either multiple
3946 strings to specify multiple options, or you can separate the option
3947 with a comma (@code{,}).
3948
3949 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
3950 function that has different target options than the caller, unless the
3951 callee has a subset of the target options of the caller. For example
3952 a function declared with @code{target("sse3")} can inline a function
3953 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
3954
3955 The @code{target} attribute is not implemented in GCC versions earlier
3956 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. It is
3957 not currently implemented for other back ends.
3958
3959 @item tiny_data
3960 @cindex tiny data section on the H8/300H and H8S
3961 Use this attribute on the H8/300H and H8S to indicate that the specified
3962 variable should be placed into the tiny data section.
3963 The compiler generates more efficient code for loads and stores
3964 on data in the tiny data section. Note the tiny data area is limited to
3965 slightly under 32KB of data.
3966
3967 @item trap_exit
3968 @cindex @code{trap_exit} attribute
3969 Use this attribute on the SH for an @code{interrupt_handler} to return using
3970 @code{trapa} instead of @code{rte}. This attribute expects an integer
3971 argument specifying the trap number to be used.
3972
3973 @item trapa_handler
3974 @cindex @code{trapa_handler} attribute
3975 On SH targets this function attribute is similar to @code{interrupt_handler}
3976 but it does not save and restore all registers.
3977
3978 @item unused
3979 @cindex @code{unused} attribute.
3980 This attribute, attached to a function, means that the function is meant
3981 to be possibly unused. GCC does not produce a warning for this
3982 function.
3983
3984 @item used
3985 @cindex @code{used} attribute.
3986 This attribute, attached to a function, means that code must be emitted
3987 for the function even if it appears that the function is not referenced.
3988 This is useful, for example, when the function is referenced only in
3989 inline assembly.
3990
3991 When applied to a member function of a C++ class template, the
3992 attribute also means that the function is instantiated if the
3993 class itself is instantiated.
3994
3995 @item version_id
3996 @cindex @code{version_id} attribute
3997 This IA64 HP-UX attribute, attached to a global variable or function, renames a
3998 symbol to contain a version string, thus allowing for function level
3999 versioning. HP-UX system header files may use version level functioning
4000 for some system calls.
4001
4002 @smallexample
4003 extern int foo () __attribute__((version_id ("20040821")));
4004 @end smallexample
4005
4006 @noindent
4007 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4008
4009 @item visibility ("@var{visibility_type}")
4010 @cindex @code{visibility} attribute
4011 This attribute affects the linkage of the declaration to which it is attached.
4012 There are four supported @var{visibility_type} values: default,
4013 hidden, protected or internal visibility.
4014
4015 @smallexample
4016 void __attribute__ ((visibility ("protected")))
4017 f () @{ /* @r{Do something.} */; @}
4018 int i __attribute__ ((visibility ("hidden")));
4019 @end smallexample
4020
4021 The possible values of @var{visibility_type} correspond to the
4022 visibility settings in the ELF gABI.
4023
4024 @table @dfn
4025 @c keep this list of visibilities in alphabetical order.
4026
4027 @item default
4028 Default visibility is the normal case for the object file format.
4029 This value is available for the visibility attribute to override other
4030 options that may change the assumed visibility of entities.
4031
4032 On ELF, default visibility means that the declaration is visible to other
4033 modules and, in shared libraries, means that the declared entity may be
4034 overridden.
4035
4036 On Darwin, default visibility means that the declaration is visible to
4037 other modules.
4038
4039 Default visibility corresponds to ``external linkage'' in the language.
4040
4041 @item hidden
4042 Hidden visibility indicates that the entity declared has a new
4043 form of linkage, which we call ``hidden linkage''. Two
4044 declarations of an object with hidden linkage refer to the same object
4045 if they are in the same shared object.
4046
4047 @item internal
4048 Internal visibility is like hidden visibility, but with additional
4049 processor specific semantics. Unless otherwise specified by the
4050 psABI, GCC defines internal visibility to mean that a function is
4051 @emph{never} called from another module. Compare this with hidden
4052 functions which, while they cannot be referenced directly by other
4053 modules, can be referenced indirectly via function pointers. By
4054 indicating that a function cannot be called from outside the module,
4055 GCC may for instance omit the load of a PIC register since it is known
4056 that the calling function loaded the correct value.
4057
4058 @item protected
4059 Protected visibility is like default visibility except that it
4060 indicates that references within the defining module bind to the
4061 definition in that module. That is, the declared entity cannot be
4062 overridden by another module.
4063
4064 @end table
4065
4066 All visibilities are supported on many, but not all, ELF targets
4067 (supported when the assembler supports the @samp{.visibility}
4068 pseudo-op). Default visibility is supported everywhere. Hidden
4069 visibility is supported on Darwin targets.
4070
4071 The visibility attribute should be applied only to declarations that
4072 would otherwise have external linkage. The attribute should be applied
4073 consistently, so that the same entity should not be declared with
4074 different settings of the attribute.
4075
4076 In C++, the visibility attribute applies to types as well as functions
4077 and objects, because in C++ types have linkage. A class must not have
4078 greater visibility than its non-static data member types and bases,
4079 and class members default to the visibility of their class. Also, a
4080 declaration without explicit visibility is limited to the visibility
4081 of its type.
4082
4083 In C++, you can mark member functions and static member variables of a
4084 class with the visibility attribute. This is useful if you know a
4085 particular method or static member variable should only be used from
4086 one shared object; then you can mark it hidden while the rest of the
4087 class has default visibility. Care must be taken to avoid breaking
4088 the One Definition Rule; for example, it is usually not useful to mark
4089 an inline method as hidden without marking the whole class as hidden.
4090
4091 A C++ namespace declaration can also have the visibility attribute.
4092 This attribute applies only to the particular namespace body, not to
4093 other definitions of the same namespace; it is equivalent to using
4094 @samp{#pragma GCC visibility} before and after the namespace
4095 definition (@pxref{Visibility Pragmas}).
4096
4097 In C++, if a template argument has limited visibility, this
4098 restriction is implicitly propagated to the template instantiation.
4099 Otherwise, template instantiations and specializations default to the
4100 visibility of their template.
4101
4102 If both the template and enclosing class have explicit visibility, the
4103 visibility from the template is used.
4104
4105 @item vliw
4106 @cindex @code{vliw} attribute
4107 On MeP, the @code{vliw} attribute tells the compiler to emit
4108 instructions in VLIW mode instead of core mode. Note that this
4109 attribute is not allowed unless a VLIW coprocessor has been configured
4110 and enabled through command-line options.
4111
4112 @item warn_unused_result
4113 @cindex @code{warn_unused_result} attribute
4114 The @code{warn_unused_result} attribute causes a warning to be emitted
4115 if a caller of the function with this attribute does not use its
4116 return value. This is useful for functions where not checking
4117 the result is either a security problem or always a bug, such as
4118 @code{realloc}.
4119
4120 @smallexample
4121 int fn () __attribute__ ((warn_unused_result));
4122 int foo ()
4123 @{
4124 if (fn () < 0) return -1;
4125 fn ();
4126 return 0;
4127 @}
4128 @end smallexample
4129
4130 @noindent
4131 results in warning on line 5.
4132
4133 @item weak
4134 @cindex @code{weak} attribute
4135 The @code{weak} attribute causes the declaration to be emitted as a weak
4136 symbol rather than a global. This is primarily useful in defining
4137 library functions that can be overridden in user code, though it can
4138 also be used with non-function declarations. Weak symbols are supported
4139 for ELF targets, and also for a.out targets when using the GNU assembler
4140 and linker.
4141
4142 @item weakref
4143 @itemx weakref ("@var{target}")
4144 @cindex @code{weakref} attribute
4145 The @code{weakref} attribute marks a declaration as a weak reference.
4146 Without arguments, it should be accompanied by an @code{alias} attribute
4147 naming the target symbol. Optionally, the @var{target} may be given as
4148 an argument to @code{weakref} itself. In either case, @code{weakref}
4149 implicitly marks the declaration as @code{weak}. Without a
4150 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4151 @code{weakref} is equivalent to @code{weak}.
4152
4153 @smallexample
4154 static int x() __attribute__ ((weakref ("y")));
4155 /* is equivalent to... */
4156 static int x() __attribute__ ((weak, weakref, alias ("y")));
4157 /* and to... */
4158 static int x() __attribute__ ((weakref));
4159 static int x() __attribute__ ((alias ("y")));
4160 @end smallexample
4161
4162 A weak reference is an alias that does not by itself require a
4163 definition to be given for the target symbol. If the target symbol is
4164 only referenced through weak references, then it becomes a @code{weak}
4165 undefined symbol. If it is directly referenced, however, then such
4166 strong references prevail, and a definition is required for the
4167 symbol, not necessarily in the same translation unit.
4168
4169 The effect is equivalent to moving all references to the alias to a
4170 separate translation unit, renaming the alias to the aliased symbol,
4171 declaring it as weak, compiling the two separate translation units and
4172 performing a reloadable link on them.
4173
4174 At present, a declaration to which @code{weakref} is attached can
4175 only be @code{static}.
4176
4177 @end table
4178
4179 You can specify multiple attributes in a declaration by separating them
4180 by commas within the double parentheses or by immediately following an
4181 attribute declaration with another attribute declaration.
4182
4183 @cindex @code{#pragma}, reason for not using
4184 @cindex pragma, reason for not using
4185 Some people object to the @code{__attribute__} feature, suggesting that
4186 ISO C's @code{#pragma} should be used instead. At the time
4187 @code{__attribute__} was designed, there were two reasons for not doing
4188 this.
4189
4190 @enumerate
4191 @item
4192 It is impossible to generate @code{#pragma} commands from a macro.
4193
4194 @item
4195 There is no telling what the same @code{#pragma} might mean in another
4196 compiler.
4197 @end enumerate
4198
4199 These two reasons applied to almost any application that might have been
4200 proposed for @code{#pragma}. It was basically a mistake to use
4201 @code{#pragma} for @emph{anything}.
4202
4203 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4204 to be generated from macros. In addition, a @code{#pragma GCC}
4205 namespace is now in use for GCC-specific pragmas. However, it has been
4206 found convenient to use @code{__attribute__} to achieve a natural
4207 attachment of attributes to their corresponding declarations, whereas
4208 @code{#pragma GCC} is of use for constructs that do not naturally form
4209 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4210
4211 @node Attribute Syntax
4212 @section Attribute Syntax
4213 @cindex attribute syntax
4214
4215 This section describes the syntax with which @code{__attribute__} may be
4216 used, and the constructs to which attribute specifiers bind, for the C
4217 language. Some details may vary for C++ and Objective-C@. Because of
4218 infelicities in the grammar for attributes, some forms described here
4219 may not be successfully parsed in all cases.
4220
4221 There are some problems with the semantics of attributes in C++. For
4222 example, there are no manglings for attributes, although they may affect
4223 code generation, so problems may arise when attributed types are used in
4224 conjunction with templates or overloading. Similarly, @code{typeid}
4225 does not distinguish between types with different attributes. Support
4226 for attributes in C++ may be restricted in future to attributes on
4227 declarations only, but not on nested declarators.
4228
4229 @xref{Function Attributes}, for details of the semantics of attributes
4230 applying to functions. @xref{Variable Attributes}, for details of the
4231 semantics of attributes applying to variables. @xref{Type Attributes},
4232 for details of the semantics of attributes applying to structure, union
4233 and enumerated types.
4234
4235 An @dfn{attribute specifier} is of the form
4236 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4237 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4238 each attribute is one of the following:
4239
4240 @itemize @bullet
4241 @item
4242 Empty. Empty attributes are ignored.
4243
4244 @item
4245 A word (which may be an identifier such as @code{unused}, or a reserved
4246 word such as @code{const}).
4247
4248 @item
4249 A word, followed by, in parentheses, parameters for the attribute.
4250 These parameters take one of the following forms:
4251
4252 @itemize @bullet
4253 @item
4254 An identifier. For example, @code{mode} attributes use this form.
4255
4256 @item
4257 An identifier followed by a comma and a non-empty comma-separated list
4258 of expressions. For example, @code{format} attributes use this form.
4259
4260 @item
4261 A possibly empty comma-separated list of expressions. For example,
4262 @code{format_arg} attributes use this form with the list being a single
4263 integer constant expression, and @code{alias} attributes use this form
4264 with the list being a single string constant.
4265 @end itemize
4266 @end itemize
4267
4268 An @dfn{attribute specifier list} is a sequence of one or more attribute
4269 specifiers, not separated by any other tokens.
4270
4271 In GNU C, an attribute specifier list may appear after the colon following a
4272 label, other than a @code{case} or @code{default} label. The only
4273 attribute it makes sense to use after a label is @code{unused}. This
4274 feature is intended for program-generated code that may contain unused labels,
4275 but which is compiled with @option{-Wall}. It is
4276 not normally appropriate to use in it human-written code, though it
4277 could be useful in cases where the code that jumps to the label is
4278 contained within an @code{#ifdef} conditional. GNU C++ only permits
4279 attributes on labels if the attribute specifier is immediately
4280 followed by a semicolon (i.e., the label applies to an empty
4281 statement). If the semicolon is missing, C++ label attributes are
4282 ambiguous, as it is permissible for a declaration, which could begin
4283 with an attribute list, to be labelled in C++. Declarations cannot be
4284 labelled in C90 or C99, so the ambiguity does not arise there.
4285
4286 An attribute specifier list may appear as part of a @code{struct},
4287 @code{union} or @code{enum} specifier. It may go either immediately
4288 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4289 the closing brace. The former syntax is preferred.
4290 Where attribute specifiers follow the closing brace, they are considered
4291 to relate to the structure, union or enumerated type defined, not to any
4292 enclosing declaration the type specifier appears in, and the type
4293 defined is not complete until after the attribute specifiers.
4294 @c Otherwise, there would be the following problems: a shift/reduce
4295 @c conflict between attributes binding the struct/union/enum and
4296 @c binding to the list of specifiers/qualifiers; and "aligned"
4297 @c attributes could use sizeof for the structure, but the size could be
4298 @c changed later by "packed" attributes.
4299
4300 Otherwise, an attribute specifier appears as part of a declaration,
4301 counting declarations of unnamed parameters and type names, and relates
4302 to that declaration (which may be nested in another declaration, for
4303 example in the case of a parameter declaration), or to a particular declarator
4304 within a declaration. Where an
4305 attribute specifier is applied to a parameter declared as a function or
4306 an array, it should apply to the function or array rather than the
4307 pointer to which the parameter is implicitly converted, but this is not
4308 yet correctly implemented.
4309
4310 Any list of specifiers and qualifiers at the start of a declaration may
4311 contain attribute specifiers, whether or not such a list may in that
4312 context contain storage class specifiers. (Some attributes, however,
4313 are essentially in the nature of storage class specifiers, and only make
4314 sense where storage class specifiers may be used; for example,
4315 @code{section}.) There is one necessary limitation to this syntax: the
4316 first old-style parameter declaration in a function definition cannot
4317 begin with an attribute specifier, because such an attribute applies to
4318 the function instead by syntax described below (which, however, is not
4319 yet implemented in this case). In some other cases, attribute
4320 specifiers are permitted by this grammar but not yet supported by the
4321 compiler. All attribute specifiers in this place relate to the
4322 declaration as a whole. In the obsolescent usage where a type of
4323 @code{int} is implied by the absence of type specifiers, such a list of
4324 specifiers and qualifiers may be an attribute specifier list with no
4325 other specifiers or qualifiers.
4326
4327 At present, the first parameter in a function prototype must have some
4328 type specifier that is not an attribute specifier; this resolves an
4329 ambiguity in the interpretation of @code{void f(int
4330 (__attribute__((foo)) x))}, but is subject to change. At present, if
4331 the parentheses of a function declarator contain only attributes then
4332 those attributes are ignored, rather than yielding an error or warning
4333 or implying a single parameter of type int, but this is subject to
4334 change.
4335
4336 An attribute specifier list may appear immediately before a declarator
4337 (other than the first) in a comma-separated list of declarators in a
4338 declaration of more than one identifier using a single list of
4339 specifiers and qualifiers. Such attribute specifiers apply
4340 only to the identifier before whose declarator they appear. For
4341 example, in
4342
4343 @smallexample
4344 __attribute__((noreturn)) void d0 (void),
4345 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4346 d2 (void)
4347 @end smallexample
4348
4349 @noindent
4350 the @code{noreturn} attribute applies to all the functions
4351 declared; the @code{format} attribute only applies to @code{d1}.
4352
4353 An attribute specifier list may appear immediately before the comma,
4354 @code{=} or semicolon terminating the declaration of an identifier other
4355 than a function definition. Such attribute specifiers apply
4356 to the declared object or function. Where an
4357 assembler name for an object or function is specified (@pxref{Asm
4358 Labels}), the attribute must follow the @code{asm}
4359 specification.
4360
4361 An attribute specifier list may, in future, be permitted to appear after
4362 the declarator in a function definition (before any old-style parameter
4363 declarations or the function body).
4364
4365 Attribute specifiers may be mixed with type qualifiers appearing inside
4366 the @code{[]} of a parameter array declarator, in the C99 construct by
4367 which such qualifiers are applied to the pointer to which the array is
4368 implicitly converted. Such attribute specifiers apply to the pointer,
4369 not to the array, but at present this is not implemented and they are
4370 ignored.
4371
4372 An attribute specifier list may appear at the start of a nested
4373 declarator. At present, there are some limitations in this usage: the
4374 attributes correctly apply to the declarator, but for most individual
4375 attributes the semantics this implies are not implemented.
4376 When attribute specifiers follow the @code{*} of a pointer
4377 declarator, they may be mixed with any type qualifiers present.
4378 The following describes the formal semantics of this syntax. It makes the
4379 most sense if you are familiar with the formal specification of
4380 declarators in the ISO C standard.
4381
4382 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4383 D1}, where @code{T} contains declaration specifiers that specify a type
4384 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4385 contains an identifier @var{ident}. The type specified for @var{ident}
4386 for derived declarators whose type does not include an attribute
4387 specifier is as in the ISO C standard.
4388
4389 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4390 and the declaration @code{T D} specifies the type
4391 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4392 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4393 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4394
4395 If @code{D1} has the form @code{*
4396 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4397 declaration @code{T D} specifies the type
4398 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4399 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4400 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4401 @var{ident}.
4402
4403 For example,
4404
4405 @smallexample
4406 void (__attribute__((noreturn)) ****f) (void);
4407 @end smallexample
4408
4409 @noindent
4410 specifies the type ``pointer to pointer to pointer to pointer to
4411 non-returning function returning @code{void}''. As another example,
4412
4413 @smallexample
4414 char *__attribute__((aligned(8))) *f;
4415 @end smallexample
4416
4417 @noindent
4418 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4419 Note again that this does not work with most attributes; for example,
4420 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4421 is not yet supported.
4422
4423 For compatibility with existing code written for compiler versions that
4424 did not implement attributes on nested declarators, some laxity is
4425 allowed in the placing of attributes. If an attribute that only applies
4426 to types is applied to a declaration, it is treated as applying to
4427 the type of that declaration. If an attribute that only applies to
4428 declarations is applied to the type of a declaration, it is treated
4429 as applying to that declaration; and, for compatibility with code
4430 placing the attributes immediately before the identifier declared, such
4431 an attribute applied to a function return type is treated as
4432 applying to the function type, and such an attribute applied to an array
4433 element type is treated as applying to the array type. If an
4434 attribute that only applies to function types is applied to a
4435 pointer-to-function type, it is treated as applying to the pointer
4436 target type; if such an attribute is applied to a function return type
4437 that is not a pointer-to-function type, it is treated as applying
4438 to the function type.
4439
4440 @node Function Prototypes
4441 @section Prototypes and Old-Style Function Definitions
4442 @cindex function prototype declarations
4443 @cindex old-style function definitions
4444 @cindex promotion of formal parameters
4445
4446 GNU C extends ISO C to allow a function prototype to override a later
4447 old-style non-prototype definition. Consider the following example:
4448
4449 @smallexample
4450 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4451 #ifdef __STDC__
4452 #define P(x) x
4453 #else
4454 #define P(x) ()
4455 #endif
4456
4457 /* @r{Prototype function declaration.} */
4458 int isroot P((uid_t));
4459
4460 /* @r{Old-style function definition.} */
4461 int
4462 isroot (x) /* @r{??? lossage here ???} */
4463 uid_t x;
4464 @{
4465 return x == 0;
4466 @}
4467 @end smallexample
4468
4469 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4470 not allow this example, because subword arguments in old-style
4471 non-prototype definitions are promoted. Therefore in this example the
4472 function definition's argument is really an @code{int}, which does not
4473 match the prototype argument type of @code{short}.
4474
4475 This restriction of ISO C makes it hard to write code that is portable
4476 to traditional C compilers, because the programmer does not know
4477 whether the @code{uid_t} type is @code{short}, @code{int}, or
4478 @code{long}. Therefore, in cases like these GNU C allows a prototype
4479 to override a later old-style definition. More precisely, in GNU C, a
4480 function prototype argument type overrides the argument type specified
4481 by a later old-style definition if the former type is the same as the
4482 latter type before promotion. Thus in GNU C the above example is
4483 equivalent to the following:
4484
4485 @smallexample
4486 int isroot (uid_t);
4487
4488 int
4489 isroot (uid_t x)
4490 @{
4491 return x == 0;
4492 @}
4493 @end smallexample
4494
4495 @noindent
4496 GNU C++ does not support old-style function definitions, so this
4497 extension is irrelevant.
4498
4499 @node C++ Comments
4500 @section C++ Style Comments
4501 @cindex @code{//}
4502 @cindex C++ comments
4503 @cindex comments, C++ style
4504
4505 In GNU C, you may use C++ style comments, which start with @samp{//} and
4506 continue until the end of the line. Many other C implementations allow
4507 such comments, and they are included in the 1999 C standard. However,
4508 C++ style comments are not recognized if you specify an @option{-std}
4509 option specifying a version of ISO C before C99, or @option{-ansi}
4510 (equivalent to @option{-std=c90}).
4511
4512 @node Dollar Signs
4513 @section Dollar Signs in Identifier Names
4514 @cindex $
4515 @cindex dollar signs in identifier names
4516 @cindex identifier names, dollar signs in
4517
4518 In GNU C, you may normally use dollar signs in identifier names.
4519 This is because many traditional C implementations allow such identifiers.
4520 However, dollar signs in identifiers are not supported on a few target
4521 machines, typically because the target assembler does not allow them.
4522
4523 @node Character Escapes
4524 @section The Character @key{ESC} in Constants
4525
4526 You can use the sequence @samp{\e} in a string or character constant to
4527 stand for the ASCII character @key{ESC}.
4528
4529 @node Variable Attributes
4530 @section Specifying Attributes of Variables
4531 @cindex attribute of variables
4532 @cindex variable attributes
4533
4534 The keyword @code{__attribute__} allows you to specify special
4535 attributes of variables or structure fields. This keyword is followed
4536 by an attribute specification inside double parentheses. Some
4537 attributes are currently defined generically for variables.
4538 Other attributes are defined for variables on particular target
4539 systems. Other attributes are available for functions
4540 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4541 Other front ends might define more attributes
4542 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4543
4544 You may also specify attributes with @samp{__} preceding and following
4545 each keyword. This allows you to use them in header files without
4546 being concerned about a possible macro of the same name. For example,
4547 you may use @code{__aligned__} instead of @code{aligned}.
4548
4549 @xref{Attribute Syntax}, for details of the exact syntax for using
4550 attributes.
4551
4552 @table @code
4553 @cindex @code{aligned} attribute
4554 @item aligned (@var{alignment})
4555 This attribute specifies a minimum alignment for the variable or
4556 structure field, measured in bytes. For example, the declaration:
4557
4558 @smallexample
4559 int x __attribute__ ((aligned (16))) = 0;
4560 @end smallexample
4561
4562 @noindent
4563 causes the compiler to allocate the global variable @code{x} on a
4564 16-byte boundary. On a 68040, this could be used in conjunction with
4565 an @code{asm} expression to access the @code{move16} instruction which
4566 requires 16-byte aligned operands.
4567
4568 You can also specify the alignment of structure fields. For example, to
4569 create a double-word aligned @code{int} pair, you could write:
4570
4571 @smallexample
4572 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4573 @end smallexample
4574
4575 @noindent
4576 This is an alternative to creating a union with a @code{double} member,
4577 which forces the union to be double-word aligned.
4578
4579 As in the preceding examples, you can explicitly specify the alignment
4580 (in bytes) that you wish the compiler to use for a given variable or
4581 structure field. Alternatively, you can leave out the alignment factor
4582 and just ask the compiler to align a variable or field to the
4583 default alignment for the target architecture you are compiling for.
4584 The default alignment is sufficient for all scalar types, but may not be
4585 enough for all vector types on a target that supports vector operations.
4586 The default alignment is fixed for a particular target ABI.
4587
4588 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4589 which is the largest alignment ever used for any data type on the
4590 target machine you are compiling for. For example, you could write:
4591
4592 @smallexample
4593 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4594 @end smallexample
4595
4596 The compiler automatically sets the alignment for the declared
4597 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4598 often make copy operations more efficient, because the compiler can
4599 use whatever instructions copy the biggest chunks of memory when
4600 performing copies to or from the variables or fields that you have
4601 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4602 may change depending on command-line options.
4603
4604 When used on a struct, or struct member, the @code{aligned} attribute can
4605 only increase the alignment; in order to decrease it, the @code{packed}
4606 attribute must be specified as well. When used as part of a typedef, the
4607 @code{aligned} attribute can both increase and decrease alignment, and
4608 specifying the @code{packed} attribute generates a warning.
4609
4610 Note that the effectiveness of @code{aligned} attributes may be limited
4611 by inherent limitations in your linker. On many systems, the linker is
4612 only able to arrange for variables to be aligned up to a certain maximum
4613 alignment. (For some linkers, the maximum supported alignment may
4614 be very very small.) If your linker is only able to align variables
4615 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4616 in an @code{__attribute__} still only provides you with 8-byte
4617 alignment. See your linker documentation for further information.
4618
4619 The @code{aligned} attribute can also be used for functions
4620 (@pxref{Function Attributes}.)
4621
4622 @item cleanup (@var{cleanup_function})
4623 @cindex @code{cleanup} attribute
4624 The @code{cleanup} attribute runs a function when the variable goes
4625 out of scope. This attribute can only be applied to auto function
4626 scope variables; it may not be applied to parameters or variables
4627 with static storage duration. The function must take one parameter,
4628 a pointer to a type compatible with the variable. The return value
4629 of the function (if any) is ignored.
4630
4631 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4632 is run during the stack unwinding that happens during the
4633 processing of the exception. Note that the @code{cleanup} attribute
4634 does not allow the exception to be caught, only to perform an action.
4635 It is undefined what happens if @var{cleanup_function} does not
4636 return normally.
4637
4638 @item common
4639 @itemx nocommon
4640 @cindex @code{common} attribute
4641 @cindex @code{nocommon} attribute
4642 @opindex fcommon
4643 @opindex fno-common
4644 The @code{common} attribute requests GCC to place a variable in
4645 ``common'' storage. The @code{nocommon} attribute requests the
4646 opposite---to allocate space for it directly.
4647
4648 These attributes override the default chosen by the
4649 @option{-fno-common} and @option{-fcommon} flags respectively.
4650
4651 @item deprecated
4652 @itemx deprecated (@var{msg})
4653 @cindex @code{deprecated} attribute
4654 The @code{deprecated} attribute results in a warning if the variable
4655 is used anywhere in the source file. This is useful when identifying
4656 variables that are expected to be removed in a future version of a
4657 program. The warning also includes the location of the declaration
4658 of the deprecated variable, to enable users to easily find further
4659 information about why the variable is deprecated, or what they should
4660 do instead. Note that the warning only occurs for uses:
4661
4662 @smallexample
4663 extern int old_var __attribute__ ((deprecated));
4664 extern int old_var;
4665 int new_fn () @{ return old_var; @}
4666 @end smallexample
4667
4668 @noindent
4669 results in a warning on line 3 but not line 2. The optional @var{msg}
4670 argument, which must be a string, is printed in the warning if
4671 present.
4672
4673 The @code{deprecated} attribute can also be used for functions and
4674 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4675
4676 @item mode (@var{mode})
4677 @cindex @code{mode} attribute
4678 This attribute specifies the data type for the declaration---whichever
4679 type corresponds to the mode @var{mode}. This in effect lets you
4680 request an integer or floating-point type according to its width.
4681
4682 You may also specify a mode of @samp{byte} or @samp{__byte__} to
4683 indicate the mode corresponding to a one-byte integer, @samp{word} or
4684 @samp{__word__} for the mode of a one-word integer, and @samp{pointer}
4685 or @samp{__pointer__} for the mode used to represent pointers.
4686
4687 @item packed
4688 @cindex @code{packed} attribute
4689 The @code{packed} attribute specifies that a variable or structure field
4690 should have the smallest possible alignment---one byte for a variable,
4691 and one bit for a field, unless you specify a larger value with the
4692 @code{aligned} attribute.
4693
4694 Here is a structure in which the field @code{x} is packed, so that it
4695 immediately follows @code{a}:
4696
4697 @smallexample
4698 struct foo
4699 @{
4700 char a;
4701 int x[2] __attribute__ ((packed));
4702 @};
4703 @end smallexample
4704
4705 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4706 @code{packed} attribute on bit-fields of type @code{char}. This has
4707 been fixed in GCC 4.4 but the change can lead to differences in the
4708 structure layout. See the documentation of
4709 @option{-Wpacked-bitfield-compat} for more information.
4710
4711 @item section ("@var{section-name}")
4712 @cindex @code{section} variable attribute
4713 Normally, the compiler places the objects it generates in sections like
4714 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
4715 or you need certain particular variables to appear in special sections,
4716 for example to map to special hardware. The @code{section}
4717 attribute specifies that a variable (or function) lives in a particular
4718 section. For example, this small program uses several specific section names:
4719
4720 @smallexample
4721 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4722 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4723 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4724 int init_data __attribute__ ((section ("INITDATA")));
4725
4726 main()
4727 @{
4728 /* @r{Initialize stack pointer} */
4729 init_sp (stack + sizeof (stack));
4730
4731 /* @r{Initialize initialized data} */
4732 memcpy (&init_data, &data, &edata - &data);
4733
4734 /* @r{Turn on the serial ports} */
4735 init_duart (&a);
4736 init_duart (&b);
4737 @}
4738 @end smallexample
4739
4740 @noindent
4741 Use the @code{section} attribute with
4742 @emph{global} variables and not @emph{local} variables,
4743 as shown in the example.
4744
4745 You may use the @code{section} attribute with initialized or
4746 uninitialized global variables but the linker requires
4747 each object be defined once, with the exception that uninitialized
4748 variables tentatively go in the @code{common} (or @code{bss}) section
4749 and can be multiply ``defined''. Using the @code{section} attribute
4750 changes what section the variable goes into and may cause the
4751 linker to issue an error if an uninitialized variable has multiple
4752 definitions. You can force a variable to be initialized with the
4753 @option{-fno-common} flag or the @code{nocommon} attribute.
4754
4755 Some file formats do not support arbitrary sections so the @code{section}
4756 attribute is not available on all platforms.
4757 If you need to map the entire contents of a module to a particular
4758 section, consider using the facilities of the linker instead.
4759
4760 @item shared
4761 @cindex @code{shared} variable attribute
4762 On Microsoft Windows, in addition to putting variable definitions in a named
4763 section, the section can also be shared among all running copies of an
4764 executable or DLL@. For example, this small program defines shared data
4765 by putting it in a named section @code{shared} and marking the section
4766 shareable:
4767
4768 @smallexample
4769 int foo __attribute__((section ("shared"), shared)) = 0;
4770
4771 int
4772 main()
4773 @{
4774 /* @r{Read and write foo. All running
4775 copies see the same value.} */
4776 return 0;
4777 @}
4778 @end smallexample
4779
4780 @noindent
4781 You may only use the @code{shared} attribute along with @code{section}
4782 attribute with a fully initialized global definition because of the way
4783 linkers work. See @code{section} attribute for more information.
4784
4785 The @code{shared} attribute is only available on Microsoft Windows@.
4786
4787 @item tls_model ("@var{tls_model}")
4788 @cindex @code{tls_model} attribute
4789 The @code{tls_model} attribute sets thread-local storage model
4790 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4791 overriding @option{-ftls-model=} command-line switch on a per-variable
4792 basis.
4793 The @var{tls_model} argument should be one of @code{global-dynamic},
4794 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4795
4796 Not all targets support this attribute.
4797
4798 @item unused
4799 This attribute, attached to a variable, means that the variable is meant
4800 to be possibly unused. GCC does not produce a warning for this
4801 variable.
4802
4803 @item used
4804 This attribute, attached to a variable, means that the variable must be
4805 emitted even if it appears that the variable is not referenced.
4806
4807 When applied to a static data member of a C++ class template, the
4808 attribute also means that the member is instantiated if the
4809 class itself is instantiated.
4810
4811 @item vector_size (@var{bytes})
4812 This attribute specifies the vector size for the variable, measured in
4813 bytes. For example, the declaration:
4814
4815 @smallexample
4816 int foo __attribute__ ((vector_size (16)));
4817 @end smallexample
4818
4819 @noindent
4820 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4821 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
4822 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
4823
4824 This attribute is only applicable to integral and float scalars,
4825 although arrays, pointers, and function return values are allowed in
4826 conjunction with this construct.
4827
4828 Aggregates with this attribute are invalid, even if they are of the same
4829 size as a corresponding scalar. For example, the declaration:
4830
4831 @smallexample
4832 struct S @{ int a; @};
4833 struct S __attribute__ ((vector_size (16))) foo;
4834 @end smallexample
4835
4836 @noindent
4837 is invalid even if the size of the structure is the same as the size of
4838 the @code{int}.
4839
4840 @item selectany
4841 The @code{selectany} attribute causes an initialized global variable to
4842 have link-once semantics. When multiple definitions of the variable are
4843 encountered by the linker, the first is selected and the remainder are
4844 discarded. Following usage by the Microsoft compiler, the linker is told
4845 @emph{not} to warn about size or content differences of the multiple
4846 definitions.
4847
4848 Although the primary usage of this attribute is for POD types, the
4849 attribute can also be applied to global C++ objects that are initialized
4850 by a constructor. In this case, the static initialization and destruction
4851 code for the object is emitted in each translation defining the object,
4852 but the calls to the constructor and destructor are protected by a
4853 link-once guard variable.
4854
4855 The @code{selectany} attribute is only available on Microsoft Windows
4856 targets. You can use @code{__declspec (selectany)} as a synonym for
4857 @code{__attribute__ ((selectany))} for compatibility with other
4858 compilers.
4859
4860 @item weak
4861 The @code{weak} attribute is described in @ref{Function Attributes}.
4862
4863 @item dllimport
4864 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4865
4866 @item dllexport
4867 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4868
4869 @end table
4870
4871 @anchor{AVR Variable Attributes}
4872 @subsection AVR Variable Attributes
4873
4874 @table @code
4875 @item progmem
4876 @cindex @code{progmem} AVR variable attribute
4877 The @code{progmem} attribute is used on the AVR to place read-only
4878 data in the non-volatile program memory (flash). The @code{progmem}
4879 attribute accomplishes this by putting respective variables into a
4880 section whose name starts with @code{.progmem}.
4881
4882 This attribute works similar to the @code{section} attribute
4883 but adds additional checking. Notice that just like the
4884 @code{section} attribute, @code{progmem} affects the location
4885 of the data but not how this data is accessed.
4886
4887 In order to read data located with the @code{progmem} attribute
4888 (inline) assembler must be used.
4889 @smallexample
4890 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}} */
4891 #include <avr/pgmspace.h>
4892
4893 /* Locate var in flash memory */
4894 const int var[2] PROGMEM = @{ 1, 2 @};
4895
4896 int read_var (int i)
4897 @{
4898 /* Access var[] by accessor macro from avr/pgmspace.h */
4899 return (int) pgm_read_word (& var[i]);
4900 @}
4901 @end smallexample
4902
4903 AVR is a Harvard architecture processor and data and read-only data
4904 normally resides in the data memory (RAM).
4905
4906 See also the @ref{AVR Named Address Spaces} section for
4907 an alternate way to locate and access data in flash memory.
4908 @end table
4909
4910 @subsection Blackfin Variable Attributes
4911
4912 Three attributes are currently defined for the Blackfin.
4913
4914 @table @code
4915 @item l1_data
4916 @itemx l1_data_A
4917 @itemx l1_data_B
4918 @cindex @code{l1_data} variable attribute
4919 @cindex @code{l1_data_A} variable attribute
4920 @cindex @code{l1_data_B} variable attribute
4921 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4922 Variables with @code{l1_data} attribute are put into the specific section
4923 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
4924 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4925 attribute are put into the specific section named @code{.l1.data.B}.
4926
4927 @item l2
4928 @cindex @code{l2} variable attribute
4929 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4930 Variables with @code{l2} attribute are put into the specific section
4931 named @code{.l2.data}.
4932 @end table
4933
4934 @subsection M32R/D Variable Attributes
4935
4936 One attribute is currently defined for the M32R/D@.
4937
4938 @table @code
4939 @item model (@var{model-name})
4940 @cindex variable addressability on the M32R/D
4941 Use this attribute on the M32R/D to set the addressability of an object.
4942 The identifier @var{model-name} is one of @code{small}, @code{medium},
4943 or @code{large}, representing each of the code models.
4944
4945 Small model objects live in the lower 16MB of memory (so that their
4946 addresses can be loaded with the @code{ld24} instruction).
4947
4948 Medium and large model objects may live anywhere in the 32-bit address space
4949 (the compiler generates @code{seth/add3} instructions to load their
4950 addresses).
4951 @end table
4952
4953 @anchor{MeP Variable Attributes}
4954 @subsection MeP Variable Attributes
4955
4956 The MeP target has a number of addressing modes and busses. The
4957 @code{near} space spans the standard memory space's first 16 megabytes
4958 (24 bits). The @code{far} space spans the entire 32-bit memory space.
4959 The @code{based} space is a 128-byte region in the memory space that
4960 is addressed relative to the @code{$tp} register. The @code{tiny}
4961 space is a 65536-byte region relative to the @code{$gp} register. In
4962 addition to these memory regions, the MeP target has a separate 16-bit
4963 control bus which is specified with @code{cb} attributes.
4964
4965 @table @code
4966
4967 @item based
4968 Any variable with the @code{based} attribute is assigned to the
4969 @code{.based} section, and is accessed with relative to the
4970 @code{$tp} register.
4971
4972 @item tiny
4973 Likewise, the @code{tiny} attribute assigned variables to the
4974 @code{.tiny} section, relative to the @code{$gp} register.
4975
4976 @item near
4977 Variables with the @code{near} attribute are assumed to have addresses
4978 that fit in a 24-bit addressing mode. This is the default for large
4979 variables (@code{-mtiny=4} is the default) but this attribute can
4980 override @code{-mtiny=} for small variables, or override @code{-ml}.
4981
4982 @item far
4983 Variables with the @code{far} attribute are addressed using a full
4984 32-bit address. Since this covers the entire memory space, this
4985 allows modules to make no assumptions about where variables might be
4986 stored.
4987
4988 @item io
4989 @itemx io (@var{addr})
4990 Variables with the @code{io} attribute are used to address
4991 memory-mapped peripherals. If an address is specified, the variable
4992 is assigned that address, else it is not assigned an address (it is
4993 assumed some other module assigns an address). Example:
4994
4995 @smallexample
4996 int timer_count __attribute__((io(0x123)));
4997 @end smallexample
4998
4999 @item cb
5000 @itemx cb (@var{addr})
5001 Variables with the @code{cb} attribute are used to access the control
5002 bus, using special instructions. @code{addr} indicates the control bus
5003 address. Example:
5004
5005 @smallexample
5006 int cpu_clock __attribute__((cb(0x123)));
5007 @end smallexample
5008
5009 @end table
5010
5011 @anchor{i386 Variable Attributes}
5012 @subsection i386 Variable Attributes
5013
5014 Two attributes are currently defined for i386 configurations:
5015 @code{ms_struct} and @code{gcc_struct}
5016
5017 @table @code
5018 @item ms_struct
5019 @itemx gcc_struct
5020 @cindex @code{ms_struct} attribute
5021 @cindex @code{gcc_struct} attribute
5022
5023 If @code{packed} is used on a structure, or if bit-fields are used
5024 it may be that the Microsoft ABI packs them differently
5025 than GCC normally packs them. Particularly when moving packed
5026 data between functions compiled with GCC and the native Microsoft compiler
5027 (either via function call or as data in a file), it may be necessary to access
5028 either format.
5029
5030 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5031 compilers to match the native Microsoft compiler.
5032
5033 The Microsoft structure layout algorithm is fairly simple with the exception
5034 of the bit-field packing:
5035
5036 The padding and alignment of members of structures and whether a bit-field
5037 can straddle a storage-unit boundary
5038
5039 @enumerate
5040 @item Structure members are stored sequentially in the order in which they are
5041 declared: the first member has the lowest memory address and the last member
5042 the highest.
5043
5044 @item Every data object has an alignment-requirement. The alignment-requirement
5045 for all data except structures, unions, and arrays is either the size of the
5046 object or the current packing size (specified with either the aligned attribute
5047 or the pack pragma), whichever is less. For structures, unions, and arrays,
5048 the alignment-requirement is the largest alignment-requirement of its members.
5049 Every object is allocated an offset so that:
5050
5051 offset % alignment-requirement == 0
5052
5053 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5054 unit if the integral types are the same size and if the next bit-field fits
5055 into the current allocation unit without crossing the boundary imposed by the
5056 common alignment requirements of the bit-fields.
5057 @end enumerate
5058
5059 Handling of zero-length bit-fields:
5060
5061 MSVC interprets zero-length bit-fields in the following ways:
5062
5063 @enumerate
5064 @item If a zero-length bit-field is inserted between two bit-fields that
5065 are normally coalesced, the bit-fields are not coalesced.
5066
5067 For example:
5068
5069 @smallexample
5070 struct
5071 @{
5072 unsigned long bf_1 : 12;
5073 unsigned long : 0;
5074 unsigned long bf_2 : 12;
5075 @} t1;
5076 @end smallexample
5077
5078 @noindent
5079 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5080 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5081
5082 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5083 alignment of the zero-length bit-field is greater than the member that follows it,
5084 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5085
5086 For example:
5087
5088 @smallexample
5089 struct
5090 @{
5091 char foo : 4;
5092 short : 0;
5093 char bar;
5094 @} t2;
5095
5096 struct
5097 @{
5098 char foo : 4;
5099 short : 0;
5100 double bar;
5101 @} t3;
5102 @end smallexample
5103
5104 @noindent
5105 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5106 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5107 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5108 of the structure.
5109
5110 Taking this into account, it is important to note the following:
5111
5112 @enumerate
5113 @item If a zero-length bit-field follows a normal bit-field, the type of the
5114 zero-length bit-field may affect the alignment of the structure as whole. For
5115 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5116 normal bit-field, and is of type short.
5117
5118 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5119 still affect the alignment of the structure:
5120
5121 @smallexample
5122 struct
5123 @{
5124 char foo : 6;
5125 long : 0;
5126 @} t4;
5127 @end smallexample
5128
5129 @noindent
5130 Here, @code{t4} takes up 4 bytes.
5131 @end enumerate
5132
5133 @item Zero-length bit-fields following non-bit-field members are ignored:
5134
5135 @smallexample
5136 struct
5137 @{
5138 char foo;
5139 long : 0;
5140 char bar;
5141 @} t5;
5142 @end smallexample
5143
5144 @noindent
5145 Here, @code{t5} takes up 2 bytes.
5146 @end enumerate
5147 @end table
5148
5149 @subsection PowerPC Variable Attributes
5150
5151 Three attributes currently are defined for PowerPC configurations:
5152 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5153
5154 For full documentation of the struct attributes please see the
5155 documentation in @ref{i386 Variable Attributes}.
5156
5157 For documentation of @code{altivec} attribute please see the
5158 documentation in @ref{PowerPC Type Attributes}.
5159
5160 @subsection SPU Variable Attributes
5161
5162 The SPU supports the @code{spu_vector} attribute for variables. For
5163 documentation of this attribute please see the documentation in
5164 @ref{SPU Type Attributes}.
5165
5166 @subsection Xstormy16 Variable Attributes
5167
5168 One attribute is currently defined for xstormy16 configurations:
5169 @code{below100}.
5170
5171 @table @code
5172 @item below100
5173 @cindex @code{below100} attribute
5174
5175 If a variable has the @code{below100} attribute (@code{BELOW100} is
5176 allowed also), GCC places the variable in the first 0x100 bytes of
5177 memory and use special opcodes to access it. Such variables are
5178 placed in either the @code{.bss_below100} section or the
5179 @code{.data_below100} section.
5180
5181 @end table
5182
5183 @node Type Attributes
5184 @section Specifying Attributes of Types
5185 @cindex attribute of types
5186 @cindex type attributes
5187
5188 The keyword @code{__attribute__} allows you to specify special
5189 attributes of @code{struct} and @code{union} types when you define
5190 such types. This keyword is followed by an attribute specification
5191 inside double parentheses. Seven attributes are currently defined for
5192 types: @code{aligned}, @code{packed}, @code{transparent_union},
5193 @code{unused}, @code{deprecated}, @code{visibility}, and
5194 @code{may_alias}. Other attributes are defined for functions
5195 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5196 Attributes}).
5197
5198 You may also specify any one of these attributes with @samp{__}
5199 preceding and following its keyword. This allows you to use these
5200 attributes in header files without being concerned about a possible
5201 macro of the same name. For example, you may use @code{__aligned__}
5202 instead of @code{aligned}.
5203
5204 You may specify type attributes in an enum, struct or union type
5205 declaration or definition, or for other types in a @code{typedef}
5206 declaration.
5207
5208 For an enum, struct or union type, you may specify attributes either
5209 between the enum, struct or union tag and the name of the type, or
5210 just past the closing curly brace of the @emph{definition}. The
5211 former syntax is preferred.
5212
5213 @xref{Attribute Syntax}, for details of the exact syntax for using
5214 attributes.
5215
5216 @table @code
5217 @cindex @code{aligned} attribute
5218 @item aligned (@var{alignment})
5219 This attribute specifies a minimum alignment (in bytes) for variables
5220 of the specified type. For example, the declarations:
5221
5222 @smallexample
5223 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5224 typedef int more_aligned_int __attribute__ ((aligned (8)));
5225 @end smallexample
5226
5227 @noindent
5228 force the compiler to insure (as far as it can) that each variable whose
5229 type is @code{struct S} or @code{more_aligned_int} is allocated and
5230 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5231 variables of type @code{struct S} aligned to 8-byte boundaries allows
5232 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5233 store) instructions when copying one variable of type @code{struct S} to
5234 another, thus improving run-time efficiency.
5235
5236 Note that the alignment of any given @code{struct} or @code{union} type
5237 is required by the ISO C standard to be at least a perfect multiple of
5238 the lowest common multiple of the alignments of all of the members of
5239 the @code{struct} or @code{union} in question. This means that you @emph{can}
5240 effectively adjust the alignment of a @code{struct} or @code{union}
5241 type by attaching an @code{aligned} attribute to any one of the members
5242 of such a type, but the notation illustrated in the example above is a
5243 more obvious, intuitive, and readable way to request the compiler to
5244 adjust the alignment of an entire @code{struct} or @code{union} type.
5245
5246 As in the preceding example, you can explicitly specify the alignment
5247 (in bytes) that you wish the compiler to use for a given @code{struct}
5248 or @code{union} type. Alternatively, you can leave out the alignment factor
5249 and just ask the compiler to align a type to the maximum
5250 useful alignment for the target machine you are compiling for. For
5251 example, you could write:
5252
5253 @smallexample
5254 struct S @{ short f[3]; @} __attribute__ ((aligned));
5255 @end smallexample
5256
5257 Whenever you leave out the alignment factor in an @code{aligned}
5258 attribute specification, the compiler automatically sets the alignment
5259 for the type to the largest alignment that is ever used for any data
5260 type on the target machine you are compiling for. Doing this can often
5261 make copy operations more efficient, because the compiler can use
5262 whatever instructions copy the biggest chunks of memory when performing
5263 copies to or from the variables that have types that you have aligned
5264 this way.
5265
5266 In the example above, if the size of each @code{short} is 2 bytes, then
5267 the size of the entire @code{struct S} type is 6 bytes. The smallest
5268 power of two that is greater than or equal to that is 8, so the
5269 compiler sets the alignment for the entire @code{struct S} type to 8
5270 bytes.
5271
5272 Note that although you can ask the compiler to select a time-efficient
5273 alignment for a given type and then declare only individual stand-alone
5274 objects of that type, the compiler's ability to select a time-efficient
5275 alignment is primarily useful only when you plan to create arrays of
5276 variables having the relevant (efficiently aligned) type. If you
5277 declare or use arrays of variables of an efficiently-aligned type, then
5278 it is likely that your program also does pointer arithmetic (or
5279 subscripting, which amounts to the same thing) on pointers to the
5280 relevant type, and the code that the compiler generates for these
5281 pointer arithmetic operations is often more efficient for
5282 efficiently-aligned types than for other types.
5283
5284 The @code{aligned} attribute can only increase the alignment; but you
5285 can decrease it by specifying @code{packed} as well. See below.
5286
5287 Note that the effectiveness of @code{aligned} attributes may be limited
5288 by inherent limitations in your linker. On many systems, the linker is
5289 only able to arrange for variables to be aligned up to a certain maximum
5290 alignment. (For some linkers, the maximum supported alignment may
5291 be very very small.) If your linker is only able to align variables
5292 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5293 in an @code{__attribute__} still only provides you with 8-byte
5294 alignment. See your linker documentation for further information.
5295
5296 @item packed
5297 This attribute, attached to @code{struct} or @code{union} type
5298 definition, specifies that each member (other than zero-width bit-fields)
5299 of the structure or union is placed to minimize the memory required. When
5300 attached to an @code{enum} definition, it indicates that the smallest
5301 integral type should be used.
5302
5303 @opindex fshort-enums
5304 Specifying this attribute for @code{struct} and @code{union} types is
5305 equivalent to specifying the @code{packed} attribute on each of the
5306 structure or union members. Specifying the @option{-fshort-enums}
5307 flag on the line is equivalent to specifying the @code{packed}
5308 attribute on all @code{enum} definitions.
5309
5310 In the following example @code{struct my_packed_struct}'s members are
5311 packed closely together, but the internal layout of its @code{s} member
5312 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5313 be packed too.
5314
5315 @smallexample
5316 struct my_unpacked_struct
5317 @{
5318 char c;
5319 int i;
5320 @};
5321
5322 struct __attribute__ ((__packed__)) my_packed_struct
5323 @{
5324 char c;
5325 int i;
5326 struct my_unpacked_struct s;
5327 @};
5328 @end smallexample
5329
5330 You may only specify this attribute on the definition of an @code{enum},
5331 @code{struct} or @code{union}, not on a @code{typedef} that does not
5332 also define the enumerated type, structure or union.
5333
5334 @item transparent_union
5335 This attribute, attached to a @code{union} type definition, indicates
5336 that any function parameter having that union type causes calls to that
5337 function to be treated in a special way.
5338
5339 First, the argument corresponding to a transparent union type can be of
5340 any type in the union; no cast is required. Also, if the union contains
5341 a pointer type, the corresponding argument can be a null pointer
5342 constant or a void pointer expression; and if the union contains a void
5343 pointer type, the corresponding argument can be any pointer expression.
5344 If the union member type is a pointer, qualifiers like @code{const} on
5345 the referenced type must be respected, just as with normal pointer
5346 conversions.
5347
5348 Second, the argument is passed to the function using the calling
5349 conventions of the first member of the transparent union, not the calling
5350 conventions of the union itself. All members of the union must have the
5351 same machine representation; this is necessary for this argument passing
5352 to work properly.
5353
5354 Transparent unions are designed for library functions that have multiple
5355 interfaces for compatibility reasons. For example, suppose the
5356 @code{wait} function must accept either a value of type @code{int *} to
5357 comply with Posix, or a value of type @code{union wait *} to comply with
5358 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5359 @code{wait} would accept both kinds of arguments, but it would also
5360 accept any other pointer type and this would make argument type checking
5361 less useful. Instead, @code{<sys/wait.h>} might define the interface
5362 as follows:
5363
5364 @smallexample
5365 typedef union __attribute__ ((__transparent_union__))
5366 @{
5367 int *__ip;
5368 union wait *__up;
5369 @} wait_status_ptr_t;
5370
5371 pid_t wait (wait_status_ptr_t);
5372 @end smallexample
5373
5374 @noindent
5375 This interface allows either @code{int *} or @code{union wait *}
5376 arguments to be passed, using the @code{int *} calling convention.
5377 The program can call @code{wait} with arguments of either type:
5378
5379 @smallexample
5380 int w1 () @{ int w; return wait (&w); @}
5381 int w2 () @{ union wait w; return wait (&w); @}
5382 @end smallexample
5383
5384 @noindent
5385 With this interface, @code{wait}'s implementation might look like this:
5386
5387 @smallexample
5388 pid_t wait (wait_status_ptr_t p)
5389 @{
5390 return waitpid (-1, p.__ip, 0);
5391 @}
5392 @end smallexample
5393
5394 @item unused
5395 When attached to a type (including a @code{union} or a @code{struct}),
5396 this attribute means that variables of that type are meant to appear
5397 possibly unused. GCC does not produce a warning for any variables of
5398 that type, even if the variable appears to do nothing. This is often
5399 the case with lock or thread classes, which are usually defined and then
5400 not referenced, but contain constructors and destructors that have
5401 nontrivial bookkeeping functions.
5402
5403 @item deprecated
5404 @itemx deprecated (@var{msg})
5405 The @code{deprecated} attribute results in a warning if the type
5406 is used anywhere in the source file. This is useful when identifying
5407 types that are expected to be removed in a future version of a program.
5408 If possible, the warning also includes the location of the declaration
5409 of the deprecated type, to enable users to easily find further
5410 information about why the type is deprecated, or what they should do
5411 instead. Note that the warnings only occur for uses and then only
5412 if the type is being applied to an identifier that itself is not being
5413 declared as deprecated.
5414
5415 @smallexample
5416 typedef int T1 __attribute__ ((deprecated));
5417 T1 x;
5418 typedef T1 T2;
5419 T2 y;
5420 typedef T1 T3 __attribute__ ((deprecated));
5421 T3 z __attribute__ ((deprecated));
5422 @end smallexample
5423
5424 @noindent
5425 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5426 warning is issued for line 4 because T2 is not explicitly
5427 deprecated. Line 5 has no warning because T3 is explicitly
5428 deprecated. Similarly for line 6. The optional @var{msg}
5429 argument, which must be a string, is printed in the warning if
5430 present.
5431
5432 The @code{deprecated} attribute can also be used for functions and
5433 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5434
5435 @item may_alias
5436 Accesses through pointers to types with this attribute are not subject
5437 to type-based alias analysis, but are instead assumed to be able to alias
5438 any other type of objects. In the context of 6.5/7 an lvalue expression
5439 dereferencing such a pointer is treated like having a character type.
5440 See @option{-fstrict-aliasing} for more information on aliasing issues.
5441 This extension exists to support some vector APIs, in which pointers to
5442 one vector type are permitted to alias pointers to a different vector type.
5443
5444 Note that an object of a type with this attribute does not have any
5445 special semantics.
5446
5447 Example of use:
5448
5449 @smallexample
5450 typedef short __attribute__((__may_alias__)) short_a;
5451
5452 int
5453 main (void)
5454 @{
5455 int a = 0x12345678;
5456 short_a *b = (short_a *) &a;
5457
5458 b[1] = 0;
5459
5460 if (a == 0x12345678)
5461 abort();
5462
5463 exit(0);
5464 @}
5465 @end smallexample
5466
5467 @noindent
5468 If you replaced @code{short_a} with @code{short} in the variable
5469 declaration, the above program would abort when compiled with
5470 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5471 above in recent GCC versions.
5472
5473 @item visibility
5474 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5475 applied to class, struct, union and enum types. Unlike other type
5476 attributes, the attribute must appear between the initial keyword and
5477 the name of the type; it cannot appear after the body of the type.
5478
5479 Note that the type visibility is applied to vague linkage entities
5480 associated with the class (vtable, typeinfo node, etc.). In
5481 particular, if a class is thrown as an exception in one shared object
5482 and caught in another, the class must have default visibility.
5483 Otherwise the two shared objects are unable to use the same
5484 typeinfo node and exception handling will break.
5485
5486 @end table
5487
5488 To specify multiple attributes, separate them by commas within the
5489 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5490 packed))}.
5491
5492 @subsection ARM Type Attributes
5493
5494 On those ARM targets that support @code{dllimport} (such as Symbian
5495 OS), you can use the @code{notshared} attribute to indicate that the
5496 virtual table and other similar data for a class should not be
5497 exported from a DLL@. For example:
5498
5499 @smallexample
5500 class __declspec(notshared) C @{
5501 public:
5502 __declspec(dllimport) C();
5503 virtual void f();
5504 @}
5505
5506 __declspec(dllexport)
5507 C::C() @{@}
5508 @end smallexample
5509
5510 @noindent
5511 In this code, @code{C::C} is exported from the current DLL, but the
5512 virtual table for @code{C} is not exported. (You can use
5513 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5514 most Symbian OS code uses @code{__declspec}.)
5515
5516 @anchor{MeP Type Attributes}
5517 @subsection MeP Type Attributes
5518
5519 Many of the MeP variable attributes may be applied to types as well.
5520 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5521 @code{far} attributes may be applied to either. The @code{io} and
5522 @code{cb} attributes may not be applied to types.
5523
5524 @anchor{i386 Type Attributes}
5525 @subsection i386 Type Attributes
5526
5527 Two attributes are currently defined for i386 configurations:
5528 @code{ms_struct} and @code{gcc_struct}.
5529
5530 @table @code
5531
5532 @item ms_struct
5533 @itemx gcc_struct
5534 @cindex @code{ms_struct}
5535 @cindex @code{gcc_struct}
5536
5537 If @code{packed} is used on a structure, or if bit-fields are used
5538 it may be that the Microsoft ABI packs them differently
5539 than GCC normally packs them. Particularly when moving packed
5540 data between functions compiled with GCC and the native Microsoft compiler
5541 (either via function call or as data in a file), it may be necessary to access
5542 either format.
5543
5544 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5545 compilers to match the native Microsoft compiler.
5546 @end table
5547
5548 @anchor{PowerPC Type Attributes}
5549 @subsection PowerPC Type Attributes
5550
5551 Three attributes currently are defined for PowerPC configurations:
5552 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5553
5554 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5555 attributes please see the documentation in @ref{i386 Type Attributes}.
5556
5557 The @code{altivec} attribute allows one to declare AltiVec vector data
5558 types supported by the AltiVec Programming Interface Manual. The
5559 attribute requires an argument to specify one of three vector types:
5560 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5561 and @code{bool__} (always followed by unsigned).
5562
5563 @smallexample
5564 __attribute__((altivec(vector__)))
5565 __attribute__((altivec(pixel__))) unsigned short
5566 __attribute__((altivec(bool__))) unsigned
5567 @end smallexample
5568
5569 These attributes mainly are intended to support the @code{__vector},
5570 @code{__pixel}, and @code{__bool} AltiVec keywords.
5571
5572 @anchor{SPU Type Attributes}
5573 @subsection SPU Type Attributes
5574
5575 The SPU supports the @code{spu_vector} attribute for types. This attribute
5576 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5577 Language Extensions Specification. It is intended to support the
5578 @code{__vector} keyword.
5579
5580 @node Alignment
5581 @section Inquiring on Alignment of Types or Variables
5582 @cindex alignment
5583 @cindex type alignment
5584 @cindex variable alignment
5585
5586 The keyword @code{__alignof__} allows you to inquire about how an object
5587 is aligned, or the minimum alignment usually required by a type. Its
5588 syntax is just like @code{sizeof}.
5589
5590 For example, if the target machine requires a @code{double} value to be
5591 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5592 This is true on many RISC machines. On more traditional machine
5593 designs, @code{__alignof__ (double)} is 4 or even 2.
5594
5595 Some machines never actually require alignment; they allow reference to any
5596 data type even at an odd address. For these machines, @code{__alignof__}
5597 reports the smallest alignment that GCC gives the data type, usually as
5598 mandated by the target ABI.
5599
5600 If the operand of @code{__alignof__} is an lvalue rather than a type,
5601 its value is the required alignment for its type, taking into account
5602 any minimum alignment specified with GCC's @code{__attribute__}
5603 extension (@pxref{Variable Attributes}). For example, after this
5604 declaration:
5605
5606 @smallexample
5607 struct foo @{ int x; char y; @} foo1;
5608 @end smallexample
5609
5610 @noindent
5611 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5612 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5613
5614 It is an error to ask for the alignment of an incomplete type.
5615
5616
5617 @node Inline
5618 @section An Inline Function is As Fast As a Macro
5619 @cindex inline functions
5620 @cindex integrating function code
5621 @cindex open coding
5622 @cindex macros, inline alternative
5623
5624 By declaring a function inline, you can direct GCC to make
5625 calls to that function faster. One way GCC can achieve this is to
5626 integrate that function's code into the code for its callers. This
5627 makes execution faster by eliminating the function-call overhead; in
5628 addition, if any of the actual argument values are constant, their
5629 known values may permit simplifications at compile time so that not
5630 all of the inline function's code needs to be included. The effect on
5631 code size is less predictable; object code may be larger or smaller
5632 with function inlining, depending on the particular case. You can
5633 also direct GCC to try to integrate all ``simple enough'' functions
5634 into their callers with the option @option{-finline-functions}.
5635
5636 GCC implements three different semantics of declaring a function
5637 inline. One is available with @option{-std=gnu89} or
5638 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5639 on all inline declarations, another when
5640 @option{-std=c99}, @option{-std=c11},
5641 @option{-std=gnu99} or @option{-std=gnu11}
5642 (without @option{-fgnu89-inline}), and the third
5643 is used when compiling C++.
5644
5645 To declare a function inline, use the @code{inline} keyword in its
5646 declaration, like this:
5647
5648 @smallexample
5649 static inline int
5650 inc (int *a)
5651 @{
5652 return (*a)++;
5653 @}
5654 @end smallexample
5655
5656 If you are writing a header file to be included in ISO C90 programs, write
5657 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
5658
5659 The three types of inlining behave similarly in two important cases:
5660 when the @code{inline} keyword is used on a @code{static} function,
5661 like the example above, and when a function is first declared without
5662 using the @code{inline} keyword and then is defined with
5663 @code{inline}, like this:
5664
5665 @smallexample
5666 extern int inc (int *a);
5667 inline int
5668 inc (int *a)
5669 @{
5670 return (*a)++;
5671 @}
5672 @end smallexample
5673
5674 In both of these common cases, the program behaves the same as if you
5675 had not used the @code{inline} keyword, except for its speed.
5676
5677 @cindex inline functions, omission of
5678 @opindex fkeep-inline-functions
5679 When a function is both inline and @code{static}, if all calls to the
5680 function are integrated into the caller, and the function's address is
5681 never used, then the function's own assembler code is never referenced.
5682 In this case, GCC does not actually output assembler code for the
5683 function, unless you specify the option @option{-fkeep-inline-functions}.
5684 Some calls cannot be integrated for various reasons (in particular,
5685 calls that precede the function's definition cannot be integrated, and
5686 neither can recursive calls within the definition). If there is a
5687 nonintegrated call, then the function is compiled to assembler code as
5688 usual. The function must also be compiled as usual if the program
5689 refers to its address, because that can't be inlined.
5690
5691 @opindex Winline
5692 Note that certain usages in a function definition can make it unsuitable
5693 for inline substitution. Among these usages are: use of varargs, use of
5694 alloca, use of variable sized data types (@pxref{Variable Length}),
5695 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5696 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
5697 warns when a function marked @code{inline} could not be substituted,
5698 and gives the reason for the failure.
5699
5700 @cindex automatic @code{inline} for C++ member fns
5701 @cindex @code{inline} automatic for C++ member fns
5702 @cindex member fns, automatically @code{inline}
5703 @cindex C++ member fns, automatically @code{inline}
5704 @opindex fno-default-inline
5705 As required by ISO C++, GCC considers member functions defined within
5706 the body of a class to be marked inline even if they are
5707 not explicitly declared with the @code{inline} keyword. You can
5708 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5709 Options,,Options Controlling C++ Dialect}.
5710
5711 GCC does not inline any functions when not optimizing unless you specify
5712 the @samp{always_inline} attribute for the function, like this:
5713
5714 @smallexample
5715 /* @r{Prototype.} */
5716 inline void foo (const char) __attribute__((always_inline));
5717 @end smallexample
5718
5719 The remainder of this section is specific to GNU C90 inlining.
5720
5721 @cindex non-static inline function
5722 When an inline function is not @code{static}, then the compiler must assume
5723 that there may be calls from other source files; since a global symbol can
5724 be defined only once in any program, the function must not be defined in
5725 the other source files, so the calls therein cannot be integrated.
5726 Therefore, a non-@code{static} inline function is always compiled on its
5727 own in the usual fashion.
5728
5729 If you specify both @code{inline} and @code{extern} in the function
5730 definition, then the definition is used only for inlining. In no case
5731 is the function compiled on its own, not even if you refer to its
5732 address explicitly. Such an address becomes an external reference, as
5733 if you had only declared the function, and had not defined it.
5734
5735 This combination of @code{inline} and @code{extern} has almost the
5736 effect of a macro. The way to use it is to put a function definition in
5737 a header file with these keywords, and put another copy of the
5738 definition (lacking @code{inline} and @code{extern}) in a library file.
5739 The definition in the header file causes most calls to the function
5740 to be inlined. If any uses of the function remain, they refer to
5741 the single copy in the library.
5742
5743 @node Volatiles
5744 @section When is a Volatile Object Accessed?
5745 @cindex accessing volatiles
5746 @cindex volatile read
5747 @cindex volatile write
5748 @cindex volatile access
5749
5750 C has the concept of volatile objects. These are normally accessed by
5751 pointers and used for accessing hardware or inter-thread
5752 communication. The standard encourages compilers to refrain from
5753 optimizations concerning accesses to volatile objects, but leaves it
5754 implementation defined as to what constitutes a volatile access. The
5755 minimum requirement is that at a sequence point all previous accesses
5756 to volatile objects have stabilized and no subsequent accesses have
5757 occurred. Thus an implementation is free to reorder and combine
5758 volatile accesses that occur between sequence points, but cannot do
5759 so for accesses across a sequence point. The use of volatile does
5760 not allow you to violate the restriction on updating objects multiple
5761 times between two sequence points.
5762
5763 Accesses to non-volatile objects are not ordered with respect to
5764 volatile accesses. You cannot use a volatile object as a memory
5765 barrier to order a sequence of writes to non-volatile memory. For
5766 instance:
5767
5768 @smallexample
5769 int *ptr = @var{something};
5770 volatile int vobj;
5771 *ptr = @var{something};
5772 vobj = 1;
5773 @end smallexample
5774
5775 @noindent
5776 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5777 that the write to @var{*ptr} occurs by the time the update
5778 of @var{vobj} happens. If you need this guarantee, you must use
5779 a stronger memory barrier such as:
5780
5781 @smallexample
5782 int *ptr = @var{something};
5783 volatile int vobj;
5784 *ptr = @var{something};
5785 asm volatile ("" : : : "memory");
5786 vobj = 1;
5787 @end smallexample
5788
5789 A scalar volatile object is read when it is accessed in a void context:
5790
5791 @smallexample
5792 volatile int *src = @var{somevalue};
5793 *src;
5794 @end smallexample
5795
5796 Such expressions are rvalues, and GCC implements this as a
5797 read of the volatile object being pointed to.
5798
5799 Assignments are also expressions and have an rvalue. However when
5800 assigning to a scalar volatile, the volatile object is not reread,
5801 regardless of whether the assignment expression's rvalue is used or
5802 not. If the assignment's rvalue is used, the value is that assigned
5803 to the volatile object. For instance, there is no read of @var{vobj}
5804 in all the following cases:
5805
5806 @smallexample
5807 int obj;
5808 volatile int vobj;
5809 vobj = @var{something};
5810 obj = vobj = @var{something};
5811 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
5812 obj = (@var{something}, vobj = @var{anotherthing});
5813 @end smallexample
5814
5815 If you need to read the volatile object after an assignment has
5816 occurred, you must use a separate expression with an intervening
5817 sequence point.
5818
5819 As bit-fields are not individually addressable, volatile bit-fields may
5820 be implicitly read when written to, or when adjacent bit-fields are
5821 accessed. Bit-field operations may be optimized such that adjacent
5822 bit-fields are only partially accessed, if they straddle a storage unit
5823 boundary. For these reasons it is unwise to use volatile bit-fields to
5824 access hardware.
5825
5826 @node Extended Asm
5827 @section Assembler Instructions with C Expression Operands
5828 @cindex extended @code{asm}
5829 @cindex @code{asm} expressions
5830 @cindex assembler instructions
5831 @cindex registers
5832
5833 In an assembler instruction using @code{asm}, you can specify the
5834 operands of the instruction using C expressions. This means you need not
5835 guess which registers or memory locations contain the data you want
5836 to use.
5837
5838 You must specify an assembler instruction template much like what
5839 appears in a machine description, plus an operand constraint string for
5840 each operand.
5841
5842 For example, here is how to use the 68881's @code{fsinx} instruction:
5843
5844 @smallexample
5845 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5846 @end smallexample
5847
5848 @noindent
5849 Here @code{angle} is the C expression for the input operand while
5850 @code{result} is that of the output operand. Each has @samp{"f"} as its
5851 operand constraint, saying that a floating-point register is required.
5852 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5853 output operands' constraints must use @samp{=}. The constraints use the
5854 same language used in the machine description (@pxref{Constraints}).
5855
5856 Each operand is described by an operand-constraint string followed by
5857 the C expression in parentheses. A colon separates the assembler
5858 template from the first output operand and another separates the last
5859 output operand from the first input, if any. Commas separate the
5860 operands within each group. The total number of operands is currently
5861 limited to 30; this limitation may be lifted in some future version of
5862 GCC@.
5863
5864 If there are no output operands but there are input operands, you must
5865 place two consecutive colons surrounding the place where the output
5866 operands would go.
5867
5868 As of GCC version 3.1, it is also possible to specify input and output
5869 operands using symbolic names which can be referenced within the
5870 assembler code. These names are specified inside square brackets
5871 preceding the constraint string, and can be referenced inside the
5872 assembler code using @code{%[@var{name}]} instead of a percentage sign
5873 followed by the operand number. Using named operands the above example
5874 could look like:
5875
5876 @smallexample
5877 asm ("fsinx %[angle],%[output]"
5878 : [output] "=f" (result)
5879 : [angle] "f" (angle));
5880 @end smallexample
5881
5882 @noindent
5883 Note that the symbolic operand names have no relation whatsoever to
5884 other C identifiers. You may use any name you like, even those of
5885 existing C symbols, but you must ensure that no two operands within the same
5886 assembler construct use the same symbolic name.
5887
5888 Output operand expressions must be lvalues; the compiler can check this.
5889 The input operands need not be lvalues. The compiler cannot check
5890 whether the operands have data types that are reasonable for the
5891 instruction being executed. It does not parse the assembler instruction
5892 template and does not know what it means or even whether it is valid
5893 assembler input. The extended @code{asm} feature is most often used for
5894 machine instructions the compiler itself does not know exist. If
5895 the output expression cannot be directly addressed (for example, it is a
5896 bit-field), your constraint must allow a register. In that case, GCC
5897 uses the register as the output of the @code{asm}, and then stores
5898 that register into the output.
5899
5900 The ordinary output operands must be write-only; GCC assumes that
5901 the values in these operands before the instruction are dead and need
5902 not be generated. Extended asm supports input-output or read-write
5903 operands. Use the constraint character @samp{+} to indicate such an
5904 operand and list it with the output operands.
5905
5906 You may, as an alternative, logically split its function into two
5907 separate operands, one input operand and one write-only output
5908 operand. The connection between them is expressed by constraints
5909 that say they need to be in the same location when the instruction
5910 executes. You can use the same C expression for both operands, or
5911 different expressions. For example, here we write the (fictitious)
5912 @samp{combine} instruction with @code{bar} as its read-only source
5913 operand and @code{foo} as its read-write destination:
5914
5915 @smallexample
5916 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5917 @end smallexample
5918
5919 @noindent
5920 The constraint @samp{"0"} for operand 1 says that it must occupy the
5921 same location as operand 0. A number in constraint is allowed only in
5922 an input operand and it must refer to an output operand.
5923
5924 Only a number in the constraint can guarantee that one operand is in
5925 the same place as another. The mere fact that @code{foo} is the value
5926 of both operands is not enough to guarantee that they are in the
5927 same place in the generated assembler code. The following does not
5928 work reliably:
5929
5930 @smallexample
5931 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5932 @end smallexample
5933
5934 Various optimizations or reloading could cause operands 0 and 1 to be in
5935 different registers; GCC knows no reason not to do so. For example, the
5936 compiler might find a copy of the value of @code{foo} in one register and
5937 use it for operand 1, but generate the output operand 0 in a different
5938 register (copying it afterward to @code{foo}'s own address). Of course,
5939 since the register for operand 1 is not even mentioned in the assembler
5940 code, the result will not work, but GCC can't tell that.
5941
5942 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5943 the operand number for a matching constraint. For example:
5944
5945 @smallexample
5946 asm ("cmoveq %1,%2,%[result]"
5947 : [result] "=r"(result)
5948 : "r" (test), "r"(new), "[result]"(old));
5949 @end smallexample
5950
5951 Sometimes you need to make an @code{asm} operand be a specific register,
5952 but there's no matching constraint letter for that register @emph{by
5953 itself}. To force the operand into that register, use a local variable
5954 for the operand and specify the register in the variable declaration.
5955 @xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any
5956 register constraint letter that matches the register:
5957
5958 @smallexample
5959 register int *p1 asm ("r0") = @dots{};
5960 register int *p2 asm ("r1") = @dots{};
5961 register int *result asm ("r0");
5962 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5963 @end smallexample
5964
5965 @anchor{Example of asm with clobbered asm reg}
5966 In the above example, beware that a register that is call-clobbered by
5967 the target ABI will be overwritten by any function call in the
5968 assignment, including library calls for arithmetic operators.
5969 Also a register may be clobbered when generating some operations,
5970 like variable shift, memory copy or memory move on x86.
5971 Assuming it is a call-clobbered register, this may happen to @code{r0}
5972 above by the assignment to @code{p2}. If you have to use such a
5973 register, use temporary variables for expressions between the register
5974 assignment and use:
5975
5976 @smallexample
5977 int t1 = @dots{};
5978 register int *p1 asm ("r0") = @dots{};
5979 register int *p2 asm ("r1") = t1;
5980 register int *result asm ("r0");
5981 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5982 @end smallexample
5983
5984 Some instructions clobber specific hard registers. To describe this,
5985 write a third colon after the input operands, followed by the names of
5986 the clobbered hard registers (given as strings). Here is a realistic
5987 example for the VAX:
5988
5989 @smallexample
5990 asm volatile ("movc3 %0,%1,%2"
5991 : /* @r{no outputs} */
5992 : "g" (from), "g" (to), "g" (count)
5993 : "r0", "r1", "r2", "r3", "r4", "r5");
5994 @end smallexample
5995
5996 You may not write a clobber description in a way that overlaps with an
5997 input or output operand. For example, you may not have an operand
5998 describing a register class with one member if you mention that register
5999 in the clobber list. Variables declared to live in specific registers
6000 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6001 have no part mentioned in the clobber description.
6002 There is no way for you to specify that an input
6003 operand is modified without also specifying it as an output
6004 operand. Note that if all the output operands you specify are for this
6005 purpose (and hence unused), you then also need to specify
6006 @code{volatile} for the @code{asm} construct, as described below, to
6007 prevent GCC from deleting the @code{asm} statement as unused.
6008
6009 If you refer to a particular hardware register from the assembler code,
6010 you probably have to list the register after the third colon to
6011 tell the compiler the register's value is modified. In some assemblers,
6012 the register names begin with @samp{%}; to produce one @samp{%} in the
6013 assembler code, you must write @samp{%%} in the input.
6014
6015 If your assembler instruction can alter the condition code register, add
6016 @samp{cc} to the list of clobbered registers. GCC on some machines
6017 represents the condition codes as a specific hardware register;
6018 @samp{cc} serves to name this register. On other machines, the
6019 condition code is handled differently, and specifying @samp{cc} has no
6020 effect. But it is valid no matter what the machine.
6021
6022 If your assembler instructions access memory in an unpredictable
6023 fashion, add @samp{memory} to the list of clobbered registers. This
6024 causes GCC to not keep memory values cached in registers across the
6025 assembler instruction and not optimize stores or loads to that memory.
6026 You also should add the @code{volatile} keyword if the memory
6027 affected is not listed in the inputs or outputs of the @code{asm}, as
6028 the @samp{memory} clobber does not count as a side-effect of the
6029 @code{asm}. If you know how large the accessed memory is, you can add
6030 it as input or output but if this is not known, you should add
6031 @samp{memory}. As an example, if you access ten bytes of a string, you
6032 can use a memory input like:
6033
6034 @smallexample
6035 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6036 @end smallexample
6037
6038 Note that in the following example the memory input is necessary,
6039 otherwise GCC might optimize the store to @code{x} away:
6040 @smallexample
6041 int foo ()
6042 @{
6043 int x = 42;
6044 int *y = &x;
6045 int result;
6046 asm ("magic stuff accessing an 'int' pointed to by '%1'"
6047 "=&d" (r) : "a" (y), "m" (*y));
6048 return result;
6049 @}
6050 @end smallexample
6051
6052 You can put multiple assembler instructions together in a single
6053 @code{asm} template, separated by the characters normally used in assembly
6054 code for the system. A combination that works in most places is a newline
6055 to break the line, plus a tab character to move to the instruction field
6056 (written as @samp{\n\t}). Sometimes semicolons can be used, if the
6057 assembler allows semicolons as a line-breaking character. Note that some
6058 assembler dialects use semicolons to start a comment.
6059 The input operands are guaranteed not to use any of the clobbered
6060 registers, and neither do the output operands' addresses, so you can
6061 read and write the clobbered registers as many times as you like. Here
6062 is an example of multiple instructions in a template; it assumes the
6063 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6064
6065 @smallexample
6066 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6067 : /* no outputs */
6068 : "g" (from), "g" (to)
6069 : "r9", "r10");
6070 @end smallexample
6071
6072 Unless an output operand has the @samp{&} constraint modifier, GCC
6073 may allocate it in the same register as an unrelated input operand, on
6074 the assumption the inputs are consumed before the outputs are produced.
6075 This assumption may be false if the assembler code actually consists of
6076 more than one instruction. In such a case, use @samp{&} for each output
6077 operand that may not overlap an input. @xref{Modifiers}.
6078
6079 If you want to test the condition code produced by an assembler
6080 instruction, you must include a branch and a label in the @code{asm}
6081 construct, as follows:
6082
6083 @smallexample
6084 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6085 : "g" (result)
6086 : "g" (input));
6087 @end smallexample
6088
6089 @noindent
6090 This assumes your assembler supports local labels, as the GNU assembler
6091 and most Unix assemblers do.
6092
6093 Speaking of labels, jumps from one @code{asm} to another are not
6094 supported. The compiler's optimizers do not know about these jumps, and
6095 therefore they cannot take account of them when deciding how to
6096 optimize. @xref{Extended asm with goto}.
6097
6098 @cindex macros containing @code{asm}
6099 Usually the most convenient way to use these @code{asm} instructions is to
6100 encapsulate them in macros that look like functions. For example,
6101
6102 @smallexample
6103 #define sin(x) \
6104 (@{ double __value, __arg = (x); \
6105 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
6106 __value; @})
6107 @end smallexample
6108
6109 @noindent
6110 Here the variable @code{__arg} is used to make sure that the instruction
6111 operates on a proper @code{double} value, and to accept only those
6112 arguments @code{x} that can convert automatically to a @code{double}.
6113
6114 Another way to make sure the instruction operates on the correct data
6115 type is to use a cast in the @code{asm}. This is different from using a
6116 variable @code{__arg} in that it converts more different types. For
6117 example, if the desired type is @code{int}, casting the argument to
6118 @code{int} accepts a pointer with no complaint, while assigning the
6119 argument to an @code{int} variable named @code{__arg} warns about
6120 using a pointer unless the caller explicitly casts it.
6121
6122 If an @code{asm} has output operands, GCC assumes for optimization
6123 purposes the instruction has no side effects except to change the output
6124 operands. This does not mean instructions with a side effect cannot be
6125 used, but you must be careful, because the compiler may eliminate them
6126 if the output operands aren't used, or move them out of loops, or
6127 replace two with one if they constitute a common subexpression. Also,
6128 if your instruction does have a side effect on a variable that otherwise
6129 appears not to change, the old value of the variable may be reused later
6130 if it happens to be found in a register.
6131
6132 You can prevent an @code{asm} instruction from being deleted
6133 by writing the keyword @code{volatile} after
6134 the @code{asm}. For example:
6135
6136 @smallexample
6137 #define get_and_set_priority(new) \
6138 (@{ int __old; \
6139 asm volatile ("get_and_set_priority %0, %1" \
6140 : "=g" (__old) : "g" (new)); \
6141 __old; @})
6142 @end smallexample
6143
6144 @noindent
6145 The @code{volatile} keyword indicates that the instruction has
6146 important side-effects. GCC does not delete a volatile @code{asm} if
6147 it is reachable. (The instruction can still be deleted if GCC can
6148 prove that control flow never reaches the location of the
6149 instruction.) Note that even a volatile @code{asm} instruction
6150 can be moved relative to other code, including across jump
6151 instructions. For example, on many targets there is a system
6152 register that can be set to control the rounding mode of
6153 floating-point operations. You might try
6154 setting it with a volatile @code{asm}, like this PowerPC example:
6155
6156 @smallexample
6157 asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6158 sum = x + y;
6159 @end smallexample
6160
6161 @noindent
6162 This does not work reliably, as the compiler may move the addition back
6163 before the volatile @code{asm}. To make it work you need to add an
6164 artificial dependency to the @code{asm} referencing a variable in the code
6165 you don't want moved, for example:
6166
6167 @smallexample
6168 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6169 sum = x + y;
6170 @end smallexample
6171
6172 Similarly, you can't expect a
6173 sequence of volatile @code{asm} instructions to remain perfectly
6174 consecutive. If you want consecutive output, use a single @code{asm}.
6175 Also, GCC performs some optimizations across a volatile @code{asm}
6176 instruction; GCC does not ``forget everything'' when it encounters
6177 a volatile @code{asm} instruction the way some other compilers do.
6178
6179 An @code{asm} instruction without any output operands is treated
6180 identically to a volatile @code{asm} instruction.
6181
6182 It is a natural idea to look for a way to give access to the condition
6183 code left by the assembler instruction. However, when we attempted to
6184 implement this, we found no way to make it work reliably. The problem
6185 is that output operands might need reloading, which result in
6186 additional following ``store'' instructions. On most machines, these
6187 instructions alter the condition code before there is time to
6188 test it. This problem doesn't arise for ordinary ``test'' and
6189 ``compare'' instructions because they don't have any output operands.
6190
6191 For reasons similar to those described above, it is not possible to give
6192 an assembler instruction access to the condition code left by previous
6193 instructions.
6194
6195 @anchor{Extended asm with goto}
6196 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6197 jump to one or more C labels. In this form, a fifth section after the
6198 clobber list contains a list of all C labels to which the assembly may jump.
6199 Each label operand is implicitly self-named. The @code{asm} is also assumed
6200 to fall through to the next statement.
6201
6202 This form of @code{asm} is restricted to not have outputs. This is due
6203 to a internal restriction in the compiler that control transfer instructions
6204 cannot have outputs. This restriction on @code{asm goto} may be lifted
6205 in some future version of the compiler. In the meantime, @code{asm goto}
6206 may include a memory clobber, and so leave outputs in memory.
6207
6208 @smallexample
6209 int frob(int x)
6210 @{
6211 int y;
6212 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6213 : : "r"(x), "r"(&y) : "r5", "memory" : error);
6214 return y;
6215 error:
6216 return -1;
6217 @}
6218 @end smallexample
6219
6220 @noindent
6221 In this (inefficient) example, the @code{frob} instruction sets the
6222 carry bit to indicate an error. The @code{jc} instruction detects
6223 this and branches to the @code{error} label. Finally, the output
6224 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6225 for variable @code{y}, which is later read by the @code{return} statement.
6226
6227 @smallexample
6228 void doit(void)
6229 @{
6230 int i = 0;
6231 asm goto ("mfsr %%r1, 123; jmp %%r1;"
6232 ".pushsection doit_table;"
6233 ".long %l0, %l1, %l2, %l3;"
6234 ".popsection"
6235 : : : "r1" : label1, label2, label3, label4);
6236 __builtin_unreachable ();
6237
6238 label1:
6239 f1();
6240 return;
6241 label2:
6242 f2();
6243 return;
6244 label3:
6245 i = 1;
6246 label4:
6247 f3(i);
6248 @}
6249 @end smallexample
6250
6251 @noindent
6252 In this (also inefficient) example, the @code{mfsr} instruction reads
6253 an address from some out-of-band machine register, and the following
6254 @code{jmp} instruction branches to that address. The address read by
6255 the @code{mfsr} instruction is assumed to have been previously set via
6256 some application-specific mechanism to be one of the four values stored
6257 in the @code{doit_table} section. Finally, the @code{asm} is followed
6258 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6259 does not in fact fall through.
6260
6261 @smallexample
6262 #define TRACE1(NUM) \
6263 do @{ \
6264 asm goto ("0: nop;" \
6265 ".pushsection trace_table;" \
6266 ".long 0b, %l0;" \
6267 ".popsection" \
6268 : : : : trace#NUM); \
6269 if (0) @{ trace#NUM: trace(); @} \
6270 @} while (0)
6271 #define TRACE TRACE1(__COUNTER__)
6272 @end smallexample
6273
6274 @noindent
6275 In this example (which in fact inspired the @code{asm goto} feature)
6276 we want on rare occasions to call the @code{trace} function; on other
6277 occasions we'd like to keep the overhead to the absolute minimum.
6278 The normal code path consists of a single @code{nop} instruction.
6279 However, we record the address of this @code{nop} together with the
6280 address of a label that calls the @code{trace} function. This allows
6281 the @code{nop} instruction to be patched at run time to be an
6282 unconditional branch to the stored label. It is assumed that an
6283 optimizing compiler moves the labeled block out of line, to
6284 optimize the fall through path from the @code{asm}.
6285
6286 If you are writing a header file that should be includable in ISO C
6287 programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate
6288 Keywords}.
6289
6290 @subsection Size of an @code{asm}
6291
6292 Some targets require that GCC track the size of each instruction used in
6293 order to generate correct code. Because the final length of an
6294 @code{asm} is only known by the assembler, GCC must make an estimate as
6295 to how big it will be. The estimate is formed by counting the number of
6296 statements in the pattern of the @code{asm} and multiplying that by the
6297 length of the longest instruction on that processor. Statements in the
6298 @code{asm} are identified by newline characters and whatever statement
6299 separator characters are supported by the assembler; on most processors
6300 this is the @samp{;} character.
6301
6302 Normally, GCC's estimate is perfectly adequate to ensure that correct
6303 code is generated, but it is possible to confuse the compiler if you use
6304 pseudo instructions or assembler macros that expand into multiple real
6305 instructions or if you use assembler directives that expand to more
6306 space in the object file than is needed for a single instruction.
6307 If this happens then the assembler produces a diagnostic saying that
6308 a label is unreachable.
6309
6310 @subsection i386 floating-point asm operands
6311
6312 There are several rules on the usage of stack-like regs in
6313 asm_operands insns. These rules apply only to the operands that are
6314 stack-like regs:
6315
6316 @enumerate
6317 @item
6318 Given a set of input regs that die in an asm_operands, it is
6319 necessary to know which are implicitly popped by the asm, and
6320 which must be explicitly popped by GCC@.
6321
6322 An input reg that is implicitly popped by the asm must be
6323 explicitly clobbered, unless it is constrained to match an
6324 output operand.
6325
6326 @item
6327 For any input reg that is implicitly popped by an asm, it is
6328 necessary to know how to adjust the stack to compensate for the pop.
6329 If any non-popped input is closer to the top of the reg-stack than
6330 the implicitly popped reg, it would not be possible to know what the
6331 stack looked like---it's not clear how the rest of the stack ``slides
6332 up''.
6333
6334 All implicitly popped input regs must be closer to the top of
6335 the reg-stack than any input that is not implicitly popped.
6336
6337 It is possible that if an input dies in an insn, reload might
6338 use the input reg for an output reload. Consider this example:
6339
6340 @smallexample
6341 asm ("foo" : "=t" (a) : "f" (b));
6342 @end smallexample
6343
6344 @noindent
6345 This asm says that input B is not popped by the asm, and that
6346 the asm pushes a result onto the reg-stack, i.e., the stack is one
6347 deeper after the asm than it was before. But, it is possible that
6348 reload thinks that it can use the same reg for both the input and
6349 the output, if input B dies in this insn.
6350
6351 If any input operand uses the @code{f} constraint, all output reg
6352 constraints must use the @code{&} earlyclobber.
6353
6354 The asm above would be written as
6355
6356 @smallexample
6357 asm ("foo" : "=&t" (a) : "f" (b));
6358 @end smallexample
6359
6360 @item
6361 Some operands need to be in particular places on the stack. All
6362 output operands fall in this category---there is no other way to
6363 know which regs the outputs appear in unless the user indicates
6364 this in the constraints.
6365
6366 Output operands must specifically indicate which reg an output
6367 appears in after an asm. @code{=f} is not allowed: the operand
6368 constraints must select a class with a single reg.
6369
6370 @item
6371 Output operands may not be ``inserted'' between existing stack regs.
6372 Since no 387 opcode uses a read/write operand, all output operands
6373 are dead before the asm_operands, and are pushed by the asm_operands.
6374 It makes no sense to push anywhere but the top of the reg-stack.
6375
6376 Output operands must start at the top of the reg-stack: output
6377 operands may not ``skip'' a reg.
6378
6379 @item
6380 Some asm statements may need extra stack space for internal
6381 calculations. This can be guaranteed by clobbering stack registers
6382 unrelated to the inputs and outputs.
6383
6384 @end enumerate
6385
6386 Here are a couple of reasonable asms to want to write. This asm
6387 takes one input, which is internally popped, and produces two outputs.
6388
6389 @smallexample
6390 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6391 @end smallexample
6392
6393 @noindent
6394 This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6395 and replaces them with one output. The user must code the @code{st(1)}
6396 clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs.
6397
6398 @smallexample
6399 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6400 @end smallexample
6401
6402 @include md.texi
6403
6404 @node Asm Labels
6405 @section Controlling Names Used in Assembler Code
6406 @cindex assembler names for identifiers
6407 @cindex names used in assembler code
6408 @cindex identifiers, names in assembler code
6409
6410 You can specify the name to be used in the assembler code for a C
6411 function or variable by writing the @code{asm} (or @code{__asm__})
6412 keyword after the declarator as follows:
6413
6414 @smallexample
6415 int foo asm ("myfoo") = 2;
6416 @end smallexample
6417
6418 @noindent
6419 This specifies that the name to be used for the variable @code{foo} in
6420 the assembler code should be @samp{myfoo} rather than the usual
6421 @samp{_foo}.
6422
6423 On systems where an underscore is normally prepended to the name of a C
6424 function or variable, this feature allows you to define names for the
6425 linker that do not start with an underscore.
6426
6427 It does not make sense to use this feature with a non-static local
6428 variable since such variables do not have assembler names. If you are
6429 trying to put the variable in a particular register, see @ref{Explicit
6430 Reg Vars}. GCC presently accepts such code with a warning, but will
6431 probably be changed to issue an error, rather than a warning, in the
6432 future.
6433
6434 You cannot use @code{asm} in this way in a function @emph{definition}; but
6435 you can get the same effect by writing a declaration for the function
6436 before its definition and putting @code{asm} there, like this:
6437
6438 @smallexample
6439 extern func () asm ("FUNC");
6440
6441 func (x, y)
6442 int x, y;
6443 /* @r{@dots{}} */
6444 @end smallexample
6445
6446 It is up to you to make sure that the assembler names you choose do not
6447 conflict with any other assembler symbols. Also, you must not use a
6448 register name; that would produce completely invalid assembler code. GCC
6449 does not as yet have the ability to store static variables in registers.
6450 Perhaps that will be added.
6451
6452 @node Explicit Reg Vars
6453 @section Variables in Specified Registers
6454 @cindex explicit register variables
6455 @cindex variables in specified registers
6456 @cindex specified registers
6457 @cindex registers, global allocation
6458
6459 GNU C allows you to put a few global variables into specified hardware
6460 registers. You can also specify the register in which an ordinary
6461 register variable should be allocated.
6462
6463 @itemize @bullet
6464 @item
6465 Global register variables reserve registers throughout the program.
6466 This may be useful in programs such as programming language
6467 interpreters that have a couple of global variables that are accessed
6468 very often.
6469
6470 @item
6471 Local register variables in specific registers do not reserve the
6472 registers, except at the point where they are used as input or output
6473 operands in an @code{asm} statement and the @code{asm} statement itself is
6474 not deleted. The compiler's data flow analysis is capable of determining
6475 where the specified registers contain live values, and where they are
6476 available for other uses. Stores into local register variables may be deleted
6477 when they appear to be dead according to dataflow analysis. References
6478 to local register variables may be deleted or moved or simplified.
6479
6480 These local variables are sometimes convenient for use with the extended
6481 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6482 output of the assembler instruction directly into a particular register.
6483 (This works provided the register you specify fits the constraints
6484 specified for that operand in the @code{asm}.)
6485 @end itemize
6486
6487 @menu
6488 * Global Reg Vars::
6489 * Local Reg Vars::
6490 @end menu
6491
6492 @node Global Reg Vars
6493 @subsection Defining Global Register Variables
6494 @cindex global register variables
6495 @cindex registers, global variables in
6496
6497 You can define a global register variable in GNU C like this:
6498
6499 @smallexample
6500 register int *foo asm ("a5");
6501 @end smallexample
6502
6503 @noindent
6504 Here @code{a5} is the name of the register that should be used. Choose a
6505 register that is normally saved and restored by function calls on your
6506 machine, so that library routines will not clobber it.
6507
6508 Naturally the register name is cpu-dependent, so you need to
6509 conditionalize your program according to cpu type. The register
6510 @code{a5} is a good choice on a 68000 for a variable of pointer
6511 type. On machines with register windows, be sure to choose a ``global''
6512 register that is not affected magically by the function call mechanism.
6513
6514 In addition, operating systems on one type of cpu may differ in how they
6515 name the registers; then you need additional conditionals. For
6516 example, some 68000 operating systems call this register @code{%a5}.
6517
6518 Eventually there may be a way of asking the compiler to choose a register
6519 automatically, but first we need to figure out how it should choose and
6520 how to enable you to guide the choice. No solution is evident.
6521
6522 Defining a global register variable in a certain register reserves that
6523 register entirely for this use, at least within the current compilation.
6524 The register is not allocated for any other purpose in the functions
6525 in the current compilation, and is not saved and restored by
6526 these functions. Stores into this register are never deleted even if they
6527 appear to be dead, but references may be deleted or moved or
6528 simplified.
6529
6530 It is not safe to access the global register variables from signal
6531 handlers, or from more than one thread of control, because the system
6532 library routines may temporarily use the register for other things (unless
6533 you recompile them specially for the task at hand).
6534
6535 @cindex @code{qsort}, and global register variables
6536 It is not safe for one function that uses a global register variable to
6537 call another such function @code{foo} by way of a third function
6538 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6539 different source file in which the variable isn't declared). This is
6540 because @code{lose} might save the register and put some other value there.
6541 For example, you can't expect a global register variable to be available in
6542 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6543 might have put something else in that register. (If you are prepared to
6544 recompile @code{qsort} with the same global register variable, you can
6545 solve this problem.)
6546
6547 If you want to recompile @code{qsort} or other source files that do not
6548 actually use your global register variable, so that they do not use that
6549 register for any other purpose, then it suffices to specify the compiler
6550 option @option{-ffixed-@var{reg}}. You need not actually add a global
6551 register declaration to their source code.
6552
6553 A function that can alter the value of a global register variable cannot
6554 safely be called from a function compiled without this variable, because it
6555 could clobber the value the caller expects to find there on return.
6556 Therefore, the function that is the entry point into the part of the
6557 program that uses the global register variable must explicitly save and
6558 restore the value that belongs to its caller.
6559
6560 @cindex register variable after @code{longjmp}
6561 @cindex global register after @code{longjmp}
6562 @cindex value after @code{longjmp}
6563 @findex longjmp
6564 @findex setjmp
6565 On most machines, @code{longjmp} restores to each global register
6566 variable the value it had at the time of the @code{setjmp}. On some
6567 machines, however, @code{longjmp} does not change the value of global
6568 register variables. To be portable, the function that called @code{setjmp}
6569 should make other arrangements to save the values of the global register
6570 variables, and to restore them in a @code{longjmp}. This way, the same
6571 thing happens regardless of what @code{longjmp} does.
6572
6573 All global register variable declarations must precede all function
6574 definitions. If such a declaration could appear after function
6575 definitions, the declaration would be too late to prevent the register from
6576 being used for other purposes in the preceding functions.
6577
6578 Global register variables may not have initial values, because an
6579 executable file has no means to supply initial contents for a register.
6580
6581 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6582 registers, but certain library functions, such as @code{getwd}, as well
6583 as the subroutines for division and remainder, modify g3 and g4. g1 and
6584 g2 are local temporaries.
6585
6586 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6587 Of course, it does not do to use more than a few of those.
6588
6589 @node Local Reg Vars
6590 @subsection Specifying Registers for Local Variables
6591 @cindex local variables, specifying registers
6592 @cindex specifying registers for local variables
6593 @cindex registers for local variables
6594
6595 You can define a local register variable with a specified register
6596 like this:
6597
6598 @smallexample
6599 register int *foo asm ("a5");
6600 @end smallexample
6601
6602 @noindent
6603 Here @code{a5} is the name of the register that should be used. Note
6604 that this is the same syntax used for defining global register
6605 variables, but for a local variable it appears within a function.
6606
6607 Naturally the register name is cpu-dependent, but this is not a
6608 problem, since specific registers are most often useful with explicit
6609 assembler instructions (@pxref{Extended Asm}). Both of these things
6610 generally require that you conditionalize your program according to
6611 cpu type.
6612
6613 In addition, operating systems on one type of cpu may differ in how they
6614 name the registers; then you need additional conditionals. For
6615 example, some 68000 operating systems call this register @code{%a5}.
6616
6617 Defining such a register variable does not reserve the register; it
6618 remains available for other uses in places where flow control determines
6619 the variable's value is not live.
6620
6621 This option does not guarantee that GCC generates code that has
6622 this variable in the register you specify at all times. You may not
6623 code an explicit reference to this register in the @emph{assembler
6624 instruction template} part of an @code{asm} statement and assume it
6625 always refers to this variable. However, using the variable as an
6626 @code{asm} @emph{operand} guarantees that the specified register is used
6627 for the operand.
6628
6629 Stores into local register variables may be deleted when they appear to be dead
6630 according to dataflow analysis. References to local register variables may
6631 be deleted or moved or simplified.
6632
6633 As for global register variables, it's recommended that you choose a
6634 register that is normally saved and restored by function calls on
6635 your machine, so that library routines will not clobber it. A common
6636 pitfall is to initialize multiple call-clobbered registers with
6637 arbitrary expressions, where a function call or library call for an
6638 arithmetic operator overwrites a register value from a previous
6639 assignment, for example @code{r0} below:
6640 @smallexample
6641 register int *p1 asm ("r0") = @dots{};
6642 register int *p2 asm ("r1") = @dots{};
6643 @end smallexample
6644
6645 @noindent
6646 In those cases, a solution is to use a temporary variable for
6647 each arbitrary expression. @xref{Example of asm with clobbered asm reg}.
6648
6649 @node Alternate Keywords
6650 @section Alternate Keywords
6651 @cindex alternate keywords
6652 @cindex keywords, alternate
6653
6654 @option{-ansi} and the various @option{-std} options disable certain
6655 keywords. This causes trouble when you want to use GNU C extensions, or
6656 a general-purpose header file that should be usable by all programs,
6657 including ISO C programs. The keywords @code{asm}, @code{typeof} and
6658 @code{inline} are not available in programs compiled with
6659 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6660 program compiled with @option{-std=c99} or @option{-std=c11}). The
6661 ISO C99 keyword
6662 @code{restrict} is only available when @option{-std=gnu99} (which will
6663 eventually be the default) or @option{-std=c99} (or the equivalent
6664 @option{-std=iso9899:1999}), or an option for a later standard
6665 version, is used.
6666
6667 The way to solve these problems is to put @samp{__} at the beginning and
6668 end of each problematical keyword. For example, use @code{__asm__}
6669 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6670
6671 Other C compilers won't accept these alternative keywords; if you want to
6672 compile with another compiler, you can define the alternate keywords as
6673 macros to replace them with the customary keywords. It looks like this:
6674
6675 @smallexample
6676 #ifndef __GNUC__
6677 #define __asm__ asm
6678 #endif
6679 @end smallexample
6680
6681 @findex __extension__
6682 @opindex pedantic
6683 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6684 You can
6685 prevent such warnings within one expression by writing
6686 @code{__extension__} before the expression. @code{__extension__} has no
6687 effect aside from this.
6688
6689 @node Incomplete Enums
6690 @section Incomplete @code{enum} Types
6691
6692 You can define an @code{enum} tag without specifying its possible values.
6693 This results in an incomplete type, much like what you get if you write
6694 @code{struct foo} without describing the elements. A later declaration
6695 that does specify the possible values completes the type.
6696
6697 You can't allocate variables or storage using the type while it is
6698 incomplete. However, you can work with pointers to that type.
6699
6700 This extension may not be very useful, but it makes the handling of
6701 @code{enum} more consistent with the way @code{struct} and @code{union}
6702 are handled.
6703
6704 This extension is not supported by GNU C++.
6705
6706 @node Function Names
6707 @section Function Names as Strings
6708 @cindex @code{__func__} identifier
6709 @cindex @code{__FUNCTION__} identifier
6710 @cindex @code{__PRETTY_FUNCTION__} identifier
6711
6712 GCC provides three magic variables that hold the name of the current
6713 function, as a string. The first of these is @code{__func__}, which
6714 is part of the C99 standard:
6715
6716 The identifier @code{__func__} is implicitly declared by the translator
6717 as if, immediately following the opening brace of each function
6718 definition, the declaration
6719
6720 @smallexample
6721 static const char __func__[] = "function-name";
6722 @end smallexample
6723
6724 @noindent
6725 appeared, where function-name is the name of the lexically-enclosing
6726 function. This name is the unadorned name of the function.
6727
6728 @code{__FUNCTION__} is another name for @code{__func__}. Older
6729 versions of GCC recognize only this name. However, it is not
6730 standardized. For maximum portability, we recommend you use
6731 @code{__func__}, but provide a fallback definition with the
6732 preprocessor:
6733
6734 @smallexample
6735 #if __STDC_VERSION__ < 199901L
6736 # if __GNUC__ >= 2
6737 # define __func__ __FUNCTION__
6738 # else
6739 # define __func__ "<unknown>"
6740 # endif
6741 #endif
6742 @end smallexample
6743
6744 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6745 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
6746 the type signature of the function as well as its bare name. For
6747 example, this program:
6748
6749 @smallexample
6750 extern "C" @{
6751 extern int printf (char *, ...);
6752 @}
6753
6754 class a @{
6755 public:
6756 void sub (int i)
6757 @{
6758 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6759 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6760 @}
6761 @};
6762
6763 int
6764 main (void)
6765 @{
6766 a ax;
6767 ax.sub (0);
6768 return 0;
6769 @}
6770 @end smallexample
6771
6772 @noindent
6773 gives this output:
6774
6775 @smallexample
6776 __FUNCTION__ = sub
6777 __PRETTY_FUNCTION__ = void a::sub(int)
6778 @end smallexample
6779
6780 These identifiers are not preprocessor macros. In GCC 3.3 and
6781 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6782 were treated as string literals; they could be used to initialize
6783 @code{char} arrays, and they could be concatenated with other string
6784 literals. GCC 3.4 and later treat them as variables, like
6785 @code{__func__}. In C++, @code{__FUNCTION__} and
6786 @code{__PRETTY_FUNCTION__} have always been variables.
6787
6788 @node Return Address
6789 @section Getting the Return or Frame Address of a Function
6790
6791 These functions may be used to get information about the callers of a
6792 function.
6793
6794 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6795 This function returns the return address of the current function, or of
6796 one of its callers. The @var{level} argument is number of frames to
6797 scan up the call stack. A value of @code{0} yields the return address
6798 of the current function, a value of @code{1} yields the return address
6799 of the caller of the current function, and so forth. When inlining
6800 the expected behavior is that the function returns the address of
6801 the function that is returned to. To work around this behavior use
6802 the @code{noinline} function attribute.
6803
6804 The @var{level} argument must be a constant integer.
6805
6806 On some machines it may be impossible to determine the return address of
6807 any function other than the current one; in such cases, or when the top
6808 of the stack has been reached, this function returns @code{0} or a
6809 random value. In addition, @code{__builtin_frame_address} may be used
6810 to determine if the top of the stack has been reached.
6811
6812 Additional post-processing of the returned value may be needed, see
6813 @code{__builtin_extract_return_addr}.
6814
6815 This function should only be used with a nonzero argument for debugging
6816 purposes.
6817 @end deftypefn
6818
6819 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
6820 The address as returned by @code{__builtin_return_address} may have to be fed
6821 through this function to get the actual encoded address. For example, on the
6822 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6823 platforms an offset has to be added for the true next instruction to be
6824 executed.
6825
6826 If no fixup is needed, this function simply passes through @var{addr}.
6827 @end deftypefn
6828
6829 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6830 This function does the reverse of @code{__builtin_extract_return_addr}.
6831 @end deftypefn
6832
6833 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6834 This function is similar to @code{__builtin_return_address}, but it
6835 returns the address of the function frame rather than the return address
6836 of the function. Calling @code{__builtin_frame_address} with a value of
6837 @code{0} yields the frame address of the current function, a value of
6838 @code{1} yields the frame address of the caller of the current function,
6839 and so forth.
6840
6841 The frame is the area on the stack that holds local variables and saved
6842 registers. The frame address is normally the address of the first word
6843 pushed on to the stack by the function. However, the exact definition
6844 depends upon the processor and the calling convention. If the processor
6845 has a dedicated frame pointer register, and the function has a frame,
6846 then @code{__builtin_frame_address} returns the value of the frame
6847 pointer register.
6848
6849 On some machines it may be impossible to determine the frame address of
6850 any function other than the current one; in such cases, or when the top
6851 of the stack has been reached, this function returns @code{0} if
6852 the first frame pointer is properly initialized by the startup code.
6853
6854 This function should only be used with a nonzero argument for debugging
6855 purposes.
6856 @end deftypefn
6857
6858 @node Vector Extensions
6859 @section Using Vector Instructions through Built-in Functions
6860
6861 On some targets, the instruction set contains SIMD vector instructions which
6862 operate on multiple values contained in one large register at the same time.
6863 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6864 this way.
6865
6866 The first step in using these extensions is to provide the necessary data
6867 types. This should be done using an appropriate @code{typedef}:
6868
6869 @smallexample
6870 typedef int v4si __attribute__ ((vector_size (16)));
6871 @end smallexample
6872
6873 @noindent
6874 The @code{int} type specifies the base type, while the attribute specifies
6875 the vector size for the variable, measured in bytes. For example, the
6876 declaration above causes the compiler to set the mode for the @code{v4si}
6877 type to be 16 bytes wide and divided into @code{int} sized units. For
6878 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6879 corresponding mode of @code{foo} is @acronym{V4SI}.
6880
6881 The @code{vector_size} attribute is only applicable to integral and
6882 float scalars, although arrays, pointers, and function return values
6883 are allowed in conjunction with this construct. Only power of two
6884 sizes are currently allowed.
6885
6886 All the basic integer types can be used as base types, both as signed
6887 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6888 @code{long long}. In addition, @code{float} and @code{double} can be
6889 used to build floating-point vector types.
6890
6891 Specifying a combination that is not valid for the current architecture
6892 causes GCC to synthesize the instructions using a narrower mode.
6893 For example, if you specify a variable of type @code{V4SI} and your
6894 architecture does not allow for this specific SIMD type, GCC
6895 produces code that uses 4 @code{SIs}.
6896
6897 The types defined in this manner can be used with a subset of normal C
6898 operations. Currently, GCC allows using the following operators
6899 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6900
6901 The operations behave like C++ @code{valarrays}. Addition is defined as
6902 the addition of the corresponding elements of the operands. For
6903 example, in the code below, each of the 4 elements in @var{a} is
6904 added to the corresponding 4 elements in @var{b} and the resulting
6905 vector is stored in @var{c}.
6906
6907 @smallexample
6908 typedef int v4si __attribute__ ((vector_size (16)));
6909
6910 v4si a, b, c;
6911
6912 c = a + b;
6913 @end smallexample
6914
6915 Subtraction, multiplication, division, and the logical operations
6916 operate in a similar manner. Likewise, the result of using the unary
6917 minus or complement operators on a vector type is a vector whose
6918 elements are the negative or complemented values of the corresponding
6919 elements in the operand.
6920
6921 It is possible to use shifting operators @code{<<}, @code{>>} on
6922 integer-type vectors. The operation is defined as following: @code{@{a0,
6923 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
6924 @dots{}, an >> bn@}}@. Vector operands must have the same number of
6925 elements.
6926
6927 For convenience, it is allowed to use a binary vector operation
6928 where one operand is a scalar. In that case the compiler transforms
6929 the scalar operand into a vector where each element is the scalar from
6930 the operation. The transformation happens only if the scalar could be
6931 safely converted to the vector-element type.
6932 Consider the following code.
6933
6934 @smallexample
6935 typedef int v4si __attribute__ ((vector_size (16)));
6936
6937 v4si a, b, c;
6938 long l;
6939
6940 a = b + 1; /* a = b + @{1,1,1,1@}; */
6941 a = 2 * b; /* a = @{2,2,2,2@} * b; */
6942
6943 a = l + a; /* Error, cannot convert long to int. */
6944 @end smallexample
6945
6946 Vectors can be subscripted as if the vector were an array with
6947 the same number of elements and base type. Out of bound accesses
6948 invoke undefined behavior at run time. Warnings for out of bound
6949 accesses for vector subscription can be enabled with
6950 @option{-Warray-bounds}.
6951
6952 Vector comparison is supported with standard comparison
6953 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
6954 vector expressions of integer-type or real-type. Comparison between
6955 integer-type vectors and real-type vectors are not supported. The
6956 result of the comparison is a vector of the same width and number of
6957 elements as the comparison operands with a signed integral element
6958 type.
6959
6960 Vectors are compared element-wise producing 0 when comparison is false
6961 and -1 (constant of the appropriate type where all bits are set)
6962 otherwise. Consider the following example.
6963
6964 @smallexample
6965 typedef int v4si __attribute__ ((vector_size (16)));
6966
6967 v4si a = @{1,2,3,4@};
6968 v4si b = @{3,2,1,4@};
6969 v4si c;
6970
6971 c = a > b; /* The result would be @{0, 0,-1, 0@} */
6972 c = a == b; /* The result would be @{0,-1, 0,-1@} */
6973 @end smallexample
6974
6975 Vector shuffling is available using functions
6976 @code{__builtin_shuffle (vec, mask)} and
6977 @code{__builtin_shuffle (vec0, vec1, mask)}.
6978 Both functions construct a permutation of elements from one or two
6979 vectors and return a vector of the same type as the input vector(s).
6980 The @var{mask} is an integral vector with the same width (@var{W})
6981 and element count (@var{N}) as the output vector.
6982
6983 The elements of the input vectors are numbered in memory ordering of
6984 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
6985 elements of @var{mask} are considered modulo @var{N} in the single-operand
6986 case and modulo @math{2*@var{N}} in the two-operand case.
6987
6988 Consider the following example,
6989
6990 @smallexample
6991 typedef int v4si __attribute__ ((vector_size (16)));
6992
6993 v4si a = @{1,2,3,4@};
6994 v4si b = @{5,6,7,8@};
6995 v4si mask1 = @{0,1,1,3@};
6996 v4si mask2 = @{0,4,2,5@};
6997 v4si res;
6998
6999 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7000 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7001 @end smallexample
7002
7003 Note that @code{__builtin_shuffle} is intentionally semantically
7004 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7005
7006 You can declare variables and use them in function calls and returns, as
7007 well as in assignments and some casts. You can specify a vector type as
7008 a return type for a function. Vector types can also be used as function
7009 arguments. It is possible to cast from one vector type to another,
7010 provided they are of the same size (in fact, you can also cast vectors
7011 to and from other datatypes of the same size).
7012
7013 You cannot operate between vectors of different lengths or different
7014 signedness without a cast.
7015
7016 @node Offsetof
7017 @section Offsetof
7018 @findex __builtin_offsetof
7019
7020 GCC implements for both C and C++ a syntactic extension to implement
7021 the @code{offsetof} macro.
7022
7023 @smallexample
7024 primary:
7025 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7026
7027 offsetof_member_designator:
7028 @code{identifier}
7029 | offsetof_member_designator "." @code{identifier}
7030 | offsetof_member_designator "[" @code{expr} "]"
7031 @end smallexample
7032
7033 This extension is sufficient such that
7034
7035 @smallexample
7036 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7037 @end smallexample
7038
7039 @noindent
7040 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7041 may be dependent. In either case, @var{member} may consist of a single
7042 identifier, or a sequence of member accesses and array references.
7043
7044 @node __sync Builtins
7045 @section Legacy __sync Built-in Functions for Atomic Memory Access
7046
7047 The following built-in functions
7048 are intended to be compatible with those described
7049 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7050 section 7.4. As such, they depart from the normal GCC practice of using
7051 the @samp{__builtin_} prefix, and further that they are overloaded such that
7052 they work on multiple types.
7053
7054 The definition given in the Intel documentation allows only for the use of
7055 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7056 counterparts. GCC allows any integral scalar or pointer type that is
7057 1, 2, 4 or 8 bytes in length.
7058
7059 Not all operations are supported by all target processors. If a particular
7060 operation cannot be implemented on the target processor, a warning is
7061 generated and a call an external function is generated. The external
7062 function carries the same name as the built-in version,
7063 with an additional suffix
7064 @samp{_@var{n}} where @var{n} is the size of the data type.
7065
7066 @c ??? Should we have a mechanism to suppress this warning? This is almost
7067 @c useful for implementing the operation under the control of an external
7068 @c mutex.
7069
7070 In most cases, these built-in functions are considered a @dfn{full barrier}.
7071 That is,
7072 no memory operand is moved across the operation, either forward or
7073 backward. Further, instructions are issued as necessary to prevent the
7074 processor from speculating loads across the operation and from queuing stores
7075 after the operation.
7076
7077 All of the routines are described in the Intel documentation to take
7078 ``an optional list of variables protected by the memory barrier''. It's
7079 not clear what is meant by that; it could mean that @emph{only} the
7080 following variables are protected, or it could mean that these variables
7081 should in addition be protected. At present GCC ignores this list and
7082 protects all variables that are globally accessible. If in the future
7083 we make some use of this list, an empty list will continue to mean all
7084 globally accessible variables.
7085
7086 @table @code
7087 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7088 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7089 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7090 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7091 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7092 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7093 @findex __sync_fetch_and_add
7094 @findex __sync_fetch_and_sub
7095 @findex __sync_fetch_and_or
7096 @findex __sync_fetch_and_and
7097 @findex __sync_fetch_and_xor
7098 @findex __sync_fetch_and_nand
7099 These built-in functions perform the operation suggested by the name, and
7100 returns the value that had previously been in memory. That is,
7101
7102 @smallexample
7103 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7104 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
7105 @end smallexample
7106
7107 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7108 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7109
7110 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7111 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7112 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7113 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7114 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7115 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7116 @findex __sync_add_and_fetch
7117 @findex __sync_sub_and_fetch
7118 @findex __sync_or_and_fetch
7119 @findex __sync_and_and_fetch
7120 @findex __sync_xor_and_fetch
7121 @findex __sync_nand_and_fetch
7122 These built-in functions perform the operation suggested by the name, and
7123 return the new value. That is,
7124
7125 @smallexample
7126 @{ *ptr @var{op}= value; return *ptr; @}
7127 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
7128 @end smallexample
7129
7130 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7131 as @code{*ptr = ~(*ptr & value)} instead of
7132 @code{*ptr = ~*ptr & value}.
7133
7134 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7135 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7136 @findex __sync_bool_compare_and_swap
7137 @findex __sync_val_compare_and_swap
7138 These built-in functions perform an atomic compare and swap.
7139 That is, if the current
7140 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7141 @code{*@var{ptr}}.
7142
7143 The ``bool'' version returns true if the comparison is successful and
7144 @var{newval} is written. The ``val'' version returns the contents
7145 of @code{*@var{ptr}} before the operation.
7146
7147 @item __sync_synchronize (...)
7148 @findex __sync_synchronize
7149 This built-in function issues a full memory barrier.
7150
7151 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7152 @findex __sync_lock_test_and_set
7153 This built-in function, as described by Intel, is not a traditional test-and-set
7154 operation, but rather an atomic exchange operation. It writes @var{value}
7155 into @code{*@var{ptr}}, and returns the previous contents of
7156 @code{*@var{ptr}}.
7157
7158 Many targets have only minimal support for such locks, and do not support
7159 a full exchange operation. In this case, a target may support reduced
7160 functionality here by which the @emph{only} valid value to store is the
7161 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
7162 is implementation defined.
7163
7164 This built-in function is not a full barrier,
7165 but rather an @dfn{acquire barrier}.
7166 This means that references after the operation cannot move to (or be
7167 speculated to) before the operation, but previous memory stores may not
7168 be globally visible yet, and previous memory loads may not yet be
7169 satisfied.
7170
7171 @item void __sync_lock_release (@var{type} *ptr, ...)
7172 @findex __sync_lock_release
7173 This built-in function releases the lock acquired by
7174 @code{__sync_lock_test_and_set}.
7175 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7176
7177 This built-in function is not a full barrier,
7178 but rather a @dfn{release barrier}.
7179 This means that all previous memory stores are globally visible, and all
7180 previous memory loads have been satisfied, but following memory reads
7181 are not prevented from being speculated to before the barrier.
7182 @end table
7183
7184 @node __atomic Builtins
7185 @section Built-in functions for memory model aware atomic operations
7186
7187 The following built-in functions approximately match the requirements for
7188 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7189 functions, but all also have a memory model parameter. These are all
7190 identified by being prefixed with @samp{__atomic}, and most are overloaded
7191 such that they work with multiple types.
7192
7193 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7194 bytes in length. 16-byte integral types are also allowed if
7195 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7196
7197 Target architectures are encouraged to provide their own patterns for
7198 each of these built-in functions. If no target is provided, the original
7199 non-memory model set of @samp{__sync} atomic built-in functions are
7200 utilized, along with any required synchronization fences surrounding it in
7201 order to achieve the proper behavior. Execution in this case is subject
7202 to the same restrictions as those built-in functions.
7203
7204 If there is no pattern or mechanism to provide a lock free instruction
7205 sequence, a call is made to an external routine with the same parameters
7206 to be resolved at run time.
7207
7208 The four non-arithmetic functions (load, store, exchange, and
7209 compare_exchange) all have a generic version as well. This generic
7210 version works on any data type. If the data type size maps to one
7211 of the integral sizes that may have lock free support, the generic
7212 version utilizes the lock free built-in function. Otherwise an
7213 external call is left to be resolved at run time. This external call is
7214 the same format with the addition of a @samp{size_t} parameter inserted
7215 as the first parameter indicating the size of the object being pointed to.
7216 All objects must be the same size.
7217
7218 There are 6 different memory models that can be specified. These map
7219 to the same names in the C++11 standard. Refer there or to the
7220 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7221 atomic synchronization} for more detailed definitions. These memory
7222 models integrate both barriers to code motion as well as synchronization
7223 requirements with other threads. These are listed in approximately
7224 ascending order of strength. It is also possible to use target specific
7225 flags for memory model flags, like Hardware Lock Elision.
7226
7227 @table @code
7228 @item __ATOMIC_RELAXED
7229 No barriers or synchronization.
7230 @item __ATOMIC_CONSUME
7231 Data dependency only for both barrier and synchronization with another
7232 thread.
7233 @item __ATOMIC_ACQUIRE
7234 Barrier to hoisting of code and synchronizes with release (or stronger)
7235 semantic stores from another thread.
7236 @item __ATOMIC_RELEASE
7237 Barrier to sinking of code and synchronizes with acquire (or stronger)
7238 semantic loads from another thread.
7239 @item __ATOMIC_ACQ_REL
7240 Full barrier in both directions and synchronizes with acquire loads and
7241 release stores in another thread.
7242 @item __ATOMIC_SEQ_CST
7243 Full barrier in both directions and synchronizes with acquire loads and
7244 release stores in all threads.
7245 @end table
7246
7247 When implementing patterns for these built-in functions, the memory model
7248 parameter can be ignored as long as the pattern implements the most
7249 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
7250 execute correctly with this memory model but they may not execute as
7251 efficiently as they could with a more appropriate implemention of the
7252 relaxed requirements.
7253
7254 Note that the C++11 standard allows for the memory model parameter to be
7255 determined at run time rather than at compile time. These built-in
7256 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7257 than invoke a runtime library call or inline a switch statement. This is
7258 standard compliant, safe, and the simplest approach for now.
7259
7260 The memory model parameter is a signed int, but only the lower 8 bits are
7261 reserved for the memory model. The remainder of the signed int is reserved
7262 for future use and should be 0. Use of the predefined atomic values
7263 ensures proper usage.
7264
7265 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7266 This built-in function implements an atomic load operation. It returns the
7267 contents of @code{*@var{ptr}}.
7268
7269 The valid memory model variants are
7270 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7271 and @code{__ATOMIC_CONSUME}.
7272
7273 @end deftypefn
7274
7275 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7276 This is the generic version of an atomic load. It returns the
7277 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7278
7279 @end deftypefn
7280
7281 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7282 This built-in function implements an atomic store operation. It writes
7283 @code{@var{val}} into @code{*@var{ptr}}.
7284
7285 The valid memory model variants are
7286 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7287
7288 @end deftypefn
7289
7290 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7291 This is the generic version of an atomic store. It stores the value
7292 of @code{*@var{val}} into @code{*@var{ptr}}.
7293
7294 @end deftypefn
7295
7296 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7297 This built-in function implements an atomic exchange operation. It writes
7298 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7299 @code{*@var{ptr}}.
7300
7301 The valid memory model variants are
7302 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7303 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7304
7305 @end deftypefn
7306
7307 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7308 This is the generic version of an atomic exchange. It stores the
7309 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7310 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7311
7312 @end deftypefn
7313
7314 @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)
7315 This built-in function implements an atomic compare and exchange operation.
7316 This compares the contents of @code{*@var{ptr}} with the contents of
7317 @code{*@var{expected}} and if equal, writes @var{desired} into
7318 @code{*@var{ptr}}. If they are not equal, the current contents of
7319 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
7320 for weak compare_exchange, and false for the strong variation. Many targets
7321 only offer the strong variation and ignore the parameter. When in doubt, use
7322 the strong variation.
7323
7324 True is returned if @var{desired} is written into
7325 @code{*@var{ptr}} and the execution is considered to conform to the
7326 memory model specified by @var{success_memmodel}. There are no
7327 restrictions on what memory model can be used here.
7328
7329 False is returned otherwise, and the execution is considered to conform
7330 to @var{failure_memmodel}. This memory model cannot be
7331 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
7332 stronger model than that specified by @var{success_memmodel}.
7333
7334 @end deftypefn
7335
7336 @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)
7337 This built-in function implements the generic version of
7338 @code{__atomic_compare_exchange}. The function is virtually identical to
7339 @code{__atomic_compare_exchange_n}, except the desired value is also a
7340 pointer.
7341
7342 @end deftypefn
7343
7344 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7345 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7346 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7347 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7348 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7349 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7350 These built-in functions perform the operation suggested by the name, and
7351 return the result of the operation. That is,
7352
7353 @smallexample
7354 @{ *ptr @var{op}= val; return *ptr; @}
7355 @end smallexample
7356
7357 All memory models are valid.
7358
7359 @end deftypefn
7360
7361 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7362 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7363 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7364 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7365 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7366 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7367 These built-in functions perform the operation suggested by the name, and
7368 return the value that had previously been in @code{*@var{ptr}}. That is,
7369
7370 @smallexample
7371 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7372 @end smallexample
7373
7374 All memory models are valid.
7375
7376 @end deftypefn
7377
7378 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7379
7380 This built-in function performs an atomic test-and-set operation on
7381 the byte at @code{*@var{ptr}}. The byte is set to some implementation
7382 defined nonzero ``set'' value and the return value is @code{true} if and only
7383 if the previous contents were ``set''.
7384
7385 All memory models are valid.
7386
7387 @end deftypefn
7388
7389 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7390
7391 This built-in function performs an atomic clear operation on
7392 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
7393
7394 The valid memory model variants are
7395 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7396 @code{__ATOMIC_RELEASE}.
7397
7398 @end deftypefn
7399
7400 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7401
7402 This built-in function acts as a synchronization fence between threads
7403 based on the specified memory model.
7404
7405 All memory orders are valid.
7406
7407 @end deftypefn
7408
7409 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7410
7411 This built-in function acts as a synchronization fence between a thread
7412 and signal handlers based in the same thread.
7413
7414 All memory orders are valid.
7415
7416 @end deftypefn
7417
7418 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
7419
7420 This built-in function returns true if objects of @var{size} bytes always
7421 generate lock free atomic instructions for the target architecture.
7422 @var{size} must resolve to a compile-time constant and the result also
7423 resolves to a compile-time constant.
7424
7425 @var{ptr} is an optional pointer to the object that may be used to determine
7426 alignment. A value of 0 indicates typical alignment should be used. The
7427 compiler may also ignore this parameter.
7428
7429 @smallexample
7430 if (_atomic_always_lock_free (sizeof (long long), 0))
7431 @end smallexample
7432
7433 @end deftypefn
7434
7435 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7436
7437 This built-in function returns true if objects of @var{size} bytes always
7438 generate lock free atomic instructions for the target architecture. If
7439 it is not known to be lock free a call is made to a runtime routine named
7440 @code{__atomic_is_lock_free}.
7441
7442 @var{ptr} is an optional pointer to the object that may be used to determine
7443 alignment. A value of 0 indicates typical alignment should be used. The
7444 compiler may also ignore this parameter.
7445 @end deftypefn
7446
7447 @node Object Size Checking
7448 @section Object Size Checking Built-in Functions
7449 @findex __builtin_object_size
7450 @findex __builtin___memcpy_chk
7451 @findex __builtin___mempcpy_chk
7452 @findex __builtin___memmove_chk
7453 @findex __builtin___memset_chk
7454 @findex __builtin___strcpy_chk
7455 @findex __builtin___stpcpy_chk
7456 @findex __builtin___strncpy_chk
7457 @findex __builtin___strcat_chk
7458 @findex __builtin___strncat_chk
7459 @findex __builtin___sprintf_chk
7460 @findex __builtin___snprintf_chk
7461 @findex __builtin___vsprintf_chk
7462 @findex __builtin___vsnprintf_chk
7463 @findex __builtin___printf_chk
7464 @findex __builtin___vprintf_chk
7465 @findex __builtin___fprintf_chk
7466 @findex __builtin___vfprintf_chk
7467
7468 GCC implements a limited buffer overflow protection mechanism
7469 that can prevent some buffer overflow attacks.
7470
7471 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7472 is a built-in construct that returns a constant number of bytes from
7473 @var{ptr} to the end of the object @var{ptr} pointer points to
7474 (if known at compile time). @code{__builtin_object_size} never evaluates
7475 its arguments for side-effects. If there are any side-effects in them, it
7476 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7477 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
7478 point to and all of them are known at compile time, the returned number
7479 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7480 0 and minimum if nonzero. If it is not possible to determine which objects
7481 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7482 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7483 for @var{type} 2 or 3.
7484
7485 @var{type} is an integer constant from 0 to 3. If the least significant
7486 bit is clear, objects are whole variables, if it is set, a closest
7487 surrounding subobject is considered the object a pointer points to.
7488 The second bit determines if maximum or minimum of remaining bytes
7489 is computed.
7490
7491 @smallexample
7492 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7493 char *p = &var.buf1[1], *q = &var.b;
7494
7495 /* Here the object p points to is var. */
7496 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7497 /* The subobject p points to is var.buf1. */
7498 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7499 /* The object q points to is var. */
7500 assert (__builtin_object_size (q, 0)
7501 == (char *) (&var + 1) - (char *) &var.b);
7502 /* The subobject q points to is var.b. */
7503 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7504 @end smallexample
7505 @end deftypefn
7506
7507 There are built-in functions added for many common string operation
7508 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7509 built-in is provided. This built-in has an additional last argument,
7510 which is the number of bytes remaining in object the @var{dest}
7511 argument points to or @code{(size_t) -1} if the size is not known.
7512
7513 The built-in functions are optimized into the normal string functions
7514 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7515 it is known at compile time that the destination object will not
7516 be overflown. If the compiler can determine at compile time the
7517 object will be always overflown, it issues a warning.
7518
7519 The intended use can be e.g.@:
7520
7521 @smallexample
7522 #undef memcpy
7523 #define bos0(dest) __builtin_object_size (dest, 0)
7524 #define memcpy(dest, src, n) \
7525 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7526
7527 char *volatile p;
7528 char buf[10];
7529 /* It is unknown what object p points to, so this is optimized
7530 into plain memcpy - no checking is possible. */
7531 memcpy (p, "abcde", n);
7532 /* Destination is known and length too. It is known at compile
7533 time there will be no overflow. */
7534 memcpy (&buf[5], "abcde", 5);
7535 /* Destination is known, but the length is not known at compile time.
7536 This will result in __memcpy_chk call that can check for overflow
7537 at run time. */
7538 memcpy (&buf[5], "abcde", n);
7539 /* Destination is known and it is known at compile time there will
7540 be overflow. There will be a warning and __memcpy_chk call that
7541 will abort the program at run time. */
7542 memcpy (&buf[6], "abcde", 5);
7543 @end smallexample
7544
7545 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7546 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7547 @code{strcat} and @code{strncat}.
7548
7549 There are also checking built-in functions for formatted output functions.
7550 @smallexample
7551 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7552 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7553 const char *fmt, ...);
7554 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7555 va_list ap);
7556 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7557 const char *fmt, va_list ap);
7558 @end smallexample
7559
7560 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7561 etc.@: functions and can contain implementation specific flags on what
7562 additional security measures the checking function might take, such as
7563 handling @code{%n} differently.
7564
7565 The @var{os} argument is the object size @var{s} points to, like in the
7566 other built-in functions. There is a small difference in the behavior
7567 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7568 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7569 the checking function is called with @var{os} argument set to
7570 @code{(size_t) -1}.
7571
7572 In addition to this, there are checking built-in functions
7573 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7574 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7575 These have just one additional argument, @var{flag}, right before
7576 format string @var{fmt}. If the compiler is able to optimize them to
7577 @code{fputc} etc.@: functions, it does, otherwise the checking function
7578 is called and the @var{flag} argument passed to it.
7579
7580 @node Other Builtins
7581 @section Other Built-in Functions Provided by GCC
7582 @cindex built-in functions
7583 @findex __builtin_fpclassify
7584 @findex __builtin_isfinite
7585 @findex __builtin_isnormal
7586 @findex __builtin_isgreater
7587 @findex __builtin_isgreaterequal
7588 @findex __builtin_isinf_sign
7589 @findex __builtin_isless
7590 @findex __builtin_islessequal
7591 @findex __builtin_islessgreater
7592 @findex __builtin_isunordered
7593 @findex __builtin_powi
7594 @findex __builtin_powif
7595 @findex __builtin_powil
7596 @findex _Exit
7597 @findex _exit
7598 @findex abort
7599 @findex abs
7600 @findex acos
7601 @findex acosf
7602 @findex acosh
7603 @findex acoshf
7604 @findex acoshl
7605 @findex acosl
7606 @findex alloca
7607 @findex asin
7608 @findex asinf
7609 @findex asinh
7610 @findex asinhf
7611 @findex asinhl
7612 @findex asinl
7613 @findex atan
7614 @findex atan2
7615 @findex atan2f
7616 @findex atan2l
7617 @findex atanf
7618 @findex atanh
7619 @findex atanhf
7620 @findex atanhl
7621 @findex atanl
7622 @findex bcmp
7623 @findex bzero
7624 @findex cabs
7625 @findex cabsf
7626 @findex cabsl
7627 @findex cacos
7628 @findex cacosf
7629 @findex cacosh
7630 @findex cacoshf
7631 @findex cacoshl
7632 @findex cacosl
7633 @findex calloc
7634 @findex carg
7635 @findex cargf
7636 @findex cargl
7637 @findex casin
7638 @findex casinf
7639 @findex casinh
7640 @findex casinhf
7641 @findex casinhl
7642 @findex casinl
7643 @findex catan
7644 @findex catanf
7645 @findex catanh
7646 @findex catanhf
7647 @findex catanhl
7648 @findex catanl
7649 @findex cbrt
7650 @findex cbrtf
7651 @findex cbrtl
7652 @findex ccos
7653 @findex ccosf
7654 @findex ccosh
7655 @findex ccoshf
7656 @findex ccoshl
7657 @findex ccosl
7658 @findex ceil
7659 @findex ceilf
7660 @findex ceill
7661 @findex cexp
7662 @findex cexpf
7663 @findex cexpl
7664 @findex cimag
7665 @findex cimagf
7666 @findex cimagl
7667 @findex clog
7668 @findex clogf
7669 @findex clogl
7670 @findex conj
7671 @findex conjf
7672 @findex conjl
7673 @findex copysign
7674 @findex copysignf
7675 @findex copysignl
7676 @findex cos
7677 @findex cosf
7678 @findex cosh
7679 @findex coshf
7680 @findex coshl
7681 @findex cosl
7682 @findex cpow
7683 @findex cpowf
7684 @findex cpowl
7685 @findex cproj
7686 @findex cprojf
7687 @findex cprojl
7688 @findex creal
7689 @findex crealf
7690 @findex creall
7691 @findex csin
7692 @findex csinf
7693 @findex csinh
7694 @findex csinhf
7695 @findex csinhl
7696 @findex csinl
7697 @findex csqrt
7698 @findex csqrtf
7699 @findex csqrtl
7700 @findex ctan
7701 @findex ctanf
7702 @findex ctanh
7703 @findex ctanhf
7704 @findex ctanhl
7705 @findex ctanl
7706 @findex dcgettext
7707 @findex dgettext
7708 @findex drem
7709 @findex dremf
7710 @findex dreml
7711 @findex erf
7712 @findex erfc
7713 @findex erfcf
7714 @findex erfcl
7715 @findex erff
7716 @findex erfl
7717 @findex exit
7718 @findex exp
7719 @findex exp10
7720 @findex exp10f
7721 @findex exp10l
7722 @findex exp2
7723 @findex exp2f
7724 @findex exp2l
7725 @findex expf
7726 @findex expl
7727 @findex expm1
7728 @findex expm1f
7729 @findex expm1l
7730 @findex fabs
7731 @findex fabsf
7732 @findex fabsl
7733 @findex fdim
7734 @findex fdimf
7735 @findex fdiml
7736 @findex ffs
7737 @findex floor
7738 @findex floorf
7739 @findex floorl
7740 @findex fma
7741 @findex fmaf
7742 @findex fmal
7743 @findex fmax
7744 @findex fmaxf
7745 @findex fmaxl
7746 @findex fmin
7747 @findex fminf
7748 @findex fminl
7749 @findex fmod
7750 @findex fmodf
7751 @findex fmodl
7752 @findex fprintf
7753 @findex fprintf_unlocked
7754 @findex fputs
7755 @findex fputs_unlocked
7756 @findex frexp
7757 @findex frexpf
7758 @findex frexpl
7759 @findex fscanf
7760 @findex gamma
7761 @findex gammaf
7762 @findex gammal
7763 @findex gamma_r
7764 @findex gammaf_r
7765 @findex gammal_r
7766 @findex gettext
7767 @findex hypot
7768 @findex hypotf
7769 @findex hypotl
7770 @findex ilogb
7771 @findex ilogbf
7772 @findex ilogbl
7773 @findex imaxabs
7774 @findex index
7775 @findex isalnum
7776 @findex isalpha
7777 @findex isascii
7778 @findex isblank
7779 @findex iscntrl
7780 @findex isdigit
7781 @findex isgraph
7782 @findex islower
7783 @findex isprint
7784 @findex ispunct
7785 @findex isspace
7786 @findex isupper
7787 @findex iswalnum
7788 @findex iswalpha
7789 @findex iswblank
7790 @findex iswcntrl
7791 @findex iswdigit
7792 @findex iswgraph
7793 @findex iswlower
7794 @findex iswprint
7795 @findex iswpunct
7796 @findex iswspace
7797 @findex iswupper
7798 @findex iswxdigit
7799 @findex isxdigit
7800 @findex j0
7801 @findex j0f
7802 @findex j0l
7803 @findex j1
7804 @findex j1f
7805 @findex j1l
7806 @findex jn
7807 @findex jnf
7808 @findex jnl
7809 @findex labs
7810 @findex ldexp
7811 @findex ldexpf
7812 @findex ldexpl
7813 @findex lgamma
7814 @findex lgammaf
7815 @findex lgammal
7816 @findex lgamma_r
7817 @findex lgammaf_r
7818 @findex lgammal_r
7819 @findex llabs
7820 @findex llrint
7821 @findex llrintf
7822 @findex llrintl
7823 @findex llround
7824 @findex llroundf
7825 @findex llroundl
7826 @findex log
7827 @findex log10
7828 @findex log10f
7829 @findex log10l
7830 @findex log1p
7831 @findex log1pf
7832 @findex log1pl
7833 @findex log2
7834 @findex log2f
7835 @findex log2l
7836 @findex logb
7837 @findex logbf
7838 @findex logbl
7839 @findex logf
7840 @findex logl
7841 @findex lrint
7842 @findex lrintf
7843 @findex lrintl
7844 @findex lround
7845 @findex lroundf
7846 @findex lroundl
7847 @findex malloc
7848 @findex memchr
7849 @findex memcmp
7850 @findex memcpy
7851 @findex mempcpy
7852 @findex memset
7853 @findex modf
7854 @findex modff
7855 @findex modfl
7856 @findex nearbyint
7857 @findex nearbyintf
7858 @findex nearbyintl
7859 @findex nextafter
7860 @findex nextafterf
7861 @findex nextafterl
7862 @findex nexttoward
7863 @findex nexttowardf
7864 @findex nexttowardl
7865 @findex pow
7866 @findex pow10
7867 @findex pow10f
7868 @findex pow10l
7869 @findex powf
7870 @findex powl
7871 @findex printf
7872 @findex printf_unlocked
7873 @findex putchar
7874 @findex puts
7875 @findex remainder
7876 @findex remainderf
7877 @findex remainderl
7878 @findex remquo
7879 @findex remquof
7880 @findex remquol
7881 @findex rindex
7882 @findex rint
7883 @findex rintf
7884 @findex rintl
7885 @findex round
7886 @findex roundf
7887 @findex roundl
7888 @findex scalb
7889 @findex scalbf
7890 @findex scalbl
7891 @findex scalbln
7892 @findex scalblnf
7893 @findex scalblnf
7894 @findex scalbn
7895 @findex scalbnf
7896 @findex scanfnl
7897 @findex signbit
7898 @findex signbitf
7899 @findex signbitl
7900 @findex signbitd32
7901 @findex signbitd64
7902 @findex signbitd128
7903 @findex significand
7904 @findex significandf
7905 @findex significandl
7906 @findex sin
7907 @findex sincos
7908 @findex sincosf
7909 @findex sincosl
7910 @findex sinf
7911 @findex sinh
7912 @findex sinhf
7913 @findex sinhl
7914 @findex sinl
7915 @findex snprintf
7916 @findex sprintf
7917 @findex sqrt
7918 @findex sqrtf
7919 @findex sqrtl
7920 @findex sscanf
7921 @findex stpcpy
7922 @findex stpncpy
7923 @findex strcasecmp
7924 @findex strcat
7925 @findex strchr
7926 @findex strcmp
7927 @findex strcpy
7928 @findex strcspn
7929 @findex strdup
7930 @findex strfmon
7931 @findex strftime
7932 @findex strlen
7933 @findex strncasecmp
7934 @findex strncat
7935 @findex strncmp
7936 @findex strncpy
7937 @findex strndup
7938 @findex strpbrk
7939 @findex strrchr
7940 @findex strspn
7941 @findex strstr
7942 @findex tan
7943 @findex tanf
7944 @findex tanh
7945 @findex tanhf
7946 @findex tanhl
7947 @findex tanl
7948 @findex tgamma
7949 @findex tgammaf
7950 @findex tgammal
7951 @findex toascii
7952 @findex tolower
7953 @findex toupper
7954 @findex towlower
7955 @findex towupper
7956 @findex trunc
7957 @findex truncf
7958 @findex truncl
7959 @findex vfprintf
7960 @findex vfscanf
7961 @findex vprintf
7962 @findex vscanf
7963 @findex vsnprintf
7964 @findex vsprintf
7965 @findex vsscanf
7966 @findex y0
7967 @findex y0f
7968 @findex y0l
7969 @findex y1
7970 @findex y1f
7971 @findex y1l
7972 @findex yn
7973 @findex ynf
7974 @findex ynl
7975
7976 GCC provides a large number of built-in functions other than the ones
7977 mentioned above. Some of these are for internal use in the processing
7978 of exceptions or variable-length argument lists and are not
7979 documented here because they may change from time to time; we do not
7980 recommend general use of these functions.
7981
7982 The remaining functions are provided for optimization purposes.
7983
7984 @opindex fno-builtin
7985 GCC includes built-in versions of many of the functions in the standard
7986 C library. The versions prefixed with @code{__builtin_} are always
7987 treated as having the same meaning as the C library function even if you
7988 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
7989 Many of these functions are only optimized in certain cases; if they are
7990 not optimized in a particular case, a call to the library function is
7991 emitted.
7992
7993 @opindex ansi
7994 @opindex std
7995 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
7996 @option{-std=c99} or @option{-std=c11}), the functions
7997 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
7998 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
7999 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8000 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8001 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8002 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8003 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8004 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8005 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8006 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8007 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8008 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8009 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8010 @code{significandl}, @code{significand}, @code{sincosf},
8011 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8012 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8013 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8014 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8015 @code{yn}
8016 may be handled as built-in functions.
8017 All these functions have corresponding versions
8018 prefixed with @code{__builtin_}, which may be used even in strict C90
8019 mode.
8020
8021 The ISO C99 functions
8022 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8023 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8024 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8025 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8026 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8027 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8028 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8029 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8030 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8031 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8032 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8033 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8034 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8035 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8036 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8037 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8038 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8039 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8040 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8041 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8042 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8043 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8044 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8045 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8046 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8047 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8048 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8049 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8050 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8051 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8052 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8053 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8054 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8055 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8056 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8057 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8058 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8059 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8060 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8061 are handled as built-in functions
8062 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8063
8064 There are also built-in versions of the ISO C99 functions
8065 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8066 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8067 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8068 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8069 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8070 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8071 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8072 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8073 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8074 that are recognized in any mode since ISO C90 reserves these names for
8075 the purpose to which ISO C99 puts them. All these functions have
8076 corresponding versions prefixed with @code{__builtin_}.
8077
8078 The ISO C94 functions
8079 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8080 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8081 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8082 @code{towupper}
8083 are handled as built-in functions
8084 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8085
8086 The ISO C90 functions
8087 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8088 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8089 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8090 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8091 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8092 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8093 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8094 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8095 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8096 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8097 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8098 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8099 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8100 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8101 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8102 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8103 are all recognized as built-in functions unless
8104 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8105 is specified for an individual function). All of these functions have
8106 corresponding versions prefixed with @code{__builtin_}.
8107
8108 GCC provides built-in versions of the ISO C99 floating-point comparison
8109 macros that avoid raising exceptions for unordered operands. They have
8110 the same names as the standard macros ( @code{isgreater},
8111 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8112 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8113 prefixed. We intend for a library implementor to be able to simply
8114 @code{#define} each standard macro to its built-in equivalent.
8115 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8116 @code{isinf_sign} and @code{isnormal} built-ins used with
8117 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
8118 built-in functions appear both with and without the @code{__builtin_} prefix.
8119
8120 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8121
8122 You can use the built-in function @code{__builtin_types_compatible_p} to
8123 determine whether two types are the same.
8124
8125 This built-in function returns 1 if the unqualified versions of the
8126 types @var{type1} and @var{type2} (which are types, not expressions) are
8127 compatible, 0 otherwise. The result of this built-in function can be
8128 used in integer constant expressions.
8129
8130 This built-in function ignores top level qualifiers (e.g., @code{const},
8131 @code{volatile}). For example, @code{int} is equivalent to @code{const
8132 int}.
8133
8134 The type @code{int[]} and @code{int[5]} are compatible. On the other
8135 hand, @code{int} and @code{char *} are not compatible, even if the size
8136 of their types, on the particular architecture are the same. Also, the
8137 amount of pointer indirection is taken into account when determining
8138 similarity. Consequently, @code{short *} is not similar to
8139 @code{short **}. Furthermore, two types that are typedefed are
8140 considered compatible if their underlying types are compatible.
8141
8142 An @code{enum} type is not considered to be compatible with another
8143 @code{enum} type even if both are compatible with the same integer
8144 type; this is what the C standard specifies.
8145 For example, @code{enum @{foo, bar@}} is not similar to
8146 @code{enum @{hot, dog@}}.
8147
8148 You typically use this function in code whose execution varies
8149 depending on the arguments' types. For example:
8150
8151 @smallexample
8152 #define foo(x) \
8153 (@{ \
8154 typeof (x) tmp = (x); \
8155 if (__builtin_types_compatible_p (typeof (x), long double)) \
8156 tmp = foo_long_double (tmp); \
8157 else if (__builtin_types_compatible_p (typeof (x), double)) \
8158 tmp = foo_double (tmp); \
8159 else if (__builtin_types_compatible_p (typeof (x), float)) \
8160 tmp = foo_float (tmp); \
8161 else \
8162 abort (); \
8163 tmp; \
8164 @})
8165 @end smallexample
8166
8167 @emph{Note:} This construct is only available for C@.
8168
8169 @end deftypefn
8170
8171 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8172
8173 You can use the built-in function @code{__builtin_choose_expr} to
8174 evaluate code depending on the value of a constant expression. This
8175 built-in function returns @var{exp1} if @var{const_exp}, which is an
8176 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
8177
8178 This built-in function is analogous to the @samp{? :} operator in C,
8179 except that the expression returned has its type unaltered by promotion
8180 rules. Also, the built-in function does not evaluate the expression
8181 that is not chosen. For example, if @var{const_exp} evaluates to true,
8182 @var{exp2} is not evaluated even if it has side-effects.
8183
8184 This built-in function can return an lvalue if the chosen argument is an
8185 lvalue.
8186
8187 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8188 type. Similarly, if @var{exp2} is returned, its return type is the same
8189 as @var{exp2}.
8190
8191 Example:
8192
8193 @smallexample
8194 #define foo(x) \
8195 __builtin_choose_expr ( \
8196 __builtin_types_compatible_p (typeof (x), double), \
8197 foo_double (x), \
8198 __builtin_choose_expr ( \
8199 __builtin_types_compatible_p (typeof (x), float), \
8200 foo_float (x), \
8201 /* @r{The void expression results in a compile-time error} \
8202 @r{when assigning the result to something.} */ \
8203 (void)0))
8204 @end smallexample
8205
8206 @emph{Note:} This construct is only available for C@. Furthermore, the
8207 unused expression (@var{exp1} or @var{exp2} depending on the value of
8208 @var{const_exp}) may still generate syntax errors. This may change in
8209 future revisions.
8210
8211 @end deftypefn
8212
8213 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8214
8215 The built-in function @code{__builtin_complex} is provided for use in
8216 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8217 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
8218 real binary floating-point type, and the result has the corresponding
8219 complex type with real and imaginary parts @var{real} and @var{imag}.
8220 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8221 infinities, NaNs and negative zeros are involved.
8222
8223 @end deftypefn
8224
8225 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8226 You can use the built-in function @code{__builtin_constant_p} to
8227 determine if a value is known to be constant at compile time and hence
8228 that GCC can perform constant-folding on expressions involving that
8229 value. The argument of the function is the value to test. The function
8230 returns the integer 1 if the argument is known to be a compile-time
8231 constant and 0 if it is not known to be a compile-time constant. A
8232 return of 0 does not indicate that the value is @emph{not} a constant,
8233 but merely that GCC cannot prove it is a constant with the specified
8234 value of the @option{-O} option.
8235
8236 You typically use this function in an embedded application where
8237 memory is a critical resource. If you have some complex calculation,
8238 you may want it to be folded if it involves constants, but need to call
8239 a function if it does not. For example:
8240
8241 @smallexample
8242 #define Scale_Value(X) \
8243 (__builtin_constant_p (X) \
8244 ? ((X) * SCALE + OFFSET) : Scale (X))
8245 @end smallexample
8246
8247 You may use this built-in function in either a macro or an inline
8248 function. However, if you use it in an inlined function and pass an
8249 argument of the function as the argument to the built-in, GCC
8250 never returns 1 when you call the inline function with a string constant
8251 or compound literal (@pxref{Compound Literals}) and does not return 1
8252 when you pass a constant numeric value to the inline function unless you
8253 specify the @option{-O} option.
8254
8255 You may also use @code{__builtin_constant_p} in initializers for static
8256 data. For instance, you can write
8257
8258 @smallexample
8259 static const int table[] = @{
8260 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8261 /* @r{@dots{}} */
8262 @};
8263 @end smallexample
8264
8265 @noindent
8266 This is an acceptable initializer even if @var{EXPRESSION} is not a
8267 constant expression, including the case where
8268 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8269 folded to a constant but @var{EXPRESSION} contains operands that are
8270 not otherwise permitted in a static initializer (for example,
8271 @code{0 && foo ()}). GCC must be more conservative about evaluating the
8272 built-in in this case, because it has no opportunity to perform
8273 optimization.
8274
8275 Previous versions of GCC did not accept this built-in in data
8276 initializers. The earliest version where it is completely safe is
8277 3.0.1.
8278 @end deftypefn
8279
8280 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8281 @opindex fprofile-arcs
8282 You may use @code{__builtin_expect} to provide the compiler with
8283 branch prediction information. In general, you should prefer to
8284 use actual profile feedback for this (@option{-fprofile-arcs}), as
8285 programmers are notoriously bad at predicting how their programs
8286 actually perform. However, there are applications in which this
8287 data is hard to collect.
8288
8289 The return value is the value of @var{exp}, which should be an integral
8290 expression. The semantics of the built-in are that it is expected that
8291 @var{exp} == @var{c}. For example:
8292
8293 @smallexample
8294 if (__builtin_expect (x, 0))
8295 foo ();
8296 @end smallexample
8297
8298 @noindent
8299 indicates that we do not expect to call @code{foo}, since
8300 we expect @code{x} to be zero. Since you are limited to integral
8301 expressions for @var{exp}, you should use constructions such as
8302
8303 @smallexample
8304 if (__builtin_expect (ptr != NULL, 1))
8305 foo (*ptr);
8306 @end smallexample
8307
8308 @noindent
8309 when testing pointer or floating-point values.
8310 @end deftypefn
8311
8312 @deftypefn {Built-in Function} void __builtin_trap (void)
8313 This function causes the program to exit abnormally. GCC implements
8314 this function by using a target-dependent mechanism (such as
8315 intentionally executing an illegal instruction) or by calling
8316 @code{abort}. The mechanism used may vary from release to release so
8317 you should not rely on any particular implementation.
8318 @end deftypefn
8319
8320 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8321 If control flow reaches the point of the @code{__builtin_unreachable},
8322 the program is undefined. It is useful in situations where the
8323 compiler cannot deduce the unreachability of the code.
8324
8325 One such case is immediately following an @code{asm} statement that
8326 either never terminates, or one that transfers control elsewhere
8327 and never returns. In this example, without the
8328 @code{__builtin_unreachable}, GCC issues a warning that control
8329 reaches the end of a non-void function. It also generates code
8330 to return after the @code{asm}.
8331
8332 @smallexample
8333 int f (int c, int v)
8334 @{
8335 if (c)
8336 @{
8337 return v;
8338 @}
8339 else
8340 @{
8341 asm("jmp error_handler");
8342 __builtin_unreachable ();
8343 @}
8344 @}
8345 @end smallexample
8346
8347 @noindent
8348 Because the @code{asm} statement unconditionally transfers control out
8349 of the function, control never reaches the end of the function
8350 body. The @code{__builtin_unreachable} is in fact unreachable and
8351 communicates this fact to the compiler.
8352
8353 Another use for @code{__builtin_unreachable} is following a call a
8354 function that never returns but that is not declared
8355 @code{__attribute__((noreturn))}, as in this example:
8356
8357 @smallexample
8358 void function_that_never_returns (void);
8359
8360 int g (int c)
8361 @{
8362 if (c)
8363 @{
8364 return 1;
8365 @}
8366 else
8367 @{
8368 function_that_never_returns ();
8369 __builtin_unreachable ();
8370 @}
8371 @}
8372 @end smallexample
8373
8374 @end deftypefn
8375
8376 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8377 This function returns its first argument, and allows the compiler
8378 to assume that the returned pointer is at least @var{align} bytes
8379 aligned. This built-in can have either two or three arguments,
8380 if it has three, the third argument should have integer type, and
8381 if it is nonzero means misalignment offset. For example:
8382
8383 @smallexample
8384 void *x = __builtin_assume_aligned (arg, 16);
8385 @end smallexample
8386
8387 @noindent
8388 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8389 16-byte aligned, while:
8390
8391 @smallexample
8392 void *x = __builtin_assume_aligned (arg, 32, 8);
8393 @end smallexample
8394
8395 @noindent
8396 means that the compiler can assume for @code{x}, set to @code{arg}, that
8397 @code{(char *) x - 8} is 32-byte aligned.
8398 @end deftypefn
8399
8400 @deftypefn {Built-in Function} int __builtin_LINE ()
8401 This function is the equivalent to the preprocessor @code{__LINE__}
8402 macro and returns the line number of the invocation of the built-in.
8403 @end deftypefn
8404
8405 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8406 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8407 macro and returns the function name the invocation of the built-in is in.
8408 @end deftypefn
8409
8410 @deftypefn {Built-in Function} int __builtin_FILE ()
8411 This function is the equivalent to the preprocessor @code{__FILE__}
8412 macro and returns the file name the invocation of the built-in is in.
8413 @end deftypefn
8414
8415 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8416 This function is used to flush the processor's instruction cache for
8417 the region of memory between @var{begin} inclusive and @var{end}
8418 exclusive. Some targets require that the instruction cache be
8419 flushed, after modifying memory containing code, in order to obtain
8420 deterministic behavior.
8421
8422 If the target does not require instruction cache flushes,
8423 @code{__builtin___clear_cache} has no effect. Otherwise either
8424 instructions are emitted in-line to clear the instruction cache or a
8425 call to the @code{__clear_cache} function in libgcc is made.
8426 @end deftypefn
8427
8428 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8429 This function is used to minimize cache-miss latency by moving data into
8430 a cache before it is accessed.
8431 You can insert calls to @code{__builtin_prefetch} into code for which
8432 you know addresses of data in memory that is likely to be accessed soon.
8433 If the target supports them, data prefetch instructions are generated.
8434 If the prefetch is done early enough before the access then the data will
8435 be in the cache by the time it is accessed.
8436
8437 The value of @var{addr} is the address of the memory to prefetch.
8438 There are two optional arguments, @var{rw} and @var{locality}.
8439 The value of @var{rw} is a compile-time constant one or zero; one
8440 means that the prefetch is preparing for a write to the memory address
8441 and zero, the default, means that the prefetch is preparing for a read.
8442 The value @var{locality} must be a compile-time constant integer between
8443 zero and three. A value of zero means that the data has no temporal
8444 locality, so it need not be left in the cache after the access. A value
8445 of three means that the data has a high degree of temporal locality and
8446 should be left in all levels of cache possible. Values of one and two
8447 mean, respectively, a low or moderate degree of temporal locality. The
8448 default is three.
8449
8450 @smallexample
8451 for (i = 0; i < n; i++)
8452 @{
8453 a[i] = a[i] + b[i];
8454 __builtin_prefetch (&a[i+j], 1, 1);
8455 __builtin_prefetch (&b[i+j], 0, 1);
8456 /* @r{@dots{}} */
8457 @}
8458 @end smallexample
8459
8460 Data prefetch does not generate faults if @var{addr} is invalid, but
8461 the address expression itself must be valid. For example, a prefetch
8462 of @code{p->next} does not fault if @code{p->next} is not a valid
8463 address, but evaluation faults if @code{p} is not a valid address.
8464
8465 If the target does not support data prefetch, the address expression
8466 is evaluated if it includes side effects but no other code is generated
8467 and GCC does not issue a warning.
8468 @end deftypefn
8469
8470 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8471 Returns a positive infinity, if supported by the floating-point format,
8472 else @code{DBL_MAX}. This function is suitable for implementing the
8473 ISO C macro @code{HUGE_VAL}.
8474 @end deftypefn
8475
8476 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8477 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8478 @end deftypefn
8479
8480 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8481 Similar to @code{__builtin_huge_val}, except the return
8482 type is @code{long double}.
8483 @end deftypefn
8484
8485 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8486 This built-in implements the C99 fpclassify functionality. The first
8487 five int arguments should be the target library's notion of the
8488 possible FP classes and are used for return values. They must be
8489 constant values and they must appear in this order: @code{FP_NAN},
8490 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8491 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
8492 to classify. GCC treats the last argument as type-generic, which
8493 means it does not do default promotion from float to double.
8494 @end deftypefn
8495
8496 @deftypefn {Built-in Function} double __builtin_inf (void)
8497 Similar to @code{__builtin_huge_val}, except a warning is generated
8498 if the target floating-point format does not support infinities.
8499 @end deftypefn
8500
8501 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8502 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8503 @end deftypefn
8504
8505 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8506 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8507 @end deftypefn
8508
8509 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8510 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8511 @end deftypefn
8512
8513 @deftypefn {Built-in Function} float __builtin_inff (void)
8514 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8515 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8516 @end deftypefn
8517
8518 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8519 Similar to @code{__builtin_inf}, except the return
8520 type is @code{long double}.
8521 @end deftypefn
8522
8523 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8524 Similar to @code{isinf}, except the return value is negative for
8525 an argument of @code{-Inf}. Note while the parameter list is an
8526 ellipsis, this function only accepts exactly one floating-point
8527 argument. GCC treats this parameter as type-generic, which means it
8528 does not do default promotion from float to double.
8529 @end deftypefn
8530
8531 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8532 This is an implementation of the ISO C99 function @code{nan}.
8533
8534 Since ISO C99 defines this function in terms of @code{strtod}, which we
8535 do not implement, a description of the parsing is in order. The string
8536 is parsed as by @code{strtol}; that is, the base is recognized by
8537 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
8538 in the significand such that the least significant bit of the number
8539 is at the least significant bit of the significand. The number is
8540 truncated to fit the significand field provided. The significand is
8541 forced to be a quiet NaN@.
8542
8543 This function, if given a string literal all of which would have been
8544 consumed by strtol, is evaluated early enough that it is considered a
8545 compile-time constant.
8546 @end deftypefn
8547
8548 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8549 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8550 @end deftypefn
8551
8552 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8553 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8554 @end deftypefn
8555
8556 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8557 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8558 @end deftypefn
8559
8560 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8561 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8562 @end deftypefn
8563
8564 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8565 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8566 @end deftypefn
8567
8568 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8569 Similar to @code{__builtin_nan}, except the significand is forced
8570 to be a signaling NaN@. The @code{nans} function is proposed by
8571 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8572 @end deftypefn
8573
8574 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8575 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8576 @end deftypefn
8577
8578 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8579 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8580 @end deftypefn
8581
8582 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8583 Returns one plus the index of the least significant 1-bit of @var{x}, or
8584 if @var{x} is zero, returns zero.
8585 @end deftypefn
8586
8587 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8588 Returns the number of leading 0-bits in @var{x}, starting at the most
8589 significant bit position. If @var{x} is 0, the result is undefined.
8590 @end deftypefn
8591
8592 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8593 Returns the number of trailing 0-bits in @var{x}, starting at the least
8594 significant bit position. If @var{x} is 0, the result is undefined.
8595 @end deftypefn
8596
8597 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8598 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
8599 number of bits following the most significant bit that are identical
8600 to it. There are no special cases for 0 or other values.
8601 @end deftypefn
8602
8603 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8604 Returns the number of 1-bits in @var{x}.
8605 @end deftypefn
8606
8607 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8608 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8609 modulo 2.
8610 @end deftypefn
8611
8612 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8613 Similar to @code{__builtin_ffs}, except the argument type is
8614 @code{unsigned long}.
8615 @end deftypefn
8616
8617 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8618 Similar to @code{__builtin_clz}, except the argument type is
8619 @code{unsigned long}.
8620 @end deftypefn
8621
8622 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8623 Similar to @code{__builtin_ctz}, except the argument type is
8624 @code{unsigned long}.
8625 @end deftypefn
8626
8627 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8628 Similar to @code{__builtin_clrsb}, except the argument type is
8629 @code{long}.
8630 @end deftypefn
8631
8632 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8633 Similar to @code{__builtin_popcount}, except the argument type is
8634 @code{unsigned long}.
8635 @end deftypefn
8636
8637 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8638 Similar to @code{__builtin_parity}, except the argument type is
8639 @code{unsigned long}.
8640 @end deftypefn
8641
8642 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8643 Similar to @code{__builtin_ffs}, except the argument type is
8644 @code{unsigned long long}.
8645 @end deftypefn
8646
8647 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8648 Similar to @code{__builtin_clz}, except the argument type is
8649 @code{unsigned long long}.
8650 @end deftypefn
8651
8652 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8653 Similar to @code{__builtin_ctz}, except the argument type is
8654 @code{unsigned long long}.
8655 @end deftypefn
8656
8657 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8658 Similar to @code{__builtin_clrsb}, except the argument type is
8659 @code{long long}.
8660 @end deftypefn
8661
8662 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8663 Similar to @code{__builtin_popcount}, except the argument type is
8664 @code{unsigned long long}.
8665 @end deftypefn
8666
8667 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8668 Similar to @code{__builtin_parity}, except the argument type is
8669 @code{unsigned long long}.
8670 @end deftypefn
8671
8672 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8673 Returns the first argument raised to the power of the second. Unlike the
8674 @code{pow} function no guarantees about precision and rounding are made.
8675 @end deftypefn
8676
8677 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8678 Similar to @code{__builtin_powi}, except the argument and return types
8679 are @code{float}.
8680 @end deftypefn
8681
8682 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8683 Similar to @code{__builtin_powi}, except the argument and return types
8684 are @code{long double}.
8685 @end deftypefn
8686
8687 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8688 Returns @var{x} with the order of the bytes reversed; for example,
8689 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
8690 exactly 8 bits.
8691 @end deftypefn
8692
8693 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8694 Similar to @code{__builtin_bswap16}, except the argument and return types
8695 are 32 bit.
8696 @end deftypefn
8697
8698 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
8699 Similar to @code{__builtin_bswap32}, except the argument and return types
8700 are 64 bit.
8701 @end deftypefn
8702
8703 @node Target Builtins
8704 @section Built-in Functions Specific to Particular Target Machines
8705
8706 On some target machines, GCC supports many built-in functions specific
8707 to those machines. Generally these generate calls to specific machine
8708 instructions, but allow the compiler to schedule those calls.
8709
8710 @menu
8711 * Alpha Built-in Functions::
8712 * ARM iWMMXt Built-in Functions::
8713 * ARM NEON Intrinsics::
8714 * AVR Built-in Functions::
8715 * Blackfin Built-in Functions::
8716 * FR-V Built-in Functions::
8717 * X86 Built-in Functions::
8718 * MIPS DSP Built-in Functions::
8719 * MIPS Paired-Single Support::
8720 * MIPS Loongson Built-in Functions::
8721 * Other MIPS Built-in Functions::
8722 * picoChip Built-in Functions::
8723 * PowerPC Built-in Functions::
8724 * PowerPC AltiVec/VSX Built-in Functions::
8725 * RX Built-in Functions::
8726 * SH Built-in Functions::
8727 * SPARC VIS Built-in Functions::
8728 * SPU Built-in Functions::
8729 * TI C6X Built-in Functions::
8730 * TILE-Gx Built-in Functions::
8731 * TILEPro Built-in Functions::
8732 @end menu
8733
8734 @node Alpha Built-in Functions
8735 @subsection Alpha Built-in Functions
8736
8737 These built-in functions are available for the Alpha family of
8738 processors, depending on the command-line switches used.
8739
8740 The following built-in functions are always available. They
8741 all generate the machine instruction that is part of the name.
8742
8743 @smallexample
8744 long __builtin_alpha_implver (void)
8745 long __builtin_alpha_rpcc (void)
8746 long __builtin_alpha_amask (long)
8747 long __builtin_alpha_cmpbge (long, long)
8748 long __builtin_alpha_extbl (long, long)
8749 long __builtin_alpha_extwl (long, long)
8750 long __builtin_alpha_extll (long, long)
8751 long __builtin_alpha_extql (long, long)
8752 long __builtin_alpha_extwh (long, long)
8753 long __builtin_alpha_extlh (long, long)
8754 long __builtin_alpha_extqh (long, long)
8755 long __builtin_alpha_insbl (long, long)
8756 long __builtin_alpha_inswl (long, long)
8757 long __builtin_alpha_insll (long, long)
8758 long __builtin_alpha_insql (long, long)
8759 long __builtin_alpha_inswh (long, long)
8760 long __builtin_alpha_inslh (long, long)
8761 long __builtin_alpha_insqh (long, long)
8762 long __builtin_alpha_mskbl (long, long)
8763 long __builtin_alpha_mskwl (long, long)
8764 long __builtin_alpha_mskll (long, long)
8765 long __builtin_alpha_mskql (long, long)
8766 long __builtin_alpha_mskwh (long, long)
8767 long __builtin_alpha_msklh (long, long)
8768 long __builtin_alpha_mskqh (long, long)
8769 long __builtin_alpha_umulh (long, long)
8770 long __builtin_alpha_zap (long, long)
8771 long __builtin_alpha_zapnot (long, long)
8772 @end smallexample
8773
8774 The following built-in functions are always with @option{-mmax}
8775 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
8776 later. They all generate the machine instruction that is part
8777 of the name.
8778
8779 @smallexample
8780 long __builtin_alpha_pklb (long)
8781 long __builtin_alpha_pkwb (long)
8782 long __builtin_alpha_unpkbl (long)
8783 long __builtin_alpha_unpkbw (long)
8784 long __builtin_alpha_minub8 (long, long)
8785 long __builtin_alpha_minsb8 (long, long)
8786 long __builtin_alpha_minuw4 (long, long)
8787 long __builtin_alpha_minsw4 (long, long)
8788 long __builtin_alpha_maxub8 (long, long)
8789 long __builtin_alpha_maxsb8 (long, long)
8790 long __builtin_alpha_maxuw4 (long, long)
8791 long __builtin_alpha_maxsw4 (long, long)
8792 long __builtin_alpha_perr (long, long)
8793 @end smallexample
8794
8795 The following built-in functions are always with @option{-mcix}
8796 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
8797 later. They all generate the machine instruction that is part
8798 of the name.
8799
8800 @smallexample
8801 long __builtin_alpha_cttz (long)
8802 long __builtin_alpha_ctlz (long)
8803 long __builtin_alpha_ctpop (long)
8804 @end smallexample
8805
8806 The following built-in functions are available on systems that use the OSF/1
8807 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
8808 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
8809 @code{rdval} and @code{wrval}.
8810
8811 @smallexample
8812 void *__builtin_thread_pointer (void)
8813 void __builtin_set_thread_pointer (void *)
8814 @end smallexample
8815
8816 @node ARM iWMMXt Built-in Functions
8817 @subsection ARM iWMMXt Built-in Functions
8818
8819 These built-in functions are available for the ARM family of
8820 processors when the @option{-mcpu=iwmmxt} switch is used:
8821
8822 @smallexample
8823 typedef int v2si __attribute__ ((vector_size (8)));
8824 typedef short v4hi __attribute__ ((vector_size (8)));
8825 typedef char v8qi __attribute__ ((vector_size (8)));
8826
8827 int __builtin_arm_getwcgr0 (void)
8828 void __builtin_arm_setwcgr0 (int)
8829 int __builtin_arm_getwcgr1 (void)
8830 void __builtin_arm_setwcgr1 (int)
8831 int __builtin_arm_getwcgr2 (void)
8832 void __builtin_arm_setwcgr2 (int)
8833 int __builtin_arm_getwcgr3 (void)
8834 void __builtin_arm_setwcgr3 (int)
8835 int __builtin_arm_textrmsb (v8qi, int)
8836 int __builtin_arm_textrmsh (v4hi, int)
8837 int __builtin_arm_textrmsw (v2si, int)
8838 int __builtin_arm_textrmub (v8qi, int)
8839 int __builtin_arm_textrmuh (v4hi, int)
8840 int __builtin_arm_textrmuw (v2si, int)
8841 v8qi __builtin_arm_tinsrb (v8qi, int, int)
8842 v4hi __builtin_arm_tinsrh (v4hi, int, int)
8843 v2si __builtin_arm_tinsrw (v2si, int, int)
8844 long long __builtin_arm_tmia (long long, int, int)
8845 long long __builtin_arm_tmiabb (long long, int, int)
8846 long long __builtin_arm_tmiabt (long long, int, int)
8847 long long __builtin_arm_tmiaph (long long, int, int)
8848 long long __builtin_arm_tmiatb (long long, int, int)
8849 long long __builtin_arm_tmiatt (long long, int, int)
8850 int __builtin_arm_tmovmskb (v8qi)
8851 int __builtin_arm_tmovmskh (v4hi)
8852 int __builtin_arm_tmovmskw (v2si)
8853 long long __builtin_arm_waccb (v8qi)
8854 long long __builtin_arm_wacch (v4hi)
8855 long long __builtin_arm_waccw (v2si)
8856 v8qi __builtin_arm_waddb (v8qi, v8qi)
8857 v8qi __builtin_arm_waddbss (v8qi, v8qi)
8858 v8qi __builtin_arm_waddbus (v8qi, v8qi)
8859 v4hi __builtin_arm_waddh (v4hi, v4hi)
8860 v4hi __builtin_arm_waddhss (v4hi, v4hi)
8861 v4hi __builtin_arm_waddhus (v4hi, v4hi)
8862 v2si __builtin_arm_waddw (v2si, v2si)
8863 v2si __builtin_arm_waddwss (v2si, v2si)
8864 v2si __builtin_arm_waddwus (v2si, v2si)
8865 v8qi __builtin_arm_walign (v8qi, v8qi, int)
8866 long long __builtin_arm_wand(long long, long long)
8867 long long __builtin_arm_wandn (long long, long long)
8868 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
8869 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
8870 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
8871 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
8872 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
8873 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
8874 v2si __builtin_arm_wcmpeqw (v2si, v2si)
8875 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
8876 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
8877 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
8878 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
8879 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
8880 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
8881 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
8882 long long __builtin_arm_wmacsz (v4hi, v4hi)
8883 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
8884 long long __builtin_arm_wmacuz (v4hi, v4hi)
8885 v4hi __builtin_arm_wmadds (v4hi, v4hi)
8886 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
8887 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
8888 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
8889 v2si __builtin_arm_wmaxsw (v2si, v2si)
8890 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
8891 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
8892 v2si __builtin_arm_wmaxuw (v2si, v2si)
8893 v8qi __builtin_arm_wminsb (v8qi, v8qi)
8894 v4hi __builtin_arm_wminsh (v4hi, v4hi)
8895 v2si __builtin_arm_wminsw (v2si, v2si)
8896 v8qi __builtin_arm_wminub (v8qi, v8qi)
8897 v4hi __builtin_arm_wminuh (v4hi, v4hi)
8898 v2si __builtin_arm_wminuw (v2si, v2si)
8899 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
8900 v4hi __builtin_arm_wmulul (v4hi, v4hi)
8901 v4hi __builtin_arm_wmulum (v4hi, v4hi)
8902 long long __builtin_arm_wor (long long, long long)
8903 v2si __builtin_arm_wpackdss (long long, long long)
8904 v2si __builtin_arm_wpackdus (long long, long long)
8905 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
8906 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
8907 v4hi __builtin_arm_wpackwss (v2si, v2si)
8908 v4hi __builtin_arm_wpackwus (v2si, v2si)
8909 long long __builtin_arm_wrord (long long, long long)
8910 long long __builtin_arm_wrordi (long long, int)
8911 v4hi __builtin_arm_wrorh (v4hi, long long)
8912 v4hi __builtin_arm_wrorhi (v4hi, int)
8913 v2si __builtin_arm_wrorw (v2si, long long)
8914 v2si __builtin_arm_wrorwi (v2si, int)
8915 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
8916 v2si __builtin_arm_wsadbz (v8qi, v8qi)
8917 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
8918 v2si __builtin_arm_wsadhz (v4hi, v4hi)
8919 v4hi __builtin_arm_wshufh (v4hi, int)
8920 long long __builtin_arm_wslld (long long, long long)
8921 long long __builtin_arm_wslldi (long long, int)
8922 v4hi __builtin_arm_wsllh (v4hi, long long)
8923 v4hi __builtin_arm_wsllhi (v4hi, int)
8924 v2si __builtin_arm_wsllw (v2si, long long)
8925 v2si __builtin_arm_wsllwi (v2si, int)
8926 long long __builtin_arm_wsrad (long long, long long)
8927 long long __builtin_arm_wsradi (long long, int)
8928 v4hi __builtin_arm_wsrah (v4hi, long long)
8929 v4hi __builtin_arm_wsrahi (v4hi, int)
8930 v2si __builtin_arm_wsraw (v2si, long long)
8931 v2si __builtin_arm_wsrawi (v2si, int)
8932 long long __builtin_arm_wsrld (long long, long long)
8933 long long __builtin_arm_wsrldi (long long, int)
8934 v4hi __builtin_arm_wsrlh (v4hi, long long)
8935 v4hi __builtin_arm_wsrlhi (v4hi, int)
8936 v2si __builtin_arm_wsrlw (v2si, long long)
8937 v2si __builtin_arm_wsrlwi (v2si, int)
8938 v8qi __builtin_arm_wsubb (v8qi, v8qi)
8939 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
8940 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
8941 v4hi __builtin_arm_wsubh (v4hi, v4hi)
8942 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
8943 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
8944 v2si __builtin_arm_wsubw (v2si, v2si)
8945 v2si __builtin_arm_wsubwss (v2si, v2si)
8946 v2si __builtin_arm_wsubwus (v2si, v2si)
8947 v4hi __builtin_arm_wunpckehsb (v8qi)
8948 v2si __builtin_arm_wunpckehsh (v4hi)
8949 long long __builtin_arm_wunpckehsw (v2si)
8950 v4hi __builtin_arm_wunpckehub (v8qi)
8951 v2si __builtin_arm_wunpckehuh (v4hi)
8952 long long __builtin_arm_wunpckehuw (v2si)
8953 v4hi __builtin_arm_wunpckelsb (v8qi)
8954 v2si __builtin_arm_wunpckelsh (v4hi)
8955 long long __builtin_arm_wunpckelsw (v2si)
8956 v4hi __builtin_arm_wunpckelub (v8qi)
8957 v2si __builtin_arm_wunpckeluh (v4hi)
8958 long long __builtin_arm_wunpckeluw (v2si)
8959 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
8960 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
8961 v2si __builtin_arm_wunpckihw (v2si, v2si)
8962 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
8963 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
8964 v2si __builtin_arm_wunpckilw (v2si, v2si)
8965 long long __builtin_arm_wxor (long long, long long)
8966 long long __builtin_arm_wzero ()
8967 @end smallexample
8968
8969 @node ARM NEON Intrinsics
8970 @subsection ARM NEON Intrinsics
8971
8972 These built-in intrinsics for the ARM Advanced SIMD extension are available
8973 when the @option{-mfpu=neon} switch is used:
8974
8975 @include arm-neon-intrinsics.texi
8976
8977 @node AVR Built-in Functions
8978 @subsection AVR Built-in Functions
8979
8980 For each built-in function for AVR, there is an equally named,
8981 uppercase built-in macro defined. That way users can easily query if
8982 or if not a specific built-in is implemented or not. For example, if
8983 @code{__builtin_avr_nop} is available the macro
8984 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
8985
8986 The following built-in functions map to the respective machine
8987 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
8988 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
8989 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
8990 as library call if no hardware multiplier is available.
8991
8992 @smallexample
8993 void __builtin_avr_nop (void)
8994 void __builtin_avr_sei (void)
8995 void __builtin_avr_cli (void)
8996 void __builtin_avr_sleep (void)
8997 void __builtin_avr_wdr (void)
8998 unsigned char __builtin_avr_swap (unsigned char)
8999 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9000 int __builtin_avr_fmuls (char, char)
9001 int __builtin_avr_fmulsu (char, unsigned char)
9002 @end smallexample
9003
9004 In order to delay execution for a specific number of cycles, GCC
9005 implements
9006 @smallexample
9007 void __builtin_avr_delay_cycles (unsigned long ticks)
9008 @end smallexample
9009
9010 @noindent
9011 @code{ticks} is the number of ticks to delay execution. Note that this
9012 built-in does not take into account the effect of interrupts that
9013 might increase delay time. @code{ticks} must be a compile-time
9014 integer constant; delays with a variable number of cycles are not supported.
9015
9016 @smallexample
9017 char __builtin_avr_flash_segment (const __memx void*)
9018 @end smallexample
9019
9020 @noindent
9021 This built-in takes a byte address to the 24-bit
9022 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9023 the number of the flash segment (the 64 KiB chunk) where the address
9024 points to. Counting starts at @code{0}.
9025 If the address does not point to flash memory, return @code{-1}.
9026
9027 @smallexample
9028 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9029 @end smallexample
9030
9031 @noindent
9032 Insert bits from @var{bits} into @var{val} and return the resulting
9033 value. The nibbles of @var{map} determine how the insertion is
9034 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9035 @enumerate
9036 @item If @var{X} is @code{0xf},
9037 then the @var{n}-th bit of @var{val} is returned unaltered.
9038
9039 @item If X is in the range 0@dots{}7,
9040 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9041
9042 @item If X is in the range 8@dots{}@code{0xe},
9043 then the @var{n}-th result bit is undefined.
9044 @end enumerate
9045
9046 @noindent
9047 One typical use case for this built-in is adjusting input and
9048 output values to non-contiguous port layouts. Some examples:
9049
9050 @smallexample
9051 // same as val, bits is unused
9052 __builtin_avr_insert_bits (0xffffffff, bits, val)
9053 @end smallexample
9054
9055 @smallexample
9056 // same as bits, val is unused
9057 __builtin_avr_insert_bits (0x76543210, bits, val)
9058 @end smallexample
9059
9060 @smallexample
9061 // same as rotating bits by 4
9062 __builtin_avr_insert_bits (0x32107654, bits, 0)
9063 @end smallexample
9064
9065 @smallexample
9066 // high nibble of result is the high nibble of val
9067 // low nibble of result is the low nibble of bits
9068 __builtin_avr_insert_bits (0xffff3210, bits, val)
9069 @end smallexample
9070
9071 @smallexample
9072 // reverse the bit order of bits
9073 __builtin_avr_insert_bits (0x01234567, bits, 0)
9074 @end smallexample
9075
9076 @node Blackfin Built-in Functions
9077 @subsection Blackfin Built-in Functions
9078
9079 Currently, there are two Blackfin-specific built-in functions. These are
9080 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9081 using inline assembly; by using these built-in functions the compiler can
9082 automatically add workarounds for hardware errata involving these
9083 instructions. These functions are named as follows:
9084
9085 @smallexample
9086 void __builtin_bfin_csync (void)
9087 void __builtin_bfin_ssync (void)
9088 @end smallexample
9089
9090 @node FR-V Built-in Functions
9091 @subsection FR-V Built-in Functions
9092
9093 GCC provides many FR-V-specific built-in functions. In general,
9094 these functions are intended to be compatible with those described
9095 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9096 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
9097 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9098 pointer rather than by value.
9099
9100 Most of the functions are named after specific FR-V instructions.
9101 Such functions are said to be ``directly mapped'' and are summarized
9102 here in tabular form.
9103
9104 @menu
9105 * Argument Types::
9106 * Directly-mapped Integer Functions::
9107 * Directly-mapped Media Functions::
9108 * Raw read/write Functions::
9109 * Other Built-in Functions::
9110 @end menu
9111
9112 @node Argument Types
9113 @subsubsection Argument Types
9114
9115 The arguments to the built-in functions can be divided into three groups:
9116 register numbers, compile-time constants and run-time values. In order
9117 to make this classification clear at a glance, the arguments and return
9118 values are given the following pseudo types:
9119
9120 @multitable @columnfractions .20 .30 .15 .35
9121 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9122 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9123 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9124 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9125 @item @code{uw2} @tab @code{unsigned long long} @tab No
9126 @tab an unsigned doubleword
9127 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9128 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9129 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9130 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9131 @end multitable
9132
9133 These pseudo types are not defined by GCC, they are simply a notational
9134 convenience used in this manual.
9135
9136 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9137 and @code{sw2} are evaluated at run time. They correspond to
9138 register operands in the underlying FR-V instructions.
9139
9140 @code{const} arguments represent immediate operands in the underlying
9141 FR-V instructions. They must be compile-time constants.
9142
9143 @code{acc} arguments are evaluated at compile time and specify the number
9144 of an accumulator register. For example, an @code{acc} argument of 2
9145 selects the ACC2 register.
9146
9147 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9148 number of an IACC register. See @pxref{Other Built-in Functions}
9149 for more details.
9150
9151 @node Directly-mapped Integer Functions
9152 @subsubsection Directly-mapped Integer Functions
9153
9154 The functions listed below map directly to FR-V I-type instructions.
9155
9156 @multitable @columnfractions .45 .32 .23
9157 @item Function prototype @tab Example usage @tab Assembly output
9158 @item @code{sw1 __ADDSS (sw1, sw1)}
9159 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9160 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9161 @item @code{sw1 __SCAN (sw1, sw1)}
9162 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9163 @tab @code{SCAN @var{a},@var{b},@var{c}}
9164 @item @code{sw1 __SCUTSS (sw1)}
9165 @tab @code{@var{b} = __SCUTSS (@var{a})}
9166 @tab @code{SCUTSS @var{a},@var{b}}
9167 @item @code{sw1 __SLASS (sw1, sw1)}
9168 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9169 @tab @code{SLASS @var{a},@var{b},@var{c}}
9170 @item @code{void __SMASS (sw1, sw1)}
9171 @tab @code{__SMASS (@var{a}, @var{b})}
9172 @tab @code{SMASS @var{a},@var{b}}
9173 @item @code{void __SMSSS (sw1, sw1)}
9174 @tab @code{__SMSSS (@var{a}, @var{b})}
9175 @tab @code{SMSSS @var{a},@var{b}}
9176 @item @code{void __SMU (sw1, sw1)}
9177 @tab @code{__SMU (@var{a}, @var{b})}
9178 @tab @code{SMU @var{a},@var{b}}
9179 @item @code{sw2 __SMUL (sw1, sw1)}
9180 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9181 @tab @code{SMUL @var{a},@var{b},@var{c}}
9182 @item @code{sw1 __SUBSS (sw1, sw1)}
9183 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9184 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9185 @item @code{uw2 __UMUL (uw1, uw1)}
9186 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9187 @tab @code{UMUL @var{a},@var{b},@var{c}}
9188 @end multitable
9189
9190 @node Directly-mapped Media Functions
9191 @subsubsection Directly-mapped Media Functions
9192
9193 The functions listed below map directly to FR-V M-type instructions.
9194
9195 @multitable @columnfractions .45 .32 .23
9196 @item Function prototype @tab Example usage @tab Assembly output
9197 @item @code{uw1 __MABSHS (sw1)}
9198 @tab @code{@var{b} = __MABSHS (@var{a})}
9199 @tab @code{MABSHS @var{a},@var{b}}
9200 @item @code{void __MADDACCS (acc, acc)}
9201 @tab @code{__MADDACCS (@var{b}, @var{a})}
9202 @tab @code{MADDACCS @var{a},@var{b}}
9203 @item @code{sw1 __MADDHSS (sw1, sw1)}
9204 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9205 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9206 @item @code{uw1 __MADDHUS (uw1, uw1)}
9207 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9208 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9209 @item @code{uw1 __MAND (uw1, uw1)}
9210 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9211 @tab @code{MAND @var{a},@var{b},@var{c}}
9212 @item @code{void __MASACCS (acc, acc)}
9213 @tab @code{__MASACCS (@var{b}, @var{a})}
9214 @tab @code{MASACCS @var{a},@var{b}}
9215 @item @code{uw1 __MAVEH (uw1, uw1)}
9216 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9217 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9218 @item @code{uw2 __MBTOH (uw1)}
9219 @tab @code{@var{b} = __MBTOH (@var{a})}
9220 @tab @code{MBTOH @var{a},@var{b}}
9221 @item @code{void __MBTOHE (uw1 *, uw1)}
9222 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9223 @tab @code{MBTOHE @var{a},@var{b}}
9224 @item @code{void __MCLRACC (acc)}
9225 @tab @code{__MCLRACC (@var{a})}
9226 @tab @code{MCLRACC @var{a}}
9227 @item @code{void __MCLRACCA (void)}
9228 @tab @code{__MCLRACCA ()}
9229 @tab @code{MCLRACCA}
9230 @item @code{uw1 __Mcop1 (uw1, uw1)}
9231 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9232 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9233 @item @code{uw1 __Mcop2 (uw1, uw1)}
9234 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9235 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9236 @item @code{uw1 __MCPLHI (uw2, const)}
9237 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9238 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9239 @item @code{uw1 __MCPLI (uw2, const)}
9240 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9241 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9242 @item @code{void __MCPXIS (acc, sw1, sw1)}
9243 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9244 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9245 @item @code{void __MCPXIU (acc, uw1, uw1)}
9246 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9247 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9248 @item @code{void __MCPXRS (acc, sw1, sw1)}
9249 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9250 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9251 @item @code{void __MCPXRU (acc, uw1, uw1)}
9252 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9253 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9254 @item @code{uw1 __MCUT (acc, uw1)}
9255 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9256 @tab @code{MCUT @var{a},@var{b},@var{c}}
9257 @item @code{uw1 __MCUTSS (acc, sw1)}
9258 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9259 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9260 @item @code{void __MDADDACCS (acc, acc)}
9261 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9262 @tab @code{MDADDACCS @var{a},@var{b}}
9263 @item @code{void __MDASACCS (acc, acc)}
9264 @tab @code{__MDASACCS (@var{b}, @var{a})}
9265 @tab @code{MDASACCS @var{a},@var{b}}
9266 @item @code{uw2 __MDCUTSSI (acc, const)}
9267 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
9268 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
9269 @item @code{uw2 __MDPACKH (uw2, uw2)}
9270 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
9271 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
9272 @item @code{uw2 __MDROTLI (uw2, const)}
9273 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
9274 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
9275 @item @code{void __MDSUBACCS (acc, acc)}
9276 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
9277 @tab @code{MDSUBACCS @var{a},@var{b}}
9278 @item @code{void __MDUNPACKH (uw1 *, uw2)}
9279 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
9280 @tab @code{MDUNPACKH @var{a},@var{b}}
9281 @item @code{uw2 __MEXPDHD (uw1, const)}
9282 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
9283 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
9284 @item @code{uw1 __MEXPDHW (uw1, const)}
9285 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
9286 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
9287 @item @code{uw1 __MHDSETH (uw1, const)}
9288 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
9289 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
9290 @item @code{sw1 __MHDSETS (const)}
9291 @tab @code{@var{b} = __MHDSETS (@var{a})}
9292 @tab @code{MHDSETS #@var{a},@var{b}}
9293 @item @code{uw1 __MHSETHIH (uw1, const)}
9294 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
9295 @tab @code{MHSETHIH #@var{a},@var{b}}
9296 @item @code{sw1 __MHSETHIS (sw1, const)}
9297 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
9298 @tab @code{MHSETHIS #@var{a},@var{b}}
9299 @item @code{uw1 __MHSETLOH (uw1, const)}
9300 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
9301 @tab @code{MHSETLOH #@var{a},@var{b}}
9302 @item @code{sw1 __MHSETLOS (sw1, const)}
9303 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
9304 @tab @code{MHSETLOS #@var{a},@var{b}}
9305 @item @code{uw1 __MHTOB (uw2)}
9306 @tab @code{@var{b} = __MHTOB (@var{a})}
9307 @tab @code{MHTOB @var{a},@var{b}}
9308 @item @code{void __MMACHS (acc, sw1, sw1)}
9309 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
9310 @tab @code{MMACHS @var{a},@var{b},@var{c}}
9311 @item @code{void __MMACHU (acc, uw1, uw1)}
9312 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
9313 @tab @code{MMACHU @var{a},@var{b},@var{c}}
9314 @item @code{void __MMRDHS (acc, sw1, sw1)}
9315 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
9316 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
9317 @item @code{void __MMRDHU (acc, uw1, uw1)}
9318 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
9319 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
9320 @item @code{void __MMULHS (acc, sw1, sw1)}
9321 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
9322 @tab @code{MMULHS @var{a},@var{b},@var{c}}
9323 @item @code{void __MMULHU (acc, uw1, uw1)}
9324 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
9325 @tab @code{MMULHU @var{a},@var{b},@var{c}}
9326 @item @code{void __MMULXHS (acc, sw1, sw1)}
9327 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
9328 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
9329 @item @code{void __MMULXHU (acc, uw1, uw1)}
9330 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
9331 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
9332 @item @code{uw1 __MNOT (uw1)}
9333 @tab @code{@var{b} = __MNOT (@var{a})}
9334 @tab @code{MNOT @var{a},@var{b}}
9335 @item @code{uw1 __MOR (uw1, uw1)}
9336 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
9337 @tab @code{MOR @var{a},@var{b},@var{c}}
9338 @item @code{uw1 __MPACKH (uh, uh)}
9339 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
9340 @tab @code{MPACKH @var{a},@var{b},@var{c}}
9341 @item @code{sw2 __MQADDHSS (sw2, sw2)}
9342 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
9343 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
9344 @item @code{uw2 __MQADDHUS (uw2, uw2)}
9345 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
9346 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
9347 @item @code{void __MQCPXIS (acc, sw2, sw2)}
9348 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
9349 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
9350 @item @code{void __MQCPXIU (acc, uw2, uw2)}
9351 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
9352 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
9353 @item @code{void __MQCPXRS (acc, sw2, sw2)}
9354 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
9355 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
9356 @item @code{void __MQCPXRU (acc, uw2, uw2)}
9357 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
9358 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
9359 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
9360 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
9361 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
9362 @item @code{sw2 __MQLMTHS (sw2, sw2)}
9363 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
9364 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
9365 @item @code{void __MQMACHS (acc, sw2, sw2)}
9366 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
9367 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
9368 @item @code{void __MQMACHU (acc, uw2, uw2)}
9369 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
9370 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
9371 @item @code{void __MQMACXHS (acc, sw2, sw2)}
9372 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
9373 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
9374 @item @code{void __MQMULHS (acc, sw2, sw2)}
9375 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
9376 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
9377 @item @code{void __MQMULHU (acc, uw2, uw2)}
9378 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
9379 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
9380 @item @code{void __MQMULXHS (acc, sw2, sw2)}
9381 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
9382 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
9383 @item @code{void __MQMULXHU (acc, uw2, uw2)}
9384 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
9385 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
9386 @item @code{sw2 __MQSATHS (sw2, sw2)}
9387 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
9388 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
9389 @item @code{uw2 __MQSLLHI (uw2, int)}
9390 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
9391 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
9392 @item @code{sw2 __MQSRAHI (sw2, int)}
9393 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
9394 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
9395 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
9396 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
9397 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
9398 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
9399 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
9400 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
9401 @item @code{void __MQXMACHS (acc, sw2, sw2)}
9402 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
9403 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
9404 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
9405 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
9406 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
9407 @item @code{uw1 __MRDACC (acc)}
9408 @tab @code{@var{b} = __MRDACC (@var{a})}
9409 @tab @code{MRDACC @var{a},@var{b}}
9410 @item @code{uw1 __MRDACCG (acc)}
9411 @tab @code{@var{b} = __MRDACCG (@var{a})}
9412 @tab @code{MRDACCG @var{a},@var{b}}
9413 @item @code{uw1 __MROTLI (uw1, const)}
9414 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
9415 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
9416 @item @code{uw1 __MROTRI (uw1, const)}
9417 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
9418 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
9419 @item @code{sw1 __MSATHS (sw1, sw1)}
9420 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
9421 @tab @code{MSATHS @var{a},@var{b},@var{c}}
9422 @item @code{uw1 __MSATHU (uw1, uw1)}
9423 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
9424 @tab @code{MSATHU @var{a},@var{b},@var{c}}
9425 @item @code{uw1 __MSLLHI (uw1, const)}
9426 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
9427 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
9428 @item @code{sw1 __MSRAHI (sw1, const)}
9429 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
9430 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
9431 @item @code{uw1 __MSRLHI (uw1, const)}
9432 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
9433 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
9434 @item @code{void __MSUBACCS (acc, acc)}
9435 @tab @code{__MSUBACCS (@var{b}, @var{a})}
9436 @tab @code{MSUBACCS @var{a},@var{b}}
9437 @item @code{sw1 __MSUBHSS (sw1, sw1)}
9438 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
9439 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
9440 @item @code{uw1 __MSUBHUS (uw1, uw1)}
9441 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
9442 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
9443 @item @code{void __MTRAP (void)}
9444 @tab @code{__MTRAP ()}
9445 @tab @code{MTRAP}
9446 @item @code{uw2 __MUNPACKH (uw1)}
9447 @tab @code{@var{b} = __MUNPACKH (@var{a})}
9448 @tab @code{MUNPACKH @var{a},@var{b}}
9449 @item @code{uw1 __MWCUT (uw2, uw1)}
9450 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
9451 @tab @code{MWCUT @var{a},@var{b},@var{c}}
9452 @item @code{void __MWTACC (acc, uw1)}
9453 @tab @code{__MWTACC (@var{b}, @var{a})}
9454 @tab @code{MWTACC @var{a},@var{b}}
9455 @item @code{void __MWTACCG (acc, uw1)}
9456 @tab @code{__MWTACCG (@var{b}, @var{a})}
9457 @tab @code{MWTACCG @var{a},@var{b}}
9458 @item @code{uw1 __MXOR (uw1, uw1)}
9459 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
9460 @tab @code{MXOR @var{a},@var{b},@var{c}}
9461 @end multitable
9462
9463 @node Raw read/write Functions
9464 @subsubsection Raw read/write Functions
9465
9466 This sections describes built-in functions related to read and write
9467 instructions to access memory. These functions generate
9468 @code{membar} instructions to flush the I/O load and stores where
9469 appropriate, as described in Fujitsu's manual described above.
9470
9471 @table @code
9472
9473 @item unsigned char __builtin_read8 (void *@var{data})
9474 @item unsigned short __builtin_read16 (void *@var{data})
9475 @item unsigned long __builtin_read32 (void *@var{data})
9476 @item unsigned long long __builtin_read64 (void *@var{data})
9477
9478 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
9479 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
9480 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
9481 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
9482 @end table
9483
9484 @node Other Built-in Functions
9485 @subsubsection Other Built-in Functions
9486
9487 This section describes built-in functions that are not named after
9488 a specific FR-V instruction.
9489
9490 @table @code
9491 @item sw2 __IACCreadll (iacc @var{reg})
9492 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
9493 for future expansion and must be 0.
9494
9495 @item sw1 __IACCreadl (iacc @var{reg})
9496 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
9497 Other values of @var{reg} are rejected as invalid.
9498
9499 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
9500 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
9501 is reserved for future expansion and must be 0.
9502
9503 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
9504 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
9505 is 1. Other values of @var{reg} are rejected as invalid.
9506
9507 @item void __data_prefetch0 (const void *@var{x})
9508 Use the @code{dcpl} instruction to load the contents of address @var{x}
9509 into the data cache.
9510
9511 @item void __data_prefetch (const void *@var{x})
9512 Use the @code{nldub} instruction to load the contents of address @var{x}
9513 into the data cache. The instruction is issued in slot I1@.
9514 @end table
9515
9516 @node X86 Built-in Functions
9517 @subsection X86 Built-in Functions
9518
9519 These built-in functions are available for the i386 and x86-64 family
9520 of computers, depending on the command-line switches used.
9521
9522 If you specify command-line switches such as @option{-msse},
9523 the compiler could use the extended instruction sets even if the built-ins
9524 are not used explicitly in the program. For this reason, applications
9525 that perform run-time CPU detection must compile separate files for each
9526 supported architecture, using the appropriate flags. In particular,
9527 the file containing the CPU detection code should be compiled without
9528 these options.
9529
9530 The following machine modes are available for use with MMX built-in functions
9531 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
9532 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
9533 vector of eight 8-bit integers. Some of the built-in functions operate on
9534 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
9535
9536 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
9537 of two 32-bit floating-point values.
9538
9539 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
9540 floating-point values. Some instructions use a vector of four 32-bit
9541 integers, these use @code{V4SI}. Finally, some instructions operate on an
9542 entire vector register, interpreting it as a 128-bit integer, these use mode
9543 @code{TI}.
9544
9545 In 64-bit mode, the x86-64 family of processors uses additional built-in
9546 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
9547 floating point and @code{TC} 128-bit complex floating-point values.
9548
9549 The following floating-point built-in functions are available in 64-bit
9550 mode. All of them implement the function that is part of the name.
9551
9552 @smallexample
9553 __float128 __builtin_fabsq (__float128)
9554 __float128 __builtin_copysignq (__float128, __float128)
9555 @end smallexample
9556
9557 The following built-in function is always available.
9558
9559 @table @code
9560 @item void __builtin_ia32_pause (void)
9561 Generates the @code{pause} machine instruction with a compiler memory
9562 barrier.
9563 @end table
9564
9565 The following floating-point built-in functions are made available in the
9566 64-bit mode.
9567
9568 @table @code
9569 @item __float128 __builtin_infq (void)
9570 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
9571 @findex __builtin_infq
9572
9573 @item __float128 __builtin_huge_valq (void)
9574 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
9575 @findex __builtin_huge_valq
9576 @end table
9577
9578 The following built-in functions are always available and can be used to
9579 check the target platform type.
9580
9581 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
9582 This function runs the CPU detection code to check the type of CPU and the
9583 features supported. This built-in function needs to be invoked along with the built-in functions
9584 to check CPU type and features, @code{__builtin_cpu_is} and
9585 @code{__builtin_cpu_supports}, only when used in a function that is
9586 executed before any constructors are called. The CPU detection code is
9587 automatically executed in a very high priority constructor.
9588
9589 For example, this function has to be used in @code{ifunc} resolvers that
9590 check for CPU type using the built-in functions @code{__builtin_cpu_is}
9591 and @code{__builtin_cpu_supports}, or in constructors on targets that
9592 don't support constructor priority.
9593 @smallexample
9594
9595 static void (*resolve_memcpy (void)) (void)
9596 @{
9597 // ifunc resolvers fire before constructors, explicitly call the init
9598 // function.
9599 __builtin_cpu_init ();
9600 if (__builtin_cpu_supports ("ssse3"))
9601 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
9602 else
9603 return default_memcpy;
9604 @}
9605
9606 void *memcpy (void *, const void *, size_t)
9607 __attribute__ ((ifunc ("resolve_memcpy")));
9608 @end smallexample
9609
9610 @end deftypefn
9611
9612 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
9613 This function returns a positive integer if the run-time CPU
9614 is of type @var{cpuname}
9615 and returns @code{0} otherwise. The following CPU names can be detected:
9616
9617 @table @samp
9618 @item intel
9619 Intel CPU.
9620
9621 @item atom
9622 Intel ATOM CPU.
9623
9624 @item core2
9625 Intel Core2 CPU.
9626
9627 @item corei7
9628 Intel Corei7 CPU.
9629
9630 @item nehalem
9631 Intel Corei7 Nehalem CPU.
9632
9633 @item westmere
9634 Intel Corei7 Westmere CPU.
9635
9636 @item sandybridge
9637 Intel Corei7 Sandybridge CPU.
9638
9639 @item amd
9640 AMD CPU.
9641
9642 @item amdfam10h
9643 AMD family 10h CPU.
9644
9645 @item barcelona
9646 AMD family 10h Barcelona CPU.
9647
9648 @item shanghai
9649 AMD family 10h Shanghai CPU.
9650
9651 @item istanbul
9652 AMD family 10h Istanbul CPU.
9653
9654 @item btver1
9655 AMD family 14h CPU.
9656
9657 @item amdfam15h
9658 AMD family 15h CPU.
9659
9660 @item bdver1
9661 AMD family 15h Bulldozer version 1.
9662
9663 @item bdver2
9664 AMD family 15h Bulldozer version 2.
9665
9666 @item bdver3
9667 AMD family 15h Bulldozer version 3.
9668
9669 @item btver2
9670 AMD family 16h CPU.
9671 @end table
9672
9673 Here is an example:
9674 @smallexample
9675 if (__builtin_cpu_is ("corei7"))
9676 @{
9677 do_corei7 (); //Corei7 specific implementation.
9678 @}
9679 else
9680 @{
9681 do_generic (); //Generic implementation.
9682 @}
9683 @end smallexample
9684 @end deftypefn
9685
9686 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
9687 This function returns a positive integer if the run-time CPU
9688 supports @var{feature}
9689 and returns @code{0} otherwise. The following features can be detected:
9690
9691 @table @samp
9692 @item cmov
9693 CMOV instruction.
9694 @item mmx
9695 MMX instructions.
9696 @item popcnt
9697 POPCNT instruction.
9698 @item sse
9699 SSE instructions.
9700 @item sse2
9701 SSE2 instructions.
9702 @item sse3
9703 SSE3 instructions.
9704 @item ssse3
9705 SSSE3 instructions.
9706 @item sse4.1
9707 SSE4.1 instructions.
9708 @item sse4.2
9709 SSE4.2 instructions.
9710 @item avx
9711 AVX instructions.
9712 @item avx2
9713 AVX2 instructions.
9714 @end table
9715
9716 Here is an example:
9717 @smallexample
9718 if (__builtin_cpu_supports ("popcnt"))
9719 @{
9720 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
9721 @}
9722 else
9723 @{
9724 count = generic_countbits (n); //generic implementation.
9725 @}
9726 @end smallexample
9727 @end deftypefn
9728
9729
9730 The following built-in functions are made available by @option{-mmmx}.
9731 All of them generate the machine instruction that is part of the name.
9732
9733 @smallexample
9734 v8qi __builtin_ia32_paddb (v8qi, v8qi)
9735 v4hi __builtin_ia32_paddw (v4hi, v4hi)
9736 v2si __builtin_ia32_paddd (v2si, v2si)
9737 v8qi __builtin_ia32_psubb (v8qi, v8qi)
9738 v4hi __builtin_ia32_psubw (v4hi, v4hi)
9739 v2si __builtin_ia32_psubd (v2si, v2si)
9740 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
9741 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
9742 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
9743 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
9744 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
9745 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
9746 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
9747 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
9748 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
9749 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
9750 di __builtin_ia32_pand (di, di)
9751 di __builtin_ia32_pandn (di,di)
9752 di __builtin_ia32_por (di, di)
9753 di __builtin_ia32_pxor (di, di)
9754 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
9755 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
9756 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
9757 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
9758 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
9759 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
9760 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
9761 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
9762 v2si __builtin_ia32_punpckhdq (v2si, v2si)
9763 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
9764 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
9765 v2si __builtin_ia32_punpckldq (v2si, v2si)
9766 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
9767 v4hi __builtin_ia32_packssdw (v2si, v2si)
9768 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
9769
9770 v4hi __builtin_ia32_psllw (v4hi, v4hi)
9771 v2si __builtin_ia32_pslld (v2si, v2si)
9772 v1di __builtin_ia32_psllq (v1di, v1di)
9773 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
9774 v2si __builtin_ia32_psrld (v2si, v2si)
9775 v1di __builtin_ia32_psrlq (v1di, v1di)
9776 v4hi __builtin_ia32_psraw (v4hi, v4hi)
9777 v2si __builtin_ia32_psrad (v2si, v2si)
9778 v4hi __builtin_ia32_psllwi (v4hi, int)
9779 v2si __builtin_ia32_pslldi (v2si, int)
9780 v1di __builtin_ia32_psllqi (v1di, int)
9781 v4hi __builtin_ia32_psrlwi (v4hi, int)
9782 v2si __builtin_ia32_psrldi (v2si, int)
9783 v1di __builtin_ia32_psrlqi (v1di, int)
9784 v4hi __builtin_ia32_psrawi (v4hi, int)
9785 v2si __builtin_ia32_psradi (v2si, int)
9786
9787 @end smallexample
9788
9789 The following built-in functions are made available either with
9790 @option{-msse}, or with a combination of @option{-m3dnow} and
9791 @option{-march=athlon}. All of them generate the machine
9792 instruction that is part of the name.
9793
9794 @smallexample
9795 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
9796 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
9797 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
9798 v1di __builtin_ia32_psadbw (v8qi, v8qi)
9799 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
9800 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
9801 v8qi __builtin_ia32_pminub (v8qi, v8qi)
9802 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
9803 int __builtin_ia32_pextrw (v4hi, int)
9804 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
9805 int __builtin_ia32_pmovmskb (v8qi)
9806 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
9807 void __builtin_ia32_movntq (di *, di)
9808 void __builtin_ia32_sfence (void)
9809 @end smallexample
9810
9811 The following built-in functions are available when @option{-msse} is used.
9812 All of them generate the machine instruction that is part of the name.
9813
9814 @smallexample
9815 int __builtin_ia32_comieq (v4sf, v4sf)
9816 int __builtin_ia32_comineq (v4sf, v4sf)
9817 int __builtin_ia32_comilt (v4sf, v4sf)
9818 int __builtin_ia32_comile (v4sf, v4sf)
9819 int __builtin_ia32_comigt (v4sf, v4sf)
9820 int __builtin_ia32_comige (v4sf, v4sf)
9821 int __builtin_ia32_ucomieq (v4sf, v4sf)
9822 int __builtin_ia32_ucomineq (v4sf, v4sf)
9823 int __builtin_ia32_ucomilt (v4sf, v4sf)
9824 int __builtin_ia32_ucomile (v4sf, v4sf)
9825 int __builtin_ia32_ucomigt (v4sf, v4sf)
9826 int __builtin_ia32_ucomige (v4sf, v4sf)
9827 v4sf __builtin_ia32_addps (v4sf, v4sf)
9828 v4sf __builtin_ia32_subps (v4sf, v4sf)
9829 v4sf __builtin_ia32_mulps (v4sf, v4sf)
9830 v4sf __builtin_ia32_divps (v4sf, v4sf)
9831 v4sf __builtin_ia32_addss (v4sf, v4sf)
9832 v4sf __builtin_ia32_subss (v4sf, v4sf)
9833 v4sf __builtin_ia32_mulss (v4sf, v4sf)
9834 v4sf __builtin_ia32_divss (v4sf, v4sf)
9835 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
9836 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
9837 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
9838 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
9839 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
9840 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
9841 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
9842 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
9843 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
9844 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
9845 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
9846 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
9847 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
9848 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
9849 v4si __builtin_ia32_cmpless (v4sf, v4sf)
9850 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
9851 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
9852 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
9853 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
9854 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
9855 v4sf __builtin_ia32_maxps (v4sf, v4sf)
9856 v4sf __builtin_ia32_maxss (v4sf, v4sf)
9857 v4sf __builtin_ia32_minps (v4sf, v4sf)
9858 v4sf __builtin_ia32_minss (v4sf, v4sf)
9859 v4sf __builtin_ia32_andps (v4sf, v4sf)
9860 v4sf __builtin_ia32_andnps (v4sf, v4sf)
9861 v4sf __builtin_ia32_orps (v4sf, v4sf)
9862 v4sf __builtin_ia32_xorps (v4sf, v4sf)
9863 v4sf __builtin_ia32_movss (v4sf, v4sf)
9864 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
9865 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
9866 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
9867 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
9868 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
9869 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
9870 v2si __builtin_ia32_cvtps2pi (v4sf)
9871 int __builtin_ia32_cvtss2si (v4sf)
9872 v2si __builtin_ia32_cvttps2pi (v4sf)
9873 int __builtin_ia32_cvttss2si (v4sf)
9874 v4sf __builtin_ia32_rcpps (v4sf)
9875 v4sf __builtin_ia32_rsqrtps (v4sf)
9876 v4sf __builtin_ia32_sqrtps (v4sf)
9877 v4sf __builtin_ia32_rcpss (v4sf)
9878 v4sf __builtin_ia32_rsqrtss (v4sf)
9879 v4sf __builtin_ia32_sqrtss (v4sf)
9880 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
9881 void __builtin_ia32_movntps (float *, v4sf)
9882 int __builtin_ia32_movmskps (v4sf)
9883 @end smallexample
9884
9885 The following built-in functions are available when @option{-msse} is used.
9886
9887 @table @code
9888 @item v4sf __builtin_ia32_loadaps (float *)
9889 Generates the @code{movaps} machine instruction as a load from memory.
9890 @item void __builtin_ia32_storeaps (float *, v4sf)
9891 Generates the @code{movaps} machine instruction as a store to memory.
9892 @item v4sf __builtin_ia32_loadups (float *)
9893 Generates the @code{movups} machine instruction as a load from memory.
9894 @item void __builtin_ia32_storeups (float *, v4sf)
9895 Generates the @code{movups} machine instruction as a store to memory.
9896 @item v4sf __builtin_ia32_loadsss (float *)
9897 Generates the @code{movss} machine instruction as a load from memory.
9898 @item void __builtin_ia32_storess (float *, v4sf)
9899 Generates the @code{movss} machine instruction as a store to memory.
9900 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
9901 Generates the @code{movhps} machine instruction as a load from memory.
9902 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
9903 Generates the @code{movlps} machine instruction as a load from memory
9904 @item void __builtin_ia32_storehps (v2sf *, v4sf)
9905 Generates the @code{movhps} machine instruction as a store to memory.
9906 @item void __builtin_ia32_storelps (v2sf *, v4sf)
9907 Generates the @code{movlps} machine instruction as a store to memory.
9908 @end table
9909
9910 The following built-in functions are available when @option{-msse2} is used.
9911 All of them generate the machine instruction that is part of the name.
9912
9913 @smallexample
9914 int __builtin_ia32_comisdeq (v2df, v2df)
9915 int __builtin_ia32_comisdlt (v2df, v2df)
9916 int __builtin_ia32_comisdle (v2df, v2df)
9917 int __builtin_ia32_comisdgt (v2df, v2df)
9918 int __builtin_ia32_comisdge (v2df, v2df)
9919 int __builtin_ia32_comisdneq (v2df, v2df)
9920 int __builtin_ia32_ucomisdeq (v2df, v2df)
9921 int __builtin_ia32_ucomisdlt (v2df, v2df)
9922 int __builtin_ia32_ucomisdle (v2df, v2df)
9923 int __builtin_ia32_ucomisdgt (v2df, v2df)
9924 int __builtin_ia32_ucomisdge (v2df, v2df)
9925 int __builtin_ia32_ucomisdneq (v2df, v2df)
9926 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
9927 v2df __builtin_ia32_cmpltpd (v2df, v2df)
9928 v2df __builtin_ia32_cmplepd (v2df, v2df)
9929 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
9930 v2df __builtin_ia32_cmpgepd (v2df, v2df)
9931 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
9932 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
9933 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
9934 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
9935 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
9936 v2df __builtin_ia32_cmpngepd (v2df, v2df)
9937 v2df __builtin_ia32_cmpordpd (v2df, v2df)
9938 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
9939 v2df __builtin_ia32_cmpltsd (v2df, v2df)
9940 v2df __builtin_ia32_cmplesd (v2df, v2df)
9941 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
9942 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
9943 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
9944 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
9945 v2df __builtin_ia32_cmpordsd (v2df, v2df)
9946 v2di __builtin_ia32_paddq (v2di, v2di)
9947 v2di __builtin_ia32_psubq (v2di, v2di)
9948 v2df __builtin_ia32_addpd (v2df, v2df)
9949 v2df __builtin_ia32_subpd (v2df, v2df)
9950 v2df __builtin_ia32_mulpd (v2df, v2df)
9951 v2df __builtin_ia32_divpd (v2df, v2df)
9952 v2df __builtin_ia32_addsd (v2df, v2df)
9953 v2df __builtin_ia32_subsd (v2df, v2df)
9954 v2df __builtin_ia32_mulsd (v2df, v2df)
9955 v2df __builtin_ia32_divsd (v2df, v2df)
9956 v2df __builtin_ia32_minpd (v2df, v2df)
9957 v2df __builtin_ia32_maxpd (v2df, v2df)
9958 v2df __builtin_ia32_minsd (v2df, v2df)
9959 v2df __builtin_ia32_maxsd (v2df, v2df)
9960 v2df __builtin_ia32_andpd (v2df, v2df)
9961 v2df __builtin_ia32_andnpd (v2df, v2df)
9962 v2df __builtin_ia32_orpd (v2df, v2df)
9963 v2df __builtin_ia32_xorpd (v2df, v2df)
9964 v2df __builtin_ia32_movsd (v2df, v2df)
9965 v2df __builtin_ia32_unpckhpd (v2df, v2df)
9966 v2df __builtin_ia32_unpcklpd (v2df, v2df)
9967 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
9968 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
9969 v4si __builtin_ia32_paddd128 (v4si, v4si)
9970 v2di __builtin_ia32_paddq128 (v2di, v2di)
9971 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
9972 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
9973 v4si __builtin_ia32_psubd128 (v4si, v4si)
9974 v2di __builtin_ia32_psubq128 (v2di, v2di)
9975 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
9976 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
9977 v2di __builtin_ia32_pand128 (v2di, v2di)
9978 v2di __builtin_ia32_pandn128 (v2di, v2di)
9979 v2di __builtin_ia32_por128 (v2di, v2di)
9980 v2di __builtin_ia32_pxor128 (v2di, v2di)
9981 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
9982 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
9983 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
9984 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
9985 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
9986 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
9987 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
9988 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
9989 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
9990 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
9991 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
9992 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
9993 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
9994 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
9995 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
9996 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
9997 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
9998 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
9999 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10000 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10001 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10002 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10003 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10004 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10005 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10006 v2df __builtin_ia32_loadupd (double *)
10007 void __builtin_ia32_storeupd (double *, v2df)
10008 v2df __builtin_ia32_loadhpd (v2df, double const *)
10009 v2df __builtin_ia32_loadlpd (v2df, double const *)
10010 int __builtin_ia32_movmskpd (v2df)
10011 int __builtin_ia32_pmovmskb128 (v16qi)
10012 void __builtin_ia32_movnti (int *, int)
10013 void __builtin_ia32_movnti64 (long long int *, long long int)
10014 void __builtin_ia32_movntpd (double *, v2df)
10015 void __builtin_ia32_movntdq (v2df *, v2df)
10016 v4si __builtin_ia32_pshufd (v4si, int)
10017 v8hi __builtin_ia32_pshuflw (v8hi, int)
10018 v8hi __builtin_ia32_pshufhw (v8hi, int)
10019 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10020 v2df __builtin_ia32_sqrtpd (v2df)
10021 v2df __builtin_ia32_sqrtsd (v2df)
10022 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10023 v2df __builtin_ia32_cvtdq2pd (v4si)
10024 v4sf __builtin_ia32_cvtdq2ps (v4si)
10025 v4si __builtin_ia32_cvtpd2dq (v2df)
10026 v2si __builtin_ia32_cvtpd2pi (v2df)
10027 v4sf __builtin_ia32_cvtpd2ps (v2df)
10028 v4si __builtin_ia32_cvttpd2dq (v2df)
10029 v2si __builtin_ia32_cvttpd2pi (v2df)
10030 v2df __builtin_ia32_cvtpi2pd (v2si)
10031 int __builtin_ia32_cvtsd2si (v2df)
10032 int __builtin_ia32_cvttsd2si (v2df)
10033 long long __builtin_ia32_cvtsd2si64 (v2df)
10034 long long __builtin_ia32_cvttsd2si64 (v2df)
10035 v4si __builtin_ia32_cvtps2dq (v4sf)
10036 v2df __builtin_ia32_cvtps2pd (v4sf)
10037 v4si __builtin_ia32_cvttps2dq (v4sf)
10038 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10039 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10040 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10041 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10042 void __builtin_ia32_clflush (const void *)
10043 void __builtin_ia32_lfence (void)
10044 void __builtin_ia32_mfence (void)
10045 v16qi __builtin_ia32_loaddqu (const char *)
10046 void __builtin_ia32_storedqu (char *, v16qi)
10047 v1di __builtin_ia32_pmuludq (v2si, v2si)
10048 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10049 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10050 v4si __builtin_ia32_pslld128 (v4si, v4si)
10051 v2di __builtin_ia32_psllq128 (v2di, v2di)
10052 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10053 v4si __builtin_ia32_psrld128 (v4si, v4si)
10054 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10055 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10056 v4si __builtin_ia32_psrad128 (v4si, v4si)
10057 v2di __builtin_ia32_pslldqi128 (v2di, int)
10058 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10059 v4si __builtin_ia32_pslldi128 (v4si, int)
10060 v2di __builtin_ia32_psllqi128 (v2di, int)
10061 v2di __builtin_ia32_psrldqi128 (v2di, int)
10062 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10063 v4si __builtin_ia32_psrldi128 (v4si, int)
10064 v2di __builtin_ia32_psrlqi128 (v2di, int)
10065 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10066 v4si __builtin_ia32_psradi128 (v4si, int)
10067 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10068 v2di __builtin_ia32_movq128 (v2di)
10069 @end smallexample
10070
10071 The following built-in functions are available when @option{-msse3} is used.
10072 All of them generate the machine instruction that is part of the name.
10073
10074 @smallexample
10075 v2df __builtin_ia32_addsubpd (v2df, v2df)
10076 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10077 v2df __builtin_ia32_haddpd (v2df, v2df)
10078 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10079 v2df __builtin_ia32_hsubpd (v2df, v2df)
10080 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10081 v16qi __builtin_ia32_lddqu (char const *)
10082 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10083 v2df __builtin_ia32_movddup (v2df)
10084 v4sf __builtin_ia32_movshdup (v4sf)
10085 v4sf __builtin_ia32_movsldup (v4sf)
10086 void __builtin_ia32_mwait (unsigned int, unsigned int)
10087 @end smallexample
10088
10089 The following built-in functions are available when @option{-msse3} is used.
10090
10091 @table @code
10092 @item v2df __builtin_ia32_loadddup (double const *)
10093 Generates the @code{movddup} machine instruction as a load from memory.
10094 @end table
10095
10096 The following built-in functions are available when @option{-mssse3} is used.
10097 All of them generate the machine instruction that is part of the name
10098 with MMX registers.
10099
10100 @smallexample
10101 v2si __builtin_ia32_phaddd (v2si, v2si)
10102 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10103 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10104 v2si __builtin_ia32_phsubd (v2si, v2si)
10105 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10106 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10107 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10108 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10109 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10110 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10111 v2si __builtin_ia32_psignd (v2si, v2si)
10112 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10113 v1di __builtin_ia32_palignr (v1di, v1di, int)
10114 v8qi __builtin_ia32_pabsb (v8qi)
10115 v2si __builtin_ia32_pabsd (v2si)
10116 v4hi __builtin_ia32_pabsw (v4hi)
10117 @end smallexample
10118
10119 The following built-in functions are available when @option{-mssse3} is used.
10120 All of them generate the machine instruction that is part of the name
10121 with SSE registers.
10122
10123 @smallexample
10124 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10125 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10126 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10127 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10128 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10129 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10130 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10131 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10132 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10133 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10134 v4si __builtin_ia32_psignd128 (v4si, v4si)
10135 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10136 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10137 v16qi __builtin_ia32_pabsb128 (v16qi)
10138 v4si __builtin_ia32_pabsd128 (v4si)
10139 v8hi __builtin_ia32_pabsw128 (v8hi)
10140 @end smallexample
10141
10142 The following built-in functions are available when @option{-msse4.1} is
10143 used. All of them generate the machine instruction that is part of the
10144 name.
10145
10146 @smallexample
10147 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10148 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10149 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10150 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10151 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10152 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10153 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10154 v2di __builtin_ia32_movntdqa (v2di *);
10155 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10156 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10157 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10158 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10159 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10160 v8hi __builtin_ia32_phminposuw128 (v8hi)
10161 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10162 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10163 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10164 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10165 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10166 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10167 v4si __builtin_ia32_pminud128 (v4si, v4si)
10168 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10169 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10170 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10171 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10172 v2di __builtin_ia32_pmovsxdq128 (v4si)
10173 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10174 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10175 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10176 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10177 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10178 v2di __builtin_ia32_pmovzxdq128 (v4si)
10179 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10180 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10181 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10182 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10183 int __builtin_ia32_ptestc128 (v2di, v2di)
10184 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10185 int __builtin_ia32_ptestz128 (v2di, v2di)
10186 v2df __builtin_ia32_roundpd (v2df, const int)
10187 v4sf __builtin_ia32_roundps (v4sf, const int)
10188 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10189 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10190 @end smallexample
10191
10192 The following built-in functions are available when @option{-msse4.1} is
10193 used.
10194
10195 @table @code
10196 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10197 Generates the @code{insertps} machine instruction.
10198 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10199 Generates the @code{pextrb} machine instruction.
10200 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10201 Generates the @code{pinsrb} machine instruction.
10202 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10203 Generates the @code{pinsrd} machine instruction.
10204 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10205 Generates the @code{pinsrq} machine instruction in 64bit mode.
10206 @end table
10207
10208 The following built-in functions are changed to generate new SSE4.1
10209 instructions when @option{-msse4.1} is used.
10210
10211 @table @code
10212 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10213 Generates the @code{extractps} machine instruction.
10214 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10215 Generates the @code{pextrd} machine instruction.
10216 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10217 Generates the @code{pextrq} machine instruction in 64bit mode.
10218 @end table
10219
10220 The following built-in functions are available when @option{-msse4.2} is
10221 used. All of them generate the machine instruction that is part of the
10222 name.
10223
10224 @smallexample
10225 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10226 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10227 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10228 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10229 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10230 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10231 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10232 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10233 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10234 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10235 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10236 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10237 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10238 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10239 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10240 @end smallexample
10241
10242 The following built-in functions are available when @option{-msse4.2} is
10243 used.
10244
10245 @table @code
10246 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10247 Generates the @code{crc32b} machine instruction.
10248 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10249 Generates the @code{crc32w} machine instruction.
10250 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10251 Generates the @code{crc32l} machine instruction.
10252 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10253 Generates the @code{crc32q} machine instruction.
10254 @end table
10255
10256 The following built-in functions are changed to generate new SSE4.2
10257 instructions when @option{-msse4.2} is used.
10258
10259 @table @code
10260 @item int __builtin_popcount (unsigned int)
10261 Generates the @code{popcntl} machine instruction.
10262 @item int __builtin_popcountl (unsigned long)
10263 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10264 depending on the size of @code{unsigned long}.
10265 @item int __builtin_popcountll (unsigned long long)
10266 Generates the @code{popcntq} machine instruction.
10267 @end table
10268
10269 The following built-in functions are available when @option{-mavx} is
10270 used. All of them generate the machine instruction that is part of the
10271 name.
10272
10273 @smallexample
10274 v4df __builtin_ia32_addpd256 (v4df,v4df)
10275 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10276 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10277 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10278 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10279 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10280 v4df __builtin_ia32_andpd256 (v4df,v4df)
10281 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
10282 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
10283 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
10284 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
10285 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
10286 v2df __builtin_ia32_cmppd (v2df,v2df,int)
10287 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
10288 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
10289 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
10290 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
10291 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
10292 v4df __builtin_ia32_cvtdq2pd256 (v4si)
10293 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
10294 v4si __builtin_ia32_cvtpd2dq256 (v4df)
10295 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
10296 v8si __builtin_ia32_cvtps2dq256 (v8sf)
10297 v4df __builtin_ia32_cvtps2pd256 (v4sf)
10298 v4si __builtin_ia32_cvttpd2dq256 (v4df)
10299 v8si __builtin_ia32_cvttps2dq256 (v8sf)
10300 v4df __builtin_ia32_divpd256 (v4df,v4df)
10301 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
10302 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
10303 v4df __builtin_ia32_haddpd256 (v4df,v4df)
10304 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
10305 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
10306 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
10307 v32qi __builtin_ia32_lddqu256 (pcchar)
10308 v32qi __builtin_ia32_loaddqu256 (pcchar)
10309 v4df __builtin_ia32_loadupd256 (pcdouble)
10310 v8sf __builtin_ia32_loadups256 (pcfloat)
10311 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
10312 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
10313 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
10314 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
10315 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
10316 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
10317 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
10318 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
10319 v4df __builtin_ia32_maxpd256 (v4df,v4df)
10320 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
10321 v4df __builtin_ia32_minpd256 (v4df,v4df)
10322 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
10323 v4df __builtin_ia32_movddup256 (v4df)
10324 int __builtin_ia32_movmskpd256 (v4df)
10325 int __builtin_ia32_movmskps256 (v8sf)
10326 v8sf __builtin_ia32_movshdup256 (v8sf)
10327 v8sf __builtin_ia32_movsldup256 (v8sf)
10328 v4df __builtin_ia32_mulpd256 (v4df,v4df)
10329 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
10330 v4df __builtin_ia32_orpd256 (v4df,v4df)
10331 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
10332 v2df __builtin_ia32_pd_pd256 (v4df)
10333 v4df __builtin_ia32_pd256_pd (v2df)
10334 v4sf __builtin_ia32_ps_ps256 (v8sf)
10335 v8sf __builtin_ia32_ps256_ps (v4sf)
10336 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
10337 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
10338 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
10339 v8sf __builtin_ia32_rcpps256 (v8sf)
10340 v4df __builtin_ia32_roundpd256 (v4df,int)
10341 v8sf __builtin_ia32_roundps256 (v8sf,int)
10342 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
10343 v8sf __builtin_ia32_rsqrtps256 (v8sf)
10344 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
10345 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
10346 v4si __builtin_ia32_si_si256 (v8si)
10347 v8si __builtin_ia32_si256_si (v4si)
10348 v4df __builtin_ia32_sqrtpd256 (v4df)
10349 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
10350 v8sf __builtin_ia32_sqrtps256 (v8sf)
10351 void __builtin_ia32_storedqu256 (pchar,v32qi)
10352 void __builtin_ia32_storeupd256 (pdouble,v4df)
10353 void __builtin_ia32_storeups256 (pfloat,v8sf)
10354 v4df __builtin_ia32_subpd256 (v4df,v4df)
10355 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
10356 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
10357 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
10358 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
10359 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
10360 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
10361 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
10362 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
10363 v4sf __builtin_ia32_vbroadcastss (pcfloat)
10364 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
10365 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
10366 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
10367 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
10368 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
10369 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
10370 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
10371 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
10372 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
10373 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
10374 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
10375 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
10376 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
10377 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
10378 v2df __builtin_ia32_vpermilpd (v2df,int)
10379 v4df __builtin_ia32_vpermilpd256 (v4df,int)
10380 v4sf __builtin_ia32_vpermilps (v4sf,int)
10381 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
10382 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
10383 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
10384 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
10385 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
10386 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
10387 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
10388 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
10389 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
10390 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
10391 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
10392 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
10393 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
10394 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
10395 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
10396 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
10397 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
10398 void __builtin_ia32_vzeroall (void)
10399 void __builtin_ia32_vzeroupper (void)
10400 v4df __builtin_ia32_xorpd256 (v4df,v4df)
10401 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
10402 @end smallexample
10403
10404 The following built-in functions are available when @option{-mavx2} is
10405 used. All of them generate the machine instruction that is part of the
10406 name.
10407
10408 @smallexample
10409 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
10410 v32qi __builtin_ia32_pabsb256 (v32qi)
10411 v16hi __builtin_ia32_pabsw256 (v16hi)
10412 v8si __builtin_ia32_pabsd256 (v8si)
10413 v16hi builtin_ia32_packssdw256 (v8si,v8si)
10414 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
10415 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
10416 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
10417 v32qi__builtin_ia32_paddb256 (v32qi,v32qi)
10418 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
10419 v8si __builtin_ia32_paddd256 (v8si,v8si)
10420 v4di __builtin_ia32_paddq256 (v4di,v4di)
10421 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
10422 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
10423 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
10424 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
10425 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
10426 v4di __builtin_ia32_andsi256 (v4di,v4di)
10427 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
10428 v32qi__builtin_ia32_pavgb256 (v32qi,v32qi)
10429 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
10430 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
10431 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
10432 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
10433 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
10434 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
10435 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
10436 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
10437 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
10438 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
10439 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
10440 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
10441 v8si __builtin_ia32_phaddd256 (v8si,v8si)
10442 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
10443 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
10444 v8si __builtin_ia32_phsubd256 (v8si,v8si)
10445 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
10446 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
10447 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
10448 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
10449 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
10450 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
10451 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
10452 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
10453 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
10454 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
10455 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
10456 v8si __builtin_ia32_pminsd256 (v8si,v8si)
10457 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
10458 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
10459 v8si __builtin_ia32_pminud256 (v8si,v8si)
10460 int __builtin_ia32_pmovmskb256 (v32qi)
10461 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
10462 v8si __builtin_ia32_pmovsxbd256 (v16qi)
10463 v4di __builtin_ia32_pmovsxbq256 (v16qi)
10464 v8si __builtin_ia32_pmovsxwd256 (v8hi)
10465 v4di __builtin_ia32_pmovsxwq256 (v8hi)
10466 v4di __builtin_ia32_pmovsxdq256 (v4si)
10467 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
10468 v8si __builtin_ia32_pmovzxbd256 (v16qi)
10469 v4di __builtin_ia32_pmovzxbq256 (v16qi)
10470 v8si __builtin_ia32_pmovzxwd256 (v8hi)
10471 v4di __builtin_ia32_pmovzxwq256 (v8hi)
10472 v4di __builtin_ia32_pmovzxdq256 (v4si)
10473 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
10474 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
10475 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
10476 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
10477 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
10478 v8si __builtin_ia32_pmulld256 (v8si,v8si)
10479 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
10480 v4di __builtin_ia32_por256 (v4di,v4di)
10481 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
10482 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
10483 v8si __builtin_ia32_pshufd256 (v8si,int)
10484 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
10485 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
10486 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
10487 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
10488 v8si __builtin_ia32_psignd256 (v8si,v8si)
10489 v4di __builtin_ia32_pslldqi256 (v4di,int)
10490 v16hi __builtin_ia32_psllwi256 (16hi,int)
10491 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
10492 v8si __builtin_ia32_pslldi256 (v8si,int)
10493 v8si __builtin_ia32_pslld256(v8si,v4si)
10494 v4di __builtin_ia32_psllqi256 (v4di,int)
10495 v4di __builtin_ia32_psllq256(v4di,v2di)
10496 v16hi __builtin_ia32_psrawi256 (v16hi,int)
10497 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
10498 v8si __builtin_ia32_psradi256 (v8si,int)
10499 v8si __builtin_ia32_psrad256 (v8si,v4si)
10500 v4di __builtin_ia32_psrldqi256 (v4di, int)
10501 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
10502 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
10503 v8si __builtin_ia32_psrldi256 (v8si,int)
10504 v8si __builtin_ia32_psrld256 (v8si,v4si)
10505 v4di __builtin_ia32_psrlqi256 (v4di,int)
10506 v4di __builtin_ia32_psrlq256(v4di,v2di)
10507 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
10508 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
10509 v8si __builtin_ia32_psubd256 (v8si,v8si)
10510 v4di __builtin_ia32_psubq256 (v4di,v4di)
10511 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
10512 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
10513 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
10514 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
10515 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
10516 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
10517 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
10518 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
10519 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
10520 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
10521 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
10522 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
10523 v4di __builtin_ia32_pxor256 (v4di,v4di)
10524 v4di __builtin_ia32_movntdqa256 (pv4di)
10525 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
10526 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
10527 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
10528 v4di __builtin_ia32_vbroadcastsi256 (v2di)
10529 v4si __builtin_ia32_pblendd128 (v4si,v4si)
10530 v8si __builtin_ia32_pblendd256 (v8si,v8si)
10531 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
10532 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
10533 v8si __builtin_ia32_pbroadcastd256 (v4si)
10534 v4di __builtin_ia32_pbroadcastq256 (v2di)
10535 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
10536 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
10537 v4si __builtin_ia32_pbroadcastd128 (v4si)
10538 v2di __builtin_ia32_pbroadcastq128 (v2di)
10539 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
10540 v4df __builtin_ia32_permdf256 (v4df,int)
10541 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
10542 v4di __builtin_ia32_permdi256 (v4di,int)
10543 v4di __builtin_ia32_permti256 (v4di,v4di,int)
10544 v4di __builtin_ia32_extract128i256 (v4di,int)
10545 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
10546 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
10547 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
10548 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
10549 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
10550 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
10551 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
10552 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
10553 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
10554 v8si __builtin_ia32_psllv8si (v8si,v8si)
10555 v4si __builtin_ia32_psllv4si (v4si,v4si)
10556 v4di __builtin_ia32_psllv4di (v4di,v4di)
10557 v2di __builtin_ia32_psllv2di (v2di,v2di)
10558 v8si __builtin_ia32_psrav8si (v8si,v8si)
10559 v4si __builtin_ia32_psrav4si (v4si,v4si)
10560 v8si __builtin_ia32_psrlv8si (v8si,v8si)
10561 v4si __builtin_ia32_psrlv4si (v4si,v4si)
10562 v4di __builtin_ia32_psrlv4di (v4di,v4di)
10563 v2di __builtin_ia32_psrlv2di (v2di,v2di)
10564 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
10565 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
10566 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
10567 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
10568 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
10569 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
10570 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
10571 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
10572 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
10573 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
10574 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
10575 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
10576 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
10577 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
10578 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
10579 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
10580 @end smallexample
10581
10582 The following built-in functions are available when @option{-maes} is
10583 used. All of them generate the machine instruction that is part of the
10584 name.
10585
10586 @smallexample
10587 v2di __builtin_ia32_aesenc128 (v2di, v2di)
10588 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
10589 v2di __builtin_ia32_aesdec128 (v2di, v2di)
10590 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
10591 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
10592 v2di __builtin_ia32_aesimc128 (v2di)
10593 @end smallexample
10594
10595 The following built-in function is available when @option{-mpclmul} is
10596 used.
10597
10598 @table @code
10599 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
10600 Generates the @code{pclmulqdq} machine instruction.
10601 @end table
10602
10603 The following built-in function is available when @option{-mfsgsbase} is
10604 used. All of them generate the machine instruction that is part of the
10605 name.
10606
10607 @smallexample
10608 unsigned int __builtin_ia32_rdfsbase32 (void)
10609 unsigned long long __builtin_ia32_rdfsbase64 (void)
10610 unsigned int __builtin_ia32_rdgsbase32 (void)
10611 unsigned long long __builtin_ia32_rdgsbase64 (void)
10612 void _writefsbase_u32 (unsigned int)
10613 void _writefsbase_u64 (unsigned long long)
10614 void _writegsbase_u32 (unsigned int)
10615 void _writegsbase_u64 (unsigned long long)
10616 @end smallexample
10617
10618 The following built-in function is available when @option{-mrdrnd} is
10619 used. All of them generate the machine instruction that is part of the
10620 name.
10621
10622 @smallexample
10623 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
10624 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
10625 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
10626 @end smallexample
10627
10628 The following built-in functions are available when @option{-msse4a} is used.
10629 All of them generate the machine instruction that is part of the name.
10630
10631 @smallexample
10632 void __builtin_ia32_movntsd (double *, v2df)
10633 void __builtin_ia32_movntss (float *, v4sf)
10634 v2di __builtin_ia32_extrq (v2di, v16qi)
10635 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
10636 v2di __builtin_ia32_insertq (v2di, v2di)
10637 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
10638 @end smallexample
10639
10640 The following built-in functions are available when @option{-mxop} is used.
10641 @smallexample
10642 v2df __builtin_ia32_vfrczpd (v2df)
10643 v4sf __builtin_ia32_vfrczps (v4sf)
10644 v2df __builtin_ia32_vfrczsd (v2df, v2df)
10645 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
10646 v4df __builtin_ia32_vfrczpd256 (v4df)
10647 v8sf __builtin_ia32_vfrczps256 (v8sf)
10648 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
10649 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
10650 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
10651 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
10652 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
10653 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
10654 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
10655 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
10656 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
10657 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
10658 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
10659 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
10660 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
10661 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
10662 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10663 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
10664 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
10665 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
10666 v4si __builtin_ia32_vpcomequd (v4si, v4si)
10667 v2di __builtin_ia32_vpcomequq (v2di, v2di)
10668 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
10669 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10670 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
10671 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
10672 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
10673 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
10674 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
10675 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
10676 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
10677 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
10678 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
10679 v4si __builtin_ia32_vpcomged (v4si, v4si)
10680 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
10681 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
10682 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
10683 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
10684 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
10685 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
10686 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
10687 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
10688 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
10689 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
10690 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
10691 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
10692 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
10693 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
10694 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
10695 v4si __builtin_ia32_vpcomled (v4si, v4si)
10696 v2di __builtin_ia32_vpcomleq (v2di, v2di)
10697 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
10698 v4si __builtin_ia32_vpcomleud (v4si, v4si)
10699 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
10700 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
10701 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
10702 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
10703 v4si __builtin_ia32_vpcomltd (v4si, v4si)
10704 v2di __builtin_ia32_vpcomltq (v2di, v2di)
10705 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
10706 v4si __builtin_ia32_vpcomltud (v4si, v4si)
10707 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
10708 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
10709 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
10710 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
10711 v4si __builtin_ia32_vpcomned (v4si, v4si)
10712 v2di __builtin_ia32_vpcomneq (v2di, v2di)
10713 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
10714 v4si __builtin_ia32_vpcomneud (v4si, v4si)
10715 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
10716 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
10717 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
10718 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
10719 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
10720 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
10721 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
10722 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
10723 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
10724 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
10725 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
10726 v4si __builtin_ia32_vphaddbd (v16qi)
10727 v2di __builtin_ia32_vphaddbq (v16qi)
10728 v8hi __builtin_ia32_vphaddbw (v16qi)
10729 v2di __builtin_ia32_vphadddq (v4si)
10730 v4si __builtin_ia32_vphaddubd (v16qi)
10731 v2di __builtin_ia32_vphaddubq (v16qi)
10732 v8hi __builtin_ia32_vphaddubw (v16qi)
10733 v2di __builtin_ia32_vphaddudq (v4si)
10734 v4si __builtin_ia32_vphadduwd (v8hi)
10735 v2di __builtin_ia32_vphadduwq (v8hi)
10736 v4si __builtin_ia32_vphaddwd (v8hi)
10737 v2di __builtin_ia32_vphaddwq (v8hi)
10738 v8hi __builtin_ia32_vphsubbw (v16qi)
10739 v2di __builtin_ia32_vphsubdq (v4si)
10740 v4si __builtin_ia32_vphsubwd (v8hi)
10741 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
10742 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
10743 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
10744 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
10745 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
10746 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
10747 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
10748 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
10749 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
10750 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
10751 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
10752 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
10753 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
10754 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
10755 v4si __builtin_ia32_vprotd (v4si, v4si)
10756 v2di __builtin_ia32_vprotq (v2di, v2di)
10757 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
10758 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
10759 v4si __builtin_ia32_vpshad (v4si, v4si)
10760 v2di __builtin_ia32_vpshaq (v2di, v2di)
10761 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
10762 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
10763 v4si __builtin_ia32_vpshld (v4si, v4si)
10764 v2di __builtin_ia32_vpshlq (v2di, v2di)
10765 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
10766 @end smallexample
10767
10768 The following built-in functions are available when @option{-mfma4} is used.
10769 All of them generate the machine instruction that is part of the name
10770 with MMX registers.
10771
10772 @smallexample
10773 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
10774 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
10775 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
10776 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
10777 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
10778 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
10779 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
10780 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
10781 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
10782 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
10783 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
10784 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
10785 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
10786 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
10787 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
10788 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
10789 v2df __builtin_ia32_fmaddsubpd (v2df, v2df, v2df)
10790 v4sf __builtin_ia32_fmaddsubps (v4sf, v4sf, v4sf)
10791 v2df __builtin_ia32_fmsubaddpd (v2df, v2df, v2df)
10792 v4sf __builtin_ia32_fmsubaddps (v4sf, v4sf, v4sf)
10793 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
10794 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
10795 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
10796 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
10797 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
10798 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
10799 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
10800 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
10801 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
10802 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
10803 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
10804 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
10805
10806 @end smallexample
10807
10808 The following built-in functions are available when @option{-mlwp} is used.
10809
10810 @smallexample
10811 void __builtin_ia32_llwpcb16 (void *);
10812 void __builtin_ia32_llwpcb32 (void *);
10813 void __builtin_ia32_llwpcb64 (void *);
10814 void * __builtin_ia32_llwpcb16 (void);
10815 void * __builtin_ia32_llwpcb32 (void);
10816 void * __builtin_ia32_llwpcb64 (void);
10817 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
10818 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
10819 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
10820 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
10821 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
10822 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
10823 @end smallexample
10824
10825 The following built-in functions are available when @option{-mbmi} is used.
10826 All of them generate the machine instruction that is part of the name.
10827 @smallexample
10828 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
10829 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
10830 @end smallexample
10831
10832 The following built-in functions are available when @option{-mbmi2} is used.
10833 All of them generate the machine instruction that is part of the name.
10834 @smallexample
10835 unsigned int _bzhi_u32 (unsigned int, unsigned int)
10836 unsigned int _pdep_u32 (unsigned int, unsigned int)
10837 unsigned int _pext_u32 (unsigned int, unsigned int)
10838 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
10839 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
10840 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
10841 @end smallexample
10842
10843 The following built-in functions are available when @option{-mlzcnt} is used.
10844 All of them generate the machine instruction that is part of the name.
10845 @smallexample
10846 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
10847 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
10848 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
10849 @end smallexample
10850
10851 The following built-in functions are available when @option{-mtbm} is used.
10852 Both of them generate the immediate form of the bextr machine instruction.
10853 @smallexample
10854 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
10855 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
10856 @end smallexample
10857
10858
10859 The following built-in functions are available when @option{-m3dnow} is used.
10860 All of them generate the machine instruction that is part of the name.
10861
10862 @smallexample
10863 void __builtin_ia32_femms (void)
10864 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
10865 v2si __builtin_ia32_pf2id (v2sf)
10866 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
10867 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
10868 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
10869 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
10870 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
10871 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
10872 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
10873 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
10874 v2sf __builtin_ia32_pfrcp (v2sf)
10875 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
10876 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
10877 v2sf __builtin_ia32_pfrsqrt (v2sf)
10878 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
10879 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
10880 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
10881 v2sf __builtin_ia32_pi2fd (v2si)
10882 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
10883 @end smallexample
10884
10885 The following built-in functions are available when both @option{-m3dnow}
10886 and @option{-march=athlon} are used. All of them generate the machine
10887 instruction that is part of the name.
10888
10889 @smallexample
10890 v2si __builtin_ia32_pf2iw (v2sf)
10891 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
10892 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
10893 v2sf __builtin_ia32_pi2fw (v2si)
10894 v2sf __builtin_ia32_pswapdsf (v2sf)
10895 v2si __builtin_ia32_pswapdsi (v2si)
10896 @end smallexample
10897
10898 @node MIPS DSP Built-in Functions
10899 @subsection MIPS DSP Built-in Functions
10900
10901 The MIPS DSP Application-Specific Extension (ASE) includes new
10902 instructions that are designed to improve the performance of DSP and
10903 media applications. It provides instructions that operate on packed
10904 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
10905
10906 GCC supports MIPS DSP operations using both the generic
10907 vector extensions (@pxref{Vector Extensions}) and a collection of
10908 MIPS-specific built-in functions. Both kinds of support are
10909 enabled by the @option{-mdsp} command-line option.
10910
10911 Revision 2 of the ASE was introduced in the second half of 2006.
10912 This revision adds extra instructions to the original ASE, but is
10913 otherwise backwards-compatible with it. You can select revision 2
10914 using the command-line option @option{-mdspr2}; this option implies
10915 @option{-mdsp}.
10916
10917 The SCOUNT and POS bits of the DSP control register are global. The
10918 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
10919 POS bits. During optimization, the compiler does not delete these
10920 instructions and it does not delete calls to functions containing
10921 these instructions.
10922
10923 At present, GCC only provides support for operations on 32-bit
10924 vectors. The vector type associated with 8-bit integer data is
10925 usually called @code{v4i8}, the vector type associated with Q7
10926 is usually called @code{v4q7}, the vector type associated with 16-bit
10927 integer data is usually called @code{v2i16}, and the vector type
10928 associated with Q15 is usually called @code{v2q15}. They can be
10929 defined in C as follows:
10930
10931 @smallexample
10932 typedef signed char v4i8 __attribute__ ((vector_size(4)));
10933 typedef signed char v4q7 __attribute__ ((vector_size(4)));
10934 typedef short v2i16 __attribute__ ((vector_size(4)));
10935 typedef short v2q15 __attribute__ ((vector_size(4)));
10936 @end smallexample
10937
10938 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
10939 initialized in the same way as aggregates. For example:
10940
10941 @smallexample
10942 v4i8 a = @{1, 2, 3, 4@};
10943 v4i8 b;
10944 b = (v4i8) @{5, 6, 7, 8@};
10945
10946 v2q15 c = @{0x0fcb, 0x3a75@};
10947 v2q15 d;
10948 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
10949 @end smallexample
10950
10951 @emph{Note:} The CPU's endianness determines the order in which values
10952 are packed. On little-endian targets, the first value is the least
10953 significant and the last value is the most significant. The opposite
10954 order applies to big-endian targets. For example, the code above
10955 sets the lowest byte of @code{a} to @code{1} on little-endian targets
10956 and @code{4} on big-endian targets.
10957
10958 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
10959 representation. As shown in this example, the integer representation
10960 of a Q7 value can be obtained by multiplying the fractional value by
10961 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
10962 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
10963 @code{0x1.0p31}.
10964
10965 The table below lists the @code{v4i8} and @code{v2q15} operations for which
10966 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
10967 and @code{c} and @code{d} are @code{v2q15} values.
10968
10969 @multitable @columnfractions .50 .50
10970 @item C code @tab MIPS instruction
10971 @item @code{a + b} @tab @code{addu.qb}
10972 @item @code{c + d} @tab @code{addq.ph}
10973 @item @code{a - b} @tab @code{subu.qb}
10974 @item @code{c - d} @tab @code{subq.ph}
10975 @end multitable
10976
10977 The table below lists the @code{v2i16} operation for which
10978 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
10979 @code{v2i16} values.
10980
10981 @multitable @columnfractions .50 .50
10982 @item C code @tab MIPS instruction
10983 @item @code{e * f} @tab @code{mul.ph}
10984 @end multitable
10985
10986 It is easier to describe the DSP built-in functions if we first define
10987 the following types:
10988
10989 @smallexample
10990 typedef int q31;
10991 typedef int i32;
10992 typedef unsigned int ui32;
10993 typedef long long a64;
10994 @end smallexample
10995
10996 @code{q31} and @code{i32} are actually the same as @code{int}, but we
10997 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
10998 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
10999 @code{long long}, but we use @code{a64} to indicate values that are
11000 placed in one of the four DSP accumulators (@code{$ac0},
11001 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11002
11003 Also, some built-in functions prefer or require immediate numbers as
11004 parameters, because the corresponding DSP instructions accept both immediate
11005 numbers and register operands, or accept immediate numbers only. The
11006 immediate parameters are listed as follows.
11007
11008 @smallexample
11009 imm0_3: 0 to 3.
11010 imm0_7: 0 to 7.
11011 imm0_15: 0 to 15.
11012 imm0_31: 0 to 31.
11013 imm0_63: 0 to 63.
11014 imm0_255: 0 to 255.
11015 imm_n32_31: -32 to 31.
11016 imm_n512_511: -512 to 511.
11017 @end smallexample
11018
11019 The following built-in functions map directly to a particular MIPS DSP
11020 instruction. Please refer to the architecture specification
11021 for details on what each instruction does.
11022
11023 @smallexample
11024 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11025 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11026 q31 __builtin_mips_addq_s_w (q31, q31)
11027 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11028 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11029 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11030 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11031 q31 __builtin_mips_subq_s_w (q31, q31)
11032 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11033 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11034 i32 __builtin_mips_addsc (i32, i32)
11035 i32 __builtin_mips_addwc (i32, i32)
11036 i32 __builtin_mips_modsub (i32, i32)
11037 i32 __builtin_mips_raddu_w_qb (v4i8)
11038 v2q15 __builtin_mips_absq_s_ph (v2q15)
11039 q31 __builtin_mips_absq_s_w (q31)
11040 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11041 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11042 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11043 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11044 q31 __builtin_mips_preceq_w_phl (v2q15)
11045 q31 __builtin_mips_preceq_w_phr (v2q15)
11046 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11047 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11048 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11049 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11050 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11051 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11052 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11053 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11054 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11055 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11056 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11057 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11058 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11059 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11060 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11061 q31 __builtin_mips_shll_s_w (q31, i32)
11062 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11063 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11064 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11065 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11066 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11067 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11068 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11069 q31 __builtin_mips_shra_r_w (q31, i32)
11070 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11071 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11072 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11073 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11074 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11075 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11076 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11077 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11078 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11079 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11080 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11081 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11082 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11083 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11084 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11085 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11086 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11087 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11088 i32 __builtin_mips_bitrev (i32)
11089 i32 __builtin_mips_insv (i32, i32)
11090 v4i8 __builtin_mips_repl_qb (imm0_255)
11091 v4i8 __builtin_mips_repl_qb (i32)
11092 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11093 v2q15 __builtin_mips_repl_ph (i32)
11094 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11095 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11096 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11097 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11098 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11099 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11100 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11101 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11102 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11103 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11104 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11105 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11106 i32 __builtin_mips_extr_w (a64, imm0_31)
11107 i32 __builtin_mips_extr_w (a64, i32)
11108 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11109 i32 __builtin_mips_extr_s_h (a64, i32)
11110 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11111 i32 __builtin_mips_extr_rs_w (a64, i32)
11112 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11113 i32 __builtin_mips_extr_r_w (a64, i32)
11114 i32 __builtin_mips_extp (a64, imm0_31)
11115 i32 __builtin_mips_extp (a64, i32)
11116 i32 __builtin_mips_extpdp (a64, imm0_31)
11117 i32 __builtin_mips_extpdp (a64, i32)
11118 a64 __builtin_mips_shilo (a64, imm_n32_31)
11119 a64 __builtin_mips_shilo (a64, i32)
11120 a64 __builtin_mips_mthlip (a64, i32)
11121 void __builtin_mips_wrdsp (i32, imm0_63)
11122 i32 __builtin_mips_rddsp (imm0_63)
11123 i32 __builtin_mips_lbux (void *, i32)
11124 i32 __builtin_mips_lhx (void *, i32)
11125 i32 __builtin_mips_lwx (void *, i32)
11126 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11127 i32 __builtin_mips_bposge32 (void)
11128 a64 __builtin_mips_madd (a64, i32, i32);
11129 a64 __builtin_mips_maddu (a64, ui32, ui32);
11130 a64 __builtin_mips_msub (a64, i32, i32);
11131 a64 __builtin_mips_msubu (a64, ui32, ui32);
11132 a64 __builtin_mips_mult (i32, i32);
11133 a64 __builtin_mips_multu (ui32, ui32);
11134 @end smallexample
11135
11136 The following built-in functions map directly to a particular MIPS DSP REV 2
11137 instruction. Please refer to the architecture specification
11138 for details on what each instruction does.
11139
11140 @smallexample
11141 v4q7 __builtin_mips_absq_s_qb (v4q7);
11142 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11143 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11144 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11145 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11146 i32 __builtin_mips_append (i32, i32, imm0_31);
11147 i32 __builtin_mips_balign (i32, i32, imm0_3);
11148 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11149 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11150 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11151 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11152 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11153 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11154 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11155 q31 __builtin_mips_mulq_rs_w (q31, q31);
11156 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11157 q31 __builtin_mips_mulq_s_w (q31, q31);
11158 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11159 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11160 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11161 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11162 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11163 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11164 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11165 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11166 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11167 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11168 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11169 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11170 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11171 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11172 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11173 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11174 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11175 q31 __builtin_mips_addqh_w (q31, q31);
11176 q31 __builtin_mips_addqh_r_w (q31, q31);
11177 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11178 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11179 q31 __builtin_mips_subqh_w (q31, q31);
11180 q31 __builtin_mips_subqh_r_w (q31, q31);
11181 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11182 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11183 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11184 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11185 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11186 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11187 @end smallexample
11188
11189
11190 @node MIPS Paired-Single Support
11191 @subsection MIPS Paired-Single Support
11192
11193 The MIPS64 architecture includes a number of instructions that
11194 operate on pairs of single-precision floating-point values.
11195 Each pair is packed into a 64-bit floating-point register,
11196 with one element being designated the ``upper half'' and
11197 the other being designated the ``lower half''.
11198
11199 GCC supports paired-single operations using both the generic
11200 vector extensions (@pxref{Vector Extensions}) and a collection of
11201 MIPS-specific built-in functions. Both kinds of support are
11202 enabled by the @option{-mpaired-single} command-line option.
11203
11204 The vector type associated with paired-single values is usually
11205 called @code{v2sf}. It can be defined in C as follows:
11206
11207 @smallexample
11208 typedef float v2sf __attribute__ ((vector_size (8)));
11209 @end smallexample
11210
11211 @code{v2sf} values are initialized in the same way as aggregates.
11212 For example:
11213
11214 @smallexample
11215 v2sf a = @{1.5, 9.1@};
11216 v2sf b;
11217 float e, f;
11218 b = (v2sf) @{e, f@};
11219 @end smallexample
11220
11221 @emph{Note:} The CPU's endianness determines which value is stored in
11222 the upper half of a register and which value is stored in the lower half.
11223 On little-endian targets, the first value is the lower one and the second
11224 value is the upper one. The opposite order applies to big-endian targets.
11225 For example, the code above sets the lower half of @code{a} to
11226 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11227
11228 @node MIPS Loongson Built-in Functions
11229 @subsection MIPS Loongson Built-in Functions
11230
11231 GCC provides intrinsics to access the SIMD instructions provided by the
11232 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
11233 available after inclusion of the @code{loongson.h} header file,
11234 operate on the following 64-bit vector types:
11235
11236 @itemize
11237 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11238 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11239 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11240 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11241 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11242 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11243 @end itemize
11244
11245 The intrinsics provided are listed below; each is named after the
11246 machine instruction to which it corresponds, with suffixes added as
11247 appropriate to distinguish intrinsics that expand to the same machine
11248 instruction yet have different argument types. Refer to the architecture
11249 documentation for a description of the functionality of each
11250 instruction.
11251
11252 @smallexample
11253 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11254 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11255 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11256 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11257 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11258 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11259 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11260 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11261 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11262 uint64_t paddd_u (uint64_t s, uint64_t t);
11263 int64_t paddd_s (int64_t s, int64_t t);
11264 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11265 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11266 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11267 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11268 uint64_t pandn_ud (uint64_t s, uint64_t t);
11269 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11270 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11271 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11272 int64_t pandn_sd (int64_t s, int64_t t);
11273 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11274 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11275 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11276 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11277 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11278 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11279 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11280 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11281 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11282 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11283 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11284 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11285 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11286 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11287 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11288 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11289 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11290 uint16x4_t pextrh_u (uint16x4_t s, int field);
11291 int16x4_t pextrh_s (int16x4_t s, int field);
11292 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11293 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11294 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11295 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11296 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11297 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11298 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11299 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11300 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11301 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11302 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11303 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11304 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11305 uint8x8_t pmovmskb_u (uint8x8_t s);
11306 int8x8_t pmovmskb_s (int8x8_t s);
11307 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11308 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11309 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11310 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11311 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11312 uint16x4_t biadd (uint8x8_t s);
11313 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11314 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11315 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11316 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11317 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11318 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11319 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11320 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11321 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
11322 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
11323 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
11324 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
11325 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
11326 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
11327 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
11328 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
11329 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
11330 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
11331 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
11332 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
11333 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
11334 uint64_t psubd_u (uint64_t s, uint64_t t);
11335 int64_t psubd_s (int64_t s, int64_t t);
11336 int16x4_t psubsh (int16x4_t s, int16x4_t t);
11337 int8x8_t psubsb (int8x8_t s, int8x8_t t);
11338 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
11339 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
11340 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
11341 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
11342 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
11343 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
11344 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
11345 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
11346 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
11347 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
11348 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
11349 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
11350 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
11351 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
11352 @end smallexample
11353
11354 @menu
11355 * Paired-Single Arithmetic::
11356 * Paired-Single Built-in Functions::
11357 * MIPS-3D Built-in Functions::
11358 @end menu
11359
11360 @node Paired-Single Arithmetic
11361 @subsubsection Paired-Single Arithmetic
11362
11363 The table below lists the @code{v2sf} operations for which hardware
11364 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
11365 values and @code{x} is an integral value.
11366
11367 @multitable @columnfractions .50 .50
11368 @item C code @tab MIPS instruction
11369 @item @code{a + b} @tab @code{add.ps}
11370 @item @code{a - b} @tab @code{sub.ps}
11371 @item @code{-a} @tab @code{neg.ps}
11372 @item @code{a * b} @tab @code{mul.ps}
11373 @item @code{a * b + c} @tab @code{madd.ps}
11374 @item @code{a * b - c} @tab @code{msub.ps}
11375 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
11376 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
11377 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
11378 @end multitable
11379
11380 Note that the multiply-accumulate instructions can be disabled
11381 using the command-line option @code{-mno-fused-madd}.
11382
11383 @node Paired-Single Built-in Functions
11384 @subsubsection Paired-Single Built-in Functions
11385
11386 The following paired-single functions map directly to a particular
11387 MIPS instruction. Please refer to the architecture specification
11388 for details on what each instruction does.
11389
11390 @table @code
11391 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
11392 Pair lower lower (@code{pll.ps}).
11393
11394 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
11395 Pair upper lower (@code{pul.ps}).
11396
11397 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
11398 Pair lower upper (@code{plu.ps}).
11399
11400 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
11401 Pair upper upper (@code{puu.ps}).
11402
11403 @item v2sf __builtin_mips_cvt_ps_s (float, float)
11404 Convert pair to paired single (@code{cvt.ps.s}).
11405
11406 @item float __builtin_mips_cvt_s_pl (v2sf)
11407 Convert pair lower to single (@code{cvt.s.pl}).
11408
11409 @item float __builtin_mips_cvt_s_pu (v2sf)
11410 Convert pair upper to single (@code{cvt.s.pu}).
11411
11412 @item v2sf __builtin_mips_abs_ps (v2sf)
11413 Absolute value (@code{abs.ps}).
11414
11415 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
11416 Align variable (@code{alnv.ps}).
11417
11418 @emph{Note:} The value of the third parameter must be 0 or 4
11419 modulo 8, otherwise the result is unpredictable. Please read the
11420 instruction description for details.
11421 @end table
11422
11423 The following multi-instruction functions are also available.
11424 In each case, @var{cond} can be any of the 16 floating-point conditions:
11425 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11426 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
11427 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11428
11429 @table @code
11430 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11431 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11432 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
11433 @code{movt.ps}/@code{movf.ps}).
11434
11435 The @code{movt} functions return the value @var{x} computed by:
11436
11437 @smallexample
11438 c.@var{cond}.ps @var{cc},@var{a},@var{b}
11439 mov.ps @var{x},@var{c}
11440 movt.ps @var{x},@var{d},@var{cc}
11441 @end smallexample
11442
11443 The @code{movf} functions are similar but use @code{movf.ps} instead
11444 of @code{movt.ps}.
11445
11446 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11447 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11448 Comparison of two paired-single values (@code{c.@var{cond}.ps},
11449 @code{bc1t}/@code{bc1f}).
11450
11451 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11452 and return either the upper or lower half of the result. For example:
11453
11454 @smallexample
11455 v2sf a, b;
11456 if (__builtin_mips_upper_c_eq_ps (a, b))
11457 upper_halves_are_equal ();
11458 else
11459 upper_halves_are_unequal ();
11460
11461 if (__builtin_mips_lower_c_eq_ps (a, b))
11462 lower_halves_are_equal ();
11463 else
11464 lower_halves_are_unequal ();
11465 @end smallexample
11466 @end table
11467
11468 @node MIPS-3D Built-in Functions
11469 @subsubsection MIPS-3D Built-in Functions
11470
11471 The MIPS-3D Application-Specific Extension (ASE) includes additional
11472 paired-single instructions that are designed to improve the performance
11473 of 3D graphics operations. Support for these instructions is controlled
11474 by the @option{-mips3d} command-line option.
11475
11476 The functions listed below map directly to a particular MIPS-3D
11477 instruction. Please refer to the architecture specification for
11478 more details on what each instruction does.
11479
11480 @table @code
11481 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
11482 Reduction add (@code{addr.ps}).
11483
11484 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
11485 Reduction multiply (@code{mulr.ps}).
11486
11487 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
11488 Convert paired single to paired word (@code{cvt.pw.ps}).
11489
11490 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
11491 Convert paired word to paired single (@code{cvt.ps.pw}).
11492
11493 @item float __builtin_mips_recip1_s (float)
11494 @itemx double __builtin_mips_recip1_d (double)
11495 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
11496 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
11497
11498 @item float __builtin_mips_recip2_s (float, float)
11499 @itemx double __builtin_mips_recip2_d (double, double)
11500 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
11501 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
11502
11503 @item float __builtin_mips_rsqrt1_s (float)
11504 @itemx double __builtin_mips_rsqrt1_d (double)
11505 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
11506 Reduced-precision reciprocal square root (sequence step 1)
11507 (@code{rsqrt1.@var{fmt}}).
11508
11509 @item float __builtin_mips_rsqrt2_s (float, float)
11510 @itemx double __builtin_mips_rsqrt2_d (double, double)
11511 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
11512 Reduced-precision reciprocal square root (sequence step 2)
11513 (@code{rsqrt2.@var{fmt}}).
11514 @end table
11515
11516 The following multi-instruction functions are also available.
11517 In each case, @var{cond} can be any of the 16 floating-point conditions:
11518 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11519 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
11520 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11521
11522 @table @code
11523 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
11524 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
11525 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
11526 @code{bc1t}/@code{bc1f}).
11527
11528 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
11529 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
11530 For example:
11531
11532 @smallexample
11533 float a, b;
11534 if (__builtin_mips_cabs_eq_s (a, b))
11535 true ();
11536 else
11537 false ();
11538 @end smallexample
11539
11540 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11541 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11542 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
11543 @code{bc1t}/@code{bc1f}).
11544
11545 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
11546 and return either the upper or lower half of the result. For example:
11547
11548 @smallexample
11549 v2sf a, b;
11550 if (__builtin_mips_upper_cabs_eq_ps (a, b))
11551 upper_halves_are_equal ();
11552 else
11553 upper_halves_are_unequal ();
11554
11555 if (__builtin_mips_lower_cabs_eq_ps (a, b))
11556 lower_halves_are_equal ();
11557 else
11558 lower_halves_are_unequal ();
11559 @end smallexample
11560
11561 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11562 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11563 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
11564 @code{movt.ps}/@code{movf.ps}).
11565
11566 The @code{movt} functions return the value @var{x} computed by:
11567
11568 @smallexample
11569 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
11570 mov.ps @var{x},@var{c}
11571 movt.ps @var{x},@var{d},@var{cc}
11572 @end smallexample
11573
11574 The @code{movf} functions are similar but use @code{movf.ps} instead
11575 of @code{movt.ps}.
11576
11577 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11578 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11579 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11580 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11581 Comparison of two paired-single values
11582 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11583 @code{bc1any2t}/@code{bc1any2f}).
11584
11585 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11586 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
11587 result is true and the @code{all} forms return true if both results are true.
11588 For example:
11589
11590 @smallexample
11591 v2sf a, b;
11592 if (__builtin_mips_any_c_eq_ps (a, b))
11593 one_is_true ();
11594 else
11595 both_are_false ();
11596
11597 if (__builtin_mips_all_c_eq_ps (a, b))
11598 both_are_true ();
11599 else
11600 one_is_false ();
11601 @end smallexample
11602
11603 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11604 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11605 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11606 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11607 Comparison of four paired-single values
11608 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11609 @code{bc1any4t}/@code{bc1any4f}).
11610
11611 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
11612 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
11613 The @code{any} forms return true if any of the four results are true
11614 and the @code{all} forms return true if all four results are true.
11615 For example:
11616
11617 @smallexample
11618 v2sf a, b, c, d;
11619 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
11620 some_are_true ();
11621 else
11622 all_are_false ();
11623
11624 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
11625 all_are_true ();
11626 else
11627 some_are_false ();
11628 @end smallexample
11629 @end table
11630
11631 @node picoChip Built-in Functions
11632 @subsection picoChip Built-in Functions
11633
11634 GCC provides an interface to selected machine instructions from the
11635 picoChip instruction set.
11636
11637 @table @code
11638 @item int __builtin_sbc (int @var{value})
11639 Sign bit count. Return the number of consecutive bits in @var{value}
11640 that have the same value as the sign bit. The result is the number of
11641 leading sign bits minus one, giving the number of redundant sign bits in
11642 @var{value}.
11643
11644 @item int __builtin_byteswap (int @var{value})
11645 Byte swap. Return the result of swapping the upper and lower bytes of
11646 @var{value}.
11647
11648 @item int __builtin_brev (int @var{value})
11649 Bit reversal. Return the result of reversing the bits in
11650 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
11651 and so on.
11652
11653 @item int __builtin_adds (int @var{x}, int @var{y})
11654 Saturating addition. Return the result of adding @var{x} and @var{y},
11655 storing the value 32767 if the result overflows.
11656
11657 @item int __builtin_subs (int @var{x}, int @var{y})
11658 Saturating subtraction. Return the result of subtracting @var{y} from
11659 @var{x}, storing the value @minus{}32768 if the result overflows.
11660
11661 @item void __builtin_halt (void)
11662 Halt. The processor stops execution. This built-in is useful for
11663 implementing assertions.
11664
11665 @end table
11666
11667 @node Other MIPS Built-in Functions
11668 @subsection Other MIPS Built-in Functions
11669
11670 GCC provides other MIPS-specific built-in functions:
11671
11672 @table @code
11673 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
11674 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
11675 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
11676 when this function is available.
11677 @end table
11678
11679 @node PowerPC Built-in Functions
11680 @subsection PowerPC Built-in Functions
11681
11682 These built-in functions are available for the PowerPC family of
11683 processors:
11684 @smallexample
11685 float __builtin_recipdivf (float, float);
11686 float __builtin_rsqrtf (float);
11687 double __builtin_recipdiv (double, double);
11688 double __builtin_rsqrt (double);
11689 long __builtin_bpermd (long, long);
11690 uint64_t __builtin_ppc_get_timebase ();
11691 unsigned long __builtin_ppc_mftb ();
11692 @end smallexample
11693
11694 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
11695 @code{__builtin_rsqrtf} functions generate multiple instructions to
11696 implement the reciprocal sqrt functionality using reciprocal sqrt
11697 estimate instructions.
11698
11699 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
11700 functions generate multiple instructions to implement division using
11701 the reciprocal estimate instructions.
11702
11703 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
11704 functions generate instructions to read the Time Base Register. The
11705 @code{__builtin_ppc_get_timebase} function may generate multiple
11706 instructions and always returns the 64 bits of the Time Base Register.
11707 The @code{__builtin_ppc_mftb} function always generates one instruction and
11708 returns the Time Base Register value as an unsigned long, throwing away
11709 the most significant word on 32-bit environments.
11710
11711 @node PowerPC AltiVec/VSX Built-in Functions
11712 @subsection PowerPC AltiVec Built-in Functions
11713
11714 GCC provides an interface for the PowerPC family of processors to access
11715 the AltiVec operations described in Motorola's AltiVec Programming
11716 Interface Manual. The interface is made available by including
11717 @code{<altivec.h>} and using @option{-maltivec} and
11718 @option{-mabi=altivec}. The interface supports the following vector
11719 types.
11720
11721 @smallexample
11722 vector unsigned char
11723 vector signed char
11724 vector bool char
11725
11726 vector unsigned short
11727 vector signed short
11728 vector bool short
11729 vector pixel
11730
11731 vector unsigned int
11732 vector signed int
11733 vector bool int
11734 vector float
11735 @end smallexample
11736
11737 If @option{-mvsx} is used the following additional vector types are
11738 implemented.
11739
11740 @smallexample
11741 vector unsigned long
11742 vector signed long
11743 vector double
11744 @end smallexample
11745
11746 The long types are only implemented for 64-bit code generation, and
11747 the long type is only used in the floating point/integer conversion
11748 instructions.
11749
11750 GCC's implementation of the high-level language interface available from
11751 C and C++ code differs from Motorola's documentation in several ways.
11752
11753 @itemize @bullet
11754
11755 @item
11756 A vector constant is a list of constant expressions within curly braces.
11757
11758 @item
11759 A vector initializer requires no cast if the vector constant is of the
11760 same type as the variable it is initializing.
11761
11762 @item
11763 If @code{signed} or @code{unsigned} is omitted, the signedness of the
11764 vector type is the default signedness of the base type. The default
11765 varies depending on the operating system, so a portable program should
11766 always specify the signedness.
11767
11768 @item
11769 Compiling with @option{-maltivec} adds keywords @code{__vector},
11770 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
11771 @code{bool}. When compiling ISO C, the context-sensitive substitution
11772 of the keywords @code{vector}, @code{pixel} and @code{bool} is
11773 disabled. To use them, you must include @code{<altivec.h>} instead.
11774
11775 @item
11776 GCC allows using a @code{typedef} name as the type specifier for a
11777 vector type.
11778
11779 @item
11780 For C, overloaded functions are implemented with macros so the following
11781 does not work:
11782
11783 @smallexample
11784 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
11785 @end smallexample
11786
11787 @noindent
11788 Since @code{vec_add} is a macro, the vector constant in the example
11789 is treated as four separate arguments. Wrap the entire argument in
11790 parentheses for this to work.
11791 @end itemize
11792
11793 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
11794 Internally, GCC uses built-in functions to achieve the functionality in
11795 the aforementioned header file, but they are not supported and are
11796 subject to change without notice.
11797
11798 The following interfaces are supported for the generic and specific
11799 AltiVec operations and the AltiVec predicates. In cases where there
11800 is a direct mapping between generic and specific operations, only the
11801 generic names are shown here, although the specific operations can also
11802 be used.
11803
11804 Arguments that are documented as @code{const int} require literal
11805 integral values within the range required for that operation.
11806
11807 @smallexample
11808 vector signed char vec_abs (vector signed char);
11809 vector signed short vec_abs (vector signed short);
11810 vector signed int vec_abs (vector signed int);
11811 vector float vec_abs (vector float);
11812
11813 vector signed char vec_abss (vector signed char);
11814 vector signed short vec_abss (vector signed short);
11815 vector signed int vec_abss (vector signed int);
11816
11817 vector signed char vec_add (vector bool char, vector signed char);
11818 vector signed char vec_add (vector signed char, vector bool char);
11819 vector signed char vec_add (vector signed char, vector signed char);
11820 vector unsigned char vec_add (vector bool char, vector unsigned char);
11821 vector unsigned char vec_add (vector unsigned char, vector bool char);
11822 vector unsigned char vec_add (vector unsigned char,
11823 vector unsigned char);
11824 vector signed short vec_add (vector bool short, vector signed short);
11825 vector signed short vec_add (vector signed short, vector bool short);
11826 vector signed short vec_add (vector signed short, vector signed short);
11827 vector unsigned short vec_add (vector bool short,
11828 vector unsigned short);
11829 vector unsigned short vec_add (vector unsigned short,
11830 vector bool short);
11831 vector unsigned short vec_add (vector unsigned short,
11832 vector unsigned short);
11833 vector signed int vec_add (vector bool int, vector signed int);
11834 vector signed int vec_add (vector signed int, vector bool int);
11835 vector signed int vec_add (vector signed int, vector signed int);
11836 vector unsigned int vec_add (vector bool int, vector unsigned int);
11837 vector unsigned int vec_add (vector unsigned int, vector bool int);
11838 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
11839 vector float vec_add (vector float, vector float);
11840
11841 vector float vec_vaddfp (vector float, vector float);
11842
11843 vector signed int vec_vadduwm (vector bool int, vector signed int);
11844 vector signed int vec_vadduwm (vector signed int, vector bool int);
11845 vector signed int vec_vadduwm (vector signed int, vector signed int);
11846 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
11847 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
11848 vector unsigned int vec_vadduwm (vector unsigned int,
11849 vector unsigned int);
11850
11851 vector signed short vec_vadduhm (vector bool short,
11852 vector signed short);
11853 vector signed short vec_vadduhm (vector signed short,
11854 vector bool short);
11855 vector signed short vec_vadduhm (vector signed short,
11856 vector signed short);
11857 vector unsigned short vec_vadduhm (vector bool short,
11858 vector unsigned short);
11859 vector unsigned short vec_vadduhm (vector unsigned short,
11860 vector bool short);
11861 vector unsigned short vec_vadduhm (vector unsigned short,
11862 vector unsigned short);
11863
11864 vector signed char vec_vaddubm (vector bool char, vector signed char);
11865 vector signed char vec_vaddubm (vector signed char, vector bool char);
11866 vector signed char vec_vaddubm (vector signed char, vector signed char);
11867 vector unsigned char vec_vaddubm (vector bool char,
11868 vector unsigned char);
11869 vector unsigned char vec_vaddubm (vector unsigned char,
11870 vector bool char);
11871 vector unsigned char vec_vaddubm (vector unsigned char,
11872 vector unsigned char);
11873
11874 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
11875
11876 vector unsigned char vec_adds (vector bool char, vector unsigned char);
11877 vector unsigned char vec_adds (vector unsigned char, vector bool char);
11878 vector unsigned char vec_adds (vector unsigned char,
11879 vector unsigned char);
11880 vector signed char vec_adds (vector bool char, vector signed char);
11881 vector signed char vec_adds (vector signed char, vector bool char);
11882 vector signed char vec_adds (vector signed char, vector signed char);
11883 vector unsigned short vec_adds (vector bool short,
11884 vector unsigned short);
11885 vector unsigned short vec_adds (vector unsigned short,
11886 vector bool short);
11887 vector unsigned short vec_adds (vector unsigned short,
11888 vector unsigned short);
11889 vector signed short vec_adds (vector bool short, vector signed short);
11890 vector signed short vec_adds (vector signed short, vector bool short);
11891 vector signed short vec_adds (vector signed short, vector signed short);
11892 vector unsigned int vec_adds (vector bool int, vector unsigned int);
11893 vector unsigned int vec_adds (vector unsigned int, vector bool int);
11894 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
11895 vector signed int vec_adds (vector bool int, vector signed int);
11896 vector signed int vec_adds (vector signed int, vector bool int);
11897 vector signed int vec_adds (vector signed int, vector signed int);
11898
11899 vector signed int vec_vaddsws (vector bool int, vector signed int);
11900 vector signed int vec_vaddsws (vector signed int, vector bool int);
11901 vector signed int vec_vaddsws (vector signed int, vector signed int);
11902
11903 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
11904 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
11905 vector unsigned int vec_vadduws (vector unsigned int,
11906 vector unsigned int);
11907
11908 vector signed short vec_vaddshs (vector bool short,
11909 vector signed short);
11910 vector signed short vec_vaddshs (vector signed short,
11911 vector bool short);
11912 vector signed short vec_vaddshs (vector signed short,
11913 vector signed short);
11914
11915 vector unsigned short vec_vadduhs (vector bool short,
11916 vector unsigned short);
11917 vector unsigned short vec_vadduhs (vector unsigned short,
11918 vector bool short);
11919 vector unsigned short vec_vadduhs (vector unsigned short,
11920 vector unsigned short);
11921
11922 vector signed char vec_vaddsbs (vector bool char, vector signed char);
11923 vector signed char vec_vaddsbs (vector signed char, vector bool char);
11924 vector signed char vec_vaddsbs (vector signed char, vector signed char);
11925
11926 vector unsigned char vec_vaddubs (vector bool char,
11927 vector unsigned char);
11928 vector unsigned char vec_vaddubs (vector unsigned char,
11929 vector bool char);
11930 vector unsigned char vec_vaddubs (vector unsigned char,
11931 vector unsigned char);
11932
11933 vector float vec_and (vector float, vector float);
11934 vector float vec_and (vector float, vector bool int);
11935 vector float vec_and (vector bool int, vector float);
11936 vector bool int vec_and (vector bool int, vector bool int);
11937 vector signed int vec_and (vector bool int, vector signed int);
11938 vector signed int vec_and (vector signed int, vector bool int);
11939 vector signed int vec_and (vector signed int, vector signed int);
11940 vector unsigned int vec_and (vector bool int, vector unsigned int);
11941 vector unsigned int vec_and (vector unsigned int, vector bool int);
11942 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
11943 vector bool short vec_and (vector bool short, vector bool short);
11944 vector signed short vec_and (vector bool short, vector signed short);
11945 vector signed short vec_and (vector signed short, vector bool short);
11946 vector signed short vec_and (vector signed short, vector signed short);
11947 vector unsigned short vec_and (vector bool short,
11948 vector unsigned short);
11949 vector unsigned short vec_and (vector unsigned short,
11950 vector bool short);
11951 vector unsigned short vec_and (vector unsigned short,
11952 vector unsigned short);
11953 vector signed char vec_and (vector bool char, vector signed char);
11954 vector bool char vec_and (vector bool char, vector bool char);
11955 vector signed char vec_and (vector signed char, vector bool char);
11956 vector signed char vec_and (vector signed char, vector signed char);
11957 vector unsigned char vec_and (vector bool char, vector unsigned char);
11958 vector unsigned char vec_and (vector unsigned char, vector bool char);
11959 vector unsigned char vec_and (vector unsigned char,
11960 vector unsigned char);
11961
11962 vector float vec_andc (vector float, vector float);
11963 vector float vec_andc (vector float, vector bool int);
11964 vector float vec_andc (vector bool int, vector float);
11965 vector bool int vec_andc (vector bool int, vector bool int);
11966 vector signed int vec_andc (vector bool int, vector signed int);
11967 vector signed int vec_andc (vector signed int, vector bool int);
11968 vector signed int vec_andc (vector signed int, vector signed int);
11969 vector unsigned int vec_andc (vector bool int, vector unsigned int);
11970 vector unsigned int vec_andc (vector unsigned int, vector bool int);
11971 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
11972 vector bool short vec_andc (vector bool short, vector bool short);
11973 vector signed short vec_andc (vector bool short, vector signed short);
11974 vector signed short vec_andc (vector signed short, vector bool short);
11975 vector signed short vec_andc (vector signed short, vector signed short);
11976 vector unsigned short vec_andc (vector bool short,
11977 vector unsigned short);
11978 vector unsigned short vec_andc (vector unsigned short,
11979 vector bool short);
11980 vector unsigned short vec_andc (vector unsigned short,
11981 vector unsigned short);
11982 vector signed char vec_andc (vector bool char, vector signed char);
11983 vector bool char vec_andc (vector bool char, vector bool char);
11984 vector signed char vec_andc (vector signed char, vector bool char);
11985 vector signed char vec_andc (vector signed char, vector signed char);
11986 vector unsigned char vec_andc (vector bool char, vector unsigned char);
11987 vector unsigned char vec_andc (vector unsigned char, vector bool char);
11988 vector unsigned char vec_andc (vector unsigned char,
11989 vector unsigned char);
11990
11991 vector unsigned char vec_avg (vector unsigned char,
11992 vector unsigned char);
11993 vector signed char vec_avg (vector signed char, vector signed char);
11994 vector unsigned short vec_avg (vector unsigned short,
11995 vector unsigned short);
11996 vector signed short vec_avg (vector signed short, vector signed short);
11997 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
11998 vector signed int vec_avg (vector signed int, vector signed int);
11999
12000 vector signed int vec_vavgsw (vector signed int, vector signed int);
12001
12002 vector unsigned int vec_vavguw (vector unsigned int,
12003 vector unsigned int);
12004
12005 vector signed short vec_vavgsh (vector signed short,
12006 vector signed short);
12007
12008 vector unsigned short vec_vavguh (vector unsigned short,
12009 vector unsigned short);
12010
12011 vector signed char vec_vavgsb (vector signed char, vector signed char);
12012
12013 vector unsigned char vec_vavgub (vector unsigned char,
12014 vector unsigned char);
12015
12016 vector float vec_copysign (vector float);
12017
12018 vector float vec_ceil (vector float);
12019
12020 vector signed int vec_cmpb (vector float, vector float);
12021
12022 vector bool char vec_cmpeq (vector signed char, vector signed char);
12023 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12024 vector bool short vec_cmpeq (vector signed short, vector signed short);
12025 vector bool short vec_cmpeq (vector unsigned short,
12026 vector unsigned short);
12027 vector bool int vec_cmpeq (vector signed int, vector signed int);
12028 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12029 vector bool int vec_cmpeq (vector float, vector float);
12030
12031 vector bool int vec_vcmpeqfp (vector float, vector float);
12032
12033 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12034 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12035
12036 vector bool short vec_vcmpequh (vector signed short,
12037 vector signed short);
12038 vector bool short vec_vcmpequh (vector unsigned short,
12039 vector unsigned short);
12040
12041 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12042 vector bool char vec_vcmpequb (vector unsigned char,
12043 vector unsigned char);
12044
12045 vector bool int vec_cmpge (vector float, vector float);
12046
12047 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12048 vector bool char vec_cmpgt (vector signed char, vector signed char);
12049 vector bool short vec_cmpgt (vector unsigned short,
12050 vector unsigned short);
12051 vector bool short vec_cmpgt (vector signed short, vector signed short);
12052 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12053 vector bool int vec_cmpgt (vector signed int, vector signed int);
12054 vector bool int vec_cmpgt (vector float, vector float);
12055
12056 vector bool int vec_vcmpgtfp (vector float, vector float);
12057
12058 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12059
12060 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12061
12062 vector bool short vec_vcmpgtsh (vector signed short,
12063 vector signed short);
12064
12065 vector bool short vec_vcmpgtuh (vector unsigned short,
12066 vector unsigned short);
12067
12068 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12069
12070 vector bool char vec_vcmpgtub (vector unsigned char,
12071 vector unsigned char);
12072
12073 vector bool int vec_cmple (vector float, vector float);
12074
12075 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12076 vector bool char vec_cmplt (vector signed char, vector signed char);
12077 vector bool short vec_cmplt (vector unsigned short,
12078 vector unsigned short);
12079 vector bool short vec_cmplt (vector signed short, vector signed short);
12080 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12081 vector bool int vec_cmplt (vector signed int, vector signed int);
12082 vector bool int vec_cmplt (vector float, vector float);
12083
12084 vector float vec_ctf (vector unsigned int, const int);
12085 vector float vec_ctf (vector signed int, const int);
12086
12087 vector float vec_vcfsx (vector signed int, const int);
12088
12089 vector float vec_vcfux (vector unsigned int, const int);
12090
12091 vector signed int vec_cts (vector float, const int);
12092
12093 vector unsigned int vec_ctu (vector float, const int);
12094
12095 void vec_dss (const int);
12096
12097 void vec_dssall (void);
12098
12099 void vec_dst (const vector unsigned char *, int, const int);
12100 void vec_dst (const vector signed char *, int, const int);
12101 void vec_dst (const vector bool char *, int, const int);
12102 void vec_dst (const vector unsigned short *, int, const int);
12103 void vec_dst (const vector signed short *, int, const int);
12104 void vec_dst (const vector bool short *, int, const int);
12105 void vec_dst (const vector pixel *, int, const int);
12106 void vec_dst (const vector unsigned int *, int, const int);
12107 void vec_dst (const vector signed int *, int, const int);
12108 void vec_dst (const vector bool int *, int, const int);
12109 void vec_dst (const vector float *, int, const int);
12110 void vec_dst (const unsigned char *, int, const int);
12111 void vec_dst (const signed char *, int, const int);
12112 void vec_dst (const unsigned short *, int, const int);
12113 void vec_dst (const short *, int, const int);
12114 void vec_dst (const unsigned int *, int, const int);
12115 void vec_dst (const int *, int, const int);
12116 void vec_dst (const unsigned long *, int, const int);
12117 void vec_dst (const long *, int, const int);
12118 void vec_dst (const float *, int, const int);
12119
12120 void vec_dstst (const vector unsigned char *, int, const int);
12121 void vec_dstst (const vector signed char *, int, const int);
12122 void vec_dstst (const vector bool char *, int, const int);
12123 void vec_dstst (const vector unsigned short *, int, const int);
12124 void vec_dstst (const vector signed short *, int, const int);
12125 void vec_dstst (const vector bool short *, int, const int);
12126 void vec_dstst (const vector pixel *, int, const int);
12127 void vec_dstst (const vector unsigned int *, int, const int);
12128 void vec_dstst (const vector signed int *, int, const int);
12129 void vec_dstst (const vector bool int *, int, const int);
12130 void vec_dstst (const vector float *, int, const int);
12131 void vec_dstst (const unsigned char *, int, const int);
12132 void vec_dstst (const signed char *, int, const int);
12133 void vec_dstst (const unsigned short *, int, const int);
12134 void vec_dstst (const short *, int, const int);
12135 void vec_dstst (const unsigned int *, int, const int);
12136 void vec_dstst (const int *, int, const int);
12137 void vec_dstst (const unsigned long *, int, const int);
12138 void vec_dstst (const long *, int, const int);
12139 void vec_dstst (const float *, int, const int);
12140
12141 void vec_dststt (const vector unsigned char *, int, const int);
12142 void vec_dststt (const vector signed char *, int, const int);
12143 void vec_dststt (const vector bool char *, int, const int);
12144 void vec_dststt (const vector unsigned short *, int, const int);
12145 void vec_dststt (const vector signed short *, int, const int);
12146 void vec_dststt (const vector bool short *, int, const int);
12147 void vec_dststt (const vector pixel *, int, const int);
12148 void vec_dststt (const vector unsigned int *, int, const int);
12149 void vec_dststt (const vector signed int *, int, const int);
12150 void vec_dststt (const vector bool int *, int, const int);
12151 void vec_dststt (const vector float *, int, const int);
12152 void vec_dststt (const unsigned char *, int, const int);
12153 void vec_dststt (const signed char *, int, const int);
12154 void vec_dststt (const unsigned short *, int, const int);
12155 void vec_dststt (const short *, int, const int);
12156 void vec_dststt (const unsigned int *, int, const int);
12157 void vec_dststt (const int *, int, const int);
12158 void vec_dststt (const unsigned long *, int, const int);
12159 void vec_dststt (const long *, int, const int);
12160 void vec_dststt (const float *, int, const int);
12161
12162 void vec_dstt (const vector unsigned char *, int, const int);
12163 void vec_dstt (const vector signed char *, int, const int);
12164 void vec_dstt (const vector bool char *, int, const int);
12165 void vec_dstt (const vector unsigned short *, int, const int);
12166 void vec_dstt (const vector signed short *, int, const int);
12167 void vec_dstt (const vector bool short *, int, const int);
12168 void vec_dstt (const vector pixel *, int, const int);
12169 void vec_dstt (const vector unsigned int *, int, const int);
12170 void vec_dstt (const vector signed int *, int, const int);
12171 void vec_dstt (const vector bool int *, int, const int);
12172 void vec_dstt (const vector float *, int, const int);
12173 void vec_dstt (const unsigned char *, int, const int);
12174 void vec_dstt (const signed char *, int, const int);
12175 void vec_dstt (const unsigned short *, int, const int);
12176 void vec_dstt (const short *, int, const int);
12177 void vec_dstt (const unsigned int *, int, const int);
12178 void vec_dstt (const int *, int, const int);
12179 void vec_dstt (const unsigned long *, int, const int);
12180 void vec_dstt (const long *, int, const int);
12181 void vec_dstt (const float *, int, const int);
12182
12183 vector float vec_expte (vector float);
12184
12185 vector float vec_floor (vector float);
12186
12187 vector float vec_ld (int, const vector float *);
12188 vector float vec_ld (int, const float *);
12189 vector bool int vec_ld (int, const vector bool int *);
12190 vector signed int vec_ld (int, const vector signed int *);
12191 vector signed int vec_ld (int, const int *);
12192 vector signed int vec_ld (int, const long *);
12193 vector unsigned int vec_ld (int, const vector unsigned int *);
12194 vector unsigned int vec_ld (int, const unsigned int *);
12195 vector unsigned int vec_ld (int, const unsigned long *);
12196 vector bool short vec_ld (int, const vector bool short *);
12197 vector pixel vec_ld (int, const vector pixel *);
12198 vector signed short vec_ld (int, const vector signed short *);
12199 vector signed short vec_ld (int, const short *);
12200 vector unsigned short vec_ld (int, const vector unsigned short *);
12201 vector unsigned short vec_ld (int, const unsigned short *);
12202 vector bool char vec_ld (int, const vector bool char *);
12203 vector signed char vec_ld (int, const vector signed char *);
12204 vector signed char vec_ld (int, const signed char *);
12205 vector unsigned char vec_ld (int, const vector unsigned char *);
12206 vector unsigned char vec_ld (int, const unsigned char *);
12207
12208 vector signed char vec_lde (int, const signed char *);
12209 vector unsigned char vec_lde (int, const unsigned char *);
12210 vector signed short vec_lde (int, const short *);
12211 vector unsigned short vec_lde (int, const unsigned short *);
12212 vector float vec_lde (int, const float *);
12213 vector signed int vec_lde (int, const int *);
12214 vector unsigned int vec_lde (int, const unsigned int *);
12215 vector signed int vec_lde (int, const long *);
12216 vector unsigned int vec_lde (int, const unsigned long *);
12217
12218 vector float vec_lvewx (int, float *);
12219 vector signed int vec_lvewx (int, int *);
12220 vector unsigned int vec_lvewx (int, unsigned int *);
12221 vector signed int vec_lvewx (int, long *);
12222 vector unsigned int vec_lvewx (int, unsigned long *);
12223
12224 vector signed short vec_lvehx (int, short *);
12225 vector unsigned short vec_lvehx (int, unsigned short *);
12226
12227 vector signed char vec_lvebx (int, char *);
12228 vector unsigned char vec_lvebx (int, unsigned char *);
12229
12230 vector float vec_ldl (int, const vector float *);
12231 vector float vec_ldl (int, const float *);
12232 vector bool int vec_ldl (int, const vector bool int *);
12233 vector signed int vec_ldl (int, const vector signed int *);
12234 vector signed int vec_ldl (int, const int *);
12235 vector signed int vec_ldl (int, const long *);
12236 vector unsigned int vec_ldl (int, const vector unsigned int *);
12237 vector unsigned int vec_ldl (int, const unsigned int *);
12238 vector unsigned int vec_ldl (int, const unsigned long *);
12239 vector bool short vec_ldl (int, const vector bool short *);
12240 vector pixel vec_ldl (int, const vector pixel *);
12241 vector signed short vec_ldl (int, const vector signed short *);
12242 vector signed short vec_ldl (int, const short *);
12243 vector unsigned short vec_ldl (int, const vector unsigned short *);
12244 vector unsigned short vec_ldl (int, const unsigned short *);
12245 vector bool char vec_ldl (int, const vector bool char *);
12246 vector signed char vec_ldl (int, const vector signed char *);
12247 vector signed char vec_ldl (int, const signed char *);
12248 vector unsigned char vec_ldl (int, const vector unsigned char *);
12249 vector unsigned char vec_ldl (int, const unsigned char *);
12250
12251 vector float vec_loge (vector float);
12252
12253 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12254 vector unsigned char vec_lvsl (int, const volatile signed char *);
12255 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12256 vector unsigned char vec_lvsl (int, const volatile short *);
12257 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12258 vector unsigned char vec_lvsl (int, const volatile int *);
12259 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12260 vector unsigned char vec_lvsl (int, const volatile long *);
12261 vector unsigned char vec_lvsl (int, const volatile float *);
12262
12263 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
12264 vector unsigned char vec_lvsr (int, const volatile signed char *);
12265 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
12266 vector unsigned char vec_lvsr (int, const volatile short *);
12267 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
12268 vector unsigned char vec_lvsr (int, const volatile int *);
12269 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
12270 vector unsigned char vec_lvsr (int, const volatile long *);
12271 vector unsigned char vec_lvsr (int, const volatile float *);
12272
12273 vector float vec_madd (vector float, vector float, vector float);
12274
12275 vector signed short vec_madds (vector signed short,
12276 vector signed short,
12277 vector signed short);
12278
12279 vector unsigned char vec_max (vector bool char, vector unsigned char);
12280 vector unsigned char vec_max (vector unsigned char, vector bool char);
12281 vector unsigned char vec_max (vector unsigned char,
12282 vector unsigned char);
12283 vector signed char vec_max (vector bool char, vector signed char);
12284 vector signed char vec_max (vector signed char, vector bool char);
12285 vector signed char vec_max (vector signed char, vector signed char);
12286 vector unsigned short vec_max (vector bool short,
12287 vector unsigned short);
12288 vector unsigned short vec_max (vector unsigned short,
12289 vector bool short);
12290 vector unsigned short vec_max (vector unsigned short,
12291 vector unsigned short);
12292 vector signed short vec_max (vector bool short, vector signed short);
12293 vector signed short vec_max (vector signed short, vector bool short);
12294 vector signed short vec_max (vector signed short, vector signed short);
12295 vector unsigned int vec_max (vector bool int, vector unsigned int);
12296 vector unsigned int vec_max (vector unsigned int, vector bool int);
12297 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
12298 vector signed int vec_max (vector bool int, vector signed int);
12299 vector signed int vec_max (vector signed int, vector bool int);
12300 vector signed int vec_max (vector signed int, vector signed int);
12301 vector float vec_max (vector float, vector float);
12302
12303 vector float vec_vmaxfp (vector float, vector float);
12304
12305 vector signed int vec_vmaxsw (vector bool int, vector signed int);
12306 vector signed int vec_vmaxsw (vector signed int, vector bool int);
12307 vector signed int vec_vmaxsw (vector signed int, vector signed int);
12308
12309 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
12310 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
12311 vector unsigned int vec_vmaxuw (vector unsigned int,
12312 vector unsigned int);
12313
12314 vector signed short vec_vmaxsh (vector bool short, vector signed short);
12315 vector signed short vec_vmaxsh (vector signed short, vector bool short);
12316 vector signed short vec_vmaxsh (vector signed short,
12317 vector signed short);
12318
12319 vector unsigned short vec_vmaxuh (vector bool short,
12320 vector unsigned short);
12321 vector unsigned short vec_vmaxuh (vector unsigned short,
12322 vector bool short);
12323 vector unsigned short vec_vmaxuh (vector unsigned short,
12324 vector unsigned short);
12325
12326 vector signed char vec_vmaxsb (vector bool char, vector signed char);
12327 vector signed char vec_vmaxsb (vector signed char, vector bool char);
12328 vector signed char vec_vmaxsb (vector signed char, vector signed char);
12329
12330 vector unsigned char vec_vmaxub (vector bool char,
12331 vector unsigned char);
12332 vector unsigned char vec_vmaxub (vector unsigned char,
12333 vector bool char);
12334 vector unsigned char vec_vmaxub (vector unsigned char,
12335 vector unsigned char);
12336
12337 vector bool char vec_mergeh (vector bool char, vector bool char);
12338 vector signed char vec_mergeh (vector signed char, vector signed char);
12339 vector unsigned char vec_mergeh (vector unsigned char,
12340 vector unsigned char);
12341 vector bool short vec_mergeh (vector bool short, vector bool short);
12342 vector pixel vec_mergeh (vector pixel, vector pixel);
12343 vector signed short vec_mergeh (vector signed short,
12344 vector signed short);
12345 vector unsigned short vec_mergeh (vector unsigned short,
12346 vector unsigned short);
12347 vector float vec_mergeh (vector float, vector float);
12348 vector bool int vec_mergeh (vector bool int, vector bool int);
12349 vector signed int vec_mergeh (vector signed int, vector signed int);
12350 vector unsigned int vec_mergeh (vector unsigned int,
12351 vector unsigned int);
12352
12353 vector float vec_vmrghw (vector float, vector float);
12354 vector bool int vec_vmrghw (vector bool int, vector bool int);
12355 vector signed int vec_vmrghw (vector signed int, vector signed int);
12356 vector unsigned int vec_vmrghw (vector unsigned int,
12357 vector unsigned int);
12358
12359 vector bool short vec_vmrghh (vector bool short, vector bool short);
12360 vector signed short vec_vmrghh (vector signed short,
12361 vector signed short);
12362 vector unsigned short vec_vmrghh (vector unsigned short,
12363 vector unsigned short);
12364 vector pixel vec_vmrghh (vector pixel, vector pixel);
12365
12366 vector bool char vec_vmrghb (vector bool char, vector bool char);
12367 vector signed char vec_vmrghb (vector signed char, vector signed char);
12368 vector unsigned char vec_vmrghb (vector unsigned char,
12369 vector unsigned char);
12370
12371 vector bool char vec_mergel (vector bool char, vector bool char);
12372 vector signed char vec_mergel (vector signed char, vector signed char);
12373 vector unsigned char vec_mergel (vector unsigned char,
12374 vector unsigned char);
12375 vector bool short vec_mergel (vector bool short, vector bool short);
12376 vector pixel vec_mergel (vector pixel, vector pixel);
12377 vector signed short vec_mergel (vector signed short,
12378 vector signed short);
12379 vector unsigned short vec_mergel (vector unsigned short,
12380 vector unsigned short);
12381 vector float vec_mergel (vector float, vector float);
12382 vector bool int vec_mergel (vector bool int, vector bool int);
12383 vector signed int vec_mergel (vector signed int, vector signed int);
12384 vector unsigned int vec_mergel (vector unsigned int,
12385 vector unsigned int);
12386
12387 vector float vec_vmrglw (vector float, vector float);
12388 vector signed int vec_vmrglw (vector signed int, vector signed int);
12389 vector unsigned int vec_vmrglw (vector unsigned int,
12390 vector unsigned int);
12391 vector bool int vec_vmrglw (vector bool int, vector bool int);
12392
12393 vector bool short vec_vmrglh (vector bool short, vector bool short);
12394 vector signed short vec_vmrglh (vector signed short,
12395 vector signed short);
12396 vector unsigned short vec_vmrglh (vector unsigned short,
12397 vector unsigned short);
12398 vector pixel vec_vmrglh (vector pixel, vector pixel);
12399
12400 vector bool char vec_vmrglb (vector bool char, vector bool char);
12401 vector signed char vec_vmrglb (vector signed char, vector signed char);
12402 vector unsigned char vec_vmrglb (vector unsigned char,
12403 vector unsigned char);
12404
12405 vector unsigned short vec_mfvscr (void);
12406
12407 vector unsigned char vec_min (vector bool char, vector unsigned char);
12408 vector unsigned char vec_min (vector unsigned char, vector bool char);
12409 vector unsigned char vec_min (vector unsigned char,
12410 vector unsigned char);
12411 vector signed char vec_min (vector bool char, vector signed char);
12412 vector signed char vec_min (vector signed char, vector bool char);
12413 vector signed char vec_min (vector signed char, vector signed char);
12414 vector unsigned short vec_min (vector bool short,
12415 vector unsigned short);
12416 vector unsigned short vec_min (vector unsigned short,
12417 vector bool short);
12418 vector unsigned short vec_min (vector unsigned short,
12419 vector unsigned short);
12420 vector signed short vec_min (vector bool short, vector signed short);
12421 vector signed short vec_min (vector signed short, vector bool short);
12422 vector signed short vec_min (vector signed short, vector signed short);
12423 vector unsigned int vec_min (vector bool int, vector unsigned int);
12424 vector unsigned int vec_min (vector unsigned int, vector bool int);
12425 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
12426 vector signed int vec_min (vector bool int, vector signed int);
12427 vector signed int vec_min (vector signed int, vector bool int);
12428 vector signed int vec_min (vector signed int, vector signed int);
12429 vector float vec_min (vector float, vector float);
12430
12431 vector float vec_vminfp (vector float, vector float);
12432
12433 vector signed int vec_vminsw (vector bool int, vector signed int);
12434 vector signed int vec_vminsw (vector signed int, vector bool int);
12435 vector signed int vec_vminsw (vector signed int, vector signed int);
12436
12437 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
12438 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
12439 vector unsigned int vec_vminuw (vector unsigned int,
12440 vector unsigned int);
12441
12442 vector signed short vec_vminsh (vector bool short, vector signed short);
12443 vector signed short vec_vminsh (vector signed short, vector bool short);
12444 vector signed short vec_vminsh (vector signed short,
12445 vector signed short);
12446
12447 vector unsigned short vec_vminuh (vector bool short,
12448 vector unsigned short);
12449 vector unsigned short vec_vminuh (vector unsigned short,
12450 vector bool short);
12451 vector unsigned short vec_vminuh (vector unsigned short,
12452 vector unsigned short);
12453
12454 vector signed char vec_vminsb (vector bool char, vector signed char);
12455 vector signed char vec_vminsb (vector signed char, vector bool char);
12456 vector signed char vec_vminsb (vector signed char, vector signed char);
12457
12458 vector unsigned char vec_vminub (vector bool char,
12459 vector unsigned char);
12460 vector unsigned char vec_vminub (vector unsigned char,
12461 vector bool char);
12462 vector unsigned char vec_vminub (vector unsigned char,
12463 vector unsigned char);
12464
12465 vector signed short vec_mladd (vector signed short,
12466 vector signed short,
12467 vector signed short);
12468 vector signed short vec_mladd (vector signed short,
12469 vector unsigned short,
12470 vector unsigned short);
12471 vector signed short vec_mladd (vector unsigned short,
12472 vector signed short,
12473 vector signed short);
12474 vector unsigned short vec_mladd (vector unsigned short,
12475 vector unsigned short,
12476 vector unsigned short);
12477
12478 vector signed short vec_mradds (vector signed short,
12479 vector signed short,
12480 vector signed short);
12481
12482 vector unsigned int vec_msum (vector unsigned char,
12483 vector unsigned char,
12484 vector unsigned int);
12485 vector signed int vec_msum (vector signed char,
12486 vector unsigned char,
12487 vector signed int);
12488 vector unsigned int vec_msum (vector unsigned short,
12489 vector unsigned short,
12490 vector unsigned int);
12491 vector signed int vec_msum (vector signed short,
12492 vector signed short,
12493 vector signed int);
12494
12495 vector signed int vec_vmsumshm (vector signed short,
12496 vector signed short,
12497 vector signed int);
12498
12499 vector unsigned int vec_vmsumuhm (vector unsigned short,
12500 vector unsigned short,
12501 vector unsigned int);
12502
12503 vector signed int vec_vmsummbm (vector signed char,
12504 vector unsigned char,
12505 vector signed int);
12506
12507 vector unsigned int vec_vmsumubm (vector unsigned char,
12508 vector unsigned char,
12509 vector unsigned int);
12510
12511 vector unsigned int vec_msums (vector unsigned short,
12512 vector unsigned short,
12513 vector unsigned int);
12514 vector signed int vec_msums (vector signed short,
12515 vector signed short,
12516 vector signed int);
12517
12518 vector signed int vec_vmsumshs (vector signed short,
12519 vector signed short,
12520 vector signed int);
12521
12522 vector unsigned int vec_vmsumuhs (vector unsigned short,
12523 vector unsigned short,
12524 vector unsigned int);
12525
12526 void vec_mtvscr (vector signed int);
12527 void vec_mtvscr (vector unsigned int);
12528 void vec_mtvscr (vector bool int);
12529 void vec_mtvscr (vector signed short);
12530 void vec_mtvscr (vector unsigned short);
12531 void vec_mtvscr (vector bool short);
12532 void vec_mtvscr (vector pixel);
12533 void vec_mtvscr (vector signed char);
12534 void vec_mtvscr (vector unsigned char);
12535 void vec_mtvscr (vector bool char);
12536
12537 vector unsigned short vec_mule (vector unsigned char,
12538 vector unsigned char);
12539 vector signed short vec_mule (vector signed char,
12540 vector signed char);
12541 vector unsigned int vec_mule (vector unsigned short,
12542 vector unsigned short);
12543 vector signed int vec_mule (vector signed short, vector signed short);
12544
12545 vector signed int vec_vmulesh (vector signed short,
12546 vector signed short);
12547
12548 vector unsigned int vec_vmuleuh (vector unsigned short,
12549 vector unsigned short);
12550
12551 vector signed short vec_vmulesb (vector signed char,
12552 vector signed char);
12553
12554 vector unsigned short vec_vmuleub (vector unsigned char,
12555 vector unsigned char);
12556
12557 vector unsigned short vec_mulo (vector unsigned char,
12558 vector unsigned char);
12559 vector signed short vec_mulo (vector signed char, vector signed char);
12560 vector unsigned int vec_mulo (vector unsigned short,
12561 vector unsigned short);
12562 vector signed int vec_mulo (vector signed short, vector signed short);
12563
12564 vector signed int vec_vmulosh (vector signed short,
12565 vector signed short);
12566
12567 vector unsigned int vec_vmulouh (vector unsigned short,
12568 vector unsigned short);
12569
12570 vector signed short vec_vmulosb (vector signed char,
12571 vector signed char);
12572
12573 vector unsigned short vec_vmuloub (vector unsigned char,
12574 vector unsigned char);
12575
12576 vector float vec_nmsub (vector float, vector float, vector float);
12577
12578 vector float vec_nor (vector float, vector float);
12579 vector signed int vec_nor (vector signed int, vector signed int);
12580 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
12581 vector bool int vec_nor (vector bool int, vector bool int);
12582 vector signed short vec_nor (vector signed short, vector signed short);
12583 vector unsigned short vec_nor (vector unsigned short,
12584 vector unsigned short);
12585 vector bool short vec_nor (vector bool short, vector bool short);
12586 vector signed char vec_nor (vector signed char, vector signed char);
12587 vector unsigned char vec_nor (vector unsigned char,
12588 vector unsigned char);
12589 vector bool char vec_nor (vector bool char, vector bool char);
12590
12591 vector float vec_or (vector float, vector float);
12592 vector float vec_or (vector float, vector bool int);
12593 vector float vec_or (vector bool int, vector float);
12594 vector bool int vec_or (vector bool int, vector bool int);
12595 vector signed int vec_or (vector bool int, vector signed int);
12596 vector signed int vec_or (vector signed int, vector bool int);
12597 vector signed int vec_or (vector signed int, vector signed int);
12598 vector unsigned int vec_or (vector bool int, vector unsigned int);
12599 vector unsigned int vec_or (vector unsigned int, vector bool int);
12600 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
12601 vector bool short vec_or (vector bool short, vector bool short);
12602 vector signed short vec_or (vector bool short, vector signed short);
12603 vector signed short vec_or (vector signed short, vector bool short);
12604 vector signed short vec_or (vector signed short, vector signed short);
12605 vector unsigned short vec_or (vector bool short, vector unsigned short);
12606 vector unsigned short vec_or (vector unsigned short, vector bool short);
12607 vector unsigned short vec_or (vector unsigned short,
12608 vector unsigned short);
12609 vector signed char vec_or (vector bool char, vector signed char);
12610 vector bool char vec_or (vector bool char, vector bool char);
12611 vector signed char vec_or (vector signed char, vector bool char);
12612 vector signed char vec_or (vector signed char, vector signed char);
12613 vector unsigned char vec_or (vector bool char, vector unsigned char);
12614 vector unsigned char vec_or (vector unsigned char, vector bool char);
12615 vector unsigned char vec_or (vector unsigned char,
12616 vector unsigned char);
12617
12618 vector signed char vec_pack (vector signed short, vector signed short);
12619 vector unsigned char vec_pack (vector unsigned short,
12620 vector unsigned short);
12621 vector bool char vec_pack (vector bool short, vector bool short);
12622 vector signed short vec_pack (vector signed int, vector signed int);
12623 vector unsigned short vec_pack (vector unsigned int,
12624 vector unsigned int);
12625 vector bool short vec_pack (vector bool int, vector bool int);
12626
12627 vector bool short vec_vpkuwum (vector bool int, vector bool int);
12628 vector signed short vec_vpkuwum (vector signed int, vector signed int);
12629 vector unsigned short vec_vpkuwum (vector unsigned int,
12630 vector unsigned int);
12631
12632 vector bool char vec_vpkuhum (vector bool short, vector bool short);
12633 vector signed char vec_vpkuhum (vector signed short,
12634 vector signed short);
12635 vector unsigned char vec_vpkuhum (vector unsigned short,
12636 vector unsigned short);
12637
12638 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
12639
12640 vector unsigned char vec_packs (vector unsigned short,
12641 vector unsigned short);
12642 vector signed char vec_packs (vector signed short, vector signed short);
12643 vector unsigned short vec_packs (vector unsigned int,
12644 vector unsigned int);
12645 vector signed short vec_packs (vector signed int, vector signed int);
12646
12647 vector signed short vec_vpkswss (vector signed int, vector signed int);
12648
12649 vector unsigned short vec_vpkuwus (vector unsigned int,
12650 vector unsigned int);
12651
12652 vector signed char vec_vpkshss (vector signed short,
12653 vector signed short);
12654
12655 vector unsigned char vec_vpkuhus (vector unsigned short,
12656 vector unsigned short);
12657
12658 vector unsigned char vec_packsu (vector unsigned short,
12659 vector unsigned short);
12660 vector unsigned char vec_packsu (vector signed short,
12661 vector signed short);
12662 vector unsigned short vec_packsu (vector unsigned int,
12663 vector unsigned int);
12664 vector unsigned short vec_packsu (vector signed int, vector signed int);
12665
12666 vector unsigned short vec_vpkswus (vector signed int,
12667 vector signed int);
12668
12669 vector unsigned char vec_vpkshus (vector signed short,
12670 vector signed short);
12671
12672 vector float vec_perm (vector float,
12673 vector float,
12674 vector unsigned char);
12675 vector signed int vec_perm (vector signed int,
12676 vector signed int,
12677 vector unsigned char);
12678 vector unsigned int vec_perm (vector unsigned int,
12679 vector unsigned int,
12680 vector unsigned char);
12681 vector bool int vec_perm (vector bool int,
12682 vector bool int,
12683 vector unsigned char);
12684 vector signed short vec_perm (vector signed short,
12685 vector signed short,
12686 vector unsigned char);
12687 vector unsigned short vec_perm (vector unsigned short,
12688 vector unsigned short,
12689 vector unsigned char);
12690 vector bool short vec_perm (vector bool short,
12691 vector bool short,
12692 vector unsigned char);
12693 vector pixel vec_perm (vector pixel,
12694 vector pixel,
12695 vector unsigned char);
12696 vector signed char vec_perm (vector signed char,
12697 vector signed char,
12698 vector unsigned char);
12699 vector unsigned char vec_perm (vector unsigned char,
12700 vector unsigned char,
12701 vector unsigned char);
12702 vector bool char vec_perm (vector bool char,
12703 vector bool char,
12704 vector unsigned char);
12705
12706 vector float vec_re (vector float);
12707
12708 vector signed char vec_rl (vector signed char,
12709 vector unsigned char);
12710 vector unsigned char vec_rl (vector unsigned char,
12711 vector unsigned char);
12712 vector signed short vec_rl (vector signed short, vector unsigned short);
12713 vector unsigned short vec_rl (vector unsigned short,
12714 vector unsigned short);
12715 vector signed int vec_rl (vector signed int, vector unsigned int);
12716 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
12717
12718 vector signed int vec_vrlw (vector signed int, vector unsigned int);
12719 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
12720
12721 vector signed short vec_vrlh (vector signed short,
12722 vector unsigned short);
12723 vector unsigned short vec_vrlh (vector unsigned short,
12724 vector unsigned short);
12725
12726 vector signed char vec_vrlb (vector signed char, vector unsigned char);
12727 vector unsigned char vec_vrlb (vector unsigned char,
12728 vector unsigned char);
12729
12730 vector float vec_round (vector float);
12731
12732 vector float vec_recip (vector float, vector float);
12733
12734 vector float vec_rsqrt (vector float);
12735
12736 vector float vec_rsqrte (vector float);
12737
12738 vector float vec_sel (vector float, vector float, vector bool int);
12739 vector float vec_sel (vector float, vector float, vector unsigned int);
12740 vector signed int vec_sel (vector signed int,
12741 vector signed int,
12742 vector bool int);
12743 vector signed int vec_sel (vector signed int,
12744 vector signed int,
12745 vector unsigned int);
12746 vector unsigned int vec_sel (vector unsigned int,
12747 vector unsigned int,
12748 vector bool int);
12749 vector unsigned int vec_sel (vector unsigned int,
12750 vector unsigned int,
12751 vector unsigned int);
12752 vector bool int vec_sel (vector bool int,
12753 vector bool int,
12754 vector bool int);
12755 vector bool int vec_sel (vector bool int,
12756 vector bool int,
12757 vector unsigned int);
12758 vector signed short vec_sel (vector signed short,
12759 vector signed short,
12760 vector bool short);
12761 vector signed short vec_sel (vector signed short,
12762 vector signed short,
12763 vector unsigned short);
12764 vector unsigned short vec_sel (vector unsigned short,
12765 vector unsigned short,
12766 vector bool short);
12767 vector unsigned short vec_sel (vector unsigned short,
12768 vector unsigned short,
12769 vector unsigned short);
12770 vector bool short vec_sel (vector bool short,
12771 vector bool short,
12772 vector bool short);
12773 vector bool short vec_sel (vector bool short,
12774 vector bool short,
12775 vector unsigned short);
12776 vector signed char vec_sel (vector signed char,
12777 vector signed char,
12778 vector bool char);
12779 vector signed char vec_sel (vector signed char,
12780 vector signed char,
12781 vector unsigned char);
12782 vector unsigned char vec_sel (vector unsigned char,
12783 vector unsigned char,
12784 vector bool char);
12785 vector unsigned char vec_sel (vector unsigned char,
12786 vector unsigned char,
12787 vector unsigned char);
12788 vector bool char vec_sel (vector bool char,
12789 vector bool char,
12790 vector bool char);
12791 vector bool char vec_sel (vector bool char,
12792 vector bool char,
12793 vector unsigned char);
12794
12795 vector signed char vec_sl (vector signed char,
12796 vector unsigned char);
12797 vector unsigned char vec_sl (vector unsigned char,
12798 vector unsigned char);
12799 vector signed short vec_sl (vector signed short, vector unsigned short);
12800 vector unsigned short vec_sl (vector unsigned short,
12801 vector unsigned short);
12802 vector signed int vec_sl (vector signed int, vector unsigned int);
12803 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
12804
12805 vector signed int vec_vslw (vector signed int, vector unsigned int);
12806 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
12807
12808 vector signed short vec_vslh (vector signed short,
12809 vector unsigned short);
12810 vector unsigned short vec_vslh (vector unsigned short,
12811 vector unsigned short);
12812
12813 vector signed char vec_vslb (vector signed char, vector unsigned char);
12814 vector unsigned char vec_vslb (vector unsigned char,
12815 vector unsigned char);
12816
12817 vector float vec_sld (vector float, vector float, const int);
12818 vector signed int vec_sld (vector signed int,
12819 vector signed int,
12820 const int);
12821 vector unsigned int vec_sld (vector unsigned int,
12822 vector unsigned int,
12823 const int);
12824 vector bool int vec_sld (vector bool int,
12825 vector bool int,
12826 const int);
12827 vector signed short vec_sld (vector signed short,
12828 vector signed short,
12829 const int);
12830 vector unsigned short vec_sld (vector unsigned short,
12831 vector unsigned short,
12832 const int);
12833 vector bool short vec_sld (vector bool short,
12834 vector bool short,
12835 const int);
12836 vector pixel vec_sld (vector pixel,
12837 vector pixel,
12838 const int);
12839 vector signed char vec_sld (vector signed char,
12840 vector signed char,
12841 const int);
12842 vector unsigned char vec_sld (vector unsigned char,
12843 vector unsigned char,
12844 const int);
12845 vector bool char vec_sld (vector bool char,
12846 vector bool char,
12847 const int);
12848
12849 vector signed int vec_sll (vector signed int,
12850 vector unsigned int);
12851 vector signed int vec_sll (vector signed int,
12852 vector unsigned short);
12853 vector signed int vec_sll (vector signed int,
12854 vector unsigned char);
12855 vector unsigned int vec_sll (vector unsigned int,
12856 vector unsigned int);
12857 vector unsigned int vec_sll (vector unsigned int,
12858 vector unsigned short);
12859 vector unsigned int vec_sll (vector unsigned int,
12860 vector unsigned char);
12861 vector bool int vec_sll (vector bool int,
12862 vector unsigned int);
12863 vector bool int vec_sll (vector bool int,
12864 vector unsigned short);
12865 vector bool int vec_sll (vector bool int,
12866 vector unsigned char);
12867 vector signed short vec_sll (vector signed short,
12868 vector unsigned int);
12869 vector signed short vec_sll (vector signed short,
12870 vector unsigned short);
12871 vector signed short vec_sll (vector signed short,
12872 vector unsigned char);
12873 vector unsigned short vec_sll (vector unsigned short,
12874 vector unsigned int);
12875 vector unsigned short vec_sll (vector unsigned short,
12876 vector unsigned short);
12877 vector unsigned short vec_sll (vector unsigned short,
12878 vector unsigned char);
12879 vector bool short vec_sll (vector bool short, vector unsigned int);
12880 vector bool short vec_sll (vector bool short, vector unsigned short);
12881 vector bool short vec_sll (vector bool short, vector unsigned char);
12882 vector pixel vec_sll (vector pixel, vector unsigned int);
12883 vector pixel vec_sll (vector pixel, vector unsigned short);
12884 vector pixel vec_sll (vector pixel, vector unsigned char);
12885 vector signed char vec_sll (vector signed char, vector unsigned int);
12886 vector signed char vec_sll (vector signed char, vector unsigned short);
12887 vector signed char vec_sll (vector signed char, vector unsigned char);
12888 vector unsigned char vec_sll (vector unsigned char,
12889 vector unsigned int);
12890 vector unsigned char vec_sll (vector unsigned char,
12891 vector unsigned short);
12892 vector unsigned char vec_sll (vector unsigned char,
12893 vector unsigned char);
12894 vector bool char vec_sll (vector bool char, vector unsigned int);
12895 vector bool char vec_sll (vector bool char, vector unsigned short);
12896 vector bool char vec_sll (vector bool char, vector unsigned char);
12897
12898 vector float vec_slo (vector float, vector signed char);
12899 vector float vec_slo (vector float, vector unsigned char);
12900 vector signed int vec_slo (vector signed int, vector signed char);
12901 vector signed int vec_slo (vector signed int, vector unsigned char);
12902 vector unsigned int vec_slo (vector unsigned int, vector signed char);
12903 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
12904 vector signed short vec_slo (vector signed short, vector signed char);
12905 vector signed short vec_slo (vector signed short, vector unsigned char);
12906 vector unsigned short vec_slo (vector unsigned short,
12907 vector signed char);
12908 vector unsigned short vec_slo (vector unsigned short,
12909 vector unsigned char);
12910 vector pixel vec_slo (vector pixel, vector signed char);
12911 vector pixel vec_slo (vector pixel, vector unsigned char);
12912 vector signed char vec_slo (vector signed char, vector signed char);
12913 vector signed char vec_slo (vector signed char, vector unsigned char);
12914 vector unsigned char vec_slo (vector unsigned char, vector signed char);
12915 vector unsigned char vec_slo (vector unsigned char,
12916 vector unsigned char);
12917
12918 vector signed char vec_splat (vector signed char, const int);
12919 vector unsigned char vec_splat (vector unsigned char, const int);
12920 vector bool char vec_splat (vector bool char, const int);
12921 vector signed short vec_splat (vector signed short, const int);
12922 vector unsigned short vec_splat (vector unsigned short, const int);
12923 vector bool short vec_splat (vector bool short, const int);
12924 vector pixel vec_splat (vector pixel, const int);
12925 vector float vec_splat (vector float, const int);
12926 vector signed int vec_splat (vector signed int, const int);
12927 vector unsigned int vec_splat (vector unsigned int, const int);
12928 vector bool int vec_splat (vector bool int, const int);
12929
12930 vector float vec_vspltw (vector float, const int);
12931 vector signed int vec_vspltw (vector signed int, const int);
12932 vector unsigned int vec_vspltw (vector unsigned int, const int);
12933 vector bool int vec_vspltw (vector bool int, const int);
12934
12935 vector bool short vec_vsplth (vector bool short, const int);
12936 vector signed short vec_vsplth (vector signed short, const int);
12937 vector unsigned short vec_vsplth (vector unsigned short, const int);
12938 vector pixel vec_vsplth (vector pixel, const int);
12939
12940 vector signed char vec_vspltb (vector signed char, const int);
12941 vector unsigned char vec_vspltb (vector unsigned char, const int);
12942 vector bool char vec_vspltb (vector bool char, const int);
12943
12944 vector signed char vec_splat_s8 (const int);
12945
12946 vector signed short vec_splat_s16 (const int);
12947
12948 vector signed int vec_splat_s32 (const int);
12949
12950 vector unsigned char vec_splat_u8 (const int);
12951
12952 vector unsigned short vec_splat_u16 (const int);
12953
12954 vector unsigned int vec_splat_u32 (const int);
12955
12956 vector signed char vec_sr (vector signed char, vector unsigned char);
12957 vector unsigned char vec_sr (vector unsigned char,
12958 vector unsigned char);
12959 vector signed short vec_sr (vector signed short,
12960 vector unsigned short);
12961 vector unsigned short vec_sr (vector unsigned short,
12962 vector unsigned short);
12963 vector signed int vec_sr (vector signed int, vector unsigned int);
12964 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
12965
12966 vector signed int vec_vsrw (vector signed int, vector unsigned int);
12967 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
12968
12969 vector signed short vec_vsrh (vector signed short,
12970 vector unsigned short);
12971 vector unsigned short vec_vsrh (vector unsigned short,
12972 vector unsigned short);
12973
12974 vector signed char vec_vsrb (vector signed char, vector unsigned char);
12975 vector unsigned char vec_vsrb (vector unsigned char,
12976 vector unsigned char);
12977
12978 vector signed char vec_sra (vector signed char, vector unsigned char);
12979 vector unsigned char vec_sra (vector unsigned char,
12980 vector unsigned char);
12981 vector signed short vec_sra (vector signed short,
12982 vector unsigned short);
12983 vector unsigned short vec_sra (vector unsigned short,
12984 vector unsigned short);
12985 vector signed int vec_sra (vector signed int, vector unsigned int);
12986 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
12987
12988 vector signed int vec_vsraw (vector signed int, vector unsigned int);
12989 vector unsigned int vec_vsraw (vector unsigned int,
12990 vector unsigned int);
12991
12992 vector signed short vec_vsrah (vector signed short,
12993 vector unsigned short);
12994 vector unsigned short vec_vsrah (vector unsigned short,
12995 vector unsigned short);
12996
12997 vector signed char vec_vsrab (vector signed char, vector unsigned char);
12998 vector unsigned char vec_vsrab (vector unsigned char,
12999 vector unsigned char);
13000
13001 vector signed int vec_srl (vector signed int, vector unsigned int);
13002 vector signed int vec_srl (vector signed int, vector unsigned short);
13003 vector signed int vec_srl (vector signed int, vector unsigned char);
13004 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13005 vector unsigned int vec_srl (vector unsigned int,
13006 vector unsigned short);
13007 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13008 vector bool int vec_srl (vector bool int, vector unsigned int);
13009 vector bool int vec_srl (vector bool int, vector unsigned short);
13010 vector bool int vec_srl (vector bool int, vector unsigned char);
13011 vector signed short vec_srl (vector signed short, vector unsigned int);
13012 vector signed short vec_srl (vector signed short,
13013 vector unsigned short);
13014 vector signed short vec_srl (vector signed short, vector unsigned char);
13015 vector unsigned short vec_srl (vector unsigned short,
13016 vector unsigned int);
13017 vector unsigned short vec_srl (vector unsigned short,
13018 vector unsigned short);
13019 vector unsigned short vec_srl (vector unsigned short,
13020 vector unsigned char);
13021 vector bool short vec_srl (vector bool short, vector unsigned int);
13022 vector bool short vec_srl (vector bool short, vector unsigned short);
13023 vector bool short vec_srl (vector bool short, vector unsigned char);
13024 vector pixel vec_srl (vector pixel, vector unsigned int);
13025 vector pixel vec_srl (vector pixel, vector unsigned short);
13026 vector pixel vec_srl (vector pixel, vector unsigned char);
13027 vector signed char vec_srl (vector signed char, vector unsigned int);
13028 vector signed char vec_srl (vector signed char, vector unsigned short);
13029 vector signed char vec_srl (vector signed char, vector unsigned char);
13030 vector unsigned char vec_srl (vector unsigned char,
13031 vector unsigned int);
13032 vector unsigned char vec_srl (vector unsigned char,
13033 vector unsigned short);
13034 vector unsigned char vec_srl (vector unsigned char,
13035 vector unsigned char);
13036 vector bool char vec_srl (vector bool char, vector unsigned int);
13037 vector bool char vec_srl (vector bool char, vector unsigned short);
13038 vector bool char vec_srl (vector bool char, vector unsigned char);
13039
13040 vector float vec_sro (vector float, vector signed char);
13041 vector float vec_sro (vector float, vector unsigned char);
13042 vector signed int vec_sro (vector signed int, vector signed char);
13043 vector signed int vec_sro (vector signed int, vector unsigned char);
13044 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13045 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13046 vector signed short vec_sro (vector signed short, vector signed char);
13047 vector signed short vec_sro (vector signed short, vector unsigned char);
13048 vector unsigned short vec_sro (vector unsigned short,
13049 vector signed char);
13050 vector unsigned short vec_sro (vector unsigned short,
13051 vector unsigned char);
13052 vector pixel vec_sro (vector pixel, vector signed char);
13053 vector pixel vec_sro (vector pixel, vector unsigned char);
13054 vector signed char vec_sro (vector signed char, vector signed char);
13055 vector signed char vec_sro (vector signed char, vector unsigned char);
13056 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13057 vector unsigned char vec_sro (vector unsigned char,
13058 vector unsigned char);
13059
13060 void vec_st (vector float, int, vector float *);
13061 void vec_st (vector float, int, float *);
13062 void vec_st (vector signed int, int, vector signed int *);
13063 void vec_st (vector signed int, int, int *);
13064 void vec_st (vector unsigned int, int, vector unsigned int *);
13065 void vec_st (vector unsigned int, int, unsigned int *);
13066 void vec_st (vector bool int, int, vector bool int *);
13067 void vec_st (vector bool int, int, unsigned int *);
13068 void vec_st (vector bool int, int, int *);
13069 void vec_st (vector signed short, int, vector signed short *);
13070 void vec_st (vector signed short, int, short *);
13071 void vec_st (vector unsigned short, int, vector unsigned short *);
13072 void vec_st (vector unsigned short, int, unsigned short *);
13073 void vec_st (vector bool short, int, vector bool short *);
13074 void vec_st (vector bool short, int, unsigned short *);
13075 void vec_st (vector pixel, int, vector pixel *);
13076 void vec_st (vector pixel, int, unsigned short *);
13077 void vec_st (vector pixel, int, short *);
13078 void vec_st (vector bool short, int, short *);
13079 void vec_st (vector signed char, int, vector signed char *);
13080 void vec_st (vector signed char, int, signed char *);
13081 void vec_st (vector unsigned char, int, vector unsigned char *);
13082 void vec_st (vector unsigned char, int, unsigned char *);
13083 void vec_st (vector bool char, int, vector bool char *);
13084 void vec_st (vector bool char, int, unsigned char *);
13085 void vec_st (vector bool char, int, signed char *);
13086
13087 void vec_ste (vector signed char, int, signed char *);
13088 void vec_ste (vector unsigned char, int, unsigned char *);
13089 void vec_ste (vector bool char, int, signed char *);
13090 void vec_ste (vector bool char, int, unsigned char *);
13091 void vec_ste (vector signed short, int, short *);
13092 void vec_ste (vector unsigned short, int, unsigned short *);
13093 void vec_ste (vector bool short, int, short *);
13094 void vec_ste (vector bool short, int, unsigned short *);
13095 void vec_ste (vector pixel, int, short *);
13096 void vec_ste (vector pixel, int, unsigned short *);
13097 void vec_ste (vector float, int, float *);
13098 void vec_ste (vector signed int, int, int *);
13099 void vec_ste (vector unsigned int, int, unsigned int *);
13100 void vec_ste (vector bool int, int, int *);
13101 void vec_ste (vector bool int, int, unsigned int *);
13102
13103 void vec_stvewx (vector float, int, float *);
13104 void vec_stvewx (vector signed int, int, int *);
13105 void vec_stvewx (vector unsigned int, int, unsigned int *);
13106 void vec_stvewx (vector bool int, int, int *);
13107 void vec_stvewx (vector bool int, int, unsigned int *);
13108
13109 void vec_stvehx (vector signed short, int, short *);
13110 void vec_stvehx (vector unsigned short, int, unsigned short *);
13111 void vec_stvehx (vector bool short, int, short *);
13112 void vec_stvehx (vector bool short, int, unsigned short *);
13113 void vec_stvehx (vector pixel, int, short *);
13114 void vec_stvehx (vector pixel, int, unsigned short *);
13115
13116 void vec_stvebx (vector signed char, int, signed char *);
13117 void vec_stvebx (vector unsigned char, int, unsigned char *);
13118 void vec_stvebx (vector bool char, int, signed char *);
13119 void vec_stvebx (vector bool char, int, unsigned char *);
13120
13121 void vec_stl (vector float, int, vector float *);
13122 void vec_stl (vector float, int, float *);
13123 void vec_stl (vector signed int, int, vector signed int *);
13124 void vec_stl (vector signed int, int, int *);
13125 void vec_stl (vector unsigned int, int, vector unsigned int *);
13126 void vec_stl (vector unsigned int, int, unsigned int *);
13127 void vec_stl (vector bool int, int, vector bool int *);
13128 void vec_stl (vector bool int, int, unsigned int *);
13129 void vec_stl (vector bool int, int, int *);
13130 void vec_stl (vector signed short, int, vector signed short *);
13131 void vec_stl (vector signed short, int, short *);
13132 void vec_stl (vector unsigned short, int, vector unsigned short *);
13133 void vec_stl (vector unsigned short, int, unsigned short *);
13134 void vec_stl (vector bool short, int, vector bool short *);
13135 void vec_stl (vector bool short, int, unsigned short *);
13136 void vec_stl (vector bool short, int, short *);
13137 void vec_stl (vector pixel, int, vector pixel *);
13138 void vec_stl (vector pixel, int, unsigned short *);
13139 void vec_stl (vector pixel, int, short *);
13140 void vec_stl (vector signed char, int, vector signed char *);
13141 void vec_stl (vector signed char, int, signed char *);
13142 void vec_stl (vector unsigned char, int, vector unsigned char *);
13143 void vec_stl (vector unsigned char, int, unsigned char *);
13144 void vec_stl (vector bool char, int, vector bool char *);
13145 void vec_stl (vector bool char, int, unsigned char *);
13146 void vec_stl (vector bool char, int, signed char *);
13147
13148 vector signed char vec_sub (vector bool char, vector signed char);
13149 vector signed char vec_sub (vector signed char, vector bool char);
13150 vector signed char vec_sub (vector signed char, vector signed char);
13151 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13152 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13153 vector unsigned char vec_sub (vector unsigned char,
13154 vector unsigned char);
13155 vector signed short vec_sub (vector bool short, vector signed short);
13156 vector signed short vec_sub (vector signed short, vector bool short);
13157 vector signed short vec_sub (vector signed short, vector signed short);
13158 vector unsigned short vec_sub (vector bool short,
13159 vector unsigned short);
13160 vector unsigned short vec_sub (vector unsigned short,
13161 vector bool short);
13162 vector unsigned short vec_sub (vector unsigned short,
13163 vector unsigned short);
13164 vector signed int vec_sub (vector bool int, vector signed int);
13165 vector signed int vec_sub (vector signed int, vector bool int);
13166 vector signed int vec_sub (vector signed int, vector signed int);
13167 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13168 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13169 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13170 vector float vec_sub (vector float, vector float);
13171
13172 vector float vec_vsubfp (vector float, vector float);
13173
13174 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13175 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13176 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13177 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13178 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13179 vector unsigned int vec_vsubuwm (vector unsigned int,
13180 vector unsigned int);
13181
13182 vector signed short vec_vsubuhm (vector bool short,
13183 vector signed short);
13184 vector signed short vec_vsubuhm (vector signed short,
13185 vector bool short);
13186 vector signed short vec_vsubuhm (vector signed short,
13187 vector signed short);
13188 vector unsigned short vec_vsubuhm (vector bool short,
13189 vector unsigned short);
13190 vector unsigned short vec_vsubuhm (vector unsigned short,
13191 vector bool short);
13192 vector unsigned short vec_vsubuhm (vector unsigned short,
13193 vector unsigned short);
13194
13195 vector signed char vec_vsububm (vector bool char, vector signed char);
13196 vector signed char vec_vsububm (vector signed char, vector bool char);
13197 vector signed char vec_vsububm (vector signed char, vector signed char);
13198 vector unsigned char vec_vsububm (vector bool char,
13199 vector unsigned char);
13200 vector unsigned char vec_vsububm (vector unsigned char,
13201 vector bool char);
13202 vector unsigned char vec_vsububm (vector unsigned char,
13203 vector unsigned char);
13204
13205 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13206
13207 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13208 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13209 vector unsigned char vec_subs (vector unsigned char,
13210 vector unsigned char);
13211 vector signed char vec_subs (vector bool char, vector signed char);
13212 vector signed char vec_subs (vector signed char, vector bool char);
13213 vector signed char vec_subs (vector signed char, vector signed char);
13214 vector unsigned short vec_subs (vector bool short,
13215 vector unsigned short);
13216 vector unsigned short vec_subs (vector unsigned short,
13217 vector bool short);
13218 vector unsigned short vec_subs (vector unsigned short,
13219 vector unsigned short);
13220 vector signed short vec_subs (vector bool short, vector signed short);
13221 vector signed short vec_subs (vector signed short, vector bool short);
13222 vector signed short vec_subs (vector signed short, vector signed short);
13223 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13224 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13225 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13226 vector signed int vec_subs (vector bool int, vector signed int);
13227 vector signed int vec_subs (vector signed int, vector bool int);
13228 vector signed int vec_subs (vector signed int, vector signed int);
13229
13230 vector signed int vec_vsubsws (vector bool int, vector signed int);
13231 vector signed int vec_vsubsws (vector signed int, vector bool int);
13232 vector signed int vec_vsubsws (vector signed int, vector signed int);
13233
13234 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13235 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13236 vector unsigned int vec_vsubuws (vector unsigned int,
13237 vector unsigned int);
13238
13239 vector signed short vec_vsubshs (vector bool short,
13240 vector signed short);
13241 vector signed short vec_vsubshs (vector signed short,
13242 vector bool short);
13243 vector signed short vec_vsubshs (vector signed short,
13244 vector signed short);
13245
13246 vector unsigned short vec_vsubuhs (vector bool short,
13247 vector unsigned short);
13248 vector unsigned short vec_vsubuhs (vector unsigned short,
13249 vector bool short);
13250 vector unsigned short vec_vsubuhs (vector unsigned short,
13251 vector unsigned short);
13252
13253 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13254 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13255 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13256
13257 vector unsigned char vec_vsububs (vector bool char,
13258 vector unsigned char);
13259 vector unsigned char vec_vsububs (vector unsigned char,
13260 vector bool char);
13261 vector unsigned char vec_vsububs (vector unsigned char,
13262 vector unsigned char);
13263
13264 vector unsigned int vec_sum4s (vector unsigned char,
13265 vector unsigned int);
13266 vector signed int vec_sum4s (vector signed char, vector signed int);
13267 vector signed int vec_sum4s (vector signed short, vector signed int);
13268
13269 vector signed int vec_vsum4shs (vector signed short, vector signed int);
13270
13271 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
13272
13273 vector unsigned int vec_vsum4ubs (vector unsigned char,
13274 vector unsigned int);
13275
13276 vector signed int vec_sum2s (vector signed int, vector signed int);
13277
13278 vector signed int vec_sums (vector signed int, vector signed int);
13279
13280 vector float vec_trunc (vector float);
13281
13282 vector signed short vec_unpackh (vector signed char);
13283 vector bool short vec_unpackh (vector bool char);
13284 vector signed int vec_unpackh (vector signed short);
13285 vector bool int vec_unpackh (vector bool short);
13286 vector unsigned int vec_unpackh (vector pixel);
13287
13288 vector bool int vec_vupkhsh (vector bool short);
13289 vector signed int vec_vupkhsh (vector signed short);
13290
13291 vector unsigned int vec_vupkhpx (vector pixel);
13292
13293 vector bool short vec_vupkhsb (vector bool char);
13294 vector signed short vec_vupkhsb (vector signed char);
13295
13296 vector signed short vec_unpackl (vector signed char);
13297 vector bool short vec_unpackl (vector bool char);
13298 vector unsigned int vec_unpackl (vector pixel);
13299 vector signed int vec_unpackl (vector signed short);
13300 vector bool int vec_unpackl (vector bool short);
13301
13302 vector unsigned int vec_vupklpx (vector pixel);
13303
13304 vector bool int vec_vupklsh (vector bool short);
13305 vector signed int vec_vupklsh (vector signed short);
13306
13307 vector bool short vec_vupklsb (vector bool char);
13308 vector signed short vec_vupklsb (vector signed char);
13309
13310 vector float vec_xor (vector float, vector float);
13311 vector float vec_xor (vector float, vector bool int);
13312 vector float vec_xor (vector bool int, vector float);
13313 vector bool int vec_xor (vector bool int, vector bool int);
13314 vector signed int vec_xor (vector bool int, vector signed int);
13315 vector signed int vec_xor (vector signed int, vector bool int);
13316 vector signed int vec_xor (vector signed int, vector signed int);
13317 vector unsigned int vec_xor (vector bool int, vector unsigned int);
13318 vector unsigned int vec_xor (vector unsigned int, vector bool int);
13319 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
13320 vector bool short vec_xor (vector bool short, vector bool short);
13321 vector signed short vec_xor (vector bool short, vector signed short);
13322 vector signed short vec_xor (vector signed short, vector bool short);
13323 vector signed short vec_xor (vector signed short, vector signed short);
13324 vector unsigned short vec_xor (vector bool short,
13325 vector unsigned short);
13326 vector unsigned short vec_xor (vector unsigned short,
13327 vector bool short);
13328 vector unsigned short vec_xor (vector unsigned short,
13329 vector unsigned short);
13330 vector signed char vec_xor (vector bool char, vector signed char);
13331 vector bool char vec_xor (vector bool char, vector bool char);
13332 vector signed char vec_xor (vector signed char, vector bool char);
13333 vector signed char vec_xor (vector signed char, vector signed char);
13334 vector unsigned char vec_xor (vector bool char, vector unsigned char);
13335 vector unsigned char vec_xor (vector unsigned char, vector bool char);
13336 vector unsigned char vec_xor (vector unsigned char,
13337 vector unsigned char);
13338
13339 int vec_all_eq (vector signed char, vector bool char);
13340 int vec_all_eq (vector signed char, vector signed char);
13341 int vec_all_eq (vector unsigned char, vector bool char);
13342 int vec_all_eq (vector unsigned char, vector unsigned char);
13343 int vec_all_eq (vector bool char, vector bool char);
13344 int vec_all_eq (vector bool char, vector unsigned char);
13345 int vec_all_eq (vector bool char, vector signed char);
13346 int vec_all_eq (vector signed short, vector bool short);
13347 int vec_all_eq (vector signed short, vector signed short);
13348 int vec_all_eq (vector unsigned short, vector bool short);
13349 int vec_all_eq (vector unsigned short, vector unsigned short);
13350 int vec_all_eq (vector bool short, vector bool short);
13351 int vec_all_eq (vector bool short, vector unsigned short);
13352 int vec_all_eq (vector bool short, vector signed short);
13353 int vec_all_eq (vector pixel, vector pixel);
13354 int vec_all_eq (vector signed int, vector bool int);
13355 int vec_all_eq (vector signed int, vector signed int);
13356 int vec_all_eq (vector unsigned int, vector bool int);
13357 int vec_all_eq (vector unsigned int, vector unsigned int);
13358 int vec_all_eq (vector bool int, vector bool int);
13359 int vec_all_eq (vector bool int, vector unsigned int);
13360 int vec_all_eq (vector bool int, vector signed int);
13361 int vec_all_eq (vector float, vector float);
13362
13363 int vec_all_ge (vector bool char, vector unsigned char);
13364 int vec_all_ge (vector unsigned char, vector bool char);
13365 int vec_all_ge (vector unsigned char, vector unsigned char);
13366 int vec_all_ge (vector bool char, vector signed char);
13367 int vec_all_ge (vector signed char, vector bool char);
13368 int vec_all_ge (vector signed char, vector signed char);
13369 int vec_all_ge (vector bool short, vector unsigned short);
13370 int vec_all_ge (vector unsigned short, vector bool short);
13371 int vec_all_ge (vector unsigned short, vector unsigned short);
13372 int vec_all_ge (vector signed short, vector signed short);
13373 int vec_all_ge (vector bool short, vector signed short);
13374 int vec_all_ge (vector signed short, vector bool short);
13375 int vec_all_ge (vector bool int, vector unsigned int);
13376 int vec_all_ge (vector unsigned int, vector bool int);
13377 int vec_all_ge (vector unsigned int, vector unsigned int);
13378 int vec_all_ge (vector bool int, vector signed int);
13379 int vec_all_ge (vector signed int, vector bool int);
13380 int vec_all_ge (vector signed int, vector signed int);
13381 int vec_all_ge (vector float, vector float);
13382
13383 int vec_all_gt (vector bool char, vector unsigned char);
13384 int vec_all_gt (vector unsigned char, vector bool char);
13385 int vec_all_gt (vector unsigned char, vector unsigned char);
13386 int vec_all_gt (vector bool char, vector signed char);
13387 int vec_all_gt (vector signed char, vector bool char);
13388 int vec_all_gt (vector signed char, vector signed char);
13389 int vec_all_gt (vector bool short, vector unsigned short);
13390 int vec_all_gt (vector unsigned short, vector bool short);
13391 int vec_all_gt (vector unsigned short, vector unsigned short);
13392 int vec_all_gt (vector bool short, vector signed short);
13393 int vec_all_gt (vector signed short, vector bool short);
13394 int vec_all_gt (vector signed short, vector signed short);
13395 int vec_all_gt (vector bool int, vector unsigned int);
13396 int vec_all_gt (vector unsigned int, vector bool int);
13397 int vec_all_gt (vector unsigned int, vector unsigned int);
13398 int vec_all_gt (vector bool int, vector signed int);
13399 int vec_all_gt (vector signed int, vector bool int);
13400 int vec_all_gt (vector signed int, vector signed int);
13401 int vec_all_gt (vector float, vector float);
13402
13403 int vec_all_in (vector float, vector float);
13404
13405 int vec_all_le (vector bool char, vector unsigned char);
13406 int vec_all_le (vector unsigned char, vector bool char);
13407 int vec_all_le (vector unsigned char, vector unsigned char);
13408 int vec_all_le (vector bool char, vector signed char);
13409 int vec_all_le (vector signed char, vector bool char);
13410 int vec_all_le (vector signed char, vector signed char);
13411 int vec_all_le (vector bool short, vector unsigned short);
13412 int vec_all_le (vector unsigned short, vector bool short);
13413 int vec_all_le (vector unsigned short, vector unsigned short);
13414 int vec_all_le (vector bool short, vector signed short);
13415 int vec_all_le (vector signed short, vector bool short);
13416 int vec_all_le (vector signed short, vector signed short);
13417 int vec_all_le (vector bool int, vector unsigned int);
13418 int vec_all_le (vector unsigned int, vector bool int);
13419 int vec_all_le (vector unsigned int, vector unsigned int);
13420 int vec_all_le (vector bool int, vector signed int);
13421 int vec_all_le (vector signed int, vector bool int);
13422 int vec_all_le (vector signed int, vector signed int);
13423 int vec_all_le (vector float, vector float);
13424
13425 int vec_all_lt (vector bool char, vector unsigned char);
13426 int vec_all_lt (vector unsigned char, vector bool char);
13427 int vec_all_lt (vector unsigned char, vector unsigned char);
13428 int vec_all_lt (vector bool char, vector signed char);
13429 int vec_all_lt (vector signed char, vector bool char);
13430 int vec_all_lt (vector signed char, vector signed char);
13431 int vec_all_lt (vector bool short, vector unsigned short);
13432 int vec_all_lt (vector unsigned short, vector bool short);
13433 int vec_all_lt (vector unsigned short, vector unsigned short);
13434 int vec_all_lt (vector bool short, vector signed short);
13435 int vec_all_lt (vector signed short, vector bool short);
13436 int vec_all_lt (vector signed short, vector signed short);
13437 int vec_all_lt (vector bool int, vector unsigned int);
13438 int vec_all_lt (vector unsigned int, vector bool int);
13439 int vec_all_lt (vector unsigned int, vector unsigned int);
13440 int vec_all_lt (vector bool int, vector signed int);
13441 int vec_all_lt (vector signed int, vector bool int);
13442 int vec_all_lt (vector signed int, vector signed int);
13443 int vec_all_lt (vector float, vector float);
13444
13445 int vec_all_nan (vector float);
13446
13447 int vec_all_ne (vector signed char, vector bool char);
13448 int vec_all_ne (vector signed char, vector signed char);
13449 int vec_all_ne (vector unsigned char, vector bool char);
13450 int vec_all_ne (vector unsigned char, vector unsigned char);
13451 int vec_all_ne (vector bool char, vector bool char);
13452 int vec_all_ne (vector bool char, vector unsigned char);
13453 int vec_all_ne (vector bool char, vector signed char);
13454 int vec_all_ne (vector signed short, vector bool short);
13455 int vec_all_ne (vector signed short, vector signed short);
13456 int vec_all_ne (vector unsigned short, vector bool short);
13457 int vec_all_ne (vector unsigned short, vector unsigned short);
13458 int vec_all_ne (vector bool short, vector bool short);
13459 int vec_all_ne (vector bool short, vector unsigned short);
13460 int vec_all_ne (vector bool short, vector signed short);
13461 int vec_all_ne (vector pixel, vector pixel);
13462 int vec_all_ne (vector signed int, vector bool int);
13463 int vec_all_ne (vector signed int, vector signed int);
13464 int vec_all_ne (vector unsigned int, vector bool int);
13465 int vec_all_ne (vector unsigned int, vector unsigned int);
13466 int vec_all_ne (vector bool int, vector bool int);
13467 int vec_all_ne (vector bool int, vector unsigned int);
13468 int vec_all_ne (vector bool int, vector signed int);
13469 int vec_all_ne (vector float, vector float);
13470
13471 int vec_all_nge (vector float, vector float);
13472
13473 int vec_all_ngt (vector float, vector float);
13474
13475 int vec_all_nle (vector float, vector float);
13476
13477 int vec_all_nlt (vector float, vector float);
13478
13479 int vec_all_numeric (vector float);
13480
13481 int vec_any_eq (vector signed char, vector bool char);
13482 int vec_any_eq (vector signed char, vector signed char);
13483 int vec_any_eq (vector unsigned char, vector bool char);
13484 int vec_any_eq (vector unsigned char, vector unsigned char);
13485 int vec_any_eq (vector bool char, vector bool char);
13486 int vec_any_eq (vector bool char, vector unsigned char);
13487 int vec_any_eq (vector bool char, vector signed char);
13488 int vec_any_eq (vector signed short, vector bool short);
13489 int vec_any_eq (vector signed short, vector signed short);
13490 int vec_any_eq (vector unsigned short, vector bool short);
13491 int vec_any_eq (vector unsigned short, vector unsigned short);
13492 int vec_any_eq (vector bool short, vector bool short);
13493 int vec_any_eq (vector bool short, vector unsigned short);
13494 int vec_any_eq (vector bool short, vector signed short);
13495 int vec_any_eq (vector pixel, vector pixel);
13496 int vec_any_eq (vector signed int, vector bool int);
13497 int vec_any_eq (vector signed int, vector signed int);
13498 int vec_any_eq (vector unsigned int, vector bool int);
13499 int vec_any_eq (vector unsigned int, vector unsigned int);
13500 int vec_any_eq (vector bool int, vector bool int);
13501 int vec_any_eq (vector bool int, vector unsigned int);
13502 int vec_any_eq (vector bool int, vector signed int);
13503 int vec_any_eq (vector float, vector float);
13504
13505 int vec_any_ge (vector signed char, vector bool char);
13506 int vec_any_ge (vector unsigned char, vector bool char);
13507 int vec_any_ge (vector unsigned char, vector unsigned char);
13508 int vec_any_ge (vector signed char, vector signed char);
13509 int vec_any_ge (vector bool char, vector unsigned char);
13510 int vec_any_ge (vector bool char, vector signed char);
13511 int vec_any_ge (vector unsigned short, vector bool short);
13512 int vec_any_ge (vector unsigned short, vector unsigned short);
13513 int vec_any_ge (vector signed short, vector signed short);
13514 int vec_any_ge (vector signed short, vector bool short);
13515 int vec_any_ge (vector bool short, vector unsigned short);
13516 int vec_any_ge (vector bool short, vector signed short);
13517 int vec_any_ge (vector signed int, vector bool int);
13518 int vec_any_ge (vector unsigned int, vector bool int);
13519 int vec_any_ge (vector unsigned int, vector unsigned int);
13520 int vec_any_ge (vector signed int, vector signed int);
13521 int vec_any_ge (vector bool int, vector unsigned int);
13522 int vec_any_ge (vector bool int, vector signed int);
13523 int vec_any_ge (vector float, vector float);
13524
13525 int vec_any_gt (vector bool char, vector unsigned char);
13526 int vec_any_gt (vector unsigned char, vector bool char);
13527 int vec_any_gt (vector unsigned char, vector unsigned char);
13528 int vec_any_gt (vector bool char, vector signed char);
13529 int vec_any_gt (vector signed char, vector bool char);
13530 int vec_any_gt (vector signed char, vector signed char);
13531 int vec_any_gt (vector bool short, vector unsigned short);
13532 int vec_any_gt (vector unsigned short, vector bool short);
13533 int vec_any_gt (vector unsigned short, vector unsigned short);
13534 int vec_any_gt (vector bool short, vector signed short);
13535 int vec_any_gt (vector signed short, vector bool short);
13536 int vec_any_gt (vector signed short, vector signed short);
13537 int vec_any_gt (vector bool int, vector unsigned int);
13538 int vec_any_gt (vector unsigned int, vector bool int);
13539 int vec_any_gt (vector unsigned int, vector unsigned int);
13540 int vec_any_gt (vector bool int, vector signed int);
13541 int vec_any_gt (vector signed int, vector bool int);
13542 int vec_any_gt (vector signed int, vector signed int);
13543 int vec_any_gt (vector float, vector float);
13544
13545 int vec_any_le (vector bool char, vector unsigned char);
13546 int vec_any_le (vector unsigned char, vector bool char);
13547 int vec_any_le (vector unsigned char, vector unsigned char);
13548 int vec_any_le (vector bool char, vector signed char);
13549 int vec_any_le (vector signed char, vector bool char);
13550 int vec_any_le (vector signed char, vector signed char);
13551 int vec_any_le (vector bool short, vector unsigned short);
13552 int vec_any_le (vector unsigned short, vector bool short);
13553 int vec_any_le (vector unsigned short, vector unsigned short);
13554 int vec_any_le (vector bool short, vector signed short);
13555 int vec_any_le (vector signed short, vector bool short);
13556 int vec_any_le (vector signed short, vector signed short);
13557 int vec_any_le (vector bool int, vector unsigned int);
13558 int vec_any_le (vector unsigned int, vector bool int);
13559 int vec_any_le (vector unsigned int, vector unsigned int);
13560 int vec_any_le (vector bool int, vector signed int);
13561 int vec_any_le (vector signed int, vector bool int);
13562 int vec_any_le (vector signed int, vector signed int);
13563 int vec_any_le (vector float, vector float);
13564
13565 int vec_any_lt (vector bool char, vector unsigned char);
13566 int vec_any_lt (vector unsigned char, vector bool char);
13567 int vec_any_lt (vector unsigned char, vector unsigned char);
13568 int vec_any_lt (vector bool char, vector signed char);
13569 int vec_any_lt (vector signed char, vector bool char);
13570 int vec_any_lt (vector signed char, vector signed char);
13571 int vec_any_lt (vector bool short, vector unsigned short);
13572 int vec_any_lt (vector unsigned short, vector bool short);
13573 int vec_any_lt (vector unsigned short, vector unsigned short);
13574 int vec_any_lt (vector bool short, vector signed short);
13575 int vec_any_lt (vector signed short, vector bool short);
13576 int vec_any_lt (vector signed short, vector signed short);
13577 int vec_any_lt (vector bool int, vector unsigned int);
13578 int vec_any_lt (vector unsigned int, vector bool int);
13579 int vec_any_lt (vector unsigned int, vector unsigned int);
13580 int vec_any_lt (vector bool int, vector signed int);
13581 int vec_any_lt (vector signed int, vector bool int);
13582 int vec_any_lt (vector signed int, vector signed int);
13583 int vec_any_lt (vector float, vector float);
13584
13585 int vec_any_nan (vector float);
13586
13587 int vec_any_ne (vector signed char, vector bool char);
13588 int vec_any_ne (vector signed char, vector signed char);
13589 int vec_any_ne (vector unsigned char, vector bool char);
13590 int vec_any_ne (vector unsigned char, vector unsigned char);
13591 int vec_any_ne (vector bool char, vector bool char);
13592 int vec_any_ne (vector bool char, vector unsigned char);
13593 int vec_any_ne (vector bool char, vector signed char);
13594 int vec_any_ne (vector signed short, vector bool short);
13595 int vec_any_ne (vector signed short, vector signed short);
13596 int vec_any_ne (vector unsigned short, vector bool short);
13597 int vec_any_ne (vector unsigned short, vector unsigned short);
13598 int vec_any_ne (vector bool short, vector bool short);
13599 int vec_any_ne (vector bool short, vector unsigned short);
13600 int vec_any_ne (vector bool short, vector signed short);
13601 int vec_any_ne (vector pixel, vector pixel);
13602 int vec_any_ne (vector signed int, vector bool int);
13603 int vec_any_ne (vector signed int, vector signed int);
13604 int vec_any_ne (vector unsigned int, vector bool int);
13605 int vec_any_ne (vector unsigned int, vector unsigned int);
13606 int vec_any_ne (vector bool int, vector bool int);
13607 int vec_any_ne (vector bool int, vector unsigned int);
13608 int vec_any_ne (vector bool int, vector signed int);
13609 int vec_any_ne (vector float, vector float);
13610
13611 int vec_any_nge (vector float, vector float);
13612
13613 int vec_any_ngt (vector float, vector float);
13614
13615 int vec_any_nle (vector float, vector float);
13616
13617 int vec_any_nlt (vector float, vector float);
13618
13619 int vec_any_numeric (vector float);
13620
13621 int vec_any_out (vector float, vector float);
13622 @end smallexample
13623
13624 If the vector/scalar (VSX) instruction set is available, the following
13625 additional functions are available:
13626
13627 @smallexample
13628 vector double vec_abs (vector double);
13629 vector double vec_add (vector double, vector double);
13630 vector double vec_and (vector double, vector double);
13631 vector double vec_and (vector double, vector bool long);
13632 vector double vec_and (vector bool long, vector double);
13633 vector double vec_andc (vector double, vector double);
13634 vector double vec_andc (vector double, vector bool long);
13635 vector double vec_andc (vector bool long, vector double);
13636 vector double vec_ceil (vector double);
13637 vector bool long vec_cmpeq (vector double, vector double);
13638 vector bool long vec_cmpge (vector double, vector double);
13639 vector bool long vec_cmpgt (vector double, vector double);
13640 vector bool long vec_cmple (vector double, vector double);
13641 vector bool long vec_cmplt (vector double, vector double);
13642 vector float vec_div (vector float, vector float);
13643 vector double vec_div (vector double, vector double);
13644 vector double vec_floor (vector double);
13645 vector double vec_ld (int, const vector double *);
13646 vector double vec_ld (int, const double *);
13647 vector double vec_ldl (int, const vector double *);
13648 vector double vec_ldl (int, const double *);
13649 vector unsigned char vec_lvsl (int, const volatile double *);
13650 vector unsigned char vec_lvsr (int, const volatile double *);
13651 vector double vec_madd (vector double, vector double, vector double);
13652 vector double vec_max (vector double, vector double);
13653 vector double vec_min (vector double, vector double);
13654 vector float vec_msub (vector float, vector float, vector float);
13655 vector double vec_msub (vector double, vector double, vector double);
13656 vector float vec_mul (vector float, vector float);
13657 vector double vec_mul (vector double, vector double);
13658 vector float vec_nearbyint (vector float);
13659 vector double vec_nearbyint (vector double);
13660 vector float vec_nmadd (vector float, vector float, vector float);
13661 vector double vec_nmadd (vector double, vector double, vector double);
13662 vector double vec_nmsub (vector double, vector double, vector double);
13663 vector double vec_nor (vector double, vector double);
13664 vector double vec_or (vector double, vector double);
13665 vector double vec_or (vector double, vector bool long);
13666 vector double vec_or (vector bool long, vector double);
13667 vector double vec_perm (vector double,
13668 vector double,
13669 vector unsigned char);
13670 vector double vec_rint (vector double);
13671 vector double vec_recip (vector double, vector double);
13672 vector double vec_rsqrt (vector double);
13673 vector double vec_rsqrte (vector double);
13674 vector double vec_sel (vector double, vector double, vector bool long);
13675 vector double vec_sel (vector double, vector double, vector unsigned long);
13676 vector double vec_sub (vector double, vector double);
13677 vector float vec_sqrt (vector float);
13678 vector double vec_sqrt (vector double);
13679 void vec_st (vector double, int, vector double *);
13680 void vec_st (vector double, int, double *);
13681 vector double vec_trunc (vector double);
13682 vector double vec_xor (vector double, vector double);
13683 vector double vec_xor (vector double, vector bool long);
13684 vector double vec_xor (vector bool long, vector double);
13685 int vec_all_eq (vector double, vector double);
13686 int vec_all_ge (vector double, vector double);
13687 int vec_all_gt (vector double, vector double);
13688 int vec_all_le (vector double, vector double);
13689 int vec_all_lt (vector double, vector double);
13690 int vec_all_nan (vector double);
13691 int vec_all_ne (vector double, vector double);
13692 int vec_all_nge (vector double, vector double);
13693 int vec_all_ngt (vector double, vector double);
13694 int vec_all_nle (vector double, vector double);
13695 int vec_all_nlt (vector double, vector double);
13696 int vec_all_numeric (vector double);
13697 int vec_any_eq (vector double, vector double);
13698 int vec_any_ge (vector double, vector double);
13699 int vec_any_gt (vector double, vector double);
13700 int vec_any_le (vector double, vector double);
13701 int vec_any_lt (vector double, vector double);
13702 int vec_any_nan (vector double);
13703 int vec_any_ne (vector double, vector double);
13704 int vec_any_nge (vector double, vector double);
13705 int vec_any_ngt (vector double, vector double);
13706 int vec_any_nle (vector double, vector double);
13707 int vec_any_nlt (vector double, vector double);
13708 int vec_any_numeric (vector double);
13709
13710 vector double vec_vsx_ld (int, const vector double *);
13711 vector double vec_vsx_ld (int, const double *);
13712 vector float vec_vsx_ld (int, const vector float *);
13713 vector float vec_vsx_ld (int, const float *);
13714 vector bool int vec_vsx_ld (int, const vector bool int *);
13715 vector signed int vec_vsx_ld (int, const vector signed int *);
13716 vector signed int vec_vsx_ld (int, const int *);
13717 vector signed int vec_vsx_ld (int, const long *);
13718 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
13719 vector unsigned int vec_vsx_ld (int, const unsigned int *);
13720 vector unsigned int vec_vsx_ld (int, const unsigned long *);
13721 vector bool short vec_vsx_ld (int, const vector bool short *);
13722 vector pixel vec_vsx_ld (int, const vector pixel *);
13723 vector signed short vec_vsx_ld (int, const vector signed short *);
13724 vector signed short vec_vsx_ld (int, const short *);
13725 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
13726 vector unsigned short vec_vsx_ld (int, const unsigned short *);
13727 vector bool char vec_vsx_ld (int, const vector bool char *);
13728 vector signed char vec_vsx_ld (int, const vector signed char *);
13729 vector signed char vec_vsx_ld (int, const signed char *);
13730 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
13731 vector unsigned char vec_vsx_ld (int, const unsigned char *);
13732
13733 void vec_vsx_st (vector double, int, vector double *);
13734 void vec_vsx_st (vector double, int, double *);
13735 void vec_vsx_st (vector float, int, vector float *);
13736 void vec_vsx_st (vector float, int, float *);
13737 void vec_vsx_st (vector signed int, int, vector signed int *);
13738 void vec_vsx_st (vector signed int, int, int *);
13739 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
13740 void vec_vsx_st (vector unsigned int, int, unsigned int *);
13741 void vec_vsx_st (vector bool int, int, vector bool int *);
13742 void vec_vsx_st (vector bool int, int, unsigned int *);
13743 void vec_vsx_st (vector bool int, int, int *);
13744 void vec_vsx_st (vector signed short, int, vector signed short *);
13745 void vec_vsx_st (vector signed short, int, short *);
13746 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
13747 void vec_vsx_st (vector unsigned short, int, unsigned short *);
13748 void vec_vsx_st (vector bool short, int, vector bool short *);
13749 void vec_vsx_st (vector bool short, int, unsigned short *);
13750 void vec_vsx_st (vector pixel, int, vector pixel *);
13751 void vec_vsx_st (vector pixel, int, unsigned short *);
13752 void vec_vsx_st (vector pixel, int, short *);
13753 void vec_vsx_st (vector bool short, int, short *);
13754 void vec_vsx_st (vector signed char, int, vector signed char *);
13755 void vec_vsx_st (vector signed char, int, signed char *);
13756 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
13757 void vec_vsx_st (vector unsigned char, int, unsigned char *);
13758 void vec_vsx_st (vector bool char, int, vector bool char *);
13759 void vec_vsx_st (vector bool char, int, unsigned char *);
13760 void vec_vsx_st (vector bool char, int, signed char *);
13761 @end smallexample
13762
13763 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
13764 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
13765 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
13766 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
13767 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
13768
13769 @node SH Built-in Functions
13770 @subsection SH Built-in Functions
13771 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
13772 families of processors:
13773
13774 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
13775 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
13776 used by system code that manages threads and execution contexts. The compiler
13777 normally does not generate code that modifies the contents of @samp{GBR} and
13778 thus the value is preserved across function calls. Changing the @samp{GBR}
13779 value in user code must be done with caution, since the compiler might use
13780 @samp{GBR} in order to access thread local variables.
13781
13782 @end deftypefn
13783
13784 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
13785 Returns the value that is currently set in the @samp{GBR} register.
13786 Memory loads and stores that use the thread pointer as a base address are
13787 turned into @samp{GBR} based displacement loads and stores, if possible.
13788 For example:
13789 @smallexample
13790 struct my_tcb
13791 @{
13792 int a, b, c, d, e;
13793 @};
13794
13795 int get_tcb_value (void)
13796 @{
13797 // Generate @samp{mov.l @@(8,gbr),r0} instruction
13798 return ((my_tcb*)__builtin_thread_pointer ())->c;
13799 @}
13800
13801 @end smallexample
13802 @end deftypefn
13803
13804 @node RX Built-in Functions
13805 @subsection RX Built-in Functions
13806 GCC supports some of the RX instructions which cannot be expressed in
13807 the C programming language via the use of built-in functions. The
13808 following functions are supported:
13809
13810 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
13811 Generates the @code{brk} machine instruction.
13812 @end deftypefn
13813
13814 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
13815 Generates the @code{clrpsw} machine instruction to clear the specified
13816 bit in the processor status word.
13817 @end deftypefn
13818
13819 @deftypefn {Built-in Function} void __builtin_rx_int (int)
13820 Generates the @code{int} machine instruction to generate an interrupt
13821 with the specified value.
13822 @end deftypefn
13823
13824 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
13825 Generates the @code{machi} machine instruction to add the result of
13826 multiplying the top 16 bits of the two arguments into the
13827 accumulator.
13828 @end deftypefn
13829
13830 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
13831 Generates the @code{maclo} machine instruction to add the result of
13832 multiplying the bottom 16 bits of the two arguments into the
13833 accumulator.
13834 @end deftypefn
13835
13836 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
13837 Generates the @code{mulhi} machine instruction to place the result of
13838 multiplying the top 16 bits of the two arguments into the
13839 accumulator.
13840 @end deftypefn
13841
13842 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
13843 Generates the @code{mullo} machine instruction to place the result of
13844 multiplying the bottom 16 bits of the two arguments into the
13845 accumulator.
13846 @end deftypefn
13847
13848 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
13849 Generates the @code{mvfachi} machine instruction to read the top
13850 32 bits of the accumulator.
13851 @end deftypefn
13852
13853 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
13854 Generates the @code{mvfacmi} machine instruction to read the middle
13855 32 bits of the accumulator.
13856 @end deftypefn
13857
13858 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
13859 Generates the @code{mvfc} machine instruction which reads the control
13860 register specified in its argument and returns its value.
13861 @end deftypefn
13862
13863 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
13864 Generates the @code{mvtachi} machine instruction to set the top
13865 32 bits of the accumulator.
13866 @end deftypefn
13867
13868 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
13869 Generates the @code{mvtaclo} machine instruction to set the bottom
13870 32 bits of the accumulator.
13871 @end deftypefn
13872
13873 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
13874 Generates the @code{mvtc} machine instruction which sets control
13875 register number @code{reg} to @code{val}.
13876 @end deftypefn
13877
13878 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
13879 Generates the @code{mvtipl} machine instruction set the interrupt
13880 priority level.
13881 @end deftypefn
13882
13883 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
13884 Generates the @code{racw} machine instruction to round the accumulator
13885 according to the specified mode.
13886 @end deftypefn
13887
13888 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
13889 Generates the @code{revw} machine instruction which swaps the bytes in
13890 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
13891 and also bits 16--23 occupy bits 24--31 and vice versa.
13892 @end deftypefn
13893
13894 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
13895 Generates the @code{rmpa} machine instruction which initiates a
13896 repeated multiply and accumulate sequence.
13897 @end deftypefn
13898
13899 @deftypefn {Built-in Function} void __builtin_rx_round (float)
13900 Generates the @code{round} machine instruction which returns the
13901 floating-point argument rounded according to the current rounding mode
13902 set in the floating-point status word register.
13903 @end deftypefn
13904
13905 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
13906 Generates the @code{sat} machine instruction which returns the
13907 saturated value of the argument.
13908 @end deftypefn
13909
13910 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
13911 Generates the @code{setpsw} machine instruction to set the specified
13912 bit in the processor status word.
13913 @end deftypefn
13914
13915 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
13916 Generates the @code{wait} machine instruction.
13917 @end deftypefn
13918
13919 @node SPARC VIS Built-in Functions
13920 @subsection SPARC VIS Built-in Functions
13921
13922 GCC supports SIMD operations on the SPARC using both the generic vector
13923 extensions (@pxref{Vector Extensions}) as well as built-in functions for
13924 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
13925 switch, the VIS extension is exposed as the following built-in functions:
13926
13927 @smallexample
13928 typedef int v1si __attribute__ ((vector_size (4)));
13929 typedef int v2si __attribute__ ((vector_size (8)));
13930 typedef short v4hi __attribute__ ((vector_size (8)));
13931 typedef short v2hi __attribute__ ((vector_size (4)));
13932 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
13933 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
13934
13935 void __builtin_vis_write_gsr (int64_t);
13936 int64_t __builtin_vis_read_gsr (void);
13937
13938 void * __builtin_vis_alignaddr (void *, long);
13939 void * __builtin_vis_alignaddrl (void *, long);
13940 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
13941 v2si __builtin_vis_faligndatav2si (v2si, v2si);
13942 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
13943 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
13944
13945 v4hi __builtin_vis_fexpand (v4qi);
13946
13947 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
13948 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
13949 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
13950 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
13951 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
13952 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
13953 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
13954
13955 v4qi __builtin_vis_fpack16 (v4hi);
13956 v8qi __builtin_vis_fpack32 (v2si, v8qi);
13957 v2hi __builtin_vis_fpackfix (v2si);
13958 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
13959
13960 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
13961
13962 long __builtin_vis_edge8 (void *, void *);
13963 long __builtin_vis_edge8l (void *, void *);
13964 long __builtin_vis_edge16 (void *, void *);
13965 long __builtin_vis_edge16l (void *, void *);
13966 long __builtin_vis_edge32 (void *, void *);
13967 long __builtin_vis_edge32l (void *, void *);
13968
13969 long __builtin_vis_fcmple16 (v4hi, v4hi);
13970 long __builtin_vis_fcmple32 (v2si, v2si);
13971 long __builtin_vis_fcmpne16 (v4hi, v4hi);
13972 long __builtin_vis_fcmpne32 (v2si, v2si);
13973 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
13974 long __builtin_vis_fcmpgt32 (v2si, v2si);
13975 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
13976 long __builtin_vis_fcmpeq32 (v2si, v2si);
13977
13978 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
13979 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
13980 v2si __builtin_vis_fpadd32 (v2si, v2si);
13981 v1si __builtin_vis_fpadd32s (v1si, v1si);
13982 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
13983 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
13984 v2si __builtin_vis_fpsub32 (v2si, v2si);
13985 v1si __builtin_vis_fpsub32s (v1si, v1si);
13986
13987 long __builtin_vis_array8 (long, long);
13988 long __builtin_vis_array16 (long, long);
13989 long __builtin_vis_array32 (long, long);
13990 @end smallexample
13991
13992 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
13993 functions also become available:
13994
13995 @smallexample
13996 long __builtin_vis_bmask (long, long);
13997 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
13998 v2si __builtin_vis_bshufflev2si (v2si, v2si);
13999 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
14000 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
14001
14002 long __builtin_vis_edge8n (void *, void *);
14003 long __builtin_vis_edge8ln (void *, void *);
14004 long __builtin_vis_edge16n (void *, void *);
14005 long __builtin_vis_edge16ln (void *, void *);
14006 long __builtin_vis_edge32n (void *, void *);
14007 long __builtin_vis_edge32ln (void *, void *);
14008 @end smallexample
14009
14010 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
14011 functions also become available:
14012
14013 @smallexample
14014 void __builtin_vis_cmask8 (long);
14015 void __builtin_vis_cmask16 (long);
14016 void __builtin_vis_cmask32 (long);
14017
14018 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
14019
14020 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
14021 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
14022 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
14023 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
14024 v2si __builtin_vis_fsll16 (v2si, v2si);
14025 v2si __builtin_vis_fslas16 (v2si, v2si);
14026 v2si __builtin_vis_fsrl16 (v2si, v2si);
14027 v2si __builtin_vis_fsra16 (v2si, v2si);
14028
14029 long __builtin_vis_pdistn (v8qi, v8qi);
14030
14031 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
14032
14033 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
14034 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
14035
14036 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
14037 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
14038 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
14039 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
14040 v2si __builtin_vis_fpadds32 (v2si, v2si);
14041 v1si __builtin_vis_fpadds32s (v1si, v1si);
14042 v2si __builtin_vis_fpsubs32 (v2si, v2si);
14043 v1si __builtin_vis_fpsubs32s (v1si, v1si);
14044
14045 long __builtin_vis_fucmple8 (v8qi, v8qi);
14046 long __builtin_vis_fucmpne8 (v8qi, v8qi);
14047 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
14048 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
14049
14050 float __builtin_vis_fhadds (float, float);
14051 double __builtin_vis_fhaddd (double, double);
14052 float __builtin_vis_fhsubs (float, float);
14053 double __builtin_vis_fhsubd (double, double);
14054 float __builtin_vis_fnhadds (float, float);
14055 double __builtin_vis_fnhaddd (double, double);
14056
14057 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
14058 int64_t __builtin_vis_xmulx (int64_t, int64_t);
14059 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
14060 @end smallexample
14061
14062 @node SPU Built-in Functions
14063 @subsection SPU Built-in Functions
14064
14065 GCC provides extensions for the SPU processor as described in the
14066 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
14067 found at @uref{http://cell.scei.co.jp/} or
14068 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
14069 implementation differs in several ways.
14070
14071 @itemize @bullet
14072
14073 @item
14074 The optional extension of specifying vector constants in parentheses is
14075 not supported.
14076
14077 @item
14078 A vector initializer requires no cast if the vector constant is of the
14079 same type as the variable it is initializing.
14080
14081 @item
14082 If @code{signed} or @code{unsigned} is omitted, the signedness of the
14083 vector type is the default signedness of the base type. The default
14084 varies depending on the operating system, so a portable program should
14085 always specify the signedness.
14086
14087 @item
14088 By default, the keyword @code{__vector} is added. The macro
14089 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
14090 undefined.
14091
14092 @item
14093 GCC allows using a @code{typedef} name as the type specifier for a
14094 vector type.
14095
14096 @item
14097 For C, overloaded functions are implemented with macros so the following
14098 does not work:
14099
14100 @smallexample
14101 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14102 @end smallexample
14103
14104 @noindent
14105 Since @code{spu_add} is a macro, the vector constant in the example
14106 is treated as four separate arguments. Wrap the entire argument in
14107 parentheses for this to work.
14108
14109 @item
14110 The extended version of @code{__builtin_expect} is not supported.
14111
14112 @end itemize
14113
14114 @emph{Note:} Only the interface described in the aforementioned
14115 specification is supported. Internally, GCC uses built-in functions to
14116 implement the required functionality, but these are not supported and
14117 are subject to change without notice.
14118
14119 @node TI C6X Built-in Functions
14120 @subsection TI C6X Built-in Functions
14121
14122 GCC provides intrinsics to access certain instructions of the TI C6X
14123 processors. These intrinsics, listed below, are available after
14124 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
14125 to C6X instructions.
14126
14127 @smallexample
14128
14129 int _sadd (int, int)
14130 int _ssub (int, int)
14131 int _sadd2 (int, int)
14132 int _ssub2 (int, int)
14133 long long _mpy2 (int, int)
14134 long long _smpy2 (int, int)
14135 int _add4 (int, int)
14136 int _sub4 (int, int)
14137 int _saddu4 (int, int)
14138
14139 int _smpy (int, int)
14140 int _smpyh (int, int)
14141 int _smpyhl (int, int)
14142 int _smpylh (int, int)
14143
14144 int _sshl (int, int)
14145 int _subc (int, int)
14146
14147 int _avg2 (int, int)
14148 int _avgu4 (int, int)
14149
14150 int _clrr (int, int)
14151 int _extr (int, int)
14152 int _extru (int, int)
14153 int _abs (int)
14154 int _abs2 (int)
14155
14156 @end smallexample
14157
14158 @node TILE-Gx Built-in Functions
14159 @subsection TILE-Gx Built-in Functions
14160
14161 GCC provides intrinsics to access every instruction of the TILE-Gx
14162 processor. The intrinsics are of the form:
14163
14164 @smallexample
14165
14166 unsigned long long __insn_@var{op} (...)
14167
14168 @end smallexample
14169
14170 Where @var{op} is the name of the instruction. Refer to the ISA manual
14171 for the complete list of instructions.
14172
14173 GCC also provides intrinsics to directly access the network registers.
14174 The intrinsics are:
14175
14176 @smallexample
14177
14178 unsigned long long __tile_idn0_receive (void)
14179 unsigned long long __tile_idn1_receive (void)
14180 unsigned long long __tile_udn0_receive (void)
14181 unsigned long long __tile_udn1_receive (void)
14182 unsigned long long __tile_udn2_receive (void)
14183 unsigned long long __tile_udn3_receive (void)
14184 void __tile_idn_send (unsigned long long)
14185 void __tile_udn_send (unsigned long long)
14186
14187 @end smallexample
14188
14189 The intrinsic @code{void __tile_network_barrier (void)} is used to
14190 guarantee that no network operations before it are reordered with
14191 those after it.
14192
14193 @node TILEPro Built-in Functions
14194 @subsection TILEPro Built-in Functions
14195
14196 GCC provides intrinsics to access every instruction of the TILEPro
14197 processor. The intrinsics are of the form:
14198
14199 @smallexample
14200
14201 unsigned __insn_@var{op} (...)
14202
14203 @end smallexample
14204
14205 @noindent
14206 where @var{op} is the name of the instruction. Refer to the ISA manual
14207 for the complete list of instructions.
14208
14209 GCC also provides intrinsics to directly access the network registers.
14210 The intrinsics are:
14211
14212 @smallexample
14213
14214 unsigned __tile_idn0_receive (void)
14215 unsigned __tile_idn1_receive (void)
14216 unsigned __tile_sn_receive (void)
14217 unsigned __tile_udn0_receive (void)
14218 unsigned __tile_udn1_receive (void)
14219 unsigned __tile_udn2_receive (void)
14220 unsigned __tile_udn3_receive (void)
14221 void __tile_idn_send (unsigned)
14222 void __tile_sn_send (unsigned)
14223 void __tile_udn_send (unsigned)
14224
14225 @end smallexample
14226
14227 The intrinsic @code{void __tile_network_barrier (void)} is used to
14228 guarantee that no network operations before it are reordered with
14229 those after it.
14230
14231 @node Target Format Checks
14232 @section Format Checks Specific to Particular Target Machines
14233
14234 For some target machines, GCC supports additional options to the
14235 format attribute
14236 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
14237
14238 @menu
14239 * Solaris Format Checks::
14240 * Darwin Format Checks::
14241 @end menu
14242
14243 @node Solaris Format Checks
14244 @subsection Solaris Format Checks
14245
14246 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
14247 check. @code{cmn_err} accepts a subset of the standard @code{printf}
14248 conversions, and the two-argument @code{%b} conversion for displaying
14249 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
14250
14251 @node Darwin Format Checks
14252 @subsection Darwin Format Checks
14253
14254 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
14255 attribute context. Declarations made with such attribution are parsed for correct syntax
14256 and format argument types. However, parsing of the format string itself is currently undefined
14257 and is not carried out by this version of the compiler.
14258
14259 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
14260 also be used as format arguments. Note that the relevant headers are only likely to be
14261 available on Darwin (OSX) installations. On such installations, the XCode and system
14262 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
14263 associated functions.
14264
14265 @node Pragmas
14266 @section Pragmas Accepted by GCC
14267 @cindex pragmas
14268 @cindex @code{#pragma}
14269
14270 GCC supports several types of pragmas, primarily in order to compile
14271 code originally written for other compilers. Note that in general
14272 we do not recommend the use of pragmas; @xref{Function Attributes},
14273 for further explanation.
14274
14275 @menu
14276 * ARM Pragmas::
14277 * M32C Pragmas::
14278 * MeP Pragmas::
14279 * RS/6000 and PowerPC Pragmas::
14280 * Darwin Pragmas::
14281 * Solaris Pragmas::
14282 * Symbol-Renaming Pragmas::
14283 * Structure-Packing Pragmas::
14284 * Weak Pragmas::
14285 * Diagnostic Pragmas::
14286 * Visibility Pragmas::
14287 * Push/Pop Macro Pragmas::
14288 * Function Specific Option Pragmas::
14289 @end menu
14290
14291 @node ARM Pragmas
14292 @subsection ARM Pragmas
14293
14294 The ARM target defines pragmas for controlling the default addition of
14295 @code{long_call} and @code{short_call} attributes to functions.
14296 @xref{Function Attributes}, for information about the effects of these
14297 attributes.
14298
14299 @table @code
14300 @item long_calls
14301 @cindex pragma, long_calls
14302 Set all subsequent functions to have the @code{long_call} attribute.
14303
14304 @item no_long_calls
14305 @cindex pragma, no_long_calls
14306 Set all subsequent functions to have the @code{short_call} attribute.
14307
14308 @item long_calls_off
14309 @cindex pragma, long_calls_off
14310 Do not affect the @code{long_call} or @code{short_call} attributes of
14311 subsequent functions.
14312 @end table
14313
14314 @node M32C Pragmas
14315 @subsection M32C Pragmas
14316
14317 @table @code
14318 @item GCC memregs @var{number}
14319 @cindex pragma, memregs
14320 Overrides the command-line option @code{-memregs=} for the current
14321 file. Use with care! This pragma must be before any function in the
14322 file, and mixing different memregs values in different objects may
14323 make them incompatible. This pragma is useful when a
14324 performance-critical function uses a memreg for temporary values,
14325 as it may allow you to reduce the number of memregs used.
14326
14327 @item ADDRESS @var{name} @var{address}
14328 @cindex pragma, address
14329 For any declared symbols matching @var{name}, this does three things
14330 to that symbol: it forces the symbol to be located at the given
14331 address (a number), it forces the symbol to be volatile, and it
14332 changes the symbol's scope to be static. This pragma exists for
14333 compatibility with other compilers, but note that the common
14334 @code{1234H} numeric syntax is not supported (use @code{0x1234}
14335 instead). Example:
14336
14337 @smallexample
14338 #pragma ADDRESS port3 0x103
14339 char port3;
14340 @end smallexample
14341
14342 @end table
14343
14344 @node MeP Pragmas
14345 @subsection MeP Pragmas
14346
14347 @table @code
14348
14349 @item custom io_volatile (on|off)
14350 @cindex pragma, custom io_volatile
14351 Overrides the command-line option @code{-mio-volatile} for the current
14352 file. Note that for compatibility with future GCC releases, this
14353 option should only be used once before any @code{io} variables in each
14354 file.
14355
14356 @item GCC coprocessor available @var{registers}
14357 @cindex pragma, coprocessor available
14358 Specifies which coprocessor registers are available to the register
14359 allocator. @var{registers} may be a single register, register range
14360 separated by ellipses, or comma-separated list of those. Example:
14361
14362 @smallexample
14363 #pragma GCC coprocessor available $c0...$c10, $c28
14364 @end smallexample
14365
14366 @item GCC coprocessor call_saved @var{registers}
14367 @cindex pragma, coprocessor call_saved
14368 Specifies which coprocessor registers are to be saved and restored by
14369 any function using them. @var{registers} may be a single register,
14370 register range separated by ellipses, or comma-separated list of
14371 those. Example:
14372
14373 @smallexample
14374 #pragma GCC coprocessor call_saved $c4...$c6, $c31
14375 @end smallexample
14376
14377 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
14378 @cindex pragma, coprocessor subclass
14379 Creates and defines a register class. These register classes can be
14380 used by inline @code{asm} constructs. @var{registers} may be a single
14381 register, register range separated by ellipses, or comma-separated
14382 list of those. Example:
14383
14384 @smallexample
14385 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
14386
14387 asm ("cpfoo %0" : "=B" (x));
14388 @end smallexample
14389
14390 @item GCC disinterrupt @var{name} , @var{name} @dots{}
14391 @cindex pragma, disinterrupt
14392 For the named functions, the compiler adds code to disable interrupts
14393 for the duration of those functions. If any functions so named
14394 are not encountered in the source, a warning is emitted that the pragma is
14395 not used. Examples:
14396
14397 @smallexample
14398 #pragma disinterrupt foo
14399 #pragma disinterrupt bar, grill
14400 int foo () @{ @dots{} @}
14401 @end smallexample
14402
14403 @item GCC call @var{name} , @var{name} @dots{}
14404 @cindex pragma, call
14405 For the named functions, the compiler always uses a register-indirect
14406 call model when calling the named functions. Examples:
14407
14408 @smallexample
14409 extern int foo ();
14410 #pragma call foo
14411 @end smallexample
14412
14413 @end table
14414
14415 @node RS/6000 and PowerPC Pragmas
14416 @subsection RS/6000 and PowerPC Pragmas
14417
14418 The RS/6000 and PowerPC targets define one pragma for controlling
14419 whether or not the @code{longcall} attribute is added to function
14420 declarations by default. This pragma overrides the @option{-mlongcall}
14421 option, but not the @code{longcall} and @code{shortcall} attributes.
14422 @xref{RS/6000 and PowerPC Options}, for more information about when long
14423 calls are and are not necessary.
14424
14425 @table @code
14426 @item longcall (1)
14427 @cindex pragma, longcall
14428 Apply the @code{longcall} attribute to all subsequent function
14429 declarations.
14430
14431 @item longcall (0)
14432 Do not apply the @code{longcall} attribute to subsequent function
14433 declarations.
14434 @end table
14435
14436 @c Describe h8300 pragmas here.
14437 @c Describe sh pragmas here.
14438 @c Describe v850 pragmas here.
14439
14440 @node Darwin Pragmas
14441 @subsection Darwin Pragmas
14442
14443 The following pragmas are available for all architectures running the
14444 Darwin operating system. These are useful for compatibility with other
14445 Mac OS compilers.
14446
14447 @table @code
14448 @item mark @var{tokens}@dots{}
14449 @cindex pragma, mark
14450 This pragma is accepted, but has no effect.
14451
14452 @item options align=@var{alignment}
14453 @cindex pragma, options align
14454 This pragma sets the alignment of fields in structures. The values of
14455 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
14456 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
14457 properly; to restore the previous setting, use @code{reset} for the
14458 @var{alignment}.
14459
14460 @item segment @var{tokens}@dots{}
14461 @cindex pragma, segment
14462 This pragma is accepted, but has no effect.
14463
14464 @item unused (@var{var} [, @var{var}]@dots{})
14465 @cindex pragma, unused
14466 This pragma declares variables to be possibly unused. GCC does not
14467 produce warnings for the listed variables. The effect is similar to
14468 that of the @code{unused} attribute, except that this pragma may appear
14469 anywhere within the variables' scopes.
14470 @end table
14471
14472 @node Solaris Pragmas
14473 @subsection Solaris Pragmas
14474
14475 The Solaris target supports @code{#pragma redefine_extname}
14476 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
14477 @code{#pragma} directives for compatibility with the system compiler.
14478
14479 @table @code
14480 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
14481 @cindex pragma, align
14482
14483 Increase the minimum alignment of each @var{variable} to @var{alignment}.
14484 This is the same as GCC's @code{aligned} attribute @pxref{Variable
14485 Attributes}). Macro expansion occurs on the arguments to this pragma
14486 when compiling C and Objective-C@. It does not currently occur when
14487 compiling C++, but this is a bug which may be fixed in a future
14488 release.
14489
14490 @item fini (@var{function} [, @var{function}]...)
14491 @cindex pragma, fini
14492
14493 This pragma causes each listed @var{function} to be called after
14494 main, or during shared module unloading, by adding a call to the
14495 @code{.fini} section.
14496
14497 @item init (@var{function} [, @var{function}]...)
14498 @cindex pragma, init
14499
14500 This pragma causes each listed @var{function} to be called during
14501 initialization (before @code{main}) or during shared module loading, by
14502 adding a call to the @code{.init} section.
14503
14504 @end table
14505
14506 @node Symbol-Renaming Pragmas
14507 @subsection Symbol-Renaming Pragmas
14508
14509 For compatibility with the Solaris system headers, GCC
14510 supports two @code{#pragma} directives that change the name used in
14511 assembly for a given declaration. To get this effect
14512 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
14513 Labels}).
14514
14515 @table @code
14516 @item redefine_extname @var{oldname} @var{newname}
14517 @cindex pragma, redefine_extname
14518
14519 This pragma gives the C function @var{oldname} the assembly symbol
14520 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
14521 is defined if this pragma is available (currently on all platforms).
14522 @end table
14523
14524 This pragma and the asm labels extension interact in a complicated
14525 manner. Here are some corner cases you may want to be aware of.
14526
14527 @enumerate
14528 @item Both pragmas silently apply only to declarations with external
14529 linkage. Asm labels do not have this restriction.
14530
14531 @item In C++, both pragmas silently apply only to declarations with
14532 ``C'' linkage. Again, asm labels do not have this restriction.
14533
14534 @item If any of the three ways of changing the assembly name of a
14535 declaration is applied to a declaration whose assembly name has
14536 already been determined (either by a previous use of one of these
14537 features, or because the compiler needed the assembly name in order to
14538 generate code), and the new name is different, a warning issues and
14539 the name does not change.
14540
14541 @item The @var{oldname} used by @code{#pragma redefine_extname} is
14542 always the C-language name.
14543 @end enumerate
14544
14545 @node Structure-Packing Pragmas
14546 @subsection Structure-Packing Pragmas
14547
14548 For compatibility with Microsoft Windows compilers, GCC supports a
14549 set of @code{#pragma} directives that change the maximum alignment of
14550 members of structures (other than zero-width bit-fields), unions, and
14551 classes subsequently defined. The @var{n} value below always is required
14552 to be a small power of two and specifies the new alignment in bytes.
14553
14554 @enumerate
14555 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
14556 @item @code{#pragma pack()} sets the alignment to the one that was in
14557 effect when compilation started (see also command-line option
14558 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
14559 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
14560 setting on an internal stack and then optionally sets the new alignment.
14561 @item @code{#pragma pack(pop)} restores the alignment setting to the one
14562 saved at the top of the internal stack (and removes that stack entry).
14563 Note that @code{#pragma pack([@var{n}])} does not influence this internal
14564 stack; thus it is possible to have @code{#pragma pack(push)} followed by
14565 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
14566 @code{#pragma pack(pop)}.
14567 @end enumerate
14568
14569 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
14570 @code{#pragma} which lays out a structure as the documented
14571 @code{__attribute__ ((ms_struct))}.
14572 @enumerate
14573 @item @code{#pragma ms_struct on} turns on the layout for structures
14574 declared.
14575 @item @code{#pragma ms_struct off} turns off the layout for structures
14576 declared.
14577 @item @code{#pragma ms_struct reset} goes back to the default layout.
14578 @end enumerate
14579
14580 @node Weak Pragmas
14581 @subsection Weak Pragmas
14582
14583 For compatibility with SVR4, GCC supports a set of @code{#pragma}
14584 directives for declaring symbols to be weak, and defining weak
14585 aliases.
14586
14587 @table @code
14588 @item #pragma weak @var{symbol}
14589 @cindex pragma, weak
14590 This pragma declares @var{symbol} to be weak, as if the declaration
14591 had the attribute of the same name. The pragma may appear before
14592 or after the declaration of @var{symbol}. It is not an error for
14593 @var{symbol} to never be defined at all.
14594
14595 @item #pragma weak @var{symbol1} = @var{symbol2}
14596 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
14597 It is an error if @var{symbol2} is not defined in the current
14598 translation unit.
14599 @end table
14600
14601 @node Diagnostic Pragmas
14602 @subsection Diagnostic Pragmas
14603
14604 GCC allows the user to selectively enable or disable certain types of
14605 diagnostics, and change the kind of the diagnostic. For example, a
14606 project's policy might require that all sources compile with
14607 @option{-Werror} but certain files might have exceptions allowing
14608 specific types of warnings. Or, a project might selectively enable
14609 diagnostics and treat them as errors depending on which preprocessor
14610 macros are defined.
14611
14612 @table @code
14613 @item #pragma GCC diagnostic @var{kind} @var{option}
14614 @cindex pragma, diagnostic
14615
14616 Modifies the disposition of a diagnostic. Note that not all
14617 diagnostics are modifiable; at the moment only warnings (normally
14618 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
14619 Use @option{-fdiagnostics-show-option} to determine which diagnostics
14620 are controllable and which option controls them.
14621
14622 @var{kind} is @samp{error} to treat this diagnostic as an error,
14623 @samp{warning} to treat it like a warning (even if @option{-Werror} is
14624 in effect), or @samp{ignored} if the diagnostic is to be ignored.
14625 @var{option} is a double quoted string that matches the command-line
14626 option.
14627
14628 @smallexample
14629 #pragma GCC diagnostic warning "-Wformat"
14630 #pragma GCC diagnostic error "-Wformat"
14631 #pragma GCC diagnostic ignored "-Wformat"
14632 @end smallexample
14633
14634 Note that these pragmas override any command-line options. GCC keeps
14635 track of the location of each pragma, and issues diagnostics according
14636 to the state as of that point in the source file. Thus, pragmas occurring
14637 after a line do not affect diagnostics caused by that line.
14638
14639 @item #pragma GCC diagnostic push
14640 @itemx #pragma GCC diagnostic pop
14641
14642 Causes GCC to remember the state of the diagnostics as of each
14643 @code{push}, and restore to that point at each @code{pop}. If a
14644 @code{pop} has no matching @code{push}, the command-line options are
14645 restored.
14646
14647 @smallexample
14648 #pragma GCC diagnostic error "-Wuninitialized"
14649 foo(a); /* error is given for this one */
14650 #pragma GCC diagnostic push
14651 #pragma GCC diagnostic ignored "-Wuninitialized"
14652 foo(b); /* no diagnostic for this one */
14653 #pragma GCC diagnostic pop
14654 foo(c); /* error is given for this one */
14655 #pragma GCC diagnostic pop
14656 foo(d); /* depends on command-line options */
14657 @end smallexample
14658
14659 @end table
14660
14661 GCC also offers a simple mechanism for printing messages during
14662 compilation.
14663
14664 @table @code
14665 @item #pragma message @var{string}
14666 @cindex pragma, diagnostic
14667
14668 Prints @var{string} as a compiler message on compilation. The message
14669 is informational only, and is neither a compilation warning nor an error.
14670
14671 @smallexample
14672 #pragma message "Compiling " __FILE__ "..."
14673 @end smallexample
14674
14675 @var{string} may be parenthesized, and is printed with location
14676 information. For example,
14677
14678 @smallexample
14679 #define DO_PRAGMA(x) _Pragma (#x)
14680 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
14681
14682 TODO(Remember to fix this)
14683 @end smallexample
14684
14685 @noindent
14686 prints @samp{/tmp/file.c:4: note: #pragma message:
14687 TODO - Remember to fix this}.
14688
14689 @end table
14690
14691 @node Visibility Pragmas
14692 @subsection Visibility Pragmas
14693
14694 @table @code
14695 @item #pragma GCC visibility push(@var{visibility})
14696 @itemx #pragma GCC visibility pop
14697 @cindex pragma, visibility
14698
14699 This pragma allows the user to set the visibility for multiple
14700 declarations without having to give each a visibility attribute
14701 @xref{Function Attributes}, for more information about visibility and
14702 the attribute syntax.
14703
14704 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
14705 declarations. Class members and template specializations are not
14706 affected; if you want to override the visibility for a particular
14707 member or instantiation, you must use an attribute.
14708
14709 @end table
14710
14711
14712 @node Push/Pop Macro Pragmas
14713 @subsection Push/Pop Macro Pragmas
14714
14715 For compatibility with Microsoft Windows compilers, GCC supports
14716 @samp{#pragma push_macro(@var{"macro_name"})}
14717 and @samp{#pragma pop_macro(@var{"macro_name"})}.
14718
14719 @table @code
14720 @item #pragma push_macro(@var{"macro_name"})
14721 @cindex pragma, push_macro
14722 This pragma saves the value of the macro named as @var{macro_name} to
14723 the top of the stack for this macro.
14724
14725 @item #pragma pop_macro(@var{"macro_name"})
14726 @cindex pragma, pop_macro
14727 This pragma sets the value of the macro named as @var{macro_name} to
14728 the value on top of the stack for this macro. If the stack for
14729 @var{macro_name} is empty, the value of the macro remains unchanged.
14730 @end table
14731
14732 For example:
14733
14734 @smallexample
14735 #define X 1
14736 #pragma push_macro("X")
14737 #undef X
14738 #define X -1
14739 #pragma pop_macro("X")
14740 int x [X];
14741 @end smallexample
14742
14743 @noindent
14744 In this example, the definition of X as 1 is saved by @code{#pragma
14745 push_macro} and restored by @code{#pragma pop_macro}.
14746
14747 @node Function Specific Option Pragmas
14748 @subsection Function Specific Option Pragmas
14749
14750 @table @code
14751 @item #pragma GCC target (@var{"string"}...)
14752 @cindex pragma GCC target
14753
14754 This pragma allows you to set target specific options for functions
14755 defined later in the source file. One or more strings can be
14756 specified. Each function that is defined after this point is as
14757 if @code{attribute((target("STRING")))} was specified for that
14758 function. The parenthesis around the options is optional.
14759 @xref{Function Attributes}, for more information about the
14760 @code{target} attribute and the attribute syntax.
14761
14762 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
14763 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. At
14764 present, it is not implemented for other back ends.
14765 @end table
14766
14767 @table @code
14768 @item #pragma GCC optimize (@var{"string"}...)
14769 @cindex pragma GCC optimize
14770
14771 This pragma allows you to set global optimization options for functions
14772 defined later in the source file. One or more strings can be
14773 specified. Each function that is defined after this point is as
14774 if @code{attribute((optimize("STRING")))} was specified for that
14775 function. The parenthesis around the options is optional.
14776 @xref{Function Attributes}, for more information about the
14777 @code{optimize} attribute and the attribute syntax.
14778
14779 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
14780 versions earlier than 4.4.
14781 @end table
14782
14783 @table @code
14784 @item #pragma GCC push_options
14785 @itemx #pragma GCC pop_options
14786 @cindex pragma GCC push_options
14787 @cindex pragma GCC pop_options
14788
14789 These pragmas maintain a stack of the current target and optimization
14790 options. It is intended for include files where you temporarily want
14791 to switch to using a different @samp{#pragma GCC target} or
14792 @samp{#pragma GCC optimize} and then to pop back to the previous
14793 options.
14794
14795 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
14796 pragmas are not implemented in GCC versions earlier than 4.4.
14797 @end table
14798
14799 @table @code
14800 @item #pragma GCC reset_options
14801 @cindex pragma GCC reset_options
14802
14803 This pragma clears the current @code{#pragma GCC target} and
14804 @code{#pragma GCC optimize} to use the default switches as specified
14805 on the command line.
14806
14807 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
14808 versions earlier than 4.4.
14809 @end table
14810
14811 @node Unnamed Fields
14812 @section Unnamed struct/union fields within structs/unions
14813 @cindex @code{struct}
14814 @cindex @code{union}
14815
14816 As permitted by ISO C11 and for compatibility with other compilers,
14817 GCC allows you to define
14818 a structure or union that contains, as fields, structures and unions
14819 without names. For example:
14820
14821 @smallexample
14822 struct @{
14823 int a;
14824 union @{
14825 int b;
14826 float c;
14827 @};
14828 int d;
14829 @} foo;
14830 @end smallexample
14831
14832 @noindent
14833 In this example, you are able to access members of the unnamed
14834 union with code like @samp{foo.b}. Note that only unnamed structs and
14835 unions are allowed, you may not have, for example, an unnamed
14836 @code{int}.
14837
14838 You must never create such structures that cause ambiguous field definitions.
14839 For example, in this structure:
14840
14841 @smallexample
14842 struct @{
14843 int a;
14844 struct @{
14845 int a;
14846 @};
14847 @} foo;
14848 @end smallexample
14849
14850 @noindent
14851 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
14852 The compiler gives errors for such constructs.
14853
14854 @opindex fms-extensions
14855 Unless @option{-fms-extensions} is used, the unnamed field must be a
14856 structure or union definition without a tag (for example, @samp{struct
14857 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
14858 also be a definition with a tag such as @samp{struct foo @{ int a;
14859 @};}, a reference to a previously defined structure or union such as
14860 @samp{struct foo;}, or a reference to a @code{typedef} name for a
14861 previously defined structure or union type.
14862
14863 @opindex fplan9-extensions
14864 The option @option{-fplan9-extensions} enables
14865 @option{-fms-extensions} as well as two other extensions. First, a
14866 pointer to a structure is automatically converted to a pointer to an
14867 anonymous field for assignments and function calls. For example:
14868
14869 @smallexample
14870 struct s1 @{ int a; @};
14871 struct s2 @{ struct s1; @};
14872 extern void f1 (struct s1 *);
14873 void f2 (struct s2 *p) @{ f1 (p); @}
14874 @end smallexample
14875
14876 @noindent
14877 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
14878 converted into a pointer to the anonymous field.
14879
14880 Second, when the type of an anonymous field is a @code{typedef} for a
14881 @code{struct} or @code{union}, code may refer to the field using the
14882 name of the @code{typedef}.
14883
14884 @smallexample
14885 typedef struct @{ int a; @} s1;
14886 struct s2 @{ s1; @};
14887 s1 f1 (struct s2 *p) @{ return p->s1; @}
14888 @end smallexample
14889
14890 These usages are only permitted when they are not ambiguous.
14891
14892 @node Thread-Local
14893 @section Thread-Local Storage
14894 @cindex Thread-Local Storage
14895 @cindex @acronym{TLS}
14896 @cindex @code{__thread}
14897
14898 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
14899 are allocated such that there is one instance of the variable per extant
14900 thread. The runtime model GCC uses to implement this originates
14901 in the IA-64 processor-specific ABI, but has since been migrated
14902 to other processors as well. It requires significant support from
14903 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
14904 system libraries (@file{libc.so} and @file{libpthread.so}), so it
14905 is not available everywhere.
14906
14907 At the user level, the extension is visible with a new storage
14908 class keyword: @code{__thread}. For example:
14909
14910 @smallexample
14911 __thread int i;
14912 extern __thread struct state s;
14913 static __thread char *p;
14914 @end smallexample
14915
14916 The @code{__thread} specifier may be used alone, with the @code{extern}
14917 or @code{static} specifiers, but with no other storage class specifier.
14918 When used with @code{extern} or @code{static}, @code{__thread} must appear
14919 immediately after the other storage class specifier.
14920
14921 The @code{__thread} specifier may be applied to any global, file-scoped
14922 static, function-scoped static, or static data member of a class. It may
14923 not be applied to block-scoped automatic or non-static data member.
14924
14925 When the address-of operator is applied to a thread-local variable, it is
14926 evaluated at run time and returns the address of the current thread's
14927 instance of that variable. An address so obtained may be used by any
14928 thread. When a thread terminates, any pointers to thread-local variables
14929 in that thread become invalid.
14930
14931 No static initialization may refer to the address of a thread-local variable.
14932
14933 In C++, if an initializer is present for a thread-local variable, it must
14934 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
14935 standard.
14936
14937 See @uref{http://www.akkadia.org/drepper/tls.pdf,
14938 ELF Handling For Thread-Local Storage} for a detailed explanation of
14939 the four thread-local storage addressing models, and how the runtime
14940 is expected to function.
14941
14942 @menu
14943 * C99 Thread-Local Edits::
14944 * C++98 Thread-Local Edits::
14945 @end menu
14946
14947 @node C99 Thread-Local Edits
14948 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
14949
14950 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
14951 that document the exact semantics of the language extension.
14952
14953 @itemize @bullet
14954 @item
14955 @cite{5.1.2 Execution environments}
14956
14957 Add new text after paragraph 1
14958
14959 @quotation
14960 Within either execution environment, a @dfn{thread} is a flow of
14961 control within a program. It is implementation defined whether
14962 or not there may be more than one thread associated with a program.
14963 It is implementation defined how threads beyond the first are
14964 created, the name and type of the function called at thread
14965 startup, and how threads may be terminated. However, objects
14966 with thread storage duration shall be initialized before thread
14967 startup.
14968 @end quotation
14969
14970 @item
14971 @cite{6.2.4 Storage durations of objects}
14972
14973 Add new text before paragraph 3
14974
14975 @quotation
14976 An object whose identifier is declared with the storage-class
14977 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
14978 Its lifetime is the entire execution of the thread, and its
14979 stored value is initialized only once, prior to thread startup.
14980 @end quotation
14981
14982 @item
14983 @cite{6.4.1 Keywords}
14984
14985 Add @code{__thread}.
14986
14987 @item
14988 @cite{6.7.1 Storage-class specifiers}
14989
14990 Add @code{__thread} to the list of storage class specifiers in
14991 paragraph 1.
14992
14993 Change paragraph 2 to
14994
14995 @quotation
14996 With the exception of @code{__thread}, at most one storage-class
14997 specifier may be given [@dots{}]. The @code{__thread} specifier may
14998 be used alone, or immediately following @code{extern} or
14999 @code{static}.
15000 @end quotation
15001
15002 Add new text after paragraph 6
15003
15004 @quotation
15005 The declaration of an identifier for a variable that has
15006 block scope that specifies @code{__thread} shall also
15007 specify either @code{extern} or @code{static}.
15008
15009 The @code{__thread} specifier shall be used only with
15010 variables.
15011 @end quotation
15012 @end itemize
15013
15014 @node C++98 Thread-Local Edits
15015 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
15016
15017 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
15018 that document the exact semantics of the language extension.
15019
15020 @itemize @bullet
15021 @item
15022 @b{[intro.execution]}
15023
15024 New text after paragraph 4
15025
15026 @quotation
15027 A @dfn{thread} is a flow of control within the abstract machine.
15028 It is implementation defined whether or not there may be more than
15029 one thread.
15030 @end quotation
15031
15032 New text after paragraph 7
15033
15034 @quotation
15035 It is unspecified whether additional action must be taken to
15036 ensure when and whether side effects are visible to other threads.
15037 @end quotation
15038
15039 @item
15040 @b{[lex.key]}
15041
15042 Add @code{__thread}.
15043
15044 @item
15045 @b{[basic.start.main]}
15046
15047 Add after paragraph 5
15048
15049 @quotation
15050 The thread that begins execution at the @code{main} function is called
15051 the @dfn{main thread}. It is implementation defined how functions
15052 beginning threads other than the main thread are designated or typed.
15053 A function so designated, as well as the @code{main} function, is called
15054 a @dfn{thread startup function}. It is implementation defined what
15055 happens if a thread startup function returns. It is implementation
15056 defined what happens to other threads when any thread calls @code{exit}.
15057 @end quotation
15058
15059 @item
15060 @b{[basic.start.init]}
15061
15062 Add after paragraph 4
15063
15064 @quotation
15065 The storage for an object of thread storage duration shall be
15066 statically initialized before the first statement of the thread startup
15067 function. An object of thread storage duration shall not require
15068 dynamic initialization.
15069 @end quotation
15070
15071 @item
15072 @b{[basic.start.term]}
15073
15074 Add after paragraph 3
15075
15076 @quotation
15077 The type of an object with thread storage duration shall not have a
15078 non-trivial destructor, nor shall it be an array type whose elements
15079 (directly or indirectly) have non-trivial destructors.
15080 @end quotation
15081
15082 @item
15083 @b{[basic.stc]}
15084
15085 Add ``thread storage duration'' to the list in paragraph 1.
15086
15087 Change paragraph 2
15088
15089 @quotation
15090 Thread, static, and automatic storage durations are associated with
15091 objects introduced by declarations [@dots{}].
15092 @end quotation
15093
15094 Add @code{__thread} to the list of specifiers in paragraph 3.
15095
15096 @item
15097 @b{[basic.stc.thread]}
15098
15099 New section before @b{[basic.stc.static]}
15100
15101 @quotation
15102 The keyword @code{__thread} applied to a non-local object gives the
15103 object thread storage duration.
15104
15105 A local variable or class data member declared both @code{static}
15106 and @code{__thread} gives the variable or member thread storage
15107 duration.
15108 @end quotation
15109
15110 @item
15111 @b{[basic.stc.static]}
15112
15113 Change paragraph 1
15114
15115 @quotation
15116 All objects that have neither thread storage duration, dynamic
15117 storage duration nor are local [@dots{}].
15118 @end quotation
15119
15120 @item
15121 @b{[dcl.stc]}
15122
15123 Add @code{__thread} to the list in paragraph 1.
15124
15125 Change paragraph 1
15126
15127 @quotation
15128 With the exception of @code{__thread}, at most one
15129 @var{storage-class-specifier} shall appear in a given
15130 @var{decl-specifier-seq}. The @code{__thread} specifier may
15131 be used alone, or immediately following the @code{extern} or
15132 @code{static} specifiers. [@dots{}]
15133 @end quotation
15134
15135 Add after paragraph 5
15136
15137 @quotation
15138 The @code{__thread} specifier can be applied only to the names of objects
15139 and to anonymous unions.
15140 @end quotation
15141
15142 @item
15143 @b{[class.mem]}
15144
15145 Add after paragraph 6
15146
15147 @quotation
15148 Non-@code{static} members shall not be @code{__thread}.
15149 @end quotation
15150 @end itemize
15151
15152 @node Binary constants
15153 @section Binary constants using the @samp{0b} prefix
15154 @cindex Binary constants using the @samp{0b} prefix
15155
15156 Integer constants can be written as binary constants, consisting of a
15157 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
15158 @samp{0B}. This is particularly useful in environments that operate a
15159 lot on the bit level (like microcontrollers).
15160
15161 The following statements are identical:
15162
15163 @smallexample
15164 i = 42;
15165 i = 0x2a;
15166 i = 052;
15167 i = 0b101010;
15168 @end smallexample
15169
15170 The type of these constants follows the same rules as for octal or
15171 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
15172 can be applied.
15173
15174 @node C++ Extensions
15175 @chapter Extensions to the C++ Language
15176 @cindex extensions, C++ language
15177 @cindex C++ language extensions
15178
15179 The GNU compiler provides these extensions to the C++ language (and you
15180 can also use most of the C language extensions in your C++ programs). If you
15181 want to write code that checks whether these features are available, you can
15182 test for the GNU compiler the same way as for C programs: check for a
15183 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
15184 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
15185 Predefined Macros,cpp,The GNU C Preprocessor}).
15186
15187 @menu
15188 * C++ Volatiles:: What constitutes an access to a volatile object.
15189 * Restricted Pointers:: C99 restricted pointers and references.
15190 * Vague Linkage:: Where G++ puts inlines, vtables and such.
15191 * C++ Interface:: You can use a single C++ header file for both
15192 declarations and definitions.
15193 * Template Instantiation:: Methods for ensuring that exactly one copy of
15194 each needed template instantiation is emitted.
15195 * Bound member functions:: You can extract a function pointer to the
15196 method denoted by a @samp{->*} or @samp{.*} expression.
15197 * C++ Attributes:: Variable, function, and type attributes for C++ only.
15198 * Namespace Association:: Strong using-directives for namespace association.
15199 * Type Traits:: Compiler support for type traits
15200 * Java Exceptions:: Tweaking exception handling to work with Java.
15201 * Deprecated Features:: Things will disappear from G++.
15202 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
15203 @end menu
15204
15205 @node C++ Volatiles
15206 @section When is a Volatile C++ Object Accessed?
15207 @cindex accessing volatiles
15208 @cindex volatile read
15209 @cindex volatile write
15210 @cindex volatile access
15211
15212 The C++ standard differs from the C standard in its treatment of
15213 volatile objects. It fails to specify what constitutes a volatile
15214 access, except to say that C++ should behave in a similar manner to C
15215 with respect to volatiles, where possible. However, the different
15216 lvalueness of expressions between C and C++ complicate the behavior.
15217 G++ behaves the same as GCC for volatile access, @xref{C
15218 Extensions,,Volatiles}, for a description of GCC's behavior.
15219
15220 The C and C++ language specifications differ when an object is
15221 accessed in a void context:
15222
15223 @smallexample
15224 volatile int *src = @var{somevalue};
15225 *src;
15226 @end smallexample
15227
15228 The C++ standard specifies that such expressions do not undergo lvalue
15229 to rvalue conversion, and that the type of the dereferenced object may
15230 be incomplete. The C++ standard does not specify explicitly that it
15231 is lvalue to rvalue conversion that is responsible for causing an
15232 access. There is reason to believe that it is, because otherwise
15233 certain simple expressions become undefined. However, because it
15234 would surprise most programmers, G++ treats dereferencing a pointer to
15235 volatile object of complete type as GCC would do for an equivalent
15236 type in C@. When the object has incomplete type, G++ issues a
15237 warning; if you wish to force an error, you must force a conversion to
15238 rvalue with, for instance, a static cast.
15239
15240 When using a reference to volatile, G++ does not treat equivalent
15241 expressions as accesses to volatiles, but instead issues a warning that
15242 no volatile is accessed. The rationale for this is that otherwise it
15243 becomes difficult to determine where volatile access occur, and not
15244 possible to ignore the return value from functions returning volatile
15245 references. Again, if you wish to force a read, cast the reference to
15246 an rvalue.
15247
15248 G++ implements the same behavior as GCC does when assigning to a
15249 volatile object---there is no reread of the assigned-to object, the
15250 assigned rvalue is reused. Note that in C++ assignment expressions
15251 are lvalues, and if used as an lvalue, the volatile object is
15252 referred to. For instance, @var{vref} refers to @var{vobj}, as
15253 expected, in the following example:
15254
15255 @smallexample
15256 volatile int vobj;
15257 volatile int &vref = vobj = @var{something};
15258 @end smallexample
15259
15260 @node Restricted Pointers
15261 @section Restricting Pointer Aliasing
15262 @cindex restricted pointers
15263 @cindex restricted references
15264 @cindex restricted this pointer
15265
15266 As with the C front end, G++ understands the C99 feature of restricted pointers,
15267 specified with the @code{__restrict__}, or @code{__restrict} type
15268 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
15269 language flag, @code{restrict} is not a keyword in C++.
15270
15271 In addition to allowing restricted pointers, you can specify restricted
15272 references, which indicate that the reference is not aliased in the local
15273 context.
15274
15275 @smallexample
15276 void fn (int *__restrict__ rptr, int &__restrict__ rref)
15277 @{
15278 /* @r{@dots{}} */
15279 @}
15280 @end smallexample
15281
15282 @noindent
15283 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
15284 @var{rref} refers to a (different) unaliased integer.
15285
15286 You may also specify whether a member function's @var{this} pointer is
15287 unaliased by using @code{__restrict__} as a member function qualifier.
15288
15289 @smallexample
15290 void T::fn () __restrict__
15291 @{
15292 /* @r{@dots{}} */
15293 @}
15294 @end smallexample
15295
15296 @noindent
15297 Within the body of @code{T::fn}, @var{this} has the effective
15298 definition @code{T *__restrict__ const this}. Notice that the
15299 interpretation of a @code{__restrict__} member function qualifier is
15300 different to that of @code{const} or @code{volatile} qualifier, in that it
15301 is applied to the pointer rather than the object. This is consistent with
15302 other compilers that implement restricted pointers.
15303
15304 As with all outermost parameter qualifiers, @code{__restrict__} is
15305 ignored in function definition matching. This means you only need to
15306 specify @code{__restrict__} in a function definition, rather than
15307 in a function prototype as well.
15308
15309 @node Vague Linkage
15310 @section Vague Linkage
15311 @cindex vague linkage
15312
15313 There are several constructs in C++ that require space in the object
15314 file but are not clearly tied to a single translation unit. We say that
15315 these constructs have ``vague linkage''. Typically such constructs are
15316 emitted wherever they are needed, though sometimes we can be more
15317 clever.
15318
15319 @table @asis
15320 @item Inline Functions
15321 Inline functions are typically defined in a header file which can be
15322 included in many different compilations. Hopefully they can usually be
15323 inlined, but sometimes an out-of-line copy is necessary, if the address
15324 of the function is taken or if inlining fails. In general, we emit an
15325 out-of-line copy in all translation units where one is needed. As an
15326 exception, we only emit inline virtual functions with the vtable, since
15327 it always requires a copy.
15328
15329 Local static variables and string constants used in an inline function
15330 are also considered to have vague linkage, since they must be shared
15331 between all inlined and out-of-line instances of the function.
15332
15333 @item VTables
15334 @cindex vtable
15335 C++ virtual functions are implemented in most compilers using a lookup
15336 table, known as a vtable. The vtable contains pointers to the virtual
15337 functions provided by a class, and each object of the class contains a
15338 pointer to its vtable (or vtables, in some multiple-inheritance
15339 situations). If the class declares any non-inline, non-pure virtual
15340 functions, the first one is chosen as the ``key method'' for the class,
15341 and the vtable is only emitted in the translation unit where the key
15342 method is defined.
15343
15344 @emph{Note:} If the chosen key method is later defined as inline, the
15345 vtable is still emitted in every translation unit that defines it.
15346 Make sure that any inline virtuals are declared inline in the class
15347 body, even if they are not defined there.
15348
15349 @item @code{type_info} objects
15350 @cindex @code{type_info}
15351 @cindex RTTI
15352 C++ requires information about types to be written out in order to
15353 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
15354 For polymorphic classes (classes with virtual functions), the @samp{type_info}
15355 object is written out along with the vtable so that @samp{dynamic_cast}
15356 can determine the dynamic type of a class object at run time. For all
15357 other types, we write out the @samp{type_info} object when it is used: when
15358 applying @samp{typeid} to an expression, throwing an object, or
15359 referring to a type in a catch clause or exception specification.
15360
15361 @item Template Instantiations
15362 Most everything in this section also applies to template instantiations,
15363 but there are other options as well.
15364 @xref{Template Instantiation,,Where's the Template?}.
15365
15366 @end table
15367
15368 When used with GNU ld version 2.8 or later on an ELF system such as
15369 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
15370 these constructs will be discarded at link time. This is known as
15371 COMDAT support.
15372
15373 On targets that don't support COMDAT, but do support weak symbols, GCC
15374 uses them. This way one copy overrides all the others, but
15375 the unused copies still take up space in the executable.
15376
15377 For targets that do not support either COMDAT or weak symbols,
15378 most entities with vague linkage are emitted as local symbols to
15379 avoid duplicate definition errors from the linker. This does not happen
15380 for local statics in inlines, however, as having multiple copies
15381 almost certainly breaks things.
15382
15383 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
15384 another way to control placement of these constructs.
15385
15386 @node C++ Interface
15387 @section #pragma interface and implementation
15388
15389 @cindex interface and implementation headers, C++
15390 @cindex C++ interface and implementation headers
15391 @cindex pragmas, interface and implementation
15392
15393 @code{#pragma interface} and @code{#pragma implementation} provide the
15394 user with a way of explicitly directing the compiler to emit entities
15395 with vague linkage (and debugging information) in a particular
15396 translation unit.
15397
15398 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
15399 most cases, because of COMDAT support and the ``key method'' heuristic
15400 mentioned in @ref{Vague Linkage}. Using them can actually cause your
15401 program to grow due to unnecessary out-of-line copies of inline
15402 functions. Currently (3.4) the only benefit of these
15403 @code{#pragma}s is reduced duplication of debugging information, and
15404 that should be addressed soon on DWARF 2 targets with the use of
15405 COMDAT groups.
15406
15407 @table @code
15408 @item #pragma interface
15409 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
15410 @kindex #pragma interface
15411 Use this directive in @emph{header files} that define object classes, to save
15412 space in most of the object files that use those classes. Normally,
15413 local copies of certain information (backup copies of inline member
15414 functions, debugging information, and the internal tables that implement
15415 virtual functions) must be kept in each object file that includes class
15416 definitions. You can use this pragma to avoid such duplication. When a
15417 header file containing @samp{#pragma interface} is included in a
15418 compilation, this auxiliary information is not generated (unless
15419 the main input source file itself uses @samp{#pragma implementation}).
15420 Instead, the object files contain references to be resolved at link
15421 time.
15422
15423 The second form of this directive is useful for the case where you have
15424 multiple headers with the same name in different directories. If you
15425 use this form, you must specify the same string to @samp{#pragma
15426 implementation}.
15427
15428 @item #pragma implementation
15429 @itemx #pragma implementation "@var{objects}.h"
15430 @kindex #pragma implementation
15431 Use this pragma in a @emph{main input file}, when you want full output from
15432 included header files to be generated (and made globally visible). The
15433 included header file, in turn, should use @samp{#pragma interface}.
15434 Backup copies of inline member functions, debugging information, and the
15435 internal tables used to implement virtual functions are all generated in
15436 implementation files.
15437
15438 @cindex implied @code{#pragma implementation}
15439 @cindex @code{#pragma implementation}, implied
15440 @cindex naming convention, implementation headers
15441 If you use @samp{#pragma implementation} with no argument, it applies to
15442 an include file with the same basename@footnote{A file's @dfn{basename}
15443 is the name stripped of all leading path information and of trailing
15444 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
15445 file. For example, in @file{allclass.cc}, giving just
15446 @samp{#pragma implementation}
15447 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
15448
15449 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
15450 an implementation file whenever you would include it from
15451 @file{allclass.cc} even if you never specified @samp{#pragma
15452 implementation}. This was deemed to be more trouble than it was worth,
15453 however, and disabled.
15454
15455 Use the string argument if you want a single implementation file to
15456 include code from multiple header files. (You must also use
15457 @samp{#include} to include the header file; @samp{#pragma
15458 implementation} only specifies how to use the file---it doesn't actually
15459 include it.)
15460
15461 There is no way to split up the contents of a single header file into
15462 multiple implementation files.
15463 @end table
15464
15465 @cindex inlining and C++ pragmas
15466 @cindex C++ pragmas, effect on inlining
15467 @cindex pragmas in C++, effect on inlining
15468 @samp{#pragma implementation} and @samp{#pragma interface} also have an
15469 effect on function inlining.
15470
15471 If you define a class in a header file marked with @samp{#pragma
15472 interface}, the effect on an inline function defined in that class is
15473 similar to an explicit @code{extern} declaration---the compiler emits
15474 no code at all to define an independent version of the function. Its
15475 definition is used only for inlining with its callers.
15476
15477 @opindex fno-implement-inlines
15478 Conversely, when you include the same header file in a main source file
15479 that declares it as @samp{#pragma implementation}, the compiler emits
15480 code for the function itself; this defines a version of the function
15481 that can be found via pointers (or by callers compiled without
15482 inlining). If all calls to the function can be inlined, you can avoid
15483 emitting the function by compiling with @option{-fno-implement-inlines}.
15484 If any calls are not inlined, you will get linker errors.
15485
15486 @node Template Instantiation
15487 @section Where's the Template?
15488 @cindex template instantiation
15489
15490 C++ templates are the first language feature to require more
15491 intelligence from the environment than one usually finds on a UNIX
15492 system. Somehow the compiler and linker have to make sure that each
15493 template instance occurs exactly once in the executable if it is needed,
15494 and not at all otherwise. There are two basic approaches to this
15495 problem, which are referred to as the Borland model and the Cfront model.
15496
15497 @table @asis
15498 @item Borland model
15499 Borland C++ solved the template instantiation problem by adding the code
15500 equivalent of common blocks to their linker; the compiler emits template
15501 instances in each translation unit that uses them, and the linker
15502 collapses them together. The advantage of this model is that the linker
15503 only has to consider the object files themselves; there is no external
15504 complexity to worry about. This disadvantage is that compilation time
15505 is increased because the template code is being compiled repeatedly.
15506 Code written for this model tends to include definitions of all
15507 templates in the header file, since they must be seen to be
15508 instantiated.
15509
15510 @item Cfront model
15511 The AT&T C++ translator, Cfront, solved the template instantiation
15512 problem by creating the notion of a template repository, an
15513 automatically maintained place where template instances are stored. A
15514 more modern version of the repository works as follows: As individual
15515 object files are built, the compiler places any template definitions and
15516 instantiations encountered in the repository. At link time, the link
15517 wrapper adds in the objects in the repository and compiles any needed
15518 instances that were not previously emitted. The advantages of this
15519 model are more optimal compilation speed and the ability to use the
15520 system linker; to implement the Borland model a compiler vendor also
15521 needs to replace the linker. The disadvantages are vastly increased
15522 complexity, and thus potential for error; for some code this can be
15523 just as transparent, but in practice it can been very difficult to build
15524 multiple programs in one directory and one program in multiple
15525 directories. Code written for this model tends to separate definitions
15526 of non-inline member templates into a separate file, which should be
15527 compiled separately.
15528 @end table
15529
15530 When used with GNU ld version 2.8 or later on an ELF system such as
15531 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
15532 Borland model. On other systems, G++ implements neither automatic
15533 model.
15534
15535 You have the following options for dealing with template instantiations:
15536
15537 @enumerate
15538 @item
15539 @opindex frepo
15540 Compile your template-using code with @option{-frepo}. The compiler
15541 generates files with the extension @samp{.rpo} listing all of the
15542 template instantiations used in the corresponding object files that
15543 could be instantiated there; the link wrapper, @samp{collect2},
15544 then updates the @samp{.rpo} files to tell the compiler where to place
15545 those instantiations and rebuild any affected object files. The
15546 link-time overhead is negligible after the first pass, as the compiler
15547 continues to place the instantiations in the same files.
15548
15549 This is your best option for application code written for the Borland
15550 model, as it just works. Code written for the Cfront model
15551 needs to be modified so that the template definitions are available at
15552 one or more points of instantiation; usually this is as simple as adding
15553 @code{#include <tmethods.cc>} to the end of each template header.
15554
15555 For library code, if you want the library to provide all of the template
15556 instantiations it needs, just try to link all of its object files
15557 together; the link will fail, but cause the instantiations to be
15558 generated as a side effect. Be warned, however, that this may cause
15559 conflicts if multiple libraries try to provide the same instantiations.
15560 For greater control, use explicit instantiation as described in the next
15561 option.
15562
15563 @item
15564 @opindex fno-implicit-templates
15565 Compile your code with @option{-fno-implicit-templates} to disable the
15566 implicit generation of template instances, and explicitly instantiate
15567 all the ones you use. This approach requires more knowledge of exactly
15568 which instances you need than do the others, but it's less
15569 mysterious and allows greater control. You can scatter the explicit
15570 instantiations throughout your program, perhaps putting them in the
15571 translation units where the instances are used or the translation units
15572 that define the templates themselves; you can put all of the explicit
15573 instantiations you need into one big file; or you can create small files
15574 like
15575
15576 @smallexample
15577 #include "Foo.h"
15578 #include "Foo.cc"
15579
15580 template class Foo<int>;
15581 template ostream& operator <<
15582 (ostream&, const Foo<int>&);
15583 @end smallexample
15584
15585 @noindent
15586 for each of the instances you need, and create a template instantiation
15587 library from those.
15588
15589 If you are using Cfront-model code, you can probably get away with not
15590 using @option{-fno-implicit-templates} when compiling files that don't
15591 @samp{#include} the member template definitions.
15592
15593 If you use one big file to do the instantiations, you may want to
15594 compile it without @option{-fno-implicit-templates} so you get all of the
15595 instances required by your explicit instantiations (but not by any
15596 other files) without having to specify them as well.
15597
15598 The ISO C++ 2011 standard allows forward declaration of explicit
15599 instantiations (with @code{extern}). G++ supports explicit instantiation
15600 declarations in C++98 mode and has extended the template instantiation
15601 syntax to support instantiation of the compiler support data for a
15602 template class (i.e.@: the vtable) without instantiating any of its
15603 members (with @code{inline}), and instantiation of only the static data
15604 members of a template class, without the support data or member
15605 functions (with (@code{static}):
15606
15607 @smallexample
15608 extern template int max (int, int);
15609 inline template class Foo<int>;
15610 static template class Foo<int>;
15611 @end smallexample
15612
15613 @item
15614 Do nothing. Pretend G++ does implement automatic instantiation
15615 management. Code written for the Borland model works fine, but
15616 each translation unit contains instances of each of the templates it
15617 uses. In a large program, this can lead to an unacceptable amount of code
15618 duplication.
15619 @end enumerate
15620
15621 @node Bound member functions
15622 @section Extracting the function pointer from a bound pointer to member function
15623 @cindex pmf
15624 @cindex pointer to member function
15625 @cindex bound pointer to member function
15626
15627 In C++, pointer to member functions (PMFs) are implemented using a wide
15628 pointer of sorts to handle all the possible call mechanisms; the PMF
15629 needs to store information about how to adjust the @samp{this} pointer,
15630 and if the function pointed to is virtual, where to find the vtable, and
15631 where in the vtable to look for the member function. If you are using
15632 PMFs in an inner loop, you should really reconsider that decision. If
15633 that is not an option, you can extract the pointer to the function that
15634 would be called for a given object/PMF pair and call it directly inside
15635 the inner loop, to save a bit of time.
15636
15637 Note that you still pay the penalty for the call through a
15638 function pointer; on most modern architectures, such a call defeats the
15639 branch prediction features of the CPU@. This is also true of normal
15640 virtual function calls.
15641
15642 The syntax for this extension is
15643
15644 @smallexample
15645 extern A a;
15646 extern int (A::*fp)();
15647 typedef int (*fptr)(A *);
15648
15649 fptr p = (fptr)(a.*fp);
15650 @end smallexample
15651
15652 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
15653 no object is needed to obtain the address of the function. They can be
15654 converted to function pointers directly:
15655
15656 @smallexample
15657 fptr p1 = (fptr)(&A::foo);
15658 @end smallexample
15659
15660 @opindex Wno-pmf-conversions
15661 You must specify @option{-Wno-pmf-conversions} to use this extension.
15662
15663 @node C++ Attributes
15664 @section C++-Specific Variable, Function, and Type Attributes
15665
15666 Some attributes only make sense for C++ programs.
15667
15668 @table @code
15669 @item abi_tag ("@var{tag}", ...)
15670 @cindex @code{abi_tag} attribute
15671 The @code{abi_tag} attribute can be applied to a function or class
15672 declaration. It modifies the mangled name of the function or class to
15673 incorporate the tag name, in order to distinguish the function or
15674 class from an earlier version with a different ABI; perhaps the class
15675 has changed size, or the function has a different return type that is
15676 not encoded in the mangled name.
15677
15678 The argument can be a list of strings of arbitrary length. The
15679 strings are sorted on output, so the order of the list is
15680 unimportant.
15681
15682 A redeclaration of a function or class must not add new ABI tags,
15683 since doing so would change the mangled name.
15684
15685 The @option{-Wabi-tag} flag enables a warning about a class which does
15686 not have all the ABI tags used by its subobjects and virtual functions; for users with code
15687 that needs to coexist with an earlier ABI, using this option can help
15688 to find all affected types that need to be tagged.
15689
15690 @item init_priority (@var{priority})
15691 @cindex @code{init_priority} attribute
15692
15693
15694 In Standard C++, objects defined at namespace scope are guaranteed to be
15695 initialized in an order in strict accordance with that of their definitions
15696 @emph{in a given translation unit}. No guarantee is made for initializations
15697 across translation units. However, GNU C++ allows users to control the
15698 order of initialization of objects defined at namespace scope with the
15699 @code{init_priority} attribute by specifying a relative @var{priority},
15700 a constant integral expression currently bounded between 101 and 65535
15701 inclusive. Lower numbers indicate a higher priority.
15702
15703 In the following example, @code{A} would normally be created before
15704 @code{B}, but the @code{init_priority} attribute reverses that order:
15705
15706 @smallexample
15707 Some_Class A __attribute__ ((init_priority (2000)));
15708 Some_Class B __attribute__ ((init_priority (543)));
15709 @end smallexample
15710
15711 @noindent
15712 Note that the particular values of @var{priority} do not matter; only their
15713 relative ordering.
15714
15715 @item java_interface
15716 @cindex @code{java_interface} attribute
15717
15718 This type attribute informs C++ that the class is a Java interface. It may
15719 only be applied to classes declared within an @code{extern "Java"} block.
15720 Calls to methods declared in this interface are dispatched using GCJ's
15721 interface table mechanism, instead of regular virtual table dispatch.
15722
15723 @end table
15724
15725 See also @ref{Namespace Association}.
15726
15727 @node Namespace Association
15728 @section Namespace Association
15729
15730 @strong{Caution:} The semantics of this extension are equivalent
15731 to C++ 2011 inline namespaces. Users should use inline namespaces
15732 instead as this extension will be removed in future versions of G++.
15733
15734 A using-directive with @code{__attribute ((strong))} is stronger
15735 than a normal using-directive in two ways:
15736
15737 @itemize @bullet
15738 @item
15739 Templates from the used namespace can be specialized and explicitly
15740 instantiated as though they were members of the using namespace.
15741
15742 @item
15743 The using namespace is considered an associated namespace of all
15744 templates in the used namespace for purposes of argument-dependent
15745 name lookup.
15746 @end itemize
15747
15748 The used namespace must be nested within the using namespace so that
15749 normal unqualified lookup works properly.
15750
15751 This is useful for composing a namespace transparently from
15752 implementation namespaces. For example:
15753
15754 @smallexample
15755 namespace std @{
15756 namespace debug @{
15757 template <class T> struct A @{ @};
15758 @}
15759 using namespace debug __attribute ((__strong__));
15760 template <> struct A<int> @{ @}; // @r{ok to specialize}
15761
15762 template <class T> void f (A<T>);
15763 @}
15764
15765 int main()
15766 @{
15767 f (std::A<float>()); // @r{lookup finds} std::f
15768 f (std::A<int>());
15769 @}
15770 @end smallexample
15771
15772 @node Type Traits
15773 @section Type Traits
15774
15775 The C++ front end implements syntactic extensions that allow
15776 compile-time determination of
15777 various characteristics of a type (or of a
15778 pair of types).
15779
15780 @table @code
15781 @item __has_nothrow_assign (type)
15782 If @code{type} is const qualified or is a reference type then the trait is
15783 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
15784 is true, else if @code{type} is a cv class or union type with copy assignment
15785 operators that are known not to throw an exception then the trait is true,
15786 else it is false. Requires: @code{type} shall be a complete type,
15787 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15788
15789 @item __has_nothrow_copy (type)
15790 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
15791 @code{type} is a cv class or union type with copy constructors that
15792 are known not to throw an exception then the trait is true, else it is false.
15793 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
15794 @code{void}, or an array of unknown bound.
15795
15796 @item __has_nothrow_constructor (type)
15797 If @code{__has_trivial_constructor (type)} is true then the trait is
15798 true, else if @code{type} is a cv class or union type (or array
15799 thereof) with a default constructor that is known not to throw an
15800 exception then the trait is true, else it is false. Requires:
15801 @code{type} shall be a complete type, (possibly cv-qualified)
15802 @code{void}, or an array of unknown bound.
15803
15804 @item __has_trivial_assign (type)
15805 If @code{type} is const qualified or is a reference type then the trait is
15806 false. Otherwise if @code{__is_pod (type)} is true then the trait is
15807 true, else if @code{type} is a cv class or union type with a trivial
15808 copy assignment ([class.copy]) then the trait is true, else it is
15809 false. Requires: @code{type} shall be a complete type, (possibly
15810 cv-qualified) @code{void}, or an array of unknown bound.
15811
15812 @item __has_trivial_copy (type)
15813 If @code{__is_pod (type)} is true or @code{type} is a reference type
15814 then the trait is true, else if @code{type} is a cv class or union type
15815 with a trivial copy constructor ([class.copy]) then the trait
15816 is true, else it is false. Requires: @code{type} shall be a complete
15817 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15818
15819 @item __has_trivial_constructor (type)
15820 If @code{__is_pod (type)} is true then the trait is true, else if
15821 @code{type} is a cv class or union type (or array thereof) with a
15822 trivial default constructor ([class.ctor]) then the trait is true,
15823 else it is false. Requires: @code{type} shall be a complete
15824 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15825
15826 @item __has_trivial_destructor (type)
15827 If @code{__is_pod (type)} is true or @code{type} is a reference type then
15828 the trait is true, else if @code{type} is a cv class or union type (or
15829 array thereof) with a trivial destructor ([class.dtor]) then the trait
15830 is true, else it is false. Requires: @code{type} shall be a complete
15831 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15832
15833 @item __has_virtual_destructor (type)
15834 If @code{type} is a class type with a virtual destructor
15835 ([class.dtor]) then the trait is true, else it is false. Requires:
15836 @code{type} shall be a complete type, (possibly cv-qualified)
15837 @code{void}, or an array of unknown bound.
15838
15839 @item __is_abstract (type)
15840 If @code{type} is an abstract class ([class.abstract]) then the trait
15841 is true, else it is false. Requires: @code{type} shall be a complete
15842 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15843
15844 @item __is_base_of (base_type, derived_type)
15845 If @code{base_type} is a base class of @code{derived_type}
15846 ([class.derived]) then the trait is true, otherwise it is false.
15847 Top-level cv qualifications of @code{base_type} and
15848 @code{derived_type} are ignored. For the purposes of this trait, a
15849 class type is considered is own base. Requires: if @code{__is_class
15850 (base_type)} and @code{__is_class (derived_type)} are true and
15851 @code{base_type} and @code{derived_type} are not the same type
15852 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
15853 type. Diagnostic is produced if this requirement is not met.
15854
15855 @item __is_class (type)
15856 If @code{type} is a cv class type, and not a union type
15857 ([basic.compound]) the trait is true, else it is false.
15858
15859 @item __is_empty (type)
15860 If @code{__is_class (type)} is false then the trait is false.
15861 Otherwise @code{type} is considered empty if and only if: @code{type}
15862 has no non-static data members, or all non-static data members, if
15863 any, are bit-fields of length 0, and @code{type} has no virtual
15864 members, and @code{type} has no virtual base classes, and @code{type}
15865 has no base classes @code{base_type} for which
15866 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
15867 be a complete type, (possibly cv-qualified) @code{void}, or an array
15868 of unknown bound.
15869
15870 @item __is_enum (type)
15871 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
15872 true, else it is false.
15873
15874 @item __is_literal_type (type)
15875 If @code{type} is a literal type ([basic.types]) the trait is
15876 true, else it is false. Requires: @code{type} shall be a complete type,
15877 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15878
15879 @item __is_pod (type)
15880 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
15881 else it is false. Requires: @code{type} shall be a complete type,
15882 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15883
15884 @item __is_polymorphic (type)
15885 If @code{type} is a polymorphic class ([class.virtual]) then the trait
15886 is true, else it is false. Requires: @code{type} shall be a complete
15887 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15888
15889 @item __is_standard_layout (type)
15890 If @code{type} is a standard-layout type ([basic.types]) the trait is
15891 true, else it is false. Requires: @code{type} shall be a complete
15892 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15893
15894 @item __is_trivial (type)
15895 If @code{type} is a trivial type ([basic.types]) the trait is
15896 true, else it is false. Requires: @code{type} shall be a complete
15897 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15898
15899 @item __is_union (type)
15900 If @code{type} is a cv union type ([basic.compound]) the trait is
15901 true, else it is false.
15902
15903 @item __underlying_type (type)
15904 The underlying type of @code{type}. Requires: @code{type} shall be
15905 an enumeration type ([dcl.enum]).
15906
15907 @end table
15908
15909 @node Java Exceptions
15910 @section Java Exceptions
15911
15912 The Java language uses a slightly different exception handling model
15913 from C++. Normally, GNU C++ automatically detects when you are
15914 writing C++ code that uses Java exceptions, and handle them
15915 appropriately. However, if C++ code only needs to execute destructors
15916 when Java exceptions are thrown through it, GCC guesses incorrectly.
15917 Sample problematic code is:
15918
15919 @smallexample
15920 struct S @{ ~S(); @};
15921 extern void bar(); // @r{is written in Java, and may throw exceptions}
15922 void foo()
15923 @{
15924 S s;
15925 bar();
15926 @}
15927 @end smallexample
15928
15929 @noindent
15930 The usual effect of an incorrect guess is a link failure, complaining of
15931 a missing routine called @samp{__gxx_personality_v0}.
15932
15933 You can inform the compiler that Java exceptions are to be used in a
15934 translation unit, irrespective of what it might think, by writing
15935 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
15936 @samp{#pragma} must appear before any functions that throw or catch
15937 exceptions, or run destructors when exceptions are thrown through them.
15938
15939 You cannot mix Java and C++ exceptions in the same translation unit. It
15940 is believed to be safe to throw a C++ exception from one file through
15941 another file compiled for the Java exception model, or vice versa, but
15942 there may be bugs in this area.
15943
15944 @node Deprecated Features
15945 @section Deprecated Features
15946
15947 In the past, the GNU C++ compiler was extended to experiment with new
15948 features, at a time when the C++ language was still evolving. Now that
15949 the C++ standard is complete, some of those features are superseded by
15950 superior alternatives. Using the old features might cause a warning in
15951 some cases that the feature will be dropped in the future. In other
15952 cases, the feature might be gone already.
15953
15954 While the list below is not exhaustive, it documents some of the options
15955 that are now deprecated:
15956
15957 @table @code
15958 @item -fexternal-templates
15959 @itemx -falt-external-templates
15960 These are two of the many ways for G++ to implement template
15961 instantiation. @xref{Template Instantiation}. The C++ standard clearly
15962 defines how template definitions have to be organized across
15963 implementation units. G++ has an implicit instantiation mechanism that
15964 should work just fine for standard-conforming code.
15965
15966 @item -fstrict-prototype
15967 @itemx -fno-strict-prototype
15968 Previously it was possible to use an empty prototype parameter list to
15969 indicate an unspecified number of parameters (like C), rather than no
15970 parameters, as C++ demands. This feature has been removed, except where
15971 it is required for backwards compatibility. @xref{Backwards Compatibility}.
15972 @end table
15973
15974 G++ allows a virtual function returning @samp{void *} to be overridden
15975 by one returning a different pointer type. This extension to the
15976 covariant return type rules is now deprecated and will be removed from a
15977 future version.
15978
15979 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
15980 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
15981 and are now removed from G++. Code using these operators should be
15982 modified to use @code{std::min} and @code{std::max} instead.
15983
15984 The named return value extension has been deprecated, and is now
15985 removed from G++.
15986
15987 The use of initializer lists with new expressions has been deprecated,
15988 and is now removed from G++.
15989
15990 Floating and complex non-type template parameters have been deprecated,
15991 and are now removed from G++.
15992
15993 The implicit typename extension has been deprecated and is now
15994 removed from G++.
15995
15996 The use of default arguments in function pointers, function typedefs
15997 and other places where they are not permitted by the standard is
15998 deprecated and will be removed from a future version of G++.
15999
16000 G++ allows floating-point literals to appear in integral constant expressions,
16001 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
16002 This extension is deprecated and will be removed from a future version.
16003
16004 G++ allows static data members of const floating-point type to be declared
16005 with an initializer in a class definition. The standard only allows
16006 initializers for static members of const integral types and const
16007 enumeration types so this extension has been deprecated and will be removed
16008 from a future version.
16009
16010 @node Backwards Compatibility
16011 @section Backwards Compatibility
16012 @cindex Backwards Compatibility
16013 @cindex ARM [Annotated C++ Reference Manual]
16014
16015 Now that there is a definitive ISO standard C++, G++ has a specification
16016 to adhere to. The C++ language evolved over time, and features that
16017 used to be acceptable in previous drafts of the standard, such as the ARM
16018 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
16019 compilation of C++ written to such drafts, G++ contains some backwards
16020 compatibilities. @emph{All such backwards compatibility features are
16021 liable to disappear in future versions of G++.} They should be considered
16022 deprecated. @xref{Deprecated Features}.
16023
16024 @table @code
16025 @item For scope
16026 If a variable is declared at for scope, it used to remain in scope until
16027 the end of the scope that contained the for statement (rather than just
16028 within the for scope). G++ retains this, but issues a warning, if such a
16029 variable is accessed outside the for scope.
16030
16031 @item Implicit C language
16032 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
16033 scope to set the language. On such systems, all header files are
16034 implicitly scoped inside a C language scope. Also, an empty prototype
16035 @code{()} is treated as an unspecified number of arguments, rather
16036 than no arguments, as C++ demands.
16037 @end table