]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
Add C++ attribute abi_tag and -Wabi-tag option.
[thirdparty/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 Then you can select a label with indexing, like this:
343
344 @smallexample
345 goto *array[i];
346 @end smallexample
347
348 @noindent
349 Note that this does not check whether the subscript is in bounds---array
350 indexing in C never does that.
351
352 Such an array of label values serves a purpose much like that of the
353 @code{switch} statement. The @code{switch} statement is cleaner, so
354 use that rather than an array unless the problem does not fit a
355 @code{switch} statement very well.
356
357 Another use of label values is in an interpreter for threaded code.
358 The labels within the interpreter function can be stored in the
359 threaded code for super-fast dispatching.
360
361 You may not use this mechanism to jump to code in a different function.
362 If you do that, totally unpredictable things happen. The best way to
363 avoid this is to store the label address only in automatic variables and
364 never pass it as an argument.
365
366 An alternate way to write the above example is
367
368 @smallexample
369 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
370 &&hack - &&foo @};
371 goto *(&&foo + array[i]);
372 @end smallexample
373
374 @noindent
375 This is more friendly to code living in shared libraries, as it reduces
376 the number of dynamic relocations that are needed, and by consequence,
377 allows the data to be read-only.
378
379 The @code{&&foo} expressions for the same label might have different
380 values if the containing function is inlined or cloned. If a program
381 relies on them being always the same,
382 @code{__attribute__((__noinline__,__noclone__))} should be used to
383 prevent inlining and cloning. If @code{&&foo} is used in a static
384 variable initializer, inlining and cloning is forbidden.
385
386 @node Nested Functions
387 @section Nested Functions
388 @cindex nested functions
389 @cindex downward funargs
390 @cindex thunks
391
392 A @dfn{nested function} is a function defined inside another function.
393 (Nested functions are not supported for GNU C++.) The nested function's
394 name is local to the block where it is defined. For example, here we
395 define a nested function named @code{square}, and call it twice:
396
397 @smallexample
398 @group
399 foo (double a, double b)
400 @{
401 double square (double z) @{ return z * z; @}
402
403 return square (a) + square (b);
404 @}
405 @end group
406 @end smallexample
407
408 The nested function can access all the variables of the containing
409 function that are visible at the point of its definition. This is
410 called @dfn{lexical scoping}. For example, here we show a nested
411 function which uses an inherited variable named @code{offset}:
412
413 @smallexample
414 @group
415 bar (int *array, int offset, int size)
416 @{
417 int access (int *array, int index)
418 @{ return array[index + offset]; @}
419 int i;
420 /* @r{@dots{}} */
421 for (i = 0; i < size; i++)
422 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
423 @}
424 @end group
425 @end smallexample
426
427 Nested function definitions are permitted within functions in the places
428 where variable definitions are allowed; that is, in any block, mixed
429 with the other declarations and statements in the block.
430
431 It is possible to call the nested function from outside the scope of its
432 name by storing its address or passing the address to another function:
433
434 @smallexample
435 hack (int *array, int size)
436 @{
437 void store (int index, int value)
438 @{ array[index] = value; @}
439
440 intermediate (store, size);
441 @}
442 @end smallexample
443
444 Here, the function @code{intermediate} receives the address of
445 @code{store} as an argument. If @code{intermediate} calls @code{store},
446 the arguments given to @code{store} are used to store into @code{array}.
447 But this technique works only so long as the containing function
448 (@code{hack}, in this example) does not exit.
449
450 If you try to call the nested function through its address after the
451 containing function exits, all hell breaks loose. If you try
452 to call it after a containing scope level exits, and if it refers
453 to some of the variables that are no longer in scope, you may be lucky,
454 but it's not wise to take the risk. If, however, the nested function
455 does not refer to anything that has gone out of scope, you should be
456 safe.
457
458 GCC implements taking the address of a nested function using a technique
459 called @dfn{trampolines}. This technique was described in
460 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
461 C++ Conference Proceedings, October 17-21, 1988).
462
463 A nested function can jump to a label inherited from a containing
464 function, provided the label is explicitly declared in the containing
465 function (@pxref{Local Labels}). Such a jump returns instantly to the
466 containing function, exiting the nested function which did the
467 @code{goto} and any intermediate functions as well. Here is an example:
468
469 @smallexample
470 @group
471 bar (int *array, int offset, int size)
472 @{
473 __label__ failure;
474 int access (int *array, int index)
475 @{
476 if (index > size)
477 goto failure;
478 return array[index + offset];
479 @}
480 int i;
481 /* @r{@dots{}} */
482 for (i = 0; i < size; i++)
483 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
484 /* @r{@dots{}} */
485 return 0;
486
487 /* @r{Control comes here from @code{access}
488 if it detects an error.} */
489 failure:
490 return -1;
491 @}
492 @end group
493 @end smallexample
494
495 A nested function always has no linkage. Declaring one with
496 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
497 before its definition, use @code{auto} (which is otherwise meaningless
498 for function declarations).
499
500 @smallexample
501 bar (int *array, int offset, int size)
502 @{
503 __label__ failure;
504 auto int access (int *, int);
505 /* @r{@dots{}} */
506 int access (int *array, int index)
507 @{
508 if (index > size)
509 goto failure;
510 return array[index + offset];
511 @}
512 /* @r{@dots{}} */
513 @}
514 @end smallexample
515
516 @node Constructing Calls
517 @section Constructing Function Calls
518 @cindex constructing calls
519 @cindex forwarding calls
520
521 Using the built-in functions described below, you can record
522 the arguments a function received, and call another function
523 with the same arguments, without knowing the number or types
524 of the arguments.
525
526 You can also record the return value of that function call,
527 and later return that value, without knowing what data type
528 the function tried to return (as long as your caller expects
529 that data type).
530
531 However, these built-in functions may interact badly with some
532 sophisticated features or other extensions of the language. It
533 is, therefore, not recommended to use them outside very simple
534 functions acting as mere forwarders for their arguments.
535
536 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
537 This built-in function returns a pointer to data
538 describing how to perform a call with the same arguments as are passed
539 to the current function.
540
541 The function saves the arg pointer register, structure value address,
542 and all registers that might be used to pass arguments to a function
543 into a block of memory allocated on the stack. Then it returns the
544 address of that block.
545 @end deftypefn
546
547 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
548 This built-in function invokes @var{function}
549 with a copy of the parameters described by @var{arguments}
550 and @var{size}.
551
552 The value of @var{arguments} should be the value returned by
553 @code{__builtin_apply_args}. The argument @var{size} specifies the size
554 of the stack argument data, in bytes.
555
556 This function returns a pointer to data describing
557 how to return whatever value is returned by @var{function}. The data
558 is saved in a block of memory allocated on the stack.
559
560 It is not always simple to compute the proper value for @var{size}. The
561 value is used by @code{__builtin_apply} to compute the amount of data
562 that should be pushed on the stack and copied from the incoming argument
563 area.
564 @end deftypefn
565
566 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
567 This built-in function returns the value described by @var{result} from
568 the containing function. You should specify, for @var{result}, a value
569 returned by @code{__builtin_apply}.
570 @end deftypefn
571
572 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
573 This built-in function represents all anonymous arguments of an inline
574 function. It can be used only in inline functions which are always
575 inlined, never compiled as a separate function, such as those using
576 @code{__attribute__ ((__always_inline__))} or
577 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
578 It must be only passed as last argument to some other function
579 with variable arguments. This is useful for writing small wrapper
580 inlines for variable argument functions, when using preprocessor
581 macros is undesirable. For example:
582 @smallexample
583 extern int myprintf (FILE *f, const char *format, ...);
584 extern inline __attribute__ ((__gnu_inline__)) int
585 myprintf (FILE *f, const char *format, ...)
586 @{
587 int r = fprintf (f, "myprintf: ");
588 if (r < 0)
589 return r;
590 int s = fprintf (f, format, __builtin_va_arg_pack ());
591 if (s < 0)
592 return s;
593 return r + s;
594 @}
595 @end smallexample
596 @end deftypefn
597
598 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
599 This built-in function returns the number of anonymous arguments of
600 an inline function. It can be used only in inline functions which
601 are always inlined, never compiled as a separate function, such
602 as those using @code{__attribute__ ((__always_inline__))} or
603 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
604 For example following does link or runtime checking of open
605 arguments for optimized code:
606 @smallexample
607 #ifdef __OPTIMIZE__
608 extern inline __attribute__((__gnu_inline__)) int
609 myopen (const char *path, int oflag, ...)
610 @{
611 if (__builtin_va_arg_pack_len () > 1)
612 warn_open_too_many_arguments ();
613
614 if (__builtin_constant_p (oflag))
615 @{
616 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
617 @{
618 warn_open_missing_mode ();
619 return __open_2 (path, oflag);
620 @}
621 return open (path, oflag, __builtin_va_arg_pack ());
622 @}
623
624 if (__builtin_va_arg_pack_len () < 1)
625 return __open_2 (path, oflag);
626
627 return open (path, oflag, __builtin_va_arg_pack ());
628 @}
629 #endif
630 @end smallexample
631 @end deftypefn
632
633 @node Typeof
634 @section Referring to a Type with @code{typeof}
635 @findex typeof
636 @findex sizeof
637 @cindex macros, types of arguments
638
639 Another way to refer to the type of an expression is with @code{typeof}.
640 The syntax of using of this keyword looks like @code{sizeof}, but the
641 construct acts semantically like a type name defined with @code{typedef}.
642
643 There are two ways of writing the argument to @code{typeof}: with an
644 expression or with a type. Here is an example with an expression:
645
646 @smallexample
647 typeof (x[0](1))
648 @end smallexample
649
650 @noindent
651 This assumes that @code{x} is an array of pointers to functions;
652 the type described is that of the values of the functions.
653
654 Here is an example with a typename as the argument:
655
656 @smallexample
657 typeof (int *)
658 @end smallexample
659
660 @noindent
661 Here the type described is that of pointers to @code{int}.
662
663 If you are writing a header file that must work when included in ISO C
664 programs, write @code{__typeof__} instead of @code{typeof}.
665 @xref{Alternate Keywords}.
666
667 A @code{typeof}-construct can be used anywhere a typedef name could be
668 used. For example, you can use it in a declaration, in a cast, or inside
669 of @code{sizeof} or @code{typeof}.
670
671 The operand of @code{typeof} is evaluated for its side effects if and
672 only if it is an expression of variably modified type or the name of
673 such a type.
674
675 @code{typeof} is often useful in conjunction with the
676 statements-within-expressions feature. Here is how the two together can
677 be used to define a safe ``maximum'' macro that operates on any
678 arithmetic type and evaluates each of its arguments exactly once:
679
680 @smallexample
681 #define max(a,b) \
682 (@{ typeof (a) _a = (a); \
683 typeof (b) _b = (b); \
684 _a > _b ? _a : _b; @})
685 @end smallexample
686
687 @cindex underscores in variables in macros
688 @cindex @samp{_} in variables in macros
689 @cindex local variables in macros
690 @cindex variables, local, in macros
691 @cindex macros, local variables in
692
693 The reason for using names that start with underscores for the local
694 variables is to avoid conflicts with variable names that occur within the
695 expressions that are substituted for @code{a} and @code{b}. Eventually we
696 hope to design a new form of declaration syntax that allows you to declare
697 variables whose scopes start only after their initializers; this will be a
698 more reliable way to prevent such conflicts.
699
700 @noindent
701 Some more examples of the use of @code{typeof}:
702
703 @itemize @bullet
704 @item
705 This declares @code{y} with the type of what @code{x} points to.
706
707 @smallexample
708 typeof (*x) y;
709 @end smallexample
710
711 @item
712 This declares @code{y} as an array of such values.
713
714 @smallexample
715 typeof (*x) y[4];
716 @end smallexample
717
718 @item
719 This declares @code{y} as an array of pointers to characters:
720
721 @smallexample
722 typeof (typeof (char *)[4]) y;
723 @end smallexample
724
725 @noindent
726 It is equivalent to the following traditional C declaration:
727
728 @smallexample
729 char *y[4];
730 @end smallexample
731
732 To see the meaning of the declaration using @code{typeof}, and why it
733 might be a useful way to write, rewrite it with these macros:
734
735 @smallexample
736 #define pointer(T) typeof(T *)
737 #define array(T, N) typeof(T [N])
738 @end smallexample
739
740 @noindent
741 Now the declaration can be rewritten this way:
742
743 @smallexample
744 array (pointer (char), 4) y;
745 @end smallexample
746
747 @noindent
748 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
749 pointers to @code{char}.
750 @end itemize
751
752 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
753 a more limited extension which permitted one to write
754
755 @smallexample
756 typedef @var{T} = @var{expr};
757 @end smallexample
758
759 @noindent
760 with the effect of declaring @var{T} to have the type of the expression
761 @var{expr}. This extension does not work with GCC 3 (versions between
762 3.0 and 3.2 crash; 3.2.1 and later give an error). Code which
763 relies on it should be rewritten to use @code{typeof}:
764
765 @smallexample
766 typedef typeof(@var{expr}) @var{T};
767 @end smallexample
768
769 @noindent
770 This works with all versions of GCC@.
771
772 @node Conditionals
773 @section Conditionals with Omitted Operands
774 @cindex conditional expressions, extensions
775 @cindex omitted middle-operands
776 @cindex middle-operands, omitted
777 @cindex extensions, @code{?:}
778 @cindex @code{?:} extensions
779
780 The middle operand in a conditional expression may be omitted. Then
781 if the first operand is nonzero, its value is the value of the conditional
782 expression.
783
784 Therefore, the expression
785
786 @smallexample
787 x ? : y
788 @end smallexample
789
790 @noindent
791 has the value of @code{x} if that is nonzero; otherwise, the value of
792 @code{y}.
793
794 This example is perfectly equivalent to
795
796 @smallexample
797 x ? x : y
798 @end smallexample
799
800 @cindex side effect in @code{?:}
801 @cindex @code{?:} side effect
802 @noindent
803 In this simple case, the ability to omit the middle operand is not
804 especially useful. When it becomes useful is when the first operand does,
805 or may (if it is a macro argument), contain a side effect. Then repeating
806 the operand in the middle would perform the side effect twice. Omitting
807 the middle operand uses the value already computed without the undesirable
808 effects of recomputing it.
809
810 @node __int128
811 @section 128-bits integers
812 @cindex @code{__int128} data types
813
814 As an extension the integer scalar type @code{__int128} is supported for
815 targets having an integer mode wide enough to hold 128-bit.
816 Simply write @code{__int128} for a signed 128-bit integer, or
817 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
818 support in GCC to express an integer constant of type @code{__int128}
819 for targets having @code{long long} integer with less then 128 bit width.
820
821 @node Long Long
822 @section Double-Word Integers
823 @cindex @code{long long} data types
824 @cindex double-word arithmetic
825 @cindex multiprecision arithmetic
826 @cindex @code{LL} integer suffix
827 @cindex @code{ULL} integer suffix
828
829 ISO C99 supports data types for integers that are at least 64 bits wide,
830 and as an extension GCC supports them in C90 mode and in C++.
831 Simply write @code{long long int} for a signed integer, or
832 @code{unsigned long long int} for an unsigned integer. To make an
833 integer constant of type @code{long long int}, add the suffix @samp{LL}
834 to the integer. To make an integer constant of type @code{unsigned long
835 long int}, add the suffix @samp{ULL} to the integer.
836
837 You can use these types in arithmetic like any other integer types.
838 Addition, subtraction, and bitwise boolean operations on these types
839 are open-coded on all types of machines. Multiplication is open-coded
840 if the machine supports fullword-to-doubleword a widening multiply
841 instruction. Division and shifts are open-coded only on machines that
842 provide special support. The operations that are not open-coded use
843 special library routines that come with GCC@.
844
845 There may be pitfalls when you use @code{long long} types for function
846 arguments, unless you declare function prototypes. If a function
847 expects type @code{int} for its argument, and you pass a value of type
848 @code{long long int}, confusion results because the caller and the
849 subroutine disagree about the number of bytes for the argument.
850 Likewise, if the function expects @code{long long int} and you pass
851 @code{int}. The best way to avoid such problems is to use prototypes.
852
853 @node Complex
854 @section Complex Numbers
855 @cindex complex numbers
856 @cindex @code{_Complex} keyword
857 @cindex @code{__complex__} keyword
858
859 ISO C99 supports complex floating data types, and as an extension GCC
860 supports them in C90 mode and in C++, and supports complex integer data
861 types which are not part of ISO C99. You can declare complex types
862 using the keyword @code{_Complex}. As an extension, the older GNU
863 keyword @code{__complex__} is also supported.
864
865 For example, @samp{_Complex double x;} declares @code{x} as a
866 variable whose real part and imaginary part are both of type
867 @code{double}. @samp{_Complex short int y;} declares @code{y} to
868 have real and imaginary parts of type @code{short int}; this is not
869 likely to be useful, but it shows that the set of complex types is
870 complete.
871
872 To write a constant with a complex data type, use the suffix @samp{i} or
873 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
874 has type @code{_Complex float} and @code{3i} has type
875 @code{_Complex int}. Such a constant always has a pure imaginary
876 value, but you can form any complex value you like by adding one to a
877 real constant. This is a GNU extension; if you have an ISO C99
878 conforming C library (such as GNU libc), and want to construct complex
879 constants of floating type, you should include @code{<complex.h>} and
880 use the macros @code{I} or @code{_Complex_I} instead.
881
882 @cindex @code{__real__} keyword
883 @cindex @code{__imag__} keyword
884 To extract the real part of a complex-valued expression @var{exp}, write
885 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
886 extract the imaginary part. This is a GNU extension; for values of
887 floating type, you should use the ISO C99 functions @code{crealf},
888 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
889 @code{cimagl}, declared in @code{<complex.h>} and also provided as
890 built-in functions by GCC@.
891
892 @cindex complex conjugation
893 The operator @samp{~} performs complex conjugation when used on a value
894 with a complex type. This is a GNU extension; for values of
895 floating type, you should use the ISO C99 functions @code{conjf},
896 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
897 provided as built-in functions by GCC@.
898
899 GCC can allocate complex automatic variables in a noncontiguous
900 fashion; it's even possible for the real part to be in a register while
901 the imaginary part is on the stack (or vice-versa). Only the DWARF2
902 debug info format can represent this, so use of DWARF2 is recommended.
903 If you are using the stabs debug info format, GCC describes a noncontiguous
904 complex variable as if it were two separate variables of noncomplex type.
905 If the variable's actual name is @code{foo}, the two fictitious
906 variables are named @code{foo$real} and @code{foo$imag}. You can
907 examine and set these two fictitious variables with your debugger.
908
909 @node Floating Types
910 @section Additional Floating Types
911 @cindex additional floating types
912 @cindex @code{__float80} data type
913 @cindex @code{__float128} data type
914 @cindex @code{w} floating point suffix
915 @cindex @code{q} floating point suffix
916 @cindex @code{W} floating point suffix
917 @cindex @code{Q} floating point suffix
918
919 As an extension, the GNU C compiler supports additional floating
920 types, @code{__float80} and @code{__float128} to support 80bit
921 (@code{XFmode}) and 128 bit (@code{TFmode}) floating types.
922 Support for additional types includes the arithmetic operators:
923 add, subtract, multiply, divide; unary arithmetic operators;
924 relational operators; equality operators; and conversions to and from
925 integer and other floating types. Use a suffix @samp{w} or @samp{W}
926 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
927 for @code{_float128}. You can declare complex types using the
928 corresponding internal complex type, @code{XCmode} for @code{__float80}
929 type and @code{TCmode} for @code{__float128} type:
930
931 @smallexample
932 typedef _Complex float __attribute__((mode(TC))) _Complex128;
933 typedef _Complex float __attribute__((mode(XC))) _Complex80;
934 @end smallexample
935
936 Not all targets support additional floating point types. @code{__float80}
937 and @code{__float128} types are supported on i386, x86_64 and ia64 targets.
938 The @code{__float128} type is supported on hppa HP-UX targets.
939
940 @node Half-Precision
941 @section Half-Precision Floating Point
942 @cindex half-precision floating point
943 @cindex @code{__fp16} data type
944
945 On ARM targets, GCC supports half-precision (16-bit) floating point via
946 the @code{__fp16} type. You must enable this type explicitly
947 with the @option{-mfp16-format} command-line option in order to use it.
948
949 ARM supports two incompatible representations for half-precision
950 floating-point values. You must choose one of the representations and
951 use it consistently in your program.
952
953 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
954 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
955 There are 11 bits of significand precision, approximately 3
956 decimal digits.
957
958 Specifying @option{-mfp16-format=alternative} selects the ARM
959 alternative format. This representation is similar to the IEEE
960 format, but does not support infinities or NaNs. Instead, the range
961 of exponents is extended, so that this format can represent normalized
962 values in the range of @math{2^{-14}} to 131008.
963
964 The @code{__fp16} type is a storage format only. For purposes
965 of arithmetic and other operations, @code{__fp16} values in C or C++
966 expressions are automatically promoted to @code{float}. In addition,
967 you cannot declare a function with a return value or parameters
968 of type @code{__fp16}.
969
970 Note that conversions from @code{double} to @code{__fp16}
971 involve an intermediate conversion to @code{float}. Because
972 of rounding, this can sometimes produce a different result than a
973 direct conversion.
974
975 ARM provides hardware support for conversions between
976 @code{__fp16} and @code{float} values
977 as an extension to VFP and NEON (Advanced SIMD). GCC generates
978 code using these hardware instructions if you compile with
979 options to select an FPU that provides them;
980 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
981 in addition to the @option{-mfp16-format} option to select
982 a half-precision format.
983
984 Language-level support for the @code{__fp16} data type is
985 independent of whether GCC generates code using hardware floating-point
986 instructions. In cases where hardware support is not specified, GCC
987 implements conversions between @code{__fp16} and @code{float} values
988 as library calls.
989
990 @node Decimal Float
991 @section Decimal Floating Types
992 @cindex decimal floating types
993 @cindex @code{_Decimal32} data type
994 @cindex @code{_Decimal64} data type
995 @cindex @code{_Decimal128} data type
996 @cindex @code{df} integer suffix
997 @cindex @code{dd} integer suffix
998 @cindex @code{dl} integer suffix
999 @cindex @code{DF} integer suffix
1000 @cindex @code{DD} integer suffix
1001 @cindex @code{DL} integer suffix
1002
1003 As an extension, the GNU C compiler supports decimal floating types as
1004 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1005 floating types in GCC will evolve as the draft technical report changes.
1006 Calling conventions for any target might also change. Not all targets
1007 support decimal floating types.
1008
1009 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1010 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1011 @code{float}, @code{double}, and @code{long double} whose radix is not
1012 specified by the C standard but is usually two.
1013
1014 Support for decimal floating types includes the arithmetic operators
1015 add, subtract, multiply, divide; unary arithmetic operators;
1016 relational operators; equality operators; and conversions to and from
1017 integer and other floating types. Use a suffix @samp{df} or
1018 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1019 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1020 @code{_Decimal128}.
1021
1022 GCC support of decimal float as specified by the draft technical report
1023 is incomplete:
1024
1025 @itemize @bullet
1026 @item
1027 When the value of a decimal floating type cannot be represented in the
1028 integer type to which it is being converted, the result is undefined
1029 rather than the result value specified by the draft technical report.
1030
1031 @item
1032 GCC does not provide the C library functionality associated with
1033 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1034 @file{wchar.h}, which must come from a separate C library implementation.
1035 Because of this the GNU C compiler does not define macro
1036 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1037 the technical report.
1038 @end itemize
1039
1040 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1041 are supported by the DWARF2 debug information format.
1042
1043 @node Hex Floats
1044 @section Hex Floats
1045 @cindex hex floats
1046
1047 ISO C99 supports floating-point numbers written not only in the usual
1048 decimal notation, such as @code{1.55e1}, but also numbers such as
1049 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1050 supports this in C90 mode (except in some cases when strictly
1051 conforming) and in C++. In that format the
1052 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1053 mandatory. The exponent is a decimal number that indicates the power of
1054 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1055 @tex
1056 $1 {15\over16}$,
1057 @end tex
1058 @ifnottex
1059 1 15/16,
1060 @end ifnottex
1061 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1062 is the same as @code{1.55e1}.
1063
1064 Unlike for floating-point numbers in the decimal notation the exponent
1065 is always required in the hexadecimal notation. Otherwise the compiler
1066 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1067 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1068 extension for floating-point constants of type @code{float}.
1069
1070 @node Fixed-Point
1071 @section Fixed-Point Types
1072 @cindex fixed-point types
1073 @cindex @code{_Fract} data type
1074 @cindex @code{_Accum} data type
1075 @cindex @code{_Sat} data type
1076 @cindex @code{hr} fixed-suffix
1077 @cindex @code{r} fixed-suffix
1078 @cindex @code{lr} fixed-suffix
1079 @cindex @code{llr} fixed-suffix
1080 @cindex @code{uhr} fixed-suffix
1081 @cindex @code{ur} fixed-suffix
1082 @cindex @code{ulr} fixed-suffix
1083 @cindex @code{ullr} fixed-suffix
1084 @cindex @code{hk} fixed-suffix
1085 @cindex @code{k} fixed-suffix
1086 @cindex @code{lk} fixed-suffix
1087 @cindex @code{llk} fixed-suffix
1088 @cindex @code{uhk} fixed-suffix
1089 @cindex @code{uk} fixed-suffix
1090 @cindex @code{ulk} fixed-suffix
1091 @cindex @code{ullk} fixed-suffix
1092 @cindex @code{HR} fixed-suffix
1093 @cindex @code{R} fixed-suffix
1094 @cindex @code{LR} fixed-suffix
1095 @cindex @code{LLR} fixed-suffix
1096 @cindex @code{UHR} fixed-suffix
1097 @cindex @code{UR} fixed-suffix
1098 @cindex @code{ULR} fixed-suffix
1099 @cindex @code{ULLR} fixed-suffix
1100 @cindex @code{HK} fixed-suffix
1101 @cindex @code{K} fixed-suffix
1102 @cindex @code{LK} fixed-suffix
1103 @cindex @code{LLK} fixed-suffix
1104 @cindex @code{UHK} fixed-suffix
1105 @cindex @code{UK} fixed-suffix
1106 @cindex @code{ULK} fixed-suffix
1107 @cindex @code{ULLK} fixed-suffix
1108
1109 As an extension, the GNU C compiler supports fixed-point types as
1110 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1111 types in GCC will evolve as the draft technical report changes.
1112 Calling conventions for any target might also change. Not all targets
1113 support fixed-point types.
1114
1115 The fixed-point types are
1116 @code{short _Fract},
1117 @code{_Fract},
1118 @code{long _Fract},
1119 @code{long long _Fract},
1120 @code{unsigned short _Fract},
1121 @code{unsigned _Fract},
1122 @code{unsigned long _Fract},
1123 @code{unsigned long long _Fract},
1124 @code{_Sat short _Fract},
1125 @code{_Sat _Fract},
1126 @code{_Sat long _Fract},
1127 @code{_Sat long long _Fract},
1128 @code{_Sat unsigned short _Fract},
1129 @code{_Sat unsigned _Fract},
1130 @code{_Sat unsigned long _Fract},
1131 @code{_Sat unsigned long long _Fract},
1132 @code{short _Accum},
1133 @code{_Accum},
1134 @code{long _Accum},
1135 @code{long long _Accum},
1136 @code{unsigned short _Accum},
1137 @code{unsigned _Accum},
1138 @code{unsigned long _Accum},
1139 @code{unsigned long long _Accum},
1140 @code{_Sat short _Accum},
1141 @code{_Sat _Accum},
1142 @code{_Sat long _Accum},
1143 @code{_Sat long long _Accum},
1144 @code{_Sat unsigned short _Accum},
1145 @code{_Sat unsigned _Accum},
1146 @code{_Sat unsigned long _Accum},
1147 @code{_Sat unsigned long long _Accum}.
1148
1149 Fixed-point data values contain fractional and optional integral parts.
1150 The format of fixed-point data varies and depends on the target machine.
1151
1152 Support for fixed-point types includes:
1153 @itemize @bullet
1154 @item
1155 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1156 @item
1157 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1158 @item
1159 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1160 @item
1161 binary shift operators (@code{<<}, @code{>>})
1162 @item
1163 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1164 @item
1165 equality operators (@code{==}, @code{!=})
1166 @item
1167 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1168 @code{<<=}, @code{>>=})
1169 @item
1170 conversions to and from integer, floating-point, or fixed-point types
1171 @end itemize
1172
1173 Use a suffix in a fixed-point literal constant:
1174 @itemize
1175 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1176 @code{_Sat short _Fract}
1177 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1178 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1179 @code{_Sat long _Fract}
1180 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1181 @code{_Sat long long _Fract}
1182 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1183 @code{_Sat unsigned short _Fract}
1184 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1185 @code{_Sat unsigned _Fract}
1186 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1187 @code{_Sat unsigned long _Fract}
1188 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1189 and @code{_Sat unsigned long long _Fract}
1190 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1191 @code{_Sat short _Accum}
1192 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1193 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1194 @code{_Sat long _Accum}
1195 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1196 @code{_Sat long long _Accum}
1197 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1198 @code{_Sat unsigned short _Accum}
1199 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1200 @code{_Sat unsigned _Accum}
1201 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1202 @code{_Sat unsigned long _Accum}
1203 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1204 and @code{_Sat unsigned long long _Accum}
1205 @end itemize
1206
1207 GCC support of fixed-point types as specified by the draft technical report
1208 is incomplete:
1209
1210 @itemize @bullet
1211 @item
1212 Pragmas to control overflow and rounding behaviors are not implemented.
1213 @end itemize
1214
1215 Fixed-point types are supported by the DWARF2 debug information format.
1216
1217 @node Named Address Spaces
1218 @section Named Address Spaces
1219 @cindex Named Address Spaces
1220
1221 As an extension, the GNU C compiler supports named address spaces as
1222 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1223 address spaces in GCC will evolve as the draft technical report
1224 changes. Calling conventions for any target might also change. At
1225 present, only the AVR, SPU, M32C, and RL78 targets support address
1226 spaces other than the generic address space.
1227
1228 Address space identifiers may be used exactly like any other C type
1229 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1230 document for more details.
1231
1232 @anchor{AVR Named Address Spaces}
1233 @subsection AVR Named Address Spaces
1234
1235 On the AVR target, there are several address spaces that can be used
1236 in order to put read-only data into the flash memory and access that
1237 data by means of the special instructions @code{LPM} or @code{ELPM}
1238 needed to read from flash.
1239
1240 Per default, any data including read-only data is located in RAM
1241 (the generic address space) so that non-generic address spaces are
1242 needed to locate read-only data in flash memory
1243 @emph{and} to generate the right instructions to access this data
1244 without using (inline) assembler code.
1245
1246 @table @code
1247 @item __flash
1248 @cindex @code{__flash} AVR Named Address Spaces
1249 The @code{__flash} qualifier locates data in the
1250 @code{.progmem.data} section. Data is read using the @code{LPM}
1251 instruction. Pointers to this address space are 16 bits wide.
1252
1253 @item __flash1
1254 @itemx __flash2
1255 @itemx __flash3
1256 @itemx __flash4
1257 @itemx __flash5
1258 @cindex @code{__flash1} AVR Named Address Spaces
1259 @cindex @code{__flash2} AVR Named Address Spaces
1260 @cindex @code{__flash3} AVR Named Address Spaces
1261 @cindex @code{__flash4} AVR Named Address Spaces
1262 @cindex @code{__flash5} AVR Named Address Spaces
1263 These are 16-bit address spaces locating data in section
1264 @code{.progmem@var{N}.data} where @var{N} refers to
1265 address space @code{__flash@var{N}}.
1266 The compiler sets the @code{RAMPZ} segment register appropriately
1267 before reading data by means of the @code{ELPM} instruction.
1268
1269 @item __memx
1270 @cindex @code{__memx} AVR Named Address Spaces
1271 This is a 24-bit address space that linearizes flash and RAM:
1272 If the high bit of the address is set, data is read from
1273 RAM using the lower two bytes as RAM address.
1274 If the high bit of the address is clear, data is read from flash
1275 with @code{RAMPZ} set according to the high byte of the address.
1276 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1277
1278 Objects in this address space are located in @code{.progmem.data}.
1279 @end table
1280
1281 @b{Example}
1282
1283 @example
1284 char my_read (const __flash char ** p)
1285 @{
1286 /* p is a pointer to RAM that points to a pointer to flash.
1287 The first indirection of p reads that flash pointer
1288 from RAM and the second indirection reads a char from this
1289 flash address. */
1290
1291 return **p;
1292 @}
1293
1294 /* Locate array[] in flash memory */
1295 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1296
1297 int i = 1;
1298
1299 int main (void)
1300 @{
1301 /* Return 17 by reading from flash memory */
1302 return array[array[i]];
1303 @}
1304 @end example
1305
1306 @noindent
1307 For each named address space supported by avr-gcc there is an equally
1308 named but uppercase built-in macro defined.
1309 The purpose is to facilitate testing if respective address space
1310 support is available or not:
1311
1312 @example
1313 #ifdef __FLASH
1314 const __flash int var = 1;
1315
1316 int read_var (void)
1317 @{
1318 return var;
1319 @}
1320 #else
1321 #include <avr/pgmspace.h> /* From AVR-LibC */
1322
1323 const int var PROGMEM = 1;
1324
1325 int read_var (void)
1326 @{
1327 return (int) pgm_read_word (&var);
1328 @}
1329 #endif /* __FLASH */
1330 @end example
1331
1332 @noindent
1333 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1334 locates data in flash but
1335 accesses to these data read from generic address space, i.e.@:
1336 from RAM,
1337 so that you need special accessors like @code{pgm_read_byte}
1338 from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}}
1339 together with attribute @code{progmem}.
1340
1341 @noindent
1342 @b{Limitations and caveats}
1343
1344 @itemize
1345 @item
1346 Reading across the 64@tie{}KiB section boundary of
1347 the @code{__flash} or @code{__flash@var{N}} address spaces
1348 shows undefined behaviour. The only address space that
1349 supports reading across the 64@tie{}KiB flash segment boundaries is
1350 @code{__memx}.
1351
1352 @item
1353 If you use one of the @code{__flash@var{N}} address spaces
1354 you must arrange your linker script to locate the
1355 @code{.progmem@var{N}.data} sections according to your needs.
1356
1357 @item
1358 Any data or pointers to the non-generic address spaces must
1359 be qualified as @code{const}, i.e.@: as read-only data.
1360 This still applies if the data in one of these address
1361 spaces like software version number or calibration lookup table are intended to
1362 be changed after load time by, say, a boot loader. In this case
1363 the right qualification is @code{const} @code{volatile} so that the compiler
1364 must not optimize away known values or insert them
1365 as immediates into operands of instructions.
1366
1367 @item
1368 The following code initializes a variable @code{pfoo}
1369 located in static storage with a 24-bit address:
1370 @example
1371 extern const __memx char foo;
1372 const __memx void *pfoo = &foo;
1373 @end example
1374 Such code requires at least binutils 2.23, see
1375 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1376
1377 @end itemize
1378
1379 @subsection M32C Named Address Spaces
1380 @cindex @code{__far} M32C Named Address Spaces
1381
1382 On the M32C target, with the R8C and M16C cpu variants, variables
1383 qualified with @code{__far} are accessed using 32-bit addresses in
1384 order to access memory beyond the first 64@tie{}Ki bytes. If
1385 @code{__far} is used with the M32CM or M32C cpu variants, it has no
1386 effect.
1387
1388 @subsection RL78 Named Address Spaces
1389 @cindex @code{__far} RL78 Named Address Spaces
1390
1391 On the RL78 target, variables qualified with @code{__far} are accessed
1392 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1393 addresses. Non-far variables are assumed to appear in the topmost
1394 64@tie{}KiB of the address space.
1395
1396 @subsection SPU Named Address Spaces
1397 @cindex @code{__ea} SPU Named Address Spaces
1398
1399 On the SPU target variables may be declared as
1400 belonging to another address space by qualifying the type with the
1401 @code{__ea} address space identifier:
1402
1403 @smallexample
1404 extern int __ea i;
1405 @end smallexample
1406
1407 The compiler generates special code to access the variable @code{i}.
1408 It may use runtime library
1409 support, or generate special machine instructions to access that address
1410 space.
1411
1412 @node Zero Length
1413 @section Arrays of Length Zero
1414 @cindex arrays of length zero
1415 @cindex zero-length arrays
1416 @cindex length-zero arrays
1417 @cindex flexible array members
1418
1419 Zero-length arrays are allowed in GNU C@. They are very useful as the
1420 last element of a structure which is really a header for a variable-length
1421 object:
1422
1423 @smallexample
1424 struct line @{
1425 int length;
1426 char contents[0];
1427 @};
1428
1429 struct line *thisline = (struct line *)
1430 malloc (sizeof (struct line) + this_length);
1431 thisline->length = this_length;
1432 @end smallexample
1433
1434 In ISO C90, you would have to give @code{contents} a length of 1, which
1435 means either you waste space or complicate the argument to @code{malloc}.
1436
1437 In ISO C99, you would use a @dfn{flexible array member}, which is
1438 slightly different in syntax and semantics:
1439
1440 @itemize @bullet
1441 @item
1442 Flexible array members are written as @code{contents[]} without
1443 the @code{0}.
1444
1445 @item
1446 Flexible array members have incomplete type, and so the @code{sizeof}
1447 operator may not be applied. As a quirk of the original implementation
1448 of zero-length arrays, @code{sizeof} evaluates to zero.
1449
1450 @item
1451 Flexible array members may only appear as the last member of a
1452 @code{struct} that is otherwise non-empty.
1453
1454 @item
1455 A structure containing a flexible array member, or a union containing
1456 such a structure (possibly recursively), may not be a member of a
1457 structure or an element of an array. (However, these uses are
1458 permitted by GCC as extensions.)
1459 @end itemize
1460
1461 GCC versions before 3.0 allowed zero-length arrays to be statically
1462 initialized, as if they were flexible arrays. In addition to those
1463 cases that were useful, it also allowed initializations in situations
1464 that would corrupt later data. Non-empty initialization of zero-length
1465 arrays is now treated like any case where there are more initializer
1466 elements than the array holds, in that a suitable warning about "excess
1467 elements in array" is given, and the excess elements (all of them, in
1468 this case) are ignored.
1469
1470 Instead GCC allows static initialization of flexible array members.
1471 This is equivalent to defining a new structure containing the original
1472 structure followed by an array of sufficient size to contain the data.
1473 I.e.@: in the following, @code{f1} is constructed as if it were declared
1474 like @code{f2}.
1475
1476 @smallexample
1477 struct f1 @{
1478 int x; int y[];
1479 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1480
1481 struct f2 @{
1482 struct f1 f1; int data[3];
1483 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1484 @end smallexample
1485
1486 @noindent
1487 The convenience of this extension is that @code{f1} has the desired
1488 type, eliminating the need to consistently refer to @code{f2.f1}.
1489
1490 This has symmetry with normal static arrays, in that an array of
1491 unknown size is also written with @code{[]}.
1492
1493 Of course, this extension only makes sense if the extra data comes at
1494 the end of a top-level object, as otherwise we would be overwriting
1495 data at subsequent offsets. To avoid undue complication and confusion
1496 with initialization of deeply nested arrays, we simply disallow any
1497 non-empty initialization except when the structure is the top-level
1498 object. For example:
1499
1500 @smallexample
1501 struct foo @{ int x; int y[]; @};
1502 struct bar @{ struct foo z; @};
1503
1504 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1505 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1506 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1507 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1508 @end smallexample
1509
1510 @node Empty Structures
1511 @section Structures With No Members
1512 @cindex empty structures
1513 @cindex zero-size structures
1514
1515 GCC permits a C structure to have no members:
1516
1517 @smallexample
1518 struct empty @{
1519 @};
1520 @end smallexample
1521
1522 The structure has size zero. In C++, empty structures are part
1523 of the language. G++ treats empty structures as if they had a single
1524 member of type @code{char}.
1525
1526 @node Variable Length
1527 @section Arrays of Variable Length
1528 @cindex variable-length arrays
1529 @cindex arrays of variable length
1530 @cindex VLAs
1531
1532 Variable-length automatic arrays are allowed in ISO C99, and as an
1533 extension GCC accepts them in C90 mode and in C++. These arrays are
1534 declared like any other automatic arrays, but with a length that is not
1535 a constant expression. The storage is allocated at the point of
1536 declaration and deallocated when the brace-level is exited. For
1537 example:
1538
1539 @smallexample
1540 FILE *
1541 concat_fopen (char *s1, char *s2, char *mode)
1542 @{
1543 char str[strlen (s1) + strlen (s2) + 1];
1544 strcpy (str, s1);
1545 strcat (str, s2);
1546 return fopen (str, mode);
1547 @}
1548 @end smallexample
1549
1550 @cindex scope of a variable length array
1551 @cindex variable-length array scope
1552 @cindex deallocating variable length arrays
1553 Jumping or breaking out of the scope of the array name deallocates the
1554 storage. Jumping into the scope is not allowed; you get an error
1555 message for it.
1556
1557 @cindex @code{alloca} vs variable-length arrays
1558 You can use the function @code{alloca} to get an effect much like
1559 variable-length arrays. The function @code{alloca} is available in
1560 many other C implementations (but not in all). On the other hand,
1561 variable-length arrays are more elegant.
1562
1563 There are other differences between these two methods. Space allocated
1564 with @code{alloca} exists until the containing @emph{function} returns.
1565 The space for a variable-length array is deallocated as soon as the array
1566 name's scope ends. (If you use both variable-length arrays and
1567 @code{alloca} in the same function, deallocation of a variable-length array
1568 also deallocates anything more recently allocated with @code{alloca}.)
1569
1570 You can also use variable-length arrays as arguments to functions:
1571
1572 @smallexample
1573 struct entry
1574 tester (int len, char data[len][len])
1575 @{
1576 /* @r{@dots{}} */
1577 @}
1578 @end smallexample
1579
1580 The length of an array is computed once when the storage is allocated
1581 and is remembered for the scope of the array in case you access it with
1582 @code{sizeof}.
1583
1584 If you want to pass the array first and the length afterward, you can
1585 use a forward declaration in the parameter list---another GNU extension.
1586
1587 @smallexample
1588 struct entry
1589 tester (int len; char data[len][len], int len)
1590 @{
1591 /* @r{@dots{}} */
1592 @}
1593 @end smallexample
1594
1595 @cindex parameter forward declaration
1596 The @samp{int len} before the semicolon is a @dfn{parameter forward
1597 declaration}, and it serves the purpose of making the name @code{len}
1598 known when the declaration of @code{data} is parsed.
1599
1600 You can write any number of such parameter forward declarations in the
1601 parameter list. They can be separated by commas or semicolons, but the
1602 last one must end with a semicolon, which is followed by the ``real''
1603 parameter declarations. Each forward declaration must match a ``real''
1604 declaration in parameter name and data type. ISO C99 does not support
1605 parameter forward declarations.
1606
1607 @node Variadic Macros
1608 @section Macros with a Variable Number of Arguments.
1609 @cindex variable number of arguments
1610 @cindex macro with variable arguments
1611 @cindex rest argument (in macro)
1612 @cindex variadic macros
1613
1614 In the ISO C standard of 1999, a macro can be declared to accept a
1615 variable number of arguments much as a function can. The syntax for
1616 defining the macro is similar to that of a function. Here is an
1617 example:
1618
1619 @smallexample
1620 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1621 @end smallexample
1622
1623 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1624 such a macro, it represents the zero or more tokens until the closing
1625 parenthesis that ends the invocation, including any commas. This set of
1626 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1627 wherever it appears. See the CPP manual for more information.
1628
1629 GCC has long supported variadic macros, and used a different syntax that
1630 allowed you to give a name to the variable arguments just like any other
1631 argument. Here is an example:
1632
1633 @smallexample
1634 #define debug(format, args...) fprintf (stderr, format, args)
1635 @end smallexample
1636
1637 This is in all ways equivalent to the ISO C example above, but arguably
1638 more readable and descriptive.
1639
1640 GNU CPP has two further variadic macro extensions, and permits them to
1641 be used with either of the above forms of macro definition.
1642
1643 In standard C, you are not allowed to leave the variable argument out
1644 entirely; but you are allowed to pass an empty argument. For example,
1645 this invocation is invalid in ISO C, because there is no comma after
1646 the string:
1647
1648 @smallexample
1649 debug ("A message")
1650 @end smallexample
1651
1652 GNU CPP permits you to completely omit the variable arguments in this
1653 way. In the above examples, the compiler would complain, though since
1654 the expansion of the macro still has the extra comma after the format
1655 string.
1656
1657 To help solve this problem, CPP behaves specially for variable arguments
1658 used with the token paste operator, @samp{##}. If instead you write
1659
1660 @smallexample
1661 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1662 @end smallexample
1663
1664 and if the variable arguments are omitted or empty, the @samp{##}
1665 operator causes the preprocessor to remove the comma before it. If you
1666 do provide some variable arguments in your macro invocation, GNU CPP
1667 does not complain about the paste operation and instead places the
1668 variable arguments after the comma. Just like any other pasted macro
1669 argument, these arguments are not macro expanded.
1670
1671 @node Escaped Newlines
1672 @section Slightly Looser Rules for Escaped Newlines
1673 @cindex escaped newlines
1674 @cindex newlines (escaped)
1675
1676 Recently, the preprocessor has relaxed its treatment of escaped
1677 newlines. Previously, the newline had to immediately follow a
1678 backslash. The current implementation allows whitespace in the form
1679 of spaces, horizontal and vertical tabs, and form feeds between the
1680 backslash and the subsequent newline. The preprocessor issues a
1681 warning, but treats it as a valid escaped newline and combines the two
1682 lines to form a single logical line. This works within comments and
1683 tokens, as well as between tokens. Comments are @emph{not} treated as
1684 whitespace for the purposes of this relaxation, since they have not
1685 yet been replaced with spaces.
1686
1687 @node Subscripting
1688 @section Non-Lvalue Arrays May Have Subscripts
1689 @cindex subscripting
1690 @cindex arrays, non-lvalue
1691
1692 @cindex subscripting and function values
1693 In ISO C99, arrays that are not lvalues still decay to pointers, and
1694 may be subscripted, although they may not be modified or used after
1695 the next sequence point and the unary @samp{&} operator may not be
1696 applied to them. As an extension, GCC allows such arrays to be
1697 subscripted in C90 mode, though otherwise they do not decay to
1698 pointers outside C99 mode. For example,
1699 this is valid in GNU C though not valid in C90:
1700
1701 @smallexample
1702 @group
1703 struct foo @{int a[4];@};
1704
1705 struct foo f();
1706
1707 bar (int index)
1708 @{
1709 return f().a[index];
1710 @}
1711 @end group
1712 @end smallexample
1713
1714 @node Pointer Arith
1715 @section Arithmetic on @code{void}- and Function-Pointers
1716 @cindex void pointers, arithmetic
1717 @cindex void, size of pointer to
1718 @cindex function pointers, arithmetic
1719 @cindex function, size of pointer to
1720
1721 In GNU C, addition and subtraction operations are supported on pointers to
1722 @code{void} and on pointers to functions. This is done by treating the
1723 size of a @code{void} or of a function as 1.
1724
1725 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1726 and on function types, and returns 1.
1727
1728 @opindex Wpointer-arith
1729 The option @option{-Wpointer-arith} requests a warning if these extensions
1730 are used.
1731
1732 @node Initializers
1733 @section Non-Constant Initializers
1734 @cindex initializers, non-constant
1735 @cindex non-constant initializers
1736
1737 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1738 automatic variable are not required to be constant expressions in GNU C@.
1739 Here is an example of an initializer with run-time varying elements:
1740
1741 @smallexample
1742 foo (float f, float g)
1743 @{
1744 float beat_freqs[2] = @{ f-g, f+g @};
1745 /* @r{@dots{}} */
1746 @}
1747 @end smallexample
1748
1749 @node Compound Literals
1750 @section Compound Literals
1751 @cindex constructor expressions
1752 @cindex initializations in expressions
1753 @cindex structures, constructor expression
1754 @cindex expressions, constructor
1755 @cindex compound literals
1756 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1757
1758 ISO C99 supports compound literals. A compound literal looks like
1759 a cast containing an initializer. Its value is an object of the
1760 type specified in the cast, containing the elements specified in
1761 the initializer; it is an lvalue. As an extension, GCC supports
1762 compound literals in C90 mode and in C++, though the semantics are
1763 somewhat different in C++.
1764
1765 Usually, the specified type is a structure. Assume that
1766 @code{struct foo} and @code{structure} are declared as shown:
1767
1768 @smallexample
1769 struct foo @{int a; char b[2];@} structure;
1770 @end smallexample
1771
1772 @noindent
1773 Here is an example of constructing a @code{struct foo} with a compound literal:
1774
1775 @smallexample
1776 structure = ((struct foo) @{x + y, 'a', 0@});
1777 @end smallexample
1778
1779 @noindent
1780 This is equivalent to writing the following:
1781
1782 @smallexample
1783 @{
1784 struct foo temp = @{x + y, 'a', 0@};
1785 structure = temp;
1786 @}
1787 @end smallexample
1788
1789 You can also construct an array, though this is dangerous in C++, as
1790 explained below. If all the elements of the compound literal are
1791 (made up of) simple constant expressions, suitable for use in
1792 initializers of objects of static storage duration, then the compound
1793 literal can be coerced to a pointer to its first element and used in
1794 such an initializer, as shown here:
1795
1796 @smallexample
1797 char **foo = (char *[]) @{ "x", "y", "z" @};
1798 @end smallexample
1799
1800 Compound literals for scalar types and union types are
1801 also allowed, but then the compound literal is equivalent
1802 to a cast.
1803
1804 As a GNU extension, GCC allows initialization of objects with static storage
1805 duration by compound literals (which is not possible in ISO C99, because
1806 the initializer is not a constant).
1807 It is handled as if the object is initialized only with the bracket
1808 enclosed list if the types of the compound literal and the object match.
1809 The initializer list of the compound literal must be constant.
1810 If the object being initialized has array type of unknown size, the size is
1811 determined by compound literal size.
1812
1813 @smallexample
1814 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1815 static int y[] = (int []) @{1, 2, 3@};
1816 static int z[] = (int [3]) @{1@};
1817 @end smallexample
1818
1819 @noindent
1820 The above lines are equivalent to the following:
1821 @smallexample
1822 static struct foo x = @{1, 'a', 'b'@};
1823 static int y[] = @{1, 2, 3@};
1824 static int z[] = @{1, 0, 0@};
1825 @end smallexample
1826
1827 In C, a compound literal designates an unnamed object with static or
1828 automatic storage duration. In C++, a compound literal designates a
1829 temporary object, which only lives until the end of its
1830 full-expression. As a result, well-defined C code that takes the
1831 address of a subobject of a compound literal can be undefined in C++.
1832 For instance, if the array compound literal example above appeared
1833 inside a function, any subsequent use of @samp{foo} in C++ has
1834 undefined behavior because the lifetime of the array ends after the
1835 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1836 the conversion of a temporary array to a pointer.
1837
1838 As an optimization, the C++ compiler sometimes gives array compound
1839 literals longer lifetimes: when the array either appears outside a
1840 function or has const-qualified type. If @samp{foo} and its
1841 initializer had elements of @samp{char *const} type rather than
1842 @samp{char *}, or if @samp{foo} were a global variable, the array
1843 would have static storage duration. But it is probably safest just to
1844 avoid the use of array compound literals in code compiled as C++.
1845
1846 @node Designated Inits
1847 @section Designated Initializers
1848 @cindex initializers with labeled elements
1849 @cindex labeled elements in initializers
1850 @cindex case labels in initializers
1851 @cindex designated initializers
1852
1853 Standard C90 requires the elements of an initializer to appear in a fixed
1854 order, the same as the order of the elements in the array or structure
1855 being initialized.
1856
1857 In ISO C99 you can give the elements in any order, specifying the array
1858 indices or structure field names they apply to, and GNU C allows this as
1859 an extension in C90 mode as well. This extension is not
1860 implemented in GNU C++.
1861
1862 To specify an array index, write
1863 @samp{[@var{index}] =} before the element value. For example,
1864
1865 @smallexample
1866 int a[6] = @{ [4] = 29, [2] = 15 @};
1867 @end smallexample
1868
1869 @noindent
1870 is equivalent to
1871
1872 @smallexample
1873 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1874 @end smallexample
1875
1876 @noindent
1877 The index values must be constant expressions, even if the array being
1878 initialized is automatic.
1879
1880 An alternative syntax for this which has been obsolete since GCC 2.5 but
1881 GCC still accepts is to write @samp{[@var{index}]} before the element
1882 value, with no @samp{=}.
1883
1884 To initialize a range of elements to the same value, write
1885 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1886 extension. For example,
1887
1888 @smallexample
1889 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1890 @end smallexample
1891
1892 @noindent
1893 If the value in it has side-effects, the side-effects happen only once,
1894 not for each initialized field by the range initializer.
1895
1896 @noindent
1897 Note that the length of the array is the highest value specified
1898 plus one.
1899
1900 In a structure initializer, specify the name of a field to initialize
1901 with @samp{.@var{fieldname} =} before the element value. For example,
1902 given the following structure,
1903
1904 @smallexample
1905 struct point @{ int x, y; @};
1906 @end smallexample
1907
1908 @noindent
1909 the following initialization
1910
1911 @smallexample
1912 struct point p = @{ .y = yvalue, .x = xvalue @};
1913 @end smallexample
1914
1915 @noindent
1916 is equivalent to
1917
1918 @smallexample
1919 struct point p = @{ xvalue, yvalue @};
1920 @end smallexample
1921
1922 Another syntax which has the same meaning, obsolete since GCC 2.5, is
1923 @samp{@var{fieldname}:}, as shown here:
1924
1925 @smallexample
1926 struct point p = @{ y: yvalue, x: xvalue @};
1927 @end smallexample
1928
1929 @cindex designators
1930 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1931 @dfn{designator}. You can also use a designator (or the obsolete colon
1932 syntax) when initializing a union, to specify which element of the union
1933 should be used. For example,
1934
1935 @smallexample
1936 union foo @{ int i; double d; @};
1937
1938 union foo f = @{ .d = 4 @};
1939 @end smallexample
1940
1941 @noindent
1942 converts 4 to a @code{double} to store it in the union using
1943 the second element. By contrast, casting 4 to type @code{union foo}
1944 stores it into the union as the integer @code{i}, since it is
1945 an integer. (@xref{Cast to Union}.)
1946
1947 You can combine this technique of naming elements with ordinary C
1948 initialization of successive elements. Each initializer element that
1949 does not have a designator applies to the next consecutive element of the
1950 array or structure. For example,
1951
1952 @smallexample
1953 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1954 @end smallexample
1955
1956 @noindent
1957 is equivalent to
1958
1959 @smallexample
1960 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1961 @end smallexample
1962
1963 Labeling the elements of an array initializer is especially useful
1964 when the indices are characters or belong to an @code{enum} type.
1965 For example:
1966
1967 @smallexample
1968 int whitespace[256]
1969 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1970 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1971 @end smallexample
1972
1973 @cindex designator lists
1974 You can also write a series of @samp{.@var{fieldname}} and
1975 @samp{[@var{index}]} designators before an @samp{=} to specify a
1976 nested subobject to initialize; the list is taken relative to the
1977 subobject corresponding to the closest surrounding brace pair. For
1978 example, with the @samp{struct point} declaration above:
1979
1980 @smallexample
1981 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1982 @end smallexample
1983
1984 @noindent
1985 If the same field is initialized multiple times, it has the value from
1986 the last initialization. If any such overridden initialization has
1987 side-effect, it is unspecified whether the side-effect happens or not.
1988 Currently, GCC discards them and issues a warning.
1989
1990 @node Case Ranges
1991 @section Case Ranges
1992 @cindex case ranges
1993 @cindex ranges in case statements
1994
1995 You can specify a range of consecutive values in a single @code{case} label,
1996 like this:
1997
1998 @smallexample
1999 case @var{low} ... @var{high}:
2000 @end smallexample
2001
2002 @noindent
2003 This has the same effect as the proper number of individual @code{case}
2004 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2005
2006 This feature is especially useful for ranges of ASCII character codes:
2007
2008 @smallexample
2009 case 'A' ... 'Z':
2010 @end smallexample
2011
2012 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2013 it may be parsed wrong when you use it with integer values. For example,
2014 write this:
2015
2016 @smallexample
2017 case 1 ... 5:
2018 @end smallexample
2019
2020 @noindent
2021 rather than this:
2022
2023 @smallexample
2024 case 1...5:
2025 @end smallexample
2026
2027 @node Cast to Union
2028 @section Cast to a Union Type
2029 @cindex cast to a union
2030 @cindex union, casting to a
2031
2032 A cast to union type is similar to other casts, except that the type
2033 specified is a union type. You can specify the type either with
2034 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2035 a constructor though, not a cast, and hence does not yield an lvalue like
2036 normal casts. (@xref{Compound Literals}.)
2037
2038 The types that may be cast to the union type are those of the members
2039 of the union. Thus, given the following union and variables:
2040
2041 @smallexample
2042 union foo @{ int i; double d; @};
2043 int x;
2044 double y;
2045 @end smallexample
2046
2047 @noindent
2048 both @code{x} and @code{y} can be cast to type @code{union foo}.
2049
2050 Using the cast as the right-hand side of an assignment to a variable of
2051 union type is equivalent to storing in a member of the union:
2052
2053 @smallexample
2054 union foo u;
2055 /* @r{@dots{}} */
2056 u = (union foo) x @equiv{} u.i = x
2057 u = (union foo) y @equiv{} u.d = y
2058 @end smallexample
2059
2060 You can also use the union cast as a function argument:
2061
2062 @smallexample
2063 void hack (union foo);
2064 /* @r{@dots{}} */
2065 hack ((union foo) x);
2066 @end smallexample
2067
2068 @node Mixed Declarations
2069 @section Mixed Declarations and Code
2070 @cindex mixed declarations and code
2071 @cindex declarations, mixed with code
2072 @cindex code, mixed with declarations
2073
2074 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2075 within compound statements. As an extension, GCC also allows this in
2076 C90 mode. For example, you could do:
2077
2078 @smallexample
2079 int i;
2080 /* @r{@dots{}} */
2081 i++;
2082 int j = i + 2;
2083 @end smallexample
2084
2085 Each identifier is visible from where it is declared until the end of
2086 the enclosing block.
2087
2088 @node Function Attributes
2089 @section Declaring Attributes of Functions
2090 @cindex function attributes
2091 @cindex declaring attributes of functions
2092 @cindex functions that never return
2093 @cindex functions that return more than once
2094 @cindex functions that have no side effects
2095 @cindex functions in arbitrary sections
2096 @cindex functions that behave like malloc
2097 @cindex @code{volatile} applied to function
2098 @cindex @code{const} applied to function
2099 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2100 @cindex functions with non-null pointer arguments
2101 @cindex functions that are passed arguments in registers on the 386
2102 @cindex functions that pop the argument stack on the 386
2103 @cindex functions that do not pop the argument stack on the 386
2104 @cindex functions that have different compilation options on the 386
2105 @cindex functions that have different optimization options
2106 @cindex functions that are dynamically resolved
2107
2108 In GNU C, you declare certain things about functions called in your program
2109 which help the compiler optimize function calls and check your code more
2110 carefully.
2111
2112 The keyword @code{__attribute__} allows you to specify special
2113 attributes when making a declaration. This keyword is followed by an
2114 attribute specification inside double parentheses. The following
2115 attributes are currently defined for functions on all targets:
2116 @code{aligned}, @code{alloc_size}, @code{noreturn},
2117 @code{returns_twice}, @code{noinline}, @code{noclone},
2118 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2119 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2120 @code{no_instrument_function}, @code{no_split_stack},
2121 @code{section}, @code{constructor},
2122 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2123 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2124 @code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
2125 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2126 @code{error} and @code{warning}. Several other attributes are defined
2127 for functions on particular target systems. Other attributes,
2128 including @code{section} are supported for variables declarations
2129 (@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}).
2130
2131 GCC plugins may provide their own attributes.
2132
2133 You may also specify attributes with @samp{__} preceding and following
2134 each keyword. This allows you to use them in header files without
2135 being concerned about a possible macro of the same name. For example,
2136 you may use @code{__noreturn__} instead of @code{noreturn}.
2137
2138 @xref{Attribute Syntax}, for details of the exact syntax for using
2139 attributes.
2140
2141 @table @code
2142 @c Keep this table alphabetized by attribute name. Treat _ as space.
2143
2144 @item alias ("@var{target}")
2145 @cindex @code{alias} attribute
2146 The @code{alias} attribute causes the declaration to be emitted as an
2147 alias for another symbol, which must be specified. For instance,
2148
2149 @smallexample
2150 void __f () @{ /* @r{Do something.} */; @}
2151 void f () __attribute__ ((weak, alias ("__f")));
2152 @end smallexample
2153
2154 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2155 mangled name for the target must be used. It is an error if @samp{__f}
2156 is not defined in the same translation unit.
2157
2158 Not all target machines support this attribute.
2159
2160 @item aligned (@var{alignment})
2161 @cindex @code{aligned} attribute
2162 This attribute specifies a minimum alignment for the function,
2163 measured in bytes.
2164
2165 You cannot use this attribute to decrease the alignment of a function,
2166 only to increase it. However, when you explicitly specify a function
2167 alignment this overrides the effect of the
2168 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2169 function.
2170
2171 Note that the effectiveness of @code{aligned} attributes may be
2172 limited by inherent limitations in your linker. On many systems, the
2173 linker is only able to arrange for functions to be aligned up to a
2174 certain maximum alignment. (For some linkers, the maximum supported
2175 alignment may be very very small.) See your linker documentation for
2176 further information.
2177
2178 The @code{aligned} attribute can also be used for variables and fields
2179 (@pxref{Variable Attributes}.)
2180
2181 @item alloc_size
2182 @cindex @code{alloc_size} attribute
2183 The @code{alloc_size} attribute is used to tell the compiler that the
2184 function return value points to memory, where the size is given by
2185 one or two of the functions parameters. GCC uses this
2186 information to improve the correctness of @code{__builtin_object_size}.
2187
2188 The function parameter(s) denoting the allocated size are specified by
2189 one or two integer arguments supplied to the attribute. The allocated size
2190 is either the value of the single function argument specified or the product
2191 of the two function arguments specified. Argument numbering starts at
2192 one.
2193
2194 For instance,
2195
2196 @smallexample
2197 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2198 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2199 @end smallexample
2200
2201 declares that @code{my_calloc} returns memory of the size given by
2202 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2203 of the size given by parameter 2.
2204
2205 @item always_inline
2206 @cindex @code{always_inline} function attribute
2207 Generally, functions are not inlined unless optimization is specified.
2208 For functions declared inline, this attribute inlines the function even
2209 if no optimization level is specified.
2210
2211 @item gnu_inline
2212 @cindex @code{gnu_inline} function attribute
2213 This attribute should be used with a function which is also declared
2214 with the @code{inline} keyword. It directs GCC to treat the function
2215 as if it were defined in gnu90 mode even when compiling in C99 or
2216 gnu99 mode.
2217
2218 If the function is declared @code{extern}, then this definition of the
2219 function is used only for inlining. In no case is the function
2220 compiled as a standalone function, not even if you take its address
2221 explicitly. Such an address becomes an external reference, as if you
2222 had only declared the function, and had not defined it. This has
2223 almost the effect of a macro. The way to use this is to put a
2224 function definition in a header file with this attribute, and put
2225 another copy of the function, without @code{extern}, in a library
2226 file. The definition in the header file causes most calls to the
2227 function to be inlined. If any uses of the function remain, they
2228 refer to the single copy in the library. Note that the two
2229 definitions of the functions need not be precisely the same, although
2230 if they do not have the same effect your program may behave oddly.
2231
2232 In C, if the function is neither @code{extern} nor @code{static}, then
2233 the function is compiled as a standalone function, as well as being
2234 inlined where possible.
2235
2236 This is how GCC traditionally handled functions declared
2237 @code{inline}. Since ISO C99 specifies a different semantics for
2238 @code{inline}, this function attribute is provided as a transition
2239 measure and as a useful feature in its own right. This attribute is
2240 available in GCC 4.1.3 and later. It is available if either of the
2241 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2242 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2243 Function is As Fast As a Macro}.
2244
2245 In C++, this attribute does not depend on @code{extern} in any way,
2246 but it still requires the @code{inline} keyword to enable its special
2247 behavior.
2248
2249 @item artificial
2250 @cindex @code{artificial} function attribute
2251 This attribute is useful for small inline wrappers which if possible
2252 should appear during debugging as a unit. Depending on the debug
2253 info format it either means marking the function as artificial
2254 or using the caller location for all instructions within the inlined
2255 body.
2256
2257 @item bank_switch
2258 @cindex interrupt handler functions
2259 When added to an interrupt handler with the M32C port, causes the
2260 prologue and epilogue to use bank switching to preserve the registers
2261 rather than saving them on the stack.
2262
2263 @item flatten
2264 @cindex @code{flatten} function attribute
2265 Generally, inlining into a function is limited. For a function marked with
2266 this attribute, every call inside this function is inlined, if possible.
2267 Whether the function itself is considered for inlining depends on its size and
2268 the current inlining parameters.
2269
2270 @item error ("@var{message}")
2271 @cindex @code{error} function attribute
2272 If this attribute is used on a function declaration and a call to such a function
2273 is not eliminated through dead code elimination or other optimizations, an error
2274 which includes @var{message} is diagnosed. This is useful
2275 for compile time checking, especially together with @code{__builtin_constant_p}
2276 and inline functions where checking the inline function arguments is not
2277 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2278 While it is possible to leave the function undefined and thus invoke
2279 a link failure, when using this attribute the problem is diagnosed
2280 earlier and with exact location of the call even in presence of inline
2281 functions or when not emitting debugging information.
2282
2283 @item warning ("@var{message}")
2284 @cindex @code{warning} function attribute
2285 If this attribute is used on a function declaration and a call to such a function
2286 is not eliminated through dead code elimination or other optimizations, a warning
2287 which includes @var{message} is diagnosed. This is useful
2288 for compile time checking, especially together with @code{__builtin_constant_p}
2289 and inline functions. While it is possible to define the function with
2290 a message in @code{.gnu.warning*} section, when using this attribute the problem
2291 is diagnosed earlier and with exact location of the call even in presence
2292 of inline functions or when not emitting debugging information.
2293
2294 @item cdecl
2295 @cindex functions that do pop the argument stack on the 386
2296 @opindex mrtd
2297 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2298 assume that the calling function pops off the stack space used to
2299 pass arguments. This is
2300 useful to override the effects of the @option{-mrtd} switch.
2301
2302 @item const
2303 @cindex @code{const} function attribute
2304 Many functions do not examine any values except their arguments, and
2305 have no effects except the return value. Basically this is just slightly
2306 more strict class than the @code{pure} attribute below, since function is not
2307 allowed to read global memory.
2308
2309 @cindex pointer arguments
2310 Note that a function that has pointer arguments and examines the data
2311 pointed to must @emph{not} be declared @code{const}. Likewise, a
2312 function that calls a non-@code{const} function usually must not be
2313 @code{const}. It does not make sense for a @code{const} function to
2314 return @code{void}.
2315
2316 The attribute @code{const} is not implemented in GCC versions earlier
2317 than 2.5. An alternative way to declare that a function has no side
2318 effects, which works in the current version and in some older versions,
2319 is as follows:
2320
2321 @smallexample
2322 typedef int intfn ();
2323
2324 extern const intfn square;
2325 @end smallexample
2326
2327 This approach does not work in GNU C++ from 2.6.0 on, since the language
2328 specifies that the @samp{const} must be attached to the return value.
2329
2330 @item constructor
2331 @itemx destructor
2332 @itemx constructor (@var{priority})
2333 @itemx destructor (@var{priority})
2334 @cindex @code{constructor} function attribute
2335 @cindex @code{destructor} function attribute
2336 The @code{constructor} attribute causes the function to be called
2337 automatically before execution enters @code{main ()}. Similarly, the
2338 @code{destructor} attribute causes the function to be called
2339 automatically after @code{main ()} completes or @code{exit ()} is
2340 called. Functions with these attributes are useful for
2341 initializing data that is used implicitly during the execution of
2342 the program.
2343
2344 You may provide an optional integer priority to control the order in
2345 which constructor and destructor functions are run. A constructor
2346 with a smaller priority number runs before a constructor with a larger
2347 priority number; the opposite relationship holds for destructors. So,
2348 if you have a constructor that allocates a resource and a destructor
2349 that deallocates the same resource, both functions typically have the
2350 same priority. The priorities for constructor and destructor
2351 functions are the same as those specified for namespace-scope C++
2352 objects (@pxref{C++ Attributes}).
2353
2354 These attributes are not currently implemented for Objective-C@.
2355
2356 @item deprecated
2357 @itemx deprecated (@var{msg})
2358 @cindex @code{deprecated} attribute.
2359 The @code{deprecated} attribute results in a warning if the function
2360 is used anywhere in the source file. This is useful when identifying
2361 functions that are expected to be removed in a future version of a
2362 program. The warning also includes the location of the declaration
2363 of the deprecated function, to enable users to easily find further
2364 information about why the function is deprecated, or what they should
2365 do instead. Note that the warnings only occurs for uses:
2366
2367 @smallexample
2368 int old_fn () __attribute__ ((deprecated));
2369 int old_fn ();
2370 int (*fn_ptr)() = old_fn;
2371 @end smallexample
2372
2373 @noindent
2374 results in a warning on line 3 but not line 2. The optional @var{msg}
2375 argument, which must be a string, is printed in the warning if
2376 present.
2377
2378 The @code{deprecated} attribute can also be used for variables and
2379 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2380
2381 @item disinterrupt
2382 @cindex @code{disinterrupt} attribute
2383 On Epiphany and MeP targets, this attribute causes the compiler to emit
2384 instructions to disable interrupts for the duration of the given
2385 function.
2386
2387 @item dllexport
2388 @cindex @code{__declspec(dllexport)}
2389 On Microsoft Windows targets and Symbian OS targets the
2390 @code{dllexport} attribute causes the compiler to provide a global
2391 pointer to a pointer in a DLL, so that it can be referenced with the
2392 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2393 name is formed by combining @code{_imp__} and the function or variable
2394 name.
2395
2396 You can use @code{__declspec(dllexport)} as a synonym for
2397 @code{__attribute__ ((dllexport))} for compatibility with other
2398 compilers.
2399
2400 On systems that support the @code{visibility} attribute, this
2401 attribute also implies ``default'' visibility. It is an error to
2402 explicitly specify any other visibility.
2403
2404 In previous versions of GCC, the @code{dllexport} attribute was ignored
2405 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2406 had been used. The default behaviour now is to emit all dllexported
2407 inline functions; however, this can cause object file-size bloat, in
2408 which case the old behaviour can be restored by using
2409 @option{-fno-keep-inline-dllexport}.
2410
2411 The attribute is also ignored for undefined symbols.
2412
2413 When applied to C++ classes, the attribute marks defined non-inlined
2414 member functions and static data members as exports. Static consts
2415 initialized in-class are not marked unless they are also defined
2416 out-of-class.
2417
2418 For Microsoft Windows targets there are alternative methods for
2419 including the symbol in the DLL's export table such as using a
2420 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2421 the @option{--export-all} linker flag.
2422
2423 @item dllimport
2424 @cindex @code{__declspec(dllimport)}
2425 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2426 attribute causes the compiler to reference a function or variable via
2427 a global pointer to a pointer that is set up by the DLL exporting the
2428 symbol. The attribute implies @code{extern}. On Microsoft Windows
2429 targets, the pointer name is formed by combining @code{_imp__} and the
2430 function or variable name.
2431
2432 You can use @code{__declspec(dllimport)} as a synonym for
2433 @code{__attribute__ ((dllimport))} for compatibility with other
2434 compilers.
2435
2436 On systems that support the @code{visibility} attribute, this
2437 attribute also implies ``default'' visibility. It is an error to
2438 explicitly specify any other visibility.
2439
2440 Currently, the attribute is ignored for inlined functions. If the
2441 attribute is applied to a symbol @emph{definition}, an error is reported.
2442 If a symbol previously declared @code{dllimport} is later defined, the
2443 attribute is ignored in subsequent references, and a warning is emitted.
2444 The attribute is also overridden by a subsequent declaration as
2445 @code{dllexport}.
2446
2447 When applied to C++ classes, the attribute marks non-inlined
2448 member functions and static data members as imports. However, the
2449 attribute is ignored for virtual methods to allow creation of vtables
2450 using thunks.
2451
2452 On the SH Symbian OS target the @code{dllimport} attribute also has
2453 another affect---it can cause the vtable and run-time type information
2454 for a class to be exported. This happens when the class has a
2455 dllimport'ed constructor or a non-inline, non-pure virtual function
2456 and, for either of those two conditions, the class also has an inline
2457 constructor or destructor and has a key function that is defined in
2458 the current translation unit.
2459
2460 For Microsoft Windows based targets the use of the @code{dllimport}
2461 attribute on functions is not necessary, but provides a small
2462 performance benefit by eliminating a thunk in the DLL@. The use of the
2463 @code{dllimport} attribute on imported variables was required on older
2464 versions of the GNU linker, but can now be avoided by passing the
2465 @option{--enable-auto-import} switch to the GNU linker. As with
2466 functions, using the attribute for a variable eliminates a thunk in
2467 the DLL@.
2468
2469 One drawback to using this attribute is that a pointer to a
2470 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2471 address. However, a pointer to a @emph{function} with the
2472 @code{dllimport} attribute can be used as a constant initializer; in
2473 this case, the address of a stub function in the import lib is
2474 referenced. On Microsoft Windows targets, the attribute can be disabled
2475 for functions by setting the @option{-mnop-fun-dllimport} flag.
2476
2477 @item eightbit_data
2478 @cindex eight bit data on the H8/300, H8/300H, and H8S
2479 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2480 variable should be placed into the eight bit data section.
2481 The compiler generates more efficient code for certain operations
2482 on data in the eight bit data area. Note the eight bit data area is limited to
2483 256 bytes of data.
2484
2485 You must use GAS and GLD from GNU binutils version 2.7 or later for
2486 this attribute to work correctly.
2487
2488 @item exception_handler
2489 @cindex exception handler functions on the Blackfin processor
2490 Use this attribute on the Blackfin to indicate that the specified function
2491 is an exception handler. The compiler generates function entry and
2492 exit sequences suitable for use in an exception handler when this
2493 attribute is present.
2494
2495 @item externally_visible
2496 @cindex @code{externally_visible} attribute.
2497 This attribute, attached to a global variable or function, nullifies
2498 the effect of the @option{-fwhole-program} command-line option, so the
2499 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.
2500
2501 @item far
2502 @cindex functions which handle memory bank switching
2503 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2504 use a calling convention that takes care of switching memory banks when
2505 entering and leaving a function. This calling convention is also the
2506 default when using the @option{-mlong-calls} option.
2507
2508 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2509 to call and return from a function.
2510
2511 On 68HC11 the compiler generates a sequence of instructions
2512 to invoke a board-specific routine to switch the memory bank and call the
2513 real function. The board-specific routine simulates a @code{call}.
2514 At the end of a function, it jumps to a board-specific routine
2515 instead of using @code{rts}. The board-specific return routine simulates
2516 the @code{rtc}.
2517
2518 On MeP targets this causes the compiler to use a calling convention
2519 which assumes the called function is too far away for the built-in
2520 addressing modes.
2521
2522 @item fast_interrupt
2523 @cindex interrupt handler functions
2524 Use this attribute on the M32C and RX ports to indicate that the specified
2525 function is a fast interrupt handler. This is just like the
2526 @code{interrupt} attribute, except that @code{freit} is used to return
2527 instead of @code{reit}.
2528
2529 @item fastcall
2530 @cindex functions that pop the argument stack on the 386
2531 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2532 pass the first argument (if of integral type) in the register ECX and
2533 the second argument (if of integral type) in the register EDX@. Subsequent
2534 and other typed arguments are passed on the stack. The called function
2535 pops the arguments off the stack. If the number of arguments is variable all
2536 arguments are pushed on the stack.
2537
2538 @item thiscall
2539 @cindex functions that pop the argument stack on the 386
2540 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2541 pass the first argument (if of integral type) in the register ECX.
2542 Subsequent and other typed arguments are passed on the stack. The called
2543 function pops the arguments off the stack.
2544 If the number of arguments is variable all arguments are pushed on the
2545 stack.
2546 The @code{thiscall} attribute is intended for C++ non-static member functions.
2547 As gcc extension this calling convention can be used for C-functions
2548 and for static member methods.
2549
2550 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2551 @cindex @code{format} function attribute
2552 @opindex Wformat
2553 The @code{format} attribute specifies that a function takes @code{printf},
2554 @code{scanf}, @code{strftime} or @code{strfmon} style arguments which
2555 should be type-checked against a format string. For example, the
2556 declaration:
2557
2558 @smallexample
2559 extern int
2560 my_printf (void *my_object, const char *my_format, ...)
2561 __attribute__ ((format (printf, 2, 3)));
2562 @end smallexample
2563
2564 @noindent
2565 causes the compiler to check the arguments in calls to @code{my_printf}
2566 for consistency with the @code{printf} style format string argument
2567 @code{my_format}.
2568
2569 The parameter @var{archetype} determines how the format string is
2570 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2571 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2572 @code{strfmon}. (You can also use @code{__printf__},
2573 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2574 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2575 @code{ms_strftime} are also present.
2576 @var{archtype} values such as @code{printf} refer to the formats accepted
2577 by the system's C run-time library, while @code{gnu_} values always refer
2578 to the formats accepted by the GNU C Library. On Microsoft Windows
2579 targets, @code{ms_} values refer to the formats accepted by the
2580 @file{msvcrt.dll} library.
2581 The parameter @var{string-index}
2582 specifies which argument is the format string argument (starting
2583 from 1), while @var{first-to-check} is the number of the first
2584 argument to check against the format string. For functions
2585 where the arguments are not available to be checked (such as
2586 @code{vprintf}), specify the third parameter as zero. In this case the
2587 compiler only checks the format string for consistency. For
2588 @code{strftime} formats, the third parameter is required to be zero.
2589 Since non-static C++ methods have an implicit @code{this} argument, the
2590 arguments of such methods should be counted from two, not one, when
2591 giving values for @var{string-index} and @var{first-to-check}.
2592
2593 In the example above, the format string (@code{my_format}) is the second
2594 argument of the function @code{my_print}, and the arguments to check
2595 start with the third argument, so the correct parameters for the format
2596 attribute are 2 and 3.
2597
2598 @opindex ffreestanding
2599 @opindex fno-builtin
2600 The @code{format} attribute allows you to identify your own functions
2601 which take format strings as arguments, so that GCC can check the
2602 calls to these functions for errors. The compiler always (unless
2603 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2604 for the standard library functions @code{printf}, @code{fprintf},
2605 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2606 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2607 warnings are requested (using @option{-Wformat}), so there is no need to
2608 modify the header file @file{stdio.h}. In C99 mode, the functions
2609 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2610 @code{vsscanf} are also checked. Except in strictly conforming C
2611 standard modes, the X/Open function @code{strfmon} is also checked as
2612 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2613 @xref{C Dialect Options,,Options Controlling C Dialect}.
2614
2615 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2616 recognized in the same context. Declarations including these format attributes
2617 are parsed for correct syntax, however the result of checking of such format
2618 strings is not yet defined, and is not carried out by this version of the
2619 compiler.
2620
2621 The target may also provide additional types of format checks.
2622 @xref{Target Format Checks,,Format Checks Specific to Particular
2623 Target Machines}.
2624
2625 @item format_arg (@var{string-index})
2626 @cindex @code{format_arg} function attribute
2627 @opindex Wformat-nonliteral
2628 The @code{format_arg} attribute specifies that a function takes a format
2629 string for a @code{printf}, @code{scanf}, @code{strftime} or
2630 @code{strfmon} style function and modifies it (for example, to translate
2631 it into another language), so the result can be passed to a
2632 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2633 function (with the remaining arguments to the format function the same
2634 as they would have been for the unmodified string). For example, the
2635 declaration:
2636
2637 @smallexample
2638 extern char *
2639 my_dgettext (char *my_domain, const char *my_format)
2640 __attribute__ ((format_arg (2)));
2641 @end smallexample
2642
2643 @noindent
2644 causes the compiler to check the arguments in calls to a @code{printf},
2645 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2646 format string argument is a call to the @code{my_dgettext} function, for
2647 consistency with the format string argument @code{my_format}. If the
2648 @code{format_arg} attribute had not been specified, all the compiler
2649 could tell in such calls to format functions would be that the format
2650 string argument is not constant; this would generate a warning when
2651 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2652 without the attribute.
2653
2654 The parameter @var{string-index} specifies which argument is the format
2655 string argument (starting from one). Since non-static C++ methods have
2656 an implicit @code{this} argument, the arguments of such methods should
2657 be counted from two.
2658
2659 The @code{format-arg} attribute allows you to identify your own
2660 functions which modify format strings, so that GCC can check the
2661 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2662 type function whose operands are a call to one of your own function.
2663 The compiler always treats @code{gettext}, @code{dgettext}, and
2664 @code{dcgettext} in this manner except when strict ISO C support is
2665 requested by @option{-ansi} or an appropriate @option{-std} option, or
2666 @option{-ffreestanding} or @option{-fno-builtin}
2667 is used. @xref{C Dialect Options,,Options
2668 Controlling C Dialect}.
2669
2670 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2671 @code{NSString} reference for compatibility with the @code{format} attribute
2672 above.
2673
2674 The target may also allow additional types in @code{format-arg} attributes.
2675 @xref{Target Format Checks,,Format Checks Specific to Particular
2676 Target Machines}.
2677
2678 @item function_vector
2679 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2680 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2681 function should be called through the function vector. Calling a
2682 function through the function vector reduces code size, however;
2683 the function vector has a limited size (maximum 128 entries on the H8/300
2684 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2685
2686 On SH2A targets, this attribute declares a function to be called using the
2687 TBR relative addressing mode. The argument to this attribute is the entry
2688 number of the same function in a vector table containing all the TBR
2689 relative addressable functions. For correct operation the TBR must be setup
2690 accordingly to point to the start of the vector table before any functions with
2691 this attribute are invoked. Usually a good place to do the initialization is
2692 the startup routine. The TBR relative vector table can have at max 256 function
2693 entries. The jumps to these functions are generated using a SH2A specific,
2694 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2695 from GNU binutils version 2.7 or later for this attribute to work correctly.
2696
2697 Please refer the example of M16C target, to see the use of this
2698 attribute while declaring a function,
2699
2700 In an application, for a function being called once, this attribute
2701 saves at least 8 bytes of code; and if other successive calls are being
2702 made to the same function, it saves 2 bytes of code per each of these
2703 calls.
2704
2705 On M16C/M32C targets, the @code{function_vector} attribute declares a
2706 special page subroutine call function. Use of this attribute reduces
2707 the code size by 2 bytes for each call generated to the
2708 subroutine. The argument to the attribute is the vector number entry
2709 from the special page vector table which contains the 16 low-order
2710 bits of the subroutine's entry address. Each vector table has special
2711 page number (18 to 255) which are used in @code{jsrs} instruction.
2712 Jump addresses of the routines are generated by adding 0x0F0000 (in
2713 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the 2
2714 byte addresses set in the vector table. Therefore you need to ensure
2715 that all the special page vector routines should get mapped within the
2716 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2717 (for M32C).
2718
2719 In the following example 2 bytes are saved for each call to
2720 function @code{foo}.
2721
2722 @smallexample
2723 void foo (void) __attribute__((function_vector(0x18)));
2724 void foo (void)
2725 @{
2726 @}
2727
2728 void bar (void)
2729 @{
2730 foo();
2731 @}
2732 @end smallexample
2733
2734 If functions are defined in one file and are called in another file,
2735 then be sure to write this declaration in both files.
2736
2737 This attribute is ignored for R8C target.
2738
2739 @item ifunc ("@var{resolver}")
2740 @cindex @code{ifunc} attribute
2741 The @code{ifunc} attribute is used to mark a function as an indirect
2742 function using the STT_GNU_IFUNC symbol type extension to the ELF
2743 standard. This allows the resolution of the symbol value to be
2744 determined dynamically at load time, and an optimized version of the
2745 routine can be selected for the particular processor or other system
2746 characteristics determined then. To use this attribute, first define
2747 the implementation functions available, and a resolver function that
2748 returns a pointer to the selected implementation function. The
2749 implementation functions' declarations must match the API of the
2750 function being implemented, the resolver's declaration is be a
2751 function returning pointer to void function returning void:
2752
2753 @smallexample
2754 void *my_memcpy (void *dst, const void *src, size_t len)
2755 @{
2756 @dots{}
2757 @}
2758
2759 static void (*resolve_memcpy (void)) (void)
2760 @{
2761 return my_memcpy; // we'll just always select this routine
2762 @}
2763 @end smallexample
2764
2765 The exported header file declaring the function the user calls would
2766 contain:
2767
2768 @smallexample
2769 extern void *memcpy (void *, const void *, size_t);
2770 @end smallexample
2771
2772 allowing the user to call this as a regular function, unaware of the
2773 implementation. Finally, the indirect function needs to be defined in
2774 the same translation unit as the resolver function:
2775
2776 @smallexample
2777 void *memcpy (void *, const void *, size_t)
2778 __attribute__ ((ifunc ("resolve_memcpy")));
2779 @end smallexample
2780
2781 Indirect functions cannot be weak, and require a recent binutils (at
2782 least version 2.20.1), and GNU C library (at least version 2.11.1).
2783
2784 @item interrupt
2785 @cindex interrupt handler functions
2786 Use this attribute on the ARM, AVR, CR16, Epiphany, M32C, M32R/D, m68k, MeP, MIPS,
2787 RL78, RX and Xstormy16 ports to indicate that the specified function is an
2788 interrupt handler. The compiler generates function entry and exit
2789 sequences suitable for use in an interrupt handler when this attribute
2790 is present. With Epiphany targets it may also generate a special section with
2791 code to initialize the interrupt vector table.
2792
2793 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2794 and SH processors can be specified via the @code{interrupt_handler} attribute.
2795
2796 Note, on the AVR, the hardware globally disables interrupts when an
2797 interrupt is executed. The first instruction of an interrupt handler
2798 declared with this attribute is a @code{SEI} instruction to
2799 re-enable interrupts. See also the @code{signal} function attribute
2800 that does not insert a @code{SEI} instuction. If both @code{signal} and
2801 @code{interrupt} are specified for the same function, @code{signal}
2802 is silently ignored.
2803
2804 Note, for the ARM, you can specify the kind of interrupt to be handled by
2805 adding an optional parameter to the interrupt attribute like this:
2806
2807 @smallexample
2808 void f () __attribute__ ((interrupt ("IRQ")));
2809 @end smallexample
2810
2811 Permissible values for this parameter are: IRQ, FIQ, SWI, ABORT and UNDEF@.
2812
2813 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2814 may be called with a word aligned stack pointer.
2815
2816 On Epiphany targets one or more optional parameters can be added like this:
2817
2818 @smallexample
2819 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2820 @end smallexample
2821
2822 Permissible values for these parameters are: @w{@code{reset}},
2823 @w{@code{software_exception}}, @w{@code{page_miss}},
2824 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2825 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2826 Multiple parameters indicate that multiple entries in the interrupt
2827 vector table should be initialized for this function, i.e. for each
2828 parameter @w{@var{name}}, a jump to the function is emitted in
2829 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2830 entirely, in which case no interrupt vector table entry is provided.
2831
2832 Note, on Epiphany targets, interrupts are enabled inside the function
2833 unless the @code{disinterrupt} attribute is also specified.
2834
2835 On Epiphany targets, you can also use the following attribute to
2836 modify the behavior of an interrupt handler:
2837 @table @code
2838 @item forwarder_section
2839 @cindex @code{forwarder_section} attribute
2840 The interrupt handler may be in external memory which cannot be
2841 reached by a branch instruction, so generate a local memory trampoline
2842 to transfer control. The single parameter identifies the section where
2843 the trampoline is placed.
2844 @end table
2845
2846 The following examples are all valid uses of these attributes on
2847 Epiphany targets:
2848 @smallexample
2849 void __attribute__ ((interrupt)) universal_handler ();
2850 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2851 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2852 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2853 fast_timer_handler ();
2854 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2855 external_dma_handler ();
2856 @end smallexample
2857
2858 On MIPS targets, you can use the following attributes to modify the behavior
2859 of an interrupt handler:
2860 @table @code
2861 @item use_shadow_register_set
2862 @cindex @code{use_shadow_register_set} attribute
2863 Assume that the handler uses a shadow register set, instead of
2864 the main general-purpose registers.
2865
2866 @item keep_interrupts_masked
2867 @cindex @code{keep_interrupts_masked} attribute
2868 Keep interrupts masked for the whole function. Without this attribute,
2869 GCC tries to reenable interrupts for as much of the function as it can.
2870
2871 @item use_debug_exception_return
2872 @cindex @code{use_debug_exception_return} attribute
2873 Return using the @code{deret} instruction. Interrupt handlers that don't
2874 have this attribute return using @code{eret} instead.
2875 @end table
2876
2877 You can use any combination of these attributes, as shown below:
2878 @smallexample
2879 void __attribute__ ((interrupt)) v0 ();
2880 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2881 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2882 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2883 void __attribute__ ((interrupt, use_shadow_register_set,
2884 keep_interrupts_masked)) v4 ();
2885 void __attribute__ ((interrupt, use_shadow_register_set,
2886 use_debug_exception_return)) v5 ();
2887 void __attribute__ ((interrupt, keep_interrupts_masked,
2888 use_debug_exception_return)) v6 ();
2889 void __attribute__ ((interrupt, use_shadow_register_set,
2890 keep_interrupts_masked,
2891 use_debug_exception_return)) v7 ();
2892 @end smallexample
2893
2894 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
2895 handlers intended to be used with the @code{BRK} opcode (i.e. those
2896 that must end with @code{RETB} instead of @code{RETI}).
2897
2898 @item interrupt_handler
2899 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2900 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2901 indicate that the specified function is an interrupt handler. The compiler
2902 generates function entry and exit sequences suitable for use in an
2903 interrupt handler when this attribute is present.
2904
2905 @item interrupt_thread
2906 @cindex interrupt thread functions on fido
2907 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2908 that the specified function is an interrupt handler that is designed
2909 to run as a thread. The compiler omits generate prologue/epilogue
2910 sequences and replaces the return instruction with a @code{sleep}
2911 instruction. This attribute is available only on fido.
2912
2913 @item isr
2914 @cindex interrupt service routines on ARM
2915 Use this attribute on ARM to write Interrupt Service Routines. This is an
2916 alias to the @code{interrupt} attribute above.
2917
2918 @item kspisusp
2919 @cindex User stack pointer in interrupts on the Blackfin
2920 When used together with @code{interrupt_handler}, @code{exception_handler}
2921 or @code{nmi_handler}, code is generated to load the stack pointer
2922 from the USP register in the function prologue.
2923
2924 @item l1_text
2925 @cindex @code{l1_text} function attribute
2926 This attribute specifies a function to be placed into L1 Instruction
2927 SRAM@. The function is put into a specific section named @code{.l1.text}.
2928 With @option{-mfdpic}, function calls with a such function as the callee
2929 or caller uses inlined PLT.
2930
2931 @item l2
2932 @cindex @code{l2} function attribute
2933 On the Blackfin, this attribute specifies a function to be placed into L2
2934 SRAM. The function is put into a specific section named
2935 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
2936 an inlined PLT.
2937
2938 @item leaf
2939 @cindex @code{leaf} function attribute
2940 Calls to external functions with this attribute must return to the current
2941 compilation unit only by return or by exception handling. In particular, leaf
2942 functions are not allowed to call callback function passed to it from the current
2943 compilation unit or directly call functions exported by the unit or longjmp
2944 into the unit. Leaf function might still call functions from other compilation
2945 units and thus they are not necessarily leaf in the sense that they contain no
2946 function calls at all.
2947
2948 The attribute is intended for library functions to improve dataflow analysis.
2949 The compiler takes the hint that any data not escaping the current compilation unit can
2950 not be used or modified by the leaf function. For example, the @code{sin} function
2951 is a leaf function, but @code{qsort} is not.
2952
2953 Note that leaf functions might invoke signals and signal handlers might be
2954 defined in the current compilation unit and use static variables. The only
2955 compliant way to write such a signal handler is to declare such variables
2956 @code{volatile}.
2957
2958 The attribute has no effect on functions defined within the current compilation
2959 unit. This is to allow easy merging of multiple compilation units into one,
2960 for example, by using the link time optimization. For this reason the
2961 attribute is not allowed on types to annotate indirect calls.
2962
2963 @item long_call/short_call
2964 @cindex indirect calls on ARM
2965 This attribute specifies how a particular function is called on
2966 ARM and Epiphany. Both attributes override the
2967 @option{-mlong-calls} (@pxref{ARM Options})
2968 command-line switch and @code{#pragma long_calls} settings. The
2969 @code{long_call} attribute indicates that the function might be far
2970 away from the call site and require a different (more expensive)
2971 calling sequence. The @code{short_call} attribute always places
2972 the offset to the function from the call site into the @samp{BL}
2973 instruction directly.
2974
2975 @item longcall/shortcall
2976 @cindex functions called via pointer on the RS/6000 and PowerPC
2977 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
2978 indicates that the function might be far away from the call site and
2979 require a different (more expensive) calling sequence. The
2980 @code{shortcall} attribute indicates that the function is always close
2981 enough for the shorter calling sequence to be used. These attributes
2982 override both the @option{-mlongcall} switch and, on the RS/6000 and
2983 PowerPC, the @code{#pragma longcall} setting.
2984
2985 @xref{RS/6000 and PowerPC Options}, for more information on whether long
2986 calls are necessary.
2987
2988 @item long_call/near/far
2989 @cindex indirect calls on MIPS
2990 These attributes specify how a particular function is called on MIPS@.
2991 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
2992 command-line switch. The @code{long_call} and @code{far} attributes are
2993 synonyms, and cause the compiler to always call
2994 the function by first loading its address into a register, and then using
2995 the contents of that register. The @code{near} attribute has the opposite
2996 effect; it specifies that non-PIC calls should be made using the more
2997 efficient @code{jal} instruction.
2998
2999 @item malloc
3000 @cindex @code{malloc} attribute
3001 The @code{malloc} attribute is used to tell the compiler that a function
3002 may be treated as if any non-@code{NULL} pointer it returns cannot
3003 alias any other pointer valid when the function returns and that the memory
3004 has undefined content.
3005 This often improves optimization.
3006 Standard functions with this property include @code{malloc} and
3007 @code{calloc}. @code{realloc}-like functions do not have this
3008 property as the memory pointed to does not have undefined content.
3009
3010 @item mips16/nomips16
3011 @cindex @code{mips16} attribute
3012 @cindex @code{nomips16} attribute
3013
3014 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3015 function attributes to locally select or turn off MIPS16 code generation.
3016 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3017 while MIPS16 code generation is disabled for functions with the
3018 @code{nomips16} attribute. These attributes override the
3019 @option{-mips16} and @option{-mno-mips16} options on the command line
3020 (@pxref{MIPS Options}).
3021
3022 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3023 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3024 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3025 may interact badly with some GCC extensions such as @code{__builtin_apply}
3026 (@pxref{Constructing Calls}).
3027
3028 @item model (@var{model-name})
3029 @cindex function addressability on the M32R/D
3030 @cindex variable addressability on the IA-64
3031
3032 On the M32R/D, use this attribute to set the addressability of an
3033 object, and of the code generated for a function. The identifier
3034 @var{model-name} is one of @code{small}, @code{medium}, or
3035 @code{large}, representing each of the code models.
3036
3037 Small model objects live in the lower 16MB of memory (so that their
3038 addresses can be loaded with the @code{ld24} instruction), and are
3039 callable with the @code{bl} instruction.
3040
3041 Medium model objects may live anywhere in the 32-bit address space (the
3042 compiler generates @code{seth/add3} instructions to load their addresses),
3043 and are callable with the @code{bl} instruction.
3044
3045 Large model objects may live anywhere in the 32-bit address space (the
3046 compiler generates @code{seth/add3} instructions to load their addresses),
3047 and may not be reachable with the @code{bl} instruction (the compiler
3048 generates the much slower @code{seth/add3/jl} instruction sequence).
3049
3050 On IA-64, use this attribute to set the addressability of an object.
3051 At present, the only supported identifier for @var{model-name} is
3052 @code{small}, indicating addressability via ``small'' (22-bit)
3053 addresses (so that their addresses can be loaded with the @code{addl}
3054 instruction). Caveat: such addressing is by definition not position
3055 independent and hence this attribute must not be used for objects
3056 defined by shared libraries.
3057
3058 @item ms_abi/sysv_abi
3059 @cindex @code{ms_abi} attribute
3060 @cindex @code{sysv_abi} attribute
3061
3062 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3063 to indicate which calling convention should be used for a function. The
3064 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3065 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3066 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3067 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3068
3069 Note, the @code{ms_abi} attribute for Windows 64-bit targets currently
3070 requires the @option{-maccumulate-outgoing-args} option.
3071
3072 @item callee_pop_aggregate_return (@var{number})
3073 @cindex @code{callee_pop_aggregate_return} attribute
3074
3075 On 32-bit i?86-*-* targets, you can control by those attribute for
3076 aggregate return in memory, if the caller is responsible to pop the hidden
3077 pointer together with the rest of the arguments - @var{number} equal to
3078 zero -, or if the callee is responsible to pop hidden pointer - @var{number}
3079 equal to one. The default i386 ABI assumes that the callee pops the
3080 stack for hidden pointer.
3081
3082 Note, that on 32-bit i386 Windows targets the compiler assumes that the
3083 caller pops the stack for hidden pointer.
3084
3085 @item ms_hook_prologue
3086 @cindex @code{ms_hook_prologue} attribute
3087
3088 On 32 bit i[34567]86-*-* targets and 64 bit x86_64-*-* targets, you can use
3089 this function attribute to make gcc generate the "hot-patching" function
3090 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3091 and newer.
3092
3093 @item naked
3094 @cindex function without a prologue/epilogue code
3095 Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that
3096 the specified function does not need prologue/epilogue sequences generated by
3097 the compiler. It is up to the programmer to provide these sequences. The
3098 only statements that can be safely included in naked functions are
3099 @code{asm} statements that do not have operands. All other statements,
3100 including declarations of local variables, @code{if} statements, and so
3101 forth, should be avoided. Naked functions should be used to implement the
3102 body of an assembly function, while allowing the compiler to construct
3103 the requisite function declaration for the assembler.
3104
3105 @item near
3106 @cindex functions which do not handle memory bank switching on 68HC11/68HC12
3107 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3108 use the normal calling convention based on @code{jsr} and @code{rts}.
3109 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3110 option.
3111
3112 On MeP targets this attribute causes the compiler to assume the called
3113 function is close enough to use the normal calling convention,
3114 overriding the @code{-mtf} command line option.
3115
3116 @item nesting
3117 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3118 Use this attribute together with @code{interrupt_handler},
3119 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3120 entry code should enable nested interrupts or exceptions.
3121
3122 @item nmi_handler
3123 @cindex NMI handler functions on the Blackfin processor
3124 Use this attribute on the Blackfin to indicate that the specified function
3125 is an NMI handler. The compiler generates function entry and
3126 exit sequences suitable for use in an NMI handler when this
3127 attribute is present.
3128
3129 @item no_instrument_function
3130 @cindex @code{no_instrument_function} function attribute
3131 @opindex finstrument-functions
3132 If @option{-finstrument-functions} is given, profiling function calls are
3133 generated at entry and exit of most user-compiled functions.
3134 Functions with this attribute are not so instrumented.
3135
3136 @item no_split_stack
3137 @cindex @code{no_split_stack} function attribute
3138 @opindex fsplit-stack
3139 If @option{-fsplit-stack} is given, functions have a small
3140 prologue which decides whether to split the stack. Functions with the
3141 @code{no_split_stack} attribute do not have that prologue, and thus
3142 may run with only a small amount of stack space available.
3143
3144 @item noinline
3145 @cindex @code{noinline} function attribute
3146 This function attribute prevents a function from being considered for
3147 inlining.
3148 @c Don't enumerate the optimizations by name here; we try to be
3149 @c future-compatible with this mechanism.
3150 If the function does not have side-effects, there are optimizations
3151 other than inlining that causes function calls to be optimized away,
3152 although the function call is live. To keep such calls from being
3153 optimized away, put
3154 @smallexample
3155 asm ("");
3156 @end smallexample
3157 (@pxref{Extended Asm}) in the called function, to serve as a special
3158 side-effect.
3159
3160 @item noclone
3161 @cindex @code{noclone} function attribute
3162 This function attribute prevents a function from being considered for
3163 cloning - a mechanism which produces specialized copies of functions
3164 and which is (currently) performed by interprocedural constant
3165 propagation.
3166
3167 @item nonnull (@var{arg-index}, @dots{})
3168 @cindex @code{nonnull} function attribute
3169 The @code{nonnull} attribute specifies that some function parameters should
3170 be non-null pointers. For instance, the declaration:
3171
3172 @smallexample
3173 extern void *
3174 my_memcpy (void *dest, const void *src, size_t len)
3175 __attribute__((nonnull (1, 2)));
3176 @end smallexample
3177
3178 @noindent
3179 causes the compiler to check that, in calls to @code{my_memcpy},
3180 arguments @var{dest} and @var{src} are non-null. If the compiler
3181 determines that a null pointer is passed in an argument slot marked
3182 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3183 is issued. The compiler may also choose to make optimizations based
3184 on the knowledge that certain function arguments will never be null.
3185
3186 If no argument index list is given to the @code{nonnull} attribute,
3187 all pointer arguments are marked as non-null. To illustrate, the
3188 following declaration is equivalent to the previous example:
3189
3190 @smallexample
3191 extern void *
3192 my_memcpy (void *dest, const void *src, size_t len)
3193 __attribute__((nonnull));
3194 @end smallexample
3195
3196 @item noreturn
3197 @cindex @code{noreturn} function attribute
3198 A few standard library functions, such as @code{abort} and @code{exit},
3199 cannot return. GCC knows this automatically. Some programs define
3200 their own functions that never return. You can declare them
3201 @code{noreturn} to tell the compiler this fact. For example,
3202
3203 @smallexample
3204 @group
3205 void fatal () __attribute__ ((noreturn));
3206
3207 void
3208 fatal (/* @r{@dots{}} */)
3209 @{
3210 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3211 exit (1);
3212 @}
3213 @end group
3214 @end smallexample
3215
3216 The @code{noreturn} keyword tells the compiler to assume that
3217 @code{fatal} cannot return. It can then optimize without regard to what
3218 would happen if @code{fatal} ever did return. This makes slightly
3219 better code. More importantly, it helps avoid spurious warnings of
3220 uninitialized variables.
3221
3222 The @code{noreturn} keyword does not affect the exceptional path when that
3223 applies: a @code{noreturn}-marked function may still return to the caller
3224 by throwing an exception or calling @code{longjmp}.
3225
3226 Do not assume that registers saved by the calling function are
3227 restored before calling the @code{noreturn} function.
3228
3229 It does not make sense for a @code{noreturn} function to have a return
3230 type other than @code{void}.
3231
3232 The attribute @code{noreturn} is not implemented in GCC versions
3233 earlier than 2.5. An alternative way to declare that a function does
3234 not return, which works in the current version and in some older
3235 versions, is as follows:
3236
3237 @smallexample
3238 typedef void voidfn ();
3239
3240 volatile voidfn fatal;
3241 @end smallexample
3242
3243 This approach does not work in GNU C++.
3244
3245 @item nothrow
3246 @cindex @code{nothrow} function attribute
3247 The @code{nothrow} attribute is used to inform the compiler that a
3248 function cannot throw an exception. For example, most functions in
3249 the standard C library can be guaranteed not to throw an exception
3250 with the notable exceptions of @code{qsort} and @code{bsearch} that
3251 take function pointer arguments. The @code{nothrow} attribute is not
3252 implemented in GCC versions earlier than 3.3.
3253
3254 @item nosave_low_regs
3255 @cindex @code{nosave_low_regs} attribute
3256 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3257 function should not save and restore registers R0..R7. This can be used on SH3*
3258 and SH4* targets which have a second R0..R7 register bank for non-reentrant
3259 interrupt handlers.
3260
3261 @item optimize
3262 @cindex @code{optimize} function attribute
3263 The @code{optimize} attribute is used to specify that a function is to
3264 be compiled with different optimization options than specified on the
3265 command line. Arguments can either be numbers or strings. Numbers
3266 are assumed to be an optimization level. Strings that begin with
3267 @code{O} are assumed to be an optimization option, while other options
3268 are assumed to be used with a @code{-f} prefix. You can also use the
3269 @samp{#pragma GCC optimize} pragma to set the optimization options
3270 that affect more than one function.
3271 @xref{Function Specific Option Pragmas}, for details about the
3272 @samp{#pragma GCC optimize} pragma.
3273
3274 This can be used for instance to have frequently executed functions
3275 compiled with more aggressive optimization options that produce faster
3276 and larger code, while other functions can be called with less
3277 aggressive options.
3278
3279 @item OS_main/OS_task
3280 @cindex @code{OS_main} AVR function attribute
3281 @cindex @code{OS_task} AVR function attribute
3282 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3283 do not save/restore any call-saved register in their prologue/epilogue.
3284
3285 The @code{OS_main} attribute can be used when there @emph{is
3286 guarantee} that interrupts are disabled at the time when the function
3287 is entered. This saves resources when the stack pointer has to be
3288 changed to set up a frame for local variables.
3289
3290 The @code{OS_task} attribute can be used when there is @emph{no
3291 guarantee} that interrupts are disabled at that time when the function
3292 is entered like for, e@.g@. task functions in a multi-threading operating
3293 system. In that case, changing the stack pointer register is
3294 guarded by save/clear/restore of the global interrupt enable flag.
3295
3296 The differences to the @code{naked} function attribute are:
3297 @itemize @bullet
3298 @item @code{naked} functions do not have a return instruction whereas
3299 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3300 @code{RETI} return instruction.
3301 @item @code{naked} functions do not set up a frame for local variables
3302 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3303 as needed.
3304 @end itemize
3305
3306 @item pcs
3307 @cindex @code{pcs} function attribute
3308
3309 The @code{pcs} attribute can be used to control the calling convention
3310 used for a function on ARM. The attribute takes an argument that specifies
3311 the calling convention to use.
3312
3313 When compiling using the AAPCS ABI (or a variant of that) then valid
3314 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3315 order to use a variant other than @code{"aapcs"} then the compiler must
3316 be permitted to use the appropriate co-processor registers (i.e., the
3317 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3318 For example,
3319
3320 @smallexample
3321 /* Argument passed in r0, and result returned in r0+r1. */
3322 double f2d (float) __attribute__((pcs("aapcs")));
3323 @end smallexample
3324
3325 Variadic functions always use the @code{"aapcs"} calling convention and
3326 the compiler rejects attempts to specify an alternative.
3327
3328 @item pure
3329 @cindex @code{pure} function attribute
3330 Many functions have no effects except the return value and their
3331 return value depends only on the parameters and/or global variables.
3332 Such a function can be subject
3333 to common subexpression elimination and loop optimization just as an
3334 arithmetic operator would be. These functions should be declared
3335 with the attribute @code{pure}. For example,
3336
3337 @smallexample
3338 int square (int) __attribute__ ((pure));
3339 @end smallexample
3340
3341 @noindent
3342 says that the hypothetical function @code{square} is safe to call
3343 fewer times than the program says.
3344
3345 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3346 Interesting non-pure functions are functions with infinite loops or those
3347 depending on volatile memory or other system resource, that may change between
3348 two consecutive calls (such as @code{feof} in a multithreading environment).
3349
3350 The attribute @code{pure} is not implemented in GCC versions earlier
3351 than 2.96.
3352
3353 @item hot
3354 @cindex @code{hot} function attribute
3355 The @code{hot} attribute on a function is used to inform the compiler that
3356 the function is a hot spot of the compiled program. The function is
3357 optimized more aggressively and on many target it is placed into special
3358 subsection of the text section so all hot functions appears close together
3359 improving locality.
3360
3361 When profile feedback is available, via @option{-fprofile-use}, hot functions
3362 are automatically detected and this attribute is ignored.
3363
3364 The @code{hot} attribute on functions is not implemented in GCC versions
3365 earlier than 4.3.
3366
3367 @cindex @code{hot} label attribute
3368 The @code{hot} attribute on a label is used to inform the compiler that
3369 path following the label are more likely than paths that are not so
3370 annotated. This attribute is used in cases where @code{__builtin_expect}
3371 cannot be used, for instance with computed goto or @code{asm goto}.
3372
3373 The @code{hot} attribute on labels is not implemented in GCC versions
3374 earlier than 4.8.
3375
3376 @item cold
3377 @cindex @code{cold} function attribute
3378 The @code{cold} attribute on functions is used to inform the compiler that
3379 the function is unlikely to be executed. The function is optimized for
3380 size rather than speed and on many targets it is placed into special
3381 subsection of the text section so all cold functions appears close together
3382 improving code locality of non-cold parts of program. The paths leading
3383 to call of cold functions within code are marked as unlikely by the branch
3384 prediction mechanism. It is thus useful to mark functions used to handle
3385 unlikely conditions, such as @code{perror}, as cold to improve optimization
3386 of hot functions that do call marked functions in rare occasions.
3387
3388 When profile feedback is available, via @option{-fprofile-use}, cold functions
3389 are automatically detected and this attribute is ignored.
3390
3391 The @code{cold} attribute on functions is not implemented in GCC versions
3392 earlier than 4.3.
3393
3394 @cindex @code{cold} label attribute
3395 The @code{cold} attribute on labels is used to inform the compiler that
3396 the path following the label is unlikely to be executed. This attribute
3397 is used in cases where @code{__builtin_expect} cannot be used, for instance
3398 with computed goto or @code{asm goto}.
3399
3400 The @code{cold} attribute on labels is not implemented in GCC versions
3401 earlier than 4.8.
3402
3403 @item regparm (@var{number})
3404 @cindex @code{regparm} attribute
3405 @cindex functions that are passed arguments in registers on the 386
3406 On the Intel 386, the @code{regparm} attribute causes the compiler to
3407 pass arguments number one to @var{number} if they are of integral type
3408 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3409 take a variable number of arguments continue to be passed all of their
3410 arguments on the stack.
3411
3412 Beware that on some ELF systems this attribute is unsuitable for
3413 global functions in shared libraries with lazy binding (which is the
3414 default). Lazy binding sends the first call via resolving code in
3415 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3416 per the standard calling conventions. Solaris 8 is affected by this.
3417 GNU systems with GLIBC 2.1 or higher, and FreeBSD, are believed to be
3418 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3419 disabled with the linker or the loader if desired, to avoid the
3420 problem.)
3421
3422 @item sseregparm
3423 @cindex @code{sseregparm} attribute
3424 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3425 causes the compiler to pass up to 3 floating point arguments in
3426 SSE registers instead of on the stack. Functions that take a
3427 variable number of arguments continue to pass all of their
3428 floating point arguments on the stack.
3429
3430 @item force_align_arg_pointer
3431 @cindex @code{force_align_arg_pointer} attribute
3432 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3433 applied to individual function definitions, generating an alternate
3434 prologue and epilogue that realigns the runtime stack if necessary.
3435 This supports mixing legacy codes that run with a 4-byte aligned stack
3436 with modern codes that keep a 16-byte stack for SSE compatibility.
3437
3438 @item renesas
3439 @cindex @code{renesas} attribute
3440 On SH targets this attribute specifies that the function or struct follows the
3441 Renesas ABI.
3442
3443 @item resbank
3444 @cindex @code{resbank} attribute
3445 On the SH2A target, this attribute enables the high-speed register
3446 saving and restoration using a register bank for @code{interrupt_handler}
3447 routines. Saving to the bank is performed automatically after the CPU
3448 accepts an interrupt that uses a register bank.
3449
3450 The nineteen 32-bit registers comprising general register R0 to R14,
3451 control register GBR, and system registers MACH, MACL, and PR and the
3452 vector table address offset are saved into a register bank. Register
3453 banks are stacked in first-in last-out (FILO) sequence. Restoration
3454 from the bank is executed by issuing a RESBANK instruction.
3455
3456 @item returns_twice
3457 @cindex @code{returns_twice} attribute
3458 The @code{returns_twice} attribute tells the compiler that a function may
3459 return more than one time. The compiler ensures that all registers
3460 are dead before calling such a function and emits a warning about
3461 the variables that may be clobbered after the second return from the
3462 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3463 The @code{longjmp}-like counterpart of such function, if any, might need
3464 to be marked with the @code{noreturn} attribute.
3465
3466 @item saveall
3467 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3468 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3469 all registers except the stack pointer should be saved in the prologue
3470 regardless of whether they are used or not.
3471
3472 @item save_volatiles
3473 @cindex save volatile registers on the MicroBlaze
3474 Use this attribute on the MicroBlaze to indicate that the function is
3475 an interrupt handler. All volatile registers (in addition to non-volatile
3476 registers) are saved in the function prologue. If the function is a leaf
3477 function, only volatiles used by the function are saved. A normal function
3478 return is generated instead of a return from interrupt.
3479
3480 @item section ("@var{section-name}")
3481 @cindex @code{section} function attribute
3482 Normally, the compiler places the code it generates in the @code{text} section.
3483 Sometimes, however, you need additional sections, or you need certain
3484 particular functions to appear in special sections. The @code{section}
3485 attribute specifies that a function lives in a particular section.
3486 For example, the declaration:
3487
3488 @smallexample
3489 extern void foobar (void) __attribute__ ((section ("bar")));
3490 @end smallexample
3491
3492 @noindent
3493 puts the function @code{foobar} in the @code{bar} section.
3494
3495 Some file formats do not support arbitrary sections so the @code{section}
3496 attribute is not available on all platforms.
3497 If you need to map the entire contents of a module to a particular
3498 section, consider using the facilities of the linker instead.
3499
3500 @item sentinel
3501 @cindex @code{sentinel} function attribute
3502 This function attribute ensures that a parameter in a function call is
3503 an explicit @code{NULL}. The attribute is only valid on variadic
3504 functions. By default, the sentinel is located at position zero, the
3505 last parameter of the function call. If an optional integer position
3506 argument P is supplied to the attribute, the sentinel must be located at
3507 position P counting backwards from the end of the argument list.
3508
3509 @smallexample
3510 __attribute__ ((sentinel))
3511 is equivalent to
3512 __attribute__ ((sentinel(0)))
3513 @end smallexample
3514
3515 The attribute is automatically set with a position of 0 for the built-in
3516 functions @code{execl} and @code{execlp}. The built-in function
3517 @code{execle} has the attribute set with a position of 1.
3518
3519 A valid @code{NULL} in this context is defined as zero with any pointer
3520 type. If your system defines the @code{NULL} macro with an integer type
3521 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3522 with a copy that redefines NULL appropriately.
3523
3524 The warnings for missing or incorrect sentinels are enabled with
3525 @option{-Wformat}.
3526
3527 @item short_call
3528 See long_call/short_call.
3529
3530 @item shortcall
3531 See longcall/shortcall.
3532
3533 @item signal
3534 @cindex interrupt handler functions on the AVR processors
3535 Use this attribute on the AVR to indicate that the specified
3536 function is an interrupt handler. The compiler generates function
3537 entry and exit sequences suitable for use in an interrupt handler when this
3538 attribute is present.
3539
3540 See also the @code{interrupt} function attribute.
3541
3542 The AVR hardware globally disables interrupts when an interrupt is executed.
3543 Interrupt handler functions defined with the @code{signal} attribute
3544 do not re-enable interrupts. It is save to enable interrupts in a
3545 @code{signal} handler. This ``save'' only applies to the code
3546 generated by the compiler and not to the IRQ-layout of the
3547 application which is responsibility of the application.
3548
3549 If both @code{signal} and @code{interrupt} are specified for the same
3550 function, @code{signal} is silently ignored.
3551
3552 @item sp_switch
3553 @cindex @code{sp_switch} attribute
3554 Use this attribute on the SH to indicate an @code{interrupt_handler}
3555 function should switch to an alternate stack. It expects a string
3556 argument that names a global variable holding the address of the
3557 alternate stack.
3558
3559 @smallexample
3560 void *alt_stack;
3561 void f () __attribute__ ((interrupt_handler,
3562 sp_switch ("alt_stack")));
3563 @end smallexample
3564
3565 @item stdcall
3566 @cindex functions that pop the argument stack on the 386
3567 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3568 assume that the called function pops off the stack space used to
3569 pass arguments, unless it takes a variable number of arguments.
3570
3571 @item syscall_linkage
3572 @cindex @code{syscall_linkage} attribute
3573 This attribute is used to modify the IA64 calling convention by marking
3574 all input registers as live at all function exits. This makes it possible
3575 to restart a system call after an interrupt without having to save/restore
3576 the input registers. This also prevents kernel data from leaking into
3577 application code.
3578
3579 @item target
3580 @cindex @code{target} function attribute
3581 The @code{target} attribute is used to specify that a function is to
3582 be compiled with different target options than specified on the
3583 command line. This can be used for instance to have functions
3584 compiled with a different ISA (instruction set architecture) than the
3585 default. You can also use the @samp{#pragma GCC target} pragma to set
3586 more than one function to be compiled with specific target options.
3587 @xref{Function Specific Option Pragmas}, for details about the
3588 @samp{#pragma GCC target} pragma.
3589
3590 For instance on a 386, you could compile one function with
3591 @code{target("sse4.1,arch=core2")} and another with
3592 @code{target("sse4a,arch=amdfam10")} that is equivalent to
3593 compiling the first function with @option{-msse4.1} and
3594 @option{-march=core2} options, and the second function with
3595 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3596 user to make sure that a function is only invoked on a machine that
3597 supports the particular ISA it is compiled for (for example by using
3598 @code{cpuid} on 386 to determine what feature bits and architecture
3599 family are used).
3600
3601 @smallexample
3602 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3603 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3604 @end smallexample
3605
3606 On the 386, the following options are allowed:
3607
3608 @table @samp
3609 @item abm
3610 @itemx no-abm
3611 @cindex @code{target("abm")} attribute
3612 Enable/disable the generation of the advanced bit instructions.
3613
3614 @item aes
3615 @itemx no-aes
3616 @cindex @code{target("aes")} attribute
3617 Enable/disable the generation of the AES instructions.
3618
3619 @item mmx
3620 @itemx no-mmx
3621 @cindex @code{target("mmx")} attribute
3622 Enable/disable the generation of the MMX instructions.
3623
3624 @item pclmul
3625 @itemx no-pclmul
3626 @cindex @code{target("pclmul")} attribute
3627 Enable/disable the generation of the PCLMUL instructions.
3628
3629 @item popcnt
3630 @itemx no-popcnt
3631 @cindex @code{target("popcnt")} attribute
3632 Enable/disable the generation of the POPCNT instruction.
3633
3634 @item sse
3635 @itemx no-sse
3636 @cindex @code{target("sse")} attribute
3637 Enable/disable the generation of the SSE instructions.
3638
3639 @item sse2
3640 @itemx no-sse2
3641 @cindex @code{target("sse2")} attribute
3642 Enable/disable the generation of the SSE2 instructions.
3643
3644 @item sse3
3645 @itemx no-sse3
3646 @cindex @code{target("sse3")} attribute
3647 Enable/disable the generation of the SSE3 instructions.
3648
3649 @item sse4
3650 @itemx no-sse4
3651 @cindex @code{target("sse4")} attribute
3652 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3653 and SSE4.2).
3654
3655 @item sse4.1
3656 @itemx no-sse4.1
3657 @cindex @code{target("sse4.1")} attribute
3658 Enable/disable the generation of the sse4.1 instructions.
3659
3660 @item sse4.2
3661 @itemx no-sse4.2
3662 @cindex @code{target("sse4.2")} attribute
3663 Enable/disable the generation of the sse4.2 instructions.
3664
3665 @item sse4a
3666 @itemx no-sse4a
3667 @cindex @code{target("sse4a")} attribute
3668 Enable/disable the generation of the SSE4A instructions.
3669
3670 @item fma4
3671 @itemx no-fma4
3672 @cindex @code{target("fma4")} attribute
3673 Enable/disable the generation of the FMA4 instructions.
3674
3675 @item xop
3676 @itemx no-xop
3677 @cindex @code{target("xop")} attribute
3678 Enable/disable the generation of the XOP instructions.
3679
3680 @item lwp
3681 @itemx no-lwp
3682 @cindex @code{target("lwp")} attribute
3683 Enable/disable the generation of the LWP instructions.
3684
3685 @item ssse3
3686 @itemx no-ssse3
3687 @cindex @code{target("ssse3")} attribute
3688 Enable/disable the generation of the SSSE3 instructions.
3689
3690 @item cld
3691 @itemx no-cld
3692 @cindex @code{target("cld")} attribute
3693 Enable/disable the generation of the CLD before string moves.
3694
3695 @item fancy-math-387
3696 @itemx no-fancy-math-387
3697 @cindex @code{target("fancy-math-387")} attribute
3698 Enable/disable the generation of the @code{sin}, @code{cos}, and
3699 @code{sqrt} instructions on the 387 floating point unit.
3700
3701 @item fused-madd
3702 @itemx no-fused-madd
3703 @cindex @code{target("fused-madd")} attribute
3704 Enable/disable the generation of the fused multiply/add instructions.
3705
3706 @item ieee-fp
3707 @itemx no-ieee-fp
3708 @cindex @code{target("ieee-fp")} attribute
3709 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3710
3711 @item inline-all-stringops
3712 @itemx no-inline-all-stringops
3713 @cindex @code{target("inline-all-stringops")} attribute
3714 Enable/disable inlining of string operations.
3715
3716 @item inline-stringops-dynamically
3717 @itemx no-inline-stringops-dynamically
3718 @cindex @code{target("inline-stringops-dynamically")} attribute
3719 Enable/disable the generation of the inline code to do small string
3720 operations and calling the library routines for large operations.
3721
3722 @item align-stringops
3723 @itemx no-align-stringops
3724 @cindex @code{target("align-stringops")} attribute
3725 Do/do not align destination of inlined string operations.
3726
3727 @item recip
3728 @itemx no-recip
3729 @cindex @code{target("recip")} attribute
3730 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3731 instructions followed an additional Newton-Raphson step instead of
3732 doing a floating point division.
3733
3734 @item arch=@var{ARCH}
3735 @cindex @code{target("arch=@var{ARCH}")} attribute
3736 Specify the architecture to generate code for in compiling the function.
3737
3738 @item tune=@var{TUNE}
3739 @cindex @code{target("tune=@var{TUNE}")} attribute
3740 Specify the architecture to tune for in compiling the function.
3741
3742 @item fpmath=@var{FPMATH}
3743 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3744 Specify which floating point unit to use. The
3745 @code{target("fpmath=sse,387")} option must be specified as
3746 @code{target("fpmath=sse+387")} because the comma would separate
3747 different options.
3748 @end table
3749
3750 On the PowerPC, the following options are allowed:
3751
3752 @table @samp
3753 @item altivec
3754 @itemx no-altivec
3755 @cindex @code{target("altivec")} attribute
3756 Generate code that uses (does not use) AltiVec instructions. In
3757 32-bit code, you cannot enable Altivec instructions unless
3758 @option{-mabi=altivec} is used on the command line.
3759
3760 @item cmpb
3761 @itemx no-cmpb
3762 @cindex @code{target("cmpb")} attribute
3763 Generate code that uses (does not use) the compare bytes instruction
3764 implemented on the POWER6 processor and other processors that support
3765 the PowerPC V2.05 architecture.
3766
3767 @item dlmzb
3768 @itemx no-dlmzb
3769 @cindex @code{target("dlmzb")} attribute
3770 Generate code that uses (does not use) the string-search @samp{dlmzb}
3771 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
3772 generated by default when targeting those processors.
3773
3774 @item fprnd
3775 @itemx no-fprnd
3776 @cindex @code{target("fprnd")} attribute
3777 Generate code that uses (does not use) the FP round to integer
3778 instructions implemented on the POWER5+ processor and other processors
3779 that support the PowerPC V2.03 architecture.
3780
3781 @item hard-dfp
3782 @itemx no-hard-dfp
3783 @cindex @code{target("hard-dfp")} attribute
3784 Generate code that uses (does not use) the decimal floating point
3785 instructions implemented on some POWER processors.
3786
3787 @item isel
3788 @itemx no-isel
3789 @cindex @code{target("isel")} attribute
3790 Generate code that uses (does not use) ISEL instruction.
3791
3792 @item mfcrf
3793 @itemx no-mfcrf
3794 @cindex @code{target("mfcrf")} attribute
3795 Generate code that uses (does not use) the move from condition
3796 register field instruction implemented on the POWER4 processor and
3797 other processors that support the PowerPC V2.01 architecture.
3798
3799 @item mfpgpr
3800 @itemx no-mfpgpr
3801 @cindex @code{target("mfpgpr")} attribute
3802 Generate code that uses (does not use) the FP move to/from general
3803 purpose register instructions implemented on the POWER6X processor and
3804 other processors that support the extended PowerPC V2.05 architecture.
3805
3806 @item mulhw
3807 @itemx no-mulhw
3808 @cindex @code{target("mulhw")} attribute
3809 Generate code that uses (does not use) the half-word multiply and
3810 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
3811 These instructions are generated by default when targeting those
3812 processors.
3813
3814 @item multiple
3815 @itemx no-multiple
3816 @cindex @code{target("multiple")} attribute
3817 Generate code that uses (does not use) the load multiple word
3818 instructions and the store multiple word instructions.
3819
3820 @item update
3821 @itemx no-update
3822 @cindex @code{target("update")} attribute
3823 Generate code that uses (does not use) the load or store instructions
3824 that update the base register to the address of the calculated memory
3825 location.
3826
3827 @item popcntb
3828 @itemx no-popcntb
3829 @cindex @code{target("popcntb")} attribute
3830 Generate code that uses (does not use) the popcount and double
3831 precision FP reciprocal estimate instruction implemented on the POWER5
3832 processor and other processors that support the PowerPC V2.02
3833 architecture.
3834
3835 @item popcntd
3836 @itemx no-popcntd
3837 @cindex @code{target("popcntd")} attribute
3838 Generate code that uses (does not use) the popcount instruction
3839 implemented on the POWER7 processor and other processors that support
3840 the PowerPC V2.06 architecture.
3841
3842 @item powerpc-gfxopt
3843 @itemx no-powerpc-gfxopt
3844 @cindex @code{target("powerpc-gfxopt")} attribute
3845 Generate code that uses (does not use) the optional PowerPC
3846 architecture instructions in the Graphics group, including
3847 floating-point select.
3848
3849 @item powerpc-gpopt
3850 @itemx no-powerpc-gpopt
3851 @cindex @code{target("powerpc-gpopt")} attribute
3852 Generate code that uses (does not use) the optional PowerPC
3853 architecture instructions in the General Purpose group, including
3854 floating-point square root.
3855
3856 @item recip-precision
3857 @itemx no-recip-precision
3858 @cindex @code{target("recip-precision")} attribute
3859 Assume (do not assume) that the reciprocal estimate instructions
3860 provide higher precision estimates than is mandated by the powerpc
3861 ABI.
3862
3863 @item string
3864 @itemx no-string
3865 @cindex @code{target("string")} attribute
3866 Generate code that uses (does not use) the load string instructions
3867 and the store string word instructions to save multiple registers and
3868 do small block moves.
3869
3870 @item vsx
3871 @itemx no-vsx
3872 @cindex @code{target("vsx")} attribute
3873 Generate code that uses (does not use) vector/scalar (VSX)
3874 instructions, and also enable the use of built-in functions that allow
3875 more direct access to the VSX instruction set. In 32-bit code, you
3876 cannot enable VSX or Altivec instructions unless
3877 @option{-mabi=altivec} is used on the command line.
3878
3879 @item friz
3880 @itemx no-friz
3881 @cindex @code{target("friz")} attribute
3882 Generate (do not generate) the @code{friz} instruction when the
3883 @option{-funsafe-math-optimizations} option is used to optimize
3884 rounding a floating point value to 64-bit integer and back to floating
3885 point. The @code{friz} instruction does not return the same value if
3886 the floating point number is too large to fit in an integer.
3887
3888 @item avoid-indexed-addresses
3889 @itemx no-avoid-indexed-addresses
3890 @cindex @code{target("avoid-indexed-addresses")} attribute
3891 Generate code that tries to avoid (not avoid) the use of indexed load
3892 or store instructions.
3893
3894 @item paired
3895 @itemx no-paired
3896 @cindex @code{target("paired")} attribute
3897 Generate code that uses (does not use) the generation of PAIRED simd
3898 instructions.
3899
3900 @item longcall
3901 @itemx no-longcall
3902 @cindex @code{target("longcall")} attribute
3903 Generate code that assumes (does not assume) that all calls are far
3904 away so that a longer more expensive calling sequence is required.
3905
3906 @item cpu=@var{CPU}
3907 @cindex @code{target("cpu=@var{CPU}")} attribute
3908 Specify the architecture to generate code for when compiling the
3909 function. If you select the @code{target("cpu=power7")} attribute when
3910 generating 32-bit code, VSX and Altivec instructions are not generated
3911 unless you use the @option{-mabi=altivec} option on the command line.
3912
3913 @item tune=@var{TUNE}
3914 @cindex @code{target("tune=@var{TUNE}")} attribute
3915 Specify the architecture to tune for when compiling the function. If
3916 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
3917 you do specify the @code{target("cpu=@var{CPU}")} attribute,
3918 compilation tunes for the @var{CPU} architecture, and not the
3919 default tuning specified on the command line.
3920 @end table
3921
3922 On the 386/x86_64 and PowerPC backends, you can use either multiple
3923 strings to specify multiple options, or you can separate the option
3924 with a comma (@code{,}).
3925
3926 On the 386/x86_64 and PowerPC backends, the inliner does not inline a
3927 function that has different target options than the caller, unless the
3928 callee has a subset of the target options of the caller. For example
3929 a function declared with @code{target("sse3")} can inline a function
3930 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
3931
3932 The @code{target} attribute is not implemented in GCC versions earlier
3933 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC backends. It is
3934 not currently implemented for other backends.
3935
3936 @item tiny_data
3937 @cindex tiny data section on the H8/300H and H8S
3938 Use this attribute on the H8/300H and H8S to indicate that the specified
3939 variable should be placed into the tiny data section.
3940 The compiler generates more efficient code for loads and stores
3941 on data in the tiny data section. Note the tiny data area is limited to
3942 slightly under 32kbytes of data.
3943
3944 @item trap_exit
3945 @cindex @code{trap_exit} attribute
3946 Use this attribute on the SH for an @code{interrupt_handler} to return using
3947 @code{trapa} instead of @code{rte}. This attribute expects an integer
3948 argument specifying the trap number to be used.
3949
3950 @item trapa_handler
3951 @cindex @code{trapa_handler} attribute
3952 On SH targets this function attribute is similar to @code{interrupt_handler}
3953 but it does not save and restore all registers.
3954
3955 @item unused
3956 @cindex @code{unused} attribute.
3957 This attribute, attached to a function, means that the function is meant
3958 to be possibly unused. GCC does not produce a warning for this
3959 function.
3960
3961 @item used
3962 @cindex @code{used} attribute.
3963 This attribute, attached to a function, means that code must be emitted
3964 for the function even if it appears that the function is not referenced.
3965 This is useful, for example, when the function is referenced only in
3966 inline assembly.
3967
3968 When applied to a member function of a C++ class template, the
3969 attribute also means that the function is instantiated if the
3970 class itself is instantiated.
3971
3972 @item version_id
3973 @cindex @code{version_id} attribute
3974 This IA64 HP-UX attribute, attached to a global variable or function, renames a
3975 symbol to contain a version string, thus allowing for function level
3976 versioning. HP-UX system header files may use version level functioning
3977 for some system calls.
3978
3979 @smallexample
3980 extern int foo () __attribute__((version_id ("20040821")));
3981 @end smallexample
3982
3983 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
3984
3985 @item visibility ("@var{visibility_type}")
3986 @cindex @code{visibility} attribute
3987 This attribute affects the linkage of the declaration to which it is attached.
3988 There are four supported @var{visibility_type} values: default,
3989 hidden, protected or internal visibility.
3990
3991 @smallexample
3992 void __attribute__ ((visibility ("protected")))
3993 f () @{ /* @r{Do something.} */; @}
3994 int i __attribute__ ((visibility ("hidden")));
3995 @end smallexample
3996
3997 The possible values of @var{visibility_type} correspond to the
3998 visibility settings in the ELF gABI.
3999
4000 @table @dfn
4001 @c keep this list of visibilities in alphabetical order.
4002
4003 @item default
4004 Default visibility is the normal case for the object file format.
4005 This value is available for the visibility attribute to override other
4006 options that may change the assumed visibility of entities.
4007
4008 On ELF, default visibility means that the declaration is visible to other
4009 modules and, in shared libraries, means that the declared entity may be
4010 overridden.
4011
4012 On Darwin, default visibility means that the declaration is visible to
4013 other modules.
4014
4015 Default visibility corresponds to ``external linkage'' in the language.
4016
4017 @item hidden
4018 Hidden visibility indicates that the entity declared has a new
4019 form of linkage, which we call ``hidden linkage''. Two
4020 declarations of an object with hidden linkage refer to the same object
4021 if they are in the same shared object.
4022
4023 @item internal
4024 Internal visibility is like hidden visibility, but with additional
4025 processor specific semantics. Unless otherwise specified by the
4026 psABI, GCC defines internal visibility to mean that a function is
4027 @emph{never} called from another module. Compare this with hidden
4028 functions which, while they cannot be referenced directly by other
4029 modules, can be referenced indirectly via function pointers. By
4030 indicating that a function cannot be called from outside the module,
4031 GCC may for instance omit the load of a PIC register since it is known
4032 that the calling function loaded the correct value.
4033
4034 @item protected
4035 Protected visibility is like default visibility except that it
4036 indicates that references within the defining module bind to the
4037 definition in that module. That is, the declared entity cannot be
4038 overridden by another module.
4039
4040 @end table
4041
4042 All visibilities are supported on many, but not all, ELF targets
4043 (supported when the assembler supports the @samp{.visibility}
4044 pseudo-op). Default visibility is supported everywhere. Hidden
4045 visibility is supported on Darwin targets.
4046
4047 The visibility attribute should be applied only to declarations which
4048 would otherwise have external linkage. The attribute should be applied
4049 consistently, so that the same entity should not be declared with
4050 different settings of the attribute.
4051
4052 In C++, the visibility attribute applies to types as well as functions
4053 and objects, because in C++ types have linkage. A class must not have
4054 greater visibility than its non-static data member types and bases,
4055 and class members default to the visibility of their class. Also, a
4056 declaration without explicit visibility is limited to the visibility
4057 of its type.
4058
4059 In C++, you can mark member functions and static member variables of a
4060 class with the visibility attribute. This is useful if you know a
4061 particular method or static member variable should only be used from
4062 one shared object; then you can mark it hidden while the rest of the
4063 class has default visibility. Care must be taken to avoid breaking
4064 the One Definition Rule; for example, it is usually not useful to mark
4065 an inline method as hidden without marking the whole class as hidden.
4066
4067 A C++ namespace declaration can also have the visibility attribute.
4068 This attribute applies only to the particular namespace body, not to
4069 other definitions of the same namespace; it is equivalent to using
4070 @samp{#pragma GCC visibility} before and after the namespace
4071 definition (@pxref{Visibility Pragmas}).
4072
4073 In C++, if a template argument has limited visibility, this
4074 restriction is implicitly propagated to the template instantiation.
4075 Otherwise, template instantiations and specializations default to the
4076 visibility of their template.
4077
4078 If both the template and enclosing class have explicit visibility, the
4079 visibility from the template is used.
4080
4081 @item vliw
4082 @cindex @code{vliw} attribute
4083 On MeP, the @code{vliw} attribute tells the compiler to emit
4084 instructions in VLIW mode instead of core mode. Note that this
4085 attribute is not allowed unless a VLIW coprocessor has been configured
4086 and enabled through command line options.
4087
4088 @item warn_unused_result
4089 @cindex @code{warn_unused_result} attribute
4090 The @code{warn_unused_result} attribute causes a warning to be emitted
4091 if a caller of the function with this attribute does not use its
4092 return value. This is useful for functions where not checking
4093 the result is either a security problem or always a bug, such as
4094 @code{realloc}.
4095
4096 @smallexample
4097 int fn () __attribute__ ((warn_unused_result));
4098 int foo ()
4099 @{
4100 if (fn () < 0) return -1;
4101 fn ();
4102 return 0;
4103 @}
4104 @end smallexample
4105
4106 results in warning on line 5.
4107
4108 @item weak
4109 @cindex @code{weak} attribute
4110 The @code{weak} attribute causes the declaration to be emitted as a weak
4111 symbol rather than a global. This is primarily useful in defining
4112 library functions which can be overridden in user code, though it can
4113 also be used with non-function declarations. Weak symbols are supported
4114 for ELF targets, and also for a.out targets when using the GNU assembler
4115 and linker.
4116
4117 @item weakref
4118 @itemx weakref ("@var{target}")
4119 @cindex @code{weakref} attribute
4120 The @code{weakref} attribute marks a declaration as a weak reference.
4121 Without arguments, it should be accompanied by an @code{alias} attribute
4122 naming the target symbol. Optionally, the @var{target} may be given as
4123 an argument to @code{weakref} itself. In either case, @code{weakref}
4124 implicitly marks the declaration as @code{weak}. Without a
4125 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4126 @code{weakref} is equivalent to @code{weak}.
4127
4128 @smallexample
4129 static int x() __attribute__ ((weakref ("y")));
4130 /* is equivalent to... */
4131 static int x() __attribute__ ((weak, weakref, alias ("y")));
4132 /* and to... */
4133 static int x() __attribute__ ((weakref));
4134 static int x() __attribute__ ((alias ("y")));
4135 @end smallexample
4136
4137 A weak reference is an alias that does not by itself require a
4138 definition to be given for the target symbol. If the target symbol is
4139 only referenced through weak references, then it becomes a @code{weak}
4140 undefined symbol. If it is directly referenced, however, then such
4141 strong references prevail, and a definition is required for the
4142 symbol, not necessarily in the same translation unit.
4143
4144 The effect is equivalent to moving all references to the alias to a
4145 separate translation unit, renaming the alias to the aliased symbol,
4146 declaring it as weak, compiling the two separate translation units and
4147 performing a reloadable link on them.
4148
4149 At present, a declaration to which @code{weakref} is attached can
4150 only be @code{static}.
4151
4152 @end table
4153
4154 You can specify multiple attributes in a declaration by separating them
4155 by commas within the double parentheses or by immediately following an
4156 attribute declaration with another attribute declaration.
4157
4158 @cindex @code{#pragma}, reason for not using
4159 @cindex pragma, reason for not using
4160 Some people object to the @code{__attribute__} feature, suggesting that
4161 ISO C's @code{#pragma} should be used instead. At the time
4162 @code{__attribute__} was designed, there were two reasons for not doing
4163 this.
4164
4165 @enumerate
4166 @item
4167 It is impossible to generate @code{#pragma} commands from a macro.
4168
4169 @item
4170 There is no telling what the same @code{#pragma} might mean in another
4171 compiler.
4172 @end enumerate
4173
4174 These two reasons applied to almost any application that might have been
4175 proposed for @code{#pragma}. It was basically a mistake to use
4176 @code{#pragma} for @emph{anything}.
4177
4178 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4179 to be generated from macros. In addition, a @code{#pragma GCC}
4180 namespace is now in use for GCC-specific pragmas. However, it has been
4181 found convenient to use @code{__attribute__} to achieve a natural
4182 attachment of attributes to their corresponding declarations, whereas
4183 @code{#pragma GCC} is of use for constructs that do not naturally form
4184 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4185
4186 @node Attribute Syntax
4187 @section Attribute Syntax
4188 @cindex attribute syntax
4189
4190 This section describes the syntax with which @code{__attribute__} may be
4191 used, and the constructs to which attribute specifiers bind, for the C
4192 language. Some details may vary for C++ and Objective-C@. Because of
4193 infelicities in the grammar for attributes, some forms described here
4194 may not be successfully parsed in all cases.
4195
4196 There are some problems with the semantics of attributes in C++. For
4197 example, there are no manglings for attributes, although they may affect
4198 code generation, so problems may arise when attributed types are used in
4199 conjunction with templates or overloading. Similarly, @code{typeid}
4200 does not distinguish between types with different attributes. Support
4201 for attributes in C++ may be restricted in future to attributes on
4202 declarations only, but not on nested declarators.
4203
4204 @xref{Function Attributes}, for details of the semantics of attributes
4205 applying to functions. @xref{Variable Attributes}, for details of the
4206 semantics of attributes applying to variables. @xref{Type Attributes},
4207 for details of the semantics of attributes applying to structure, union
4208 and enumerated types.
4209
4210 An @dfn{attribute specifier} is of the form
4211 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4212 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4213 each attribute is one of the following:
4214
4215 @itemize @bullet
4216 @item
4217 Empty. Empty attributes are ignored.
4218
4219 @item
4220 A word (which may be an identifier such as @code{unused}, or a reserved
4221 word such as @code{const}).
4222
4223 @item
4224 A word, followed by, in parentheses, parameters for the attribute.
4225 These parameters take one of the following forms:
4226
4227 @itemize @bullet
4228 @item
4229 An identifier. For example, @code{mode} attributes use this form.
4230
4231 @item
4232 An identifier followed by a comma and a non-empty comma-separated list
4233 of expressions. For example, @code{format} attributes use this form.
4234
4235 @item
4236 A possibly empty comma-separated list of expressions. For example,
4237 @code{format_arg} attributes use this form with the list being a single
4238 integer constant expression, and @code{alias} attributes use this form
4239 with the list being a single string constant.
4240 @end itemize
4241 @end itemize
4242
4243 An @dfn{attribute specifier list} is a sequence of one or more attribute
4244 specifiers, not separated by any other tokens.
4245
4246 In GNU C, an attribute specifier list may appear after the colon following a
4247 label, other than a @code{case} or @code{default} label. The only
4248 attribute it makes sense to use after a label is @code{unused}. This
4249 feature is intended for code generated by programs which contains labels
4250 that may be unused but which is compiled with @option{-Wall}. It is
4251 not normally appropriate to use in it human-written code, though it
4252 could be useful in cases where the code that jumps to the label is
4253 contained within an @code{#ifdef} conditional. GNU C++ only permits
4254 attributes on labels if the attribute specifier is immediately
4255 followed by a semicolon (i.e., the label applies to an empty
4256 statement). If the semicolon is missing, C++ label attributes are
4257 ambiguous, as it is permissible for a declaration, which could begin
4258 with an attribute list, to be labelled in C++. Declarations cannot be
4259 labelled in C90 or C99, so the ambiguity does not arise there.
4260
4261 An attribute specifier list may appear as part of a @code{struct},
4262 @code{union} or @code{enum} specifier. It may go either immediately
4263 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4264 the closing brace. The former syntax is preferred.
4265 Where attribute specifiers follow the closing brace, they are considered
4266 to relate to the structure, union or enumerated type defined, not to any
4267 enclosing declaration the type specifier appears in, and the type
4268 defined is not complete until after the attribute specifiers.
4269 @c Otherwise, there would be the following problems: a shift/reduce
4270 @c conflict between attributes binding the struct/union/enum and
4271 @c binding to the list of specifiers/qualifiers; and "aligned"
4272 @c attributes could use sizeof for the structure, but the size could be
4273 @c changed later by "packed" attributes.
4274
4275 Otherwise, an attribute specifier appears as part of a declaration,
4276 counting declarations of unnamed parameters and type names, and relates
4277 to that declaration (which may be nested in another declaration, for
4278 example in the case of a parameter declaration), or to a particular declarator
4279 within a declaration. Where an
4280 attribute specifier is applied to a parameter declared as a function or
4281 an array, it should apply to the function or array rather than the
4282 pointer to which the parameter is implicitly converted, but this is not
4283 yet correctly implemented.
4284
4285 Any list of specifiers and qualifiers at the start of a declaration may
4286 contain attribute specifiers, whether or not such a list may in that
4287 context contain storage class specifiers. (Some attributes, however,
4288 are essentially in the nature of storage class specifiers, and only make
4289 sense where storage class specifiers may be used; for example,
4290 @code{section}.) There is one necessary limitation to this syntax: the
4291 first old-style parameter declaration in a function definition cannot
4292 begin with an attribute specifier, because such an attribute applies to
4293 the function instead by syntax described below (which, however, is not
4294 yet implemented in this case). In some other cases, attribute
4295 specifiers are permitted by this grammar but not yet supported by the
4296 compiler. All attribute specifiers in this place relate to the
4297 declaration as a whole. In the obsolescent usage where a type of
4298 @code{int} is implied by the absence of type specifiers, such a list of
4299 specifiers and qualifiers may be an attribute specifier list with no
4300 other specifiers or qualifiers.
4301
4302 At present, the first parameter in a function prototype must have some
4303 type specifier which is not an attribute specifier; this resolves an
4304 ambiguity in the interpretation of @code{void f(int
4305 (__attribute__((foo)) x))}, but is subject to change. At present, if
4306 the parentheses of a function declarator contain only attributes then
4307 those attributes are ignored, rather than yielding an error or warning
4308 or implying a single parameter of type int, but this is subject to
4309 change.
4310
4311 An attribute specifier list may appear immediately before a declarator
4312 (other than the first) in a comma-separated list of declarators in a
4313 declaration of more than one identifier using a single list of
4314 specifiers and qualifiers. Such attribute specifiers apply
4315 only to the identifier before whose declarator they appear. For
4316 example, in
4317
4318 @smallexample
4319 __attribute__((noreturn)) void d0 (void),
4320 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4321 d2 (void)
4322 @end smallexample
4323
4324 @noindent
4325 the @code{noreturn} attribute applies to all the functions
4326 declared; the @code{format} attribute only applies to @code{d1}.
4327
4328 An attribute specifier list may appear immediately before the comma,
4329 @code{=} or semicolon terminating the declaration of an identifier other
4330 than a function definition. Such attribute specifiers apply
4331 to the declared object or function. Where an
4332 assembler name for an object or function is specified (@pxref{Asm
4333 Labels}), the attribute must follow the @code{asm}
4334 specification.
4335
4336 An attribute specifier list may, in future, be permitted to appear after
4337 the declarator in a function definition (before any old-style parameter
4338 declarations or the function body).
4339
4340 Attribute specifiers may be mixed with type qualifiers appearing inside
4341 the @code{[]} of a parameter array declarator, in the C99 construct by
4342 which such qualifiers are applied to the pointer to which the array is
4343 implicitly converted. Such attribute specifiers apply to the pointer,
4344 not to the array, but at present this is not implemented and they are
4345 ignored.
4346
4347 An attribute specifier list may appear at the start of a nested
4348 declarator. At present, there are some limitations in this usage: the
4349 attributes correctly apply to the declarator, but for most individual
4350 attributes the semantics this implies are not implemented.
4351 When attribute specifiers follow the @code{*} of a pointer
4352 declarator, they may be mixed with any type qualifiers present.
4353 The following describes the formal semantics of this syntax. It makes the
4354 most sense if you are familiar with the formal specification of
4355 declarators in the ISO C standard.
4356
4357 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4358 D1}, where @code{T} contains declaration specifiers that specify a type
4359 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4360 contains an identifier @var{ident}. The type specified for @var{ident}
4361 for derived declarators whose type does not include an attribute
4362 specifier is as in the ISO C standard.
4363
4364 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4365 and the declaration @code{T D} specifies the type
4366 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4367 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4368 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4369
4370 If @code{D1} has the form @code{*
4371 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4372 declaration @code{T D} specifies the type
4373 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4374 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4375 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4376 @var{ident}.
4377
4378 For example,
4379
4380 @smallexample
4381 void (__attribute__((noreturn)) ****f) (void);
4382 @end smallexample
4383
4384 @noindent
4385 specifies the type ``pointer to pointer to pointer to pointer to
4386 non-returning function returning @code{void}''. As another example,
4387
4388 @smallexample
4389 char *__attribute__((aligned(8))) *f;
4390 @end smallexample
4391
4392 @noindent
4393 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4394 Note again that this does not work with most attributes; for example,
4395 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4396 is not yet supported.
4397
4398 For compatibility with existing code written for compiler versions that
4399 did not implement attributes on nested declarators, some laxity is
4400 allowed in the placing of attributes. If an attribute that only applies
4401 to types is applied to a declaration, it is treated as applying to
4402 the type of that declaration. If an attribute that only applies to
4403 declarations is applied to the type of a declaration, it is treated
4404 as applying to that declaration; and, for compatibility with code
4405 placing the attributes immediately before the identifier declared, such
4406 an attribute applied to a function return type is treated as
4407 applying to the function type, and such an attribute applied to an array
4408 element type is treated as applying to the array type. If an
4409 attribute that only applies to function types is applied to a
4410 pointer-to-function type, it is treated as applying to the pointer
4411 target type; if such an attribute is applied to a function return type
4412 that is not a pointer-to-function type, it is treated as applying
4413 to the function type.
4414
4415 @node Function Prototypes
4416 @section Prototypes and Old-Style Function Definitions
4417 @cindex function prototype declarations
4418 @cindex old-style function definitions
4419 @cindex promotion of formal parameters
4420
4421 GNU C extends ISO C to allow a function prototype to override a later
4422 old-style non-prototype definition. Consider the following example:
4423
4424 @smallexample
4425 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4426 #ifdef __STDC__
4427 #define P(x) x
4428 #else
4429 #define P(x) ()
4430 #endif
4431
4432 /* @r{Prototype function declaration.} */
4433 int isroot P((uid_t));
4434
4435 /* @r{Old-style function definition.} */
4436 int
4437 isroot (x) /* @r{??? lossage here ???} */
4438 uid_t x;
4439 @{
4440 return x == 0;
4441 @}
4442 @end smallexample
4443
4444 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4445 not allow this example, because subword arguments in old-style
4446 non-prototype definitions are promoted. Therefore in this example the
4447 function definition's argument is really an @code{int}, which does not
4448 match the prototype argument type of @code{short}.
4449
4450 This restriction of ISO C makes it hard to write code that is portable
4451 to traditional C compilers, because the programmer does not know
4452 whether the @code{uid_t} type is @code{short}, @code{int}, or
4453 @code{long}. Therefore, in cases like these GNU C allows a prototype
4454 to override a later old-style definition. More precisely, in GNU C, a
4455 function prototype argument type overrides the argument type specified
4456 by a later old-style definition if the former type is the same as the
4457 latter type before promotion. Thus in GNU C the above example is
4458 equivalent to the following:
4459
4460 @smallexample
4461 int isroot (uid_t);
4462
4463 int
4464 isroot (uid_t x)
4465 @{
4466 return x == 0;
4467 @}
4468 @end smallexample
4469
4470 @noindent
4471 GNU C++ does not support old-style function definitions, so this
4472 extension is irrelevant.
4473
4474 @node C++ Comments
4475 @section C++ Style Comments
4476 @cindex @code{//}
4477 @cindex C++ comments
4478 @cindex comments, C++ style
4479
4480 In GNU C, you may use C++ style comments, which start with @samp{//} and
4481 continue until the end of the line. Many other C implementations allow
4482 such comments, and they are included in the 1999 C standard. However,
4483 C++ style comments are not recognized if you specify an @option{-std}
4484 option specifying a version of ISO C before C99, or @option{-ansi}
4485 (equivalent to @option{-std=c90}).
4486
4487 @node Dollar Signs
4488 @section Dollar Signs in Identifier Names
4489 @cindex $
4490 @cindex dollar signs in identifier names
4491 @cindex identifier names, dollar signs in
4492
4493 In GNU C, you may normally use dollar signs in identifier names.
4494 This is because many traditional C implementations allow such identifiers.
4495 However, dollar signs in identifiers are not supported on a few target
4496 machines, typically because the target assembler does not allow them.
4497
4498 @node Character Escapes
4499 @section The Character @key{ESC} in Constants
4500
4501 You can use the sequence @samp{\e} in a string or character constant to
4502 stand for the ASCII character @key{ESC}.
4503
4504 @node Variable Attributes
4505 @section Specifying Attributes of Variables
4506 @cindex attribute of variables
4507 @cindex variable attributes
4508
4509 The keyword @code{__attribute__} allows you to specify special
4510 attributes of variables or structure fields. This keyword is followed
4511 by an attribute specification inside double parentheses. Some
4512 attributes are currently defined generically for variables.
4513 Other attributes are defined for variables on particular target
4514 systems. Other attributes are available for functions
4515 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4516 Other front ends might define more attributes
4517 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4518
4519 You may also specify attributes with @samp{__} preceding and following
4520 each keyword. This allows you to use them in header files without
4521 being concerned about a possible macro of the same name. For example,
4522 you may use @code{__aligned__} instead of @code{aligned}.
4523
4524 @xref{Attribute Syntax}, for details of the exact syntax for using
4525 attributes.
4526
4527 @table @code
4528 @cindex @code{aligned} attribute
4529 @item aligned (@var{alignment})
4530 This attribute specifies a minimum alignment for the variable or
4531 structure field, measured in bytes. For example, the declaration:
4532
4533 @smallexample
4534 int x __attribute__ ((aligned (16))) = 0;
4535 @end smallexample
4536
4537 @noindent
4538 causes the compiler to allocate the global variable @code{x} on a
4539 16-byte boundary. On a 68040, this could be used in conjunction with
4540 an @code{asm} expression to access the @code{move16} instruction which
4541 requires 16-byte aligned operands.
4542
4543 You can also specify the alignment of structure fields. For example, to
4544 create a double-word aligned @code{int} pair, you could write:
4545
4546 @smallexample
4547 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4548 @end smallexample
4549
4550 @noindent
4551 This is an alternative to creating a union with a @code{double} member
4552 that forces the union to be double-word aligned.
4553
4554 As in the preceding examples, you can explicitly specify the alignment
4555 (in bytes) that you wish the compiler to use for a given variable or
4556 structure field. Alternatively, you can leave out the alignment factor
4557 and just ask the compiler to align a variable or field to the
4558 default alignment for the target architecture you are compiling for.
4559 The default alignment is sufficient for all scalar types, but may not be
4560 enough for all vector types on a target which supports vector operations.
4561 The default alignment is fixed for a particular target ABI.
4562
4563 Gcc also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4564 which is the largest alignment ever used for any data type on the
4565 target machine you are compiling for. For example, you could write:
4566
4567 @smallexample
4568 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4569 @end smallexample
4570
4571 The compiler automatically sets the alignment for the declared
4572 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4573 often make copy operations more efficient, because the compiler can
4574 use whatever instructions copy the biggest chunks of memory when
4575 performing copies to or from the variables or fields that you have
4576 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4577 may change depending on command line options.
4578
4579 When used on a struct, or struct member, the @code{aligned} attribute can
4580 only increase the alignment; in order to decrease it, the @code{packed}
4581 attribute must be specified as well. When used as part of a typedef, the
4582 @code{aligned} attribute can both increase and decrease alignment, and
4583 specifying the @code{packed} attribute generates a warning.
4584
4585 Note that the effectiveness of @code{aligned} attributes may be limited
4586 by inherent limitations in your linker. On many systems, the linker is
4587 only able to arrange for variables to be aligned up to a certain maximum
4588 alignment. (For some linkers, the maximum supported alignment may
4589 be very very small.) If your linker is only able to align variables
4590 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
4591 in an @code{__attribute__} still only provides you with 8 byte
4592 alignment. See your linker documentation for further information.
4593
4594 The @code{aligned} attribute can also be used for functions
4595 (@pxref{Function Attributes}.)
4596
4597 @item cleanup (@var{cleanup_function})
4598 @cindex @code{cleanup} attribute
4599 The @code{cleanup} attribute runs a function when the variable goes
4600 out of scope. This attribute can only be applied to auto function
4601 scope variables; it may not be applied to parameters or variables
4602 with static storage duration. The function must take one parameter,
4603 a pointer to a type compatible with the variable. The return value
4604 of the function (if any) is ignored.
4605
4606 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4607 is run during the stack unwinding that happens during the
4608 processing of the exception. Note that the @code{cleanup} attribute
4609 does not allow the exception to be caught, only to perform an action.
4610 It is undefined what happens if @var{cleanup_function} does not
4611 return normally.
4612
4613 @item common
4614 @itemx nocommon
4615 @cindex @code{common} attribute
4616 @cindex @code{nocommon} attribute
4617 @opindex fcommon
4618 @opindex fno-common
4619 The @code{common} attribute requests GCC to place a variable in
4620 ``common'' storage. The @code{nocommon} attribute requests the
4621 opposite---to allocate space for it directly.
4622
4623 These attributes override the default chosen by the
4624 @option{-fno-common} and @option{-fcommon} flags respectively.
4625
4626 @item deprecated
4627 @itemx deprecated (@var{msg})
4628 @cindex @code{deprecated} attribute
4629 The @code{deprecated} attribute results in a warning if the variable
4630 is used anywhere in the source file. This is useful when identifying
4631 variables that are expected to be removed in a future version of a
4632 program. The warning also includes the location of the declaration
4633 of the deprecated variable, to enable users to easily find further
4634 information about why the variable is deprecated, or what they should
4635 do instead. Note that the warning only occurs for uses:
4636
4637 @smallexample
4638 extern int old_var __attribute__ ((deprecated));
4639 extern int old_var;
4640 int new_fn () @{ return old_var; @}
4641 @end smallexample
4642
4643 @noindent
4644 results in a warning on line 3 but not line 2. The optional @var{msg}
4645 argument, which must be a string, is printed in the warning if
4646 present.
4647
4648 The @code{deprecated} attribute can also be used for functions and
4649 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4650
4651 @item mode (@var{mode})
4652 @cindex @code{mode} attribute
4653 This attribute specifies the data type for the declaration---whichever
4654 type corresponds to the mode @var{mode}. This in effect lets you
4655 request an integer or floating point type according to its width.
4656
4657 You may also specify a mode of @samp{byte} or @samp{__byte__} to
4658 indicate the mode corresponding to a one-byte integer, @samp{word} or
4659 @samp{__word__} for the mode of a one-word integer, and @samp{pointer}
4660 or @samp{__pointer__} for the mode used to represent pointers.
4661
4662 @item packed
4663 @cindex @code{packed} attribute
4664 The @code{packed} attribute specifies that a variable or structure field
4665 should have the smallest possible alignment---one byte for a variable,
4666 and one bit for a field, unless you specify a larger value with the
4667 @code{aligned} attribute.
4668
4669 Here is a structure in which the field @code{x} is packed, so that it
4670 immediately follows @code{a}:
4671
4672 @smallexample
4673 struct foo
4674 @{
4675 char a;
4676 int x[2] __attribute__ ((packed));
4677 @};
4678 @end smallexample
4679
4680 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4681 @code{packed} attribute on bit-fields of type @code{char}. This has
4682 been fixed in GCC 4.4 but the change can lead to differences in the
4683 structure layout. See the documentation of
4684 @option{-Wpacked-bitfield-compat} for more information.
4685
4686 @item section ("@var{section-name}")
4687 @cindex @code{section} variable attribute
4688 Normally, the compiler places the objects it generates in sections like
4689 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
4690 or you need certain particular variables to appear in special sections,
4691 for example to map to special hardware. The @code{section}
4692 attribute specifies that a variable (or function) lives in a particular
4693 section. For example, this small program uses several specific section names:
4694
4695 @smallexample
4696 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4697 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4698 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4699 int init_data __attribute__ ((section ("INITDATA")));
4700
4701 main()
4702 @{
4703 /* @r{Initialize stack pointer} */
4704 init_sp (stack + sizeof (stack));
4705
4706 /* @r{Initialize initialized data} */
4707 memcpy (&init_data, &data, &edata - &data);
4708
4709 /* @r{Turn on the serial ports} */
4710 init_duart (&a);
4711 init_duart (&b);
4712 @}
4713 @end smallexample
4714
4715 @noindent
4716 Use the @code{section} attribute with
4717 @emph{global} variables and not @emph{local} variables,
4718 as shown in the example.
4719
4720 You may use the @code{section} attribute with initialized or
4721 uninitialized global variables but the linker requires
4722 each object be defined once, with the exception that uninitialized
4723 variables tentatively go in the @code{common} (or @code{bss}) section
4724 and can be multiply ``defined''. Using the @code{section} attribute
4725 changes what section the variable goes into and may cause the
4726 linker to issue an error if an uninitialized variable has multiple
4727 definitions. You can force a variable to be initialized with the
4728 @option{-fno-common} flag or the @code{nocommon} attribute.
4729
4730 Some file formats do not support arbitrary sections so the @code{section}
4731 attribute is not available on all platforms.
4732 If you need to map the entire contents of a module to a particular
4733 section, consider using the facilities of the linker instead.
4734
4735 @item shared
4736 @cindex @code{shared} variable attribute
4737 On Microsoft Windows, in addition to putting variable definitions in a named
4738 section, the section can also be shared among all running copies of an
4739 executable or DLL@. For example, this small program defines shared data
4740 by putting it in a named section @code{shared} and marking the section
4741 shareable:
4742
4743 @smallexample
4744 int foo __attribute__((section ("shared"), shared)) = 0;
4745
4746 int
4747 main()
4748 @{
4749 /* @r{Read and write foo. All running
4750 copies see the same value.} */
4751 return 0;
4752 @}
4753 @end smallexample
4754
4755 @noindent
4756 You may only use the @code{shared} attribute along with @code{section}
4757 attribute with a fully initialized global definition because of the way
4758 linkers work. See @code{section} attribute for more information.
4759
4760 The @code{shared} attribute is only available on Microsoft Windows@.
4761
4762 @item tls_model ("@var{tls_model}")
4763 @cindex @code{tls_model} attribute
4764 The @code{tls_model} attribute sets thread-local storage model
4765 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4766 overriding @option{-ftls-model=} command-line switch on a per-variable
4767 basis.
4768 The @var{tls_model} argument should be one of @code{global-dynamic},
4769 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4770
4771 Not all targets support this attribute.
4772
4773 @item unused
4774 This attribute, attached to a variable, means that the variable is meant
4775 to be possibly unused. GCC does not produce a warning for this
4776 variable.
4777
4778 @item used
4779 This attribute, attached to a variable, means that the variable must be
4780 emitted even if it appears that the variable is not referenced.
4781
4782 When applied to a static data member of a C++ class template, the
4783 attribute also means that the member is instantiated if the
4784 class itself is instantiated.
4785
4786 @item vector_size (@var{bytes})
4787 This attribute specifies the vector size for the variable, measured in
4788 bytes. For example, the declaration:
4789
4790 @smallexample
4791 int foo __attribute__ ((vector_size (16)));
4792 @end smallexample
4793
4794 @noindent
4795 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4796 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
4797 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
4798
4799 This attribute is only applicable to integral and float scalars,
4800 although arrays, pointers, and function return values are allowed in
4801 conjunction with this construct.
4802
4803 Aggregates with this attribute are invalid, even if they are of the same
4804 size as a corresponding scalar. For example, the declaration:
4805
4806 @smallexample
4807 struct S @{ int a; @};
4808 struct S __attribute__ ((vector_size (16))) foo;
4809 @end smallexample
4810
4811 @noindent
4812 is invalid even if the size of the structure is the same as the size of
4813 the @code{int}.
4814
4815 @item selectany
4816 The @code{selectany} attribute causes an initialized global variable to
4817 have link-once semantics. When multiple definitions of the variable are
4818 encountered by the linker, the first is selected and the remainder are
4819 discarded. Following usage by the Microsoft compiler, the linker is told
4820 @emph{not} to warn about size or content differences of the multiple
4821 definitions.
4822
4823 Although the primary usage of this attribute is for POD types, the
4824 attribute can also be applied to global C++ objects that are initialized
4825 by a constructor. In this case, the static initialization and destruction
4826 code for the object is emitted in each translation defining the object,
4827 but the calls to the constructor and destructor are protected by a
4828 link-once guard variable.
4829
4830 The @code{selectany} attribute is only available on Microsoft Windows
4831 targets. You can use @code{__declspec (selectany)} as a synonym for
4832 @code{__attribute__ ((selectany))} for compatibility with other
4833 compilers.
4834
4835 @item weak
4836 The @code{weak} attribute is described in @ref{Function Attributes}.
4837
4838 @item dllimport
4839 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4840
4841 @item dllexport
4842 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4843
4844 @end table
4845
4846 @anchor{AVR Variable Attributes}
4847 @subsection AVR Variable Attributes
4848
4849 @table @code
4850 @item progmem
4851 @cindex @code{progmem} AVR variable attribute
4852 The @code{progmem} attribute is used on the AVR to place read-only
4853 data in the non-volatile program memory (flash). The @code{progmem}
4854 attribute accomplishes this by putting respective variables into a
4855 section whose name starts with @code{.progmem}.
4856
4857 This attribute works similar to the @code{section} attribute
4858 but adds additional checking. Notice that just like the
4859 @code{section} attribute, @code{progmem} affects the location
4860 of the data but not how this data is accessed.
4861
4862 In order to read data located with the @code{progmem} attribute
4863 (inline) assembler must be used.
4864 @example
4865 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual,AVR-LibC}} */
4866 #include <avr/pgmspace.h>
4867
4868 /* Locate var in flash memory */
4869 const int var[2] PROGMEM = @{ 1, 2 @};
4870
4871 int read_var (int i)
4872 @{
4873 /* Access var[] by accessor macro from avr/pgmspace.h */
4874 return (int) pgm_read_word (& var[i]);
4875 @}
4876 @end example
4877
4878 AVR is a Harvard architecture processor and data and read-only data
4879 normally resides in the data memory (RAM).
4880
4881 See also the @ref{AVR Named Address Spaces} section for
4882 an alternate way to locate and access data in flash memory.
4883 @end table
4884
4885 @subsection Blackfin Variable Attributes
4886
4887 Three attributes are currently defined for the Blackfin.
4888
4889 @table @code
4890 @item l1_data
4891 @itemx l1_data_A
4892 @itemx l1_data_B
4893 @cindex @code{l1_data} variable attribute
4894 @cindex @code{l1_data_A} variable attribute
4895 @cindex @code{l1_data_B} variable attribute
4896 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4897 Variables with @code{l1_data} attribute are put into the specific section
4898 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
4899 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4900 attribute are put into the specific section named @code{.l1.data.B}.
4901
4902 @item l2
4903 @cindex @code{l2} variable attribute
4904 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4905 Variables with @code{l2} attribute are put into the specific section
4906 named @code{.l2.data}.
4907 @end table
4908
4909 @subsection M32R/D Variable Attributes
4910
4911 One attribute is currently defined for the M32R/D@.
4912
4913 @table @code
4914 @item model (@var{model-name})
4915 @cindex variable addressability on the M32R/D
4916 Use this attribute on the M32R/D to set the addressability of an object.
4917 The identifier @var{model-name} is one of @code{small}, @code{medium},
4918 or @code{large}, representing each of the code models.
4919
4920 Small model objects live in the lower 16MB of memory (so that their
4921 addresses can be loaded with the @code{ld24} instruction).
4922
4923 Medium and large model objects may live anywhere in the 32-bit address space
4924 (the compiler generates @code{seth/add3} instructions to load their
4925 addresses).
4926 @end table
4927
4928 @anchor{MeP Variable Attributes}
4929 @subsection MeP Variable Attributes
4930
4931 The MeP target has a number of addressing modes and busses. The
4932 @code{near} space spans the standard memory space's first 16 megabytes
4933 (24 bits). The @code{far} space spans the entire 32-bit memory space.
4934 The @code{based} space is a 128 byte region in the memory space which
4935 is addressed relative to the @code{$tp} register. The @code{tiny}
4936 space is a 65536 byte region relative to the @code{$gp} register. In
4937 addition to these memory regions, the MeP target has a separate 16-bit
4938 control bus which is specified with @code{cb} attributes.
4939
4940 @table @code
4941
4942 @item based
4943 Any variable with the @code{based} attribute is assigned to the
4944 @code{.based} section, and is accessed with relative to the
4945 @code{$tp} register.
4946
4947 @item tiny
4948 Likewise, the @code{tiny} attribute assigned variables to the
4949 @code{.tiny} section, relative to the @code{$gp} register.
4950
4951 @item near
4952 Variables with the @code{near} attribute are assumed to have addresses
4953 that fit in a 24-bit addressing mode. This is the default for large
4954 variables (@code{-mtiny=4} is the default) but this attribute can
4955 override @code{-mtiny=} for small variables, or override @code{-ml}.
4956
4957 @item far
4958 Variables with the @code{far} attribute are addressed using a full
4959 32-bit address. Since this covers the entire memory space, this
4960 allows modules to make no assumptions about where variables might be
4961 stored.
4962
4963 @item io
4964 @itemx io (@var{addr})
4965 Variables with the @code{io} attribute are used to address
4966 memory-mapped peripherals. If an address is specified, the variable
4967 is assigned that address, else it is not assigned an address (it is
4968 assumed some other module assigns an address). Example:
4969
4970 @example
4971 int timer_count __attribute__((io(0x123)));
4972 @end example
4973
4974 @item cb
4975 @itemx cb (@var{addr})
4976 Variables with the @code{cb} attribute are used to access the control
4977 bus, using special instructions. @code{addr} indicates the control bus
4978 address. Example:
4979
4980 @example
4981 int cpu_clock __attribute__((cb(0x123)));
4982 @end example
4983
4984 @end table
4985
4986 @anchor{i386 Variable Attributes}
4987 @subsection i386 Variable Attributes
4988
4989 Two attributes are currently defined for i386 configurations:
4990 @code{ms_struct} and @code{gcc_struct}
4991
4992 @table @code
4993 @item ms_struct
4994 @itemx gcc_struct
4995 @cindex @code{ms_struct} attribute
4996 @cindex @code{gcc_struct} attribute
4997
4998 If @code{packed} is used on a structure, or if bit-fields are used
4999 it may be that the Microsoft ABI packs them differently
5000 than GCC normally packs them. Particularly when moving packed
5001 data between functions compiled with GCC and the native Microsoft compiler
5002 (either via function call or as data in a file), it may be necessary to access
5003 either format.
5004
5005 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5006 compilers to match the native Microsoft compiler.
5007
5008 The Microsoft structure layout algorithm is fairly simple with the exception
5009 of the bitfield packing:
5010
5011 The padding and alignment of members of structures and whether a bit field
5012 can straddle a storage-unit boundary
5013
5014 @enumerate
5015 @item Structure members are stored sequentially in the order in which they are
5016 declared: the first member has the lowest memory address and the last member
5017 the highest.
5018
5019 @item Every data object has an alignment-requirement. The alignment-requirement
5020 for all data except structures, unions, and arrays is either the size of the
5021 object or the current packing size (specified with either the aligned attribute
5022 or the pack pragma), whichever is less. For structures, unions, and arrays,
5023 the alignment-requirement is the largest alignment-requirement of its members.
5024 Every object is allocated an offset so that:
5025
5026 offset % alignment-requirement == 0
5027
5028 @item Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation
5029 unit if the integral types are the same size and if the next bit field fits
5030 into the current allocation unit without crossing the boundary imposed by the
5031 common alignment requirements of the bit fields.
5032 @end enumerate
5033
5034 Handling of zero-length bitfields:
5035
5036 MSVC interprets zero-length bitfields in the following ways:
5037
5038 @enumerate
5039 @item If a zero-length bitfield is inserted between two bitfields that
5040 are normally coalesced, the bitfields are not coalesced.
5041
5042 For example:
5043
5044 @smallexample
5045 struct
5046 @{
5047 unsigned long bf_1 : 12;
5048 unsigned long : 0;
5049 unsigned long bf_2 : 12;
5050 @} t1;
5051 @end smallexample
5052
5053 The size of @code{t1} is 8 bytes with the zero-length bitfield. If the
5054 zero-length bitfield were removed, @code{t1}'s size would be 4 bytes.
5055
5056 @item If a zero-length bitfield is inserted after a bitfield, @code{foo}, and the
5057 alignment of the zero-length bitfield is greater than the member that follows it,
5058 @code{bar}, @code{bar} is aligned as the type of the zero-length bitfield.
5059
5060 For example:
5061
5062 @smallexample
5063 struct
5064 @{
5065 char foo : 4;
5066 short : 0;
5067 char bar;
5068 @} t2;
5069
5070 struct
5071 @{
5072 char foo : 4;
5073 short : 0;
5074 double bar;
5075 @} t3;
5076 @end smallexample
5077
5078 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5079 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5080 bitfield does not affect the alignment of @code{bar} or, as a result, the size
5081 of the structure.
5082
5083 Taking this into account, it is important to note the following:
5084
5085 @enumerate
5086 @item If a zero-length bitfield follows a normal bitfield, the type of the
5087 zero-length bitfield may affect the alignment of the structure as whole. For
5088 example, @code{t2} has a size of 4 bytes, since the zero-length bitfield follows a
5089 normal bitfield, and is of type short.
5090
5091 @item Even if a zero-length bitfield is not followed by a normal bitfield, it may
5092 still affect the alignment of the structure:
5093
5094 @smallexample
5095 struct
5096 @{
5097 char foo : 6;
5098 long : 0;
5099 @} t4;
5100 @end smallexample
5101
5102 Here, @code{t4} takes up 4 bytes.
5103 @end enumerate
5104
5105 @item Zero-length bitfields following non-bitfield members are ignored:
5106
5107 @smallexample
5108 struct
5109 @{
5110 char foo;
5111 long : 0;
5112 char bar;
5113 @} t5;
5114 @end smallexample
5115
5116 Here, @code{t5} takes up 2 bytes.
5117 @end enumerate
5118 @end table
5119
5120 @subsection PowerPC Variable Attributes
5121
5122 Three attributes currently are defined for PowerPC configurations:
5123 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5124
5125 For full documentation of the struct attributes please see the
5126 documentation in @ref{i386 Variable Attributes}.
5127
5128 For documentation of @code{altivec} attribute please see the
5129 documentation in @ref{PowerPC Type Attributes}.
5130
5131 @subsection SPU Variable Attributes
5132
5133 The SPU supports the @code{spu_vector} attribute for variables. For
5134 documentation of this attribute please see the documentation in
5135 @ref{SPU Type Attributes}.
5136
5137 @subsection Xstormy16 Variable Attributes
5138
5139 One attribute is currently defined for xstormy16 configurations:
5140 @code{below100}.
5141
5142 @table @code
5143 @item below100
5144 @cindex @code{below100} attribute
5145
5146 If a variable has the @code{below100} attribute (@code{BELOW100} is
5147 allowed also), GCC places the variable in the first 0x100 bytes of
5148 memory and use special opcodes to access it. Such variables are
5149 placed in either the @code{.bss_below100} section or the
5150 @code{.data_below100} section.
5151
5152 @end table
5153
5154 @node Type Attributes
5155 @section Specifying Attributes of Types
5156 @cindex attribute of types
5157 @cindex type attributes
5158
5159 The keyword @code{__attribute__} allows you to specify special
5160 attributes of @code{struct} and @code{union} types when you define
5161 such types. This keyword is followed by an attribute specification
5162 inside double parentheses. Seven attributes are currently defined for
5163 types: @code{aligned}, @code{packed}, @code{transparent_union},
5164 @code{unused}, @code{deprecated}, @code{visibility}, and
5165 @code{may_alias}. Other attributes are defined for functions
5166 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5167 Attributes}).
5168
5169 You may also specify any one of these attributes with @samp{__}
5170 preceding and following its keyword. This allows you to use these
5171 attributes in header files without being concerned about a possible
5172 macro of the same name. For example, you may use @code{__aligned__}
5173 instead of @code{aligned}.
5174
5175 You may specify type attributes in an enum, struct or union type
5176 declaration or definition, or for other types in a @code{typedef}
5177 declaration.
5178
5179 For an enum, struct or union type, you may specify attributes either
5180 between the enum, struct or union tag and the name of the type, or
5181 just past the closing curly brace of the @emph{definition}. The
5182 former syntax is preferred.
5183
5184 @xref{Attribute Syntax}, for details of the exact syntax for using
5185 attributes.
5186
5187 @table @code
5188 @cindex @code{aligned} attribute
5189 @item aligned (@var{alignment})
5190 This attribute specifies a minimum alignment (in bytes) for variables
5191 of the specified type. For example, the declarations:
5192
5193 @smallexample
5194 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5195 typedef int more_aligned_int __attribute__ ((aligned (8)));
5196 @end smallexample
5197
5198 @noindent
5199 force the compiler to insure (as far as it can) that each variable whose
5200 type is @code{struct S} or @code{more_aligned_int} is allocated and
5201 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5202 variables of type @code{struct S} aligned to 8-byte boundaries allows
5203 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5204 store) instructions when copying one variable of type @code{struct S} to
5205 another, thus improving run-time efficiency.
5206
5207 Note that the alignment of any given @code{struct} or @code{union} type
5208 is required by the ISO C standard to be at least a perfect multiple of
5209 the lowest common multiple of the alignments of all of the members of
5210 the @code{struct} or @code{union} in question. This means that you @emph{can}
5211 effectively adjust the alignment of a @code{struct} or @code{union}
5212 type by attaching an @code{aligned} attribute to any one of the members
5213 of such a type, but the notation illustrated in the example above is a
5214 more obvious, intuitive, and readable way to request the compiler to
5215 adjust the alignment of an entire @code{struct} or @code{union} type.
5216
5217 As in the preceding example, you can explicitly specify the alignment
5218 (in bytes) that you wish the compiler to use for a given @code{struct}
5219 or @code{union} type. Alternatively, you can leave out the alignment factor
5220 and just ask the compiler to align a type to the maximum
5221 useful alignment for the target machine you are compiling for. For
5222 example, you could write:
5223
5224 @smallexample
5225 struct S @{ short f[3]; @} __attribute__ ((aligned));
5226 @end smallexample
5227
5228 Whenever you leave out the alignment factor in an @code{aligned}
5229 attribute specification, the compiler automatically sets the alignment
5230 for the type to the largest alignment which is ever used for any data
5231 type on the target machine you are compiling for. Doing this can often
5232 make copy operations more efficient, because the compiler can use
5233 whatever instructions copy the biggest chunks of memory when performing
5234 copies to or from the variables which have types that you have aligned
5235 this way.
5236
5237 In the example above, if the size of each @code{short} is 2 bytes, then
5238 the size of the entire @code{struct S} type is 6 bytes. The smallest
5239 power of two which is greater than or equal to that is 8, so the
5240 compiler sets the alignment for the entire @code{struct S} type to 8
5241 bytes.
5242
5243 Note that although you can ask the compiler to select a time-efficient
5244 alignment for a given type and then declare only individual stand-alone
5245 objects of that type, the compiler's ability to select a time-efficient
5246 alignment is primarily useful only when you plan to create arrays of
5247 variables having the relevant (efficiently aligned) type. If you
5248 declare or use arrays of variables of an efficiently-aligned type, then
5249 it is likely that your program also does pointer arithmetic (or
5250 subscripting, which amounts to the same thing) on pointers to the
5251 relevant type, and the code that the compiler generates for these
5252 pointer arithmetic operations is often more efficient for
5253 efficiently-aligned types than for other types.
5254
5255 The @code{aligned} attribute can only increase the alignment; but you
5256 can decrease it by specifying @code{packed} as well. See below.
5257
5258 Note that the effectiveness of @code{aligned} attributes may be limited
5259 by inherent limitations in your linker. On many systems, the linker is
5260 only able to arrange for variables to be aligned up to a certain maximum
5261 alignment. (For some linkers, the maximum supported alignment may
5262 be very very small.) If your linker is only able to align variables
5263 up to a maximum of 8 byte alignment, then specifying @code{aligned(16)}
5264 in an @code{__attribute__} still only provides you with 8 byte
5265 alignment. See your linker documentation for further information.
5266
5267 @item packed
5268 This attribute, attached to @code{struct} or @code{union} type
5269 definition, specifies that each member (other than zero-width bitfields)
5270 of the structure or union is placed to minimize the memory required. When
5271 attached to an @code{enum} definition, it indicates that the smallest
5272 integral type should be used.
5273
5274 @opindex fshort-enums
5275 Specifying this attribute for @code{struct} and @code{union} types is
5276 equivalent to specifying the @code{packed} attribute on each of the
5277 structure or union members. Specifying the @option{-fshort-enums}
5278 flag on the line is equivalent to specifying the @code{packed}
5279 attribute on all @code{enum} definitions.
5280
5281 In the following example @code{struct my_packed_struct}'s members are
5282 packed closely together, but the internal layout of its @code{s} member
5283 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5284 be packed too.
5285
5286 @smallexample
5287 struct my_unpacked_struct
5288 @{
5289 char c;
5290 int i;
5291 @};
5292
5293 struct __attribute__ ((__packed__)) my_packed_struct
5294 @{
5295 char c;
5296 int i;
5297 struct my_unpacked_struct s;
5298 @};
5299 @end smallexample
5300
5301 You may only specify this attribute on the definition of an @code{enum},
5302 @code{struct} or @code{union}, not on a @code{typedef} which does not
5303 also define the enumerated type, structure or union.
5304
5305 @item transparent_union
5306 This attribute, attached to a @code{union} type definition, indicates
5307 that any function parameter having that union type causes calls to that
5308 function to be treated in a special way.
5309
5310 First, the argument corresponding to a transparent union type can be of
5311 any type in the union; no cast is required. Also, if the union contains
5312 a pointer type, the corresponding argument can be a null pointer
5313 constant or a void pointer expression; and if the union contains a void
5314 pointer type, the corresponding argument can be any pointer expression.
5315 If the union member type is a pointer, qualifiers like @code{const} on
5316 the referenced type must be respected, just as with normal pointer
5317 conversions.
5318
5319 Second, the argument is passed to the function using the calling
5320 conventions of the first member of the transparent union, not the calling
5321 conventions of the union itself. All members of the union must have the
5322 same machine representation; this is necessary for this argument passing
5323 to work properly.
5324
5325 Transparent unions are designed for library functions that have multiple
5326 interfaces for compatibility reasons. For example, suppose the
5327 @code{wait} function must accept either a value of type @code{int *} to
5328 comply with Posix, or a value of type @code{union wait *} to comply with
5329 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5330 @code{wait} would accept both kinds of arguments, but it would also
5331 accept any other pointer type and this would make argument type checking
5332 less useful. Instead, @code{<sys/wait.h>} might define the interface
5333 as follows:
5334
5335 @smallexample
5336 typedef union __attribute__ ((__transparent_union__))
5337 @{
5338 int *__ip;
5339 union wait *__up;
5340 @} wait_status_ptr_t;
5341
5342 pid_t wait (wait_status_ptr_t);
5343 @end smallexample
5344
5345 This interface allows either @code{int *} or @code{union wait *}
5346 arguments to be passed, using the @code{int *} calling convention.
5347 The program can call @code{wait} with arguments of either type:
5348
5349 @smallexample
5350 int w1 () @{ int w; return wait (&w); @}
5351 int w2 () @{ union wait w; return wait (&w); @}
5352 @end smallexample
5353
5354 With this interface, @code{wait}'s implementation might look like this:
5355
5356 @smallexample
5357 pid_t wait (wait_status_ptr_t p)
5358 @{
5359 return waitpid (-1, p.__ip, 0);
5360 @}
5361 @end smallexample
5362
5363 @item unused
5364 When attached to a type (including a @code{union} or a @code{struct}),
5365 this attribute means that variables of that type are meant to appear
5366 possibly unused. GCC does not produce a warning for any variables of
5367 that type, even if the variable appears to do nothing. This is often
5368 the case with lock or thread classes, which are usually defined and then
5369 not referenced, but contain constructors and destructors that have
5370 nontrivial bookkeeping functions.
5371
5372 @item deprecated
5373 @itemx deprecated (@var{msg})
5374 The @code{deprecated} attribute results in a warning if the type
5375 is used anywhere in the source file. This is useful when identifying
5376 types that are expected to be removed in a future version of a program.
5377 If possible, the warning also includes the location of the declaration
5378 of the deprecated type, to enable users to easily find further
5379 information about why the type is deprecated, or what they should do
5380 instead. Note that the warnings only occur for uses and then only
5381 if the type is being applied to an identifier that itself is not being
5382 declared as deprecated.
5383
5384 @smallexample
5385 typedef int T1 __attribute__ ((deprecated));
5386 T1 x;
5387 typedef T1 T2;
5388 T2 y;
5389 typedef T1 T3 __attribute__ ((deprecated));
5390 T3 z __attribute__ ((deprecated));
5391 @end smallexample
5392
5393 @noindent
5394 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5395 warning is issued for line 4 because T2 is not explicitly
5396 deprecated. Line 5 has no warning because T3 is explicitly
5397 deprecated. Similarly for line 6. The optional @var{msg}
5398 argument, which must be a string, is printed in the warning if
5399 present.
5400
5401 The @code{deprecated} attribute can also be used for functions and
5402 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5403
5404 @item may_alias
5405 Accesses through pointers to types with this attribute are not subject
5406 to type-based alias analysis, but are instead assumed to be able to alias
5407 any other type of objects. In the context of 6.5/7 an lvalue expression
5408 dereferencing such a pointer is treated like having a character type.
5409 See @option{-fstrict-aliasing} for more information on aliasing issues.
5410 This extension exists to support some vector APIs, in which pointers to
5411 one vector type are permitted to alias pointers to a different vector type.
5412
5413 Note that an object of a type with this attribute does not have any
5414 special semantics.
5415
5416 Example of use:
5417
5418 @smallexample
5419 typedef short __attribute__((__may_alias__)) short_a;
5420
5421 int
5422 main (void)
5423 @{
5424 int a = 0x12345678;
5425 short_a *b = (short_a *) &a;
5426
5427 b[1] = 0;
5428
5429 if (a == 0x12345678)
5430 abort();
5431
5432 exit(0);
5433 @}
5434 @end smallexample
5435
5436 If you replaced @code{short_a} with @code{short} in the variable
5437 declaration, the above program would abort when compiled with
5438 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5439 above in recent GCC versions.
5440
5441 @item visibility
5442 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5443 applied to class, struct, union and enum types. Unlike other type
5444 attributes, the attribute must appear between the initial keyword and
5445 the name of the type; it cannot appear after the body of the type.
5446
5447 Note that the type visibility is applied to vague linkage entities
5448 associated with the class (vtable, typeinfo node, etc.). In
5449 particular, if a class is thrown as an exception in one shared object
5450 and caught in another, the class must have default visibility.
5451 Otherwise the two shared objects are unable to use the same
5452 typeinfo node and exception handling will break.
5453
5454 @end table
5455
5456 To specify multiple attributes, separate them by commas within the
5457 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5458 packed))}.
5459
5460 @subsection ARM Type Attributes
5461
5462 On those ARM targets that support @code{dllimport} (such as Symbian
5463 OS), you can use the @code{notshared} attribute to indicate that the
5464 virtual table and other similar data for a class should not be
5465 exported from a DLL@. For example:
5466
5467 @smallexample
5468 class __declspec(notshared) C @{
5469 public:
5470 __declspec(dllimport) C();
5471 virtual void f();
5472 @}
5473
5474 __declspec(dllexport)
5475 C::C() @{@}
5476 @end smallexample
5477
5478 In this code, @code{C::C} is exported from the current DLL, but the
5479 virtual table for @code{C} is not exported. (You can use
5480 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5481 most Symbian OS code uses @code{__declspec}.)
5482
5483 @anchor{MeP Type Attributes}
5484 @subsection MeP Type Attributes
5485
5486 Many of the MeP variable attributes may be applied to types as well.
5487 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5488 @code{far} attributes may be applied to either. The @code{io} and
5489 @code{cb} attributes may not be applied to types.
5490
5491 @anchor{i386 Type Attributes}
5492 @subsection i386 Type Attributes
5493
5494 Two attributes are currently defined for i386 configurations:
5495 @code{ms_struct} and @code{gcc_struct}.
5496
5497 @table @code
5498
5499 @item ms_struct
5500 @itemx gcc_struct
5501 @cindex @code{ms_struct}
5502 @cindex @code{gcc_struct}
5503
5504 If @code{packed} is used on a structure, or if bit-fields are used
5505 it may be that the Microsoft ABI packs them differently
5506 than GCC normally packs them. Particularly when moving packed
5507 data between functions compiled with GCC and the native Microsoft compiler
5508 (either via function call or as data in a file), it may be necessary to access
5509 either format.
5510
5511 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5512 compilers to match the native Microsoft compiler.
5513 @end table
5514
5515 @anchor{PowerPC Type Attributes}
5516 @subsection PowerPC Type Attributes
5517
5518 Three attributes currently are defined for PowerPC configurations:
5519 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5520
5521 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5522 attributes please see the documentation in @ref{i386 Type Attributes}.
5523
5524 The @code{altivec} attribute allows one to declare AltiVec vector data
5525 types supported by the AltiVec Programming Interface Manual. The
5526 attribute requires an argument to specify one of three vector types:
5527 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5528 and @code{bool__} (always followed by unsigned).
5529
5530 @smallexample
5531 __attribute__((altivec(vector__)))
5532 __attribute__((altivec(pixel__))) unsigned short
5533 __attribute__((altivec(bool__))) unsigned
5534 @end smallexample
5535
5536 These attributes mainly are intended to support the @code{__vector},
5537 @code{__pixel}, and @code{__bool} AltiVec keywords.
5538
5539 @anchor{SPU Type Attributes}
5540 @subsection SPU Type Attributes
5541
5542 The SPU supports the @code{spu_vector} attribute for types. This attribute
5543 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5544 Language Extensions Specification. It is intended to support the
5545 @code{__vector} keyword.
5546
5547 @node Alignment
5548 @section Inquiring on Alignment of Types or Variables
5549 @cindex alignment
5550 @cindex type alignment
5551 @cindex variable alignment
5552
5553 The keyword @code{__alignof__} allows you to inquire about how an object
5554 is aligned, or the minimum alignment usually required by a type. Its
5555 syntax is just like @code{sizeof}.
5556
5557 For example, if the target machine requires a @code{double} value to be
5558 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5559 This is true on many RISC machines. On more traditional machine
5560 designs, @code{__alignof__ (double)} is 4 or even 2.
5561
5562 Some machines never actually require alignment; they allow reference to any
5563 data type even at an odd address. For these machines, @code{__alignof__}
5564 reports the smallest alignment that GCC gives the data type, usually as
5565 mandated by the target ABI.
5566
5567 If the operand of @code{__alignof__} is an lvalue rather than a type,
5568 its value is the required alignment for its type, taking into account
5569 any minimum alignment specified with GCC's @code{__attribute__}
5570 extension (@pxref{Variable Attributes}). For example, after this
5571 declaration:
5572
5573 @smallexample
5574 struct foo @{ int x; char y; @} foo1;
5575 @end smallexample
5576
5577 @noindent
5578 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5579 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5580
5581 It is an error to ask for the alignment of an incomplete type.
5582
5583
5584 @node Inline
5585 @section An Inline Function is As Fast As a Macro
5586 @cindex inline functions
5587 @cindex integrating function code
5588 @cindex open coding
5589 @cindex macros, inline alternative
5590
5591 By declaring a function inline, you can direct GCC to make
5592 calls to that function faster. One way GCC can achieve this is to
5593 integrate that function's code into the code for its callers. This
5594 makes execution faster by eliminating the function-call overhead; in
5595 addition, if any of the actual argument values are constant, their
5596 known values may permit simplifications at compile time so that not
5597 all of the inline function's code needs to be included. The effect on
5598 code size is less predictable; object code may be larger or smaller
5599 with function inlining, depending on the particular case. You can
5600 also direct GCC to try to integrate all ``simple enough'' functions
5601 into their callers with the option @option{-finline-functions}.
5602
5603 GCC implements three different semantics of declaring a function
5604 inline. One is available with @option{-std=gnu89} or
5605 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5606 on all inline declarations, another when
5607 @option{-std=c99}, @option{-std=c11},
5608 @option{-std=gnu99} or @option{-std=gnu11}
5609 (without @option{-fgnu89-inline}), and the third
5610 is used when compiling C++.
5611
5612 To declare a function inline, use the @code{inline} keyword in its
5613 declaration, like this:
5614
5615 @smallexample
5616 static inline int
5617 inc (int *a)
5618 @{
5619 return (*a)++;
5620 @}
5621 @end smallexample
5622
5623 If you are writing a header file to be included in ISO C90 programs, write
5624 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
5625
5626 The three types of inlining behave similarly in two important cases:
5627 when the @code{inline} keyword is used on a @code{static} function,
5628 like the example above, and when a function is first declared without
5629 using the @code{inline} keyword and then is defined with
5630 @code{inline}, like this:
5631
5632 @smallexample
5633 extern int inc (int *a);
5634 inline int
5635 inc (int *a)
5636 @{
5637 return (*a)++;
5638 @}
5639 @end smallexample
5640
5641 In both of these common cases, the program behaves the same as if you
5642 had not used the @code{inline} keyword, except for its speed.
5643
5644 @cindex inline functions, omission of
5645 @opindex fkeep-inline-functions
5646 When a function is both inline and @code{static}, if all calls to the
5647 function are integrated into the caller, and the function's address is
5648 never used, then the function's own assembler code is never referenced.
5649 In this case, GCC does not actually output assembler code for the
5650 function, unless you specify the option @option{-fkeep-inline-functions}.
5651 Some calls cannot be integrated for various reasons (in particular,
5652 calls that precede the function's definition cannot be integrated, and
5653 neither can recursive calls within the definition). If there is a
5654 nonintegrated call, then the function is compiled to assembler code as
5655 usual. The function must also be compiled as usual if the program
5656 refers to its address, because that can't be inlined.
5657
5658 @opindex Winline
5659 Note that certain usages in a function definition can make it unsuitable
5660 for inline substitution. Among these usages are: use of varargs, use of
5661 alloca, use of variable sized data types (@pxref{Variable Length}),
5662 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5663 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
5664 warns when a function marked @code{inline} could not be substituted,
5665 and gives the reason for the failure.
5666
5667 @cindex automatic @code{inline} for C++ member fns
5668 @cindex @code{inline} automatic for C++ member fns
5669 @cindex member fns, automatically @code{inline}
5670 @cindex C++ member fns, automatically @code{inline}
5671 @opindex fno-default-inline
5672 As required by ISO C++, GCC considers member functions defined within
5673 the body of a class to be marked inline even if they are
5674 not explicitly declared with the @code{inline} keyword. You can
5675 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5676 Options,,Options Controlling C++ Dialect}.
5677
5678 GCC does not inline any functions when not optimizing unless you specify
5679 the @samp{always_inline} attribute for the function, like this:
5680
5681 @smallexample
5682 /* @r{Prototype.} */
5683 inline void foo (const char) __attribute__((always_inline));
5684 @end smallexample
5685
5686 The remainder of this section is specific to GNU C90 inlining.
5687
5688 @cindex non-static inline function
5689 When an inline function is not @code{static}, then the compiler must assume
5690 that there may be calls from other source files; since a global symbol can
5691 be defined only once in any program, the function must not be defined in
5692 the other source files, so the calls therein cannot be integrated.
5693 Therefore, a non-@code{static} inline function is always compiled on its
5694 own in the usual fashion.
5695
5696 If you specify both @code{inline} and @code{extern} in the function
5697 definition, then the definition is used only for inlining. In no case
5698 is the function compiled on its own, not even if you refer to its
5699 address explicitly. Such an address becomes an external reference, as
5700 if you had only declared the function, and had not defined it.
5701
5702 This combination of @code{inline} and @code{extern} has almost the
5703 effect of a macro. The way to use it is to put a function definition in
5704 a header file with these keywords, and put another copy of the
5705 definition (lacking @code{inline} and @code{extern}) in a library file.
5706 The definition in the header file causes most calls to the function
5707 to be inlined. If any uses of the function remain, they refer to
5708 the single copy in the library.
5709
5710 @node Volatiles
5711 @section When is a Volatile Object Accessed?
5712 @cindex accessing volatiles
5713 @cindex volatile read
5714 @cindex volatile write
5715 @cindex volatile access
5716
5717 C has the concept of volatile objects. These are normally accessed by
5718 pointers and used for accessing hardware or inter-thread
5719 communication. The standard encourages compilers to refrain from
5720 optimizations concerning accesses to volatile objects, but leaves it
5721 implementation defined as to what constitutes a volatile access. The
5722 minimum requirement is that at a sequence point all previous accesses
5723 to volatile objects have stabilized and no subsequent accesses have
5724 occurred. Thus an implementation is free to reorder and combine
5725 volatile accesses which occur between sequence points, but cannot do
5726 so for accesses across a sequence point. The use of volatile does
5727 not allow you to violate the restriction on updating objects multiple
5728 times between two sequence points.
5729
5730 Accesses to non-volatile objects are not ordered with respect to
5731 volatile accesses. You cannot use a volatile object as a memory
5732 barrier to order a sequence of writes to non-volatile memory. For
5733 instance:
5734
5735 @smallexample
5736 int *ptr = @var{something};
5737 volatile int vobj;
5738 *ptr = @var{something};
5739 vobj = 1;
5740 @end smallexample
5741
5742 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5743 that the write to @var{*ptr} occurs by the time the update
5744 of @var{vobj} happens. If you need this guarantee, you must use
5745 a stronger memory barrier such as:
5746
5747 @smallexample
5748 int *ptr = @var{something};
5749 volatile int vobj;
5750 *ptr = @var{something};
5751 asm volatile ("" : : : "memory");
5752 vobj = 1;
5753 @end smallexample
5754
5755 A scalar volatile object is read when it is accessed in a void context:
5756
5757 @smallexample
5758 volatile int *src = @var{somevalue};
5759 *src;
5760 @end smallexample
5761
5762 Such expressions are rvalues, and GCC implements this as a
5763 read of the volatile object being pointed to.
5764
5765 Assignments are also expressions and have an rvalue. However when
5766 assigning to a scalar volatile, the volatile object is not reread,
5767 regardless of whether the assignment expression's rvalue is used or
5768 not. If the assignment's rvalue is used, the value is that assigned
5769 to the volatile object. For instance, there is no read of @var{vobj}
5770 in all the following cases:
5771
5772 @smallexample
5773 int obj;
5774 volatile int vobj;
5775 vobj = @var{something};
5776 obj = vobj = @var{something};
5777 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
5778 obj = (@var{something}, vobj = @var{anotherthing});
5779 @end smallexample
5780
5781 If you need to read the volatile object after an assignment has
5782 occurred, you must use a separate expression with an intervening
5783 sequence point.
5784
5785 As bitfields are not individually addressable, volatile bitfields may
5786 be implicitly read when written to, or when adjacent bitfields are
5787 accessed. Bitfield operations may be optimized such that adjacent
5788 bitfields are only partially accessed, if they straddle a storage unit
5789 boundary. For these reasons it is unwise to use volatile bitfields to
5790 access hardware.
5791
5792 @node Extended Asm
5793 @section Assembler Instructions with C Expression Operands
5794 @cindex extended @code{asm}
5795 @cindex @code{asm} expressions
5796 @cindex assembler instructions
5797 @cindex registers
5798
5799 In an assembler instruction using @code{asm}, you can specify the
5800 operands of the instruction using C expressions. This means you need not
5801 guess which registers or memory locations contain the data you want
5802 to use.
5803
5804 You must specify an assembler instruction template much like what
5805 appears in a machine description, plus an operand constraint string for
5806 each operand.
5807
5808 For example, here is how to use the 68881's @code{fsinx} instruction:
5809
5810 @smallexample
5811 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5812 @end smallexample
5813
5814 @noindent
5815 Here @code{angle} is the C expression for the input operand while
5816 @code{result} is that of the output operand. Each has @samp{"f"} as its
5817 operand constraint, saying that a floating point register is required.
5818 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5819 output operands' constraints must use @samp{=}. The constraints use the
5820 same language used in the machine description (@pxref{Constraints}).
5821
5822 Each operand is described by an operand-constraint string followed by
5823 the C expression in parentheses. A colon separates the assembler
5824 template from the first output operand and another separates the last
5825 output operand from the first input, if any. Commas separate the
5826 operands within each group. The total number of operands is currently
5827 limited to 30; this limitation may be lifted in some future version of
5828 GCC@.
5829
5830 If there are no output operands but there are input operands, you must
5831 place two consecutive colons surrounding the place where the output
5832 operands would go.
5833
5834 As of GCC version 3.1, it is also possible to specify input and output
5835 operands using symbolic names which can be referenced within the
5836 assembler code. These names are specified inside square brackets
5837 preceding the constraint string, and can be referenced inside the
5838 assembler code using @code{%[@var{name}]} instead of a percentage sign
5839 followed by the operand number. Using named operands the above example
5840 could look like:
5841
5842 @smallexample
5843 asm ("fsinx %[angle],%[output]"
5844 : [output] "=f" (result)
5845 : [angle] "f" (angle));
5846 @end smallexample
5847
5848 @noindent
5849 Note that the symbolic operand names have no relation whatsoever to
5850 other C identifiers. You may use any name you like, even those of
5851 existing C symbols, but you must ensure that no two operands within the same
5852 assembler construct use the same symbolic name.
5853
5854 Output operand expressions must be lvalues; the compiler can check this.
5855 The input operands need not be lvalues. The compiler cannot check
5856 whether the operands have data types that are reasonable for the
5857 instruction being executed. It does not parse the assembler instruction
5858 template and does not know what it means or even whether it is valid
5859 assembler input. The extended @code{asm} feature is most often used for
5860 machine instructions the compiler itself does not know exist. If
5861 the output expression cannot be directly addressed (for example, it is a
5862 bit-field), your constraint must allow a register. In that case, GCC
5863 uses the register as the output of the @code{asm}, and then stores
5864 that register into the output.
5865
5866 The ordinary output operands must be write-only; GCC assumes that
5867 the values in these operands before the instruction are dead and need
5868 not be generated. Extended asm supports input-output or read-write
5869 operands. Use the constraint character @samp{+} to indicate such an
5870 operand and list it with the output operands.
5871
5872 You may, as an alternative, logically split its function into two
5873 separate operands, one input operand and one write-only output
5874 operand. The connection between them is expressed by constraints
5875 which say they need to be in the same location when the instruction
5876 executes. You can use the same C expression for both operands, or
5877 different expressions. For example, here we write the (fictitious)
5878 @samp{combine} instruction with @code{bar} as its read-only source
5879 operand and @code{foo} as its read-write destination:
5880
5881 @smallexample
5882 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5883 @end smallexample
5884
5885 @noindent
5886 The constraint @samp{"0"} for operand 1 says that it must occupy the
5887 same location as operand 0. A number in constraint is allowed only in
5888 an input operand and it must refer to an output operand.
5889
5890 Only a number in the constraint can guarantee that one operand is in
5891 the same place as another. The mere fact that @code{foo} is the value
5892 of both operands is not enough to guarantee that they are in the
5893 same place in the generated assembler code. The following does not
5894 work reliably:
5895
5896 @smallexample
5897 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5898 @end smallexample
5899
5900 Various optimizations or reloading could cause operands 0 and 1 to be in
5901 different registers; GCC knows no reason not to do so. For example, the
5902 compiler might find a copy of the value of @code{foo} in one register and
5903 use it for operand 1, but generate the output operand 0 in a different
5904 register (copying it afterward to @code{foo}'s own address). Of course,
5905 since the register for operand 1 is not even mentioned in the assembler
5906 code, the result will not work, but GCC can't tell that.
5907
5908 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5909 the operand number for a matching constraint. For example:
5910
5911 @smallexample
5912 asm ("cmoveq %1,%2,%[result]"
5913 : [result] "=r"(result)
5914 : "r" (test), "r"(new), "[result]"(old));
5915 @end smallexample
5916
5917 Sometimes you need to make an @code{asm} operand be a specific register,
5918 but there's no matching constraint letter for that register @emph{by
5919 itself}. To force the operand into that register, use a local variable
5920 for the operand and specify the register in the variable declaration.
5921 @xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any
5922 register constraint letter that matches the register:
5923
5924 @smallexample
5925 register int *p1 asm ("r0") = @dots{};
5926 register int *p2 asm ("r1") = @dots{};
5927 register int *result asm ("r0");
5928 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5929 @end smallexample
5930
5931 @anchor{Example of asm with clobbered asm reg}
5932 In the above example, beware that a register that is call-clobbered by
5933 the target ABI will be overwritten by any function call in the
5934 assignment, including library calls for arithmetic operators.
5935 Also a register may be clobbered when generating some operations,
5936 like variable shift, memory copy or memory move on x86.
5937 Assuming it is a call-clobbered register, this may happen to @code{r0}
5938 above by the assignment to @code{p2}. If you have to use such a
5939 register, use temporary variables for expressions between the register
5940 assignment and use:
5941
5942 @smallexample
5943 int t1 = @dots{};
5944 register int *p1 asm ("r0") = @dots{};
5945 register int *p2 asm ("r1") = t1;
5946 register int *result asm ("r0");
5947 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
5948 @end smallexample
5949
5950 Some instructions clobber specific hard registers. To describe this,
5951 write a third colon after the input operands, followed by the names of
5952 the clobbered hard registers (given as strings). Here is a realistic
5953 example for the VAX:
5954
5955 @smallexample
5956 asm volatile ("movc3 %0,%1,%2"
5957 : /* @r{no outputs} */
5958 : "g" (from), "g" (to), "g" (count)
5959 : "r0", "r1", "r2", "r3", "r4", "r5");
5960 @end smallexample
5961
5962 You may not write a clobber description in a way that overlaps with an
5963 input or output operand. For example, you may not have an operand
5964 describing a register class with one member if you mention that register
5965 in the clobber list. Variables declared to live in specific registers
5966 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
5967 have no part mentioned in the clobber description.
5968 There is no way for you to specify that an input
5969 operand is modified without also specifying it as an output
5970 operand. Note that if all the output operands you specify are for this
5971 purpose (and hence unused), you then also need to specify
5972 @code{volatile} for the @code{asm} construct, as described below, to
5973 prevent GCC from deleting the @code{asm} statement as unused.
5974
5975 If you refer to a particular hardware register from the assembler code,
5976 you probably have to list the register after the third colon to
5977 tell the compiler the register's value is modified. In some assemblers,
5978 the register names begin with @samp{%}; to produce one @samp{%} in the
5979 assembler code, you must write @samp{%%} in the input.
5980
5981 If your assembler instruction can alter the condition code register, add
5982 @samp{cc} to the list of clobbered registers. GCC on some machines
5983 represents the condition codes as a specific hardware register;
5984 @samp{cc} serves to name this register. On other machines, the
5985 condition code is handled differently, and specifying @samp{cc} has no
5986 effect. But it is valid no matter what the machine.
5987
5988 If your assembler instructions access memory in an unpredictable
5989 fashion, add @samp{memory} to the list of clobbered registers. This
5990 causes GCC to not keep memory values cached in registers across the
5991 assembler instruction and not optimize stores or loads to that memory.
5992 You also should add the @code{volatile} keyword if the memory
5993 affected is not listed in the inputs or outputs of the @code{asm}, as
5994 the @samp{memory} clobber does not count as a side-effect of the
5995 @code{asm}. If you know how large the accessed memory is, you can add
5996 it as input or output but if this is not known, you should add
5997 @samp{memory}. As an example, if you access ten bytes of a string, you
5998 can use a memory input like:
5999
6000 @smallexample
6001 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6002 @end smallexample
6003
6004 Note that in the following example the memory input is necessary,
6005 otherwise GCC might optimize the store to @code{x} away:
6006 @smallexample
6007 int foo ()
6008 @{
6009 int x = 42;
6010 int *y = &x;
6011 int result;
6012 asm ("magic stuff accessing an 'int' pointed to by '%1'"
6013 "=&d" (r) : "a" (y), "m" (*y));
6014 return result;
6015 @}
6016 @end smallexample
6017
6018 You can put multiple assembler instructions together in a single
6019 @code{asm} template, separated by the characters normally used in assembly
6020 code for the system. A combination that works in most places is a newline
6021 to break the line, plus a tab character to move to the instruction field
6022 (written as @samp{\n\t}). Sometimes semicolons can be used, if the
6023 assembler allows semicolons as a line-breaking character. Note that some
6024 assembler dialects use semicolons to start a comment.
6025 The input operands are guaranteed not to use any of the clobbered
6026 registers, and neither do the output operands' addresses, so you can
6027 read and write the clobbered registers as many times as you like. Here
6028 is an example of multiple instructions in a template; it assumes the
6029 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6030
6031 @smallexample
6032 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6033 : /* no outputs */
6034 : "g" (from), "g" (to)
6035 : "r9", "r10");
6036 @end smallexample
6037
6038 Unless an output operand has the @samp{&} constraint modifier, GCC
6039 may allocate it in the same register as an unrelated input operand, on
6040 the assumption the inputs are consumed before the outputs are produced.
6041 This assumption may be false if the assembler code actually consists of
6042 more than one instruction. In such a case, use @samp{&} for each output
6043 operand that may not overlap an input. @xref{Modifiers}.
6044
6045 If you want to test the condition code produced by an assembler
6046 instruction, you must include a branch and a label in the @code{asm}
6047 construct, as follows:
6048
6049 @smallexample
6050 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6051 : "g" (result)
6052 : "g" (input));
6053 @end smallexample
6054
6055 @noindent
6056 This assumes your assembler supports local labels, as the GNU assembler
6057 and most Unix assemblers do.
6058
6059 Speaking of labels, jumps from one @code{asm} to another are not
6060 supported. The compiler's optimizers do not know about these jumps, and
6061 therefore they cannot take account of them when deciding how to
6062 optimize. @xref{Extended asm with goto}.
6063
6064 @cindex macros containing @code{asm}
6065 Usually the most convenient way to use these @code{asm} instructions is to
6066 encapsulate them in macros that look like functions. For example,
6067
6068 @smallexample
6069 #define sin(x) \
6070 (@{ double __value, __arg = (x); \
6071 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
6072 __value; @})
6073 @end smallexample
6074
6075 @noindent
6076 Here the variable @code{__arg} is used to make sure that the instruction
6077 operates on a proper @code{double} value, and to accept only those
6078 arguments @code{x} which can convert automatically to a @code{double}.
6079
6080 Another way to make sure the instruction operates on the correct data
6081 type is to use a cast in the @code{asm}. This is different from using a
6082 variable @code{__arg} in that it converts more different types. For
6083 example, if the desired type is @code{int}, casting the argument to
6084 @code{int} accepts a pointer with no complaint, while assigning the
6085 argument to an @code{int} variable named @code{__arg} warns about
6086 using a pointer unless the caller explicitly casts it.
6087
6088 If an @code{asm} has output operands, GCC assumes for optimization
6089 purposes the instruction has no side effects except to change the output
6090 operands. This does not mean instructions with a side effect cannot be
6091 used, but you must be careful, because the compiler may eliminate them
6092 if the output operands aren't used, or move them out of loops, or
6093 replace two with one if they constitute a common subexpression. Also,
6094 if your instruction does have a side effect on a variable that otherwise
6095 appears not to change, the old value of the variable may be reused later
6096 if it happens to be found in a register.
6097
6098 You can prevent an @code{asm} instruction from being deleted
6099 by writing the keyword @code{volatile} after
6100 the @code{asm}. For example:
6101
6102 @smallexample
6103 #define get_and_set_priority(new) \
6104 (@{ int __old; \
6105 asm volatile ("get_and_set_priority %0, %1" \
6106 : "=g" (__old) : "g" (new)); \
6107 __old; @})
6108 @end smallexample
6109
6110 @noindent
6111 The @code{volatile} keyword indicates that the instruction has
6112 important side-effects. GCC does not delete a volatile @code{asm} if
6113 it is reachable. (The instruction can still be deleted if GCC can
6114 prove that control flow never reaches the location of the
6115 instruction.) Note that even a volatile @code{asm} instruction
6116 can be moved relative to other code, including across jump
6117 instructions. For example, on many targets there is a system
6118 register which can be set to control the rounding mode of
6119 floating point operations. You might try
6120 setting it with a volatile @code{asm}, like this PowerPC example:
6121
6122 @smallexample
6123 asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6124 sum = x + y;
6125 @end smallexample
6126
6127 @noindent
6128 This does not work reliably, as the compiler may move the addition back
6129 before the volatile @code{asm}. To make it work you need to add an
6130 artificial dependency to the @code{asm} referencing a variable in the code
6131 you don't want moved, for example:
6132
6133 @smallexample
6134 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6135 sum = x + y;
6136 @end smallexample
6137
6138 Similarly, you can't expect a
6139 sequence of volatile @code{asm} instructions to remain perfectly
6140 consecutive. If you want consecutive output, use a single @code{asm}.
6141 Also, GCC performs some optimizations across a volatile @code{asm}
6142 instruction; GCC does not ``forget everything'' when it encounters
6143 a volatile @code{asm} instruction the way some other compilers do.
6144
6145 An @code{asm} instruction without any output operands is treated
6146 identically to a volatile @code{asm} instruction.
6147
6148 It is a natural idea to look for a way to give access to the condition
6149 code left by the assembler instruction. However, when we attempted to
6150 implement this, we found no way to make it work reliably. The problem
6151 is that output operands might need reloading, which result in
6152 additional following ``store'' instructions. On most machines, these
6153 instructions alter the condition code before there is time to
6154 test it. This problem doesn't arise for ordinary ``test'' and
6155 ``compare'' instructions because they don't have any output operands.
6156
6157 For reasons similar to those described above, it is not possible to give
6158 an assembler instruction access to the condition code left by previous
6159 instructions.
6160
6161 @anchor{Extended asm with goto}
6162 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6163 jump to one or more C labels. In this form, a fifth section after the
6164 clobber list contains a list of all C labels to which the assembly may jump.
6165 Each label operand is implicitly self-named. The @code{asm} is also assumed
6166 to fall through to the next statement.
6167
6168 This form of @code{asm} is restricted to not have outputs. This is due
6169 to a internal restriction in the compiler that control transfer instructions
6170 cannot have outputs. This restriction on @code{asm goto} may be lifted
6171 in some future version of the compiler. In the mean time, @code{asm goto}
6172 may include a memory clobber, and so leave outputs in memory.
6173
6174 @smallexample
6175 int frob(int x)
6176 @{
6177 int y;
6178 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6179 : : "r"(x), "r"(&y) : "r5", "memory" : error);
6180 return y;
6181 error:
6182 return -1;
6183 @}
6184 @end smallexample
6185
6186 In this (inefficient) example, the @code{frob} instruction sets the
6187 carry bit to indicate an error. The @code{jc} instruction detects
6188 this and branches to the @code{error} label. Finally, the output
6189 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6190 for variable @code{y}, which is later read by the @code{return} statement.
6191
6192 @smallexample
6193 void doit(void)
6194 @{
6195 int i = 0;
6196 asm goto ("mfsr %%r1, 123; jmp %%r1;"
6197 ".pushsection doit_table;"
6198 ".long %l0, %l1, %l2, %l3;"
6199 ".popsection"
6200 : : : "r1" : label1, label2, label3, label4);
6201 __builtin_unreachable ();
6202
6203 label1:
6204 f1();
6205 return;
6206 label2:
6207 f2();
6208 return;
6209 label3:
6210 i = 1;
6211 label4:
6212 f3(i);
6213 @}
6214 @end smallexample
6215
6216 In this (also inefficient) example, the @code{mfsr} instruction reads
6217 an address from some out-of-band machine register, and the following
6218 @code{jmp} instruction branches to that address. The address read by
6219 the @code{mfsr} instruction is assumed to have been previously set via
6220 some application-specific mechanism to be one of the four values stored
6221 in the @code{doit_table} section. Finally, the @code{asm} is followed
6222 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6223 does not in fact fall through.
6224
6225 @smallexample
6226 #define TRACE1(NUM) \
6227 do @{ \
6228 asm goto ("0: nop;" \
6229 ".pushsection trace_table;" \
6230 ".long 0b, %l0;" \
6231 ".popsection" \
6232 : : : : trace#NUM); \
6233 if (0) @{ trace#NUM: trace(); @} \
6234 @} while (0)
6235 #define TRACE TRACE1(__COUNTER__)
6236 @end smallexample
6237
6238 In this example (which in fact inspired the @code{asm goto} feature)
6239 we want on rare occasions to call the @code{trace} function; on other
6240 occasions we'd like to keep the overhead to the absolute minimum.
6241 The normal code path consists of a single @code{nop} instruction.
6242 However, we record the address of this @code{nop} together with the
6243 address of a label that calls the @code{trace} function. This allows
6244 the @code{nop} instruction to be patched at runtime to be an
6245 unconditional branch to the stored label. It is assumed that an
6246 optimizing compiler moves the labeled block out of line, to
6247 optimize the fall through path from the @code{asm}.
6248
6249 If you are writing a header file that should be includable in ISO C
6250 programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate
6251 Keywords}.
6252
6253 @subsection Size of an @code{asm}
6254
6255 Some targets require that GCC track the size of each instruction used in
6256 order to generate correct code. Because the final length of an
6257 @code{asm} is only known by the assembler, GCC must make an estimate as
6258 to how big it will be. The estimate is formed by counting the number of
6259 statements in the pattern of the @code{asm} and multiplying that by the
6260 length of the longest instruction on that processor. Statements in the
6261 @code{asm} are identified by newline characters and whatever statement
6262 separator characters are supported by the assembler; on most processors
6263 this is the `@code{;}' character.
6264
6265 Normally, GCC's estimate is perfectly adequate to ensure that correct
6266 code is generated, but it is possible to confuse the compiler if you use
6267 pseudo instructions or assembler macros that expand into multiple real
6268 instructions or if you use assembler directives that expand to more
6269 space in the object file than is needed for a single instruction.
6270 If this happens then the assembler produces a diagnostic saying that
6271 a label is unreachable.
6272
6273 @subsection i386 floating point asm operands
6274
6275 There are several rules on the usage of stack-like regs in
6276 asm_operands insns. These rules apply only to the operands that are
6277 stack-like regs:
6278
6279 @enumerate
6280 @item
6281 Given a set of input regs that die in an asm_operands, it is
6282 necessary to know which are implicitly popped by the asm, and
6283 which must be explicitly popped by gcc.
6284
6285 An input reg that is implicitly popped by the asm must be
6286 explicitly clobbered, unless it is constrained to match an
6287 output operand.
6288
6289 @item
6290 For any input reg that is implicitly popped by an asm, it is
6291 necessary to know how to adjust the stack to compensate for the pop.
6292 If any non-popped input is closer to the top of the reg-stack than
6293 the implicitly popped reg, it would not be possible to know what the
6294 stack looked like---it's not clear how the rest of the stack ``slides
6295 up''.
6296
6297 All implicitly popped input regs must be closer to the top of
6298 the reg-stack than any input that is not implicitly popped.
6299
6300 It is possible that if an input dies in an insn, reload might
6301 use the input reg for an output reload. Consider this example:
6302
6303 @smallexample
6304 asm ("foo" : "=t" (a) : "f" (b));
6305 @end smallexample
6306
6307 This asm says that input B is not popped by the asm, and that
6308 the asm pushes a result onto the reg-stack, i.e., the stack is one
6309 deeper after the asm than it was before. But, it is possible that
6310 reload thinks that it can use the same reg for both the input and
6311 the output, if input B dies in this insn.
6312
6313 If any input operand uses the @code{f} constraint, all output reg
6314 constraints must use the @code{&} earlyclobber.
6315
6316 The asm above would be written as
6317
6318 @smallexample
6319 asm ("foo" : "=&t" (a) : "f" (b));
6320 @end smallexample
6321
6322 @item
6323 Some operands need to be in particular places on the stack. All
6324 output operands fall in this category---there is no other way to
6325 know which regs the outputs appear in unless the user indicates
6326 this in the constraints.
6327
6328 Output operands must specifically indicate which reg an output
6329 appears in after an asm. @code{=f} is not allowed: the operand
6330 constraints must select a class with a single reg.
6331
6332 @item
6333 Output operands may not be ``inserted'' between existing stack regs.
6334 Since no 387 opcode uses a read/write operand, all output operands
6335 are dead before the asm_operands, and are pushed by the asm_operands.
6336 It makes no sense to push anywhere but the top of the reg-stack.
6337
6338 Output operands must start at the top of the reg-stack: output
6339 operands may not ``skip'' a reg.
6340
6341 @item
6342 Some asm statements may need extra stack space for internal
6343 calculations. This can be guaranteed by clobbering stack registers
6344 unrelated to the inputs and outputs.
6345
6346 @end enumerate
6347
6348 Here are a couple of reasonable asms to want to write. This asm
6349 takes one input, which is internally popped, and produces two outputs.
6350
6351 @smallexample
6352 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6353 @end smallexample
6354
6355 This asm takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6356 and replaces them with one output. The user must code the @code{st(1)}
6357 clobber for reg-stack.c to know that @code{fyl2xp1} pops both inputs.
6358
6359 @smallexample
6360 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6361 @end smallexample
6362
6363 @include md.texi
6364
6365 @node Asm Labels
6366 @section Controlling Names Used in Assembler Code
6367 @cindex assembler names for identifiers
6368 @cindex names used in assembler code
6369 @cindex identifiers, names in assembler code
6370
6371 You can specify the name to be used in the assembler code for a C
6372 function or variable by writing the @code{asm} (or @code{__asm__})
6373 keyword after the declarator as follows:
6374
6375 @smallexample
6376 int foo asm ("myfoo") = 2;
6377 @end smallexample
6378
6379 @noindent
6380 This specifies that the name to be used for the variable @code{foo} in
6381 the assembler code should be @samp{myfoo} rather than the usual
6382 @samp{_foo}.
6383
6384 On systems where an underscore is normally prepended to the name of a C
6385 function or variable, this feature allows you to define names for the
6386 linker that do not start with an underscore.
6387
6388 It does not make sense to use this feature with a non-static local
6389 variable since such variables do not have assembler names. If you are
6390 trying to put the variable in a particular register, see @ref{Explicit
6391 Reg Vars}. GCC presently accepts such code with a warning, but will
6392 probably be changed to issue an error, rather than a warning, in the
6393 future.
6394
6395 You cannot use @code{asm} in this way in a function @emph{definition}; but
6396 you can get the same effect by writing a declaration for the function
6397 before its definition and putting @code{asm} there, like this:
6398
6399 @smallexample
6400 extern func () asm ("FUNC");
6401
6402 func (x, y)
6403 int x, y;
6404 /* @r{@dots{}} */
6405 @end smallexample
6406
6407 It is up to you to make sure that the assembler names you choose do not
6408 conflict with any other assembler symbols. Also, you must not use a
6409 register name; that would produce completely invalid assembler code. GCC
6410 does not as yet have the ability to store static variables in registers.
6411 Perhaps that will be added.
6412
6413 @node Explicit Reg Vars
6414 @section Variables in Specified Registers
6415 @cindex explicit register variables
6416 @cindex variables in specified registers
6417 @cindex specified registers
6418 @cindex registers, global allocation
6419
6420 GNU C allows you to put a few global variables into specified hardware
6421 registers. You can also specify the register in which an ordinary
6422 register variable should be allocated.
6423
6424 @itemize @bullet
6425 @item
6426 Global register variables reserve registers throughout the program.
6427 This may be useful in programs such as programming language
6428 interpreters which have a couple of global variables that are accessed
6429 very often.
6430
6431 @item
6432 Local register variables in specific registers do not reserve the
6433 registers, except at the point where they are used as input or output
6434 operands in an @code{asm} statement and the @code{asm} statement itself is
6435 not deleted. The compiler's data flow analysis is capable of determining
6436 where the specified registers contain live values, and where they are
6437 available for other uses. Stores into local register variables may be deleted
6438 when they appear to be dead according to dataflow analysis. References
6439 to local register variables may be deleted or moved or simplified.
6440
6441 These local variables are sometimes convenient for use with the extended
6442 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6443 output of the assembler instruction directly into a particular register.
6444 (This works provided the register you specify fits the constraints
6445 specified for that operand in the @code{asm}.)
6446 @end itemize
6447
6448 @menu
6449 * Global Reg Vars::
6450 * Local Reg Vars::
6451 @end menu
6452
6453 @node Global Reg Vars
6454 @subsection Defining Global Register Variables
6455 @cindex global register variables
6456 @cindex registers, global variables in
6457
6458 You can define a global register variable in GNU C like this:
6459
6460 @smallexample
6461 register int *foo asm ("a5");
6462 @end smallexample
6463
6464 @noindent
6465 Here @code{a5} is the name of the register which should be used. Choose a
6466 register which is normally saved and restored by function calls on your
6467 machine, so that library routines will not clobber it.
6468
6469 Naturally the register name is cpu-dependent, so you need to
6470 conditionalize your program according to cpu type. The register
6471 @code{a5} is a good choice on a 68000 for a variable of pointer
6472 type. On machines with register windows, be sure to choose a ``global''
6473 register that is not affected magically by the function call mechanism.
6474
6475 In addition, operating systems on one type of cpu may differ in how they
6476 name the registers; then you need additional conditionals. For
6477 example, some 68000 operating systems call this register @code{%a5}.
6478
6479 Eventually there may be a way of asking the compiler to choose a register
6480 automatically, but first we need to figure out how it should choose and
6481 how to enable you to guide the choice. No solution is evident.
6482
6483 Defining a global register variable in a certain register reserves that
6484 register entirely for this use, at least within the current compilation.
6485 The register is not allocated for any other purpose in the functions
6486 in the current compilation, and is not saved and restored by
6487 these functions. Stores into this register are never deleted even if they
6488 appear to be dead, but references may be deleted or moved or
6489 simplified.
6490
6491 It is not safe to access the global register variables from signal
6492 handlers, or from more than one thread of control, because the system
6493 library routines may temporarily use the register for other things (unless
6494 you recompile them specially for the task at hand).
6495
6496 @cindex @code{qsort}, and global register variables
6497 It is not safe for one function that uses a global register variable to
6498 call another such function @code{foo} by way of a third function
6499 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6500 different source file in which the variable isn't declared). This is
6501 because @code{lose} might save the register and put some other value there.
6502 For example, you can't expect a global register variable to be available in
6503 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6504 might have put something else in that register. (If you are prepared to
6505 recompile @code{qsort} with the same global register variable, you can
6506 solve this problem.)
6507
6508 If you want to recompile @code{qsort} or other source files which do not
6509 actually use your global register variable, so that they do not use that
6510 register for any other purpose, then it suffices to specify the compiler
6511 option @option{-ffixed-@var{reg}}. You need not actually add a global
6512 register declaration to their source code.
6513
6514 A function which can alter the value of a global register variable cannot
6515 safely be called from a function compiled without this variable, because it
6516 could clobber the value the caller expects to find there on return.
6517 Therefore, the function which is the entry point into the part of the
6518 program that uses the global register variable must explicitly save and
6519 restore the value which belongs to its caller.
6520
6521 @cindex register variable after @code{longjmp}
6522 @cindex global register after @code{longjmp}
6523 @cindex value after @code{longjmp}
6524 @findex longjmp
6525 @findex setjmp
6526 On most machines, @code{longjmp} restores to each global register
6527 variable the value it had at the time of the @code{setjmp}. On some
6528 machines, however, @code{longjmp} does not change the value of global
6529 register variables. To be portable, the function that called @code{setjmp}
6530 should make other arrangements to save the values of the global register
6531 variables, and to restore them in a @code{longjmp}. This way, the same
6532 thing happens regardless of what @code{longjmp} does.
6533
6534 All global register variable declarations must precede all function
6535 definitions. If such a declaration could appear after function
6536 definitions, the declaration would be too late to prevent the register from
6537 being used for other purposes in the preceding functions.
6538
6539 Global register variables may not have initial values, because an
6540 executable file has no means to supply initial contents for a register.
6541
6542 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6543 registers, but certain library functions, such as @code{getwd}, as well
6544 as the subroutines for division and remainder, modify g3 and g4. g1 and
6545 g2 are local temporaries.
6546
6547 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6548 Of course, it does not do to use more than a few of those.
6549
6550 @node Local Reg Vars
6551 @subsection Specifying Registers for Local Variables
6552 @cindex local variables, specifying registers
6553 @cindex specifying registers for local variables
6554 @cindex registers for local variables
6555
6556 You can define a local register variable with a specified register
6557 like this:
6558
6559 @smallexample
6560 register int *foo asm ("a5");
6561 @end smallexample
6562
6563 @noindent
6564 Here @code{a5} is the name of the register which should be used. Note
6565 that this is the same syntax used for defining global register
6566 variables, but for a local variable it appears within a function.
6567
6568 Naturally the register name is cpu-dependent, but this is not a
6569 problem, since specific registers are most often useful with explicit
6570 assembler instructions (@pxref{Extended Asm}). Both of these things
6571 generally require that you conditionalize your program according to
6572 cpu type.
6573
6574 In addition, operating systems on one type of cpu may differ in how they
6575 name the registers; then you need additional conditionals. For
6576 example, some 68000 operating systems call this register @code{%a5}.
6577
6578 Defining such a register variable does not reserve the register; it
6579 remains available for other uses in places where flow control determines
6580 the variable's value is not live.
6581
6582 This option does not guarantee that GCC generates code that has
6583 this variable in the register you specify at all times. You may not
6584 code an explicit reference to this register in the @emph{assembler
6585 instruction template} part of an @code{asm} statement and assume it
6586 always refers to this variable. However, using the variable as an
6587 @code{asm} @emph{operand} guarantees that the specified register is used
6588 for the operand.
6589
6590 Stores into local register variables may be deleted when they appear to be dead
6591 according to dataflow analysis. References to local register variables may
6592 be deleted or moved or simplified.
6593
6594 As for global register variables, it's recommended that you choose a
6595 register which is normally saved and restored by function calls on
6596 your machine, so that library routines will not clobber it. A common
6597 pitfall is to initialize multiple call-clobbered registers with
6598 arbitrary expressions, where a function call or library call for an
6599 arithmetic operator overwrites a register value from a previous
6600 assignment, for example @code{r0} below:
6601 @smallexample
6602 register int *p1 asm ("r0") = @dots{};
6603 register int *p2 asm ("r1") = @dots{};
6604 @end smallexample
6605 In those cases, a solution is to use a temporary variable for
6606 each arbitrary expression. @xref{Example of asm with clobbered asm reg}.
6607
6608 @node Alternate Keywords
6609 @section Alternate Keywords
6610 @cindex alternate keywords
6611 @cindex keywords, alternate
6612
6613 @option{-ansi} and the various @option{-std} options disable certain
6614 keywords. This causes trouble when you want to use GNU C extensions, or
6615 a general-purpose header file that should be usable by all programs,
6616 including ISO C programs. The keywords @code{asm}, @code{typeof} and
6617 @code{inline} are not available in programs compiled with
6618 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6619 program compiled with @option{-std=c99} or @option{-std=c11}). The
6620 ISO C99 keyword
6621 @code{restrict} is only available when @option{-std=gnu99} (which will
6622 eventually be the default) or @option{-std=c99} (or the equivalent
6623 @option{-std=iso9899:1999}), or an option for a later standard
6624 version, is used.
6625
6626 The way to solve these problems is to put @samp{__} at the beginning and
6627 end of each problematical keyword. For example, use @code{__asm__}
6628 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6629
6630 Other C compilers won't accept these alternative keywords; if you want to
6631 compile with another compiler, you can define the alternate keywords as
6632 macros to replace them with the customary keywords. It looks like this:
6633
6634 @smallexample
6635 #ifndef __GNUC__
6636 #define __asm__ asm
6637 #endif
6638 @end smallexample
6639
6640 @findex __extension__
6641 @opindex pedantic
6642 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6643 You can
6644 prevent such warnings within one expression by writing
6645 @code{__extension__} before the expression. @code{__extension__} has no
6646 effect aside from this.
6647
6648 @node Incomplete Enums
6649 @section Incomplete @code{enum} Types
6650
6651 You can define an @code{enum} tag without specifying its possible values.
6652 This results in an incomplete type, much like what you get if you write
6653 @code{struct foo} without describing the elements. A later declaration
6654 which does specify the possible values completes the type.
6655
6656 You can't allocate variables or storage using the type while it is
6657 incomplete. However, you can work with pointers to that type.
6658
6659 This extension may not be very useful, but it makes the handling of
6660 @code{enum} more consistent with the way @code{struct} and @code{union}
6661 are handled.
6662
6663 This extension is not supported by GNU C++.
6664
6665 @node Function Names
6666 @section Function Names as Strings
6667 @cindex @code{__func__} identifier
6668 @cindex @code{__FUNCTION__} identifier
6669 @cindex @code{__PRETTY_FUNCTION__} identifier
6670
6671 GCC provides three magic variables which hold the name of the current
6672 function, as a string. The first of these is @code{__func__}, which
6673 is part of the C99 standard:
6674
6675 The identifier @code{__func__} is implicitly declared by the translator
6676 as if, immediately following the opening brace of each function
6677 definition, the declaration
6678
6679 @smallexample
6680 static const char __func__[] = "function-name";
6681 @end smallexample
6682
6683 @noindent
6684 appeared, where function-name is the name of the lexically-enclosing
6685 function. This name is the unadorned name of the function.
6686
6687 @code{__FUNCTION__} is another name for @code{__func__}. Older
6688 versions of GCC recognize only this name. However, it is not
6689 standardized. For maximum portability, we recommend you use
6690 @code{__func__}, but provide a fallback definition with the
6691 preprocessor:
6692
6693 @smallexample
6694 #if __STDC_VERSION__ < 199901L
6695 # if __GNUC__ >= 2
6696 # define __func__ __FUNCTION__
6697 # else
6698 # define __func__ "<unknown>"
6699 # endif
6700 #endif
6701 @end smallexample
6702
6703 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6704 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
6705 the type signature of the function as well as its bare name. For
6706 example, this program:
6707
6708 @smallexample
6709 extern "C" @{
6710 extern int printf (char *, ...);
6711 @}
6712
6713 class a @{
6714 public:
6715 void sub (int i)
6716 @{
6717 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6718 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6719 @}
6720 @};
6721
6722 int
6723 main (void)
6724 @{
6725 a ax;
6726 ax.sub (0);
6727 return 0;
6728 @}
6729 @end smallexample
6730
6731 @noindent
6732 gives this output:
6733
6734 @smallexample
6735 __FUNCTION__ = sub
6736 __PRETTY_FUNCTION__ = void a::sub(int)
6737 @end smallexample
6738
6739 These identifiers are not preprocessor macros. In GCC 3.3 and
6740 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6741 were treated as string literals; they could be used to initialize
6742 @code{char} arrays, and they could be concatenated with other string
6743 literals. GCC 3.4 and later treat them as variables, like
6744 @code{__func__}. In C++, @code{__FUNCTION__} and
6745 @code{__PRETTY_FUNCTION__} have always been variables.
6746
6747 @node Return Address
6748 @section Getting the Return or Frame Address of a Function
6749
6750 These functions may be used to get information about the callers of a
6751 function.
6752
6753 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6754 This function returns the return address of the current function, or of
6755 one of its callers. The @var{level} argument is number of frames to
6756 scan up the call stack. A value of @code{0} yields the return address
6757 of the current function, a value of @code{1} yields the return address
6758 of the caller of the current function, and so forth. When inlining
6759 the expected behavior is that the function returns the address of
6760 the function that is returned to. To work around this behavior use
6761 the @code{noinline} function attribute.
6762
6763 The @var{level} argument must be a constant integer.
6764
6765 On some machines it may be impossible to determine the return address of
6766 any function other than the current one; in such cases, or when the top
6767 of the stack has been reached, this function returns @code{0} or a
6768 random value. In addition, @code{__builtin_frame_address} may be used
6769 to determine if the top of the stack has been reached.
6770
6771 Additional post-processing of the returned value may be needed, see
6772 @code{__builtin_extract_return_addr}.
6773
6774 This function should only be used with a nonzero argument for debugging
6775 purposes.
6776 @end deftypefn
6777
6778 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
6779 The address as returned by @code{__builtin_return_address} may have to be fed
6780 through this function to get the actual encoded address. For example, on the
6781 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6782 platforms an offset has to be added for the true next instruction to be
6783 executed.
6784
6785 If no fixup is needed, this function simply passes through @var{addr}.
6786 @end deftypefn
6787
6788 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6789 This function does the reverse of @code{__builtin_extract_return_addr}.
6790 @end deftypefn
6791
6792 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6793 This function is similar to @code{__builtin_return_address}, but it
6794 returns the address of the function frame rather than the return address
6795 of the function. Calling @code{__builtin_frame_address} with a value of
6796 @code{0} yields the frame address of the current function, a value of
6797 @code{1} yields the frame address of the caller of the current function,
6798 and so forth.
6799
6800 The frame is the area on the stack which holds local variables and saved
6801 registers. The frame address is normally the address of the first word
6802 pushed on to the stack by the function. However, the exact definition
6803 depends upon the processor and the calling convention. If the processor
6804 has a dedicated frame pointer register, and the function has a frame,
6805 then @code{__builtin_frame_address} returns the value of the frame
6806 pointer register.
6807
6808 On some machines it may be impossible to determine the frame address of
6809 any function other than the current one; in such cases, or when the top
6810 of the stack has been reached, this function returns @code{0} if
6811 the first frame pointer is properly initialized by the startup code.
6812
6813 This function should only be used with a nonzero argument for debugging
6814 purposes.
6815 @end deftypefn
6816
6817 @node Vector Extensions
6818 @section Using vector instructions through built-in functions
6819
6820 On some targets, the instruction set contains SIMD vector instructions that
6821 operate on multiple values contained in one large register at the same time.
6822 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6823 this way.
6824
6825 The first step in using these extensions is to provide the necessary data
6826 types. This should be done using an appropriate @code{typedef}:
6827
6828 @smallexample
6829 typedef int v4si __attribute__ ((vector_size (16)));
6830 @end smallexample
6831
6832 The @code{int} type specifies the base type, while the attribute specifies
6833 the vector size for the variable, measured in bytes. For example, the
6834 declaration above causes the compiler to set the mode for the @code{v4si}
6835 type to be 16 bytes wide and divided into @code{int} sized units. For
6836 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6837 corresponding mode of @code{foo} is @acronym{V4SI}.
6838
6839 The @code{vector_size} attribute is only applicable to integral and
6840 float scalars, although arrays, pointers, and function return values
6841 are allowed in conjunction with this construct. Only power of two
6842 sizes are currently allowed.
6843
6844 All the basic integer types can be used as base types, both as signed
6845 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6846 @code{long long}. In addition, @code{float} and @code{double} can be
6847 used to build floating-point vector types.
6848
6849 Specifying a combination that is not valid for the current architecture
6850 causes GCC to synthesize the instructions using a narrower mode.
6851 For example, if you specify a variable of type @code{V4SI} and your
6852 architecture does not allow for this specific SIMD type, GCC
6853 produces code that uses 4 @code{SIs}.
6854
6855 The types defined in this manner can be used with a subset of normal C
6856 operations. Currently, GCC allows using the following operators
6857 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6858
6859 The operations behave like C++ @code{valarrays}. Addition is defined as
6860 the addition of the corresponding elements of the operands. For
6861 example, in the code below, each of the 4 elements in @var{a} is
6862 added to the corresponding 4 elements in @var{b} and the resulting
6863 vector is stored in @var{c}.
6864
6865 @smallexample
6866 typedef int v4si __attribute__ ((vector_size (16)));
6867
6868 v4si a, b, c;
6869
6870 c = a + b;
6871 @end smallexample
6872
6873 Subtraction, multiplication, division, and the logical operations
6874 operate in a similar manner. Likewise, the result of using the unary
6875 minus or complement operators on a vector type is a vector whose
6876 elements are the negative or complemented values of the corresponding
6877 elements in the operand.
6878
6879 It is possible to use shifting operators @code{<<}, @code{>>} on
6880 integer-type vectors. The operation is defined as following: @code{@{a0,
6881 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
6882 @dots{}, an >> bn@}}@. Vector operands must have the same number of
6883 elements.
6884
6885 For convenience, it is allowed to use a binary vector operation
6886 where one operand is a scalar. In that case the compiler transforms
6887 the scalar operand into a vector where each element is the scalar from
6888 the operation. The transformation happens only if the scalar could be
6889 safely converted to the vector-element type.
6890 Consider the following code.
6891
6892 @smallexample
6893 typedef int v4si __attribute__ ((vector_size (16)));
6894
6895 v4si a, b, c;
6896 long l;
6897
6898 a = b + 1; /* a = b + @{1,1,1,1@}; */
6899 a = 2 * b; /* a = @{2,2,2,2@} * b; */
6900
6901 a = l + a; /* Error, cannot convert long to int. */
6902 @end smallexample
6903
6904 Vectors can be subscripted as if the vector were an array with
6905 the same number of elements and base type. Out of bound accesses
6906 invoke undefined behavior at runtime. Warnings for out of bound
6907 accesses for vector subscription can be enabled with
6908 @option{-Warray-bounds}.
6909
6910 Vector comparison is supported with standard comparison
6911 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
6912 vector expressions of integer-type or real-type. Comparison between
6913 integer-type vectors and real-type vectors are not supported. The
6914 result of the comparison is a vector of the same width and number of
6915 elements as the comparison operands with a signed integral element
6916 type.
6917
6918 Vectors are compared element-wise producing 0 when comparison is false
6919 and -1 (constant of the appropriate type where all bits are set)
6920 otherwise. Consider the following example.
6921
6922 @smallexample
6923 typedef int v4si __attribute__ ((vector_size (16)));
6924
6925 v4si a = @{1,2,3,4@};
6926 v4si b = @{3,2,1,4@};
6927 v4si c;
6928
6929 c = a > b; /* The result would be @{0, 0,-1, 0@} */
6930 c = a == b; /* The result would be @{0,-1, 0,-1@} */
6931 @end smallexample
6932
6933 Vector shuffling is available using functions
6934 @code{__builtin_shuffle (vec, mask)} and
6935 @code{__builtin_shuffle (vec0, vec1, mask)}.
6936 Both functions construct a permutation of elements from one or two
6937 vectors and return a vector of the same type as the input vector(s).
6938 The @var{mask} is an integral vector with the same width (@var{W})
6939 and element count (@var{N}) as the output vector.
6940
6941 The elements of the input vectors are numbered in memory ordering of
6942 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
6943 elements of @var{mask} are considered modulo @var{N} in the single-operand
6944 case and modulo @math{2*@var{N}} in the two-operand case.
6945
6946 Consider the following example,
6947
6948 @smallexample
6949 typedef int v4si __attribute__ ((vector_size (16)));
6950
6951 v4si a = @{1,2,3,4@};
6952 v4si b = @{5,6,7,8@};
6953 v4si mask1 = @{0,1,1,3@};
6954 v4si mask2 = @{0,4,2,5@};
6955 v4si res;
6956
6957 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
6958 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
6959 @end smallexample
6960
6961 Note that @code{__builtin_shuffle} is intentionally semantically
6962 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
6963
6964 You can declare variables and use them in function calls and returns, as
6965 well as in assignments and some casts. You can specify a vector type as
6966 a return type for a function. Vector types can also be used as function
6967 arguments. It is possible to cast from one vector type to another,
6968 provided they are of the same size (in fact, you can also cast vectors
6969 to and from other datatypes of the same size).
6970
6971 You cannot operate between vectors of different lengths or different
6972 signedness without a cast.
6973
6974 @node Offsetof
6975 @section Offsetof
6976 @findex __builtin_offsetof
6977
6978 GCC implements for both C and C++ a syntactic extension to implement
6979 the @code{offsetof} macro.
6980
6981 @smallexample
6982 primary:
6983 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
6984
6985 offsetof_member_designator:
6986 @code{identifier}
6987 | offsetof_member_designator "." @code{identifier}
6988 | offsetof_member_designator "[" @code{expr} "]"
6989 @end smallexample
6990
6991 This extension is sufficient such that
6992
6993 @smallexample
6994 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
6995 @end smallexample
6996
6997 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
6998 may be dependent. In either case, @var{member} may consist of a single
6999 identifier, or a sequence of member accesses and array references.
7000
7001 @node __sync Builtins
7002 @section Legacy __sync built-in functions for atomic memory access
7003
7004 The following builtins are intended to be compatible with those described
7005 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7006 section 7.4. As such, they depart from the normal GCC practice of using
7007 the ``__builtin_'' prefix, and further that they are overloaded such that
7008 they work on multiple types.
7009
7010 The definition given in the Intel documentation allows only for the use of
7011 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7012 counterparts. GCC allows any integral scalar or pointer type that is
7013 1, 2, 4 or 8 bytes in length.
7014
7015 Not all operations are supported by all target processors. If a particular
7016 operation cannot be implemented on the target processor, a warning is
7017 generated and a call an external function is generated. The external
7018 function carries the same name as the builtin, with an additional suffix
7019 @samp{_@var{n}} where @var{n} is the size of the data type.
7020
7021 @c ??? Should we have a mechanism to suppress this warning? This is almost
7022 @c useful for implementing the operation under the control of an external
7023 @c mutex.
7024
7025 In most cases, these builtins are considered a @dfn{full barrier}. That is,
7026 no memory operand is moved across the operation, either forward or
7027 backward. Further, instructions are issued as necessary to prevent the
7028 processor from speculating loads across the operation and from queuing stores
7029 after the operation.
7030
7031 All of the routines are described in the Intel documentation to take
7032 ``an optional list of variables protected by the memory barrier''. It's
7033 not clear what is meant by that; it could mean that @emph{only} the
7034 following variables are protected, or it could mean that these variables
7035 should in addition be protected. At present GCC ignores this list and
7036 protects all variables which are globally accessible. If in the future
7037 we make some use of this list, an empty list will continue to mean all
7038 globally accessible variables.
7039
7040 @table @code
7041 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7042 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7043 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7044 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7045 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7046 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7047 @findex __sync_fetch_and_add
7048 @findex __sync_fetch_and_sub
7049 @findex __sync_fetch_and_or
7050 @findex __sync_fetch_and_and
7051 @findex __sync_fetch_and_xor
7052 @findex __sync_fetch_and_nand
7053 These builtins perform the operation suggested by the name, and
7054 returns the value that had previously been in memory. That is,
7055
7056 @smallexample
7057 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7058 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
7059 @end smallexample
7060
7061 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7062 builtin as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7063
7064 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7065 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7066 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7067 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7068 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7069 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7070 @findex __sync_add_and_fetch
7071 @findex __sync_sub_and_fetch
7072 @findex __sync_or_and_fetch
7073 @findex __sync_and_and_fetch
7074 @findex __sync_xor_and_fetch
7075 @findex __sync_nand_and_fetch
7076 These builtins perform the operation suggested by the name, and
7077 return the new value. That is,
7078
7079 @smallexample
7080 @{ *ptr @var{op}= value; return *ptr; @}
7081 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
7082 @end smallexample
7083
7084 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7085 builtin as @code{*ptr = ~(*ptr & value)} instead of
7086 @code{*ptr = ~*ptr & value}.
7087
7088 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7089 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7090 @findex __sync_bool_compare_and_swap
7091 @findex __sync_val_compare_and_swap
7092 These builtins perform an atomic compare and swap. That is, if the current
7093 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7094 @code{*@var{ptr}}.
7095
7096 The ``bool'' version returns true if the comparison is successful and
7097 @var{newval} is written. The ``val'' version returns the contents
7098 of @code{*@var{ptr}} before the operation.
7099
7100 @item __sync_synchronize (...)
7101 @findex __sync_synchronize
7102 This builtin issues a full memory barrier.
7103
7104 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7105 @findex __sync_lock_test_and_set
7106 This builtin, as described by Intel, is not a traditional test-and-set
7107 operation, but rather an atomic exchange operation. It writes @var{value}
7108 into @code{*@var{ptr}}, and returns the previous contents of
7109 @code{*@var{ptr}}.
7110
7111 Many targets have only minimal support for such locks, and do not support
7112 a full exchange operation. In this case, a target may support reduced
7113 functionality here by which the @emph{only} valid value to store is the
7114 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
7115 is implementation defined.
7116
7117 This builtin is not a full barrier, but rather an @dfn{acquire barrier}.
7118 This means that references after the builtin cannot move to (or be
7119 speculated to) before the builtin, but previous memory stores may not
7120 be globally visible yet, and previous memory loads may not yet be
7121 satisfied.
7122
7123 @item void __sync_lock_release (@var{type} *ptr, ...)
7124 @findex __sync_lock_release
7125 This builtin releases the lock acquired by @code{__sync_lock_test_and_set}.
7126 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7127
7128 This builtin is not a full barrier, but rather a @dfn{release barrier}.
7129 This means that all previous memory stores are globally visible, and all
7130 previous memory loads have been satisfied, but following memory reads
7131 are not prevented from being speculated to before the barrier.
7132 @end table
7133
7134 @node __atomic Builtins
7135 @section Built-in functions for memory model aware atomic operations
7136
7137 The following built-in functions approximately match the requirements for
7138 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7139 functions, but all also have a memory model parameter. These are all
7140 identified by being prefixed with @samp{__atomic}, and most are overloaded
7141 such that they work with multiple types.
7142
7143 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7144 bytes in length. 16-byte integral types are also allowed if
7145 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7146
7147 Target architectures are encouraged to provide their own patterns for
7148 each of these built-in functions. If no target is provided, the original
7149 non-memory model set of @samp{__sync} atomic built-in functions are
7150 utilized, along with any required synchronization fences surrounding it in
7151 order to achieve the proper behaviour. Execution in this case is subject
7152 to the same restrictions as those built-in functions.
7153
7154 If there is no pattern or mechanism to provide a lock free instruction
7155 sequence, a call is made to an external routine with the same parameters
7156 to be resolved at runtime.
7157
7158 The four non-arithmetic functions (load, store, exchange, and
7159 compare_exchange) all have a generic version as well. This generic
7160 version works on any data type. If the data type size maps to one
7161 of the integral sizes which may have lock free support, the generic
7162 version utilizes the lock free built-in function. Otherwise an
7163 external call is left to be resolved at runtime. This external call is
7164 the same format with the addition of a @samp{size_t} parameter inserted
7165 as the first parameter indicating the size of the object being pointed to.
7166 All objects must be the same size.
7167
7168 There are 6 different memory models which can be specified. These map
7169 to the same names in the C++11 standard. Refer there or to the
7170 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7171 atomic synchronization} for more detailed definitions. These memory
7172 models integrate both barriers to code motion as well as synchronization
7173 requirements with other threads. These are listed in approximately
7174 ascending order of strength. It is also possible to use target specific
7175 flags for memory model flags, like Hardware Lock Elision.
7176
7177 @table @code
7178 @item __ATOMIC_RELAXED
7179 No barriers or synchronization.
7180 @item __ATOMIC_CONSUME
7181 Data dependency only for both barrier and synchronization with another
7182 thread.
7183 @item __ATOMIC_ACQUIRE
7184 Barrier to hoisting of code and synchronizes with release (or stronger)
7185 semantic stores from another thread.
7186 @item __ATOMIC_RELEASE
7187 Barrier to sinking of code and synchronizes with acquire (or stronger)
7188 semantic loads from another thread.
7189 @item __ATOMIC_ACQ_REL
7190 Full barrier in both directions and synchronizes with acquire loads and
7191 release stores in another thread.
7192 @item __ATOMIC_SEQ_CST
7193 Full barrier in both directions and synchronizes with acquire loads and
7194 release stores in all threads.
7195 @end table
7196
7197 When implementing patterns for these built-in functions, the memory model
7198 parameter can be ignored as long as the pattern implements the most
7199 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
7200 execute correctly with this memory model but they may not execute as
7201 efficiently as they could with a more appropriate implemention of the
7202 relaxed requirements.
7203
7204 Note that the C++11 standard allows for the memory model parameter to be
7205 determined at runtime rather than at compile time. These built-in
7206 functions map any runtime value to @code{__ATOMIC_SEQ_CST} rather
7207 than invoke a runtime library call or inline a switch statement. This is
7208 standard compliant, safe, and the simplest approach for now.
7209
7210 The memory model parameter is a signed int, but only the lower 8 bits are
7211 reserved for the memory model. The remainder of the signed int is reserved
7212 for future use and should be 0. Use of the predefined atomic values
7213 ensures proper usage.
7214
7215 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7216 This built-in function implements an atomic load operation. It returns the
7217 contents of @code{*@var{ptr}}.
7218
7219 The valid memory model variants are
7220 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7221 and @code{__ATOMIC_CONSUME}.
7222
7223 @end deftypefn
7224
7225 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7226 This is the generic version of an atomic load. It returns the
7227 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7228
7229 @end deftypefn
7230
7231 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7232 This built-in function implements an atomic store operation. It writes
7233 @code{@var{val}} into @code{*@var{ptr}}.
7234
7235 The valid memory model variants are
7236 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7237
7238 @end deftypefn
7239
7240 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7241 This is the generic version of an atomic store. It stores the value
7242 of @code{*@var{val}} into @code{*@var{ptr}}.
7243
7244 @end deftypefn
7245
7246 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7247 This built-in function implements an atomic exchange operation. It writes
7248 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7249 @code{*@var{ptr}}.
7250
7251 The valid memory model variants are
7252 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7253 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7254
7255 @end deftypefn
7256
7257 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7258 This is the generic version of an atomic exchange. It stores the
7259 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7260 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7261
7262 @end deftypefn
7263
7264 @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)
7265 This built-in function implements an atomic compare and exchange operation.
7266 This compares the contents of @code{*@var{ptr}} with the contents of
7267 @code{*@var{expected}} and if equal, writes @var{desired} into
7268 @code{*@var{ptr}}. If they are not equal, the current contents of
7269 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
7270 for weak compare_exchange, and false for the strong variation. Many targets
7271 only offer the strong variation and ignore the parameter. When in doubt, use
7272 the strong variation.
7273
7274 True is returned if @var{desired} is written into
7275 @code{*@var{ptr}} and the execution is considered to conform to the
7276 memory model specified by @var{success_memmodel}. There are no
7277 restrictions on what memory model can be used here.
7278
7279 False is returned otherwise, and the execution is considered to conform
7280 to @var{failure_memmodel}. This memory model cannot be
7281 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
7282 stronger model than that specified by @var{success_memmodel}.
7283
7284 @end deftypefn
7285
7286 @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)
7287 This built-in function implements the generic version of
7288 @code{__atomic_compare_exchange}. The function is virtually identical to
7289 @code{__atomic_compare_exchange_n}, except the desired value is also a
7290 pointer.
7291
7292 @end deftypefn
7293
7294 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7295 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7296 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7297 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7298 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7299 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7300 These built-in functions perform the operation suggested by the name, and
7301 return the result of the operation. That is,
7302
7303 @smallexample
7304 @{ *ptr @var{op}= val; return *ptr; @}
7305 @end smallexample
7306
7307 All memory models are valid.
7308
7309 @end deftypefn
7310
7311 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7312 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7313 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7314 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7315 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7316 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7317 These built-in functions perform the operation suggested by the name, and
7318 return the value that had previously been in @code{*@var{ptr}}. That is,
7319
7320 @smallexample
7321 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7322 @end smallexample
7323
7324 All memory models are valid.
7325
7326 @end deftypefn
7327
7328 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7329
7330 This built-in function performs an atomic test-and-set operation on
7331 the byte at @code{*@var{ptr}}. The byte is set to some implementation
7332 defined non-zero "set" value and the return value is @code{true} if and only
7333 if the previous contents were "set".
7334
7335 All memory models are valid.
7336
7337 @end deftypefn
7338
7339 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7340
7341 This built-in function performs an atomic clear operation on
7342 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
7343
7344 The valid memory model variants are
7345 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7346 @code{__ATOMIC_RELEASE}.
7347
7348 @end deftypefn
7349
7350 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7351
7352 This built-in function acts as a synchronization fence between threads
7353 based on the specified memory model.
7354
7355 All memory orders are valid.
7356
7357 @end deftypefn
7358
7359 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7360
7361 This built-in function acts as a synchronization fence between a thread
7362 and signal handlers based in the same thread.
7363
7364 All memory orders are valid.
7365
7366 @end deftypefn
7367
7368 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
7369
7370 This built-in function returns true if objects of @var{size} bytes always
7371 generate lock free atomic instructions for the target architecture.
7372 @var{size} must resolve to a compile time constant and the result also resolves to compile time constant.
7373
7374 @var{ptr} is an optional pointer to the object which may be used to determine
7375 alignment. A value of 0 indicates typical alignment should be used. The
7376 compiler may also ignore this parameter.
7377
7378 @smallexample
7379 if (_atomic_always_lock_free (sizeof (long long), 0))
7380 @end smallexample
7381
7382 @end deftypefn
7383
7384 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7385
7386 This built-in function returns true if objects of @var{size} bytes always
7387 generate lock free atomic instructions for the target architecture. If
7388 it is not known to be lock free a call is made to a runtime routine named
7389 @code{__atomic_is_lock_free}.
7390
7391 @var{ptr} is an optional pointer to the object which may be used to determine
7392 alignment. A value of 0 indicates typical alignment should be used. The
7393 compiler may also ignore this parameter.
7394 @end deftypefn
7395
7396 @node Object Size Checking
7397 @section Object Size Checking Builtins
7398 @findex __builtin_object_size
7399 @findex __builtin___memcpy_chk
7400 @findex __builtin___mempcpy_chk
7401 @findex __builtin___memmove_chk
7402 @findex __builtin___memset_chk
7403 @findex __builtin___strcpy_chk
7404 @findex __builtin___stpcpy_chk
7405 @findex __builtin___strncpy_chk
7406 @findex __builtin___strcat_chk
7407 @findex __builtin___strncat_chk
7408 @findex __builtin___sprintf_chk
7409 @findex __builtin___snprintf_chk
7410 @findex __builtin___vsprintf_chk
7411 @findex __builtin___vsnprintf_chk
7412 @findex __builtin___printf_chk
7413 @findex __builtin___vprintf_chk
7414 @findex __builtin___fprintf_chk
7415 @findex __builtin___vfprintf_chk
7416
7417 GCC implements a limited buffer overflow protection mechanism
7418 that can prevent some buffer overflow attacks.
7419
7420 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7421 is a built-in construct that returns a constant number of bytes from
7422 @var{ptr} to the end of the object @var{ptr} pointer points to
7423 (if known at compile time). @code{__builtin_object_size} never evaluates
7424 its arguments for side-effects. If there are any side-effects in them, it
7425 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7426 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
7427 point to and all of them are known at compile time, the returned number
7428 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7429 0 and minimum if nonzero. If it is not possible to determine which objects
7430 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7431 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7432 for @var{type} 2 or 3.
7433
7434 @var{type} is an integer constant from 0 to 3. If the least significant
7435 bit is clear, objects are whole variables, if it is set, a closest
7436 surrounding subobject is considered the object a pointer points to.
7437 The second bit determines if maximum or minimum of remaining bytes
7438 is computed.
7439
7440 @smallexample
7441 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7442 char *p = &var.buf1[1], *q = &var.b;
7443
7444 /* Here the object p points to is var. */
7445 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7446 /* The subobject p points to is var.buf1. */
7447 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7448 /* The object q points to is var. */
7449 assert (__builtin_object_size (q, 0)
7450 == (char *) (&var + 1) - (char *) &var.b);
7451 /* The subobject q points to is var.b. */
7452 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7453 @end smallexample
7454 @end deftypefn
7455
7456 There are built-in functions added for many common string operation
7457 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7458 built-in is provided. This built-in has an additional last argument,
7459 which is the number of bytes remaining in object the @var{dest}
7460 argument points to or @code{(size_t) -1} if the size is not known.
7461
7462 The built-in functions are optimized into the normal string functions
7463 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7464 it is known at compile time that the destination object will not
7465 be overflown. If the compiler can determine at compile time the
7466 object will be always overflown, it issues a warning.
7467
7468 The intended use can be e.g.
7469
7470 @smallexample
7471 #undef memcpy
7472 #define bos0(dest) __builtin_object_size (dest, 0)
7473 #define memcpy(dest, src, n) \
7474 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7475
7476 char *volatile p;
7477 char buf[10];
7478 /* It is unknown what object p points to, so this is optimized
7479 into plain memcpy - no checking is possible. */
7480 memcpy (p, "abcde", n);
7481 /* Destination is known and length too. It is known at compile
7482 time there will be no overflow. */
7483 memcpy (&buf[5], "abcde", 5);
7484 /* Destination is known, but the length is not known at compile time.
7485 This will result in __memcpy_chk call that can check for overflow
7486 at runtime. */
7487 memcpy (&buf[5], "abcde", n);
7488 /* Destination is known and it is known at compile time there will
7489 be overflow. There will be a warning and __memcpy_chk call that
7490 will abort the program at runtime. */
7491 memcpy (&buf[6], "abcde", 5);
7492 @end smallexample
7493
7494 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7495 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7496 @code{strcat} and @code{strncat}.
7497
7498 There are also checking built-in functions for formatted output functions.
7499 @smallexample
7500 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7501 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7502 const char *fmt, ...);
7503 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7504 va_list ap);
7505 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7506 const char *fmt, va_list ap);
7507 @end smallexample
7508
7509 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7510 etc.@: functions and can contain implementation specific flags on what
7511 additional security measures the checking function might take, such as
7512 handling @code{%n} differently.
7513
7514 The @var{os} argument is the object size @var{s} points to, like in the
7515 other built-in functions. There is a small difference in the behavior
7516 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7517 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7518 the checking function is called with @var{os} argument set to
7519 @code{(size_t) -1}.
7520
7521 In addition to this, there are checking built-in functions
7522 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7523 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7524 These have just one additional argument, @var{flag}, right before
7525 format string @var{fmt}. If the compiler is able to optimize them to
7526 @code{fputc} etc.@: functions, it does, otherwise the checking function
7527 is called and the @var{flag} argument passed to it.
7528
7529 @node Other Builtins
7530 @section Other built-in functions provided by GCC
7531 @cindex built-in functions
7532 @findex __builtin_fpclassify
7533 @findex __builtin_isfinite
7534 @findex __builtin_isnormal
7535 @findex __builtin_isgreater
7536 @findex __builtin_isgreaterequal
7537 @findex __builtin_isinf_sign
7538 @findex __builtin_isless
7539 @findex __builtin_islessequal
7540 @findex __builtin_islessgreater
7541 @findex __builtin_isunordered
7542 @findex __builtin_powi
7543 @findex __builtin_powif
7544 @findex __builtin_powil
7545 @findex _Exit
7546 @findex _exit
7547 @findex abort
7548 @findex abs
7549 @findex acos
7550 @findex acosf
7551 @findex acosh
7552 @findex acoshf
7553 @findex acoshl
7554 @findex acosl
7555 @findex alloca
7556 @findex asin
7557 @findex asinf
7558 @findex asinh
7559 @findex asinhf
7560 @findex asinhl
7561 @findex asinl
7562 @findex atan
7563 @findex atan2
7564 @findex atan2f
7565 @findex atan2l
7566 @findex atanf
7567 @findex atanh
7568 @findex atanhf
7569 @findex atanhl
7570 @findex atanl
7571 @findex bcmp
7572 @findex bzero
7573 @findex cabs
7574 @findex cabsf
7575 @findex cabsl
7576 @findex cacos
7577 @findex cacosf
7578 @findex cacosh
7579 @findex cacoshf
7580 @findex cacoshl
7581 @findex cacosl
7582 @findex calloc
7583 @findex carg
7584 @findex cargf
7585 @findex cargl
7586 @findex casin
7587 @findex casinf
7588 @findex casinh
7589 @findex casinhf
7590 @findex casinhl
7591 @findex casinl
7592 @findex catan
7593 @findex catanf
7594 @findex catanh
7595 @findex catanhf
7596 @findex catanhl
7597 @findex catanl
7598 @findex cbrt
7599 @findex cbrtf
7600 @findex cbrtl
7601 @findex ccos
7602 @findex ccosf
7603 @findex ccosh
7604 @findex ccoshf
7605 @findex ccoshl
7606 @findex ccosl
7607 @findex ceil
7608 @findex ceilf
7609 @findex ceill
7610 @findex cexp
7611 @findex cexpf
7612 @findex cexpl
7613 @findex cimag
7614 @findex cimagf
7615 @findex cimagl
7616 @findex clog
7617 @findex clogf
7618 @findex clogl
7619 @findex conj
7620 @findex conjf
7621 @findex conjl
7622 @findex copysign
7623 @findex copysignf
7624 @findex copysignl
7625 @findex cos
7626 @findex cosf
7627 @findex cosh
7628 @findex coshf
7629 @findex coshl
7630 @findex cosl
7631 @findex cpow
7632 @findex cpowf
7633 @findex cpowl
7634 @findex cproj
7635 @findex cprojf
7636 @findex cprojl
7637 @findex creal
7638 @findex crealf
7639 @findex creall
7640 @findex csin
7641 @findex csinf
7642 @findex csinh
7643 @findex csinhf
7644 @findex csinhl
7645 @findex csinl
7646 @findex csqrt
7647 @findex csqrtf
7648 @findex csqrtl
7649 @findex ctan
7650 @findex ctanf
7651 @findex ctanh
7652 @findex ctanhf
7653 @findex ctanhl
7654 @findex ctanl
7655 @findex dcgettext
7656 @findex dgettext
7657 @findex drem
7658 @findex dremf
7659 @findex dreml
7660 @findex erf
7661 @findex erfc
7662 @findex erfcf
7663 @findex erfcl
7664 @findex erff
7665 @findex erfl
7666 @findex exit
7667 @findex exp
7668 @findex exp10
7669 @findex exp10f
7670 @findex exp10l
7671 @findex exp2
7672 @findex exp2f
7673 @findex exp2l
7674 @findex expf
7675 @findex expl
7676 @findex expm1
7677 @findex expm1f
7678 @findex expm1l
7679 @findex fabs
7680 @findex fabsf
7681 @findex fabsl
7682 @findex fdim
7683 @findex fdimf
7684 @findex fdiml
7685 @findex ffs
7686 @findex floor
7687 @findex floorf
7688 @findex floorl
7689 @findex fma
7690 @findex fmaf
7691 @findex fmal
7692 @findex fmax
7693 @findex fmaxf
7694 @findex fmaxl
7695 @findex fmin
7696 @findex fminf
7697 @findex fminl
7698 @findex fmod
7699 @findex fmodf
7700 @findex fmodl
7701 @findex fprintf
7702 @findex fprintf_unlocked
7703 @findex fputs
7704 @findex fputs_unlocked
7705 @findex frexp
7706 @findex frexpf
7707 @findex frexpl
7708 @findex fscanf
7709 @findex gamma
7710 @findex gammaf
7711 @findex gammal
7712 @findex gamma_r
7713 @findex gammaf_r
7714 @findex gammal_r
7715 @findex gettext
7716 @findex hypot
7717 @findex hypotf
7718 @findex hypotl
7719 @findex ilogb
7720 @findex ilogbf
7721 @findex ilogbl
7722 @findex imaxabs
7723 @findex index
7724 @findex isalnum
7725 @findex isalpha
7726 @findex isascii
7727 @findex isblank
7728 @findex iscntrl
7729 @findex isdigit
7730 @findex isgraph
7731 @findex islower
7732 @findex isprint
7733 @findex ispunct
7734 @findex isspace
7735 @findex isupper
7736 @findex iswalnum
7737 @findex iswalpha
7738 @findex iswblank
7739 @findex iswcntrl
7740 @findex iswdigit
7741 @findex iswgraph
7742 @findex iswlower
7743 @findex iswprint
7744 @findex iswpunct
7745 @findex iswspace
7746 @findex iswupper
7747 @findex iswxdigit
7748 @findex isxdigit
7749 @findex j0
7750 @findex j0f
7751 @findex j0l
7752 @findex j1
7753 @findex j1f
7754 @findex j1l
7755 @findex jn
7756 @findex jnf
7757 @findex jnl
7758 @findex labs
7759 @findex ldexp
7760 @findex ldexpf
7761 @findex ldexpl
7762 @findex lgamma
7763 @findex lgammaf
7764 @findex lgammal
7765 @findex lgamma_r
7766 @findex lgammaf_r
7767 @findex lgammal_r
7768 @findex llabs
7769 @findex llrint
7770 @findex llrintf
7771 @findex llrintl
7772 @findex llround
7773 @findex llroundf
7774 @findex llroundl
7775 @findex log
7776 @findex log10
7777 @findex log10f
7778 @findex log10l
7779 @findex log1p
7780 @findex log1pf
7781 @findex log1pl
7782 @findex log2
7783 @findex log2f
7784 @findex log2l
7785 @findex logb
7786 @findex logbf
7787 @findex logbl
7788 @findex logf
7789 @findex logl
7790 @findex lrint
7791 @findex lrintf
7792 @findex lrintl
7793 @findex lround
7794 @findex lroundf
7795 @findex lroundl
7796 @findex malloc
7797 @findex memchr
7798 @findex memcmp
7799 @findex memcpy
7800 @findex mempcpy
7801 @findex memset
7802 @findex modf
7803 @findex modff
7804 @findex modfl
7805 @findex nearbyint
7806 @findex nearbyintf
7807 @findex nearbyintl
7808 @findex nextafter
7809 @findex nextafterf
7810 @findex nextafterl
7811 @findex nexttoward
7812 @findex nexttowardf
7813 @findex nexttowardl
7814 @findex pow
7815 @findex pow10
7816 @findex pow10f
7817 @findex pow10l
7818 @findex powf
7819 @findex powl
7820 @findex printf
7821 @findex printf_unlocked
7822 @findex putchar
7823 @findex puts
7824 @findex remainder
7825 @findex remainderf
7826 @findex remainderl
7827 @findex remquo
7828 @findex remquof
7829 @findex remquol
7830 @findex rindex
7831 @findex rint
7832 @findex rintf
7833 @findex rintl
7834 @findex round
7835 @findex roundf
7836 @findex roundl
7837 @findex scalb
7838 @findex scalbf
7839 @findex scalbl
7840 @findex scalbln
7841 @findex scalblnf
7842 @findex scalblnf
7843 @findex scalbn
7844 @findex scalbnf
7845 @findex scanfnl
7846 @findex signbit
7847 @findex signbitf
7848 @findex signbitl
7849 @findex signbitd32
7850 @findex signbitd64
7851 @findex signbitd128
7852 @findex significand
7853 @findex significandf
7854 @findex significandl
7855 @findex sin
7856 @findex sincos
7857 @findex sincosf
7858 @findex sincosl
7859 @findex sinf
7860 @findex sinh
7861 @findex sinhf
7862 @findex sinhl
7863 @findex sinl
7864 @findex snprintf
7865 @findex sprintf
7866 @findex sqrt
7867 @findex sqrtf
7868 @findex sqrtl
7869 @findex sscanf
7870 @findex stpcpy
7871 @findex stpncpy
7872 @findex strcasecmp
7873 @findex strcat
7874 @findex strchr
7875 @findex strcmp
7876 @findex strcpy
7877 @findex strcspn
7878 @findex strdup
7879 @findex strfmon
7880 @findex strftime
7881 @findex strlen
7882 @findex strncasecmp
7883 @findex strncat
7884 @findex strncmp
7885 @findex strncpy
7886 @findex strndup
7887 @findex strpbrk
7888 @findex strrchr
7889 @findex strspn
7890 @findex strstr
7891 @findex tan
7892 @findex tanf
7893 @findex tanh
7894 @findex tanhf
7895 @findex tanhl
7896 @findex tanl
7897 @findex tgamma
7898 @findex tgammaf
7899 @findex tgammal
7900 @findex toascii
7901 @findex tolower
7902 @findex toupper
7903 @findex towlower
7904 @findex towupper
7905 @findex trunc
7906 @findex truncf
7907 @findex truncl
7908 @findex vfprintf
7909 @findex vfscanf
7910 @findex vprintf
7911 @findex vscanf
7912 @findex vsnprintf
7913 @findex vsprintf
7914 @findex vsscanf
7915 @findex y0
7916 @findex y0f
7917 @findex y0l
7918 @findex y1
7919 @findex y1f
7920 @findex y1l
7921 @findex yn
7922 @findex ynf
7923 @findex ynl
7924
7925 GCC provides a large number of built-in functions other than the ones
7926 mentioned above. Some of these are for internal use in the processing
7927 of exceptions or variable-length argument lists and are not
7928 documented here because they may change from time to time; we do not
7929 recommend general use of these functions.
7930
7931 The remaining functions are provided for optimization purposes.
7932
7933 @opindex fno-builtin
7934 GCC includes built-in versions of many of the functions in the standard
7935 C library. The versions prefixed with @code{__builtin_} are always
7936 treated as having the same meaning as the C library function even if you
7937 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
7938 Many of these functions are only optimized in certain cases; if they are
7939 not optimized in a particular case, a call to the library function is
7940 emitted.
7941
7942 @opindex ansi
7943 @opindex std
7944 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
7945 @option{-std=c99} or @option{-std=c11}), the functions
7946 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
7947 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
7948 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
7949 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
7950 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
7951 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
7952 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
7953 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
7954 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
7955 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
7956 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
7957 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
7958 @code{signbitd64}, @code{signbitd128}, @code{significandf},
7959 @code{significandl}, @code{significand}, @code{sincosf},
7960 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
7961 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
7962 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
7963 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
7964 @code{yn}
7965 may be handled as built-in functions.
7966 All these functions have corresponding versions
7967 prefixed with @code{__builtin_}, which may be used even in strict C90
7968 mode.
7969
7970 The ISO C99 functions
7971 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
7972 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
7973 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
7974 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
7975 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
7976 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
7977 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
7978 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
7979 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
7980 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
7981 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
7982 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
7983 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
7984 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
7985 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
7986 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
7987 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
7988 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
7989 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
7990 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
7991 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
7992 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
7993 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
7994 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
7995 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
7996 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
7997 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
7998 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
7999 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8000 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8001 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8002 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8003 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8004 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8005 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8006 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8007 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8008 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8009 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8010 are handled as built-in functions
8011 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8012
8013 There are also built-in versions of the ISO C99 functions
8014 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8015 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8016 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8017 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8018 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8019 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8020 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8021 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8022 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8023 that are recognized in any mode since ISO C90 reserves these names for
8024 the purpose to which ISO C99 puts them. All these functions have
8025 corresponding versions prefixed with @code{__builtin_}.
8026
8027 The ISO C94 functions
8028 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8029 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8030 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8031 @code{towupper}
8032 are handled as built-in functions
8033 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8034
8035 The ISO C90 functions
8036 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8037 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8038 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8039 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8040 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8041 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8042 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8043 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8044 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8045 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8046 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8047 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8048 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8049 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8050 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8051 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8052 are all recognized as built-in functions unless
8053 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8054 is specified for an individual function). All of these functions have
8055 corresponding versions prefixed with @code{__builtin_}.
8056
8057 GCC provides built-in versions of the ISO C99 floating point comparison
8058 macros that avoid raising exceptions for unordered operands. They have
8059 the same names as the standard macros ( @code{isgreater},
8060 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8061 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8062 prefixed. We intend for a library implementor to be able to simply
8063 @code{#define} each standard macro to its built-in equivalent.
8064 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8065 @code{isinf_sign} and @code{isnormal} built-ins used with
8066 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
8067 builtins appear both with and without the @code{__builtin_} prefix.
8068
8069 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8070
8071 You can use the built-in function @code{__builtin_types_compatible_p} to
8072 determine whether two types are the same.
8073
8074 This built-in function returns 1 if the unqualified versions of the
8075 types @var{type1} and @var{type2} (which are types, not expressions) are
8076 compatible, 0 otherwise. The result of this built-in function can be
8077 used in integer constant expressions.
8078
8079 This built-in function ignores top level qualifiers (e.g., @code{const},
8080 @code{volatile}). For example, @code{int} is equivalent to @code{const
8081 int}.
8082
8083 The type @code{int[]} and @code{int[5]} are compatible. On the other
8084 hand, @code{int} and @code{char *} are not compatible, even if the size
8085 of their types, on the particular architecture are the same. Also, the
8086 amount of pointer indirection is taken into account when determining
8087 similarity. Consequently, @code{short *} is not similar to
8088 @code{short **}. Furthermore, two types that are typedefed are
8089 considered compatible if their underlying types are compatible.
8090
8091 An @code{enum} type is not considered to be compatible with another
8092 @code{enum} type even if both are compatible with the same integer
8093 type; this is what the C standard specifies.
8094 For example, @code{enum @{foo, bar@}} is not similar to
8095 @code{enum @{hot, dog@}}.
8096
8097 You typically use this function in code whose execution varies
8098 depending on the arguments' types. For example:
8099
8100 @smallexample
8101 #define foo(x) \
8102 (@{ \
8103 typeof (x) tmp = (x); \
8104 if (__builtin_types_compatible_p (typeof (x), long double)) \
8105 tmp = foo_long_double (tmp); \
8106 else if (__builtin_types_compatible_p (typeof (x), double)) \
8107 tmp = foo_double (tmp); \
8108 else if (__builtin_types_compatible_p (typeof (x), float)) \
8109 tmp = foo_float (tmp); \
8110 else \
8111 abort (); \
8112 tmp; \
8113 @})
8114 @end smallexample
8115
8116 @emph{Note:} This construct is only available for C@.
8117
8118 @end deftypefn
8119
8120 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8121
8122 You can use the built-in function @code{__builtin_choose_expr} to
8123 evaluate code depending on the value of a constant expression. This
8124 built-in function returns @var{exp1} if @var{const_exp}, which is an
8125 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
8126
8127 This built-in function is analogous to the @samp{? :} operator in C,
8128 except that the expression returned has its type unaltered by promotion
8129 rules. Also, the built-in function does not evaluate the expression
8130 that is not chosen. For example, if @var{const_exp} evaluates to true,
8131 @var{exp2} is not evaluated even if it has side-effects.
8132
8133 This built-in function can return an lvalue if the chosen argument is an
8134 lvalue.
8135
8136 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8137 type. Similarly, if @var{exp2} is returned, its return type is the same
8138 as @var{exp2}.
8139
8140 Example:
8141
8142 @smallexample
8143 #define foo(x) \
8144 __builtin_choose_expr ( \
8145 __builtin_types_compatible_p (typeof (x), double), \
8146 foo_double (x), \
8147 __builtin_choose_expr ( \
8148 __builtin_types_compatible_p (typeof (x), float), \
8149 foo_float (x), \
8150 /* @r{The void expression results in a compile-time error} \
8151 @r{when assigning the result to something.} */ \
8152 (void)0))
8153 @end smallexample
8154
8155 @emph{Note:} This construct is only available for C@. Furthermore, the
8156 unused expression (@var{exp1} or @var{exp2} depending on the value of
8157 @var{const_exp}) may still generate syntax errors. This may change in
8158 future revisions.
8159
8160 @end deftypefn
8161
8162 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8163
8164 The built-in function @code{__builtin_complex} is provided for use in
8165 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8166 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
8167 real binary floating-point type, and the result has the corresponding
8168 complex type with real and imaginary parts @var{real} and @var{imag}.
8169 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8170 infinities, NaNs and negative zeros are involved.
8171
8172 @end deftypefn
8173
8174 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8175 You can use the built-in function @code{__builtin_constant_p} to
8176 determine if a value is known to be constant at compile-time and hence
8177 that GCC can perform constant-folding on expressions involving that
8178 value. The argument of the function is the value to test. The function
8179 returns the integer 1 if the argument is known to be a compile-time
8180 constant and 0 if it is not known to be a compile-time constant. A
8181 return of 0 does not indicate that the value is @emph{not} a constant,
8182 but merely that GCC cannot prove it is a constant with the specified
8183 value of the @option{-O} option.
8184
8185 You typically use this function in an embedded application where
8186 memory is a critical resource. If you have some complex calculation,
8187 you may want it to be folded if it involves constants, but need to call
8188 a function if it does not. For example:
8189
8190 @smallexample
8191 #define Scale_Value(X) \
8192 (__builtin_constant_p (X) \
8193 ? ((X) * SCALE + OFFSET) : Scale (X))
8194 @end smallexample
8195
8196 You may use this built-in function in either a macro or an inline
8197 function. However, if you use it in an inlined function and pass an
8198 argument of the function as the argument to the built-in, GCC
8199 never returns 1 when you call the inline function with a string constant
8200 or compound literal (@pxref{Compound Literals}) and does not return 1
8201 when you pass a constant numeric value to the inline function unless you
8202 specify the @option{-O} option.
8203
8204 You may also use @code{__builtin_constant_p} in initializers for static
8205 data. For instance, you can write
8206
8207 @smallexample
8208 static const int table[] = @{
8209 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8210 /* @r{@dots{}} */
8211 @};
8212 @end smallexample
8213
8214 @noindent
8215 This is an acceptable initializer even if @var{EXPRESSION} is not a
8216 constant expression, including the case where
8217 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8218 folded to a constant but @var{EXPRESSION} contains operands that are
8219 not otherwise permitted in a static initializer (for example,
8220 @code{0 && foo ()}). GCC must be more conservative about evaluating the
8221 built-in in this case, because it has no opportunity to perform
8222 optimization.
8223
8224 Previous versions of GCC did not accept this built-in in data
8225 initializers. The earliest version where it is completely safe is
8226 3.0.1.
8227 @end deftypefn
8228
8229 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8230 @opindex fprofile-arcs
8231 You may use @code{__builtin_expect} to provide the compiler with
8232 branch prediction information. In general, you should prefer to
8233 use actual profile feedback for this (@option{-fprofile-arcs}), as
8234 programmers are notoriously bad at predicting how their programs
8235 actually perform. However, there are applications in which this
8236 data is hard to collect.
8237
8238 The return value is the value of @var{exp}, which should be an integral
8239 expression. The semantics of the built-in are that it is expected that
8240 @var{exp} == @var{c}. For example:
8241
8242 @smallexample
8243 if (__builtin_expect (x, 0))
8244 foo ();
8245 @end smallexample
8246
8247 @noindent
8248 indicates that we do not expect to call @code{foo}, since
8249 we expect @code{x} to be zero. Since you are limited to integral
8250 expressions for @var{exp}, you should use constructions such as
8251
8252 @smallexample
8253 if (__builtin_expect (ptr != NULL, 1))
8254 foo (*ptr);
8255 @end smallexample
8256
8257 @noindent
8258 when testing pointer or floating-point values.
8259 @end deftypefn
8260
8261 @deftypefn {Built-in Function} void __builtin_trap (void)
8262 This function causes the program to exit abnormally. GCC implements
8263 this function by using a target-dependent mechanism (such as
8264 intentionally executing an illegal instruction) or by calling
8265 @code{abort}. The mechanism used may vary from release to release so
8266 you should not rely on any particular implementation.
8267 @end deftypefn
8268
8269 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8270 If control flow reaches the point of the @code{__builtin_unreachable},
8271 the program is undefined. It is useful in situations where the
8272 compiler cannot deduce the unreachability of the code.
8273
8274 One such case is immediately following an @code{asm} statement that
8275 either never terminates, or one that transfers control elsewhere
8276 and never returns. In this example, without the
8277 @code{__builtin_unreachable}, GCC issues a warning that control
8278 reaches the end of a non-void function. It also generates code
8279 to return after the @code{asm}.
8280
8281 @smallexample
8282 int f (int c, int v)
8283 @{
8284 if (c)
8285 @{
8286 return v;
8287 @}
8288 else
8289 @{
8290 asm("jmp error_handler");
8291 __builtin_unreachable ();
8292 @}
8293 @}
8294 @end smallexample
8295
8296 Because the @code{asm} statement unconditionally transfers control out
8297 of the function, control never reaches the end of the function
8298 body. The @code{__builtin_unreachable} is in fact unreachable and
8299 communicates this fact to the compiler.
8300
8301 Another use for @code{__builtin_unreachable} is following a call a
8302 function that never returns but that is not declared
8303 @code{__attribute__((noreturn))}, as in this example:
8304
8305 @smallexample
8306 void function_that_never_returns (void);
8307
8308 int g (int c)
8309 @{
8310 if (c)
8311 @{
8312 return 1;
8313 @}
8314 else
8315 @{
8316 function_that_never_returns ();
8317 __builtin_unreachable ();
8318 @}
8319 @}
8320 @end smallexample
8321
8322 @end deftypefn
8323
8324 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8325 This function returns its first argument, and allows the compiler
8326 to assume that the returned pointer is at least @var{align} bytes
8327 aligned. This built-in can have either two or three arguments,
8328 if it has three, the third argument should have integer type, and
8329 if it is non-zero means misalignment offset. For example:
8330
8331 @smallexample
8332 void *x = __builtin_assume_aligned (arg, 16);
8333 @end smallexample
8334
8335 means that the compiler can assume x, set to arg, is at least
8336 16 byte aligned, while:
8337
8338 @smallexample
8339 void *x = __builtin_assume_aligned (arg, 32, 8);
8340 @end smallexample
8341
8342 means that the compiler can assume for x, set to arg, that
8343 (char *) x - 8 is 32 byte aligned.
8344 @end deftypefn
8345
8346 @deftypefn {Built-in Function} int __builtin_LINE ()
8347 This function is the equivalent to the preprocessor @code{__LINE__}
8348 macro and returns the line number of the invocation of the built-in.
8349 @end deftypefn
8350
8351 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8352 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8353 macro and returns the function name the invocation of the built-in is in.
8354 @end deftypefn
8355
8356 @deftypefn {Built-in Function} int __builtin_FILE ()
8357 This function is the equivalent to the preprocessor @code{__FILE__}
8358 macro and returns the file name the invocation of the built-in is in.
8359 @end deftypefn
8360
8361 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8362 This function is used to flush the processor's instruction cache for
8363 the region of memory between @var{begin} inclusive and @var{end}
8364 exclusive. Some targets require that the instruction cache be
8365 flushed, after modifying memory containing code, in order to obtain
8366 deterministic behavior.
8367
8368 If the target does not require instruction cache flushes,
8369 @code{__builtin___clear_cache} has no effect. Otherwise either
8370 instructions are emitted in-line to clear the instruction cache or a
8371 call to the @code{__clear_cache} function in libgcc is made.
8372 @end deftypefn
8373
8374 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8375 This function is used to minimize cache-miss latency by moving data into
8376 a cache before it is accessed.
8377 You can insert calls to @code{__builtin_prefetch} into code for which
8378 you know addresses of data in memory that is likely to be accessed soon.
8379 If the target supports them, data prefetch instructions are generated.
8380 If the prefetch is done early enough before the access then the data will
8381 be in the cache by the time it is accessed.
8382
8383 The value of @var{addr} is the address of the memory to prefetch.
8384 There are two optional arguments, @var{rw} and @var{locality}.
8385 The value of @var{rw} is a compile-time constant one or zero; one
8386 means that the prefetch is preparing for a write to the memory address
8387 and zero, the default, means that the prefetch is preparing for a read.
8388 The value @var{locality} must be a compile-time constant integer between
8389 zero and three. A value of zero means that the data has no temporal
8390 locality, so it need not be left in the cache after the access. A value
8391 of three means that the data has a high degree of temporal locality and
8392 should be left in all levels of cache possible. Values of one and two
8393 mean, respectively, a low or moderate degree of temporal locality. The
8394 default is three.
8395
8396 @smallexample
8397 for (i = 0; i < n; i++)
8398 @{
8399 a[i] = a[i] + b[i];
8400 __builtin_prefetch (&a[i+j], 1, 1);
8401 __builtin_prefetch (&b[i+j], 0, 1);
8402 /* @r{@dots{}} */
8403 @}
8404 @end smallexample
8405
8406 Data prefetch does not generate faults if @var{addr} is invalid, but
8407 the address expression itself must be valid. For example, a prefetch
8408 of @code{p->next} does not fault if @code{p->next} is not a valid
8409 address, but evaluation faults if @code{p} is not a valid address.
8410
8411 If the target does not support data prefetch, the address expression
8412 is evaluated if it includes side effects but no other code is generated
8413 and GCC does not issue a warning.
8414 @end deftypefn
8415
8416 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8417 Returns a positive infinity, if supported by the floating-point format,
8418 else @code{DBL_MAX}. This function is suitable for implementing the
8419 ISO C macro @code{HUGE_VAL}.
8420 @end deftypefn
8421
8422 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8423 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8424 @end deftypefn
8425
8426 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8427 Similar to @code{__builtin_huge_val}, except the return
8428 type is @code{long double}.
8429 @end deftypefn
8430
8431 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8432 This built-in implements the C99 fpclassify functionality. The first
8433 five int arguments should be the target library's notion of the
8434 possible FP classes and are used for return values. They must be
8435 constant values and they must appear in this order: @code{FP_NAN},
8436 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8437 @code{FP_ZERO}. The ellipsis is for exactly one floating point value
8438 to classify. GCC treats the last argument as type-generic, which
8439 means it does not do default promotion from float to double.
8440 @end deftypefn
8441
8442 @deftypefn {Built-in Function} double __builtin_inf (void)
8443 Similar to @code{__builtin_huge_val}, except a warning is generated
8444 if the target floating-point format does not support infinities.
8445 @end deftypefn
8446
8447 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8448 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8449 @end deftypefn
8450
8451 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8452 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8453 @end deftypefn
8454
8455 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8456 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8457 @end deftypefn
8458
8459 @deftypefn {Built-in Function} float __builtin_inff (void)
8460 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8461 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8462 @end deftypefn
8463
8464 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8465 Similar to @code{__builtin_inf}, except the return
8466 type is @code{long double}.
8467 @end deftypefn
8468
8469 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8470 Similar to @code{isinf}, except the return value is negative for
8471 an argument of @code{-Inf}. Note while the parameter list is an
8472 ellipsis, this function only accepts exactly one floating point
8473 argument. GCC treats this parameter as type-generic, which means it
8474 does not do default promotion from float to double.
8475 @end deftypefn
8476
8477 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8478 This is an implementation of the ISO C99 function @code{nan}.
8479
8480 Since ISO C99 defines this function in terms of @code{strtod}, which we
8481 do not implement, a description of the parsing is in order. The string
8482 is parsed as by @code{strtol}; that is, the base is recognized by
8483 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
8484 in the significand such that the least significant bit of the number
8485 is at the least significant bit of the significand. The number is
8486 truncated to fit the significand field provided. The significand is
8487 forced to be a quiet NaN@.
8488
8489 This function, if given a string literal all of which would have been
8490 consumed by strtol, is evaluated early enough that it is considered a
8491 compile-time constant.
8492 @end deftypefn
8493
8494 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8495 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8496 @end deftypefn
8497
8498 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8499 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8500 @end deftypefn
8501
8502 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8503 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8504 @end deftypefn
8505
8506 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8507 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8508 @end deftypefn
8509
8510 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8511 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8512 @end deftypefn
8513
8514 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8515 Similar to @code{__builtin_nan}, except the significand is forced
8516 to be a signaling NaN@. The @code{nans} function is proposed by
8517 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8518 @end deftypefn
8519
8520 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8521 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8522 @end deftypefn
8523
8524 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8525 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8526 @end deftypefn
8527
8528 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8529 Returns one plus the index of the least significant 1-bit of @var{x}, or
8530 if @var{x} is zero, returns zero.
8531 @end deftypefn
8532
8533 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8534 Returns the number of leading 0-bits in @var{x}, starting at the most
8535 significant bit position. If @var{x} is 0, the result is undefined.
8536 @end deftypefn
8537
8538 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8539 Returns the number of trailing 0-bits in @var{x}, starting at the least
8540 significant bit position. If @var{x} is 0, the result is undefined.
8541 @end deftypefn
8542
8543 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8544 Returns the number of leading redundant sign bits in @var{x}, i.e. the
8545 number of bits following the most significant bit which are identical
8546 to it. There are no special cases for 0 or other values.
8547 @end deftypefn
8548
8549 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8550 Returns the number of 1-bits in @var{x}.
8551 @end deftypefn
8552
8553 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8554 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8555 modulo 2.
8556 @end deftypefn
8557
8558 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8559 Similar to @code{__builtin_ffs}, except the argument type is
8560 @code{unsigned long}.
8561 @end deftypefn
8562
8563 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8564 Similar to @code{__builtin_clz}, except the argument type is
8565 @code{unsigned long}.
8566 @end deftypefn
8567
8568 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8569 Similar to @code{__builtin_ctz}, except the argument type is
8570 @code{unsigned long}.
8571 @end deftypefn
8572
8573 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8574 Similar to @code{__builtin_clrsb}, except the argument type is
8575 @code{long}.
8576 @end deftypefn
8577
8578 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8579 Similar to @code{__builtin_popcount}, except the argument type is
8580 @code{unsigned long}.
8581 @end deftypefn
8582
8583 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8584 Similar to @code{__builtin_parity}, except the argument type is
8585 @code{unsigned long}.
8586 @end deftypefn
8587
8588 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8589 Similar to @code{__builtin_ffs}, except the argument type is
8590 @code{unsigned long long}.
8591 @end deftypefn
8592
8593 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8594 Similar to @code{__builtin_clz}, except the argument type is
8595 @code{unsigned long long}.
8596 @end deftypefn
8597
8598 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8599 Similar to @code{__builtin_ctz}, except the argument type is
8600 @code{unsigned long long}.
8601 @end deftypefn
8602
8603 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8604 Similar to @code{__builtin_clrsb}, except the argument type is
8605 @code{long long}.
8606 @end deftypefn
8607
8608 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8609 Similar to @code{__builtin_popcount}, except the argument type is
8610 @code{unsigned long long}.
8611 @end deftypefn
8612
8613 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8614 Similar to @code{__builtin_parity}, except the argument type is
8615 @code{unsigned long long}.
8616 @end deftypefn
8617
8618 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8619 Returns the first argument raised to the power of the second. Unlike the
8620 @code{pow} function no guarantees about precision and rounding are made.
8621 @end deftypefn
8622
8623 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8624 Similar to @code{__builtin_powi}, except the argument and return types
8625 are @code{float}.
8626 @end deftypefn
8627
8628 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8629 Similar to @code{__builtin_powi}, except the argument and return types
8630 are @code{long double}.
8631 @end deftypefn
8632
8633 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8634 Returns @var{x} with the order of the bytes reversed; for example,
8635 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
8636 exactly 8 bits.
8637 @end deftypefn
8638
8639 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8640 Similar to @code{__builtin_bswap16}, except the argument and return types
8641 are 32-bit.
8642 @end deftypefn
8643
8644 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
8645 Similar to @code{__builtin_bswap32}, except the argument and return types
8646 are 64-bit.
8647 @end deftypefn
8648
8649 @node Target Builtins
8650 @section Built-in Functions Specific to Particular Target Machines
8651
8652 On some target machines, GCC supports many built-in functions specific
8653 to those machines. Generally these generate calls to specific machine
8654 instructions, but allow the compiler to schedule those calls.
8655
8656 @menu
8657 * Alpha Built-in Functions::
8658 * ARM iWMMXt Built-in Functions::
8659 * ARM NEON Intrinsics::
8660 * AVR Built-in Functions::
8661 * Blackfin Built-in Functions::
8662 * FR-V Built-in Functions::
8663 * X86 Built-in Functions::
8664 * MIPS DSP Built-in Functions::
8665 * MIPS Paired-Single Support::
8666 * MIPS Loongson Built-in Functions::
8667 * Other MIPS Built-in Functions::
8668 * picoChip Built-in Functions::
8669 * PowerPC Built-in Functions::
8670 * PowerPC AltiVec/VSX Built-in Functions::
8671 * RX Built-in Functions::
8672 * SH Built-in Functions::
8673 * SPARC VIS Built-in Functions::
8674 * SPU Built-in Functions::
8675 * TI C6X Built-in Functions::
8676 * TILE-Gx Built-in Functions::
8677 * TILEPro Built-in Functions::
8678 @end menu
8679
8680 @node Alpha Built-in Functions
8681 @subsection Alpha Built-in Functions
8682
8683 These built-in functions are available for the Alpha family of
8684 processors, depending on the command-line switches used.
8685
8686 The following built-in functions are always available. They
8687 all generate the machine instruction that is part of the name.
8688
8689 @smallexample
8690 long __builtin_alpha_implver (void)
8691 long __builtin_alpha_rpcc (void)
8692 long __builtin_alpha_amask (long)
8693 long __builtin_alpha_cmpbge (long, long)
8694 long __builtin_alpha_extbl (long, long)
8695 long __builtin_alpha_extwl (long, long)
8696 long __builtin_alpha_extll (long, long)
8697 long __builtin_alpha_extql (long, long)
8698 long __builtin_alpha_extwh (long, long)
8699 long __builtin_alpha_extlh (long, long)
8700 long __builtin_alpha_extqh (long, long)
8701 long __builtin_alpha_insbl (long, long)
8702 long __builtin_alpha_inswl (long, long)
8703 long __builtin_alpha_insll (long, long)
8704 long __builtin_alpha_insql (long, long)
8705 long __builtin_alpha_inswh (long, long)
8706 long __builtin_alpha_inslh (long, long)
8707 long __builtin_alpha_insqh (long, long)
8708 long __builtin_alpha_mskbl (long, long)
8709 long __builtin_alpha_mskwl (long, long)
8710 long __builtin_alpha_mskll (long, long)
8711 long __builtin_alpha_mskql (long, long)
8712 long __builtin_alpha_mskwh (long, long)
8713 long __builtin_alpha_msklh (long, long)
8714 long __builtin_alpha_mskqh (long, long)
8715 long __builtin_alpha_umulh (long, long)
8716 long __builtin_alpha_zap (long, long)
8717 long __builtin_alpha_zapnot (long, long)
8718 @end smallexample
8719
8720 The following built-in functions are always with @option{-mmax}
8721 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
8722 later. They all generate the machine instruction that is part
8723 of the name.
8724
8725 @smallexample
8726 long __builtin_alpha_pklb (long)
8727 long __builtin_alpha_pkwb (long)
8728 long __builtin_alpha_unpkbl (long)
8729 long __builtin_alpha_unpkbw (long)
8730 long __builtin_alpha_minub8 (long, long)
8731 long __builtin_alpha_minsb8 (long, long)
8732 long __builtin_alpha_minuw4 (long, long)
8733 long __builtin_alpha_minsw4 (long, long)
8734 long __builtin_alpha_maxub8 (long, long)
8735 long __builtin_alpha_maxsb8 (long, long)
8736 long __builtin_alpha_maxuw4 (long, long)
8737 long __builtin_alpha_maxsw4 (long, long)
8738 long __builtin_alpha_perr (long, long)
8739 @end smallexample
8740
8741 The following built-in functions are always with @option{-mcix}
8742 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
8743 later. They all generate the machine instruction that is part
8744 of the name.
8745
8746 @smallexample
8747 long __builtin_alpha_cttz (long)
8748 long __builtin_alpha_ctlz (long)
8749 long __builtin_alpha_ctpop (long)
8750 @end smallexample
8751
8752 The following builtins are available on systems that use the OSF/1
8753 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
8754 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
8755 @code{rdval} and @code{wrval}.
8756
8757 @smallexample
8758 void *__builtin_thread_pointer (void)
8759 void __builtin_set_thread_pointer (void *)
8760 @end smallexample
8761
8762 @node ARM iWMMXt Built-in Functions
8763 @subsection ARM iWMMXt Built-in Functions
8764
8765 These built-in functions are available for the ARM family of
8766 processors when the @option{-mcpu=iwmmxt} switch is used:
8767
8768 @smallexample
8769 typedef int v2si __attribute__ ((vector_size (8)));
8770 typedef short v4hi __attribute__ ((vector_size (8)));
8771 typedef char v8qi __attribute__ ((vector_size (8)));
8772
8773 int __builtin_arm_getwcgr0 (void)
8774 void __builtin_arm_setwcgr0 (int)
8775 int __builtin_arm_getwcgr1 (void)
8776 void __builtin_arm_setwcgr1 (int)
8777 int __builtin_arm_getwcgr2 (void)
8778 void __builtin_arm_setwcgr2 (int)
8779 int __builtin_arm_getwcgr3 (void)
8780 void __builtin_arm_setwcgr3 (int)
8781 int __builtin_arm_textrmsb (v8qi, int)
8782 int __builtin_arm_textrmsh (v4hi, int)
8783 int __builtin_arm_textrmsw (v2si, int)
8784 int __builtin_arm_textrmub (v8qi, int)
8785 int __builtin_arm_textrmuh (v4hi, int)
8786 int __builtin_arm_textrmuw (v2si, int)
8787 v8qi __builtin_arm_tinsrb (v8qi, int, int)
8788 v4hi __builtin_arm_tinsrh (v4hi, int, int)
8789 v2si __builtin_arm_tinsrw (v2si, int, int)
8790 long long __builtin_arm_tmia (long long, int, int)
8791 long long __builtin_arm_tmiabb (long long, int, int)
8792 long long __builtin_arm_tmiabt (long long, int, int)
8793 long long __builtin_arm_tmiaph (long long, int, int)
8794 long long __builtin_arm_tmiatb (long long, int, int)
8795 long long __builtin_arm_tmiatt (long long, int, int)
8796 int __builtin_arm_tmovmskb (v8qi)
8797 int __builtin_arm_tmovmskh (v4hi)
8798 int __builtin_arm_tmovmskw (v2si)
8799 long long __builtin_arm_waccb (v8qi)
8800 long long __builtin_arm_wacch (v4hi)
8801 long long __builtin_arm_waccw (v2si)
8802 v8qi __builtin_arm_waddb (v8qi, v8qi)
8803 v8qi __builtin_arm_waddbss (v8qi, v8qi)
8804 v8qi __builtin_arm_waddbus (v8qi, v8qi)
8805 v4hi __builtin_arm_waddh (v4hi, v4hi)
8806 v4hi __builtin_arm_waddhss (v4hi, v4hi)
8807 v4hi __builtin_arm_waddhus (v4hi, v4hi)
8808 v2si __builtin_arm_waddw (v2si, v2si)
8809 v2si __builtin_arm_waddwss (v2si, v2si)
8810 v2si __builtin_arm_waddwus (v2si, v2si)
8811 v8qi __builtin_arm_walign (v8qi, v8qi, int)
8812 long long __builtin_arm_wand(long long, long long)
8813 long long __builtin_arm_wandn (long long, long long)
8814 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
8815 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
8816 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
8817 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
8818 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
8819 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
8820 v2si __builtin_arm_wcmpeqw (v2si, v2si)
8821 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
8822 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
8823 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
8824 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
8825 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
8826 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
8827 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
8828 long long __builtin_arm_wmacsz (v4hi, v4hi)
8829 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
8830 long long __builtin_arm_wmacuz (v4hi, v4hi)
8831 v4hi __builtin_arm_wmadds (v4hi, v4hi)
8832 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
8833 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
8834 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
8835 v2si __builtin_arm_wmaxsw (v2si, v2si)
8836 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
8837 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
8838 v2si __builtin_arm_wmaxuw (v2si, v2si)
8839 v8qi __builtin_arm_wminsb (v8qi, v8qi)
8840 v4hi __builtin_arm_wminsh (v4hi, v4hi)
8841 v2si __builtin_arm_wminsw (v2si, v2si)
8842 v8qi __builtin_arm_wminub (v8qi, v8qi)
8843 v4hi __builtin_arm_wminuh (v4hi, v4hi)
8844 v2si __builtin_arm_wminuw (v2si, v2si)
8845 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
8846 v4hi __builtin_arm_wmulul (v4hi, v4hi)
8847 v4hi __builtin_arm_wmulum (v4hi, v4hi)
8848 long long __builtin_arm_wor (long long, long long)
8849 v2si __builtin_arm_wpackdss (long long, long long)
8850 v2si __builtin_arm_wpackdus (long long, long long)
8851 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
8852 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
8853 v4hi __builtin_arm_wpackwss (v2si, v2si)
8854 v4hi __builtin_arm_wpackwus (v2si, v2si)
8855 long long __builtin_arm_wrord (long long, long long)
8856 long long __builtin_arm_wrordi (long long, int)
8857 v4hi __builtin_arm_wrorh (v4hi, long long)
8858 v4hi __builtin_arm_wrorhi (v4hi, int)
8859 v2si __builtin_arm_wrorw (v2si, long long)
8860 v2si __builtin_arm_wrorwi (v2si, int)
8861 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
8862 v2si __builtin_arm_wsadbz (v8qi, v8qi)
8863 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
8864 v2si __builtin_arm_wsadhz (v4hi, v4hi)
8865 v4hi __builtin_arm_wshufh (v4hi, int)
8866 long long __builtin_arm_wslld (long long, long long)
8867 long long __builtin_arm_wslldi (long long, int)
8868 v4hi __builtin_arm_wsllh (v4hi, long long)
8869 v4hi __builtin_arm_wsllhi (v4hi, int)
8870 v2si __builtin_arm_wsllw (v2si, long long)
8871 v2si __builtin_arm_wsllwi (v2si, int)
8872 long long __builtin_arm_wsrad (long long, long long)
8873 long long __builtin_arm_wsradi (long long, int)
8874 v4hi __builtin_arm_wsrah (v4hi, long long)
8875 v4hi __builtin_arm_wsrahi (v4hi, int)
8876 v2si __builtin_arm_wsraw (v2si, long long)
8877 v2si __builtin_arm_wsrawi (v2si, int)
8878 long long __builtin_arm_wsrld (long long, long long)
8879 long long __builtin_arm_wsrldi (long long, int)
8880 v4hi __builtin_arm_wsrlh (v4hi, long long)
8881 v4hi __builtin_arm_wsrlhi (v4hi, int)
8882 v2si __builtin_arm_wsrlw (v2si, long long)
8883 v2si __builtin_arm_wsrlwi (v2si, int)
8884 v8qi __builtin_arm_wsubb (v8qi, v8qi)
8885 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
8886 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
8887 v4hi __builtin_arm_wsubh (v4hi, v4hi)
8888 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
8889 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
8890 v2si __builtin_arm_wsubw (v2si, v2si)
8891 v2si __builtin_arm_wsubwss (v2si, v2si)
8892 v2si __builtin_arm_wsubwus (v2si, v2si)
8893 v4hi __builtin_arm_wunpckehsb (v8qi)
8894 v2si __builtin_arm_wunpckehsh (v4hi)
8895 long long __builtin_arm_wunpckehsw (v2si)
8896 v4hi __builtin_arm_wunpckehub (v8qi)
8897 v2si __builtin_arm_wunpckehuh (v4hi)
8898 long long __builtin_arm_wunpckehuw (v2si)
8899 v4hi __builtin_arm_wunpckelsb (v8qi)
8900 v2si __builtin_arm_wunpckelsh (v4hi)
8901 long long __builtin_arm_wunpckelsw (v2si)
8902 v4hi __builtin_arm_wunpckelub (v8qi)
8903 v2si __builtin_arm_wunpckeluh (v4hi)
8904 long long __builtin_arm_wunpckeluw (v2si)
8905 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
8906 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
8907 v2si __builtin_arm_wunpckihw (v2si, v2si)
8908 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
8909 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
8910 v2si __builtin_arm_wunpckilw (v2si, v2si)
8911 long long __builtin_arm_wxor (long long, long long)
8912 long long __builtin_arm_wzero ()
8913 @end smallexample
8914
8915 @node ARM NEON Intrinsics
8916 @subsection ARM NEON Intrinsics
8917
8918 These built-in intrinsics for the ARM Advanced SIMD extension are available
8919 when the @option{-mfpu=neon} switch is used:
8920
8921 @include arm-neon-intrinsics.texi
8922
8923 @node AVR Built-in Functions
8924 @subsection AVR Built-in Functions
8925
8926 For each built-in function for AVR, there is an equally named,
8927 uppercase built-in macro defined. That way users can easily query if
8928 or if not a specific built-in is implemented or not. For example, if
8929 @code{__builtin_avr_nop} is available the macro
8930 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
8931
8932 The following built-in functions map to the respective machine
8933 instruction, i.e. @code{nop}, @code{sei}, @code{cli}, @code{sleep},
8934 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
8935 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
8936 as library call if no hardware multiplier is available.
8937
8938 @smallexample
8939 void __builtin_avr_nop (void)
8940 void __builtin_avr_sei (void)
8941 void __builtin_avr_cli (void)
8942 void __builtin_avr_sleep (void)
8943 void __builtin_avr_wdr (void)
8944 unsigned char __builtin_avr_swap (unsigned char)
8945 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
8946 int __builtin_avr_fmuls (char, char)
8947 int __builtin_avr_fmulsu (char, unsigned char)
8948 @end smallexample
8949
8950 In order to delay execution for a specific number of cycles, GCC
8951 implements
8952 @smallexample
8953 void __builtin_avr_delay_cycles (unsigned long ticks)
8954 @end smallexample
8955
8956 @noindent
8957 @code{ticks} is the number of ticks to delay execution. Note that this
8958 built-in does not take into account the effect of interrupts which
8959 might increase delay time. @code{ticks} must be a compile time
8960 integer constant; delays with a variable number of cycles are not supported.
8961
8962 @smallexample
8963 char __builtin_avr_flash_segment (const __memx void*)
8964 @end smallexample
8965
8966 @noindent
8967 This built-in takes a byte address to the 24-bit
8968 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
8969 the number of the flash segment (the 64 KiB chunk) where the address
8970 points to. Counting starts at @code{0}.
8971 If the address does not point to flash memory, return @code{-1}.
8972
8973 @smallexample
8974 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
8975 @end smallexample
8976
8977 @noindent
8978 Insert bits from @var{bits} into @var{val} and return the resulting
8979 value. The nibbles of @var{map} determine how the insertion is
8980 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
8981 @enumerate
8982 @item If @var{X} is @code{0xf},
8983 then the @var{n}-th bit of @var{val} is returned unaltered.
8984
8985 @item If X is in the range 0@dots{}7,
8986 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
8987
8988 @item If X is in the range 8@dots{}@code{0xe},
8989 then the @var{n}-th result bit is undefined.
8990 @end enumerate
8991
8992 @noindent
8993 One typical use case for this built-in is adjusting input and
8994 output values to non-contiguous port layouts. Some examples:
8995
8996 @smallexample
8997 // same as val, bits is unused
8998 __builtin_avr_insert_bits (0xffffffff, bits, val)
8999 @end smallexample
9000
9001 @smallexample
9002 // same as bits, val is unused
9003 __builtin_avr_insert_bits (0x76543210, bits, val)
9004 @end smallexample
9005
9006 @smallexample
9007 // same as rotating bits by 4
9008 __builtin_avr_insert_bits (0x32107654, bits, 0)
9009 @end smallexample
9010
9011 @smallexample
9012 // high-nibble of result is the high-nibble of val
9013 // low-nibble of result is the low-nibble of bits
9014 __builtin_avr_insert_bits (0xffff3210, bits, val)
9015 @end smallexample
9016
9017 @smallexample
9018 // reverse the bit order of bits
9019 __builtin_avr_insert_bits (0x01234567, bits, 0)
9020 @end smallexample
9021
9022 @node Blackfin Built-in Functions
9023 @subsection Blackfin Built-in Functions
9024
9025 Currently, there are two Blackfin-specific built-in functions. These are
9026 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9027 using inline assembly; by using these built-in functions the compiler can
9028 automatically add workarounds for hardware errata involving these
9029 instructions. These functions are named as follows:
9030
9031 @smallexample
9032 void __builtin_bfin_csync (void)
9033 void __builtin_bfin_ssync (void)
9034 @end smallexample
9035
9036 @node FR-V Built-in Functions
9037 @subsection FR-V Built-in Functions
9038
9039 GCC provides many FR-V-specific built-in functions. In general,
9040 these functions are intended to be compatible with those described
9041 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9042 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
9043 @code{__MBTOHE}, the gcc forms of which pass 128-bit values by
9044 pointer rather than by value.
9045
9046 Most of the functions are named after specific FR-V instructions.
9047 Such functions are said to be ``directly mapped'' and are summarized
9048 here in tabular form.
9049
9050 @menu
9051 * Argument Types::
9052 * Directly-mapped Integer Functions::
9053 * Directly-mapped Media Functions::
9054 * Raw read/write Functions::
9055 * Other Built-in Functions::
9056 @end menu
9057
9058 @node Argument Types
9059 @subsubsection Argument Types
9060
9061 The arguments to the built-in functions can be divided into three groups:
9062 register numbers, compile-time constants and run-time values. In order
9063 to make this classification clear at a glance, the arguments and return
9064 values are given the following pseudo types:
9065
9066 @multitable @columnfractions .20 .30 .15 .35
9067 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9068 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9069 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9070 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9071 @item @code{uw2} @tab @code{unsigned long long} @tab No
9072 @tab an unsigned doubleword
9073 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9074 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9075 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9076 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9077 @end multitable
9078
9079 These pseudo types are not defined by GCC, they are simply a notational
9080 convenience used in this manual.
9081
9082 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9083 and @code{sw2} are evaluated at run time. They correspond to
9084 register operands in the underlying FR-V instructions.
9085
9086 @code{const} arguments represent immediate operands in the underlying
9087 FR-V instructions. They must be compile-time constants.
9088
9089 @code{acc} arguments are evaluated at compile time and specify the number
9090 of an accumulator register. For example, an @code{acc} argument of 2
9091 selects the ACC2 register.
9092
9093 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9094 number of an IACC register. See @pxref{Other Built-in Functions}
9095 for more details.
9096
9097 @node Directly-mapped Integer Functions
9098 @subsubsection Directly-mapped Integer Functions
9099
9100 The functions listed below map directly to FR-V I-type instructions.
9101
9102 @multitable @columnfractions .45 .32 .23
9103 @item Function prototype @tab Example usage @tab Assembly output
9104 @item @code{sw1 __ADDSS (sw1, sw1)}
9105 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9106 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9107 @item @code{sw1 __SCAN (sw1, sw1)}
9108 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9109 @tab @code{SCAN @var{a},@var{b},@var{c}}
9110 @item @code{sw1 __SCUTSS (sw1)}
9111 @tab @code{@var{b} = __SCUTSS (@var{a})}
9112 @tab @code{SCUTSS @var{a},@var{b}}
9113 @item @code{sw1 __SLASS (sw1, sw1)}
9114 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9115 @tab @code{SLASS @var{a},@var{b},@var{c}}
9116 @item @code{void __SMASS (sw1, sw1)}
9117 @tab @code{__SMASS (@var{a}, @var{b})}
9118 @tab @code{SMASS @var{a},@var{b}}
9119 @item @code{void __SMSSS (sw1, sw1)}
9120 @tab @code{__SMSSS (@var{a}, @var{b})}
9121 @tab @code{SMSSS @var{a},@var{b}}
9122 @item @code{void __SMU (sw1, sw1)}
9123 @tab @code{__SMU (@var{a}, @var{b})}
9124 @tab @code{SMU @var{a},@var{b}}
9125 @item @code{sw2 __SMUL (sw1, sw1)}
9126 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9127 @tab @code{SMUL @var{a},@var{b},@var{c}}
9128 @item @code{sw1 __SUBSS (sw1, sw1)}
9129 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9130 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9131 @item @code{uw2 __UMUL (uw1, uw1)}
9132 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9133 @tab @code{UMUL @var{a},@var{b},@var{c}}
9134 @end multitable
9135
9136 @node Directly-mapped Media Functions
9137 @subsubsection Directly-mapped Media Functions
9138
9139 The functions listed below map directly to FR-V M-type instructions.
9140
9141 @multitable @columnfractions .45 .32 .23
9142 @item Function prototype @tab Example usage @tab Assembly output
9143 @item @code{uw1 __MABSHS (sw1)}
9144 @tab @code{@var{b} = __MABSHS (@var{a})}
9145 @tab @code{MABSHS @var{a},@var{b}}
9146 @item @code{void __MADDACCS (acc, acc)}
9147 @tab @code{__MADDACCS (@var{b}, @var{a})}
9148 @tab @code{MADDACCS @var{a},@var{b}}
9149 @item @code{sw1 __MADDHSS (sw1, sw1)}
9150 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9151 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9152 @item @code{uw1 __MADDHUS (uw1, uw1)}
9153 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9154 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9155 @item @code{uw1 __MAND (uw1, uw1)}
9156 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9157 @tab @code{MAND @var{a},@var{b},@var{c}}
9158 @item @code{void __MASACCS (acc, acc)}
9159 @tab @code{__MASACCS (@var{b}, @var{a})}
9160 @tab @code{MASACCS @var{a},@var{b}}
9161 @item @code{uw1 __MAVEH (uw1, uw1)}
9162 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9163 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9164 @item @code{uw2 __MBTOH (uw1)}
9165 @tab @code{@var{b} = __MBTOH (@var{a})}
9166 @tab @code{MBTOH @var{a},@var{b}}
9167 @item @code{void __MBTOHE (uw1 *, uw1)}
9168 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9169 @tab @code{MBTOHE @var{a},@var{b}}
9170 @item @code{void __MCLRACC (acc)}
9171 @tab @code{__MCLRACC (@var{a})}
9172 @tab @code{MCLRACC @var{a}}
9173 @item @code{void __MCLRACCA (void)}
9174 @tab @code{__MCLRACCA ()}
9175 @tab @code{MCLRACCA}
9176 @item @code{uw1 __Mcop1 (uw1, uw1)}
9177 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9178 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9179 @item @code{uw1 __Mcop2 (uw1, uw1)}
9180 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9181 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9182 @item @code{uw1 __MCPLHI (uw2, const)}
9183 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9184 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9185 @item @code{uw1 __MCPLI (uw2, const)}
9186 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9187 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9188 @item @code{void __MCPXIS (acc, sw1, sw1)}
9189 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9190 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9191 @item @code{void __MCPXIU (acc, uw1, uw1)}
9192 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9193 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9194 @item @code{void __MCPXRS (acc, sw1, sw1)}
9195 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9196 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9197 @item @code{void __MCPXRU (acc, uw1, uw1)}
9198 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9199 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9200 @item @code{uw1 __MCUT (acc, uw1)}
9201 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9202 @tab @code{MCUT @var{a},@var{b},@var{c}}
9203 @item @code{uw1 __MCUTSS (acc, sw1)}
9204 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9205 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9206 @item @code{void __MDADDACCS (acc, acc)}
9207 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9208 @tab @code{MDADDACCS @var{a},@var{b}}
9209 @item @code{void __MDASACCS (acc, acc)}
9210 @tab @code{__MDASACCS (@var{b}, @var{a})}
9211 @tab @code{MDASACCS @var{a},@var{b}}
9212 @item @code{uw2 __MDCUTSSI (acc, const)}
9213 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
9214 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
9215 @item @code{uw2 __MDPACKH (uw2, uw2)}
9216 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
9217 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
9218 @item @code{uw2 __MDROTLI (uw2, const)}
9219 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
9220 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
9221 @item @code{void __MDSUBACCS (acc, acc)}
9222 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
9223 @tab @code{MDSUBACCS @var{a},@var{b}}
9224 @item @code{void __MDUNPACKH (uw1 *, uw2)}
9225 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
9226 @tab @code{MDUNPACKH @var{a},@var{b}}
9227 @item @code{uw2 __MEXPDHD (uw1, const)}
9228 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
9229 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
9230 @item @code{uw1 __MEXPDHW (uw1, const)}
9231 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
9232 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
9233 @item @code{uw1 __MHDSETH (uw1, const)}
9234 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
9235 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
9236 @item @code{sw1 __MHDSETS (const)}
9237 @tab @code{@var{b} = __MHDSETS (@var{a})}
9238 @tab @code{MHDSETS #@var{a},@var{b}}
9239 @item @code{uw1 __MHSETHIH (uw1, const)}
9240 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
9241 @tab @code{MHSETHIH #@var{a},@var{b}}
9242 @item @code{sw1 __MHSETHIS (sw1, const)}
9243 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
9244 @tab @code{MHSETHIS #@var{a},@var{b}}
9245 @item @code{uw1 __MHSETLOH (uw1, const)}
9246 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
9247 @tab @code{MHSETLOH #@var{a},@var{b}}
9248 @item @code{sw1 __MHSETLOS (sw1, const)}
9249 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
9250 @tab @code{MHSETLOS #@var{a},@var{b}}
9251 @item @code{uw1 __MHTOB (uw2)}
9252 @tab @code{@var{b} = __MHTOB (@var{a})}
9253 @tab @code{MHTOB @var{a},@var{b}}
9254 @item @code{void __MMACHS (acc, sw1, sw1)}
9255 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
9256 @tab @code{MMACHS @var{a},@var{b},@var{c}}
9257 @item @code{void __MMACHU (acc, uw1, uw1)}
9258 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
9259 @tab @code{MMACHU @var{a},@var{b},@var{c}}
9260 @item @code{void __MMRDHS (acc, sw1, sw1)}
9261 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
9262 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
9263 @item @code{void __MMRDHU (acc, uw1, uw1)}
9264 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
9265 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
9266 @item @code{void __MMULHS (acc, sw1, sw1)}
9267 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
9268 @tab @code{MMULHS @var{a},@var{b},@var{c}}
9269 @item @code{void __MMULHU (acc, uw1, uw1)}
9270 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
9271 @tab @code{MMULHU @var{a},@var{b},@var{c}}
9272 @item @code{void __MMULXHS (acc, sw1, sw1)}
9273 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
9274 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
9275 @item @code{void __MMULXHU (acc, uw1, uw1)}
9276 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
9277 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
9278 @item @code{uw1 __MNOT (uw1)}
9279 @tab @code{@var{b} = __MNOT (@var{a})}
9280 @tab @code{MNOT @var{a},@var{b}}
9281 @item @code{uw1 __MOR (uw1, uw1)}
9282 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
9283 @tab @code{MOR @var{a},@var{b},@var{c}}
9284 @item @code{uw1 __MPACKH (uh, uh)}
9285 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
9286 @tab @code{MPACKH @var{a},@var{b},@var{c}}
9287 @item @code{sw2 __MQADDHSS (sw2, sw2)}
9288 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
9289 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
9290 @item @code{uw2 __MQADDHUS (uw2, uw2)}
9291 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
9292 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
9293 @item @code{void __MQCPXIS (acc, sw2, sw2)}
9294 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
9295 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
9296 @item @code{void __MQCPXIU (acc, uw2, uw2)}
9297 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
9298 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
9299 @item @code{void __MQCPXRS (acc, sw2, sw2)}
9300 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
9301 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
9302 @item @code{void __MQCPXRU (acc, uw2, uw2)}
9303 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
9304 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
9305 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
9306 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
9307 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
9308 @item @code{sw2 __MQLMTHS (sw2, sw2)}
9309 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
9310 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
9311 @item @code{void __MQMACHS (acc, sw2, sw2)}
9312 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
9313 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
9314 @item @code{void __MQMACHU (acc, uw2, uw2)}
9315 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
9316 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
9317 @item @code{void __MQMACXHS (acc, sw2, sw2)}
9318 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
9319 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
9320 @item @code{void __MQMULHS (acc, sw2, sw2)}
9321 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
9322 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
9323 @item @code{void __MQMULHU (acc, uw2, uw2)}
9324 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
9325 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
9326 @item @code{void __MQMULXHS (acc, sw2, sw2)}
9327 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
9328 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
9329 @item @code{void __MQMULXHU (acc, uw2, uw2)}
9330 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
9331 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
9332 @item @code{sw2 __MQSATHS (sw2, sw2)}
9333 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
9334 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
9335 @item @code{uw2 __MQSLLHI (uw2, int)}
9336 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
9337 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
9338 @item @code{sw2 __MQSRAHI (sw2, int)}
9339 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
9340 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
9341 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
9342 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
9343 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
9344 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
9345 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
9346 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
9347 @item @code{void __MQXMACHS (acc, sw2, sw2)}
9348 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
9349 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
9350 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
9351 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
9352 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
9353 @item @code{uw1 __MRDACC (acc)}
9354 @tab @code{@var{b} = __MRDACC (@var{a})}
9355 @tab @code{MRDACC @var{a},@var{b}}
9356 @item @code{uw1 __MRDACCG (acc)}
9357 @tab @code{@var{b} = __MRDACCG (@var{a})}
9358 @tab @code{MRDACCG @var{a},@var{b}}
9359 @item @code{uw1 __MROTLI (uw1, const)}
9360 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
9361 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
9362 @item @code{uw1 __MROTRI (uw1, const)}
9363 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
9364 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
9365 @item @code{sw1 __MSATHS (sw1, sw1)}
9366 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
9367 @tab @code{MSATHS @var{a},@var{b},@var{c}}
9368 @item @code{uw1 __MSATHU (uw1, uw1)}
9369 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
9370 @tab @code{MSATHU @var{a},@var{b},@var{c}}
9371 @item @code{uw1 __MSLLHI (uw1, const)}
9372 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
9373 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
9374 @item @code{sw1 __MSRAHI (sw1, const)}
9375 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
9376 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
9377 @item @code{uw1 __MSRLHI (uw1, const)}
9378 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
9379 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
9380 @item @code{void __MSUBACCS (acc, acc)}
9381 @tab @code{__MSUBACCS (@var{b}, @var{a})}
9382 @tab @code{MSUBACCS @var{a},@var{b}}
9383 @item @code{sw1 __MSUBHSS (sw1, sw1)}
9384 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
9385 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
9386 @item @code{uw1 __MSUBHUS (uw1, uw1)}
9387 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
9388 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
9389 @item @code{void __MTRAP (void)}
9390 @tab @code{__MTRAP ()}
9391 @tab @code{MTRAP}
9392 @item @code{uw2 __MUNPACKH (uw1)}
9393 @tab @code{@var{b} = __MUNPACKH (@var{a})}
9394 @tab @code{MUNPACKH @var{a},@var{b}}
9395 @item @code{uw1 __MWCUT (uw2, uw1)}
9396 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
9397 @tab @code{MWCUT @var{a},@var{b},@var{c}}
9398 @item @code{void __MWTACC (acc, uw1)}
9399 @tab @code{__MWTACC (@var{b}, @var{a})}
9400 @tab @code{MWTACC @var{a},@var{b}}
9401 @item @code{void __MWTACCG (acc, uw1)}
9402 @tab @code{__MWTACCG (@var{b}, @var{a})}
9403 @tab @code{MWTACCG @var{a},@var{b}}
9404 @item @code{uw1 __MXOR (uw1, uw1)}
9405 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
9406 @tab @code{MXOR @var{a},@var{b},@var{c}}
9407 @end multitable
9408
9409 @node Raw read/write Functions
9410 @subsubsection Raw read/write Functions
9411
9412 This sections describes built-in functions related to read and write
9413 instructions to access memory. These functions generate
9414 @code{membar} instructions to flush the I/O load and stores where
9415 appropriate, as described in Fujitsu's manual described above.
9416
9417 @table @code
9418
9419 @item unsigned char __builtin_read8 (void *@var{data})
9420 @item unsigned short __builtin_read16 (void *@var{data})
9421 @item unsigned long __builtin_read32 (void *@var{data})
9422 @item unsigned long long __builtin_read64 (void *@var{data})
9423
9424 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
9425 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
9426 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
9427 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
9428 @end table
9429
9430 @node Other Built-in Functions
9431 @subsubsection Other Built-in Functions
9432
9433 This section describes built-in functions that are not named after
9434 a specific FR-V instruction.
9435
9436 @table @code
9437 @item sw2 __IACCreadll (iacc @var{reg})
9438 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
9439 for future expansion and must be 0.
9440
9441 @item sw1 __IACCreadl (iacc @var{reg})
9442 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
9443 Other values of @var{reg} are rejected as invalid.
9444
9445 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
9446 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
9447 is reserved for future expansion and must be 0.
9448
9449 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
9450 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
9451 is 1. Other values of @var{reg} are rejected as invalid.
9452
9453 @item void __data_prefetch0 (const void *@var{x})
9454 Use the @code{dcpl} instruction to load the contents of address @var{x}
9455 into the data cache.
9456
9457 @item void __data_prefetch (const void *@var{x})
9458 Use the @code{nldub} instruction to load the contents of address @var{x}
9459 into the data cache. The instruction is issued in slot I1@.
9460 @end table
9461
9462 @node X86 Built-in Functions
9463 @subsection X86 Built-in Functions
9464
9465 These built-in functions are available for the i386 and x86-64 family
9466 of computers, depending on the command-line switches used.
9467
9468 Note that, if you specify command-line switches such as @option{-msse},
9469 the compiler could use the extended instruction sets even if the built-ins
9470 are not used explicitly in the program. For this reason, applications
9471 which perform runtime CPU detection must compile separate files for each
9472 supported architecture, using the appropriate flags. In particular,
9473 the file containing the CPU detection code should be compiled without
9474 these options.
9475
9476 The following machine modes are available for use with MMX built-in functions
9477 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
9478 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
9479 vector of eight 8-bit integers. Some of the built-in functions operate on
9480 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
9481
9482 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
9483 of two 32-bit floating point values.
9484
9485 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
9486 floating point values. Some instructions use a vector of four 32-bit
9487 integers, these use @code{V4SI}. Finally, some instructions operate on an
9488 entire vector register, interpreting it as a 128-bit integer, these use mode
9489 @code{TI}.
9490
9491 In 64-bit mode, the x86-64 family of processors uses additional built-in
9492 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
9493 floating point and @code{TC} 128-bit complex floating point values.
9494
9495 The following floating point built-in functions are available in 64-bit
9496 mode. All of them implement the function that is part of the name.
9497
9498 @smallexample
9499 __float128 __builtin_fabsq (__float128)
9500 __float128 __builtin_copysignq (__float128, __float128)
9501 @end smallexample
9502
9503 The following built-in function is always available.
9504
9505 @table @code
9506 @item void __builtin_ia32_pause (void)
9507 Generates the @code{pause} machine instruction with a compiler memory
9508 barrier.
9509 @end table
9510
9511 The following floating point built-in functions are made available in the
9512 64-bit mode.
9513
9514 @table @code
9515 @item __float128 __builtin_infq (void)
9516 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
9517 @findex __builtin_infq
9518
9519 @item __float128 __builtin_huge_valq (void)
9520 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
9521 @findex __builtin_huge_valq
9522 @end table
9523
9524 The following built-in functions are always available and can be used to
9525 check the target platform type.
9526
9527 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
9528 This function runs the CPU detection code to check the type of CPU and the
9529 features supported. This builtin needs to be invoked along with the builtins
9530 to check CPU type and features, @code{__builtin_cpu_is} and
9531 @code{__builtin_cpu_supports}, only when used in a function that is
9532 executed before any constructors are called. The CPU detection code is
9533 automatically executed in a very high priority constructor.
9534
9535 For example, this function has to be used in @code{ifunc} resolvers which
9536 check for CPU type using the builtins @code{__builtin_cpu_is}
9537 and @code{__builtin_cpu_supports}, or in constructors on targets which
9538 don't support constructor priority.
9539 @smallexample
9540
9541 static void (*resolve_memcpy (void)) (void)
9542 @{
9543 // ifunc resolvers fire before constructors, explicitly call the init
9544 // function.
9545 __builtin_cpu_init ();
9546 if (__builtin_cpu_supports ("ssse3"))
9547 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
9548 else
9549 return default_memcpy;
9550 @}
9551
9552 void *memcpy (void *, const void *, size_t)
9553 __attribute__ ((ifunc ("resolve_memcpy")));
9554 @end smallexample
9555
9556 @end deftypefn
9557
9558 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
9559 This function returns a positive integer if the runtime cpu is of type @var{cpuname}
9560 and returns @code{0} otherwise. The following cpu names can be detected:
9561
9562 @table @samp
9563 @item intel
9564 Intel CPU.
9565
9566 @item atom
9567 Intel ATOM CPU.
9568
9569 @item core2
9570 Intel Core2 CPU.
9571
9572 @item corei7
9573 Intel Corei7 CPU.
9574
9575 @item nehalem
9576 Intel Corei7 Nehalem CPU.
9577
9578 @item westmere
9579 Intel Corei7 Westmere CPU.
9580
9581 @item sandybridge
9582 Intel Corei7 Sandybridge CPU.
9583
9584 @item amd
9585 AMD CPU.
9586
9587 @item amdfam10h
9588 AMD family 10h CPU.
9589
9590 @item barcelona
9591 AMD family 10h Barcelona CPU.
9592
9593 @item shanghai
9594 AMD family 10h Shanghai CPU.
9595
9596 @item istanbul
9597 AMD family 10h Istanbul CPU.
9598
9599 @item btver1
9600 AMD family 14h CPU.
9601
9602 @item amdfam15h
9603 AMD family 15h CPU.
9604
9605 @item bdver1
9606 AMD family 15h Bulldozer version 1.
9607
9608 @item bdver2
9609 AMD family 15h Bulldozer version 2.
9610
9611 @item btver2
9612 AMD family 16h CPU.
9613 @end table
9614
9615 Here is an example:
9616 @smallexample
9617 if (__builtin_cpu_is ("corei7"))
9618 @{
9619 do_corei7 (); //Corei7 specific implementation.
9620 @}
9621 else
9622 @{
9623 do_generic (); //Generic implementation.
9624 @}
9625 @end smallexample
9626 @end deftypefn
9627
9628 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
9629 This function returns a positive integer if the runtime cpu supports @var{feature}
9630 and returns @code{0} otherwise. The following features can be detected:
9631
9632 @table @samp
9633 @item cmov
9634 CMOV instruction.
9635 @item mmx
9636 MMX instructions.
9637 @item popcnt
9638 POPCNT instruction.
9639 @item sse
9640 SSE instructions.
9641 @item sse2
9642 SSE2 instructions.
9643 @item sse3
9644 SSE3 instructions.
9645 @item ssse3
9646 SSSE3 instructions.
9647 @item sse4.1
9648 SSE4.1 instructions.
9649 @item sse4.2
9650 SSE4.2 instructions.
9651 @item avx
9652 AVX instructions.
9653 @item avx2
9654 AVX2 instructions.
9655 @end table
9656
9657 Here is an example:
9658 @smallexample
9659 if (__builtin_cpu_supports ("popcnt"))
9660 @{
9661 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
9662 @}
9663 else
9664 @{
9665 count = generic_countbits (n); //generic implementation.
9666 @}
9667 @end smallexample
9668 @end deftypefn
9669
9670
9671 The following built-in functions are made available by @option{-mmmx}.
9672 All of them generate the machine instruction that is part of the name.
9673
9674 @smallexample
9675 v8qi __builtin_ia32_paddb (v8qi, v8qi)
9676 v4hi __builtin_ia32_paddw (v4hi, v4hi)
9677 v2si __builtin_ia32_paddd (v2si, v2si)
9678 v8qi __builtin_ia32_psubb (v8qi, v8qi)
9679 v4hi __builtin_ia32_psubw (v4hi, v4hi)
9680 v2si __builtin_ia32_psubd (v2si, v2si)
9681 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
9682 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
9683 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
9684 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
9685 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
9686 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
9687 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
9688 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
9689 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
9690 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
9691 di __builtin_ia32_pand (di, di)
9692 di __builtin_ia32_pandn (di,di)
9693 di __builtin_ia32_por (di, di)
9694 di __builtin_ia32_pxor (di, di)
9695 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
9696 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
9697 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
9698 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
9699 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
9700 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
9701 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
9702 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
9703 v2si __builtin_ia32_punpckhdq (v2si, v2si)
9704 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
9705 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
9706 v2si __builtin_ia32_punpckldq (v2si, v2si)
9707 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
9708 v4hi __builtin_ia32_packssdw (v2si, v2si)
9709 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
9710
9711 v4hi __builtin_ia32_psllw (v4hi, v4hi)
9712 v2si __builtin_ia32_pslld (v2si, v2si)
9713 v1di __builtin_ia32_psllq (v1di, v1di)
9714 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
9715 v2si __builtin_ia32_psrld (v2si, v2si)
9716 v1di __builtin_ia32_psrlq (v1di, v1di)
9717 v4hi __builtin_ia32_psraw (v4hi, v4hi)
9718 v2si __builtin_ia32_psrad (v2si, v2si)
9719 v4hi __builtin_ia32_psllwi (v4hi, int)
9720 v2si __builtin_ia32_pslldi (v2si, int)
9721 v1di __builtin_ia32_psllqi (v1di, int)
9722 v4hi __builtin_ia32_psrlwi (v4hi, int)
9723 v2si __builtin_ia32_psrldi (v2si, int)
9724 v1di __builtin_ia32_psrlqi (v1di, int)
9725 v4hi __builtin_ia32_psrawi (v4hi, int)
9726 v2si __builtin_ia32_psradi (v2si, int)
9727
9728 @end smallexample
9729
9730 The following built-in functions are made available either with
9731 @option{-msse}, or with a combination of @option{-m3dnow} and
9732 @option{-march=athlon}. All of them generate the machine
9733 instruction that is part of the name.
9734
9735 @smallexample
9736 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
9737 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
9738 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
9739 v1di __builtin_ia32_psadbw (v8qi, v8qi)
9740 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
9741 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
9742 v8qi __builtin_ia32_pminub (v8qi, v8qi)
9743 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
9744 int __builtin_ia32_pextrw (v4hi, int)
9745 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
9746 int __builtin_ia32_pmovmskb (v8qi)
9747 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
9748 void __builtin_ia32_movntq (di *, di)
9749 void __builtin_ia32_sfence (void)
9750 @end smallexample
9751
9752 The following built-in functions are available when @option{-msse} is used.
9753 All of them generate the machine instruction that is part of the name.
9754
9755 @smallexample
9756 int __builtin_ia32_comieq (v4sf, v4sf)
9757 int __builtin_ia32_comineq (v4sf, v4sf)
9758 int __builtin_ia32_comilt (v4sf, v4sf)
9759 int __builtin_ia32_comile (v4sf, v4sf)
9760 int __builtin_ia32_comigt (v4sf, v4sf)
9761 int __builtin_ia32_comige (v4sf, v4sf)
9762 int __builtin_ia32_ucomieq (v4sf, v4sf)
9763 int __builtin_ia32_ucomineq (v4sf, v4sf)
9764 int __builtin_ia32_ucomilt (v4sf, v4sf)
9765 int __builtin_ia32_ucomile (v4sf, v4sf)
9766 int __builtin_ia32_ucomigt (v4sf, v4sf)
9767 int __builtin_ia32_ucomige (v4sf, v4sf)
9768 v4sf __builtin_ia32_addps (v4sf, v4sf)
9769 v4sf __builtin_ia32_subps (v4sf, v4sf)
9770 v4sf __builtin_ia32_mulps (v4sf, v4sf)
9771 v4sf __builtin_ia32_divps (v4sf, v4sf)
9772 v4sf __builtin_ia32_addss (v4sf, v4sf)
9773 v4sf __builtin_ia32_subss (v4sf, v4sf)
9774 v4sf __builtin_ia32_mulss (v4sf, v4sf)
9775 v4sf __builtin_ia32_divss (v4sf, v4sf)
9776 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
9777 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
9778 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
9779 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
9780 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
9781 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
9782 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
9783 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
9784 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
9785 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
9786 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
9787 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
9788 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
9789 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
9790 v4si __builtin_ia32_cmpless (v4sf, v4sf)
9791 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
9792 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
9793 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
9794 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
9795 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
9796 v4sf __builtin_ia32_maxps (v4sf, v4sf)
9797 v4sf __builtin_ia32_maxss (v4sf, v4sf)
9798 v4sf __builtin_ia32_minps (v4sf, v4sf)
9799 v4sf __builtin_ia32_minss (v4sf, v4sf)
9800 v4sf __builtin_ia32_andps (v4sf, v4sf)
9801 v4sf __builtin_ia32_andnps (v4sf, v4sf)
9802 v4sf __builtin_ia32_orps (v4sf, v4sf)
9803 v4sf __builtin_ia32_xorps (v4sf, v4sf)
9804 v4sf __builtin_ia32_movss (v4sf, v4sf)
9805 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
9806 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
9807 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
9808 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
9809 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
9810 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
9811 v2si __builtin_ia32_cvtps2pi (v4sf)
9812 int __builtin_ia32_cvtss2si (v4sf)
9813 v2si __builtin_ia32_cvttps2pi (v4sf)
9814 int __builtin_ia32_cvttss2si (v4sf)
9815 v4sf __builtin_ia32_rcpps (v4sf)
9816 v4sf __builtin_ia32_rsqrtps (v4sf)
9817 v4sf __builtin_ia32_sqrtps (v4sf)
9818 v4sf __builtin_ia32_rcpss (v4sf)
9819 v4sf __builtin_ia32_rsqrtss (v4sf)
9820 v4sf __builtin_ia32_sqrtss (v4sf)
9821 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
9822 void __builtin_ia32_movntps (float *, v4sf)
9823 int __builtin_ia32_movmskps (v4sf)
9824 @end smallexample
9825
9826 The following built-in functions are available when @option{-msse} is used.
9827
9828 @table @code
9829 @item v4sf __builtin_ia32_loadaps (float *)
9830 Generates the @code{movaps} machine instruction as a load from memory.
9831 @item void __builtin_ia32_storeaps (float *, v4sf)
9832 Generates the @code{movaps} machine instruction as a store to memory.
9833 @item v4sf __builtin_ia32_loadups (float *)
9834 Generates the @code{movups} machine instruction as a load from memory.
9835 @item void __builtin_ia32_storeups (float *, v4sf)
9836 Generates the @code{movups} machine instruction as a store to memory.
9837 @item v4sf __builtin_ia32_loadsss (float *)
9838 Generates the @code{movss} machine instruction as a load from memory.
9839 @item void __builtin_ia32_storess (float *, v4sf)
9840 Generates the @code{movss} machine instruction as a store to memory.
9841 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
9842 Generates the @code{movhps} machine instruction as a load from memory.
9843 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
9844 Generates the @code{movlps} machine instruction as a load from memory
9845 @item void __builtin_ia32_storehps (v2sf *, v4sf)
9846 Generates the @code{movhps} machine instruction as a store to memory.
9847 @item void __builtin_ia32_storelps (v2sf *, v4sf)
9848 Generates the @code{movlps} machine instruction as a store to memory.
9849 @end table
9850
9851 The following built-in functions are available when @option{-msse2} is used.
9852 All of them generate the machine instruction that is part of the name.
9853
9854 @smallexample
9855 int __builtin_ia32_comisdeq (v2df, v2df)
9856 int __builtin_ia32_comisdlt (v2df, v2df)
9857 int __builtin_ia32_comisdle (v2df, v2df)
9858 int __builtin_ia32_comisdgt (v2df, v2df)
9859 int __builtin_ia32_comisdge (v2df, v2df)
9860 int __builtin_ia32_comisdneq (v2df, v2df)
9861 int __builtin_ia32_ucomisdeq (v2df, v2df)
9862 int __builtin_ia32_ucomisdlt (v2df, v2df)
9863 int __builtin_ia32_ucomisdle (v2df, v2df)
9864 int __builtin_ia32_ucomisdgt (v2df, v2df)
9865 int __builtin_ia32_ucomisdge (v2df, v2df)
9866 int __builtin_ia32_ucomisdneq (v2df, v2df)
9867 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
9868 v2df __builtin_ia32_cmpltpd (v2df, v2df)
9869 v2df __builtin_ia32_cmplepd (v2df, v2df)
9870 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
9871 v2df __builtin_ia32_cmpgepd (v2df, v2df)
9872 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
9873 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
9874 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
9875 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
9876 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
9877 v2df __builtin_ia32_cmpngepd (v2df, v2df)
9878 v2df __builtin_ia32_cmpordpd (v2df, v2df)
9879 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
9880 v2df __builtin_ia32_cmpltsd (v2df, v2df)
9881 v2df __builtin_ia32_cmplesd (v2df, v2df)
9882 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
9883 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
9884 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
9885 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
9886 v2df __builtin_ia32_cmpordsd (v2df, v2df)
9887 v2di __builtin_ia32_paddq (v2di, v2di)
9888 v2di __builtin_ia32_psubq (v2di, v2di)
9889 v2df __builtin_ia32_addpd (v2df, v2df)
9890 v2df __builtin_ia32_subpd (v2df, v2df)
9891 v2df __builtin_ia32_mulpd (v2df, v2df)
9892 v2df __builtin_ia32_divpd (v2df, v2df)
9893 v2df __builtin_ia32_addsd (v2df, v2df)
9894 v2df __builtin_ia32_subsd (v2df, v2df)
9895 v2df __builtin_ia32_mulsd (v2df, v2df)
9896 v2df __builtin_ia32_divsd (v2df, v2df)
9897 v2df __builtin_ia32_minpd (v2df, v2df)
9898 v2df __builtin_ia32_maxpd (v2df, v2df)
9899 v2df __builtin_ia32_minsd (v2df, v2df)
9900 v2df __builtin_ia32_maxsd (v2df, v2df)
9901 v2df __builtin_ia32_andpd (v2df, v2df)
9902 v2df __builtin_ia32_andnpd (v2df, v2df)
9903 v2df __builtin_ia32_orpd (v2df, v2df)
9904 v2df __builtin_ia32_xorpd (v2df, v2df)
9905 v2df __builtin_ia32_movsd (v2df, v2df)
9906 v2df __builtin_ia32_unpckhpd (v2df, v2df)
9907 v2df __builtin_ia32_unpcklpd (v2df, v2df)
9908 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
9909 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
9910 v4si __builtin_ia32_paddd128 (v4si, v4si)
9911 v2di __builtin_ia32_paddq128 (v2di, v2di)
9912 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
9913 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
9914 v4si __builtin_ia32_psubd128 (v4si, v4si)
9915 v2di __builtin_ia32_psubq128 (v2di, v2di)
9916 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
9917 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
9918 v2di __builtin_ia32_pand128 (v2di, v2di)
9919 v2di __builtin_ia32_pandn128 (v2di, v2di)
9920 v2di __builtin_ia32_por128 (v2di, v2di)
9921 v2di __builtin_ia32_pxor128 (v2di, v2di)
9922 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
9923 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
9924 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
9925 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
9926 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
9927 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
9928 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
9929 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
9930 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
9931 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
9932 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
9933 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
9934 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
9935 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
9936 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
9937 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
9938 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
9939 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
9940 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
9941 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
9942 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
9943 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
9944 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
9945 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
9946 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
9947 v2df __builtin_ia32_loadupd (double *)
9948 void __builtin_ia32_storeupd (double *, v2df)
9949 v2df __builtin_ia32_loadhpd (v2df, double const *)
9950 v2df __builtin_ia32_loadlpd (v2df, double const *)
9951 int __builtin_ia32_movmskpd (v2df)
9952 int __builtin_ia32_pmovmskb128 (v16qi)
9953 void __builtin_ia32_movnti (int *, int)
9954 void __builtin_ia32_movnti64 (long long int *, long long int)
9955 void __builtin_ia32_movntpd (double *, v2df)
9956 void __builtin_ia32_movntdq (v2df *, v2df)
9957 v4si __builtin_ia32_pshufd (v4si, int)
9958 v8hi __builtin_ia32_pshuflw (v8hi, int)
9959 v8hi __builtin_ia32_pshufhw (v8hi, int)
9960 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
9961 v2df __builtin_ia32_sqrtpd (v2df)
9962 v2df __builtin_ia32_sqrtsd (v2df)
9963 v2df __builtin_ia32_shufpd (v2df, v2df, int)
9964 v2df __builtin_ia32_cvtdq2pd (v4si)
9965 v4sf __builtin_ia32_cvtdq2ps (v4si)
9966 v4si __builtin_ia32_cvtpd2dq (v2df)
9967 v2si __builtin_ia32_cvtpd2pi (v2df)
9968 v4sf __builtin_ia32_cvtpd2ps (v2df)
9969 v4si __builtin_ia32_cvttpd2dq (v2df)
9970 v2si __builtin_ia32_cvttpd2pi (v2df)
9971 v2df __builtin_ia32_cvtpi2pd (v2si)
9972 int __builtin_ia32_cvtsd2si (v2df)
9973 int __builtin_ia32_cvttsd2si (v2df)
9974 long long __builtin_ia32_cvtsd2si64 (v2df)
9975 long long __builtin_ia32_cvttsd2si64 (v2df)
9976 v4si __builtin_ia32_cvtps2dq (v4sf)
9977 v2df __builtin_ia32_cvtps2pd (v4sf)
9978 v4si __builtin_ia32_cvttps2dq (v4sf)
9979 v2df __builtin_ia32_cvtsi2sd (v2df, int)
9980 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
9981 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
9982 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
9983 void __builtin_ia32_clflush (const void *)
9984 void __builtin_ia32_lfence (void)
9985 void __builtin_ia32_mfence (void)
9986 v16qi __builtin_ia32_loaddqu (const char *)
9987 void __builtin_ia32_storedqu (char *, v16qi)
9988 v1di __builtin_ia32_pmuludq (v2si, v2si)
9989 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
9990 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
9991 v4si __builtin_ia32_pslld128 (v4si, v4si)
9992 v2di __builtin_ia32_psllq128 (v2di, v2di)
9993 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
9994 v4si __builtin_ia32_psrld128 (v4si, v4si)
9995 v2di __builtin_ia32_psrlq128 (v2di, v2di)
9996 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
9997 v4si __builtin_ia32_psrad128 (v4si, v4si)
9998 v2di __builtin_ia32_pslldqi128 (v2di, int)
9999 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10000 v4si __builtin_ia32_pslldi128 (v4si, int)
10001 v2di __builtin_ia32_psllqi128 (v2di, int)
10002 v2di __builtin_ia32_psrldqi128 (v2di, int)
10003 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10004 v4si __builtin_ia32_psrldi128 (v4si, int)
10005 v2di __builtin_ia32_psrlqi128 (v2di, int)
10006 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10007 v4si __builtin_ia32_psradi128 (v4si, int)
10008 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10009 v2di __builtin_ia32_movq128 (v2di)
10010 @end smallexample
10011
10012 The following built-in functions are available when @option{-msse3} is used.
10013 All of them generate the machine instruction that is part of the name.
10014
10015 @smallexample
10016 v2df __builtin_ia32_addsubpd (v2df, v2df)
10017 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10018 v2df __builtin_ia32_haddpd (v2df, v2df)
10019 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10020 v2df __builtin_ia32_hsubpd (v2df, v2df)
10021 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10022 v16qi __builtin_ia32_lddqu (char const *)
10023 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10024 v2df __builtin_ia32_movddup (v2df)
10025 v4sf __builtin_ia32_movshdup (v4sf)
10026 v4sf __builtin_ia32_movsldup (v4sf)
10027 void __builtin_ia32_mwait (unsigned int, unsigned int)
10028 @end smallexample
10029
10030 The following built-in functions are available when @option{-msse3} is used.
10031
10032 @table @code
10033 @item v2df __builtin_ia32_loadddup (double const *)
10034 Generates the @code{movddup} machine instruction as a load from memory.
10035 @end table
10036
10037 The following built-in functions are available when @option{-mssse3} is used.
10038 All of them generate the machine instruction that is part of the name
10039 with MMX registers.
10040
10041 @smallexample
10042 v2si __builtin_ia32_phaddd (v2si, v2si)
10043 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10044 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10045 v2si __builtin_ia32_phsubd (v2si, v2si)
10046 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10047 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10048 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10049 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10050 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10051 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10052 v2si __builtin_ia32_psignd (v2si, v2si)
10053 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10054 v1di __builtin_ia32_palignr (v1di, v1di, int)
10055 v8qi __builtin_ia32_pabsb (v8qi)
10056 v2si __builtin_ia32_pabsd (v2si)
10057 v4hi __builtin_ia32_pabsw (v4hi)
10058 @end smallexample
10059
10060 The following built-in functions are available when @option{-mssse3} is used.
10061 All of them generate the machine instruction that is part of the name
10062 with SSE registers.
10063
10064 @smallexample
10065 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10066 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10067 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10068 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10069 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10070 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10071 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10072 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10073 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10074 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10075 v4si __builtin_ia32_psignd128 (v4si, v4si)
10076 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10077 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10078 v16qi __builtin_ia32_pabsb128 (v16qi)
10079 v4si __builtin_ia32_pabsd128 (v4si)
10080 v8hi __builtin_ia32_pabsw128 (v8hi)
10081 @end smallexample
10082
10083 The following built-in functions are available when @option{-msse4.1} is
10084 used. All of them generate the machine instruction that is part of the
10085 name.
10086
10087 @smallexample
10088 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10089 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10090 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10091 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10092 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10093 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10094 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10095 v2di __builtin_ia32_movntdqa (v2di *);
10096 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10097 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10098 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10099 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10100 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10101 v8hi __builtin_ia32_phminposuw128 (v8hi)
10102 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10103 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10104 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10105 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10106 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10107 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10108 v4si __builtin_ia32_pminud128 (v4si, v4si)
10109 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10110 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10111 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10112 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10113 v2di __builtin_ia32_pmovsxdq128 (v4si)
10114 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10115 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10116 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10117 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10118 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10119 v2di __builtin_ia32_pmovzxdq128 (v4si)
10120 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10121 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10122 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10123 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10124 int __builtin_ia32_ptestc128 (v2di, v2di)
10125 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10126 int __builtin_ia32_ptestz128 (v2di, v2di)
10127 v2df __builtin_ia32_roundpd (v2df, const int)
10128 v4sf __builtin_ia32_roundps (v4sf, const int)
10129 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10130 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10131 @end smallexample
10132
10133 The following built-in functions are available when @option{-msse4.1} is
10134 used.
10135
10136 @table @code
10137 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10138 Generates the @code{insertps} machine instruction.
10139 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10140 Generates the @code{pextrb} machine instruction.
10141 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10142 Generates the @code{pinsrb} machine instruction.
10143 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10144 Generates the @code{pinsrd} machine instruction.
10145 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10146 Generates the @code{pinsrq} machine instruction in 64bit mode.
10147 @end table
10148
10149 The following built-in functions are changed to generate new SSE4.1
10150 instructions when @option{-msse4.1} is used.
10151
10152 @table @code
10153 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10154 Generates the @code{extractps} machine instruction.
10155 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10156 Generates the @code{pextrd} machine instruction.
10157 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10158 Generates the @code{pextrq} machine instruction in 64bit mode.
10159 @end table
10160
10161 The following built-in functions are available when @option{-msse4.2} is
10162 used. All of them generate the machine instruction that is part of the
10163 name.
10164
10165 @smallexample
10166 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10167 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10168 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10169 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10170 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10171 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10172 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10173 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10174 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10175 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10176 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10177 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10178 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10179 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10180 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10181 @end smallexample
10182
10183 The following built-in functions are available when @option{-msse4.2} is
10184 used.
10185
10186 @table @code
10187 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10188 Generates the @code{crc32b} machine instruction.
10189 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10190 Generates the @code{crc32w} machine instruction.
10191 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10192 Generates the @code{crc32l} machine instruction.
10193 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10194 Generates the @code{crc32q} machine instruction.
10195 @end table
10196
10197 The following built-in functions are changed to generate new SSE4.2
10198 instructions when @option{-msse4.2} is used.
10199
10200 @table @code
10201 @item int __builtin_popcount (unsigned int)
10202 Generates the @code{popcntl} machine instruction.
10203 @item int __builtin_popcountl (unsigned long)
10204 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10205 depending on the size of @code{unsigned long}.
10206 @item int __builtin_popcountll (unsigned long long)
10207 Generates the @code{popcntq} machine instruction.
10208 @end table
10209
10210 The following built-in functions are available when @option{-mavx} is
10211 used. All of them generate the machine instruction that is part of the
10212 name.
10213
10214 @smallexample
10215 v4df __builtin_ia32_addpd256 (v4df,v4df)
10216 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10217 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10218 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10219 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10220 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10221 v4df __builtin_ia32_andpd256 (v4df,v4df)
10222 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
10223 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
10224 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
10225 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
10226 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
10227 v2df __builtin_ia32_cmppd (v2df,v2df,int)
10228 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
10229 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
10230 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
10231 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
10232 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
10233 v4df __builtin_ia32_cvtdq2pd256 (v4si)
10234 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
10235 v4si __builtin_ia32_cvtpd2dq256 (v4df)
10236 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
10237 v8si __builtin_ia32_cvtps2dq256 (v8sf)
10238 v4df __builtin_ia32_cvtps2pd256 (v4sf)
10239 v4si __builtin_ia32_cvttpd2dq256 (v4df)
10240 v8si __builtin_ia32_cvttps2dq256 (v8sf)
10241 v4df __builtin_ia32_divpd256 (v4df,v4df)
10242 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
10243 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
10244 v4df __builtin_ia32_haddpd256 (v4df,v4df)
10245 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
10246 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
10247 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
10248 v32qi __builtin_ia32_lddqu256 (pcchar)
10249 v32qi __builtin_ia32_loaddqu256 (pcchar)
10250 v4df __builtin_ia32_loadupd256 (pcdouble)
10251 v8sf __builtin_ia32_loadups256 (pcfloat)
10252 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
10253 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
10254 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
10255 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
10256 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
10257 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
10258 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
10259 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
10260 v4df __builtin_ia32_maxpd256 (v4df,v4df)
10261 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
10262 v4df __builtin_ia32_minpd256 (v4df,v4df)
10263 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
10264 v4df __builtin_ia32_movddup256 (v4df)
10265 int __builtin_ia32_movmskpd256 (v4df)
10266 int __builtin_ia32_movmskps256 (v8sf)
10267 v8sf __builtin_ia32_movshdup256 (v8sf)
10268 v8sf __builtin_ia32_movsldup256 (v8sf)
10269 v4df __builtin_ia32_mulpd256 (v4df,v4df)
10270 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
10271 v4df __builtin_ia32_orpd256 (v4df,v4df)
10272 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
10273 v2df __builtin_ia32_pd_pd256 (v4df)
10274 v4df __builtin_ia32_pd256_pd (v2df)
10275 v4sf __builtin_ia32_ps_ps256 (v8sf)
10276 v8sf __builtin_ia32_ps256_ps (v4sf)
10277 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
10278 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
10279 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
10280 v8sf __builtin_ia32_rcpps256 (v8sf)
10281 v4df __builtin_ia32_roundpd256 (v4df,int)
10282 v8sf __builtin_ia32_roundps256 (v8sf,int)
10283 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
10284 v8sf __builtin_ia32_rsqrtps256 (v8sf)
10285 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
10286 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
10287 v4si __builtin_ia32_si_si256 (v8si)
10288 v8si __builtin_ia32_si256_si (v4si)
10289 v4df __builtin_ia32_sqrtpd256 (v4df)
10290 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
10291 v8sf __builtin_ia32_sqrtps256 (v8sf)
10292 void __builtin_ia32_storedqu256 (pchar,v32qi)
10293 void __builtin_ia32_storeupd256 (pdouble,v4df)
10294 void __builtin_ia32_storeups256 (pfloat,v8sf)
10295 v4df __builtin_ia32_subpd256 (v4df,v4df)
10296 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
10297 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
10298 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
10299 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
10300 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
10301 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
10302 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
10303 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
10304 v4sf __builtin_ia32_vbroadcastss (pcfloat)
10305 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
10306 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
10307 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
10308 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
10309 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
10310 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
10311 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
10312 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
10313 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
10314 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
10315 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
10316 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
10317 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
10318 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
10319 v2df __builtin_ia32_vpermilpd (v2df,int)
10320 v4df __builtin_ia32_vpermilpd256 (v4df,int)
10321 v4sf __builtin_ia32_vpermilps (v4sf,int)
10322 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
10323 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
10324 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
10325 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
10326 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
10327 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
10328 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
10329 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
10330 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
10331 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
10332 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
10333 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
10334 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
10335 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
10336 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
10337 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
10338 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
10339 void __builtin_ia32_vzeroall (void)
10340 void __builtin_ia32_vzeroupper (void)
10341 v4df __builtin_ia32_xorpd256 (v4df,v4df)
10342 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
10343 @end smallexample
10344
10345 The following built-in functions are available when @option{-mavx2} is
10346 used. All of them generate the machine instruction that is part of the
10347 name.
10348
10349 @smallexample
10350 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
10351 v32qi __builtin_ia32_pabsb256 (v32qi)
10352 v16hi __builtin_ia32_pabsw256 (v16hi)
10353 v8si __builtin_ia32_pabsd256 (v8si)
10354 v16hi builtin_ia32_packssdw256 (v8si,v8si)
10355 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
10356 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
10357 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
10358 v32qi__builtin_ia32_paddb256 (v32qi,v32qi)
10359 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
10360 v8si __builtin_ia32_paddd256 (v8si,v8si)
10361 v4di __builtin_ia32_paddq256 (v4di,v4di)
10362 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
10363 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
10364 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
10365 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
10366 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
10367 v4di __builtin_ia32_andsi256 (v4di,v4di)
10368 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
10369 v32qi__builtin_ia32_pavgb256 (v32qi,v32qi)
10370 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
10371 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
10372 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
10373 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
10374 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
10375 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
10376 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
10377 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
10378 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
10379 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
10380 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
10381 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
10382 v8si __builtin_ia32_phaddd256 (v8si,v8si)
10383 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
10384 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
10385 v8si __builtin_ia32_phsubd256 (v8si,v8si)
10386 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
10387 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
10388 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
10389 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
10390 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
10391 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
10392 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
10393 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
10394 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
10395 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
10396 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
10397 v8si __builtin_ia32_pminsd256 (v8si,v8si)
10398 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
10399 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
10400 v8si __builtin_ia32_pminud256 (v8si,v8si)
10401 int __builtin_ia32_pmovmskb256 (v32qi)
10402 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
10403 v8si __builtin_ia32_pmovsxbd256 (v16qi)
10404 v4di __builtin_ia32_pmovsxbq256 (v16qi)
10405 v8si __builtin_ia32_pmovsxwd256 (v8hi)
10406 v4di __builtin_ia32_pmovsxwq256 (v8hi)
10407 v4di __builtin_ia32_pmovsxdq256 (v4si)
10408 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
10409 v8si __builtin_ia32_pmovzxbd256 (v16qi)
10410 v4di __builtin_ia32_pmovzxbq256 (v16qi)
10411 v8si __builtin_ia32_pmovzxwd256 (v8hi)
10412 v4di __builtin_ia32_pmovzxwq256 (v8hi)
10413 v4di __builtin_ia32_pmovzxdq256 (v4si)
10414 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
10415 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
10416 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
10417 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
10418 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
10419 v8si __builtin_ia32_pmulld256 (v8si,v8si)
10420 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
10421 v4di __builtin_ia32_por256 (v4di,v4di)
10422 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
10423 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
10424 v8si __builtin_ia32_pshufd256 (v8si,int)
10425 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
10426 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
10427 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
10428 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
10429 v8si __builtin_ia32_psignd256 (v8si,v8si)
10430 v4di __builtin_ia32_pslldqi256 (v4di,int)
10431 v16hi __builtin_ia32_psllwi256 (16hi,int)
10432 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
10433 v8si __builtin_ia32_pslldi256 (v8si,int)
10434 v8si __builtin_ia32_pslld256(v8si,v4si)
10435 v4di __builtin_ia32_psllqi256 (v4di,int)
10436 v4di __builtin_ia32_psllq256(v4di,v2di)
10437 v16hi __builtin_ia32_psrawi256 (v16hi,int)
10438 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
10439 v8si __builtin_ia32_psradi256 (v8si,int)
10440 v8si __builtin_ia32_psrad256 (v8si,v4si)
10441 v4di __builtin_ia32_psrldqi256 (v4di, int)
10442 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
10443 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
10444 v8si __builtin_ia32_psrldi256 (v8si,int)
10445 v8si __builtin_ia32_psrld256 (v8si,v4si)
10446 v4di __builtin_ia32_psrlqi256 (v4di,int)
10447 v4di __builtin_ia32_psrlq256(v4di,v2di)
10448 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
10449 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
10450 v8si __builtin_ia32_psubd256 (v8si,v8si)
10451 v4di __builtin_ia32_psubq256 (v4di,v4di)
10452 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
10453 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
10454 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
10455 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
10456 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
10457 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
10458 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
10459 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
10460 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
10461 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
10462 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
10463 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
10464 v4di __builtin_ia32_pxor256 (v4di,v4di)
10465 v4di __builtin_ia32_movntdqa256 (pv4di)
10466 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
10467 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
10468 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
10469 v4di __builtin_ia32_vbroadcastsi256 (v2di)
10470 v4si __builtin_ia32_pblendd128 (v4si,v4si)
10471 v8si __builtin_ia32_pblendd256 (v8si,v8si)
10472 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
10473 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
10474 v8si __builtin_ia32_pbroadcastd256 (v4si)
10475 v4di __builtin_ia32_pbroadcastq256 (v2di)
10476 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
10477 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
10478 v4si __builtin_ia32_pbroadcastd128 (v4si)
10479 v2di __builtin_ia32_pbroadcastq128 (v2di)
10480 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
10481 v4df __builtin_ia32_permdf256 (v4df,int)
10482 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
10483 v4di __builtin_ia32_permdi256 (v4di,int)
10484 v4di __builtin_ia32_permti256 (v4di,v4di,int)
10485 v4di __builtin_ia32_extract128i256 (v4di,int)
10486 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
10487 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
10488 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
10489 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
10490 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
10491 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
10492 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
10493 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
10494 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
10495 v8si __builtin_ia32_psllv8si (v8si,v8si)
10496 v4si __builtin_ia32_psllv4si (v4si,v4si)
10497 v4di __builtin_ia32_psllv4di (v4di,v4di)
10498 v2di __builtin_ia32_psllv2di (v2di,v2di)
10499 v8si __builtin_ia32_psrav8si (v8si,v8si)
10500 v4si __builtin_ia32_psrav4si (v4si,v4si)
10501 v8si __builtin_ia32_psrlv8si (v8si,v8si)
10502 v4si __builtin_ia32_psrlv4si (v4si,v4si)
10503 v4di __builtin_ia32_psrlv4di (v4di,v4di)
10504 v2di __builtin_ia32_psrlv2di (v2di,v2di)
10505 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
10506 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
10507 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
10508 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
10509 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
10510 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
10511 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
10512 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
10513 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
10514 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
10515 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
10516 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
10517 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
10518 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
10519 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
10520 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
10521 @end smallexample
10522
10523 The following built-in functions are available when @option{-maes} is
10524 used. All of them generate the machine instruction that is part of the
10525 name.
10526
10527 @smallexample
10528 v2di __builtin_ia32_aesenc128 (v2di, v2di)
10529 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
10530 v2di __builtin_ia32_aesdec128 (v2di, v2di)
10531 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
10532 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
10533 v2di __builtin_ia32_aesimc128 (v2di)
10534 @end smallexample
10535
10536 The following built-in function is available when @option{-mpclmul} is
10537 used.
10538
10539 @table @code
10540 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
10541 Generates the @code{pclmulqdq} machine instruction.
10542 @end table
10543
10544 The following built-in function is available when @option{-mfsgsbase} is
10545 used. All of them generate the machine instruction that is part of the
10546 name.
10547
10548 @smallexample
10549 unsigned int __builtin_ia32_rdfsbase32 (void)
10550 unsigned long long __builtin_ia32_rdfsbase64 (void)
10551 unsigned int __builtin_ia32_rdgsbase32 (void)
10552 unsigned long long __builtin_ia32_rdgsbase64 (void)
10553 void _writefsbase_u32 (unsigned int)
10554 void _writefsbase_u64 (unsigned long long)
10555 void _writegsbase_u32 (unsigned int)
10556 void _writegsbase_u64 (unsigned long long)
10557 @end smallexample
10558
10559 The following built-in function is available when @option{-mrdrnd} is
10560 used. All of them generate the machine instruction that is part of the
10561 name.
10562
10563 @smallexample
10564 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
10565 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
10566 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
10567 @end smallexample
10568
10569 The following built-in functions are available when @option{-msse4a} is used.
10570 All of them generate the machine instruction that is part of the name.
10571
10572 @smallexample
10573 void __builtin_ia32_movntsd (double *, v2df)
10574 void __builtin_ia32_movntss (float *, v4sf)
10575 v2di __builtin_ia32_extrq (v2di, v16qi)
10576 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
10577 v2di __builtin_ia32_insertq (v2di, v2di)
10578 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
10579 @end smallexample
10580
10581 The following built-in functions are available when @option{-mxop} is used.
10582 @smallexample
10583 v2df __builtin_ia32_vfrczpd (v2df)
10584 v4sf __builtin_ia32_vfrczps (v4sf)
10585 v2df __builtin_ia32_vfrczsd (v2df, v2df)
10586 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
10587 v4df __builtin_ia32_vfrczpd256 (v4df)
10588 v8sf __builtin_ia32_vfrczps256 (v8sf)
10589 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
10590 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
10591 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
10592 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
10593 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
10594 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
10595 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
10596 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
10597 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
10598 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
10599 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
10600 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
10601 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
10602 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
10603 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10604 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
10605 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
10606 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
10607 v4si __builtin_ia32_vpcomequd (v4si, v4si)
10608 v2di __builtin_ia32_vpcomequq (v2di, v2di)
10609 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
10610 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10611 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
10612 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
10613 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
10614 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
10615 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
10616 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
10617 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
10618 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
10619 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
10620 v4si __builtin_ia32_vpcomged (v4si, v4si)
10621 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
10622 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
10623 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
10624 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
10625 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
10626 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
10627 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
10628 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
10629 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
10630 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
10631 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
10632 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
10633 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
10634 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
10635 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
10636 v4si __builtin_ia32_vpcomled (v4si, v4si)
10637 v2di __builtin_ia32_vpcomleq (v2di, v2di)
10638 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
10639 v4si __builtin_ia32_vpcomleud (v4si, v4si)
10640 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
10641 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
10642 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
10643 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
10644 v4si __builtin_ia32_vpcomltd (v4si, v4si)
10645 v2di __builtin_ia32_vpcomltq (v2di, v2di)
10646 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
10647 v4si __builtin_ia32_vpcomltud (v4si, v4si)
10648 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
10649 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
10650 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
10651 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
10652 v4si __builtin_ia32_vpcomned (v4si, v4si)
10653 v2di __builtin_ia32_vpcomneq (v2di, v2di)
10654 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
10655 v4si __builtin_ia32_vpcomneud (v4si, v4si)
10656 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
10657 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
10658 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
10659 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
10660 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
10661 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
10662 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
10663 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
10664 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
10665 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
10666 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
10667 v4si __builtin_ia32_vphaddbd (v16qi)
10668 v2di __builtin_ia32_vphaddbq (v16qi)
10669 v8hi __builtin_ia32_vphaddbw (v16qi)
10670 v2di __builtin_ia32_vphadddq (v4si)
10671 v4si __builtin_ia32_vphaddubd (v16qi)
10672 v2di __builtin_ia32_vphaddubq (v16qi)
10673 v8hi __builtin_ia32_vphaddubw (v16qi)
10674 v2di __builtin_ia32_vphaddudq (v4si)
10675 v4si __builtin_ia32_vphadduwd (v8hi)
10676 v2di __builtin_ia32_vphadduwq (v8hi)
10677 v4si __builtin_ia32_vphaddwd (v8hi)
10678 v2di __builtin_ia32_vphaddwq (v8hi)
10679 v8hi __builtin_ia32_vphsubbw (v16qi)
10680 v2di __builtin_ia32_vphsubdq (v4si)
10681 v4si __builtin_ia32_vphsubwd (v8hi)
10682 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
10683 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
10684 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
10685 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
10686 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
10687 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
10688 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
10689 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
10690 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
10691 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
10692 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
10693 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
10694 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
10695 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
10696 v4si __builtin_ia32_vprotd (v4si, v4si)
10697 v2di __builtin_ia32_vprotq (v2di, v2di)
10698 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
10699 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
10700 v4si __builtin_ia32_vpshad (v4si, v4si)
10701 v2di __builtin_ia32_vpshaq (v2di, v2di)
10702 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
10703 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
10704 v4si __builtin_ia32_vpshld (v4si, v4si)
10705 v2di __builtin_ia32_vpshlq (v2di, v2di)
10706 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
10707 @end smallexample
10708
10709 The following built-in functions are available when @option{-mfma4} is used.
10710 All of them generate the machine instruction that is part of the name
10711 with MMX registers.
10712
10713 @smallexample
10714 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
10715 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
10716 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
10717 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
10718 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
10719 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
10720 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
10721 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
10722 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
10723 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
10724 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
10725 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
10726 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
10727 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
10728 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
10729 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
10730 v2df __builtin_ia32_fmaddsubpd (v2df, v2df, v2df)
10731 v4sf __builtin_ia32_fmaddsubps (v4sf, v4sf, v4sf)
10732 v2df __builtin_ia32_fmsubaddpd (v2df, v2df, v2df)
10733 v4sf __builtin_ia32_fmsubaddps (v4sf, v4sf, v4sf)
10734 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
10735 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
10736 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
10737 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
10738 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
10739 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
10740 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
10741 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
10742 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
10743 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
10744 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
10745 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
10746
10747 @end smallexample
10748
10749 The following built-in functions are available when @option{-mlwp} is used.
10750
10751 @smallexample
10752 void __builtin_ia32_llwpcb16 (void *);
10753 void __builtin_ia32_llwpcb32 (void *);
10754 void __builtin_ia32_llwpcb64 (void *);
10755 void * __builtin_ia32_llwpcb16 (void);
10756 void * __builtin_ia32_llwpcb32 (void);
10757 void * __builtin_ia32_llwpcb64 (void);
10758 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
10759 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
10760 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
10761 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
10762 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
10763 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
10764 @end smallexample
10765
10766 The following built-in functions are available when @option{-mbmi} is used.
10767 All of them generate the machine instruction that is part of the name.
10768 @smallexample
10769 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
10770 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
10771 @end smallexample
10772
10773 The following built-in functions are available when @option{-mbmi2} is used.
10774 All of them generate the machine instruction that is part of the name.
10775 @smallexample
10776 unsigned int _bzhi_u32 (unsigned int, unsigned int)
10777 unsigned int _pdep_u32 (unsigned int, unsigned int)
10778 unsigned int _pext_u32 (unsigned int, unsigned int)
10779 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
10780 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
10781 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
10782 @end smallexample
10783
10784 The following built-in functions are available when @option{-mlzcnt} is used.
10785 All of them generate the machine instruction that is part of the name.
10786 @smallexample
10787 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
10788 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
10789 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
10790 @end smallexample
10791
10792 The following built-in functions are available when @option{-mtbm} is used.
10793 Both of them generate the immediate form of the bextr machine instruction.
10794 @smallexample
10795 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
10796 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
10797 @end smallexample
10798
10799
10800 The following built-in functions are available when @option{-m3dnow} is used.
10801 All of them generate the machine instruction that is part of the name.
10802
10803 @smallexample
10804 void __builtin_ia32_femms (void)
10805 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
10806 v2si __builtin_ia32_pf2id (v2sf)
10807 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
10808 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
10809 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
10810 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
10811 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
10812 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
10813 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
10814 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
10815 v2sf __builtin_ia32_pfrcp (v2sf)
10816 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
10817 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
10818 v2sf __builtin_ia32_pfrsqrt (v2sf)
10819 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
10820 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
10821 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
10822 v2sf __builtin_ia32_pi2fd (v2si)
10823 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
10824 @end smallexample
10825
10826 The following built-in functions are available when both @option{-m3dnow}
10827 and @option{-march=athlon} are used. All of them generate the machine
10828 instruction that is part of the name.
10829
10830 @smallexample
10831 v2si __builtin_ia32_pf2iw (v2sf)
10832 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
10833 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
10834 v2sf __builtin_ia32_pi2fw (v2si)
10835 v2sf __builtin_ia32_pswapdsf (v2sf)
10836 v2si __builtin_ia32_pswapdsi (v2si)
10837 @end smallexample
10838
10839 @node MIPS DSP Built-in Functions
10840 @subsection MIPS DSP Built-in Functions
10841
10842 The MIPS DSP Application-Specific Extension (ASE) includes new
10843 instructions that are designed to improve the performance of DSP and
10844 media applications. It provides instructions that operate on packed
10845 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
10846
10847 GCC supports MIPS DSP operations using both the generic
10848 vector extensions (@pxref{Vector Extensions}) and a collection of
10849 MIPS-specific built-in functions. Both kinds of support are
10850 enabled by the @option{-mdsp} command-line option.
10851
10852 Revision 2 of the ASE was introduced in the second half of 2006.
10853 This revision adds extra instructions to the original ASE, but is
10854 otherwise backwards-compatible with it. You can select revision 2
10855 using the command-line option @option{-mdspr2}; this option implies
10856 @option{-mdsp}.
10857
10858 The SCOUNT and POS bits of the DSP control register are global. The
10859 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
10860 POS bits. During optimization, the compiler does not delete these
10861 instructions and it does not delete calls to functions containing
10862 these instructions.
10863
10864 At present, GCC only provides support for operations on 32-bit
10865 vectors. The vector type associated with 8-bit integer data is
10866 usually called @code{v4i8}, the vector type associated with Q7
10867 is usually called @code{v4q7}, the vector type associated with 16-bit
10868 integer data is usually called @code{v2i16}, and the vector type
10869 associated with Q15 is usually called @code{v2q15}. They can be
10870 defined in C as follows:
10871
10872 @smallexample
10873 typedef signed char v4i8 __attribute__ ((vector_size(4)));
10874 typedef signed char v4q7 __attribute__ ((vector_size(4)));
10875 typedef short v2i16 __attribute__ ((vector_size(4)));
10876 typedef short v2q15 __attribute__ ((vector_size(4)));
10877 @end smallexample
10878
10879 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
10880 initialized in the same way as aggregates. For example:
10881
10882 @smallexample
10883 v4i8 a = @{1, 2, 3, 4@};
10884 v4i8 b;
10885 b = (v4i8) @{5, 6, 7, 8@};
10886
10887 v2q15 c = @{0x0fcb, 0x3a75@};
10888 v2q15 d;
10889 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
10890 @end smallexample
10891
10892 @emph{Note:} The CPU's endianness determines the order in which values
10893 are packed. On little-endian targets, the first value is the least
10894 significant and the last value is the most significant. The opposite
10895 order applies to big-endian targets. For example, the code above
10896 sets the lowest byte of @code{a} to @code{1} on little-endian targets
10897 and @code{4} on big-endian targets.
10898
10899 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
10900 representation. As shown in this example, the integer representation
10901 of a Q7 value can be obtained by multiplying the fractional value by
10902 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
10903 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
10904 @code{0x1.0p31}.
10905
10906 The table below lists the @code{v4i8} and @code{v2q15} operations for which
10907 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
10908 and @code{c} and @code{d} are @code{v2q15} values.
10909
10910 @multitable @columnfractions .50 .50
10911 @item C code @tab MIPS instruction
10912 @item @code{a + b} @tab @code{addu.qb}
10913 @item @code{c + d} @tab @code{addq.ph}
10914 @item @code{a - b} @tab @code{subu.qb}
10915 @item @code{c - d} @tab @code{subq.ph}
10916 @end multitable
10917
10918 The table below lists the @code{v2i16} operation for which
10919 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
10920 @code{v2i16} values.
10921
10922 @multitable @columnfractions .50 .50
10923 @item C code @tab MIPS instruction
10924 @item @code{e * f} @tab @code{mul.ph}
10925 @end multitable
10926
10927 It is easier to describe the DSP built-in functions if we first define
10928 the following types:
10929
10930 @smallexample
10931 typedef int q31;
10932 typedef int i32;
10933 typedef unsigned int ui32;
10934 typedef long long a64;
10935 @end smallexample
10936
10937 @code{q31} and @code{i32} are actually the same as @code{int}, but we
10938 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
10939 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
10940 @code{long long}, but we use @code{a64} to indicate values that are
10941 placed in one of the four DSP accumulators (@code{$ac0},
10942 @code{$ac1}, @code{$ac2} or @code{$ac3}).
10943
10944 Also, some built-in functions prefer or require immediate numbers as
10945 parameters, because the corresponding DSP instructions accept both immediate
10946 numbers and register operands, or accept immediate numbers only. The
10947 immediate parameters are listed as follows.
10948
10949 @smallexample
10950 imm0_3: 0 to 3.
10951 imm0_7: 0 to 7.
10952 imm0_15: 0 to 15.
10953 imm0_31: 0 to 31.
10954 imm0_63: 0 to 63.
10955 imm0_255: 0 to 255.
10956 imm_n32_31: -32 to 31.
10957 imm_n512_511: -512 to 511.
10958 @end smallexample
10959
10960 The following built-in functions map directly to a particular MIPS DSP
10961 instruction. Please refer to the architecture specification
10962 for details on what each instruction does.
10963
10964 @smallexample
10965 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
10966 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
10967 q31 __builtin_mips_addq_s_w (q31, q31)
10968 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
10969 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
10970 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
10971 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
10972 q31 __builtin_mips_subq_s_w (q31, q31)
10973 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
10974 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
10975 i32 __builtin_mips_addsc (i32, i32)
10976 i32 __builtin_mips_addwc (i32, i32)
10977 i32 __builtin_mips_modsub (i32, i32)
10978 i32 __builtin_mips_raddu_w_qb (v4i8)
10979 v2q15 __builtin_mips_absq_s_ph (v2q15)
10980 q31 __builtin_mips_absq_s_w (q31)
10981 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
10982 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
10983 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
10984 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
10985 q31 __builtin_mips_preceq_w_phl (v2q15)
10986 q31 __builtin_mips_preceq_w_phr (v2q15)
10987 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
10988 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
10989 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
10990 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
10991 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
10992 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
10993 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
10994 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
10995 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
10996 v4i8 __builtin_mips_shll_qb (v4i8, i32)
10997 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
10998 v2q15 __builtin_mips_shll_ph (v2q15, i32)
10999 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11000 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11001 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11002 q31 __builtin_mips_shll_s_w (q31, i32)
11003 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11004 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11005 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11006 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11007 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11008 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11009 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11010 q31 __builtin_mips_shra_r_w (q31, i32)
11011 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11012 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11013 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11014 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11015 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11016 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11017 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11018 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11019 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11020 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11021 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11022 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11023 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11024 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11025 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11026 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11027 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11028 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11029 i32 __builtin_mips_bitrev (i32)
11030 i32 __builtin_mips_insv (i32, i32)
11031 v4i8 __builtin_mips_repl_qb (imm0_255)
11032 v4i8 __builtin_mips_repl_qb (i32)
11033 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11034 v2q15 __builtin_mips_repl_ph (i32)
11035 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11036 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11037 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11038 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11039 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11040 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11041 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11042 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11043 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11044 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11045 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11046 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11047 i32 __builtin_mips_extr_w (a64, imm0_31)
11048 i32 __builtin_mips_extr_w (a64, i32)
11049 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11050 i32 __builtin_mips_extr_s_h (a64, i32)
11051 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11052 i32 __builtin_mips_extr_rs_w (a64, i32)
11053 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11054 i32 __builtin_mips_extr_r_w (a64, i32)
11055 i32 __builtin_mips_extp (a64, imm0_31)
11056 i32 __builtin_mips_extp (a64, i32)
11057 i32 __builtin_mips_extpdp (a64, imm0_31)
11058 i32 __builtin_mips_extpdp (a64, i32)
11059 a64 __builtin_mips_shilo (a64, imm_n32_31)
11060 a64 __builtin_mips_shilo (a64, i32)
11061 a64 __builtin_mips_mthlip (a64, i32)
11062 void __builtin_mips_wrdsp (i32, imm0_63)
11063 i32 __builtin_mips_rddsp (imm0_63)
11064 i32 __builtin_mips_lbux (void *, i32)
11065 i32 __builtin_mips_lhx (void *, i32)
11066 i32 __builtin_mips_lwx (void *, i32)
11067 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11068 i32 __builtin_mips_bposge32 (void)
11069 a64 __builtin_mips_madd (a64, i32, i32);
11070 a64 __builtin_mips_maddu (a64, ui32, ui32);
11071 a64 __builtin_mips_msub (a64, i32, i32);
11072 a64 __builtin_mips_msubu (a64, ui32, ui32);
11073 a64 __builtin_mips_mult (i32, i32);
11074 a64 __builtin_mips_multu (ui32, ui32);
11075 @end smallexample
11076
11077 The following built-in functions map directly to a particular MIPS DSP REV 2
11078 instruction. Please refer to the architecture specification
11079 for details on what each instruction does.
11080
11081 @smallexample
11082 v4q7 __builtin_mips_absq_s_qb (v4q7);
11083 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11084 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11085 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11086 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11087 i32 __builtin_mips_append (i32, i32, imm0_31);
11088 i32 __builtin_mips_balign (i32, i32, imm0_3);
11089 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11090 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11091 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11092 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11093 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11094 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11095 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11096 q31 __builtin_mips_mulq_rs_w (q31, q31);
11097 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11098 q31 __builtin_mips_mulq_s_w (q31, q31);
11099 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11100 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11101 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11102 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11103 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11104 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11105 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11106 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11107 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11108 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11109 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11110 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11111 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11112 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11113 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11114 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11115 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11116 q31 __builtin_mips_addqh_w (q31, q31);
11117 q31 __builtin_mips_addqh_r_w (q31, q31);
11118 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11119 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11120 q31 __builtin_mips_subqh_w (q31, q31);
11121 q31 __builtin_mips_subqh_r_w (q31, q31);
11122 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11123 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11124 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11125 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11126 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11127 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11128 @end smallexample
11129
11130
11131 @node MIPS Paired-Single Support
11132 @subsection MIPS Paired-Single Support
11133
11134 The MIPS64 architecture includes a number of instructions that
11135 operate on pairs of single-precision floating-point values.
11136 Each pair is packed into a 64-bit floating-point register,
11137 with one element being designated the ``upper half'' and
11138 the other being designated the ``lower half''.
11139
11140 GCC supports paired-single operations using both the generic
11141 vector extensions (@pxref{Vector Extensions}) and a collection of
11142 MIPS-specific built-in functions. Both kinds of support are
11143 enabled by the @option{-mpaired-single} command-line option.
11144
11145 The vector type associated with paired-single values is usually
11146 called @code{v2sf}. It can be defined in C as follows:
11147
11148 @smallexample
11149 typedef float v2sf __attribute__ ((vector_size (8)));
11150 @end smallexample
11151
11152 @code{v2sf} values are initialized in the same way as aggregates.
11153 For example:
11154
11155 @smallexample
11156 v2sf a = @{1.5, 9.1@};
11157 v2sf b;
11158 float e, f;
11159 b = (v2sf) @{e, f@};
11160 @end smallexample
11161
11162 @emph{Note:} The CPU's endianness determines which value is stored in
11163 the upper half of a register and which value is stored in the lower half.
11164 On little-endian targets, the first value is the lower one and the second
11165 value is the upper one. The opposite order applies to big-endian targets.
11166 For example, the code above sets the lower half of @code{a} to
11167 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11168
11169 @node MIPS Loongson Built-in Functions
11170 @subsection MIPS Loongson Built-in Functions
11171
11172 GCC provides intrinsics to access the SIMD instructions provided by the
11173 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
11174 available after inclusion of the @code{loongson.h} header file,
11175 operate on the following 64-bit vector types:
11176
11177 @itemize
11178 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11179 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11180 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11181 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11182 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11183 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11184 @end itemize
11185
11186 The intrinsics provided are listed below; each is named after the
11187 machine instruction to which it corresponds, with suffixes added as
11188 appropriate to distinguish intrinsics that expand to the same machine
11189 instruction yet have different argument types. Refer to the architecture
11190 documentation for a description of the functionality of each
11191 instruction.
11192
11193 @smallexample
11194 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11195 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11196 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11197 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11198 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11199 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11200 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11201 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11202 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11203 uint64_t paddd_u (uint64_t s, uint64_t t);
11204 int64_t paddd_s (int64_t s, int64_t t);
11205 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11206 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11207 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11208 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11209 uint64_t pandn_ud (uint64_t s, uint64_t t);
11210 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11211 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11212 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11213 int64_t pandn_sd (int64_t s, int64_t t);
11214 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11215 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11216 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11217 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11218 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11219 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11220 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11221 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11222 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11223 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11224 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11225 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11226 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11227 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11228 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11229 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11230 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11231 uint16x4_t pextrh_u (uint16x4_t s, int field);
11232 int16x4_t pextrh_s (int16x4_t s, int field);
11233 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11234 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11235 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11236 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11237 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11238 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11239 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11240 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11241 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11242 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11243 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11244 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11245 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11246 uint8x8_t pmovmskb_u (uint8x8_t s);
11247 int8x8_t pmovmskb_s (int8x8_t s);
11248 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11249 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11250 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11251 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11252 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11253 uint16x4_t biadd (uint8x8_t s);
11254 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11255 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11256 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11257 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11258 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11259 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11260 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11261 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11262 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
11263 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
11264 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
11265 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
11266 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
11267 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
11268 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
11269 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
11270 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
11271 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
11272 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
11273 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
11274 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
11275 uint64_t psubd_u (uint64_t s, uint64_t t);
11276 int64_t psubd_s (int64_t s, int64_t t);
11277 int16x4_t psubsh (int16x4_t s, int16x4_t t);
11278 int8x8_t psubsb (int8x8_t s, int8x8_t t);
11279 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
11280 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
11281 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
11282 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
11283 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
11284 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
11285 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
11286 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
11287 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
11288 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
11289 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
11290 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
11291 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
11292 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
11293 @end smallexample
11294
11295 @menu
11296 * Paired-Single Arithmetic::
11297 * Paired-Single Built-in Functions::
11298 * MIPS-3D Built-in Functions::
11299 @end menu
11300
11301 @node Paired-Single Arithmetic
11302 @subsubsection Paired-Single Arithmetic
11303
11304 The table below lists the @code{v2sf} operations for which hardware
11305 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
11306 values and @code{x} is an integral value.
11307
11308 @multitable @columnfractions .50 .50
11309 @item C code @tab MIPS instruction
11310 @item @code{a + b} @tab @code{add.ps}
11311 @item @code{a - b} @tab @code{sub.ps}
11312 @item @code{-a} @tab @code{neg.ps}
11313 @item @code{a * b} @tab @code{mul.ps}
11314 @item @code{a * b + c} @tab @code{madd.ps}
11315 @item @code{a * b - c} @tab @code{msub.ps}
11316 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
11317 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
11318 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
11319 @end multitable
11320
11321 Note that the multiply-accumulate instructions can be disabled
11322 using the command-line option @code{-mno-fused-madd}.
11323
11324 @node Paired-Single Built-in Functions
11325 @subsubsection Paired-Single Built-in Functions
11326
11327 The following paired-single functions map directly to a particular
11328 MIPS instruction. Please refer to the architecture specification
11329 for details on what each instruction does.
11330
11331 @table @code
11332 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
11333 Pair lower lower (@code{pll.ps}).
11334
11335 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
11336 Pair upper lower (@code{pul.ps}).
11337
11338 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
11339 Pair lower upper (@code{plu.ps}).
11340
11341 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
11342 Pair upper upper (@code{puu.ps}).
11343
11344 @item v2sf __builtin_mips_cvt_ps_s (float, float)
11345 Convert pair to paired single (@code{cvt.ps.s}).
11346
11347 @item float __builtin_mips_cvt_s_pl (v2sf)
11348 Convert pair lower to single (@code{cvt.s.pl}).
11349
11350 @item float __builtin_mips_cvt_s_pu (v2sf)
11351 Convert pair upper to single (@code{cvt.s.pu}).
11352
11353 @item v2sf __builtin_mips_abs_ps (v2sf)
11354 Absolute value (@code{abs.ps}).
11355
11356 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
11357 Align variable (@code{alnv.ps}).
11358
11359 @emph{Note:} The value of the third parameter must be 0 or 4
11360 modulo 8, otherwise the result is unpredictable. Please read the
11361 instruction description for details.
11362 @end table
11363
11364 The following multi-instruction functions are also available.
11365 In each case, @var{cond} can be any of the 16 floating-point conditions:
11366 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11367 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
11368 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11369
11370 @table @code
11371 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11372 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11373 Conditional move based on floating point comparison (@code{c.@var{cond}.ps},
11374 @code{movt.ps}/@code{movf.ps}).
11375
11376 The @code{movt} functions return the value @var{x} computed by:
11377
11378 @smallexample
11379 c.@var{cond}.ps @var{cc},@var{a},@var{b}
11380 mov.ps @var{x},@var{c}
11381 movt.ps @var{x},@var{d},@var{cc}
11382 @end smallexample
11383
11384 The @code{movf} functions are similar but use @code{movf.ps} instead
11385 of @code{movt.ps}.
11386
11387 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11388 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11389 Comparison of two paired-single values (@code{c.@var{cond}.ps},
11390 @code{bc1t}/@code{bc1f}).
11391
11392 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11393 and return either the upper or lower half of the result. For example:
11394
11395 @smallexample
11396 v2sf a, b;
11397 if (__builtin_mips_upper_c_eq_ps (a, b))
11398 upper_halves_are_equal ();
11399 else
11400 upper_halves_are_unequal ();
11401
11402 if (__builtin_mips_lower_c_eq_ps (a, b))
11403 lower_halves_are_equal ();
11404 else
11405 lower_halves_are_unequal ();
11406 @end smallexample
11407 @end table
11408
11409 @node MIPS-3D Built-in Functions
11410 @subsubsection MIPS-3D Built-in Functions
11411
11412 The MIPS-3D Application-Specific Extension (ASE) includes additional
11413 paired-single instructions that are designed to improve the performance
11414 of 3D graphics operations. Support for these instructions is controlled
11415 by the @option{-mips3d} command-line option.
11416
11417 The functions listed below map directly to a particular MIPS-3D
11418 instruction. Please refer to the architecture specification for
11419 more details on what each instruction does.
11420
11421 @table @code
11422 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
11423 Reduction add (@code{addr.ps}).
11424
11425 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
11426 Reduction multiply (@code{mulr.ps}).
11427
11428 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
11429 Convert paired single to paired word (@code{cvt.pw.ps}).
11430
11431 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
11432 Convert paired word to paired single (@code{cvt.ps.pw}).
11433
11434 @item float __builtin_mips_recip1_s (float)
11435 @itemx double __builtin_mips_recip1_d (double)
11436 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
11437 Reduced precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
11438
11439 @item float __builtin_mips_recip2_s (float, float)
11440 @itemx double __builtin_mips_recip2_d (double, double)
11441 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
11442 Reduced precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
11443
11444 @item float __builtin_mips_rsqrt1_s (float)
11445 @itemx double __builtin_mips_rsqrt1_d (double)
11446 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
11447 Reduced precision reciprocal square root (sequence step 1)
11448 (@code{rsqrt1.@var{fmt}}).
11449
11450 @item float __builtin_mips_rsqrt2_s (float, float)
11451 @itemx double __builtin_mips_rsqrt2_d (double, double)
11452 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
11453 Reduced precision reciprocal square root (sequence step 2)
11454 (@code{rsqrt2.@var{fmt}}).
11455 @end table
11456
11457 The following multi-instruction functions are also available.
11458 In each case, @var{cond} can be any of the 16 floating-point conditions:
11459 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11460 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
11461 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11462
11463 @table @code
11464 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
11465 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
11466 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
11467 @code{bc1t}/@code{bc1f}).
11468
11469 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
11470 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
11471 For example:
11472
11473 @smallexample
11474 float a, b;
11475 if (__builtin_mips_cabs_eq_s (a, b))
11476 true ();
11477 else
11478 false ();
11479 @end smallexample
11480
11481 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11482 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11483 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
11484 @code{bc1t}/@code{bc1f}).
11485
11486 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
11487 and return either the upper or lower half of the result. For example:
11488
11489 @smallexample
11490 v2sf a, b;
11491 if (__builtin_mips_upper_cabs_eq_ps (a, b))
11492 upper_halves_are_equal ();
11493 else
11494 upper_halves_are_unequal ();
11495
11496 if (__builtin_mips_lower_cabs_eq_ps (a, b))
11497 lower_halves_are_equal ();
11498 else
11499 lower_halves_are_unequal ();
11500 @end smallexample
11501
11502 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11503 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11504 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
11505 @code{movt.ps}/@code{movf.ps}).
11506
11507 The @code{movt} functions return the value @var{x} computed by:
11508
11509 @smallexample
11510 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
11511 mov.ps @var{x},@var{c}
11512 movt.ps @var{x},@var{d},@var{cc}
11513 @end smallexample
11514
11515 The @code{movf} functions are similar but use @code{movf.ps} instead
11516 of @code{movt.ps}.
11517
11518 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11519 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11520 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11521 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11522 Comparison of two paired-single values
11523 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11524 @code{bc1any2t}/@code{bc1any2f}).
11525
11526 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11527 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
11528 result is true and the @code{all} forms return true if both results are true.
11529 For example:
11530
11531 @smallexample
11532 v2sf a, b;
11533 if (__builtin_mips_any_c_eq_ps (a, b))
11534 one_is_true ();
11535 else
11536 both_are_false ();
11537
11538 if (__builtin_mips_all_c_eq_ps (a, b))
11539 both_are_true ();
11540 else
11541 one_is_false ();
11542 @end smallexample
11543
11544 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11545 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11546 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11547 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11548 Comparison of four paired-single values
11549 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11550 @code{bc1any4t}/@code{bc1any4f}).
11551
11552 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
11553 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
11554 The @code{any} forms return true if any of the four results are true
11555 and the @code{all} forms return true if all four results are true.
11556 For example:
11557
11558 @smallexample
11559 v2sf a, b, c, d;
11560 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
11561 some_are_true ();
11562 else
11563 all_are_false ();
11564
11565 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
11566 all_are_true ();
11567 else
11568 some_are_false ();
11569 @end smallexample
11570 @end table
11571
11572 @node picoChip Built-in Functions
11573 @subsection picoChip Built-in Functions
11574
11575 GCC provides an interface to selected machine instructions from the
11576 picoChip instruction set.
11577
11578 @table @code
11579 @item int __builtin_sbc (int @var{value})
11580 Sign bit count. Return the number of consecutive bits in @var{value}
11581 which have the same value as the sign-bit. The result is the number of
11582 leading sign bits minus one, giving the number of redundant sign bits in
11583 @var{value}.
11584
11585 @item int __builtin_byteswap (int @var{value})
11586 Byte swap. Return the result of swapping the upper and lower bytes of
11587 @var{value}.
11588
11589 @item int __builtin_brev (int @var{value})
11590 Bit reversal. Return the result of reversing the bits in
11591 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
11592 and so on.
11593
11594 @item int __builtin_adds (int @var{x}, int @var{y})
11595 Saturating addition. Return the result of adding @var{x} and @var{y},
11596 storing the value 32767 if the result overflows.
11597
11598 @item int __builtin_subs (int @var{x}, int @var{y})
11599 Saturating subtraction. Return the result of subtracting @var{y} from
11600 @var{x}, storing the value @minus{}32768 if the result overflows.
11601
11602 @item void __builtin_halt (void)
11603 Halt. The processor stops execution. This built-in is useful for
11604 implementing assertions.
11605
11606 @end table
11607
11608 @node Other MIPS Built-in Functions
11609 @subsection Other MIPS Built-in Functions
11610
11611 GCC provides other MIPS-specific built-in functions:
11612
11613 @table @code
11614 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
11615 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
11616 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
11617 when this function is available.
11618 @end table
11619
11620 @node PowerPC Built-in Functions
11621 @subsection PowerPC Built-in Functions
11622
11623 These built-in functions are available for the PowerPC family of
11624 processors:
11625 @smallexample
11626 float __builtin_recipdivf (float, float);
11627 float __builtin_rsqrtf (float);
11628 double __builtin_recipdiv (double, double);
11629 double __builtin_rsqrt (double);
11630 long __builtin_bpermd (long, long);
11631 uint64_t __builtin_ppc_get_timebase ();
11632 unsigned long __builtin_ppc_mftb ();
11633 @end smallexample
11634
11635 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
11636 @code{__builtin_rsqrtf} functions generate multiple instructions to
11637 implement the reciprocal sqrt functionality using reciprocal sqrt
11638 estimate instructions.
11639
11640 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
11641 functions generate multiple instructions to implement division using
11642 the reciprocal estimate instructions.
11643
11644 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
11645 functions generate instructions to read the Time Base Register. The
11646 @code{__builtin_ppc_get_timebase} function may generate multiple
11647 instructions and always returns the 64 bits of the Time Base Register.
11648 The @code{__builtin_ppc_mftb} function always generates one instruction and
11649 returns the Time Base Register value as an unsigned long, throwing away
11650 the most significant word on 32-bit environments.
11651
11652 @node PowerPC AltiVec/VSX Built-in Functions
11653 @subsection PowerPC AltiVec Built-in Functions
11654
11655 GCC provides an interface for the PowerPC family of processors to access
11656 the AltiVec operations described in Motorola's AltiVec Programming
11657 Interface Manual. The interface is made available by including
11658 @code{<altivec.h>} and using @option{-maltivec} and
11659 @option{-mabi=altivec}. The interface supports the following vector
11660 types.
11661
11662 @smallexample
11663 vector unsigned char
11664 vector signed char
11665 vector bool char
11666
11667 vector unsigned short
11668 vector signed short
11669 vector bool short
11670 vector pixel
11671
11672 vector unsigned int
11673 vector signed int
11674 vector bool int
11675 vector float
11676 @end smallexample
11677
11678 If @option{-mvsx} is used the following additional vector types are
11679 implemented.
11680
11681 @smallexample
11682 vector unsigned long
11683 vector signed long
11684 vector double
11685 @end smallexample
11686
11687 The long types are only implemented for 64-bit code generation, and
11688 the long type is only used in the floating point/integer conversion
11689 instructions.
11690
11691 GCC's implementation of the high-level language interface available from
11692 C and C++ code differs from Motorola's documentation in several ways.
11693
11694 @itemize @bullet
11695
11696 @item
11697 A vector constant is a list of constant expressions within curly braces.
11698
11699 @item
11700 A vector initializer requires no cast if the vector constant is of the
11701 same type as the variable it is initializing.
11702
11703 @item
11704 If @code{signed} or @code{unsigned} is omitted, the signedness of the
11705 vector type is the default signedness of the base type. The default
11706 varies depending on the operating system, so a portable program should
11707 always specify the signedness.
11708
11709 @item
11710 Compiling with @option{-maltivec} adds keywords @code{__vector},
11711 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
11712 @code{bool}. When compiling ISO C, the context-sensitive substitution
11713 of the keywords @code{vector}, @code{pixel} and @code{bool} is
11714 disabled. To use them, you must include @code{<altivec.h>} instead.
11715
11716 @item
11717 GCC allows using a @code{typedef} name as the type specifier for a
11718 vector type.
11719
11720 @item
11721 For C, overloaded functions are implemented with macros so the following
11722 does not work:
11723
11724 @smallexample
11725 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
11726 @end smallexample
11727
11728 Since @code{vec_add} is a macro, the vector constant in the example
11729 is treated as four separate arguments. Wrap the entire argument in
11730 parentheses for this to work.
11731 @end itemize
11732
11733 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
11734 Internally, GCC uses built-in functions to achieve the functionality in
11735 the aforementioned header file, but they are not supported and are
11736 subject to change without notice.
11737
11738 The following interfaces are supported for the generic and specific
11739 AltiVec operations and the AltiVec predicates. In cases where there
11740 is a direct mapping between generic and specific operations, only the
11741 generic names are shown here, although the specific operations can also
11742 be used.
11743
11744 Arguments that are documented as @code{const int} require literal
11745 integral values within the range required for that operation.
11746
11747 @smallexample
11748 vector signed char vec_abs (vector signed char);
11749 vector signed short vec_abs (vector signed short);
11750 vector signed int vec_abs (vector signed int);
11751 vector float vec_abs (vector float);
11752
11753 vector signed char vec_abss (vector signed char);
11754 vector signed short vec_abss (vector signed short);
11755 vector signed int vec_abss (vector signed int);
11756
11757 vector signed char vec_add (vector bool char, vector signed char);
11758 vector signed char vec_add (vector signed char, vector bool char);
11759 vector signed char vec_add (vector signed char, vector signed char);
11760 vector unsigned char vec_add (vector bool char, vector unsigned char);
11761 vector unsigned char vec_add (vector unsigned char, vector bool char);
11762 vector unsigned char vec_add (vector unsigned char,
11763 vector unsigned char);
11764 vector signed short vec_add (vector bool short, vector signed short);
11765 vector signed short vec_add (vector signed short, vector bool short);
11766 vector signed short vec_add (vector signed short, vector signed short);
11767 vector unsigned short vec_add (vector bool short,
11768 vector unsigned short);
11769 vector unsigned short vec_add (vector unsigned short,
11770 vector bool short);
11771 vector unsigned short vec_add (vector unsigned short,
11772 vector unsigned short);
11773 vector signed int vec_add (vector bool int, vector signed int);
11774 vector signed int vec_add (vector signed int, vector bool int);
11775 vector signed int vec_add (vector signed int, vector signed int);
11776 vector unsigned int vec_add (vector bool int, vector unsigned int);
11777 vector unsigned int vec_add (vector unsigned int, vector bool int);
11778 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
11779 vector float vec_add (vector float, vector float);
11780
11781 vector float vec_vaddfp (vector float, vector float);
11782
11783 vector signed int vec_vadduwm (vector bool int, vector signed int);
11784 vector signed int vec_vadduwm (vector signed int, vector bool int);
11785 vector signed int vec_vadduwm (vector signed int, vector signed int);
11786 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
11787 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
11788 vector unsigned int vec_vadduwm (vector unsigned int,
11789 vector unsigned int);
11790
11791 vector signed short vec_vadduhm (vector bool short,
11792 vector signed short);
11793 vector signed short vec_vadduhm (vector signed short,
11794 vector bool short);
11795 vector signed short vec_vadduhm (vector signed short,
11796 vector signed short);
11797 vector unsigned short vec_vadduhm (vector bool short,
11798 vector unsigned short);
11799 vector unsigned short vec_vadduhm (vector unsigned short,
11800 vector bool short);
11801 vector unsigned short vec_vadduhm (vector unsigned short,
11802 vector unsigned short);
11803
11804 vector signed char vec_vaddubm (vector bool char, vector signed char);
11805 vector signed char vec_vaddubm (vector signed char, vector bool char);
11806 vector signed char vec_vaddubm (vector signed char, vector signed char);
11807 vector unsigned char vec_vaddubm (vector bool char,
11808 vector unsigned char);
11809 vector unsigned char vec_vaddubm (vector unsigned char,
11810 vector bool char);
11811 vector unsigned char vec_vaddubm (vector unsigned char,
11812 vector unsigned char);
11813
11814 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
11815
11816 vector unsigned char vec_adds (vector bool char, vector unsigned char);
11817 vector unsigned char vec_adds (vector unsigned char, vector bool char);
11818 vector unsigned char vec_adds (vector unsigned char,
11819 vector unsigned char);
11820 vector signed char vec_adds (vector bool char, vector signed char);
11821 vector signed char vec_adds (vector signed char, vector bool char);
11822 vector signed char vec_adds (vector signed char, vector signed char);
11823 vector unsigned short vec_adds (vector bool short,
11824 vector unsigned short);
11825 vector unsigned short vec_adds (vector unsigned short,
11826 vector bool short);
11827 vector unsigned short vec_adds (vector unsigned short,
11828 vector unsigned short);
11829 vector signed short vec_adds (vector bool short, vector signed short);
11830 vector signed short vec_adds (vector signed short, vector bool short);
11831 vector signed short vec_adds (vector signed short, vector signed short);
11832 vector unsigned int vec_adds (vector bool int, vector unsigned int);
11833 vector unsigned int vec_adds (vector unsigned int, vector bool int);
11834 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
11835 vector signed int vec_adds (vector bool int, vector signed int);
11836 vector signed int vec_adds (vector signed int, vector bool int);
11837 vector signed int vec_adds (vector signed int, vector signed int);
11838
11839 vector signed int vec_vaddsws (vector bool int, vector signed int);
11840 vector signed int vec_vaddsws (vector signed int, vector bool int);
11841 vector signed int vec_vaddsws (vector signed int, vector signed int);
11842
11843 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
11844 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
11845 vector unsigned int vec_vadduws (vector unsigned int,
11846 vector unsigned int);
11847
11848 vector signed short vec_vaddshs (vector bool short,
11849 vector signed short);
11850 vector signed short vec_vaddshs (vector signed short,
11851 vector bool short);
11852 vector signed short vec_vaddshs (vector signed short,
11853 vector signed short);
11854
11855 vector unsigned short vec_vadduhs (vector bool short,
11856 vector unsigned short);
11857 vector unsigned short vec_vadduhs (vector unsigned short,
11858 vector bool short);
11859 vector unsigned short vec_vadduhs (vector unsigned short,
11860 vector unsigned short);
11861
11862 vector signed char vec_vaddsbs (vector bool char, vector signed char);
11863 vector signed char vec_vaddsbs (vector signed char, vector bool char);
11864 vector signed char vec_vaddsbs (vector signed char, vector signed char);
11865
11866 vector unsigned char vec_vaddubs (vector bool char,
11867 vector unsigned char);
11868 vector unsigned char vec_vaddubs (vector unsigned char,
11869 vector bool char);
11870 vector unsigned char vec_vaddubs (vector unsigned char,
11871 vector unsigned char);
11872
11873 vector float vec_and (vector float, vector float);
11874 vector float vec_and (vector float, vector bool int);
11875 vector float vec_and (vector bool int, vector float);
11876 vector bool int vec_and (vector bool int, vector bool int);
11877 vector signed int vec_and (vector bool int, vector signed int);
11878 vector signed int vec_and (vector signed int, vector bool int);
11879 vector signed int vec_and (vector signed int, vector signed int);
11880 vector unsigned int vec_and (vector bool int, vector unsigned int);
11881 vector unsigned int vec_and (vector unsigned int, vector bool int);
11882 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
11883 vector bool short vec_and (vector bool short, vector bool short);
11884 vector signed short vec_and (vector bool short, vector signed short);
11885 vector signed short vec_and (vector signed short, vector bool short);
11886 vector signed short vec_and (vector signed short, vector signed short);
11887 vector unsigned short vec_and (vector bool short,
11888 vector unsigned short);
11889 vector unsigned short vec_and (vector unsigned short,
11890 vector bool short);
11891 vector unsigned short vec_and (vector unsigned short,
11892 vector unsigned short);
11893 vector signed char vec_and (vector bool char, vector signed char);
11894 vector bool char vec_and (vector bool char, vector bool char);
11895 vector signed char vec_and (vector signed char, vector bool char);
11896 vector signed char vec_and (vector signed char, vector signed char);
11897 vector unsigned char vec_and (vector bool char, vector unsigned char);
11898 vector unsigned char vec_and (vector unsigned char, vector bool char);
11899 vector unsigned char vec_and (vector unsigned char,
11900 vector unsigned char);
11901
11902 vector float vec_andc (vector float, vector float);
11903 vector float vec_andc (vector float, vector bool int);
11904 vector float vec_andc (vector bool int, vector float);
11905 vector bool int vec_andc (vector bool int, vector bool int);
11906 vector signed int vec_andc (vector bool int, vector signed int);
11907 vector signed int vec_andc (vector signed int, vector bool int);
11908 vector signed int vec_andc (vector signed int, vector signed int);
11909 vector unsigned int vec_andc (vector bool int, vector unsigned int);
11910 vector unsigned int vec_andc (vector unsigned int, vector bool int);
11911 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
11912 vector bool short vec_andc (vector bool short, vector bool short);
11913 vector signed short vec_andc (vector bool short, vector signed short);
11914 vector signed short vec_andc (vector signed short, vector bool short);
11915 vector signed short vec_andc (vector signed short, vector signed short);
11916 vector unsigned short vec_andc (vector bool short,
11917 vector unsigned short);
11918 vector unsigned short vec_andc (vector unsigned short,
11919 vector bool short);
11920 vector unsigned short vec_andc (vector unsigned short,
11921 vector unsigned short);
11922 vector signed char vec_andc (vector bool char, vector signed char);
11923 vector bool char vec_andc (vector bool char, vector bool char);
11924 vector signed char vec_andc (vector signed char, vector bool char);
11925 vector signed char vec_andc (vector signed char, vector signed char);
11926 vector unsigned char vec_andc (vector bool char, vector unsigned char);
11927 vector unsigned char vec_andc (vector unsigned char, vector bool char);
11928 vector unsigned char vec_andc (vector unsigned char,
11929 vector unsigned char);
11930
11931 vector unsigned char vec_avg (vector unsigned char,
11932 vector unsigned char);
11933 vector signed char vec_avg (vector signed char, vector signed char);
11934 vector unsigned short vec_avg (vector unsigned short,
11935 vector unsigned short);
11936 vector signed short vec_avg (vector signed short, vector signed short);
11937 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
11938 vector signed int vec_avg (vector signed int, vector signed int);
11939
11940 vector signed int vec_vavgsw (vector signed int, vector signed int);
11941
11942 vector unsigned int vec_vavguw (vector unsigned int,
11943 vector unsigned int);
11944
11945 vector signed short vec_vavgsh (vector signed short,
11946 vector signed short);
11947
11948 vector unsigned short vec_vavguh (vector unsigned short,
11949 vector unsigned short);
11950
11951 vector signed char vec_vavgsb (vector signed char, vector signed char);
11952
11953 vector unsigned char vec_vavgub (vector unsigned char,
11954 vector unsigned char);
11955
11956 vector float vec_copysign (vector float);
11957
11958 vector float vec_ceil (vector float);
11959
11960 vector signed int vec_cmpb (vector float, vector float);
11961
11962 vector bool char vec_cmpeq (vector signed char, vector signed char);
11963 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
11964 vector bool short vec_cmpeq (vector signed short, vector signed short);
11965 vector bool short vec_cmpeq (vector unsigned short,
11966 vector unsigned short);
11967 vector bool int vec_cmpeq (vector signed int, vector signed int);
11968 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
11969 vector bool int vec_cmpeq (vector float, vector float);
11970
11971 vector bool int vec_vcmpeqfp (vector float, vector float);
11972
11973 vector bool int vec_vcmpequw (vector signed int, vector signed int);
11974 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
11975
11976 vector bool short vec_vcmpequh (vector signed short,
11977 vector signed short);
11978 vector bool short vec_vcmpequh (vector unsigned short,
11979 vector unsigned short);
11980
11981 vector bool char vec_vcmpequb (vector signed char, vector signed char);
11982 vector bool char vec_vcmpequb (vector unsigned char,
11983 vector unsigned char);
11984
11985 vector bool int vec_cmpge (vector float, vector float);
11986
11987 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
11988 vector bool char vec_cmpgt (vector signed char, vector signed char);
11989 vector bool short vec_cmpgt (vector unsigned short,
11990 vector unsigned short);
11991 vector bool short vec_cmpgt (vector signed short, vector signed short);
11992 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
11993 vector bool int vec_cmpgt (vector signed int, vector signed int);
11994 vector bool int vec_cmpgt (vector float, vector float);
11995
11996 vector bool int vec_vcmpgtfp (vector float, vector float);
11997
11998 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
11999
12000 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12001
12002 vector bool short vec_vcmpgtsh (vector signed short,
12003 vector signed short);
12004
12005 vector bool short vec_vcmpgtuh (vector unsigned short,
12006 vector unsigned short);
12007
12008 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12009
12010 vector bool char vec_vcmpgtub (vector unsigned char,
12011 vector unsigned char);
12012
12013 vector bool int vec_cmple (vector float, vector float);
12014
12015 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12016 vector bool char vec_cmplt (vector signed char, vector signed char);
12017 vector bool short vec_cmplt (vector unsigned short,
12018 vector unsigned short);
12019 vector bool short vec_cmplt (vector signed short, vector signed short);
12020 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12021 vector bool int vec_cmplt (vector signed int, vector signed int);
12022 vector bool int vec_cmplt (vector float, vector float);
12023
12024 vector float vec_ctf (vector unsigned int, const int);
12025 vector float vec_ctf (vector signed int, const int);
12026
12027 vector float vec_vcfsx (vector signed int, const int);
12028
12029 vector float vec_vcfux (vector unsigned int, const int);
12030
12031 vector signed int vec_cts (vector float, const int);
12032
12033 vector unsigned int vec_ctu (vector float, const int);
12034
12035 void vec_dss (const int);
12036
12037 void vec_dssall (void);
12038
12039 void vec_dst (const vector unsigned char *, int, const int);
12040 void vec_dst (const vector signed char *, int, const int);
12041 void vec_dst (const vector bool char *, int, const int);
12042 void vec_dst (const vector unsigned short *, int, const int);
12043 void vec_dst (const vector signed short *, int, const int);
12044 void vec_dst (const vector bool short *, int, const int);
12045 void vec_dst (const vector pixel *, int, const int);
12046 void vec_dst (const vector unsigned int *, int, const int);
12047 void vec_dst (const vector signed int *, int, const int);
12048 void vec_dst (const vector bool int *, int, const int);
12049 void vec_dst (const vector float *, int, const int);
12050 void vec_dst (const unsigned char *, int, const int);
12051 void vec_dst (const signed char *, int, const int);
12052 void vec_dst (const unsigned short *, int, const int);
12053 void vec_dst (const short *, int, const int);
12054 void vec_dst (const unsigned int *, int, const int);
12055 void vec_dst (const int *, int, const int);
12056 void vec_dst (const unsigned long *, int, const int);
12057 void vec_dst (const long *, int, const int);
12058 void vec_dst (const float *, int, const int);
12059
12060 void vec_dstst (const vector unsigned char *, int, const int);
12061 void vec_dstst (const vector signed char *, int, const int);
12062 void vec_dstst (const vector bool char *, int, const int);
12063 void vec_dstst (const vector unsigned short *, int, const int);
12064 void vec_dstst (const vector signed short *, int, const int);
12065 void vec_dstst (const vector bool short *, int, const int);
12066 void vec_dstst (const vector pixel *, int, const int);
12067 void vec_dstst (const vector unsigned int *, int, const int);
12068 void vec_dstst (const vector signed int *, int, const int);
12069 void vec_dstst (const vector bool int *, int, const int);
12070 void vec_dstst (const vector float *, int, const int);
12071 void vec_dstst (const unsigned char *, int, const int);
12072 void vec_dstst (const signed char *, int, const int);
12073 void vec_dstst (const unsigned short *, int, const int);
12074 void vec_dstst (const short *, int, const int);
12075 void vec_dstst (const unsigned int *, int, const int);
12076 void vec_dstst (const int *, int, const int);
12077 void vec_dstst (const unsigned long *, int, const int);
12078 void vec_dstst (const long *, int, const int);
12079 void vec_dstst (const float *, int, const int);
12080
12081 void vec_dststt (const vector unsigned char *, int, const int);
12082 void vec_dststt (const vector signed char *, int, const int);
12083 void vec_dststt (const vector bool char *, int, const int);
12084 void vec_dststt (const vector unsigned short *, int, const int);
12085 void vec_dststt (const vector signed short *, int, const int);
12086 void vec_dststt (const vector bool short *, int, const int);
12087 void vec_dststt (const vector pixel *, int, const int);
12088 void vec_dststt (const vector unsigned int *, int, const int);
12089 void vec_dststt (const vector signed int *, int, const int);
12090 void vec_dststt (const vector bool int *, int, const int);
12091 void vec_dststt (const vector float *, int, const int);
12092 void vec_dststt (const unsigned char *, int, const int);
12093 void vec_dststt (const signed char *, int, const int);
12094 void vec_dststt (const unsigned short *, int, const int);
12095 void vec_dststt (const short *, int, const int);
12096 void vec_dststt (const unsigned int *, int, const int);
12097 void vec_dststt (const int *, int, const int);
12098 void vec_dststt (const unsigned long *, int, const int);
12099 void vec_dststt (const long *, int, const int);
12100 void vec_dststt (const float *, int, const int);
12101
12102 void vec_dstt (const vector unsigned char *, int, const int);
12103 void vec_dstt (const vector signed char *, int, const int);
12104 void vec_dstt (const vector bool char *, int, const int);
12105 void vec_dstt (const vector unsigned short *, int, const int);
12106 void vec_dstt (const vector signed short *, int, const int);
12107 void vec_dstt (const vector bool short *, int, const int);
12108 void vec_dstt (const vector pixel *, int, const int);
12109 void vec_dstt (const vector unsigned int *, int, const int);
12110 void vec_dstt (const vector signed int *, int, const int);
12111 void vec_dstt (const vector bool int *, int, const int);
12112 void vec_dstt (const vector float *, int, const int);
12113 void vec_dstt (const unsigned char *, int, const int);
12114 void vec_dstt (const signed char *, int, const int);
12115 void vec_dstt (const unsigned short *, int, const int);
12116 void vec_dstt (const short *, int, const int);
12117 void vec_dstt (const unsigned int *, int, const int);
12118 void vec_dstt (const int *, int, const int);
12119 void vec_dstt (const unsigned long *, int, const int);
12120 void vec_dstt (const long *, int, const int);
12121 void vec_dstt (const float *, int, const int);
12122
12123 vector float vec_expte (vector float);
12124
12125 vector float vec_floor (vector float);
12126
12127 vector float vec_ld (int, const vector float *);
12128 vector float vec_ld (int, const float *);
12129 vector bool int vec_ld (int, const vector bool int *);
12130 vector signed int vec_ld (int, const vector signed int *);
12131 vector signed int vec_ld (int, const int *);
12132 vector signed int vec_ld (int, const long *);
12133 vector unsigned int vec_ld (int, const vector unsigned int *);
12134 vector unsigned int vec_ld (int, const unsigned int *);
12135 vector unsigned int vec_ld (int, const unsigned long *);
12136 vector bool short vec_ld (int, const vector bool short *);
12137 vector pixel vec_ld (int, const vector pixel *);
12138 vector signed short vec_ld (int, const vector signed short *);
12139 vector signed short vec_ld (int, const short *);
12140 vector unsigned short vec_ld (int, const vector unsigned short *);
12141 vector unsigned short vec_ld (int, const unsigned short *);
12142 vector bool char vec_ld (int, const vector bool char *);
12143 vector signed char vec_ld (int, const vector signed char *);
12144 vector signed char vec_ld (int, const signed char *);
12145 vector unsigned char vec_ld (int, const vector unsigned char *);
12146 vector unsigned char vec_ld (int, const unsigned char *);
12147
12148 vector signed char vec_lde (int, const signed char *);
12149 vector unsigned char vec_lde (int, const unsigned char *);
12150 vector signed short vec_lde (int, const short *);
12151 vector unsigned short vec_lde (int, const unsigned short *);
12152 vector float vec_lde (int, const float *);
12153 vector signed int vec_lde (int, const int *);
12154 vector unsigned int vec_lde (int, const unsigned int *);
12155 vector signed int vec_lde (int, const long *);
12156 vector unsigned int vec_lde (int, const unsigned long *);
12157
12158 vector float vec_lvewx (int, float *);
12159 vector signed int vec_lvewx (int, int *);
12160 vector unsigned int vec_lvewx (int, unsigned int *);
12161 vector signed int vec_lvewx (int, long *);
12162 vector unsigned int vec_lvewx (int, unsigned long *);
12163
12164 vector signed short vec_lvehx (int, short *);
12165 vector unsigned short vec_lvehx (int, unsigned short *);
12166
12167 vector signed char vec_lvebx (int, char *);
12168 vector unsigned char vec_lvebx (int, unsigned char *);
12169
12170 vector float vec_ldl (int, const vector float *);
12171 vector float vec_ldl (int, const float *);
12172 vector bool int vec_ldl (int, const vector bool int *);
12173 vector signed int vec_ldl (int, const vector signed int *);
12174 vector signed int vec_ldl (int, const int *);
12175 vector signed int vec_ldl (int, const long *);
12176 vector unsigned int vec_ldl (int, const vector unsigned int *);
12177 vector unsigned int vec_ldl (int, const unsigned int *);
12178 vector unsigned int vec_ldl (int, const unsigned long *);
12179 vector bool short vec_ldl (int, const vector bool short *);
12180 vector pixel vec_ldl (int, const vector pixel *);
12181 vector signed short vec_ldl (int, const vector signed short *);
12182 vector signed short vec_ldl (int, const short *);
12183 vector unsigned short vec_ldl (int, const vector unsigned short *);
12184 vector unsigned short vec_ldl (int, const unsigned short *);
12185 vector bool char vec_ldl (int, const vector bool char *);
12186 vector signed char vec_ldl (int, const vector signed char *);
12187 vector signed char vec_ldl (int, const signed char *);
12188 vector unsigned char vec_ldl (int, const vector unsigned char *);
12189 vector unsigned char vec_ldl (int, const unsigned char *);
12190
12191 vector float vec_loge (vector float);
12192
12193 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12194 vector unsigned char vec_lvsl (int, const volatile signed char *);
12195 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12196 vector unsigned char vec_lvsl (int, const volatile short *);
12197 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12198 vector unsigned char vec_lvsl (int, const volatile int *);
12199 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12200 vector unsigned char vec_lvsl (int, const volatile long *);
12201 vector unsigned char vec_lvsl (int, const volatile float *);
12202
12203 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
12204 vector unsigned char vec_lvsr (int, const volatile signed char *);
12205 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
12206 vector unsigned char vec_lvsr (int, const volatile short *);
12207 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
12208 vector unsigned char vec_lvsr (int, const volatile int *);
12209 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
12210 vector unsigned char vec_lvsr (int, const volatile long *);
12211 vector unsigned char vec_lvsr (int, const volatile float *);
12212
12213 vector float vec_madd (vector float, vector float, vector float);
12214
12215 vector signed short vec_madds (vector signed short,
12216 vector signed short,
12217 vector signed short);
12218
12219 vector unsigned char vec_max (vector bool char, vector unsigned char);
12220 vector unsigned char vec_max (vector unsigned char, vector bool char);
12221 vector unsigned char vec_max (vector unsigned char,
12222 vector unsigned char);
12223 vector signed char vec_max (vector bool char, vector signed char);
12224 vector signed char vec_max (vector signed char, vector bool char);
12225 vector signed char vec_max (vector signed char, vector signed char);
12226 vector unsigned short vec_max (vector bool short,
12227 vector unsigned short);
12228 vector unsigned short vec_max (vector unsigned short,
12229 vector bool short);
12230 vector unsigned short vec_max (vector unsigned short,
12231 vector unsigned short);
12232 vector signed short vec_max (vector bool short, vector signed short);
12233 vector signed short vec_max (vector signed short, vector bool short);
12234 vector signed short vec_max (vector signed short, vector signed short);
12235 vector unsigned int vec_max (vector bool int, vector unsigned int);
12236 vector unsigned int vec_max (vector unsigned int, vector bool int);
12237 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
12238 vector signed int vec_max (vector bool int, vector signed int);
12239 vector signed int vec_max (vector signed int, vector bool int);
12240 vector signed int vec_max (vector signed int, vector signed int);
12241 vector float vec_max (vector float, vector float);
12242
12243 vector float vec_vmaxfp (vector float, vector float);
12244
12245 vector signed int vec_vmaxsw (vector bool int, vector signed int);
12246 vector signed int vec_vmaxsw (vector signed int, vector bool int);
12247 vector signed int vec_vmaxsw (vector signed int, vector signed int);
12248
12249 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
12250 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
12251 vector unsigned int vec_vmaxuw (vector unsigned int,
12252 vector unsigned int);
12253
12254 vector signed short vec_vmaxsh (vector bool short, vector signed short);
12255 vector signed short vec_vmaxsh (vector signed short, vector bool short);
12256 vector signed short vec_vmaxsh (vector signed short,
12257 vector signed short);
12258
12259 vector unsigned short vec_vmaxuh (vector bool short,
12260 vector unsigned short);
12261 vector unsigned short vec_vmaxuh (vector unsigned short,
12262 vector bool short);
12263 vector unsigned short vec_vmaxuh (vector unsigned short,
12264 vector unsigned short);
12265
12266 vector signed char vec_vmaxsb (vector bool char, vector signed char);
12267 vector signed char vec_vmaxsb (vector signed char, vector bool char);
12268 vector signed char vec_vmaxsb (vector signed char, vector signed char);
12269
12270 vector unsigned char vec_vmaxub (vector bool char,
12271 vector unsigned char);
12272 vector unsigned char vec_vmaxub (vector unsigned char,
12273 vector bool char);
12274 vector unsigned char vec_vmaxub (vector unsigned char,
12275 vector unsigned char);
12276
12277 vector bool char vec_mergeh (vector bool char, vector bool char);
12278 vector signed char vec_mergeh (vector signed char, vector signed char);
12279 vector unsigned char vec_mergeh (vector unsigned char,
12280 vector unsigned char);
12281 vector bool short vec_mergeh (vector bool short, vector bool short);
12282 vector pixel vec_mergeh (vector pixel, vector pixel);
12283 vector signed short vec_mergeh (vector signed short,
12284 vector signed short);
12285 vector unsigned short vec_mergeh (vector unsigned short,
12286 vector unsigned short);
12287 vector float vec_mergeh (vector float, vector float);
12288 vector bool int vec_mergeh (vector bool int, vector bool int);
12289 vector signed int vec_mergeh (vector signed int, vector signed int);
12290 vector unsigned int vec_mergeh (vector unsigned int,
12291 vector unsigned int);
12292
12293 vector float vec_vmrghw (vector float, vector float);
12294 vector bool int vec_vmrghw (vector bool int, vector bool int);
12295 vector signed int vec_vmrghw (vector signed int, vector signed int);
12296 vector unsigned int vec_vmrghw (vector unsigned int,
12297 vector unsigned int);
12298
12299 vector bool short vec_vmrghh (vector bool short, vector bool short);
12300 vector signed short vec_vmrghh (vector signed short,
12301 vector signed short);
12302 vector unsigned short vec_vmrghh (vector unsigned short,
12303 vector unsigned short);
12304 vector pixel vec_vmrghh (vector pixel, vector pixel);
12305
12306 vector bool char vec_vmrghb (vector bool char, vector bool char);
12307 vector signed char vec_vmrghb (vector signed char, vector signed char);
12308 vector unsigned char vec_vmrghb (vector unsigned char,
12309 vector unsigned char);
12310
12311 vector bool char vec_mergel (vector bool char, vector bool char);
12312 vector signed char vec_mergel (vector signed char, vector signed char);
12313 vector unsigned char vec_mergel (vector unsigned char,
12314 vector unsigned char);
12315 vector bool short vec_mergel (vector bool short, vector bool short);
12316 vector pixel vec_mergel (vector pixel, vector pixel);
12317 vector signed short vec_mergel (vector signed short,
12318 vector signed short);
12319 vector unsigned short vec_mergel (vector unsigned short,
12320 vector unsigned short);
12321 vector float vec_mergel (vector float, vector float);
12322 vector bool int vec_mergel (vector bool int, vector bool int);
12323 vector signed int vec_mergel (vector signed int, vector signed int);
12324 vector unsigned int vec_mergel (vector unsigned int,
12325 vector unsigned int);
12326
12327 vector float vec_vmrglw (vector float, vector float);
12328 vector signed int vec_vmrglw (vector signed int, vector signed int);
12329 vector unsigned int vec_vmrglw (vector unsigned int,
12330 vector unsigned int);
12331 vector bool int vec_vmrglw (vector bool int, vector bool int);
12332
12333 vector bool short vec_vmrglh (vector bool short, vector bool short);
12334 vector signed short vec_vmrglh (vector signed short,
12335 vector signed short);
12336 vector unsigned short vec_vmrglh (vector unsigned short,
12337 vector unsigned short);
12338 vector pixel vec_vmrglh (vector pixel, vector pixel);
12339
12340 vector bool char vec_vmrglb (vector bool char, vector bool char);
12341 vector signed char vec_vmrglb (vector signed char, vector signed char);
12342 vector unsigned char vec_vmrglb (vector unsigned char,
12343 vector unsigned char);
12344
12345 vector unsigned short vec_mfvscr (void);
12346
12347 vector unsigned char vec_min (vector bool char, vector unsigned char);
12348 vector unsigned char vec_min (vector unsigned char, vector bool char);
12349 vector unsigned char vec_min (vector unsigned char,
12350 vector unsigned char);
12351 vector signed char vec_min (vector bool char, vector signed char);
12352 vector signed char vec_min (vector signed char, vector bool char);
12353 vector signed char vec_min (vector signed char, vector signed char);
12354 vector unsigned short vec_min (vector bool short,
12355 vector unsigned short);
12356 vector unsigned short vec_min (vector unsigned short,
12357 vector bool short);
12358 vector unsigned short vec_min (vector unsigned short,
12359 vector unsigned short);
12360 vector signed short vec_min (vector bool short, vector signed short);
12361 vector signed short vec_min (vector signed short, vector bool short);
12362 vector signed short vec_min (vector signed short, vector signed short);
12363 vector unsigned int vec_min (vector bool int, vector unsigned int);
12364 vector unsigned int vec_min (vector unsigned int, vector bool int);
12365 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
12366 vector signed int vec_min (vector bool int, vector signed int);
12367 vector signed int vec_min (vector signed int, vector bool int);
12368 vector signed int vec_min (vector signed int, vector signed int);
12369 vector float vec_min (vector float, vector float);
12370
12371 vector float vec_vminfp (vector float, vector float);
12372
12373 vector signed int vec_vminsw (vector bool int, vector signed int);
12374 vector signed int vec_vminsw (vector signed int, vector bool int);
12375 vector signed int vec_vminsw (vector signed int, vector signed int);
12376
12377 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
12378 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
12379 vector unsigned int vec_vminuw (vector unsigned int,
12380 vector unsigned int);
12381
12382 vector signed short vec_vminsh (vector bool short, vector signed short);
12383 vector signed short vec_vminsh (vector signed short, vector bool short);
12384 vector signed short vec_vminsh (vector signed short,
12385 vector signed short);
12386
12387 vector unsigned short vec_vminuh (vector bool short,
12388 vector unsigned short);
12389 vector unsigned short vec_vminuh (vector unsigned short,
12390 vector bool short);
12391 vector unsigned short vec_vminuh (vector unsigned short,
12392 vector unsigned short);
12393
12394 vector signed char vec_vminsb (vector bool char, vector signed char);
12395 vector signed char vec_vminsb (vector signed char, vector bool char);
12396 vector signed char vec_vminsb (vector signed char, vector signed char);
12397
12398 vector unsigned char vec_vminub (vector bool char,
12399 vector unsigned char);
12400 vector unsigned char vec_vminub (vector unsigned char,
12401 vector bool char);
12402 vector unsigned char vec_vminub (vector unsigned char,
12403 vector unsigned char);
12404
12405 vector signed short vec_mladd (vector signed short,
12406 vector signed short,
12407 vector signed short);
12408 vector signed short vec_mladd (vector signed short,
12409 vector unsigned short,
12410 vector unsigned short);
12411 vector signed short vec_mladd (vector unsigned short,
12412 vector signed short,
12413 vector signed short);
12414 vector unsigned short vec_mladd (vector unsigned short,
12415 vector unsigned short,
12416 vector unsigned short);
12417
12418 vector signed short vec_mradds (vector signed short,
12419 vector signed short,
12420 vector signed short);
12421
12422 vector unsigned int vec_msum (vector unsigned char,
12423 vector unsigned char,
12424 vector unsigned int);
12425 vector signed int vec_msum (vector signed char,
12426 vector unsigned char,
12427 vector signed int);
12428 vector unsigned int vec_msum (vector unsigned short,
12429 vector unsigned short,
12430 vector unsigned int);
12431 vector signed int vec_msum (vector signed short,
12432 vector signed short,
12433 vector signed int);
12434
12435 vector signed int vec_vmsumshm (vector signed short,
12436 vector signed short,
12437 vector signed int);
12438
12439 vector unsigned int vec_vmsumuhm (vector unsigned short,
12440 vector unsigned short,
12441 vector unsigned int);
12442
12443 vector signed int vec_vmsummbm (vector signed char,
12444 vector unsigned char,
12445 vector signed int);
12446
12447 vector unsigned int vec_vmsumubm (vector unsigned char,
12448 vector unsigned char,
12449 vector unsigned int);
12450
12451 vector unsigned int vec_msums (vector unsigned short,
12452 vector unsigned short,
12453 vector unsigned int);
12454 vector signed int vec_msums (vector signed short,
12455 vector signed short,
12456 vector signed int);
12457
12458 vector signed int vec_vmsumshs (vector signed short,
12459 vector signed short,
12460 vector signed int);
12461
12462 vector unsigned int vec_vmsumuhs (vector unsigned short,
12463 vector unsigned short,
12464 vector unsigned int);
12465
12466 void vec_mtvscr (vector signed int);
12467 void vec_mtvscr (vector unsigned int);
12468 void vec_mtvscr (vector bool int);
12469 void vec_mtvscr (vector signed short);
12470 void vec_mtvscr (vector unsigned short);
12471 void vec_mtvscr (vector bool short);
12472 void vec_mtvscr (vector pixel);
12473 void vec_mtvscr (vector signed char);
12474 void vec_mtvscr (vector unsigned char);
12475 void vec_mtvscr (vector bool char);
12476
12477 vector unsigned short vec_mule (vector unsigned char,
12478 vector unsigned char);
12479 vector signed short vec_mule (vector signed char,
12480 vector signed char);
12481 vector unsigned int vec_mule (vector unsigned short,
12482 vector unsigned short);
12483 vector signed int vec_mule (vector signed short, vector signed short);
12484
12485 vector signed int vec_vmulesh (vector signed short,
12486 vector signed short);
12487
12488 vector unsigned int vec_vmuleuh (vector unsigned short,
12489 vector unsigned short);
12490
12491 vector signed short vec_vmulesb (vector signed char,
12492 vector signed char);
12493
12494 vector unsigned short vec_vmuleub (vector unsigned char,
12495 vector unsigned char);
12496
12497 vector unsigned short vec_mulo (vector unsigned char,
12498 vector unsigned char);
12499 vector signed short vec_mulo (vector signed char, vector signed char);
12500 vector unsigned int vec_mulo (vector unsigned short,
12501 vector unsigned short);
12502 vector signed int vec_mulo (vector signed short, vector signed short);
12503
12504 vector signed int vec_vmulosh (vector signed short,
12505 vector signed short);
12506
12507 vector unsigned int vec_vmulouh (vector unsigned short,
12508 vector unsigned short);
12509
12510 vector signed short vec_vmulosb (vector signed char,
12511 vector signed char);
12512
12513 vector unsigned short vec_vmuloub (vector unsigned char,
12514 vector unsigned char);
12515
12516 vector float vec_nmsub (vector float, vector float, vector float);
12517
12518 vector float vec_nor (vector float, vector float);
12519 vector signed int vec_nor (vector signed int, vector signed int);
12520 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
12521 vector bool int vec_nor (vector bool int, vector bool int);
12522 vector signed short vec_nor (vector signed short, vector signed short);
12523 vector unsigned short vec_nor (vector unsigned short,
12524 vector unsigned short);
12525 vector bool short vec_nor (vector bool short, vector bool short);
12526 vector signed char vec_nor (vector signed char, vector signed char);
12527 vector unsigned char vec_nor (vector unsigned char,
12528 vector unsigned char);
12529 vector bool char vec_nor (vector bool char, vector bool char);
12530
12531 vector float vec_or (vector float, vector float);
12532 vector float vec_or (vector float, vector bool int);
12533 vector float vec_or (vector bool int, vector float);
12534 vector bool int vec_or (vector bool int, vector bool int);
12535 vector signed int vec_or (vector bool int, vector signed int);
12536 vector signed int vec_or (vector signed int, vector bool int);
12537 vector signed int vec_or (vector signed int, vector signed int);
12538 vector unsigned int vec_or (vector bool int, vector unsigned int);
12539 vector unsigned int vec_or (vector unsigned int, vector bool int);
12540 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
12541 vector bool short vec_or (vector bool short, vector bool short);
12542 vector signed short vec_or (vector bool short, vector signed short);
12543 vector signed short vec_or (vector signed short, vector bool short);
12544 vector signed short vec_or (vector signed short, vector signed short);
12545 vector unsigned short vec_or (vector bool short, vector unsigned short);
12546 vector unsigned short vec_or (vector unsigned short, vector bool short);
12547 vector unsigned short vec_or (vector unsigned short,
12548 vector unsigned short);
12549 vector signed char vec_or (vector bool char, vector signed char);
12550 vector bool char vec_or (vector bool char, vector bool char);
12551 vector signed char vec_or (vector signed char, vector bool char);
12552 vector signed char vec_or (vector signed char, vector signed char);
12553 vector unsigned char vec_or (vector bool char, vector unsigned char);
12554 vector unsigned char vec_or (vector unsigned char, vector bool char);
12555 vector unsigned char vec_or (vector unsigned char,
12556 vector unsigned char);
12557
12558 vector signed char vec_pack (vector signed short, vector signed short);
12559 vector unsigned char vec_pack (vector unsigned short,
12560 vector unsigned short);
12561 vector bool char vec_pack (vector bool short, vector bool short);
12562 vector signed short vec_pack (vector signed int, vector signed int);
12563 vector unsigned short vec_pack (vector unsigned int,
12564 vector unsigned int);
12565 vector bool short vec_pack (vector bool int, vector bool int);
12566
12567 vector bool short vec_vpkuwum (vector bool int, vector bool int);
12568 vector signed short vec_vpkuwum (vector signed int, vector signed int);
12569 vector unsigned short vec_vpkuwum (vector unsigned int,
12570 vector unsigned int);
12571
12572 vector bool char vec_vpkuhum (vector bool short, vector bool short);
12573 vector signed char vec_vpkuhum (vector signed short,
12574 vector signed short);
12575 vector unsigned char vec_vpkuhum (vector unsigned short,
12576 vector unsigned short);
12577
12578 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
12579
12580 vector unsigned char vec_packs (vector unsigned short,
12581 vector unsigned short);
12582 vector signed char vec_packs (vector signed short, vector signed short);
12583 vector unsigned short vec_packs (vector unsigned int,
12584 vector unsigned int);
12585 vector signed short vec_packs (vector signed int, vector signed int);
12586
12587 vector signed short vec_vpkswss (vector signed int, vector signed int);
12588
12589 vector unsigned short vec_vpkuwus (vector unsigned int,
12590 vector unsigned int);
12591
12592 vector signed char vec_vpkshss (vector signed short,
12593 vector signed short);
12594
12595 vector unsigned char vec_vpkuhus (vector unsigned short,
12596 vector unsigned short);
12597
12598 vector unsigned char vec_packsu (vector unsigned short,
12599 vector unsigned short);
12600 vector unsigned char vec_packsu (vector signed short,
12601 vector signed short);
12602 vector unsigned short vec_packsu (vector unsigned int,
12603 vector unsigned int);
12604 vector unsigned short vec_packsu (vector signed int, vector signed int);
12605
12606 vector unsigned short vec_vpkswus (vector signed int,
12607 vector signed int);
12608
12609 vector unsigned char vec_vpkshus (vector signed short,
12610 vector signed short);
12611
12612 vector float vec_perm (vector float,
12613 vector float,
12614 vector unsigned char);
12615 vector signed int vec_perm (vector signed int,
12616 vector signed int,
12617 vector unsigned char);
12618 vector unsigned int vec_perm (vector unsigned int,
12619 vector unsigned int,
12620 vector unsigned char);
12621 vector bool int vec_perm (vector bool int,
12622 vector bool int,
12623 vector unsigned char);
12624 vector signed short vec_perm (vector signed short,
12625 vector signed short,
12626 vector unsigned char);
12627 vector unsigned short vec_perm (vector unsigned short,
12628 vector unsigned short,
12629 vector unsigned char);
12630 vector bool short vec_perm (vector bool short,
12631 vector bool short,
12632 vector unsigned char);
12633 vector pixel vec_perm (vector pixel,
12634 vector pixel,
12635 vector unsigned char);
12636 vector signed char vec_perm (vector signed char,
12637 vector signed char,
12638 vector unsigned char);
12639 vector unsigned char vec_perm (vector unsigned char,
12640 vector unsigned char,
12641 vector unsigned char);
12642 vector bool char vec_perm (vector bool char,
12643 vector bool char,
12644 vector unsigned char);
12645
12646 vector float vec_re (vector float);
12647
12648 vector signed char vec_rl (vector signed char,
12649 vector unsigned char);
12650 vector unsigned char vec_rl (vector unsigned char,
12651 vector unsigned char);
12652 vector signed short vec_rl (vector signed short, vector unsigned short);
12653 vector unsigned short vec_rl (vector unsigned short,
12654 vector unsigned short);
12655 vector signed int vec_rl (vector signed int, vector unsigned int);
12656 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
12657
12658 vector signed int vec_vrlw (vector signed int, vector unsigned int);
12659 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
12660
12661 vector signed short vec_vrlh (vector signed short,
12662 vector unsigned short);
12663 vector unsigned short vec_vrlh (vector unsigned short,
12664 vector unsigned short);
12665
12666 vector signed char vec_vrlb (vector signed char, vector unsigned char);
12667 vector unsigned char vec_vrlb (vector unsigned char,
12668 vector unsigned char);
12669
12670 vector float vec_round (vector float);
12671
12672 vector float vec_recip (vector float, vector float);
12673
12674 vector float vec_rsqrt (vector float);
12675
12676 vector float vec_rsqrte (vector float);
12677
12678 vector float vec_sel (vector float, vector float, vector bool int);
12679 vector float vec_sel (vector float, vector float, vector unsigned int);
12680 vector signed int vec_sel (vector signed int,
12681 vector signed int,
12682 vector bool int);
12683 vector signed int vec_sel (vector signed int,
12684 vector signed int,
12685 vector unsigned int);
12686 vector unsigned int vec_sel (vector unsigned int,
12687 vector unsigned int,
12688 vector bool int);
12689 vector unsigned int vec_sel (vector unsigned int,
12690 vector unsigned int,
12691 vector unsigned int);
12692 vector bool int vec_sel (vector bool int,
12693 vector bool int,
12694 vector bool int);
12695 vector bool int vec_sel (vector bool int,
12696 vector bool int,
12697 vector unsigned int);
12698 vector signed short vec_sel (vector signed short,
12699 vector signed short,
12700 vector bool short);
12701 vector signed short vec_sel (vector signed short,
12702 vector signed short,
12703 vector unsigned short);
12704 vector unsigned short vec_sel (vector unsigned short,
12705 vector unsigned short,
12706 vector bool short);
12707 vector unsigned short vec_sel (vector unsigned short,
12708 vector unsigned short,
12709 vector unsigned short);
12710 vector bool short vec_sel (vector bool short,
12711 vector bool short,
12712 vector bool short);
12713 vector bool short vec_sel (vector bool short,
12714 vector bool short,
12715 vector unsigned short);
12716 vector signed char vec_sel (vector signed char,
12717 vector signed char,
12718 vector bool char);
12719 vector signed char vec_sel (vector signed char,
12720 vector signed char,
12721 vector unsigned char);
12722 vector unsigned char vec_sel (vector unsigned char,
12723 vector unsigned char,
12724 vector bool char);
12725 vector unsigned char vec_sel (vector unsigned char,
12726 vector unsigned char,
12727 vector unsigned char);
12728 vector bool char vec_sel (vector bool char,
12729 vector bool char,
12730 vector bool char);
12731 vector bool char vec_sel (vector bool char,
12732 vector bool char,
12733 vector unsigned char);
12734
12735 vector signed char vec_sl (vector signed char,
12736 vector unsigned char);
12737 vector unsigned char vec_sl (vector unsigned char,
12738 vector unsigned char);
12739 vector signed short vec_sl (vector signed short, vector unsigned short);
12740 vector unsigned short vec_sl (vector unsigned short,
12741 vector unsigned short);
12742 vector signed int vec_sl (vector signed int, vector unsigned int);
12743 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
12744
12745 vector signed int vec_vslw (vector signed int, vector unsigned int);
12746 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
12747
12748 vector signed short vec_vslh (vector signed short,
12749 vector unsigned short);
12750 vector unsigned short vec_vslh (vector unsigned short,
12751 vector unsigned short);
12752
12753 vector signed char vec_vslb (vector signed char, vector unsigned char);
12754 vector unsigned char vec_vslb (vector unsigned char,
12755 vector unsigned char);
12756
12757 vector float vec_sld (vector float, vector float, const int);
12758 vector signed int vec_sld (vector signed int,
12759 vector signed int,
12760 const int);
12761 vector unsigned int vec_sld (vector unsigned int,
12762 vector unsigned int,
12763 const int);
12764 vector bool int vec_sld (vector bool int,
12765 vector bool int,
12766 const int);
12767 vector signed short vec_sld (vector signed short,
12768 vector signed short,
12769 const int);
12770 vector unsigned short vec_sld (vector unsigned short,
12771 vector unsigned short,
12772 const int);
12773 vector bool short vec_sld (vector bool short,
12774 vector bool short,
12775 const int);
12776 vector pixel vec_sld (vector pixel,
12777 vector pixel,
12778 const int);
12779 vector signed char vec_sld (vector signed char,
12780 vector signed char,
12781 const int);
12782 vector unsigned char vec_sld (vector unsigned char,
12783 vector unsigned char,
12784 const int);
12785 vector bool char vec_sld (vector bool char,
12786 vector bool char,
12787 const int);
12788
12789 vector signed int vec_sll (vector signed int,
12790 vector unsigned int);
12791 vector signed int vec_sll (vector signed int,
12792 vector unsigned short);
12793 vector signed int vec_sll (vector signed int,
12794 vector unsigned char);
12795 vector unsigned int vec_sll (vector unsigned int,
12796 vector unsigned int);
12797 vector unsigned int vec_sll (vector unsigned int,
12798 vector unsigned short);
12799 vector unsigned int vec_sll (vector unsigned int,
12800 vector unsigned char);
12801 vector bool int vec_sll (vector bool int,
12802 vector unsigned int);
12803 vector bool int vec_sll (vector bool int,
12804 vector unsigned short);
12805 vector bool int vec_sll (vector bool int,
12806 vector unsigned char);
12807 vector signed short vec_sll (vector signed short,
12808 vector unsigned int);
12809 vector signed short vec_sll (vector signed short,
12810 vector unsigned short);
12811 vector signed short vec_sll (vector signed short,
12812 vector unsigned char);
12813 vector unsigned short vec_sll (vector unsigned short,
12814 vector unsigned int);
12815 vector unsigned short vec_sll (vector unsigned short,
12816 vector unsigned short);
12817 vector unsigned short vec_sll (vector unsigned short,
12818 vector unsigned char);
12819 vector bool short vec_sll (vector bool short, vector unsigned int);
12820 vector bool short vec_sll (vector bool short, vector unsigned short);
12821 vector bool short vec_sll (vector bool short, vector unsigned char);
12822 vector pixel vec_sll (vector pixel, vector unsigned int);
12823 vector pixel vec_sll (vector pixel, vector unsigned short);
12824 vector pixel vec_sll (vector pixel, vector unsigned char);
12825 vector signed char vec_sll (vector signed char, vector unsigned int);
12826 vector signed char vec_sll (vector signed char, vector unsigned short);
12827 vector signed char vec_sll (vector signed char, vector unsigned char);
12828 vector unsigned char vec_sll (vector unsigned char,
12829 vector unsigned int);
12830 vector unsigned char vec_sll (vector unsigned char,
12831 vector unsigned short);
12832 vector unsigned char vec_sll (vector unsigned char,
12833 vector unsigned char);
12834 vector bool char vec_sll (vector bool char, vector unsigned int);
12835 vector bool char vec_sll (vector bool char, vector unsigned short);
12836 vector bool char vec_sll (vector bool char, vector unsigned char);
12837
12838 vector float vec_slo (vector float, vector signed char);
12839 vector float vec_slo (vector float, vector unsigned char);
12840 vector signed int vec_slo (vector signed int, vector signed char);
12841 vector signed int vec_slo (vector signed int, vector unsigned char);
12842 vector unsigned int vec_slo (vector unsigned int, vector signed char);
12843 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
12844 vector signed short vec_slo (vector signed short, vector signed char);
12845 vector signed short vec_slo (vector signed short, vector unsigned char);
12846 vector unsigned short vec_slo (vector unsigned short,
12847 vector signed char);
12848 vector unsigned short vec_slo (vector unsigned short,
12849 vector unsigned char);
12850 vector pixel vec_slo (vector pixel, vector signed char);
12851 vector pixel vec_slo (vector pixel, vector unsigned char);
12852 vector signed char vec_slo (vector signed char, vector signed char);
12853 vector signed char vec_slo (vector signed char, vector unsigned char);
12854 vector unsigned char vec_slo (vector unsigned char, vector signed char);
12855 vector unsigned char vec_slo (vector unsigned char,
12856 vector unsigned char);
12857
12858 vector signed char vec_splat (vector signed char, const int);
12859 vector unsigned char vec_splat (vector unsigned char, const int);
12860 vector bool char vec_splat (vector bool char, const int);
12861 vector signed short vec_splat (vector signed short, const int);
12862 vector unsigned short vec_splat (vector unsigned short, const int);
12863 vector bool short vec_splat (vector bool short, const int);
12864 vector pixel vec_splat (vector pixel, const int);
12865 vector float vec_splat (vector float, const int);
12866 vector signed int vec_splat (vector signed int, const int);
12867 vector unsigned int vec_splat (vector unsigned int, const int);
12868 vector bool int vec_splat (vector bool int, const int);
12869
12870 vector float vec_vspltw (vector float, const int);
12871 vector signed int vec_vspltw (vector signed int, const int);
12872 vector unsigned int vec_vspltw (vector unsigned int, const int);
12873 vector bool int vec_vspltw (vector bool int, const int);
12874
12875 vector bool short vec_vsplth (vector bool short, const int);
12876 vector signed short vec_vsplth (vector signed short, const int);
12877 vector unsigned short vec_vsplth (vector unsigned short, const int);
12878 vector pixel vec_vsplth (vector pixel, const int);
12879
12880 vector signed char vec_vspltb (vector signed char, const int);
12881 vector unsigned char vec_vspltb (vector unsigned char, const int);
12882 vector bool char vec_vspltb (vector bool char, const int);
12883
12884 vector signed char vec_splat_s8 (const int);
12885
12886 vector signed short vec_splat_s16 (const int);
12887
12888 vector signed int vec_splat_s32 (const int);
12889
12890 vector unsigned char vec_splat_u8 (const int);
12891
12892 vector unsigned short vec_splat_u16 (const int);
12893
12894 vector unsigned int vec_splat_u32 (const int);
12895
12896 vector signed char vec_sr (vector signed char, vector unsigned char);
12897 vector unsigned char vec_sr (vector unsigned char,
12898 vector unsigned char);
12899 vector signed short vec_sr (vector signed short,
12900 vector unsigned short);
12901 vector unsigned short vec_sr (vector unsigned short,
12902 vector unsigned short);
12903 vector signed int vec_sr (vector signed int, vector unsigned int);
12904 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
12905
12906 vector signed int vec_vsrw (vector signed int, vector unsigned int);
12907 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
12908
12909 vector signed short vec_vsrh (vector signed short,
12910 vector unsigned short);
12911 vector unsigned short vec_vsrh (vector unsigned short,
12912 vector unsigned short);
12913
12914 vector signed char vec_vsrb (vector signed char, vector unsigned char);
12915 vector unsigned char vec_vsrb (vector unsigned char,
12916 vector unsigned char);
12917
12918 vector signed char vec_sra (vector signed char, vector unsigned char);
12919 vector unsigned char vec_sra (vector unsigned char,
12920 vector unsigned char);
12921 vector signed short vec_sra (vector signed short,
12922 vector unsigned short);
12923 vector unsigned short vec_sra (vector unsigned short,
12924 vector unsigned short);
12925 vector signed int vec_sra (vector signed int, vector unsigned int);
12926 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
12927
12928 vector signed int vec_vsraw (vector signed int, vector unsigned int);
12929 vector unsigned int vec_vsraw (vector unsigned int,
12930 vector unsigned int);
12931
12932 vector signed short vec_vsrah (vector signed short,
12933 vector unsigned short);
12934 vector unsigned short vec_vsrah (vector unsigned short,
12935 vector unsigned short);
12936
12937 vector signed char vec_vsrab (vector signed char, vector unsigned char);
12938 vector unsigned char vec_vsrab (vector unsigned char,
12939 vector unsigned char);
12940
12941 vector signed int vec_srl (vector signed int, vector unsigned int);
12942 vector signed int vec_srl (vector signed int, vector unsigned short);
12943 vector signed int vec_srl (vector signed int, vector unsigned char);
12944 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
12945 vector unsigned int vec_srl (vector unsigned int,
12946 vector unsigned short);
12947 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
12948 vector bool int vec_srl (vector bool int, vector unsigned int);
12949 vector bool int vec_srl (vector bool int, vector unsigned short);
12950 vector bool int vec_srl (vector bool int, vector unsigned char);
12951 vector signed short vec_srl (vector signed short, vector unsigned int);
12952 vector signed short vec_srl (vector signed short,
12953 vector unsigned short);
12954 vector signed short vec_srl (vector signed short, vector unsigned char);
12955 vector unsigned short vec_srl (vector unsigned short,
12956 vector unsigned int);
12957 vector unsigned short vec_srl (vector unsigned short,
12958 vector unsigned short);
12959 vector unsigned short vec_srl (vector unsigned short,
12960 vector unsigned char);
12961 vector bool short vec_srl (vector bool short, vector unsigned int);
12962 vector bool short vec_srl (vector bool short, vector unsigned short);
12963 vector bool short vec_srl (vector bool short, vector unsigned char);
12964 vector pixel vec_srl (vector pixel, vector unsigned int);
12965 vector pixel vec_srl (vector pixel, vector unsigned short);
12966 vector pixel vec_srl (vector pixel, vector unsigned char);
12967 vector signed char vec_srl (vector signed char, vector unsigned int);
12968 vector signed char vec_srl (vector signed char, vector unsigned short);
12969 vector signed char vec_srl (vector signed char, vector unsigned char);
12970 vector unsigned char vec_srl (vector unsigned char,
12971 vector unsigned int);
12972 vector unsigned char vec_srl (vector unsigned char,
12973 vector unsigned short);
12974 vector unsigned char vec_srl (vector unsigned char,
12975 vector unsigned char);
12976 vector bool char vec_srl (vector bool char, vector unsigned int);
12977 vector bool char vec_srl (vector bool char, vector unsigned short);
12978 vector bool char vec_srl (vector bool char, vector unsigned char);
12979
12980 vector float vec_sro (vector float, vector signed char);
12981 vector float vec_sro (vector float, vector unsigned char);
12982 vector signed int vec_sro (vector signed int, vector signed char);
12983 vector signed int vec_sro (vector signed int, vector unsigned char);
12984 vector unsigned int vec_sro (vector unsigned int, vector signed char);
12985 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
12986 vector signed short vec_sro (vector signed short, vector signed char);
12987 vector signed short vec_sro (vector signed short, vector unsigned char);
12988 vector unsigned short vec_sro (vector unsigned short,
12989 vector signed char);
12990 vector unsigned short vec_sro (vector unsigned short,
12991 vector unsigned char);
12992 vector pixel vec_sro (vector pixel, vector signed char);
12993 vector pixel vec_sro (vector pixel, vector unsigned char);
12994 vector signed char vec_sro (vector signed char, vector signed char);
12995 vector signed char vec_sro (vector signed char, vector unsigned char);
12996 vector unsigned char vec_sro (vector unsigned char, vector signed char);
12997 vector unsigned char vec_sro (vector unsigned char,
12998 vector unsigned char);
12999
13000 void vec_st (vector float, int, vector float *);
13001 void vec_st (vector float, int, float *);
13002 void vec_st (vector signed int, int, vector signed int *);
13003 void vec_st (vector signed int, int, int *);
13004 void vec_st (vector unsigned int, int, vector unsigned int *);
13005 void vec_st (vector unsigned int, int, unsigned int *);
13006 void vec_st (vector bool int, int, vector bool int *);
13007 void vec_st (vector bool int, int, unsigned int *);
13008 void vec_st (vector bool int, int, int *);
13009 void vec_st (vector signed short, int, vector signed short *);
13010 void vec_st (vector signed short, int, short *);
13011 void vec_st (vector unsigned short, int, vector unsigned short *);
13012 void vec_st (vector unsigned short, int, unsigned short *);
13013 void vec_st (vector bool short, int, vector bool short *);
13014 void vec_st (vector bool short, int, unsigned short *);
13015 void vec_st (vector pixel, int, vector pixel *);
13016 void vec_st (vector pixel, int, unsigned short *);
13017 void vec_st (vector pixel, int, short *);
13018 void vec_st (vector bool short, int, short *);
13019 void vec_st (vector signed char, int, vector signed char *);
13020 void vec_st (vector signed char, int, signed char *);
13021 void vec_st (vector unsigned char, int, vector unsigned char *);
13022 void vec_st (vector unsigned char, int, unsigned char *);
13023 void vec_st (vector bool char, int, vector bool char *);
13024 void vec_st (vector bool char, int, unsigned char *);
13025 void vec_st (vector bool char, int, signed char *);
13026
13027 void vec_ste (vector signed char, int, signed char *);
13028 void vec_ste (vector unsigned char, int, unsigned char *);
13029 void vec_ste (vector bool char, int, signed char *);
13030 void vec_ste (vector bool char, int, unsigned char *);
13031 void vec_ste (vector signed short, int, short *);
13032 void vec_ste (vector unsigned short, int, unsigned short *);
13033 void vec_ste (vector bool short, int, short *);
13034 void vec_ste (vector bool short, int, unsigned short *);
13035 void vec_ste (vector pixel, int, short *);
13036 void vec_ste (vector pixel, int, unsigned short *);
13037 void vec_ste (vector float, int, float *);
13038 void vec_ste (vector signed int, int, int *);
13039 void vec_ste (vector unsigned int, int, unsigned int *);
13040 void vec_ste (vector bool int, int, int *);
13041 void vec_ste (vector bool int, int, unsigned int *);
13042
13043 void vec_stvewx (vector float, int, float *);
13044 void vec_stvewx (vector signed int, int, int *);
13045 void vec_stvewx (vector unsigned int, int, unsigned int *);
13046 void vec_stvewx (vector bool int, int, int *);
13047 void vec_stvewx (vector bool int, int, unsigned int *);
13048
13049 void vec_stvehx (vector signed short, int, short *);
13050 void vec_stvehx (vector unsigned short, int, unsigned short *);
13051 void vec_stvehx (vector bool short, int, short *);
13052 void vec_stvehx (vector bool short, int, unsigned short *);
13053 void vec_stvehx (vector pixel, int, short *);
13054 void vec_stvehx (vector pixel, int, unsigned short *);
13055
13056 void vec_stvebx (vector signed char, int, signed char *);
13057 void vec_stvebx (vector unsigned char, int, unsigned char *);
13058 void vec_stvebx (vector bool char, int, signed char *);
13059 void vec_stvebx (vector bool char, int, unsigned char *);
13060
13061 void vec_stl (vector float, int, vector float *);
13062 void vec_stl (vector float, int, float *);
13063 void vec_stl (vector signed int, int, vector signed int *);
13064 void vec_stl (vector signed int, int, int *);
13065 void vec_stl (vector unsigned int, int, vector unsigned int *);
13066 void vec_stl (vector unsigned int, int, unsigned int *);
13067 void vec_stl (vector bool int, int, vector bool int *);
13068 void vec_stl (vector bool int, int, unsigned int *);
13069 void vec_stl (vector bool int, int, int *);
13070 void vec_stl (vector signed short, int, vector signed short *);
13071 void vec_stl (vector signed short, int, short *);
13072 void vec_stl (vector unsigned short, int, vector unsigned short *);
13073 void vec_stl (vector unsigned short, int, unsigned short *);
13074 void vec_stl (vector bool short, int, vector bool short *);
13075 void vec_stl (vector bool short, int, unsigned short *);
13076 void vec_stl (vector bool short, int, short *);
13077 void vec_stl (vector pixel, int, vector pixel *);
13078 void vec_stl (vector pixel, int, unsigned short *);
13079 void vec_stl (vector pixel, int, short *);
13080 void vec_stl (vector signed char, int, vector signed char *);
13081 void vec_stl (vector signed char, int, signed char *);
13082 void vec_stl (vector unsigned char, int, vector unsigned char *);
13083 void vec_stl (vector unsigned char, int, unsigned char *);
13084 void vec_stl (vector bool char, int, vector bool char *);
13085 void vec_stl (vector bool char, int, unsigned char *);
13086 void vec_stl (vector bool char, int, signed char *);
13087
13088 vector signed char vec_sub (vector bool char, vector signed char);
13089 vector signed char vec_sub (vector signed char, vector bool char);
13090 vector signed char vec_sub (vector signed char, vector signed char);
13091 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13092 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13093 vector unsigned char vec_sub (vector unsigned char,
13094 vector unsigned char);
13095 vector signed short vec_sub (vector bool short, vector signed short);
13096 vector signed short vec_sub (vector signed short, vector bool short);
13097 vector signed short vec_sub (vector signed short, vector signed short);
13098 vector unsigned short vec_sub (vector bool short,
13099 vector unsigned short);
13100 vector unsigned short vec_sub (vector unsigned short,
13101 vector bool short);
13102 vector unsigned short vec_sub (vector unsigned short,
13103 vector unsigned short);
13104 vector signed int vec_sub (vector bool int, vector signed int);
13105 vector signed int vec_sub (vector signed int, vector bool int);
13106 vector signed int vec_sub (vector signed int, vector signed int);
13107 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13108 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13109 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13110 vector float vec_sub (vector float, vector float);
13111
13112 vector float vec_vsubfp (vector float, vector float);
13113
13114 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13115 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13116 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13117 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13118 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13119 vector unsigned int vec_vsubuwm (vector unsigned int,
13120 vector unsigned int);
13121
13122 vector signed short vec_vsubuhm (vector bool short,
13123 vector signed short);
13124 vector signed short vec_vsubuhm (vector signed short,
13125 vector bool short);
13126 vector signed short vec_vsubuhm (vector signed short,
13127 vector signed short);
13128 vector unsigned short vec_vsubuhm (vector bool short,
13129 vector unsigned short);
13130 vector unsigned short vec_vsubuhm (vector unsigned short,
13131 vector bool short);
13132 vector unsigned short vec_vsubuhm (vector unsigned short,
13133 vector unsigned short);
13134
13135 vector signed char vec_vsububm (vector bool char, vector signed char);
13136 vector signed char vec_vsububm (vector signed char, vector bool char);
13137 vector signed char vec_vsububm (vector signed char, vector signed char);
13138 vector unsigned char vec_vsububm (vector bool char,
13139 vector unsigned char);
13140 vector unsigned char vec_vsububm (vector unsigned char,
13141 vector bool char);
13142 vector unsigned char vec_vsububm (vector unsigned char,
13143 vector unsigned char);
13144
13145 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13146
13147 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13148 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13149 vector unsigned char vec_subs (vector unsigned char,
13150 vector unsigned char);
13151 vector signed char vec_subs (vector bool char, vector signed char);
13152 vector signed char vec_subs (vector signed char, vector bool char);
13153 vector signed char vec_subs (vector signed char, vector signed char);
13154 vector unsigned short vec_subs (vector bool short,
13155 vector unsigned short);
13156 vector unsigned short vec_subs (vector unsigned short,
13157 vector bool short);
13158 vector unsigned short vec_subs (vector unsigned short,
13159 vector unsigned short);
13160 vector signed short vec_subs (vector bool short, vector signed short);
13161 vector signed short vec_subs (vector signed short, vector bool short);
13162 vector signed short vec_subs (vector signed short, vector signed short);
13163 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13164 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13165 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13166 vector signed int vec_subs (vector bool int, vector signed int);
13167 vector signed int vec_subs (vector signed int, vector bool int);
13168 vector signed int vec_subs (vector signed int, vector signed int);
13169
13170 vector signed int vec_vsubsws (vector bool int, vector signed int);
13171 vector signed int vec_vsubsws (vector signed int, vector bool int);
13172 vector signed int vec_vsubsws (vector signed int, vector signed int);
13173
13174 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13175 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13176 vector unsigned int vec_vsubuws (vector unsigned int,
13177 vector unsigned int);
13178
13179 vector signed short vec_vsubshs (vector bool short,
13180 vector signed short);
13181 vector signed short vec_vsubshs (vector signed short,
13182 vector bool short);
13183 vector signed short vec_vsubshs (vector signed short,
13184 vector signed short);
13185
13186 vector unsigned short vec_vsubuhs (vector bool short,
13187 vector unsigned short);
13188 vector unsigned short vec_vsubuhs (vector unsigned short,
13189 vector bool short);
13190 vector unsigned short vec_vsubuhs (vector unsigned short,
13191 vector unsigned short);
13192
13193 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13194 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13195 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13196
13197 vector unsigned char vec_vsububs (vector bool char,
13198 vector unsigned char);
13199 vector unsigned char vec_vsububs (vector unsigned char,
13200 vector bool char);
13201 vector unsigned char vec_vsububs (vector unsigned char,
13202 vector unsigned char);
13203
13204 vector unsigned int vec_sum4s (vector unsigned char,
13205 vector unsigned int);
13206 vector signed int vec_sum4s (vector signed char, vector signed int);
13207 vector signed int vec_sum4s (vector signed short, vector signed int);
13208
13209 vector signed int vec_vsum4shs (vector signed short, vector signed int);
13210
13211 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
13212
13213 vector unsigned int vec_vsum4ubs (vector unsigned char,
13214 vector unsigned int);
13215
13216 vector signed int vec_sum2s (vector signed int, vector signed int);
13217
13218 vector signed int vec_sums (vector signed int, vector signed int);
13219
13220 vector float vec_trunc (vector float);
13221
13222 vector signed short vec_unpackh (vector signed char);
13223 vector bool short vec_unpackh (vector bool char);
13224 vector signed int vec_unpackh (vector signed short);
13225 vector bool int vec_unpackh (vector bool short);
13226 vector unsigned int vec_unpackh (vector pixel);
13227
13228 vector bool int vec_vupkhsh (vector bool short);
13229 vector signed int vec_vupkhsh (vector signed short);
13230
13231 vector unsigned int vec_vupkhpx (vector pixel);
13232
13233 vector bool short vec_vupkhsb (vector bool char);
13234 vector signed short vec_vupkhsb (vector signed char);
13235
13236 vector signed short vec_unpackl (vector signed char);
13237 vector bool short vec_unpackl (vector bool char);
13238 vector unsigned int vec_unpackl (vector pixel);
13239 vector signed int vec_unpackl (vector signed short);
13240 vector bool int vec_unpackl (vector bool short);
13241
13242 vector unsigned int vec_vupklpx (vector pixel);
13243
13244 vector bool int vec_vupklsh (vector bool short);
13245 vector signed int vec_vupklsh (vector signed short);
13246
13247 vector bool short vec_vupklsb (vector bool char);
13248 vector signed short vec_vupklsb (vector signed char);
13249
13250 vector float vec_xor (vector float, vector float);
13251 vector float vec_xor (vector float, vector bool int);
13252 vector float vec_xor (vector bool int, vector float);
13253 vector bool int vec_xor (vector bool int, vector bool int);
13254 vector signed int vec_xor (vector bool int, vector signed int);
13255 vector signed int vec_xor (vector signed int, vector bool int);
13256 vector signed int vec_xor (vector signed int, vector signed int);
13257 vector unsigned int vec_xor (vector bool int, vector unsigned int);
13258 vector unsigned int vec_xor (vector unsigned int, vector bool int);
13259 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
13260 vector bool short vec_xor (vector bool short, vector bool short);
13261 vector signed short vec_xor (vector bool short, vector signed short);
13262 vector signed short vec_xor (vector signed short, vector bool short);
13263 vector signed short vec_xor (vector signed short, vector signed short);
13264 vector unsigned short vec_xor (vector bool short,
13265 vector unsigned short);
13266 vector unsigned short vec_xor (vector unsigned short,
13267 vector bool short);
13268 vector unsigned short vec_xor (vector unsigned short,
13269 vector unsigned short);
13270 vector signed char vec_xor (vector bool char, vector signed char);
13271 vector bool char vec_xor (vector bool char, vector bool char);
13272 vector signed char vec_xor (vector signed char, vector bool char);
13273 vector signed char vec_xor (vector signed char, vector signed char);
13274 vector unsigned char vec_xor (vector bool char, vector unsigned char);
13275 vector unsigned char vec_xor (vector unsigned char, vector bool char);
13276 vector unsigned char vec_xor (vector unsigned char,
13277 vector unsigned char);
13278
13279 int vec_all_eq (vector signed char, vector bool char);
13280 int vec_all_eq (vector signed char, vector signed char);
13281 int vec_all_eq (vector unsigned char, vector bool char);
13282 int vec_all_eq (vector unsigned char, vector unsigned char);
13283 int vec_all_eq (vector bool char, vector bool char);
13284 int vec_all_eq (vector bool char, vector unsigned char);
13285 int vec_all_eq (vector bool char, vector signed char);
13286 int vec_all_eq (vector signed short, vector bool short);
13287 int vec_all_eq (vector signed short, vector signed short);
13288 int vec_all_eq (vector unsigned short, vector bool short);
13289 int vec_all_eq (vector unsigned short, vector unsigned short);
13290 int vec_all_eq (vector bool short, vector bool short);
13291 int vec_all_eq (vector bool short, vector unsigned short);
13292 int vec_all_eq (vector bool short, vector signed short);
13293 int vec_all_eq (vector pixel, vector pixel);
13294 int vec_all_eq (vector signed int, vector bool int);
13295 int vec_all_eq (vector signed int, vector signed int);
13296 int vec_all_eq (vector unsigned int, vector bool int);
13297 int vec_all_eq (vector unsigned int, vector unsigned int);
13298 int vec_all_eq (vector bool int, vector bool int);
13299 int vec_all_eq (vector bool int, vector unsigned int);
13300 int vec_all_eq (vector bool int, vector signed int);
13301 int vec_all_eq (vector float, vector float);
13302
13303 int vec_all_ge (vector bool char, vector unsigned char);
13304 int vec_all_ge (vector unsigned char, vector bool char);
13305 int vec_all_ge (vector unsigned char, vector unsigned char);
13306 int vec_all_ge (vector bool char, vector signed char);
13307 int vec_all_ge (vector signed char, vector bool char);
13308 int vec_all_ge (vector signed char, vector signed char);
13309 int vec_all_ge (vector bool short, vector unsigned short);
13310 int vec_all_ge (vector unsigned short, vector bool short);
13311 int vec_all_ge (vector unsigned short, vector unsigned short);
13312 int vec_all_ge (vector signed short, vector signed short);
13313 int vec_all_ge (vector bool short, vector signed short);
13314 int vec_all_ge (vector signed short, vector bool short);
13315 int vec_all_ge (vector bool int, vector unsigned int);
13316 int vec_all_ge (vector unsigned int, vector bool int);
13317 int vec_all_ge (vector unsigned int, vector unsigned int);
13318 int vec_all_ge (vector bool int, vector signed int);
13319 int vec_all_ge (vector signed int, vector bool int);
13320 int vec_all_ge (vector signed int, vector signed int);
13321 int vec_all_ge (vector float, vector float);
13322
13323 int vec_all_gt (vector bool char, vector unsigned char);
13324 int vec_all_gt (vector unsigned char, vector bool char);
13325 int vec_all_gt (vector unsigned char, vector unsigned char);
13326 int vec_all_gt (vector bool char, vector signed char);
13327 int vec_all_gt (vector signed char, vector bool char);
13328 int vec_all_gt (vector signed char, vector signed char);
13329 int vec_all_gt (vector bool short, vector unsigned short);
13330 int vec_all_gt (vector unsigned short, vector bool short);
13331 int vec_all_gt (vector unsigned short, vector unsigned short);
13332 int vec_all_gt (vector bool short, vector signed short);
13333 int vec_all_gt (vector signed short, vector bool short);
13334 int vec_all_gt (vector signed short, vector signed short);
13335 int vec_all_gt (vector bool int, vector unsigned int);
13336 int vec_all_gt (vector unsigned int, vector bool int);
13337 int vec_all_gt (vector unsigned int, vector unsigned int);
13338 int vec_all_gt (vector bool int, vector signed int);
13339 int vec_all_gt (vector signed int, vector bool int);
13340 int vec_all_gt (vector signed int, vector signed int);
13341 int vec_all_gt (vector float, vector float);
13342
13343 int vec_all_in (vector float, vector float);
13344
13345 int vec_all_le (vector bool char, vector unsigned char);
13346 int vec_all_le (vector unsigned char, vector bool char);
13347 int vec_all_le (vector unsigned char, vector unsigned char);
13348 int vec_all_le (vector bool char, vector signed char);
13349 int vec_all_le (vector signed char, vector bool char);
13350 int vec_all_le (vector signed char, vector signed char);
13351 int vec_all_le (vector bool short, vector unsigned short);
13352 int vec_all_le (vector unsigned short, vector bool short);
13353 int vec_all_le (vector unsigned short, vector unsigned short);
13354 int vec_all_le (vector bool short, vector signed short);
13355 int vec_all_le (vector signed short, vector bool short);
13356 int vec_all_le (vector signed short, vector signed short);
13357 int vec_all_le (vector bool int, vector unsigned int);
13358 int vec_all_le (vector unsigned int, vector bool int);
13359 int vec_all_le (vector unsigned int, vector unsigned int);
13360 int vec_all_le (vector bool int, vector signed int);
13361 int vec_all_le (vector signed int, vector bool int);
13362 int vec_all_le (vector signed int, vector signed int);
13363 int vec_all_le (vector float, vector float);
13364
13365 int vec_all_lt (vector bool char, vector unsigned char);
13366 int vec_all_lt (vector unsigned char, vector bool char);
13367 int vec_all_lt (vector unsigned char, vector unsigned char);
13368 int vec_all_lt (vector bool char, vector signed char);
13369 int vec_all_lt (vector signed char, vector bool char);
13370 int vec_all_lt (vector signed char, vector signed char);
13371 int vec_all_lt (vector bool short, vector unsigned short);
13372 int vec_all_lt (vector unsigned short, vector bool short);
13373 int vec_all_lt (vector unsigned short, vector unsigned short);
13374 int vec_all_lt (vector bool short, vector signed short);
13375 int vec_all_lt (vector signed short, vector bool short);
13376 int vec_all_lt (vector signed short, vector signed short);
13377 int vec_all_lt (vector bool int, vector unsigned int);
13378 int vec_all_lt (vector unsigned int, vector bool int);
13379 int vec_all_lt (vector unsigned int, vector unsigned int);
13380 int vec_all_lt (vector bool int, vector signed int);
13381 int vec_all_lt (vector signed int, vector bool int);
13382 int vec_all_lt (vector signed int, vector signed int);
13383 int vec_all_lt (vector float, vector float);
13384
13385 int vec_all_nan (vector float);
13386
13387 int vec_all_ne (vector signed char, vector bool char);
13388 int vec_all_ne (vector signed char, vector signed char);
13389 int vec_all_ne (vector unsigned char, vector bool char);
13390 int vec_all_ne (vector unsigned char, vector unsigned char);
13391 int vec_all_ne (vector bool char, vector bool char);
13392 int vec_all_ne (vector bool char, vector unsigned char);
13393 int vec_all_ne (vector bool char, vector signed char);
13394 int vec_all_ne (vector signed short, vector bool short);
13395 int vec_all_ne (vector signed short, vector signed short);
13396 int vec_all_ne (vector unsigned short, vector bool short);
13397 int vec_all_ne (vector unsigned short, vector unsigned short);
13398 int vec_all_ne (vector bool short, vector bool short);
13399 int vec_all_ne (vector bool short, vector unsigned short);
13400 int vec_all_ne (vector bool short, vector signed short);
13401 int vec_all_ne (vector pixel, vector pixel);
13402 int vec_all_ne (vector signed int, vector bool int);
13403 int vec_all_ne (vector signed int, vector signed int);
13404 int vec_all_ne (vector unsigned int, vector bool int);
13405 int vec_all_ne (vector unsigned int, vector unsigned int);
13406 int vec_all_ne (vector bool int, vector bool int);
13407 int vec_all_ne (vector bool int, vector unsigned int);
13408 int vec_all_ne (vector bool int, vector signed int);
13409 int vec_all_ne (vector float, vector float);
13410
13411 int vec_all_nge (vector float, vector float);
13412
13413 int vec_all_ngt (vector float, vector float);
13414
13415 int vec_all_nle (vector float, vector float);
13416
13417 int vec_all_nlt (vector float, vector float);
13418
13419 int vec_all_numeric (vector float);
13420
13421 int vec_any_eq (vector signed char, vector bool char);
13422 int vec_any_eq (vector signed char, vector signed char);
13423 int vec_any_eq (vector unsigned char, vector bool char);
13424 int vec_any_eq (vector unsigned char, vector unsigned char);
13425 int vec_any_eq (vector bool char, vector bool char);
13426 int vec_any_eq (vector bool char, vector unsigned char);
13427 int vec_any_eq (vector bool char, vector signed char);
13428 int vec_any_eq (vector signed short, vector bool short);
13429 int vec_any_eq (vector signed short, vector signed short);
13430 int vec_any_eq (vector unsigned short, vector bool short);
13431 int vec_any_eq (vector unsigned short, vector unsigned short);
13432 int vec_any_eq (vector bool short, vector bool short);
13433 int vec_any_eq (vector bool short, vector unsigned short);
13434 int vec_any_eq (vector bool short, vector signed short);
13435 int vec_any_eq (vector pixel, vector pixel);
13436 int vec_any_eq (vector signed int, vector bool int);
13437 int vec_any_eq (vector signed int, vector signed int);
13438 int vec_any_eq (vector unsigned int, vector bool int);
13439 int vec_any_eq (vector unsigned int, vector unsigned int);
13440 int vec_any_eq (vector bool int, vector bool int);
13441 int vec_any_eq (vector bool int, vector unsigned int);
13442 int vec_any_eq (vector bool int, vector signed int);
13443 int vec_any_eq (vector float, vector float);
13444
13445 int vec_any_ge (vector signed char, vector bool char);
13446 int vec_any_ge (vector unsigned char, vector bool char);
13447 int vec_any_ge (vector unsigned char, vector unsigned char);
13448 int vec_any_ge (vector signed char, vector signed char);
13449 int vec_any_ge (vector bool char, vector unsigned char);
13450 int vec_any_ge (vector bool char, vector signed char);
13451 int vec_any_ge (vector unsigned short, vector bool short);
13452 int vec_any_ge (vector unsigned short, vector unsigned short);
13453 int vec_any_ge (vector signed short, vector signed short);
13454 int vec_any_ge (vector signed short, vector bool short);
13455 int vec_any_ge (vector bool short, vector unsigned short);
13456 int vec_any_ge (vector bool short, vector signed short);
13457 int vec_any_ge (vector signed int, vector bool int);
13458 int vec_any_ge (vector unsigned int, vector bool int);
13459 int vec_any_ge (vector unsigned int, vector unsigned int);
13460 int vec_any_ge (vector signed int, vector signed int);
13461 int vec_any_ge (vector bool int, vector unsigned int);
13462 int vec_any_ge (vector bool int, vector signed int);
13463 int vec_any_ge (vector float, vector float);
13464
13465 int vec_any_gt (vector bool char, vector unsigned char);
13466 int vec_any_gt (vector unsigned char, vector bool char);
13467 int vec_any_gt (vector unsigned char, vector unsigned char);
13468 int vec_any_gt (vector bool char, vector signed char);
13469 int vec_any_gt (vector signed char, vector bool char);
13470 int vec_any_gt (vector signed char, vector signed char);
13471 int vec_any_gt (vector bool short, vector unsigned short);
13472 int vec_any_gt (vector unsigned short, vector bool short);
13473 int vec_any_gt (vector unsigned short, vector unsigned short);
13474 int vec_any_gt (vector bool short, vector signed short);
13475 int vec_any_gt (vector signed short, vector bool short);
13476 int vec_any_gt (vector signed short, vector signed short);
13477 int vec_any_gt (vector bool int, vector unsigned int);
13478 int vec_any_gt (vector unsigned int, vector bool int);
13479 int vec_any_gt (vector unsigned int, vector unsigned int);
13480 int vec_any_gt (vector bool int, vector signed int);
13481 int vec_any_gt (vector signed int, vector bool int);
13482 int vec_any_gt (vector signed int, vector signed int);
13483 int vec_any_gt (vector float, vector float);
13484
13485 int vec_any_le (vector bool char, vector unsigned char);
13486 int vec_any_le (vector unsigned char, vector bool char);
13487 int vec_any_le (vector unsigned char, vector unsigned char);
13488 int vec_any_le (vector bool char, vector signed char);
13489 int vec_any_le (vector signed char, vector bool char);
13490 int vec_any_le (vector signed char, vector signed char);
13491 int vec_any_le (vector bool short, vector unsigned short);
13492 int vec_any_le (vector unsigned short, vector bool short);
13493 int vec_any_le (vector unsigned short, vector unsigned short);
13494 int vec_any_le (vector bool short, vector signed short);
13495 int vec_any_le (vector signed short, vector bool short);
13496 int vec_any_le (vector signed short, vector signed short);
13497 int vec_any_le (vector bool int, vector unsigned int);
13498 int vec_any_le (vector unsigned int, vector bool int);
13499 int vec_any_le (vector unsigned int, vector unsigned int);
13500 int vec_any_le (vector bool int, vector signed int);
13501 int vec_any_le (vector signed int, vector bool int);
13502 int vec_any_le (vector signed int, vector signed int);
13503 int vec_any_le (vector float, vector float);
13504
13505 int vec_any_lt (vector bool char, vector unsigned char);
13506 int vec_any_lt (vector unsigned char, vector bool char);
13507 int vec_any_lt (vector unsigned char, vector unsigned char);
13508 int vec_any_lt (vector bool char, vector signed char);
13509 int vec_any_lt (vector signed char, vector bool char);
13510 int vec_any_lt (vector signed char, vector signed char);
13511 int vec_any_lt (vector bool short, vector unsigned short);
13512 int vec_any_lt (vector unsigned short, vector bool short);
13513 int vec_any_lt (vector unsigned short, vector unsigned short);
13514 int vec_any_lt (vector bool short, vector signed short);
13515 int vec_any_lt (vector signed short, vector bool short);
13516 int vec_any_lt (vector signed short, vector signed short);
13517 int vec_any_lt (vector bool int, vector unsigned int);
13518 int vec_any_lt (vector unsigned int, vector bool int);
13519 int vec_any_lt (vector unsigned int, vector unsigned int);
13520 int vec_any_lt (vector bool int, vector signed int);
13521 int vec_any_lt (vector signed int, vector bool int);
13522 int vec_any_lt (vector signed int, vector signed int);
13523 int vec_any_lt (vector float, vector float);
13524
13525 int vec_any_nan (vector float);
13526
13527 int vec_any_ne (vector signed char, vector bool char);
13528 int vec_any_ne (vector signed char, vector signed char);
13529 int vec_any_ne (vector unsigned char, vector bool char);
13530 int vec_any_ne (vector unsigned char, vector unsigned char);
13531 int vec_any_ne (vector bool char, vector bool char);
13532 int vec_any_ne (vector bool char, vector unsigned char);
13533 int vec_any_ne (vector bool char, vector signed char);
13534 int vec_any_ne (vector signed short, vector bool short);
13535 int vec_any_ne (vector signed short, vector signed short);
13536 int vec_any_ne (vector unsigned short, vector bool short);
13537 int vec_any_ne (vector unsigned short, vector unsigned short);
13538 int vec_any_ne (vector bool short, vector bool short);
13539 int vec_any_ne (vector bool short, vector unsigned short);
13540 int vec_any_ne (vector bool short, vector signed short);
13541 int vec_any_ne (vector pixel, vector pixel);
13542 int vec_any_ne (vector signed int, vector bool int);
13543 int vec_any_ne (vector signed int, vector signed int);
13544 int vec_any_ne (vector unsigned int, vector bool int);
13545 int vec_any_ne (vector unsigned int, vector unsigned int);
13546 int vec_any_ne (vector bool int, vector bool int);
13547 int vec_any_ne (vector bool int, vector unsigned int);
13548 int vec_any_ne (vector bool int, vector signed int);
13549 int vec_any_ne (vector float, vector float);
13550
13551 int vec_any_nge (vector float, vector float);
13552
13553 int vec_any_ngt (vector float, vector float);
13554
13555 int vec_any_nle (vector float, vector float);
13556
13557 int vec_any_nlt (vector float, vector float);
13558
13559 int vec_any_numeric (vector float);
13560
13561 int vec_any_out (vector float, vector float);
13562 @end smallexample
13563
13564 If the vector/scalar (VSX) instruction set is available, the following
13565 additional functions are available:
13566
13567 @smallexample
13568 vector double vec_abs (vector double);
13569 vector double vec_add (vector double, vector double);
13570 vector double vec_and (vector double, vector double);
13571 vector double vec_and (vector double, vector bool long);
13572 vector double vec_and (vector bool long, vector double);
13573 vector double vec_andc (vector double, vector double);
13574 vector double vec_andc (vector double, vector bool long);
13575 vector double vec_andc (vector bool long, vector double);
13576 vector double vec_ceil (vector double);
13577 vector bool long vec_cmpeq (vector double, vector double);
13578 vector bool long vec_cmpge (vector double, vector double);
13579 vector bool long vec_cmpgt (vector double, vector double);
13580 vector bool long vec_cmple (vector double, vector double);
13581 vector bool long vec_cmplt (vector double, vector double);
13582 vector float vec_div (vector float, vector float);
13583 vector double vec_div (vector double, vector double);
13584 vector double vec_floor (vector double);
13585 vector double vec_ld (int, const vector double *);
13586 vector double vec_ld (int, const double *);
13587 vector double vec_ldl (int, const vector double *);
13588 vector double vec_ldl (int, const double *);
13589 vector unsigned char vec_lvsl (int, const volatile double *);
13590 vector unsigned char vec_lvsr (int, const volatile double *);
13591 vector double vec_madd (vector double, vector double, vector double);
13592 vector double vec_max (vector double, vector double);
13593 vector double vec_min (vector double, vector double);
13594 vector float vec_msub (vector float, vector float, vector float);
13595 vector double vec_msub (vector double, vector double, vector double);
13596 vector float vec_mul (vector float, vector float);
13597 vector double vec_mul (vector double, vector double);
13598 vector float vec_nearbyint (vector float);
13599 vector double vec_nearbyint (vector double);
13600 vector float vec_nmadd (vector float, vector float, vector float);
13601 vector double vec_nmadd (vector double, vector double, vector double);
13602 vector double vec_nmsub (vector double, vector double, vector double);
13603 vector double vec_nor (vector double, vector double);
13604 vector double vec_or (vector double, vector double);
13605 vector double vec_or (vector double, vector bool long);
13606 vector double vec_or (vector bool long, vector double);
13607 vector double vec_perm (vector double,
13608 vector double,
13609 vector unsigned char);
13610 vector double vec_rint (vector double);
13611 vector double vec_recip (vector double, vector double);
13612 vector double vec_rsqrt (vector double);
13613 vector double vec_rsqrte (vector double);
13614 vector double vec_sel (vector double, vector double, vector bool long);
13615 vector double vec_sel (vector double, vector double, vector unsigned long);
13616 vector double vec_sub (vector double, vector double);
13617 vector float vec_sqrt (vector float);
13618 vector double vec_sqrt (vector double);
13619 void vec_st (vector double, int, vector double *);
13620 void vec_st (vector double, int, double *);
13621 vector double vec_trunc (vector double);
13622 vector double vec_xor (vector double, vector double);
13623 vector double vec_xor (vector double, vector bool long);
13624 vector double vec_xor (vector bool long, vector double);
13625 int vec_all_eq (vector double, vector double);
13626 int vec_all_ge (vector double, vector double);
13627 int vec_all_gt (vector double, vector double);
13628 int vec_all_le (vector double, vector double);
13629 int vec_all_lt (vector double, vector double);
13630 int vec_all_nan (vector double);
13631 int vec_all_ne (vector double, vector double);
13632 int vec_all_nge (vector double, vector double);
13633 int vec_all_ngt (vector double, vector double);
13634 int vec_all_nle (vector double, vector double);
13635 int vec_all_nlt (vector double, vector double);
13636 int vec_all_numeric (vector double);
13637 int vec_any_eq (vector double, vector double);
13638 int vec_any_ge (vector double, vector double);
13639 int vec_any_gt (vector double, vector double);
13640 int vec_any_le (vector double, vector double);
13641 int vec_any_lt (vector double, vector double);
13642 int vec_any_nan (vector double);
13643 int vec_any_ne (vector double, vector double);
13644 int vec_any_nge (vector double, vector double);
13645 int vec_any_ngt (vector double, vector double);
13646 int vec_any_nle (vector double, vector double);
13647 int vec_any_nlt (vector double, vector double);
13648 int vec_any_numeric (vector double);
13649
13650 vector double vec_vsx_ld (int, const vector double *);
13651 vector double vec_vsx_ld (int, const double *);
13652 vector float vec_vsx_ld (int, const vector float *);
13653 vector float vec_vsx_ld (int, const float *);
13654 vector bool int vec_vsx_ld (int, const vector bool int *);
13655 vector signed int vec_vsx_ld (int, const vector signed int *);
13656 vector signed int vec_vsx_ld (int, const int *);
13657 vector signed int vec_vsx_ld (int, const long *);
13658 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
13659 vector unsigned int vec_vsx_ld (int, const unsigned int *);
13660 vector unsigned int vec_vsx_ld (int, const unsigned long *);
13661 vector bool short vec_vsx_ld (int, const vector bool short *);
13662 vector pixel vec_vsx_ld (int, const vector pixel *);
13663 vector signed short vec_vsx_ld (int, const vector signed short *);
13664 vector signed short vec_vsx_ld (int, const short *);
13665 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
13666 vector unsigned short vec_vsx_ld (int, const unsigned short *);
13667 vector bool char vec_vsx_ld (int, const vector bool char *);
13668 vector signed char vec_vsx_ld (int, const vector signed char *);
13669 vector signed char vec_vsx_ld (int, const signed char *);
13670 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
13671 vector unsigned char vec_vsx_ld (int, const unsigned char *);
13672
13673 void vec_vsx_st (vector double, int, vector double *);
13674 void vec_vsx_st (vector double, int, double *);
13675 void vec_vsx_st (vector float, int, vector float *);
13676 void vec_vsx_st (vector float, int, float *);
13677 void vec_vsx_st (vector signed int, int, vector signed int *);
13678 void vec_vsx_st (vector signed int, int, int *);
13679 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
13680 void vec_vsx_st (vector unsigned int, int, unsigned int *);
13681 void vec_vsx_st (vector bool int, int, vector bool int *);
13682 void vec_vsx_st (vector bool int, int, unsigned int *);
13683 void vec_vsx_st (vector bool int, int, int *);
13684 void vec_vsx_st (vector signed short, int, vector signed short *);
13685 void vec_vsx_st (vector signed short, int, short *);
13686 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
13687 void vec_vsx_st (vector unsigned short, int, unsigned short *);
13688 void vec_vsx_st (vector bool short, int, vector bool short *);
13689 void vec_vsx_st (vector bool short, int, unsigned short *);
13690 void vec_vsx_st (vector pixel, int, vector pixel *);
13691 void vec_vsx_st (vector pixel, int, unsigned short *);
13692 void vec_vsx_st (vector pixel, int, short *);
13693 void vec_vsx_st (vector bool short, int, short *);
13694 void vec_vsx_st (vector signed char, int, vector signed char *);
13695 void vec_vsx_st (vector signed char, int, signed char *);
13696 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
13697 void vec_vsx_st (vector unsigned char, int, unsigned char *);
13698 void vec_vsx_st (vector bool char, int, vector bool char *);
13699 void vec_vsx_st (vector bool char, int, unsigned char *);
13700 void vec_vsx_st (vector bool char, int, signed char *);
13701 @end smallexample
13702
13703 Note that the @samp{vec_ld} and @samp{vec_st} builtins always
13704 generate the Altivec @samp{LVX} and @samp{STVX} instructions even
13705 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
13706 @samp{vec_vsx_st} builtins always generate the VSX @samp{LXVD2X},
13707 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
13708
13709 @node SH Built-in Functions
13710 @subsection SH Built-in Functions
13711 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
13712 families of processors:
13713
13714 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
13715 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
13716 used by system code that manages threads and execution contexts. The compiler
13717 normally does not generate code that modifies the contents of @samp{GBR} and
13718 thus the value is preserved across function calls. Changing the @samp{GBR}
13719 value in user code must be done with caution, since the compiler might use
13720 @samp{GBR} in order to access thread local variables.
13721
13722 @end deftypefn
13723
13724 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
13725 Returns the value that is currently set in the @samp{GBR} register.
13726 Memory loads and stores that use the thread pointer as a base address are
13727 turned into @samp{GBR} based displacement loads and stores, if possible.
13728 For example:
13729 @smallexample
13730 struct my_tcb
13731 @{
13732 int a, b, c, d, e;
13733 @};
13734
13735 int get_tcb_value (void)
13736 @{
13737 // Generate @samp{mov.l @@(8,gbr),r0} instruction
13738 return ((my_tcb*)__builtin_thread_pointer ())->c;
13739 @}
13740
13741 @end smallexample
13742 @end deftypefn
13743
13744 @node RX Built-in Functions
13745 @subsection RX Built-in Functions
13746 GCC supports some of the RX instructions which cannot be expressed in
13747 the C programming language via the use of built-in functions. The
13748 following functions are supported:
13749
13750 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
13751 Generates the @code{brk} machine instruction.
13752 @end deftypefn
13753
13754 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
13755 Generates the @code{clrpsw} machine instruction to clear the specified
13756 bit in the processor status word.
13757 @end deftypefn
13758
13759 @deftypefn {Built-in Function} void __builtin_rx_int (int)
13760 Generates the @code{int} machine instruction to generate an interrupt
13761 with the specified value.
13762 @end deftypefn
13763
13764 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
13765 Generates the @code{machi} machine instruction to add the result of
13766 multiplying the top 16-bits of the two arguments into the
13767 accumulator.
13768 @end deftypefn
13769
13770 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
13771 Generates the @code{maclo} machine instruction to add the result of
13772 multiplying the bottom 16-bits of the two arguments into the
13773 accumulator.
13774 @end deftypefn
13775
13776 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
13777 Generates the @code{mulhi} machine instruction to place the result of
13778 multiplying the top 16-bits of the two arguments into the
13779 accumulator.
13780 @end deftypefn
13781
13782 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
13783 Generates the @code{mullo} machine instruction to place the result of
13784 multiplying the bottom 16-bits of the two arguments into the
13785 accumulator.
13786 @end deftypefn
13787
13788 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
13789 Generates the @code{mvfachi} machine instruction to read the top
13790 32-bits of the accumulator.
13791 @end deftypefn
13792
13793 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
13794 Generates the @code{mvfacmi} machine instruction to read the middle
13795 32-bits of the accumulator.
13796 @end deftypefn
13797
13798 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
13799 Generates the @code{mvfc} machine instruction which reads the control
13800 register specified in its argument and returns its value.
13801 @end deftypefn
13802
13803 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
13804 Generates the @code{mvtachi} machine instruction to set the top
13805 32-bits of the accumulator.
13806 @end deftypefn
13807
13808 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
13809 Generates the @code{mvtaclo} machine instruction to set the bottom
13810 32-bits of the accumulator.
13811 @end deftypefn
13812
13813 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
13814 Generates the @code{mvtc} machine instruction which sets control
13815 register number @code{reg} to @code{val}.
13816 @end deftypefn
13817
13818 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
13819 Generates the @code{mvtipl} machine instruction set the interrupt
13820 priority level.
13821 @end deftypefn
13822
13823 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
13824 Generates the @code{racw} machine instruction to round the accumulator
13825 according to the specified mode.
13826 @end deftypefn
13827
13828 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
13829 Generates the @code{revw} machine instruction which swaps the bytes in
13830 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
13831 and also bits 16--23 occupy bits 24--31 and vice versa.
13832 @end deftypefn
13833
13834 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
13835 Generates the @code{rmpa} machine instruction which initiates a
13836 repeated multiply and accumulate sequence.
13837 @end deftypefn
13838
13839 @deftypefn {Built-in Function} void __builtin_rx_round (float)
13840 Generates the @code{round} machine instruction which returns the
13841 floating point argument rounded according to the current rounding mode
13842 set in the floating point status word register.
13843 @end deftypefn
13844
13845 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
13846 Generates the @code{sat} machine instruction which returns the
13847 saturated value of the argument.
13848 @end deftypefn
13849
13850 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
13851 Generates the @code{setpsw} machine instruction to set the specified
13852 bit in the processor status word.
13853 @end deftypefn
13854
13855 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
13856 Generates the @code{wait} machine instruction.
13857 @end deftypefn
13858
13859 @node SPARC VIS Built-in Functions
13860 @subsection SPARC VIS Built-in Functions
13861
13862 GCC supports SIMD operations on the SPARC using both the generic vector
13863 extensions (@pxref{Vector Extensions}) as well as built-in functions for
13864 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
13865 switch, the VIS extension is exposed as the following built-in functions:
13866
13867 @smallexample
13868 typedef int v1si __attribute__ ((vector_size (4)));
13869 typedef int v2si __attribute__ ((vector_size (8)));
13870 typedef short v4hi __attribute__ ((vector_size (8)));
13871 typedef short v2hi __attribute__ ((vector_size (4)));
13872 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
13873 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
13874
13875 void __builtin_vis_write_gsr (int64_t);
13876 int64_t __builtin_vis_read_gsr (void);
13877
13878 void * __builtin_vis_alignaddr (void *, long);
13879 void * __builtin_vis_alignaddrl (void *, long);
13880 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
13881 v2si __builtin_vis_faligndatav2si (v2si, v2si);
13882 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
13883 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
13884
13885 v4hi __builtin_vis_fexpand (v4qi);
13886
13887 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
13888 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
13889 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
13890 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
13891 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
13892 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
13893 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
13894
13895 v4qi __builtin_vis_fpack16 (v4hi);
13896 v8qi __builtin_vis_fpack32 (v2si, v8qi);
13897 v2hi __builtin_vis_fpackfix (v2si);
13898 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
13899
13900 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
13901
13902 long __builtin_vis_edge8 (void *, void *);
13903 long __builtin_vis_edge8l (void *, void *);
13904 long __builtin_vis_edge16 (void *, void *);
13905 long __builtin_vis_edge16l (void *, void *);
13906 long __builtin_vis_edge32 (void *, void *);
13907 long __builtin_vis_edge32l (void *, void *);
13908
13909 long __builtin_vis_fcmple16 (v4hi, v4hi);
13910 long __builtin_vis_fcmple32 (v2si, v2si);
13911 long __builtin_vis_fcmpne16 (v4hi, v4hi);
13912 long __builtin_vis_fcmpne32 (v2si, v2si);
13913 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
13914 long __builtin_vis_fcmpgt32 (v2si, v2si);
13915 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
13916 long __builtin_vis_fcmpeq32 (v2si, v2si);
13917
13918 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
13919 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
13920 v2si __builtin_vis_fpadd32 (v2si, v2si);
13921 v1si __builtin_vis_fpadd32s (v1si, v1si);
13922 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
13923 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
13924 v2si __builtin_vis_fpsub32 (v2si, v2si);
13925 v1si __builtin_vis_fpsub32s (v1si, v1si);
13926
13927 long __builtin_vis_array8 (long, long);
13928 long __builtin_vis_array16 (long, long);
13929 long __builtin_vis_array32 (long, long);
13930 @end smallexample
13931
13932 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
13933 functions also become available:
13934
13935 @smallexample
13936 long __builtin_vis_bmask (long, long);
13937 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
13938 v2si __builtin_vis_bshufflev2si (v2si, v2si);
13939 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
13940 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
13941
13942 long __builtin_vis_edge8n (void *, void *);
13943 long __builtin_vis_edge8ln (void *, void *);
13944 long __builtin_vis_edge16n (void *, void *);
13945 long __builtin_vis_edge16ln (void *, void *);
13946 long __builtin_vis_edge32n (void *, void *);
13947 long __builtin_vis_edge32ln (void *, void *);
13948 @end smallexample
13949
13950 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
13951 functions also become available:
13952
13953 @smallexample
13954 void __builtin_vis_cmask8 (long);
13955 void __builtin_vis_cmask16 (long);
13956 void __builtin_vis_cmask32 (long);
13957
13958 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
13959
13960 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
13961 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
13962 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
13963 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
13964 v2si __builtin_vis_fsll16 (v2si, v2si);
13965 v2si __builtin_vis_fslas16 (v2si, v2si);
13966 v2si __builtin_vis_fsrl16 (v2si, v2si);
13967 v2si __builtin_vis_fsra16 (v2si, v2si);
13968
13969 long __builtin_vis_pdistn (v8qi, v8qi);
13970
13971 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
13972
13973 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
13974 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
13975
13976 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
13977 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
13978 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
13979 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
13980 v2si __builtin_vis_fpadds32 (v2si, v2si);
13981 v1si __builtin_vis_fpadds32s (v1si, v1si);
13982 v2si __builtin_vis_fpsubs32 (v2si, v2si);
13983 v1si __builtin_vis_fpsubs32s (v1si, v1si);
13984
13985 long __builtin_vis_fucmple8 (v8qi, v8qi);
13986 long __builtin_vis_fucmpne8 (v8qi, v8qi);
13987 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
13988 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
13989
13990 float __builtin_vis_fhadds (float, float);
13991 double __builtin_vis_fhaddd (double, double);
13992 float __builtin_vis_fhsubs (float, float);
13993 double __builtin_vis_fhsubd (double, double);
13994 float __builtin_vis_fnhadds (float, float);
13995 double __builtin_vis_fnhaddd (double, double);
13996
13997 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
13998 int64_t __builtin_vis_xmulx (int64_t, int64_t);
13999 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
14000 @end smallexample
14001
14002 @node SPU Built-in Functions
14003 @subsection SPU Built-in Functions
14004
14005 GCC provides extensions for the SPU processor as described in the
14006 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
14007 found at @uref{http://cell.scei.co.jp/} or
14008 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
14009 implementation differs in several ways.
14010
14011 @itemize @bullet
14012
14013 @item
14014 The optional extension of specifying vector constants in parentheses is
14015 not supported.
14016
14017 @item
14018 A vector initializer requires no cast if the vector constant is of the
14019 same type as the variable it is initializing.
14020
14021 @item
14022 If @code{signed} or @code{unsigned} is omitted, the signedness of the
14023 vector type is the default signedness of the base type. The default
14024 varies depending on the operating system, so a portable program should
14025 always specify the signedness.
14026
14027 @item
14028 By default, the keyword @code{__vector} is added. The macro
14029 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
14030 undefined.
14031
14032 @item
14033 GCC allows using a @code{typedef} name as the type specifier for a
14034 vector type.
14035
14036 @item
14037 For C, overloaded functions are implemented with macros so the following
14038 does not work:
14039
14040 @smallexample
14041 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14042 @end smallexample
14043
14044 Since @code{spu_add} is a macro, the vector constant in the example
14045 is treated as four separate arguments. Wrap the entire argument in
14046 parentheses for this to work.
14047
14048 @item
14049 The extended version of @code{__builtin_expect} is not supported.
14050
14051 @end itemize
14052
14053 @emph{Note:} Only the interface described in the aforementioned
14054 specification is supported. Internally, GCC uses built-in functions to
14055 implement the required functionality, but these are not supported and
14056 are subject to change without notice.
14057
14058 @node TI C6X Built-in Functions
14059 @subsection TI C6X Built-in Functions
14060
14061 GCC provides intrinsics to access certain instructions of the TI C6X
14062 processors. These intrinsics, listed below, are available after
14063 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
14064 to C6X instructions.
14065
14066 @smallexample
14067
14068 int _sadd (int, int)
14069 int _ssub (int, int)
14070 int _sadd2 (int, int)
14071 int _ssub2 (int, int)
14072 long long _mpy2 (int, int)
14073 long long _smpy2 (int, int)
14074 int _add4 (int, int)
14075 int _sub4 (int, int)
14076 int _saddu4 (int, int)
14077
14078 int _smpy (int, int)
14079 int _smpyh (int, int)
14080 int _smpyhl (int, int)
14081 int _smpylh (int, int)
14082
14083 int _sshl (int, int)
14084 int _subc (int, int)
14085
14086 int _avg2 (int, int)
14087 int _avgu4 (int, int)
14088
14089 int _clrr (int, int)
14090 int _extr (int, int)
14091 int _extru (int, int)
14092 int _abs (int)
14093 int _abs2 (int)
14094
14095 @end smallexample
14096
14097 @node TILE-Gx Built-in Functions
14098 @subsection TILE-Gx Built-in Functions
14099
14100 GCC provides intrinsics to access every instruction of the TILE-Gx
14101 processor. The intrinsics are of the form:
14102
14103 @smallexample
14104
14105 unsigned long long __insn_@var{op} (...)
14106
14107 @end smallexample
14108
14109 Where @var{op} is the name of the instruction. Refer to the ISA manual
14110 for the complete list of instructions.
14111
14112 GCC also provides intrinsics to directly access the network registers.
14113 The intrinsics are:
14114
14115 @smallexample
14116
14117 unsigned long long __tile_idn0_receive (void)
14118 unsigned long long __tile_idn1_receive (void)
14119 unsigned long long __tile_udn0_receive (void)
14120 unsigned long long __tile_udn1_receive (void)
14121 unsigned long long __tile_udn2_receive (void)
14122 unsigned long long __tile_udn3_receive (void)
14123 void __tile_idn_send (unsigned long long)
14124 void __tile_udn_send (unsigned long long)
14125
14126 @end smallexample
14127
14128 The intrinsic @code{void __tile_network_barrier (void)} is used to
14129 guarantee that no network operations before it are reordered with
14130 those after it.
14131
14132 @node TILEPro Built-in Functions
14133 @subsection TILEPro Built-in Functions
14134
14135 GCC provides intrinsics to access every instruction of the TILEPro
14136 processor. The intrinsics are of the form:
14137
14138 @smallexample
14139
14140 unsigned __insn_@var{op} (...)
14141
14142 @end smallexample
14143
14144 Where @var{op} is the name of the instruction. Refer to the ISA manual
14145 for the complete list of instructions.
14146
14147 GCC also provides intrinsics to directly access the network registers.
14148 The intrinsics are:
14149
14150 @smallexample
14151
14152 unsigned __tile_idn0_receive (void)
14153 unsigned __tile_idn1_receive (void)
14154 unsigned __tile_sn_receive (void)
14155 unsigned __tile_udn0_receive (void)
14156 unsigned __tile_udn1_receive (void)
14157 unsigned __tile_udn2_receive (void)
14158 unsigned __tile_udn3_receive (void)
14159 void __tile_idn_send (unsigned)
14160 void __tile_sn_send (unsigned)
14161 void __tile_udn_send (unsigned)
14162
14163 @end smallexample
14164
14165 The intrinsic @code{void __tile_network_barrier (void)} is used to
14166 guarantee that no network operations before it are reordered with
14167 those after it.
14168
14169 @node Target Format Checks
14170 @section Format Checks Specific to Particular Target Machines
14171
14172 For some target machines, GCC supports additional options to the
14173 format attribute
14174 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
14175
14176 @menu
14177 * Solaris Format Checks::
14178 * Darwin Format Checks::
14179 @end menu
14180
14181 @node Solaris Format Checks
14182 @subsection Solaris Format Checks
14183
14184 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
14185 check. @code{cmn_err} accepts a subset of the standard @code{printf}
14186 conversions, and the two-argument @code{%b} conversion for displaying
14187 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
14188
14189 @node Darwin Format Checks
14190 @subsection Darwin Format Checks
14191
14192 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
14193 attribute context. Declarations made with such attribution are parsed for correct syntax
14194 and format argument types. However, parsing of the format string itself is currently undefined
14195 and is not carried out by this version of the compiler.
14196
14197 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
14198 also be used as format arguments. Note that the relevant headers are only likely to be
14199 available on Darwin (OSX) installations. On such installations, the XCode and system
14200 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
14201 associated functions.
14202
14203 @node Pragmas
14204 @section Pragmas Accepted by GCC
14205 @cindex pragmas
14206 @cindex @code{#pragma}
14207
14208 GCC supports several types of pragmas, primarily in order to compile
14209 code originally written for other compilers. Note that in general
14210 we do not recommend the use of pragmas; @xref{Function Attributes},
14211 for further explanation.
14212
14213 @menu
14214 * ARM Pragmas::
14215 * M32C Pragmas::
14216 * MeP Pragmas::
14217 * RS/6000 and PowerPC Pragmas::
14218 * Darwin Pragmas::
14219 * Solaris Pragmas::
14220 * Symbol-Renaming Pragmas::
14221 * Structure-Packing Pragmas::
14222 * Weak Pragmas::
14223 * Diagnostic Pragmas::
14224 * Visibility Pragmas::
14225 * Push/Pop Macro Pragmas::
14226 * Function Specific Option Pragmas::
14227 @end menu
14228
14229 @node ARM Pragmas
14230 @subsection ARM Pragmas
14231
14232 The ARM target defines pragmas for controlling the default addition of
14233 @code{long_call} and @code{short_call} attributes to functions.
14234 @xref{Function Attributes}, for information about the effects of these
14235 attributes.
14236
14237 @table @code
14238 @item long_calls
14239 @cindex pragma, long_calls
14240 Set all subsequent functions to have the @code{long_call} attribute.
14241
14242 @item no_long_calls
14243 @cindex pragma, no_long_calls
14244 Set all subsequent functions to have the @code{short_call} attribute.
14245
14246 @item long_calls_off
14247 @cindex pragma, long_calls_off
14248 Do not affect the @code{long_call} or @code{short_call} attributes of
14249 subsequent functions.
14250 @end table
14251
14252 @node M32C Pragmas
14253 @subsection M32C Pragmas
14254
14255 @table @code
14256 @item GCC memregs @var{number}
14257 @cindex pragma, memregs
14258 Overrides the command-line option @code{-memregs=} for the current
14259 file. Use with care! This pragma must be before any function in the
14260 file, and mixing different memregs values in different objects may
14261 make them incompatible. This pragma is useful when a
14262 performance-critical function uses a memreg for temporary values,
14263 as it may allow you to reduce the number of memregs used.
14264
14265 @item ADDRESS @var{name} @var{address}
14266 @cindex pragma, address
14267 For any declared symbols matching @var{name}, this does three things
14268 to that symbol: it forces the symbol to be located at the given
14269 address (a number), it forces the symbol to be volatile, and it
14270 changes the symbol's scope to be static. This pragma exists for
14271 compatibility with other compilers, but note that the common
14272 @code{1234H} numeric syntax is not supported (use @code{0x1234}
14273 instead). Example:
14274
14275 @example
14276 #pragma ADDRESS port3 0x103
14277 char port3;
14278 @end example
14279
14280 @end table
14281
14282 @node MeP Pragmas
14283 @subsection MeP Pragmas
14284
14285 @table @code
14286
14287 @item custom io_volatile (on|off)
14288 @cindex pragma, custom io_volatile
14289 Overrides the command line option @code{-mio-volatile} for the current
14290 file. Note that for compatibility with future GCC releases, this
14291 option should only be used once before any @code{io} variables in each
14292 file.
14293
14294 @item GCC coprocessor available @var{registers}
14295 @cindex pragma, coprocessor available
14296 Specifies which coprocessor registers are available to the register
14297 allocator. @var{registers} may be a single register, register range
14298 separated by ellipses, or comma-separated list of those. Example:
14299
14300 @example
14301 #pragma GCC coprocessor available $c0...$c10, $c28
14302 @end example
14303
14304 @item GCC coprocessor call_saved @var{registers}
14305 @cindex pragma, coprocessor call_saved
14306 Specifies which coprocessor registers are to be saved and restored by
14307 any function using them. @var{registers} may be a single register,
14308 register range separated by ellipses, or comma-separated list of
14309 those. Example:
14310
14311 @example
14312 #pragma GCC coprocessor call_saved $c4...$c6, $c31
14313 @end example
14314
14315 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
14316 @cindex pragma, coprocessor subclass
14317 Creates and defines a register class. These register classes can be
14318 used by inline @code{asm} constructs. @var{registers} may be a single
14319 register, register range separated by ellipses, or comma-separated
14320 list of those. Example:
14321
14322 @example
14323 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
14324
14325 asm ("cpfoo %0" : "=B" (x));
14326 @end example
14327
14328 @item GCC disinterrupt @var{name} , @var{name} @dots{}
14329 @cindex pragma, disinterrupt
14330 For the named functions, the compiler adds code to disable interrupts
14331 for the duration of those functions. Any functions so named, which
14332 are not encountered in the source, cause a warning that the pragma is
14333 not used. Examples:
14334
14335 @example
14336 #pragma disinterrupt foo
14337 #pragma disinterrupt bar, grill
14338 int foo () @{ @dots{} @}
14339 @end example
14340
14341 @item GCC call @var{name} , @var{name} @dots{}
14342 @cindex pragma, call
14343 For the named functions, the compiler always uses a register-indirect
14344 call model when calling the named functions. Examples:
14345
14346 @example
14347 extern int foo ();
14348 #pragma call foo
14349 @end example
14350
14351 @end table
14352
14353 @node RS/6000 and PowerPC Pragmas
14354 @subsection RS/6000 and PowerPC Pragmas
14355
14356 The RS/6000 and PowerPC targets define one pragma for controlling
14357 whether or not the @code{longcall} attribute is added to function
14358 declarations by default. This pragma overrides the @option{-mlongcall}
14359 option, but not the @code{longcall} and @code{shortcall} attributes.
14360 @xref{RS/6000 and PowerPC Options}, for more information about when long
14361 calls are and are not necessary.
14362
14363 @table @code
14364 @item longcall (1)
14365 @cindex pragma, longcall
14366 Apply the @code{longcall} attribute to all subsequent function
14367 declarations.
14368
14369 @item longcall (0)
14370 Do not apply the @code{longcall} attribute to subsequent function
14371 declarations.
14372 @end table
14373
14374 @c Describe h8300 pragmas here.
14375 @c Describe sh pragmas here.
14376 @c Describe v850 pragmas here.
14377
14378 @node Darwin Pragmas
14379 @subsection Darwin Pragmas
14380
14381 The following pragmas are available for all architectures running the
14382 Darwin operating system. These are useful for compatibility with other
14383 Mac OS compilers.
14384
14385 @table @code
14386 @item mark @var{tokens}@dots{}
14387 @cindex pragma, mark
14388 This pragma is accepted, but has no effect.
14389
14390 @item options align=@var{alignment}
14391 @cindex pragma, options align
14392 This pragma sets the alignment of fields in structures. The values of
14393 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
14394 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
14395 properly; to restore the previous setting, use @code{reset} for the
14396 @var{alignment}.
14397
14398 @item segment @var{tokens}@dots{}
14399 @cindex pragma, segment
14400 This pragma is accepted, but has no effect.
14401
14402 @item unused (@var{var} [, @var{var}]@dots{})
14403 @cindex pragma, unused
14404 This pragma declares variables to be possibly unused. GCC does not
14405 produce warnings for the listed variables. The effect is similar to
14406 that of the @code{unused} attribute, except that this pragma may appear
14407 anywhere within the variables' scopes.
14408 @end table
14409
14410 @node Solaris Pragmas
14411 @subsection Solaris Pragmas
14412
14413 The Solaris target supports @code{#pragma redefine_extname}
14414 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
14415 @code{#pragma} directives for compatibility with the system compiler.
14416
14417 @table @code
14418 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
14419 @cindex pragma, align
14420
14421 Increase the minimum alignment of each @var{variable} to @var{alignment}.
14422 This is the same as GCC's @code{aligned} attribute @pxref{Variable
14423 Attributes}). Macro expansion occurs on the arguments to this pragma
14424 when compiling C and Objective-C@. It does not currently occur when
14425 compiling C++, but this is a bug which may be fixed in a future
14426 release.
14427
14428 @item fini (@var{function} [, @var{function}]...)
14429 @cindex pragma, fini
14430
14431 This pragma causes each listed @var{function} to be called after
14432 main, or during shared module unloading, by adding a call to the
14433 @code{.fini} section.
14434
14435 @item init (@var{function} [, @var{function}]...)
14436 @cindex pragma, init
14437
14438 This pragma causes each listed @var{function} to be called during
14439 initialization (before @code{main}) or during shared module loading, by
14440 adding a call to the @code{.init} section.
14441
14442 @end table
14443
14444 @node Symbol-Renaming Pragmas
14445 @subsection Symbol-Renaming Pragmas
14446
14447 For compatibility with the Solaris system headers, GCC
14448 supports two @code{#pragma} directives which change the name used in
14449 assembly for a given declaration. To get this effect
14450 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
14451 Labels}).
14452
14453 @table @code
14454 @item redefine_extname @var{oldname} @var{newname}
14455 @cindex pragma, redefine_extname
14456
14457 This pragma gives the C function @var{oldname} the assembly symbol
14458 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
14459 is defined if this pragma is available (currently on all platforms).
14460 @end table
14461
14462 This pragma and the asm labels extension interact in a complicated
14463 manner. Here are some corner cases you may want to be aware of.
14464
14465 @enumerate
14466 @item Both pragmas silently apply only to declarations with external
14467 linkage. Asm labels do not have this restriction.
14468
14469 @item In C++, both pragmas silently apply only to declarations with
14470 ``C'' linkage. Again, asm labels do not have this restriction.
14471
14472 @item If any of the three ways of changing the assembly name of a
14473 declaration is applied to a declaration whose assembly name has
14474 already been determined (either by a previous use of one of these
14475 features, or because the compiler needed the assembly name in order to
14476 generate code), and the new name is different, a warning issues and
14477 the name does not change.
14478
14479 @item The @var{oldname} used by @code{#pragma redefine_extname} is
14480 always the C-language name.
14481 @end enumerate
14482
14483 @node Structure-Packing Pragmas
14484 @subsection Structure-Packing Pragmas
14485
14486 For compatibility with Microsoft Windows compilers, GCC supports a
14487 set of @code{#pragma} directives which change the maximum alignment of
14488 members of structures (other than zero-width bitfields), unions, and
14489 classes subsequently defined. The @var{n} value below always is required
14490 to be a small power of two and specifies the new alignment in bytes.
14491
14492 @enumerate
14493 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
14494 @item @code{#pragma pack()} sets the alignment to the one that was in
14495 effect when compilation started (see also command-line option
14496 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
14497 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
14498 setting on an internal stack and then optionally sets the new alignment.
14499 @item @code{#pragma pack(pop)} restores the alignment setting to the one
14500 saved at the top of the internal stack (and removes that stack entry).
14501 Note that @code{#pragma pack([@var{n}])} does not influence this internal
14502 stack; thus it is possible to have @code{#pragma pack(push)} followed by
14503 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
14504 @code{#pragma pack(pop)}.
14505 @end enumerate
14506
14507 Some targets, e.g.@: i386 and powerpc, support the @code{ms_struct}
14508 @code{#pragma} which lays out a structure as the documented
14509 @code{__attribute__ ((ms_struct))}.
14510 @enumerate
14511 @item @code{#pragma ms_struct on} turns on the layout for structures
14512 declared.
14513 @item @code{#pragma ms_struct off} turns off the layout for structures
14514 declared.
14515 @item @code{#pragma ms_struct reset} goes back to the default layout.
14516 @end enumerate
14517
14518 @node Weak Pragmas
14519 @subsection Weak Pragmas
14520
14521 For compatibility with SVR4, GCC supports a set of @code{#pragma}
14522 directives for declaring symbols to be weak, and defining weak
14523 aliases.
14524
14525 @table @code
14526 @item #pragma weak @var{symbol}
14527 @cindex pragma, weak
14528 This pragma declares @var{symbol} to be weak, as if the declaration
14529 had the attribute of the same name. The pragma may appear before
14530 or after the declaration of @var{symbol}. It is not an error for
14531 @var{symbol} to never be defined at all.
14532
14533 @item #pragma weak @var{symbol1} = @var{symbol2}
14534 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
14535 It is an error if @var{symbol2} is not defined in the current
14536 translation unit.
14537 @end table
14538
14539 @node Diagnostic Pragmas
14540 @subsection Diagnostic Pragmas
14541
14542 GCC allows the user to selectively enable or disable certain types of
14543 diagnostics, and change the kind of the diagnostic. For example, a
14544 project's policy might require that all sources compile with
14545 @option{-Werror} but certain files might have exceptions allowing
14546 specific types of warnings. Or, a project might selectively enable
14547 diagnostics and treat them as errors depending on which preprocessor
14548 macros are defined.
14549
14550 @table @code
14551 @item #pragma GCC diagnostic @var{kind} @var{option}
14552 @cindex pragma, diagnostic
14553
14554 Modifies the disposition of a diagnostic. Note that not all
14555 diagnostics are modifiable; at the moment only warnings (normally
14556 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
14557 Use @option{-fdiagnostics-show-option} to determine which diagnostics
14558 are controllable and which option controls them.
14559
14560 @var{kind} is @samp{error} to treat this diagnostic as an error,
14561 @samp{warning} to treat it like a warning (even if @option{-Werror} is
14562 in effect), or @samp{ignored} if the diagnostic is to be ignored.
14563 @var{option} is a double quoted string which matches the command-line
14564 option.
14565
14566 @example
14567 #pragma GCC diagnostic warning "-Wformat"
14568 #pragma GCC diagnostic error "-Wformat"
14569 #pragma GCC diagnostic ignored "-Wformat"
14570 @end example
14571
14572 Note that these pragmas override any command-line options. GCC keeps
14573 track of the location of each pragma, and issues diagnostics according
14574 to the state as of that point in the source file. Thus, pragmas occurring
14575 after a line do not affect diagnostics caused by that line.
14576
14577 @item #pragma GCC diagnostic push
14578 @itemx #pragma GCC diagnostic pop
14579
14580 Causes GCC to remember the state of the diagnostics as of each
14581 @code{push}, and restore to that point at each @code{pop}. If a
14582 @code{pop} has no matching @code{push}, the command line options are
14583 restored.
14584
14585 @example
14586 #pragma GCC diagnostic error "-Wuninitialized"
14587 foo(a); /* error is given for this one */
14588 #pragma GCC diagnostic push
14589 #pragma GCC diagnostic ignored "-Wuninitialized"
14590 foo(b); /* no diagnostic for this one */
14591 #pragma GCC diagnostic pop
14592 foo(c); /* error is given for this one */
14593 #pragma GCC diagnostic pop
14594 foo(d); /* depends on command line options */
14595 @end example
14596
14597 @end table
14598
14599 GCC also offers a simple mechanism for printing messages during
14600 compilation.
14601
14602 @table @code
14603 @item #pragma message @var{string}
14604 @cindex pragma, diagnostic
14605
14606 Prints @var{string} as a compiler message on compilation. The message
14607 is informational only, and is neither a compilation warning nor an error.
14608
14609 @smallexample
14610 #pragma message "Compiling " __FILE__ "..."
14611 @end smallexample
14612
14613 @var{string} may be parenthesized, and is printed with location
14614 information. For example,
14615
14616 @smallexample
14617 #define DO_PRAGMA(x) _Pragma (#x)
14618 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
14619
14620 TODO(Remember to fix this)
14621 @end smallexample
14622
14623 prints @samp{/tmp/file.c:4: note: #pragma message:
14624 TODO - Remember to fix this}.
14625
14626 @end table
14627
14628 @node Visibility Pragmas
14629 @subsection Visibility Pragmas
14630
14631 @table @code
14632 @item #pragma GCC visibility push(@var{visibility})
14633 @itemx #pragma GCC visibility pop
14634 @cindex pragma, visibility
14635
14636 This pragma allows the user to set the visibility for multiple
14637 declarations without having to give each a visibility attribute
14638 @xref{Function Attributes}, for more information about visibility and
14639 the attribute syntax.
14640
14641 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
14642 declarations. Class members and template specializations are not
14643 affected; if you want to override the visibility for a particular
14644 member or instantiation, you must use an attribute.
14645
14646 @end table
14647
14648
14649 @node Push/Pop Macro Pragmas
14650 @subsection Push/Pop Macro Pragmas
14651
14652 For compatibility with Microsoft Windows compilers, GCC supports
14653 @samp{#pragma push_macro(@var{"macro_name"})}
14654 and @samp{#pragma pop_macro(@var{"macro_name"})}.
14655
14656 @table @code
14657 @item #pragma push_macro(@var{"macro_name"})
14658 @cindex pragma, push_macro
14659 This pragma saves the value of the macro named as @var{macro_name} to
14660 the top of the stack for this macro.
14661
14662 @item #pragma pop_macro(@var{"macro_name"})
14663 @cindex pragma, pop_macro
14664 This pragma sets the value of the macro named as @var{macro_name} to
14665 the value on top of the stack for this macro. If the stack for
14666 @var{macro_name} is empty, the value of the macro remains unchanged.
14667 @end table
14668
14669 For example:
14670
14671 @smallexample
14672 #define X 1
14673 #pragma push_macro("X")
14674 #undef X
14675 #define X -1
14676 #pragma pop_macro("X")
14677 int x [X];
14678 @end smallexample
14679
14680 In this example, the definition of X as 1 is saved by @code{#pragma
14681 push_macro} and restored by @code{#pragma pop_macro}.
14682
14683 @node Function Specific Option Pragmas
14684 @subsection Function Specific Option Pragmas
14685
14686 @table @code
14687 @item #pragma GCC target (@var{"string"}...)
14688 @cindex pragma GCC target
14689
14690 This pragma allows you to set target specific options for functions
14691 defined later in the source file. One or more strings can be
14692 specified. Each function that is defined after this point is as
14693 if @code{attribute((target("STRING")))} was specified for that
14694 function. The parenthesis around the options is optional.
14695 @xref{Function Attributes}, for more information about the
14696 @code{target} attribute and the attribute syntax.
14697
14698 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
14699 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC backends. At
14700 present, it is not implemented for other backends.
14701 @end table
14702
14703 @table @code
14704 @item #pragma GCC optimize (@var{"string"}...)
14705 @cindex pragma GCC optimize
14706
14707 This pragma allows you to set global optimization options for functions
14708 defined later in the source file. One or more strings can be
14709 specified. Each function that is defined after this point is as
14710 if @code{attribute((optimize("STRING")))} was specified for that
14711 function. The parenthesis around the options is optional.
14712 @xref{Function Attributes}, for more information about the
14713 @code{optimize} attribute and the attribute syntax.
14714
14715 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
14716 versions earlier than 4.4.
14717 @end table
14718
14719 @table @code
14720 @item #pragma GCC push_options
14721 @itemx #pragma GCC pop_options
14722 @cindex pragma GCC push_options
14723 @cindex pragma GCC pop_options
14724
14725 These pragmas maintain a stack of the current target and optimization
14726 options. It is intended for include files where you temporarily want
14727 to switch to using a different @samp{#pragma GCC target} or
14728 @samp{#pragma GCC optimize} and then to pop back to the previous
14729 options.
14730
14731 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
14732 pragmas are not implemented in GCC versions earlier than 4.4.
14733 @end table
14734
14735 @table @code
14736 @item #pragma GCC reset_options
14737 @cindex pragma GCC reset_options
14738
14739 This pragma clears the current @code{#pragma GCC target} and
14740 @code{#pragma GCC optimize} to use the default switches as specified
14741 on the command line.
14742
14743 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
14744 versions earlier than 4.4.
14745 @end table
14746
14747 @node Unnamed Fields
14748 @section Unnamed struct/union fields within structs/unions
14749 @cindex @code{struct}
14750 @cindex @code{union}
14751
14752 As permitted by ISO C11 and for compatibility with other compilers,
14753 GCC allows you to define
14754 a structure or union that contains, as fields, structures and unions
14755 without names. For example:
14756
14757 @smallexample
14758 struct @{
14759 int a;
14760 union @{
14761 int b;
14762 float c;
14763 @};
14764 int d;
14765 @} foo;
14766 @end smallexample
14767
14768 In this example, you are able to access members of the unnamed
14769 union with code like @samp{foo.b}. Note that only unnamed structs and
14770 unions are allowed, you may not have, for example, an unnamed
14771 @code{int}.
14772
14773 You must never create such structures that cause ambiguous field definitions.
14774 For example, this structure:
14775
14776 @smallexample
14777 struct @{
14778 int a;
14779 struct @{
14780 int a;
14781 @};
14782 @} foo;
14783 @end smallexample
14784
14785 It is ambiguous which @code{a} is being referred to with @samp{foo.a}.
14786 The compiler gives errors for such constructs.
14787
14788 @opindex fms-extensions
14789 Unless @option{-fms-extensions} is used, the unnamed field must be a
14790 structure or union definition without a tag (for example, @samp{struct
14791 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
14792 also be a definition with a tag such as @samp{struct foo @{ int a;
14793 @};}, a reference to a previously defined structure or union such as
14794 @samp{struct foo;}, or a reference to a @code{typedef} name for a
14795 previously defined structure or union type.
14796
14797 @opindex fplan9-extensions
14798 The option @option{-fplan9-extensions} enables
14799 @option{-fms-extensions} as well as two other extensions. First, a
14800 pointer to a structure is automatically converted to a pointer to an
14801 anonymous field for assignments and function calls. For example:
14802
14803 @smallexample
14804 struct s1 @{ int a; @};
14805 struct s2 @{ struct s1; @};
14806 extern void f1 (struct s1 *);
14807 void f2 (struct s2 *p) @{ f1 (p); @}
14808 @end smallexample
14809
14810 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
14811 converted into a pointer to the anonymous field.
14812
14813 Second, when the type of an anonymous field is a @code{typedef} for a
14814 @code{struct} or @code{union}, code may refer to the field using the
14815 name of the @code{typedef}.
14816
14817 @smallexample
14818 typedef struct @{ int a; @} s1;
14819 struct s2 @{ s1; @};
14820 s1 f1 (struct s2 *p) @{ return p->s1; @}
14821 @end smallexample
14822
14823 These usages are only permitted when they are not ambiguous.
14824
14825 @node Thread-Local
14826 @section Thread-Local Storage
14827 @cindex Thread-Local Storage
14828 @cindex @acronym{TLS}
14829 @cindex @code{__thread}
14830
14831 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
14832 are allocated such that there is one instance of the variable per extant
14833 thread. The run-time model GCC uses to implement this originates
14834 in the IA-64 processor-specific ABI, but has since been migrated
14835 to other processors as well. It requires significant support from
14836 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
14837 system libraries (@file{libc.so} and @file{libpthread.so}), so it
14838 is not available everywhere.
14839
14840 At the user level, the extension is visible with a new storage
14841 class keyword: @code{__thread}. For example:
14842
14843 @smallexample
14844 __thread int i;
14845 extern __thread struct state s;
14846 static __thread char *p;
14847 @end smallexample
14848
14849 The @code{__thread} specifier may be used alone, with the @code{extern}
14850 or @code{static} specifiers, but with no other storage class specifier.
14851 When used with @code{extern} or @code{static}, @code{__thread} must appear
14852 immediately after the other storage class specifier.
14853
14854 The @code{__thread} specifier may be applied to any global, file-scoped
14855 static, function-scoped static, or static data member of a class. It may
14856 not be applied to block-scoped automatic or non-static data member.
14857
14858 When the address-of operator is applied to a thread-local variable, it is
14859 evaluated at run-time and returns the address of the current thread's
14860 instance of that variable. An address so obtained may be used by any
14861 thread. When a thread terminates, any pointers to thread-local variables
14862 in that thread become invalid.
14863
14864 No static initialization may refer to the address of a thread-local variable.
14865
14866 In C++, if an initializer is present for a thread-local variable, it must
14867 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
14868 standard.
14869
14870 See @uref{http://www.akkadia.org/drepper/tls.pdf,
14871 ELF Handling For Thread-Local Storage} for a detailed explanation of
14872 the four thread-local storage addressing models, and how the run-time
14873 is expected to function.
14874
14875 @menu
14876 * C99 Thread-Local Edits::
14877 * C++98 Thread-Local Edits::
14878 @end menu
14879
14880 @node C99 Thread-Local Edits
14881 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
14882
14883 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
14884 that document the exact semantics of the language extension.
14885
14886 @itemize @bullet
14887 @item
14888 @cite{5.1.2 Execution environments}
14889
14890 Add new text after paragraph 1
14891
14892 @quotation
14893 Within either execution environment, a @dfn{thread} is a flow of
14894 control within a program. It is implementation defined whether
14895 or not there may be more than one thread associated with a program.
14896 It is implementation defined how threads beyond the first are
14897 created, the name and type of the function called at thread
14898 startup, and how threads may be terminated. However, objects
14899 with thread storage duration shall be initialized before thread
14900 startup.
14901 @end quotation
14902
14903 @item
14904 @cite{6.2.4 Storage durations of objects}
14905
14906 Add new text before paragraph 3
14907
14908 @quotation
14909 An object whose identifier is declared with the storage-class
14910 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
14911 Its lifetime is the entire execution of the thread, and its
14912 stored value is initialized only once, prior to thread startup.
14913 @end quotation
14914
14915 @item
14916 @cite{6.4.1 Keywords}
14917
14918 Add @code{__thread}.
14919
14920 @item
14921 @cite{6.7.1 Storage-class specifiers}
14922
14923 Add @code{__thread} to the list of storage class specifiers in
14924 paragraph 1.
14925
14926 Change paragraph 2 to
14927
14928 @quotation
14929 With the exception of @code{__thread}, at most one storage-class
14930 specifier may be given [@dots{}]. The @code{__thread} specifier may
14931 be used alone, or immediately following @code{extern} or
14932 @code{static}.
14933 @end quotation
14934
14935 Add new text after paragraph 6
14936
14937 @quotation
14938 The declaration of an identifier for a variable that has
14939 block scope that specifies @code{__thread} shall also
14940 specify either @code{extern} or @code{static}.
14941
14942 The @code{__thread} specifier shall be used only with
14943 variables.
14944 @end quotation
14945 @end itemize
14946
14947 @node C++98 Thread-Local Edits
14948 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
14949
14950 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
14951 that document the exact semantics of the language extension.
14952
14953 @itemize @bullet
14954 @item
14955 @b{[intro.execution]}
14956
14957 New text after paragraph 4
14958
14959 @quotation
14960 A @dfn{thread} is a flow of control within the abstract machine.
14961 It is implementation defined whether or not there may be more than
14962 one thread.
14963 @end quotation
14964
14965 New text after paragraph 7
14966
14967 @quotation
14968 It is unspecified whether additional action must be taken to
14969 ensure when and whether side effects are visible to other threads.
14970 @end quotation
14971
14972 @item
14973 @b{[lex.key]}
14974
14975 Add @code{__thread}.
14976
14977 @item
14978 @b{[basic.start.main]}
14979
14980 Add after paragraph 5
14981
14982 @quotation
14983 The thread that begins execution at the @code{main} function is called
14984 the @dfn{main thread}. It is implementation defined how functions
14985 beginning threads other than the main thread are designated or typed.
14986 A function so designated, as well as the @code{main} function, is called
14987 a @dfn{thread startup function}. It is implementation defined what
14988 happens if a thread startup function returns. It is implementation
14989 defined what happens to other threads when any thread calls @code{exit}.
14990 @end quotation
14991
14992 @item
14993 @b{[basic.start.init]}
14994
14995 Add after paragraph 4
14996
14997 @quotation
14998 The storage for an object of thread storage duration shall be
14999 statically initialized before the first statement of the thread startup
15000 function. An object of thread storage duration shall not require
15001 dynamic initialization.
15002 @end quotation
15003
15004 @item
15005 @b{[basic.start.term]}
15006
15007 Add after paragraph 3
15008
15009 @quotation
15010 The type of an object with thread storage duration shall not have a
15011 non-trivial destructor, nor shall it be an array type whose elements
15012 (directly or indirectly) have non-trivial destructors.
15013 @end quotation
15014
15015 @item
15016 @b{[basic.stc]}
15017
15018 Add ``thread storage duration'' to the list in paragraph 1.
15019
15020 Change paragraph 2
15021
15022 @quotation
15023 Thread, static, and automatic storage durations are associated with
15024 objects introduced by declarations [@dots{}].
15025 @end quotation
15026
15027 Add @code{__thread} to the list of specifiers in paragraph 3.
15028
15029 @item
15030 @b{[basic.stc.thread]}
15031
15032 New section before @b{[basic.stc.static]}
15033
15034 @quotation
15035 The keyword @code{__thread} applied to a non-local object gives the
15036 object thread storage duration.
15037
15038 A local variable or class data member declared both @code{static}
15039 and @code{__thread} gives the variable or member thread storage
15040 duration.
15041 @end quotation
15042
15043 @item
15044 @b{[basic.stc.static]}
15045
15046 Change paragraph 1
15047
15048 @quotation
15049 All objects which have neither thread storage duration, dynamic
15050 storage duration nor are local [@dots{}].
15051 @end quotation
15052
15053 @item
15054 @b{[dcl.stc]}
15055
15056 Add @code{__thread} to the list in paragraph 1.
15057
15058 Change paragraph 1
15059
15060 @quotation
15061 With the exception of @code{__thread}, at most one
15062 @var{storage-class-specifier} shall appear in a given
15063 @var{decl-specifier-seq}. The @code{__thread} specifier may
15064 be used alone, or immediately following the @code{extern} or
15065 @code{static} specifiers. [@dots{}]
15066 @end quotation
15067
15068 Add after paragraph 5
15069
15070 @quotation
15071 The @code{__thread} specifier can be applied only to the names of objects
15072 and to anonymous unions.
15073 @end quotation
15074
15075 @item
15076 @b{[class.mem]}
15077
15078 Add after paragraph 6
15079
15080 @quotation
15081 Non-@code{static} members shall not be @code{__thread}.
15082 @end quotation
15083 @end itemize
15084
15085 @node Binary constants
15086 @section Binary constants using the @samp{0b} prefix
15087 @cindex Binary constants using the @samp{0b} prefix
15088
15089 Integer constants can be written as binary constants, consisting of a
15090 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
15091 @samp{0B}. This is particularly useful in environments that operate a
15092 lot on the bit-level (like microcontrollers).
15093
15094 The following statements are identical:
15095
15096 @smallexample
15097 i = 42;
15098 i = 0x2a;
15099 i = 052;
15100 i = 0b101010;
15101 @end smallexample
15102
15103 The type of these constants follows the same rules as for octal or
15104 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
15105 can be applied.
15106
15107 @node C++ Extensions
15108 @chapter Extensions to the C++ Language
15109 @cindex extensions, C++ language
15110 @cindex C++ language extensions
15111
15112 The GNU compiler provides these extensions to the C++ language (and you
15113 can also use most of the C language extensions in your C++ programs). If you
15114 want to write code that checks whether these features are available, you can
15115 test for the GNU compiler the same way as for C programs: check for a
15116 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
15117 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
15118 Predefined Macros,cpp,The GNU C Preprocessor}).
15119
15120 @menu
15121 * C++ Volatiles:: What constitutes an access to a volatile object.
15122 * Restricted Pointers:: C99 restricted pointers and references.
15123 * Vague Linkage:: Where G++ puts inlines, vtables and such.
15124 * C++ Interface:: You can use a single C++ header file for both
15125 declarations and definitions.
15126 * Template Instantiation:: Methods for ensuring that exactly one copy of
15127 each needed template instantiation is emitted.
15128 * Bound member functions:: You can extract a function pointer to the
15129 method denoted by a @samp{->*} or @samp{.*} expression.
15130 * C++ Attributes:: Variable, function, and type attributes for C++ only.
15131 * Namespace Association:: Strong using-directives for namespace association.
15132 * Type Traits:: Compiler support for type traits
15133 * Java Exceptions:: Tweaking exception handling to work with Java.
15134 * Deprecated Features:: Things will disappear from g++.
15135 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
15136 @end menu
15137
15138 @node C++ Volatiles
15139 @section When is a Volatile C++ Object Accessed?
15140 @cindex accessing volatiles
15141 @cindex volatile read
15142 @cindex volatile write
15143 @cindex volatile access
15144
15145 The C++ standard differs from the C standard in its treatment of
15146 volatile objects. It fails to specify what constitutes a volatile
15147 access, except to say that C++ should behave in a similar manner to C
15148 with respect to volatiles, where possible. However, the different
15149 lvalueness of expressions between C and C++ complicate the behavior.
15150 G++ behaves the same as GCC for volatile access, @xref{C
15151 Extensions,,Volatiles}, for a description of GCC's behavior.
15152
15153 The C and C++ language specifications differ when an object is
15154 accessed in a void context:
15155
15156 @smallexample
15157 volatile int *src = @var{somevalue};
15158 *src;
15159 @end smallexample
15160
15161 The C++ standard specifies that such expressions do not undergo lvalue
15162 to rvalue conversion, and that the type of the dereferenced object may
15163 be incomplete. The C++ standard does not specify explicitly that it
15164 is lvalue to rvalue conversion which is responsible for causing an
15165 access. There is reason to believe that it is, because otherwise
15166 certain simple expressions become undefined. However, because it
15167 would surprise most programmers, G++ treats dereferencing a pointer to
15168 volatile object of complete type as GCC would do for an equivalent
15169 type in C@. When the object has incomplete type, G++ issues a
15170 warning; if you wish to force an error, you must force a conversion to
15171 rvalue with, for instance, a static cast.
15172
15173 When using a reference to volatile, G++ does not treat equivalent
15174 expressions as accesses to volatiles, but instead issues a warning that
15175 no volatile is accessed. The rationale for this is that otherwise it
15176 becomes difficult to determine where volatile access occur, and not
15177 possible to ignore the return value from functions returning volatile
15178 references. Again, if you wish to force a read, cast the reference to
15179 an rvalue.
15180
15181 G++ implements the same behavior as GCC does when assigning to a
15182 volatile object -- there is no reread of the assigned-to object, the
15183 assigned rvalue is reused. Note that in C++ assignment expressions
15184 are lvalues, and if used as an lvalue, the volatile object is
15185 referred to. For instance, @var{vref} refers to @var{vobj}, as
15186 expected, in the following example:
15187
15188 @smallexample
15189 volatile int vobj;
15190 volatile int &vref = vobj = @var{something};
15191 @end smallexample
15192
15193 @node Restricted Pointers
15194 @section Restricting Pointer Aliasing
15195 @cindex restricted pointers
15196 @cindex restricted references
15197 @cindex restricted this pointer
15198
15199 As with the C front end, G++ understands the C99 feature of restricted pointers,
15200 specified with the @code{__restrict__}, or @code{__restrict} type
15201 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
15202 language flag, @code{restrict} is not a keyword in C++.
15203
15204 In addition to allowing restricted pointers, you can specify restricted
15205 references, which indicate that the reference is not aliased in the local
15206 context.
15207
15208 @smallexample
15209 void fn (int *__restrict__ rptr, int &__restrict__ rref)
15210 @{
15211 /* @r{@dots{}} */
15212 @}
15213 @end smallexample
15214
15215 @noindent
15216 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
15217 @var{rref} refers to a (different) unaliased integer.
15218
15219 You may also specify whether a member function's @var{this} pointer is
15220 unaliased by using @code{__restrict__} as a member function qualifier.
15221
15222 @smallexample
15223 void T::fn () __restrict__
15224 @{
15225 /* @r{@dots{}} */
15226 @}
15227 @end smallexample
15228
15229 @noindent
15230 Within the body of @code{T::fn}, @var{this} has the effective
15231 definition @code{T *__restrict__ const this}. Notice that the
15232 interpretation of a @code{__restrict__} member function qualifier is
15233 different to that of @code{const} or @code{volatile} qualifier, in that it
15234 is applied to the pointer rather than the object. This is consistent with
15235 other compilers which implement restricted pointers.
15236
15237 As with all outermost parameter qualifiers, @code{__restrict__} is
15238 ignored in function definition matching. This means you only need to
15239 specify @code{__restrict__} in a function definition, rather than
15240 in a function prototype as well.
15241
15242 @node Vague Linkage
15243 @section Vague Linkage
15244 @cindex vague linkage
15245
15246 There are several constructs in C++ which require space in the object
15247 file but are not clearly tied to a single translation unit. We say that
15248 these constructs have ``vague linkage''. Typically such constructs are
15249 emitted wherever they are needed, though sometimes we can be more
15250 clever.
15251
15252 @table @asis
15253 @item Inline Functions
15254 Inline functions are typically defined in a header file which can be
15255 included in many different compilations. Hopefully they can usually be
15256 inlined, but sometimes an out-of-line copy is necessary, if the address
15257 of the function is taken or if inlining fails. In general, we emit an
15258 out-of-line copy in all translation units where one is needed. As an
15259 exception, we only emit inline virtual functions with the vtable, since
15260 it always requires a copy.
15261
15262 Local static variables and string constants used in an inline function
15263 are also considered to have vague linkage, since they must be shared
15264 between all inlined and out-of-line instances of the function.
15265
15266 @item VTables
15267 @cindex vtable
15268 C++ virtual functions are implemented in most compilers using a lookup
15269 table, known as a vtable. The vtable contains pointers to the virtual
15270 functions provided by a class, and each object of the class contains a
15271 pointer to its vtable (or vtables, in some multiple-inheritance
15272 situations). If the class declares any non-inline, non-pure virtual
15273 functions, the first one is chosen as the ``key method'' for the class,
15274 and the vtable is only emitted in the translation unit where the key
15275 method is defined.
15276
15277 @emph{Note:} If the chosen key method is later defined as inline, the
15278 vtable is still emitted in every translation unit which defines it.
15279 Make sure that any inline virtuals are declared inline in the class
15280 body, even if they are not defined there.
15281
15282 @item @code{type_info} objects
15283 @cindex @code{type_info}
15284 @cindex RTTI
15285 C++ requires information about types to be written out in order to
15286 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
15287 For polymorphic classes (classes with virtual functions), the @samp{type_info}
15288 object is written out along with the vtable so that @samp{dynamic_cast}
15289 can determine the dynamic type of a class object at runtime. For all
15290 other types, we write out the @samp{type_info} object when it is used: when
15291 applying @samp{typeid} to an expression, throwing an object, or
15292 referring to a type in a catch clause or exception specification.
15293
15294 @item Template Instantiations
15295 Most everything in this section also applies to template instantiations,
15296 but there are other options as well.
15297 @xref{Template Instantiation,,Where's the Template?}.
15298
15299 @end table
15300
15301 When used with GNU ld version 2.8 or later on an ELF system such as
15302 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
15303 these constructs will be discarded at link time. This is known as
15304 COMDAT support.
15305
15306 On targets that don't support COMDAT, but do support weak symbols, GCC
15307 uses them. This way one copy overrides all the others, but
15308 the unused copies still take up space in the executable.
15309
15310 For targets which do not support either COMDAT or weak symbols,
15311 most entities with vague linkage are emitted as local symbols to
15312 avoid duplicate definition errors from the linker. This does not happen
15313 for local statics in inlines, however, as having multiple copies
15314 almost certainly breaks things.
15315
15316 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
15317 another way to control placement of these constructs.
15318
15319 @node C++ Interface
15320 @section #pragma interface and implementation
15321
15322 @cindex interface and implementation headers, C++
15323 @cindex C++ interface and implementation headers
15324 @cindex pragmas, interface and implementation
15325
15326 @code{#pragma interface} and @code{#pragma implementation} provide the
15327 user with a way of explicitly directing the compiler to emit entities
15328 with vague linkage (and debugging information) in a particular
15329 translation unit.
15330
15331 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
15332 most cases, because of COMDAT support and the ``key method'' heuristic
15333 mentioned in @ref{Vague Linkage}. Using them can actually cause your
15334 program to grow due to unnecessary out-of-line copies of inline
15335 functions. Currently (3.4) the only benefit of these
15336 @code{#pragma}s is reduced duplication of debugging information, and
15337 that should be addressed soon on DWARF 2 targets with the use of
15338 COMDAT groups.
15339
15340 @table @code
15341 @item #pragma interface
15342 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
15343 @kindex #pragma interface
15344 Use this directive in @emph{header files} that define object classes, to save
15345 space in most of the object files that use those classes. Normally,
15346 local copies of certain information (backup copies of inline member
15347 functions, debugging information, and the internal tables that implement
15348 virtual functions) must be kept in each object file that includes class
15349 definitions. You can use this pragma to avoid such duplication. When a
15350 header file containing @samp{#pragma interface} is included in a
15351 compilation, this auxiliary information is not generated (unless
15352 the main input source file itself uses @samp{#pragma implementation}).
15353 Instead, the object files contain references to be resolved at link
15354 time.
15355
15356 The second form of this directive is useful for the case where you have
15357 multiple headers with the same name in different directories. If you
15358 use this form, you must specify the same string to @samp{#pragma
15359 implementation}.
15360
15361 @item #pragma implementation
15362 @itemx #pragma implementation "@var{objects}.h"
15363 @kindex #pragma implementation
15364 Use this pragma in a @emph{main input file}, when you want full output from
15365 included header files to be generated (and made globally visible). The
15366 included header file, in turn, should use @samp{#pragma interface}.
15367 Backup copies of inline member functions, debugging information, and the
15368 internal tables used to implement virtual functions are all generated in
15369 implementation files.
15370
15371 @cindex implied @code{#pragma implementation}
15372 @cindex @code{#pragma implementation}, implied
15373 @cindex naming convention, implementation headers
15374 If you use @samp{#pragma implementation} with no argument, it applies to
15375 an include file with the same basename@footnote{A file's @dfn{basename}
15376 is the name stripped of all leading path information and of trailing
15377 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
15378 file. For example, in @file{allclass.cc}, giving just
15379 @samp{#pragma implementation}
15380 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
15381
15382 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
15383 an implementation file whenever you would include it from
15384 @file{allclass.cc} even if you never specified @samp{#pragma
15385 implementation}. This was deemed to be more trouble than it was worth,
15386 however, and disabled.
15387
15388 Use the string argument if you want a single implementation file to
15389 include code from multiple header files. (You must also use
15390 @samp{#include} to include the header file; @samp{#pragma
15391 implementation} only specifies how to use the file---it doesn't actually
15392 include it.)
15393
15394 There is no way to split up the contents of a single header file into
15395 multiple implementation files.
15396 @end table
15397
15398 @cindex inlining and C++ pragmas
15399 @cindex C++ pragmas, effect on inlining
15400 @cindex pragmas in C++, effect on inlining
15401 @samp{#pragma implementation} and @samp{#pragma interface} also have an
15402 effect on function inlining.
15403
15404 If you define a class in a header file marked with @samp{#pragma
15405 interface}, the effect on an inline function defined in that class is
15406 similar to an explicit @code{extern} declaration---the compiler emits
15407 no code at all to define an independent version of the function. Its
15408 definition is used only for inlining with its callers.
15409
15410 @opindex fno-implement-inlines
15411 Conversely, when you include the same header file in a main source file
15412 that declares it as @samp{#pragma implementation}, the compiler emits
15413 code for the function itself; this defines a version of the function
15414 that can be found via pointers (or by callers compiled without
15415 inlining). If all calls to the function can be inlined, you can avoid
15416 emitting the function by compiling with @option{-fno-implement-inlines}.
15417 If any calls are not inlined, you will get linker errors.
15418
15419 @node Template Instantiation
15420 @section Where's the Template?
15421 @cindex template instantiation
15422
15423 C++ templates are the first language feature to require more
15424 intelligence from the environment than one usually finds on a UNIX
15425 system. Somehow the compiler and linker have to make sure that each
15426 template instance occurs exactly once in the executable if it is needed,
15427 and not at all otherwise. There are two basic approaches to this
15428 problem, which are referred to as the Borland model and the Cfront model.
15429
15430 @table @asis
15431 @item Borland model
15432 Borland C++ solved the template instantiation problem by adding the code
15433 equivalent of common blocks to their linker; the compiler emits template
15434 instances in each translation unit that uses them, and the linker
15435 collapses them together. The advantage of this model is that the linker
15436 only has to consider the object files themselves; there is no external
15437 complexity to worry about. This disadvantage is that compilation time
15438 is increased because the template code is being compiled repeatedly.
15439 Code written for this model tends to include definitions of all
15440 templates in the header file, since they must be seen to be
15441 instantiated.
15442
15443 @item Cfront model
15444 The AT&T C++ translator, Cfront, solved the template instantiation
15445 problem by creating the notion of a template repository, an
15446 automatically maintained place where template instances are stored. A
15447 more modern version of the repository works as follows: As individual
15448 object files are built, the compiler places any template definitions and
15449 instantiations encountered in the repository. At link time, the link
15450 wrapper adds in the objects in the repository and compiles any needed
15451 instances that were not previously emitted. The advantages of this
15452 model are more optimal compilation speed and the ability to use the
15453 system linker; to implement the Borland model a compiler vendor also
15454 needs to replace the linker. The disadvantages are vastly increased
15455 complexity, and thus potential for error; for some code this can be
15456 just as transparent, but in practice it can been very difficult to build
15457 multiple programs in one directory and one program in multiple
15458 directories. Code written for this model tends to separate definitions
15459 of non-inline member templates into a separate file, which should be
15460 compiled separately.
15461 @end table
15462
15463 When used with GNU ld version 2.8 or later on an ELF system such as
15464 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
15465 Borland model. On other systems, G++ implements neither automatic
15466 model.
15467
15468 You have the following options for dealing with template instantiations:
15469
15470 @enumerate
15471 @item
15472 @opindex frepo
15473 Compile your template-using code with @option{-frepo}. The compiler
15474 generates files with the extension @samp{.rpo} listing all of the
15475 template instantiations used in the corresponding object files which
15476 could be instantiated there; the link wrapper, @samp{collect2},
15477 then updates the @samp{.rpo} files to tell the compiler where to place
15478 those instantiations and rebuild any affected object files. The
15479 link-time overhead is negligible after the first pass, as the compiler
15480 continues to place the instantiations in the same files.
15481
15482 This is your best option for application code written for the Borland
15483 model, as it just works. Code written for the Cfront model
15484 needs to be modified so that the template definitions are available at
15485 one or more points of instantiation; usually this is as simple as adding
15486 @code{#include <tmethods.cc>} to the end of each template header.
15487
15488 For library code, if you want the library to provide all of the template
15489 instantiations it needs, just try to link all of its object files
15490 together; the link will fail, but cause the instantiations to be
15491 generated as a side effect. Be warned, however, that this may cause
15492 conflicts if multiple libraries try to provide the same instantiations.
15493 For greater control, use explicit instantiation as described in the next
15494 option.
15495
15496 @item
15497 @opindex fno-implicit-templates
15498 Compile your code with @option{-fno-implicit-templates} to disable the
15499 implicit generation of template instances, and explicitly instantiate
15500 all the ones you use. This approach requires more knowledge of exactly
15501 which instances you need than do the others, but it's less
15502 mysterious and allows greater control. You can scatter the explicit
15503 instantiations throughout your program, perhaps putting them in the
15504 translation units where the instances are used or the translation units
15505 that define the templates themselves; you can put all of the explicit
15506 instantiations you need into one big file; or you can create small files
15507 like
15508
15509 @smallexample
15510 #include "Foo.h"
15511 #include "Foo.cc"
15512
15513 template class Foo<int>;
15514 template ostream& operator <<
15515 (ostream&, const Foo<int>&);
15516 @end smallexample
15517
15518 for each of the instances you need, and create a template instantiation
15519 library from those.
15520
15521 If you are using Cfront-model code, you can probably get away with not
15522 using @option{-fno-implicit-templates} when compiling files that don't
15523 @samp{#include} the member template definitions.
15524
15525 If you use one big file to do the instantiations, you may want to
15526 compile it without @option{-fno-implicit-templates} so you get all of the
15527 instances required by your explicit instantiations (but not by any
15528 other files) without having to specify them as well.
15529
15530 The ISO C++ 2011 standard allows forward declaration of explicit
15531 instantiations (with @code{extern}). G++ supports explicit instantiation
15532 declarations in C++98 mode and has extended the template instantiation
15533 syntax to support instantiation of the compiler support data for a
15534 template class (i.e.@: the vtable) without instantiating any of its
15535 members (with @code{inline}), and instantiation of only the static data
15536 members of a template class, without the support data or member
15537 functions (with (@code{static}):
15538
15539 @smallexample
15540 extern template int max (int, int);
15541 inline template class Foo<int>;
15542 static template class Foo<int>;
15543 @end smallexample
15544
15545 @item
15546 Do nothing. Pretend G++ does implement automatic instantiation
15547 management. Code written for the Borland model works fine, but
15548 each translation unit contains instances of each of the templates it
15549 uses. In a large program, this can lead to an unacceptable amount of code
15550 duplication.
15551 @end enumerate
15552
15553 @node Bound member functions
15554 @section Extracting the function pointer from a bound pointer to member function
15555 @cindex pmf
15556 @cindex pointer to member function
15557 @cindex bound pointer to member function
15558
15559 In C++, pointer to member functions (PMFs) are implemented using a wide
15560 pointer of sorts to handle all the possible call mechanisms; the PMF
15561 needs to store information about how to adjust the @samp{this} pointer,
15562 and if the function pointed to is virtual, where to find the vtable, and
15563 where in the vtable to look for the member function. If you are using
15564 PMFs in an inner loop, you should really reconsider that decision. If
15565 that is not an option, you can extract the pointer to the function that
15566 would be called for a given object/PMF pair and call it directly inside
15567 the inner loop, to save a bit of time.
15568
15569 Note that you still pay the penalty for the call through a
15570 function pointer; on most modern architectures, such a call defeats the
15571 branch prediction features of the CPU@. This is also true of normal
15572 virtual function calls.
15573
15574 The syntax for this extension is
15575
15576 @smallexample
15577 extern A a;
15578 extern int (A::*fp)();
15579 typedef int (*fptr)(A *);
15580
15581 fptr p = (fptr)(a.*fp);
15582 @end smallexample
15583
15584 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
15585 no object is needed to obtain the address of the function. They can be
15586 converted to function pointers directly:
15587
15588 @smallexample
15589 fptr p1 = (fptr)(&A::foo);
15590 @end smallexample
15591
15592 @opindex Wno-pmf-conversions
15593 You must specify @option{-Wno-pmf-conversions} to use this extension.
15594
15595 @node C++ Attributes
15596 @section C++-Specific Variable, Function, and Type Attributes
15597
15598 Some attributes only make sense for C++ programs.
15599
15600 @table @code
15601 @item abi_tag ("@var{tag}", ...)
15602 @cindex @code{abi_tag} attribute
15603 The @code{abi_tag} attribute can be applied to a function or class
15604 declaration. It modifies the mangled name of the function or class to
15605 incorporate the tag name, in order to distinguish the function or
15606 class from an earlier version with a different ABI; perhaps the class
15607 has changed size, or the function has a different return type that is
15608 not encoded in the mangled name.
15609
15610 The argument can be a list of strings of arbitrary length. The
15611 strings are sorted on output, so the order of the list is
15612 unimportant.
15613
15614 A redeclaration of a function or class must not add new ABI tags,
15615 since doing so would change the mangled name.
15616
15617 The @option{-Wabi-tag} flag enables a warning about a class which does
15618 not have all the ABI tags used by its subobjects; for users with code
15619 that needs to coexist with an earlier ABI, using this option can help
15620 to find all affected types that need to be tagged.
15621
15622 @item init_priority (@var{priority})
15623 @cindex @code{init_priority} attribute
15624
15625
15626 In Standard C++, objects defined at namespace scope are guaranteed to be
15627 initialized in an order in strict accordance with that of their definitions
15628 @emph{in a given translation unit}. No guarantee is made for initializations
15629 across translation units. However, GNU C++ allows users to control the
15630 order of initialization of objects defined at namespace scope with the
15631 @code{init_priority} attribute by specifying a relative @var{priority},
15632 a constant integral expression currently bounded between 101 and 65535
15633 inclusive. Lower numbers indicate a higher priority.
15634
15635 In the following example, @code{A} would normally be created before
15636 @code{B}, but the @code{init_priority} attribute reverses that order:
15637
15638 @smallexample
15639 Some_Class A __attribute__ ((init_priority (2000)));
15640 Some_Class B __attribute__ ((init_priority (543)));
15641 @end smallexample
15642
15643 @noindent
15644 Note that the particular values of @var{priority} do not matter; only their
15645 relative ordering.
15646
15647 @item java_interface
15648 @cindex @code{java_interface} attribute
15649
15650 This type attribute informs C++ that the class is a Java interface. It may
15651 only be applied to classes declared within an @code{extern "Java"} block.
15652 Calls to methods declared in this interface are dispatched using GCJ's
15653 interface table mechanism, instead of regular virtual table dispatch.
15654
15655 @end table
15656
15657 See also @ref{Namespace Association}.
15658
15659 @node Namespace Association
15660 @section Namespace Association
15661
15662 @strong{Caution:} The semantics of this extension are equivalent
15663 to C++ 2011 inline namespaces. Users should use inline namespaces
15664 instead as this extension will be removed in future versions of G++.
15665
15666 A using-directive with @code{__attribute ((strong))} is stronger
15667 than a normal using-directive in two ways:
15668
15669 @itemize @bullet
15670 @item
15671 Templates from the used namespace can be specialized and explicitly
15672 instantiated as though they were members of the using namespace.
15673
15674 @item
15675 The using namespace is considered an associated namespace of all
15676 templates in the used namespace for purposes of argument-dependent
15677 name lookup.
15678 @end itemize
15679
15680 The used namespace must be nested within the using namespace so that
15681 normal unqualified lookup works properly.
15682
15683 This is useful for composing a namespace transparently from
15684 implementation namespaces. For example:
15685
15686 @smallexample
15687 namespace std @{
15688 namespace debug @{
15689 template <class T> struct A @{ @};
15690 @}
15691 using namespace debug __attribute ((__strong__));
15692 template <> struct A<int> @{ @}; // @r{ok to specialize}
15693
15694 template <class T> void f (A<T>);
15695 @}
15696
15697 int main()
15698 @{
15699 f (std::A<float>()); // @r{lookup finds} std::f
15700 f (std::A<int>());
15701 @}
15702 @end smallexample
15703
15704 @node Type Traits
15705 @section Type Traits
15706
15707 The C++ front-end implements syntactic extensions that allow to
15708 determine at compile time various characteristics of a type (or of a
15709 pair of types).
15710
15711 @table @code
15712 @item __has_nothrow_assign (type)
15713 If @code{type} is const qualified or is a reference type then the trait is
15714 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
15715 is true, else if @code{type} is a cv class or union type with copy assignment
15716 operators that are known not to throw an exception then the trait is true,
15717 else it is false. Requires: @code{type} shall be a complete type,
15718 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15719
15720 @item __has_nothrow_copy (type)
15721 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
15722 @code{type} is a cv class or union type with copy constructors that
15723 are known not to throw an exception then the trait is true, else it is false.
15724 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
15725 @code{void}, or an array of unknown bound.
15726
15727 @item __has_nothrow_constructor (type)
15728 If @code{__has_trivial_constructor (type)} is true then the trait is
15729 true, else if @code{type} is a cv class or union type (or array
15730 thereof) with a default constructor that is known not to throw an
15731 exception then the trait is true, else it is false. Requires:
15732 @code{type} shall be a complete type, (possibly cv-qualified)
15733 @code{void}, or an array of unknown bound.
15734
15735 @item __has_trivial_assign (type)
15736 If @code{type} is const qualified or is a reference type then the trait is
15737 false. Otherwise if @code{__is_pod (type)} is true then the trait is
15738 true, else if @code{type} is a cv class or union type with a trivial
15739 copy assignment ([class.copy]) then the trait is true, else it is
15740 false. Requires: @code{type} shall be a complete type, (possibly
15741 cv-qualified) @code{void}, or an array of unknown bound.
15742
15743 @item __has_trivial_copy (type)
15744 If @code{__is_pod (type)} is true or @code{type} is a reference type
15745 then the trait is true, else if @code{type} is a cv class or union type
15746 with a trivial copy constructor ([class.copy]) then the trait
15747 is true, else it is false. Requires: @code{type} shall be a complete
15748 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15749
15750 @item __has_trivial_constructor (type)
15751 If @code{__is_pod (type)} is true then the trait is true, else if
15752 @code{type} is a cv class or union type (or array thereof) with a
15753 trivial default constructor ([class.ctor]) then the trait is true,
15754 else it is false. Requires: @code{type} shall be a complete
15755 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15756
15757 @item __has_trivial_destructor (type)
15758 If @code{__is_pod (type)} is true or @code{type} is a reference type then
15759 the trait is true, else if @code{type} is a cv class or union type (or
15760 array thereof) with a trivial destructor ([class.dtor]) then the trait
15761 is true, else it is false. Requires: @code{type} shall be a complete
15762 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15763
15764 @item __has_virtual_destructor (type)
15765 If @code{type} is a class type with a virtual destructor
15766 ([class.dtor]) then the trait is true, else it is false. Requires:
15767 @code{type} shall be a complete type, (possibly cv-qualified)
15768 @code{void}, or an array of unknown bound.
15769
15770 @item __is_abstract (type)
15771 If @code{type} is an abstract class ([class.abstract]) then the trait
15772 is true, else it is false. Requires: @code{type} shall be a complete
15773 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15774
15775 @item __is_base_of (base_type, derived_type)
15776 If @code{base_type} is a base class of @code{derived_type}
15777 ([class.derived]) then the trait is true, otherwise it is false.
15778 Top-level cv qualifications of @code{base_type} and
15779 @code{derived_type} are ignored. For the purposes of this trait, a
15780 class type is considered is own base. Requires: if @code{__is_class
15781 (base_type)} and @code{__is_class (derived_type)} are true and
15782 @code{base_type} and @code{derived_type} are not the same type
15783 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
15784 type. Diagnostic is produced if this requirement is not met.
15785
15786 @item __is_class (type)
15787 If @code{type} is a cv class type, and not a union type
15788 ([basic.compound]) the trait is true, else it is false.
15789
15790 @item __is_empty (type)
15791 If @code{__is_class (type)} is false then the trait is false.
15792 Otherwise @code{type} is considered empty if and only if: @code{type}
15793 has no non-static data members, or all non-static data members, if
15794 any, are bit-fields of length 0, and @code{type} has no virtual
15795 members, and @code{type} has no virtual base classes, and @code{type}
15796 has no base classes @code{base_type} for which
15797 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
15798 be a complete type, (possibly cv-qualified) @code{void}, or an array
15799 of unknown bound.
15800
15801 @item __is_enum (type)
15802 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
15803 true, else it is false.
15804
15805 @item __is_literal_type (type)
15806 If @code{type} is a literal type ([basic.types]) the trait is
15807 true, else it is false. Requires: @code{type} shall be a complete type,
15808 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15809
15810 @item __is_pod (type)
15811 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
15812 else it is false. Requires: @code{type} shall be a complete type,
15813 (possibly cv-qualified) @code{void}, or an array of unknown bound.
15814
15815 @item __is_polymorphic (type)
15816 If @code{type} is a polymorphic class ([class.virtual]) then the trait
15817 is true, else it is false. Requires: @code{type} shall be a complete
15818 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15819
15820 @item __is_standard_layout (type)
15821 If @code{type} is a standard-layout type ([basic.types]) the trait is
15822 true, else it is false. Requires: @code{type} shall be a complete
15823 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15824
15825 @item __is_trivial (type)
15826 If @code{type} is a trivial type ([basic.types]) the trait is
15827 true, else it is false. Requires: @code{type} shall be a complete
15828 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
15829
15830 @item __is_union (type)
15831 If @code{type} is a cv union type ([basic.compound]) the trait is
15832 true, else it is false.
15833
15834 @item __underlying_type (type)
15835 The underlying type of @code{type}. Requires: @code{type} shall be
15836 an enumeration type ([dcl.enum]).
15837
15838 @end table
15839
15840 @node Java Exceptions
15841 @section Java Exceptions
15842
15843 The Java language uses a slightly different exception handling model
15844 from C++. Normally, GNU C++ automatically detects when you are
15845 writing C++ code that uses Java exceptions, and handle them
15846 appropriately. However, if C++ code only needs to execute destructors
15847 when Java exceptions are thrown through it, GCC guesses incorrectly.
15848 Sample problematic code is:
15849
15850 @smallexample
15851 struct S @{ ~S(); @};
15852 extern void bar(); // @r{is written in Java, and may throw exceptions}
15853 void foo()
15854 @{
15855 S s;
15856 bar();
15857 @}
15858 @end smallexample
15859
15860 @noindent
15861 The usual effect of an incorrect guess is a link failure, complaining of
15862 a missing routine called @samp{__gxx_personality_v0}.
15863
15864 You can inform the compiler that Java exceptions are to be used in a
15865 translation unit, irrespective of what it might think, by writing
15866 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
15867 @samp{#pragma} must appear before any functions that throw or catch
15868 exceptions, or run destructors when exceptions are thrown through them.
15869
15870 You cannot mix Java and C++ exceptions in the same translation unit. It
15871 is believed to be safe to throw a C++ exception from one file through
15872 another file compiled for the Java exception model, or vice versa, but
15873 there may be bugs in this area.
15874
15875 @node Deprecated Features
15876 @section Deprecated Features
15877
15878 In the past, the GNU C++ compiler was extended to experiment with new
15879 features, at a time when the C++ language was still evolving. Now that
15880 the C++ standard is complete, some of those features are superseded by
15881 superior alternatives. Using the old features might cause a warning in
15882 some cases that the feature will be dropped in the future. In other
15883 cases, the feature might be gone already.
15884
15885 While the list below is not exhaustive, it documents some of the options
15886 that are now deprecated:
15887
15888 @table @code
15889 @item -fexternal-templates
15890 @itemx -falt-external-templates
15891 These are two of the many ways for G++ to implement template
15892 instantiation. @xref{Template Instantiation}. The C++ standard clearly
15893 defines how template definitions have to be organized across
15894 implementation units. G++ has an implicit instantiation mechanism that
15895 should work just fine for standard-conforming code.
15896
15897 @item -fstrict-prototype
15898 @itemx -fno-strict-prototype
15899 Previously it was possible to use an empty prototype parameter list to
15900 indicate an unspecified number of parameters (like C), rather than no
15901 parameters, as C++ demands. This feature has been removed, except where
15902 it is required for backwards compatibility. @xref{Backwards Compatibility}.
15903 @end table
15904
15905 G++ allows a virtual function returning @samp{void *} to be overridden
15906 by one returning a different pointer type. This extension to the
15907 covariant return type rules is now deprecated and will be removed from a
15908 future version.
15909
15910 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
15911 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
15912 and are now removed from G++. Code using these operators should be
15913 modified to use @code{std::min} and @code{std::max} instead.
15914
15915 The named return value extension has been deprecated, and is now
15916 removed from G++.
15917
15918 The use of initializer lists with new expressions has been deprecated,
15919 and is now removed from G++.
15920
15921 Floating and complex non-type template parameters have been deprecated,
15922 and are now removed from G++.
15923
15924 The implicit typename extension has been deprecated and is now
15925 removed from G++.
15926
15927 The use of default arguments in function pointers, function typedefs
15928 and other places where they are not permitted by the standard is
15929 deprecated and will be removed from a future version of G++.
15930
15931 G++ allows floating-point literals to appear in integral constant expressions,
15932 e.g. @samp{ enum E @{ e = int(2.2 * 3.7) @} }
15933 This extension is deprecated and will be removed from a future version.
15934
15935 G++ allows static data members of const floating-point type to be declared
15936 with an initializer in a class definition. The standard only allows
15937 initializers for static members of const integral types and const
15938 enumeration types so this extension has been deprecated and will be removed
15939 from a future version.
15940
15941 @node Backwards Compatibility
15942 @section Backwards Compatibility
15943 @cindex Backwards Compatibility
15944 @cindex ARM [Annotated C++ Reference Manual]
15945
15946 Now that there is a definitive ISO standard C++, G++ has a specification
15947 to adhere to. The C++ language evolved over time, and features that
15948 used to be acceptable in previous drafts of the standard, such as the ARM
15949 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
15950 compilation of C++ written to such drafts, G++ contains some backwards
15951 compatibilities. @emph{All such backwards compatibility features are
15952 liable to disappear in future versions of G++.} They should be considered
15953 deprecated. @xref{Deprecated Features}.
15954
15955 @table @code
15956 @item For scope
15957 If a variable is declared at for scope, it used to remain in scope until
15958 the end of the scope which contained the for statement (rather than just
15959 within the for scope). G++ retains this, but issues a warning, if such a
15960 variable is accessed outside the for scope.
15961
15962 @item Implicit C language
15963 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
15964 scope to set the language. On such systems, all header files are
15965 implicitly scoped inside a C language scope. Also, an empty prototype
15966 @code{()} is treated as an unspecified number of arguments, rather
15967 than no arguments, as C++ demands.
15968 @end table