]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
extend.texi (PowerPC AltiVec/VSX Built-in Functions): Document new power8 builtins.
[thirdparty/gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2013 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Initializers:: Non-constant initializers.
50 * Compound Literals:: Compound literals give structures, unions
51 or arrays as values.
52 * Designated Inits:: Labeling elements of initializers.
53 * Case Ranges:: `case 1 ... 9' and such.
54 * Cast to Union:: Casting to union type from any member of the union.
55 * Mixed Declarations:: Mixing declarations and code.
56 * Function Attributes:: Declaring that functions have no side effects,
57 or that they can never return.
58 * Attribute Syntax:: Formal syntax for attributes.
59 * Function Prototypes:: Prototype declarations and old-style definitions.
60 * C++ Comments:: C++ comments are recognized.
61 * Dollar Signs:: Dollar sign is allowed in identifiers.
62 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes:: Specifying attributes of types.
65 * Alignment:: Inquiring about the alignment of a type or variable.
66 * Inline:: Defining inline functions (as fast as macros).
67 * Volatiles:: What constitutes an access to a volatile object.
68 * Extended Asm:: Assembler instructions with C expressions as operands.
69 (With them you can define ``built-in'' functions.)
70 * Constraints:: Constraints for asm operands
71 * Asm Labels:: Specifying the assembler name to use for a C symbol.
72 * Explicit Reg Vars:: Defining variables residing in specified registers.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
76 function.
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * x86 specific memory model extensions for transactional memory:: x86 memory models.
83 * Object Size Checking:: Built-in functions for limited buffer overflow
84 checking.
85 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
86 * Other Builtins:: Other built-in functions.
87 * Target Builtins:: Built-in functions specific to particular targets.
88 * Target Format Checks:: Format checks specific to particular targets.
89 * Pragmas:: Pragmas accepted by GCC.
90 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
91 * Thread-Local:: Per-thread variables.
92 * Binary constants:: Binary constants using the @samp{0b} prefix.
93 @end menu
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 In a statement expression, any temporaries created within a statement
174 are destroyed at that statement's end. This makes statement
175 expressions inside macros slightly different from function calls. In
176 the latter case temporaries introduced during argument evaluation are
177 destroyed at the end of the statement that includes the function
178 call. In the statement expression case they are destroyed during
179 the statement expression. For instance,
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 expressions 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}) has undefined behavior.
209 Jumping out of a statement expression is permitted, but if the
210 statement expression is part of a larger expression then it is
211 unspecified which other subexpressions of that expression have been
212 evaluated except where the language definition requires certain
213 subexpressions to be evaluated before or after the statement
214 expression. In any case, as with a function call, the evaluation of a
215 statement expression is not interleaved with the evaluation of other
216 parts of the containing expression. For example,
217
218 @smallexample
219 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
220 @end smallexample
221
222 @noindent
223 calls @code{foo} and @code{bar1} and does not call @code{baz} but
224 may or may not call @code{bar2}. If @code{bar2} is called, it is
225 called after @code{foo} and before @code{bar1}.
226
227 @node Local Labels
228 @section Locally Declared Labels
229 @cindex local labels
230 @cindex macros, local labels
231
232 GCC allows you to declare @dfn{local labels} in any nested block
233 scope. A local label is just like an ordinary label, but you can
234 only reference it (with a @code{goto} statement, or by taking its
235 address) within the block in which it is declared.
236
237 A local label declaration looks like this:
238
239 @smallexample
240 __label__ @var{label};
241 @end smallexample
242
243 @noindent
244 or
245
246 @smallexample
247 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
248 @end smallexample
249
250 Local label declarations must come at the beginning of the block,
251 before any ordinary declarations or statements.
252
253 The label declaration defines the label @emph{name}, but does not define
254 the label itself. You must do this in the usual way, with
255 @code{@var{label}:}, within the statements of the statement expression.
256
257 The local label feature is useful for complex macros. If a macro
258 contains nested loops, a @code{goto} can be useful for breaking out of
259 them. However, an ordinary label whose scope is the whole function
260 cannot be used: if the macro can be expanded several times in one
261 function, the label is multiply defined in that function. A
262 local label avoids this problem. For example:
263
264 @smallexample
265 #define SEARCH(value, array, target) \
266 do @{ \
267 __label__ found; \
268 typeof (target) _SEARCH_target = (target); \
269 typeof (*(array)) *_SEARCH_array = (array); \
270 int i, j; \
271 int value; \
272 for (i = 0; i < max; i++) \
273 for (j = 0; j < max; j++) \
274 if (_SEARCH_array[i][j] == _SEARCH_target) \
275 @{ (value) = i; goto found; @} \
276 (value) = -1; \
277 found:; \
278 @} while (0)
279 @end smallexample
280
281 This could also be written using a statement expression:
282
283 @smallexample
284 #define SEARCH(array, target) \
285 (@{ \
286 __label__ found; \
287 typeof (target) _SEARCH_target = (target); \
288 typeof (*(array)) *_SEARCH_array = (array); \
289 int i, j; \
290 int value; \
291 for (i = 0; i < max; i++) \
292 for (j = 0; j < max; j++) \
293 if (_SEARCH_array[i][j] == _SEARCH_target) \
294 @{ value = i; goto found; @} \
295 value = -1; \
296 found: \
297 value; \
298 @})
299 @end smallexample
300
301 Local label declarations also make the labels they declare visible to
302 nested functions, if there are any. @xref{Nested Functions}, for details.
303
304 @node Labels as Values
305 @section Labels as Values
306 @cindex labels as values
307 @cindex computed gotos
308 @cindex goto with computed label
309 @cindex address of a label
310
311 You can get the address of a label defined in the current function
312 (or a containing function) with the unary operator @samp{&&}. The
313 value has type @code{void *}. This value is a constant and can be used
314 wherever a constant of that type is valid. For example:
315
316 @smallexample
317 void *ptr;
318 /* @r{@dots{}} */
319 ptr = &&foo;
320 @end smallexample
321
322 To use these values, you need to be able to jump to one. This is done
323 with the computed goto statement@footnote{The analogous feature in
324 Fortran is called an assigned goto, but that name seems inappropriate in
325 C, where one can do more than simply store label addresses in label
326 variables.}, @code{goto *@var{exp};}. For example,
327
328 @smallexample
329 goto *ptr;
330 @end smallexample
331
332 @noindent
333 Any expression of type @code{void *} is allowed.
334
335 One way of using these constants is in initializing a static array that
336 serves as a jump table:
337
338 @smallexample
339 static void *array[] = @{ &&foo, &&bar, &&hack @};
340 @end smallexample
341
342 @noindent
343 Then you can select a label with indexing, like this:
344
345 @smallexample
346 goto *array[i];
347 @end smallexample
348
349 @noindent
350 Note that this does not check whether the subscript is in bounds---array
351 indexing in C never does that.
352
353 Such an array of label values serves a purpose much like that of the
354 @code{switch} statement. The @code{switch} statement is cleaner, so
355 use that rather than an array unless the problem does not fit a
356 @code{switch} statement very well.
357
358 Another use of label values is in an interpreter for threaded code.
359 The labels within the interpreter function can be stored in the
360 threaded code for super-fast dispatching.
361
362 You may not use this mechanism to jump to code in a different function.
363 If you do that, totally unpredictable things happen. The best way to
364 avoid this is to store the label address only in automatic variables and
365 never pass it as an argument.
366
367 An alternate way to write the above example is
368
369 @smallexample
370 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
371 &&hack - &&foo @};
372 goto *(&&foo + array[i]);
373 @end smallexample
374
375 @noindent
376 This is more friendly to code living in shared libraries, as it reduces
377 the number of dynamic relocations that are needed, and by consequence,
378 allows the data to be read-only.
379
380 The @code{&&foo} expressions for the same label might have different
381 values if the containing function is inlined or cloned. If a program
382 relies on them being always the same,
383 @code{__attribute__((__noinline__,__noclone__))} should be used to
384 prevent inlining and cloning. If @code{&&foo} is used in a static
385 variable initializer, inlining and cloning is forbidden.
386
387 @node Nested Functions
388 @section Nested Functions
389 @cindex nested functions
390 @cindex downward funargs
391 @cindex thunks
392
393 A @dfn{nested function} is a function defined inside another function.
394 Nested functions are supported as an extension in GNU C, but are not
395 supported by GNU C++.
396
397 The nested function's name is local to the block where it is defined.
398 For example, here we define a nested function named @code{square}, and
399 call it twice:
400
401 @smallexample
402 @group
403 foo (double a, double b)
404 @{
405 double square (double z) @{ return z * z; @}
406
407 return square (a) + square (b);
408 @}
409 @end group
410 @end smallexample
411
412 The nested function can access all the variables of the containing
413 function that are visible at the point of its definition. This is
414 called @dfn{lexical scoping}. For example, here we show a nested
415 function which uses an inherited variable named @code{offset}:
416
417 @smallexample
418 @group
419 bar (int *array, int offset, int size)
420 @{
421 int access (int *array, int index)
422 @{ return array[index + offset]; @}
423 int i;
424 /* @r{@dots{}} */
425 for (i = 0; i < size; i++)
426 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
427 @}
428 @end group
429 @end smallexample
430
431 Nested function definitions are permitted within functions in the places
432 where variable definitions are allowed; that is, in any block, mixed
433 with the other declarations and statements in the block.
434
435 It is possible to call the nested function from outside the scope of its
436 name by storing its address or passing the address to another function:
437
438 @smallexample
439 hack (int *array, int size)
440 @{
441 void store (int index, int value)
442 @{ array[index] = value; @}
443
444 intermediate (store, size);
445 @}
446 @end smallexample
447
448 Here, the function @code{intermediate} receives the address of
449 @code{store} as an argument. If @code{intermediate} calls @code{store},
450 the arguments given to @code{store} are used to store into @code{array}.
451 But this technique works only so long as the containing function
452 (@code{hack}, in this example) does not exit.
453
454 If you try to call the nested function through its address after the
455 containing function exits, all hell breaks loose. If you try
456 to call it after a containing scope level exits, and if it refers
457 to some of the variables that are no longer in scope, you may be lucky,
458 but it's not wise to take the risk. If, however, the nested function
459 does not refer to anything that has gone out of scope, you should be
460 safe.
461
462 GCC implements taking the address of a nested function using a technique
463 called @dfn{trampolines}. This technique was described in
464 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
465 C++ Conference Proceedings, October 17-21, 1988).
466
467 A nested function can jump to a label inherited from a containing
468 function, provided the label is explicitly declared in the containing
469 function (@pxref{Local Labels}). Such a jump returns instantly to the
470 containing function, exiting the nested function that did the
471 @code{goto} and any intermediate functions as well. Here is an example:
472
473 @smallexample
474 @group
475 bar (int *array, int offset, int size)
476 @{
477 __label__ failure;
478 int access (int *array, int index)
479 @{
480 if (index > size)
481 goto failure;
482 return array[index + offset];
483 @}
484 int i;
485 /* @r{@dots{}} */
486 for (i = 0; i < size; i++)
487 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
488 /* @r{@dots{}} */
489 return 0;
490
491 /* @r{Control comes here from @code{access}
492 if it detects an error.} */
493 failure:
494 return -1;
495 @}
496 @end group
497 @end smallexample
498
499 A nested function always has no linkage. Declaring one with
500 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
501 before its definition, use @code{auto} (which is otherwise meaningless
502 for function declarations).
503
504 @smallexample
505 bar (int *array, int offset, int size)
506 @{
507 __label__ failure;
508 auto int access (int *, int);
509 /* @r{@dots{}} */
510 int access (int *array, int index)
511 @{
512 if (index > size)
513 goto failure;
514 return array[index + offset];
515 @}
516 /* @r{@dots{}} */
517 @}
518 @end smallexample
519
520 @node Constructing Calls
521 @section Constructing Function Calls
522 @cindex constructing calls
523 @cindex forwarding calls
524
525 Using the built-in functions described below, you can record
526 the arguments a function received, and call another function
527 with the same arguments, without knowing the number or types
528 of the arguments.
529
530 You can also record the return value of that function call,
531 and later return that value, without knowing what data type
532 the function tried to return (as long as your caller expects
533 that data type).
534
535 However, these built-in functions may interact badly with some
536 sophisticated features or other extensions of the language. It
537 is, therefore, not recommended to use them outside very simple
538 functions acting as mere forwarders for their arguments.
539
540 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
541 This built-in function returns a pointer to data
542 describing how to perform a call with the same arguments as are passed
543 to the current function.
544
545 The function saves the arg pointer register, structure value address,
546 and all registers that might be used to pass arguments to a function
547 into a block of memory allocated on the stack. Then it returns the
548 address of that block.
549 @end deftypefn
550
551 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
552 This built-in function invokes @var{function}
553 with a copy of the parameters described by @var{arguments}
554 and @var{size}.
555
556 The value of @var{arguments} should be the value returned by
557 @code{__builtin_apply_args}. The argument @var{size} specifies the size
558 of the stack argument data, in bytes.
559
560 This function returns a pointer to data describing
561 how to return whatever value is returned by @var{function}. The data
562 is saved in a block of memory allocated on the stack.
563
564 It is not always simple to compute the proper value for @var{size}. The
565 value is used by @code{__builtin_apply} to compute the amount of data
566 that should be pushed on the stack and copied from the incoming argument
567 area.
568 @end deftypefn
569
570 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
571 This built-in function returns the value described by @var{result} from
572 the containing function. You should specify, for @var{result}, a value
573 returned by @code{__builtin_apply}.
574 @end deftypefn
575
576 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
577 This built-in function represents all anonymous arguments of an inline
578 function. It can be used only in inline functions that are always
579 inlined, never compiled as a separate function, such as those using
580 @code{__attribute__ ((__always_inline__))} or
581 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
582 It must be only passed as last argument to some other function
583 with variable arguments. This is useful for writing small wrapper
584 inlines for variable argument functions, when using preprocessor
585 macros is undesirable. For example:
586 @smallexample
587 extern int myprintf (FILE *f, const char *format, ...);
588 extern inline __attribute__ ((__gnu_inline__)) int
589 myprintf (FILE *f, const char *format, ...)
590 @{
591 int r = fprintf (f, "myprintf: ");
592 if (r < 0)
593 return r;
594 int s = fprintf (f, format, __builtin_va_arg_pack ());
595 if (s < 0)
596 return s;
597 return r + s;
598 @}
599 @end smallexample
600 @end deftypefn
601
602 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
603 This built-in function returns the number of anonymous arguments of
604 an inline function. It can be used only in inline functions that
605 are always inlined, never compiled as a separate function, such
606 as those using @code{__attribute__ ((__always_inline__))} or
607 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
608 For example following does link- or run-time checking of open
609 arguments for optimized code:
610 @smallexample
611 #ifdef __OPTIMIZE__
612 extern inline __attribute__((__gnu_inline__)) int
613 myopen (const char *path, int oflag, ...)
614 @{
615 if (__builtin_va_arg_pack_len () > 1)
616 warn_open_too_many_arguments ();
617
618 if (__builtin_constant_p (oflag))
619 @{
620 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
621 @{
622 warn_open_missing_mode ();
623 return __open_2 (path, oflag);
624 @}
625 return open (path, oflag, __builtin_va_arg_pack ());
626 @}
627
628 if (__builtin_va_arg_pack_len () < 1)
629 return __open_2 (path, oflag);
630
631 return open (path, oflag, __builtin_va_arg_pack ());
632 @}
633 #endif
634 @end smallexample
635 @end deftypefn
636
637 @node Typeof
638 @section Referring to a Type with @code{typeof}
639 @findex typeof
640 @findex sizeof
641 @cindex macros, types of arguments
642
643 Another way to refer to the type of an expression is with @code{typeof}.
644 The syntax of using of this keyword looks like @code{sizeof}, but the
645 construct acts semantically like a type name defined with @code{typedef}.
646
647 There are two ways of writing the argument to @code{typeof}: with an
648 expression or with a type. Here is an example with an expression:
649
650 @smallexample
651 typeof (x[0](1))
652 @end smallexample
653
654 @noindent
655 This assumes that @code{x} is an array of pointers to functions;
656 the type described is that of the values of the functions.
657
658 Here is an example with a typename as the argument:
659
660 @smallexample
661 typeof (int *)
662 @end smallexample
663
664 @noindent
665 Here the type described is that of pointers to @code{int}.
666
667 If you are writing a header file that must work when included in ISO C
668 programs, write @code{__typeof__} instead of @code{typeof}.
669 @xref{Alternate Keywords}.
670
671 A @code{typeof} construct can be used anywhere a typedef name can be
672 used. For example, you can use it in a declaration, in a cast, or inside
673 of @code{sizeof} or @code{typeof}.
674
675 The operand of @code{typeof} is evaluated for its side effects if and
676 only if it is an expression of variably modified type or the name of
677 such a type.
678
679 @code{typeof} is often useful in conjunction with
680 statement expressions (@pxref{Statement Exprs}).
681 Here is how the two together can
682 be used to define a safe ``maximum'' macro which operates on any
683 arithmetic type and evaluates each of its arguments exactly once:
684
685 @smallexample
686 #define max(a,b) \
687 (@{ typeof (a) _a = (a); \
688 typeof (b) _b = (b); \
689 _a > _b ? _a : _b; @})
690 @end smallexample
691
692 @cindex underscores in variables in macros
693 @cindex @samp{_} in variables in macros
694 @cindex local variables in macros
695 @cindex variables, local, in macros
696 @cindex macros, local variables in
697
698 The reason for using names that start with underscores for the local
699 variables is to avoid conflicts with variable names that occur within the
700 expressions that are substituted for @code{a} and @code{b}. Eventually we
701 hope to design a new form of declaration syntax that allows you to declare
702 variables whose scopes start only after their initializers; this will be a
703 more reliable way to prevent such conflicts.
704
705 @noindent
706 Some more examples of the use of @code{typeof}:
707
708 @itemize @bullet
709 @item
710 This declares @code{y} with the type of what @code{x} points to.
711
712 @smallexample
713 typeof (*x) y;
714 @end smallexample
715
716 @item
717 This declares @code{y} as an array of such values.
718
719 @smallexample
720 typeof (*x) y[4];
721 @end smallexample
722
723 @item
724 This declares @code{y} as an array of pointers to characters:
725
726 @smallexample
727 typeof (typeof (char *)[4]) y;
728 @end smallexample
729
730 @noindent
731 It is equivalent to the following traditional C declaration:
732
733 @smallexample
734 char *y[4];
735 @end smallexample
736
737 To see the meaning of the declaration using @code{typeof}, and why it
738 might be a useful way to write, rewrite it with these macros:
739
740 @smallexample
741 #define pointer(T) typeof(T *)
742 #define array(T, N) typeof(T [N])
743 @end smallexample
744
745 @noindent
746 Now the declaration can be rewritten this way:
747
748 @smallexample
749 array (pointer (char), 4) y;
750 @end smallexample
751
752 @noindent
753 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
754 pointers to @code{char}.
755 @end itemize
756
757 @emph{Compatibility Note:} In addition to @code{typeof}, GCC 2 supported
758 a more limited extension that permitted one to write
759
760 @smallexample
761 typedef @var{T} = @var{expr};
762 @end smallexample
763
764 @noindent
765 with the effect of declaring @var{T} to have the type of the expression
766 @var{expr}. This extension does not work with GCC 3 (versions between
767 3.0 and 3.2 crash; 3.2.1 and later give an error). Code that
768 relies on it should be rewritten to use @code{typeof}:
769
770 @smallexample
771 typedef typeof(@var{expr}) @var{T};
772 @end smallexample
773
774 @noindent
775 This works with all versions of GCC@.
776
777 @node Conditionals
778 @section Conditionals with Omitted Operands
779 @cindex conditional expressions, extensions
780 @cindex omitted middle-operands
781 @cindex middle-operands, omitted
782 @cindex extensions, @code{?:}
783 @cindex @code{?:} extensions
784
785 The middle operand in a conditional expression may be omitted. Then
786 if the first operand is nonzero, its value is the value of the conditional
787 expression.
788
789 Therefore, the expression
790
791 @smallexample
792 x ? : y
793 @end smallexample
794
795 @noindent
796 has the value of @code{x} if that is nonzero; otherwise, the value of
797 @code{y}.
798
799 This example is perfectly equivalent to
800
801 @smallexample
802 x ? x : y
803 @end smallexample
804
805 @cindex side effect in @code{?:}
806 @cindex @code{?:} side effect
807 @noindent
808 In this simple case, the ability to omit the middle operand is not
809 especially useful. When it becomes useful is when the first operand does,
810 or may (if it is a macro argument), contain a side effect. Then repeating
811 the operand in the middle would perform the side effect twice. Omitting
812 the middle operand uses the value already computed without the undesirable
813 effects of recomputing it.
814
815 @node __int128
816 @section 128-bit integers
817 @cindex @code{__int128} data types
818
819 As an extension the integer scalar type @code{__int128} is supported for
820 targets which have an integer mode wide enough to hold 128 bits.
821 Simply write @code{__int128} for a signed 128-bit integer, or
822 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
823 support in GCC for expressing an integer constant of type @code{__int128}
824 for targets with @code{long long} integer less than 128 bits wide.
825
826 @node Long Long
827 @section Double-Word Integers
828 @cindex @code{long long} data types
829 @cindex double-word arithmetic
830 @cindex multiprecision arithmetic
831 @cindex @code{LL} integer suffix
832 @cindex @code{ULL} integer suffix
833
834 ISO C99 supports data types for integers that are at least 64 bits wide,
835 and as an extension GCC supports them in C90 mode and in C++.
836 Simply write @code{long long int} for a signed integer, or
837 @code{unsigned long long int} for an unsigned integer. To make an
838 integer constant of type @code{long long int}, add the suffix @samp{LL}
839 to the integer. To make an integer constant of type @code{unsigned long
840 long int}, add the suffix @samp{ULL} to the integer.
841
842 You can use these types in arithmetic like any other integer types.
843 Addition, subtraction, and bitwise boolean operations on these types
844 are open-coded on all types of machines. Multiplication is open-coded
845 if the machine supports a fullword-to-doubleword widening multiply
846 instruction. Division and shifts are open-coded only on machines that
847 provide special support. The operations that are not open-coded use
848 special library routines that come with GCC@.
849
850 There may be pitfalls when you use @code{long long} types for function
851 arguments without function prototypes. If a function
852 expects type @code{int} for its argument, and you pass a value of type
853 @code{long long int}, confusion results because the caller and the
854 subroutine disagree about the number of bytes for the argument.
855 Likewise, if the function expects @code{long long int} and you pass
856 @code{int}. The best way to avoid such problems is to use prototypes.
857
858 @node Complex
859 @section Complex Numbers
860 @cindex complex numbers
861 @cindex @code{_Complex} keyword
862 @cindex @code{__complex__} keyword
863
864 ISO C99 supports complex floating data types, and as an extension GCC
865 supports them in C90 mode and in C++. GCC also supports complex integer data
866 types which are not part of ISO C99. You can declare complex types
867 using the keyword @code{_Complex}. As an extension, the older GNU
868 keyword @code{__complex__} is also supported.
869
870 For example, @samp{_Complex double x;} declares @code{x} as a
871 variable whose real part and imaginary part are both of type
872 @code{double}. @samp{_Complex short int y;} declares @code{y} to
873 have real and imaginary parts of type @code{short int}; this is not
874 likely to be useful, but it shows that the set of complex types is
875 complete.
876
877 To write a constant with a complex data type, use the suffix @samp{i} or
878 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
879 has type @code{_Complex float} and @code{3i} has type
880 @code{_Complex int}. Such a constant always has a pure imaginary
881 value, but you can form any complex value you like by adding one to a
882 real constant. This is a GNU extension; if you have an ISO C99
883 conforming C library (such as the GNU C Library), and want to construct complex
884 constants of floating type, you should include @code{<complex.h>} and
885 use the macros @code{I} or @code{_Complex_I} instead.
886
887 @cindex @code{__real__} keyword
888 @cindex @code{__imag__} keyword
889 To extract the real part of a complex-valued expression @var{exp}, write
890 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
891 extract the imaginary part. This is a GNU extension; for values of
892 floating type, you should use the ISO C99 functions @code{crealf},
893 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
894 @code{cimagl}, declared in @code{<complex.h>} and also provided as
895 built-in functions by GCC@.
896
897 @cindex complex conjugation
898 The operator @samp{~} performs complex conjugation when used on a value
899 with a complex type. This is a GNU extension; for values of
900 floating type, you should use the ISO C99 functions @code{conjf},
901 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
902 provided as built-in functions by GCC@.
903
904 GCC can allocate complex automatic variables in a noncontiguous
905 fashion; it's even possible for the real part to be in a register while
906 the imaginary part is on the stack (or vice versa). Only the DWARF 2
907 debug info format can represent this, so use of DWARF 2 is recommended.
908 If you are using the stabs debug info format, GCC describes a noncontiguous
909 complex variable as if it were two separate variables of noncomplex type.
910 If the variable's actual name is @code{foo}, the two fictitious
911 variables are named @code{foo$real} and @code{foo$imag}. You can
912 examine and set these two fictitious variables with your debugger.
913
914 @node Floating Types
915 @section Additional Floating Types
916 @cindex additional floating types
917 @cindex @code{__float80} data type
918 @cindex @code{__float128} data type
919 @cindex @code{w} floating point suffix
920 @cindex @code{q} floating point suffix
921 @cindex @code{W} floating point suffix
922 @cindex @code{Q} floating point suffix
923
924 As an extension, GNU C supports additional floating
925 types, @code{__float80} and @code{__float128} to support 80-bit
926 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
927 Support for additional types includes the arithmetic operators:
928 add, subtract, multiply, divide; unary arithmetic operators;
929 relational operators; equality operators; and conversions to and from
930 integer and other floating types. Use a suffix @samp{w} or @samp{W}
931 in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
932 for @code{_float128}. You can declare complex types using the
933 corresponding internal complex type, @code{XCmode} for @code{__float80}
934 type and @code{TCmode} for @code{__float128} type:
935
936 @smallexample
937 typedef _Complex float __attribute__((mode(TC))) _Complex128;
938 typedef _Complex float __attribute__((mode(XC))) _Complex80;
939 @end smallexample
940
941 Not all targets support additional floating-point types. @code{__float80}
942 and @code{__float128} types are supported on i386, x86_64 and IA-64 targets.
943 The @code{__float128} type is supported on hppa HP-UX targets.
944
945 @node Half-Precision
946 @section Half-Precision Floating Point
947 @cindex half-precision floating point
948 @cindex @code{__fp16} data type
949
950 On ARM targets, GCC supports half-precision (16-bit) floating point via
951 the @code{__fp16} type. You must enable this type explicitly
952 with the @option{-mfp16-format} command-line option in order to use it.
953
954 ARM supports two incompatible representations for half-precision
955 floating-point values. You must choose one of the representations and
956 use it consistently in your program.
957
958 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
959 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
960 There are 11 bits of significand precision, approximately 3
961 decimal digits.
962
963 Specifying @option{-mfp16-format=alternative} selects the ARM
964 alternative format. This representation is similar to the IEEE
965 format, but does not support infinities or NaNs. Instead, the range
966 of exponents is extended, so that this format can represent normalized
967 values in the range of @math{2^{-14}} to 131008.
968
969 The @code{__fp16} type is a storage format only. For purposes
970 of arithmetic and other operations, @code{__fp16} values in C or C++
971 expressions are automatically promoted to @code{float}. In addition,
972 you cannot declare a function with a return value or parameters
973 of type @code{__fp16}.
974
975 Note that conversions from @code{double} to @code{__fp16}
976 involve an intermediate conversion to @code{float}. Because
977 of rounding, this can sometimes produce a different result than a
978 direct conversion.
979
980 ARM provides hardware support for conversions between
981 @code{__fp16} and @code{float} values
982 as an extension to VFP and NEON (Advanced SIMD). GCC generates
983 code using these hardware instructions if you compile with
984 options to select an FPU that provides them;
985 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
986 in addition to the @option{-mfp16-format} option to select
987 a half-precision format.
988
989 Language-level support for the @code{__fp16} data type is
990 independent of whether GCC generates code using hardware floating-point
991 instructions. In cases where hardware support is not specified, GCC
992 implements conversions between @code{__fp16} and @code{float} values
993 as library calls.
994
995 @node Decimal Float
996 @section Decimal Floating Types
997 @cindex decimal floating types
998 @cindex @code{_Decimal32} data type
999 @cindex @code{_Decimal64} data type
1000 @cindex @code{_Decimal128} data type
1001 @cindex @code{df} integer suffix
1002 @cindex @code{dd} integer suffix
1003 @cindex @code{dl} integer suffix
1004 @cindex @code{DF} integer suffix
1005 @cindex @code{DD} integer suffix
1006 @cindex @code{DL} integer suffix
1007
1008 As an extension, GNU C supports decimal floating types as
1009 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1010 floating types in GCC will evolve as the draft technical report changes.
1011 Calling conventions for any target might also change. Not all targets
1012 support decimal floating types.
1013
1014 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1015 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1016 @code{float}, @code{double}, and @code{long double} whose radix is not
1017 specified by the C standard but is usually two.
1018
1019 Support for decimal floating types includes the arithmetic operators
1020 add, subtract, multiply, divide; unary arithmetic operators;
1021 relational operators; equality operators; and conversions to and from
1022 integer and other floating types. Use a suffix @samp{df} or
1023 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1024 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1025 @code{_Decimal128}.
1026
1027 GCC support of decimal float as specified by the draft technical report
1028 is incomplete:
1029
1030 @itemize @bullet
1031 @item
1032 When the value of a decimal floating type cannot be represented in the
1033 integer type to which it is being converted, the result is undefined
1034 rather than the result value specified by the draft technical report.
1035
1036 @item
1037 GCC does not provide the C library functionality associated with
1038 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1039 @file{wchar.h}, which must come from a separate C library implementation.
1040 Because of this the GNU C compiler does not define macro
1041 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1042 the technical report.
1043 @end itemize
1044
1045 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1046 are supported by the DWARF 2 debug information format.
1047
1048 @node Hex Floats
1049 @section Hex Floats
1050 @cindex hex floats
1051
1052 ISO C99 supports floating-point numbers written not only in the usual
1053 decimal notation, such as @code{1.55e1}, but also numbers such as
1054 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1055 supports this in C90 mode (except in some cases when strictly
1056 conforming) and in C++. In that format the
1057 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1058 mandatory. The exponent is a decimal number that indicates the power of
1059 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1060 @tex
1061 $1 {15\over16}$,
1062 @end tex
1063 @ifnottex
1064 1 15/16,
1065 @end ifnottex
1066 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1067 is the same as @code{1.55e1}.
1068
1069 Unlike for floating-point numbers in the decimal notation the exponent
1070 is always required in the hexadecimal notation. Otherwise the compiler
1071 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1072 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1073 extension for floating-point constants of type @code{float}.
1074
1075 @node Fixed-Point
1076 @section Fixed-Point Types
1077 @cindex fixed-point types
1078 @cindex @code{_Fract} data type
1079 @cindex @code{_Accum} data type
1080 @cindex @code{_Sat} data type
1081 @cindex @code{hr} fixed-suffix
1082 @cindex @code{r} fixed-suffix
1083 @cindex @code{lr} fixed-suffix
1084 @cindex @code{llr} fixed-suffix
1085 @cindex @code{uhr} fixed-suffix
1086 @cindex @code{ur} fixed-suffix
1087 @cindex @code{ulr} fixed-suffix
1088 @cindex @code{ullr} fixed-suffix
1089 @cindex @code{hk} fixed-suffix
1090 @cindex @code{k} fixed-suffix
1091 @cindex @code{lk} fixed-suffix
1092 @cindex @code{llk} fixed-suffix
1093 @cindex @code{uhk} fixed-suffix
1094 @cindex @code{uk} fixed-suffix
1095 @cindex @code{ulk} fixed-suffix
1096 @cindex @code{ullk} fixed-suffix
1097 @cindex @code{HR} fixed-suffix
1098 @cindex @code{R} fixed-suffix
1099 @cindex @code{LR} fixed-suffix
1100 @cindex @code{LLR} fixed-suffix
1101 @cindex @code{UHR} fixed-suffix
1102 @cindex @code{UR} fixed-suffix
1103 @cindex @code{ULR} fixed-suffix
1104 @cindex @code{ULLR} fixed-suffix
1105 @cindex @code{HK} fixed-suffix
1106 @cindex @code{K} fixed-suffix
1107 @cindex @code{LK} fixed-suffix
1108 @cindex @code{LLK} fixed-suffix
1109 @cindex @code{UHK} fixed-suffix
1110 @cindex @code{UK} fixed-suffix
1111 @cindex @code{ULK} fixed-suffix
1112 @cindex @code{ULLK} fixed-suffix
1113
1114 As an extension, GNU C supports fixed-point types as
1115 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1116 types in GCC will evolve as the draft technical report changes.
1117 Calling conventions for any target might also change. Not all targets
1118 support fixed-point types.
1119
1120 The fixed-point types are
1121 @code{short _Fract},
1122 @code{_Fract},
1123 @code{long _Fract},
1124 @code{long long _Fract},
1125 @code{unsigned short _Fract},
1126 @code{unsigned _Fract},
1127 @code{unsigned long _Fract},
1128 @code{unsigned long long _Fract},
1129 @code{_Sat short _Fract},
1130 @code{_Sat _Fract},
1131 @code{_Sat long _Fract},
1132 @code{_Sat long long _Fract},
1133 @code{_Sat unsigned short _Fract},
1134 @code{_Sat unsigned _Fract},
1135 @code{_Sat unsigned long _Fract},
1136 @code{_Sat unsigned long long _Fract},
1137 @code{short _Accum},
1138 @code{_Accum},
1139 @code{long _Accum},
1140 @code{long long _Accum},
1141 @code{unsigned short _Accum},
1142 @code{unsigned _Accum},
1143 @code{unsigned long _Accum},
1144 @code{unsigned long long _Accum},
1145 @code{_Sat short _Accum},
1146 @code{_Sat _Accum},
1147 @code{_Sat long _Accum},
1148 @code{_Sat long long _Accum},
1149 @code{_Sat unsigned short _Accum},
1150 @code{_Sat unsigned _Accum},
1151 @code{_Sat unsigned long _Accum},
1152 @code{_Sat unsigned long long _Accum}.
1153
1154 Fixed-point data values contain fractional and optional integral parts.
1155 The format of fixed-point data varies and depends on the target machine.
1156
1157 Support for fixed-point types includes:
1158 @itemize @bullet
1159 @item
1160 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1161 @item
1162 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1163 @item
1164 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1165 @item
1166 binary shift operators (@code{<<}, @code{>>})
1167 @item
1168 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1169 @item
1170 equality operators (@code{==}, @code{!=})
1171 @item
1172 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1173 @code{<<=}, @code{>>=})
1174 @item
1175 conversions to and from integer, floating-point, or fixed-point types
1176 @end itemize
1177
1178 Use a suffix in a fixed-point literal constant:
1179 @itemize
1180 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1181 @code{_Sat short _Fract}
1182 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1183 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1184 @code{_Sat long _Fract}
1185 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1186 @code{_Sat long long _Fract}
1187 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1188 @code{_Sat unsigned short _Fract}
1189 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1190 @code{_Sat unsigned _Fract}
1191 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1192 @code{_Sat unsigned long _Fract}
1193 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1194 and @code{_Sat unsigned long long _Fract}
1195 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1196 @code{_Sat short _Accum}
1197 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1198 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1199 @code{_Sat long _Accum}
1200 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1201 @code{_Sat long long _Accum}
1202 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1203 @code{_Sat unsigned short _Accum}
1204 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1205 @code{_Sat unsigned _Accum}
1206 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1207 @code{_Sat unsigned long _Accum}
1208 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1209 and @code{_Sat unsigned long long _Accum}
1210 @end itemize
1211
1212 GCC support of fixed-point types as specified by the draft technical report
1213 is incomplete:
1214
1215 @itemize @bullet
1216 @item
1217 Pragmas to control overflow and rounding behaviors are not implemented.
1218 @end itemize
1219
1220 Fixed-point types are supported by the DWARF 2 debug information format.
1221
1222 @node Named Address Spaces
1223 @section Named Address Spaces
1224 @cindex Named Address Spaces
1225
1226 As an extension, GNU C supports named address spaces as
1227 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1228 address spaces in GCC will evolve as the draft technical report
1229 changes. Calling conventions for any target might also change. At
1230 present, only the AVR, SPU, M32C, and RL78 targets support address
1231 spaces other than the generic address space.
1232
1233 Address space identifiers may be used exactly like any other C type
1234 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1235 document for more details.
1236
1237 @anchor{AVR Named Address Spaces}
1238 @subsection AVR Named Address Spaces
1239
1240 On the AVR target, there are several address spaces that can be used
1241 in order to put read-only data into the flash memory and access that
1242 data by means of the special instructions @code{LPM} or @code{ELPM}
1243 needed to read from flash.
1244
1245 Per default, any data including read-only data is located in RAM
1246 (the generic address space) so that non-generic address spaces are
1247 needed to locate read-only data in flash memory
1248 @emph{and} to generate the right instructions to access this data
1249 without using (inline) assembler code.
1250
1251 @table @code
1252 @item __flash
1253 @cindex @code{__flash} AVR Named Address Spaces
1254 The @code{__flash} qualifier locates data in the
1255 @code{.progmem.data} section. Data is read using the @code{LPM}
1256 instruction. Pointers to this address space are 16 bits wide.
1257
1258 @item __flash1
1259 @itemx __flash2
1260 @itemx __flash3
1261 @itemx __flash4
1262 @itemx __flash5
1263 @cindex @code{__flash1} AVR Named Address Spaces
1264 @cindex @code{__flash2} AVR Named Address Spaces
1265 @cindex @code{__flash3} AVR Named Address Spaces
1266 @cindex @code{__flash4} AVR Named Address Spaces
1267 @cindex @code{__flash5} AVR Named Address Spaces
1268 These are 16-bit address spaces locating data in section
1269 @code{.progmem@var{N}.data} where @var{N} refers to
1270 address space @code{__flash@var{N}}.
1271 The compiler sets the @code{RAMPZ} segment register appropriately
1272 before reading data by means of the @code{ELPM} instruction.
1273
1274 @item __memx
1275 @cindex @code{__memx} AVR Named Address Spaces
1276 This is a 24-bit address space that linearizes flash and RAM:
1277 If the high bit of the address is set, data is read from
1278 RAM using the lower two bytes as RAM address.
1279 If the high bit of the address is clear, data is read from flash
1280 with @code{RAMPZ} set according to the high byte of the address.
1281 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1282
1283 Objects in this address space are located in @code{.progmemx.data}.
1284 @end table
1285
1286 @b{Example}
1287
1288 @smallexample
1289 char my_read (const __flash char ** p)
1290 @{
1291 /* p is a pointer to RAM that points to a pointer to flash.
1292 The first indirection of p reads that flash pointer
1293 from RAM and the second indirection reads a char from this
1294 flash address. */
1295
1296 return **p;
1297 @}
1298
1299 /* Locate array[] in flash memory */
1300 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1301
1302 int i = 1;
1303
1304 int main (void)
1305 @{
1306 /* Return 17 by reading from flash memory */
1307 return array[array[i]];
1308 @}
1309 @end smallexample
1310
1311 @noindent
1312 For each named address space supported by avr-gcc there is an equally
1313 named but uppercase built-in macro defined.
1314 The purpose is to facilitate testing if respective address space
1315 support is available or not:
1316
1317 @smallexample
1318 #ifdef __FLASH
1319 const __flash int var = 1;
1320
1321 int read_var (void)
1322 @{
1323 return var;
1324 @}
1325 #else
1326 #include <avr/pgmspace.h> /* From AVR-LibC */
1327
1328 const int var PROGMEM = 1;
1329
1330 int read_var (void)
1331 @{
1332 return (int) pgm_read_word (&var);
1333 @}
1334 #endif /* __FLASH */
1335 @end smallexample
1336
1337 @noindent
1338 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1339 locates data in flash but
1340 accesses to these data read from generic address space, i.e.@:
1341 from RAM,
1342 so that you need special accessors like @code{pgm_read_byte}
1343 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1344 together with attribute @code{progmem}.
1345
1346 @noindent
1347 @b{Limitations and caveats}
1348
1349 @itemize
1350 @item
1351 Reading across the 64@tie{}KiB section boundary of
1352 the @code{__flash} or @code{__flash@var{N}} address spaces
1353 shows undefined behavior. The only address space that
1354 supports reading across the 64@tie{}KiB flash segment boundaries is
1355 @code{__memx}.
1356
1357 @item
1358 If you use one of the @code{__flash@var{N}} address spaces
1359 you must arrange your linker script to locate the
1360 @code{.progmem@var{N}.data} sections according to your needs.
1361
1362 @item
1363 Any data or pointers to the non-generic address spaces must
1364 be qualified as @code{const}, i.e.@: as read-only data.
1365 This still applies if the data in one of these address
1366 spaces like software version number or calibration lookup table are intended to
1367 be changed after load time by, say, a boot loader. In this case
1368 the right qualification is @code{const} @code{volatile} so that the compiler
1369 must not optimize away known values or insert them
1370 as immediates into operands of instructions.
1371
1372 @item
1373 The following code initializes a variable @code{pfoo}
1374 located in static storage with a 24-bit address:
1375 @smallexample
1376 extern const __memx char foo;
1377 const __memx void *pfoo = &foo;
1378 @end smallexample
1379
1380 @noindent
1381 Such code requires at least binutils 2.23, see
1382 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1383
1384 @end itemize
1385
1386 @subsection M32C Named Address Spaces
1387 @cindex @code{__far} M32C Named Address Spaces
1388
1389 On the M32C target, with the R8C and M16C CPU variants, variables
1390 qualified with @code{__far} are accessed using 32-bit addresses in
1391 order to access memory beyond the first 64@tie{}Ki bytes. If
1392 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1393 effect.
1394
1395 @subsection RL78 Named Address Spaces
1396 @cindex @code{__far} RL78 Named Address Spaces
1397
1398 On the RL78 target, variables qualified with @code{__far} are accessed
1399 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1400 addresses. Non-far variables are assumed to appear in the topmost
1401 64@tie{}KiB of the address space.
1402
1403 @subsection SPU Named Address Spaces
1404 @cindex @code{__ea} SPU Named Address Spaces
1405
1406 On the SPU target variables may be declared as
1407 belonging to another address space by qualifying the type with the
1408 @code{__ea} address space identifier:
1409
1410 @smallexample
1411 extern int __ea i;
1412 @end smallexample
1413
1414 @noindent
1415 The compiler generates special code to access the variable @code{i}.
1416 It may use runtime library
1417 support, or generate special machine instructions to access that address
1418 space.
1419
1420 @node Zero Length
1421 @section Arrays of Length Zero
1422 @cindex arrays of length zero
1423 @cindex zero-length arrays
1424 @cindex length-zero arrays
1425 @cindex flexible array members
1426
1427 Zero-length arrays are allowed in GNU C@. They are very useful as the
1428 last element of a structure that is really a header for a variable-length
1429 object:
1430
1431 @smallexample
1432 struct line @{
1433 int length;
1434 char contents[0];
1435 @};
1436
1437 struct line *thisline = (struct line *)
1438 malloc (sizeof (struct line) + this_length);
1439 thisline->length = this_length;
1440 @end smallexample
1441
1442 In ISO C90, you would have to give @code{contents} a length of 1, which
1443 means either you waste space or complicate the argument to @code{malloc}.
1444
1445 In ISO C99, you would use a @dfn{flexible array member}, which is
1446 slightly different in syntax and semantics:
1447
1448 @itemize @bullet
1449 @item
1450 Flexible array members are written as @code{contents[]} without
1451 the @code{0}.
1452
1453 @item
1454 Flexible array members have incomplete type, and so the @code{sizeof}
1455 operator may not be applied. As a quirk of the original implementation
1456 of zero-length arrays, @code{sizeof} evaluates to zero.
1457
1458 @item
1459 Flexible array members may only appear as the last member of a
1460 @code{struct} that is otherwise non-empty.
1461
1462 @item
1463 A structure containing a flexible array member, or a union containing
1464 such a structure (possibly recursively), may not be a member of a
1465 structure or an element of an array. (However, these uses are
1466 permitted by GCC as extensions.)
1467 @end itemize
1468
1469 GCC versions before 3.0 allowed zero-length arrays to be statically
1470 initialized, as if they were flexible arrays. In addition to those
1471 cases that were useful, it also allowed initializations in situations
1472 that would corrupt later data. Non-empty initialization of zero-length
1473 arrays is now treated like any case where there are more initializer
1474 elements than the array holds, in that a suitable warning about ``excess
1475 elements in array'' is given, and the excess elements (all of them, in
1476 this case) are ignored.
1477
1478 Instead GCC allows static initialization of flexible array members.
1479 This is equivalent to defining a new structure containing the original
1480 structure followed by an array of sufficient size to contain the data.
1481 E.g.@: in the following, @code{f1} is constructed as if it were declared
1482 like @code{f2}.
1483
1484 @smallexample
1485 struct f1 @{
1486 int x; int y[];
1487 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1488
1489 struct f2 @{
1490 struct f1 f1; int data[3];
1491 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1492 @end smallexample
1493
1494 @noindent
1495 The convenience of this extension is that @code{f1} has the desired
1496 type, eliminating the need to consistently refer to @code{f2.f1}.
1497
1498 This has symmetry with normal static arrays, in that an array of
1499 unknown size is also written with @code{[]}.
1500
1501 Of course, this extension only makes sense if the extra data comes at
1502 the end of a top-level object, as otherwise we would be overwriting
1503 data at subsequent offsets. To avoid undue complication and confusion
1504 with initialization of deeply nested arrays, we simply disallow any
1505 non-empty initialization except when the structure is the top-level
1506 object. For example:
1507
1508 @smallexample
1509 struct foo @{ int x; int y[]; @};
1510 struct bar @{ struct foo z; @};
1511
1512 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1513 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1514 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1515 struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1516 @end smallexample
1517
1518 @node Empty Structures
1519 @section Structures With No Members
1520 @cindex empty structures
1521 @cindex zero-size structures
1522
1523 GCC permits a C structure to have no members:
1524
1525 @smallexample
1526 struct empty @{
1527 @};
1528 @end smallexample
1529
1530 The structure has size zero. In C++, empty structures are part
1531 of the language. G++ treats empty structures as if they had a single
1532 member of type @code{char}.
1533
1534 @node Variable Length
1535 @section Arrays of Variable Length
1536 @cindex variable-length arrays
1537 @cindex arrays of variable length
1538 @cindex VLAs
1539
1540 Variable-length automatic arrays are allowed in ISO C99, and as an
1541 extension GCC accepts them in C90 mode and in C++. These arrays are
1542 declared like any other automatic arrays, but with a length that is not
1543 a constant expression. The storage is allocated at the point of
1544 declaration and deallocated when the block scope containing the declaration
1545 exits. For
1546 example:
1547
1548 @smallexample
1549 FILE *
1550 concat_fopen (char *s1, char *s2, char *mode)
1551 @{
1552 char str[strlen (s1) + strlen (s2) + 1];
1553 strcpy (str, s1);
1554 strcat (str, s2);
1555 return fopen (str, mode);
1556 @}
1557 @end smallexample
1558
1559 @cindex scope of a variable length array
1560 @cindex variable-length array scope
1561 @cindex deallocating variable length arrays
1562 Jumping or breaking out of the scope of the array name deallocates the
1563 storage. Jumping into the scope is not allowed; you get an error
1564 message for it.
1565
1566 @cindex @code{alloca} vs variable-length arrays
1567 You can use the function @code{alloca} to get an effect much like
1568 variable-length arrays. The function @code{alloca} is available in
1569 many other C implementations (but not in all). On the other hand,
1570 variable-length arrays are more elegant.
1571
1572 There are other differences between these two methods. Space allocated
1573 with @code{alloca} exists until the containing @emph{function} returns.
1574 The space for a variable-length array is deallocated as soon as the array
1575 name's scope ends. (If you use both variable-length arrays and
1576 @code{alloca} in the same function, deallocation of a variable-length array
1577 also deallocates anything more recently allocated with @code{alloca}.)
1578
1579 You can also use variable-length arrays as arguments to functions:
1580
1581 @smallexample
1582 struct entry
1583 tester (int len, char data[len][len])
1584 @{
1585 /* @r{@dots{}} */
1586 @}
1587 @end smallexample
1588
1589 The length of an array is computed once when the storage is allocated
1590 and is remembered for the scope of the array in case you access it with
1591 @code{sizeof}.
1592
1593 If you want to pass the array first and the length afterward, you can
1594 use a forward declaration in the parameter list---another GNU extension.
1595
1596 @smallexample
1597 struct entry
1598 tester (int len; char data[len][len], int len)
1599 @{
1600 /* @r{@dots{}} */
1601 @}
1602 @end smallexample
1603
1604 @cindex parameter forward declaration
1605 The @samp{int len} before the semicolon is a @dfn{parameter forward
1606 declaration}, and it serves the purpose of making the name @code{len}
1607 known when the declaration of @code{data} is parsed.
1608
1609 You can write any number of such parameter forward declarations in the
1610 parameter list. They can be separated by commas or semicolons, but the
1611 last one must end with a semicolon, which is followed by the ``real''
1612 parameter declarations. Each forward declaration must match a ``real''
1613 declaration in parameter name and data type. ISO C99 does not support
1614 parameter forward declarations.
1615
1616 @node Variadic Macros
1617 @section Macros with a Variable Number of Arguments.
1618 @cindex variable number of arguments
1619 @cindex macro with variable arguments
1620 @cindex rest argument (in macro)
1621 @cindex variadic macros
1622
1623 In the ISO C standard of 1999, a macro can be declared to accept a
1624 variable number of arguments much as a function can. The syntax for
1625 defining the macro is similar to that of a function. Here is an
1626 example:
1627
1628 @smallexample
1629 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1630 @end smallexample
1631
1632 @noindent
1633 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1634 such a macro, it represents the zero or more tokens until the closing
1635 parenthesis that ends the invocation, including any commas. This set of
1636 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1637 wherever it appears. See the CPP manual for more information.
1638
1639 GCC has long supported variadic macros, and used a different syntax that
1640 allowed you to give a name to the variable arguments just like any other
1641 argument. Here is an example:
1642
1643 @smallexample
1644 #define debug(format, args...) fprintf (stderr, format, args)
1645 @end smallexample
1646
1647 @noindent
1648 This is in all ways equivalent to the ISO C example above, but arguably
1649 more readable and descriptive.
1650
1651 GNU CPP has two further variadic macro extensions, and permits them to
1652 be used with either of the above forms of macro definition.
1653
1654 In standard C, you are not allowed to leave the variable argument out
1655 entirely; but you are allowed to pass an empty argument. For example,
1656 this invocation is invalid in ISO C, because there is no comma after
1657 the string:
1658
1659 @smallexample
1660 debug ("A message")
1661 @end smallexample
1662
1663 GNU CPP permits you to completely omit the variable arguments in this
1664 way. In the above examples, the compiler would complain, though since
1665 the expansion of the macro still has the extra comma after the format
1666 string.
1667
1668 To help solve this problem, CPP behaves specially for variable arguments
1669 used with the token paste operator, @samp{##}. If instead you write
1670
1671 @smallexample
1672 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1673 @end smallexample
1674
1675 @noindent
1676 and if the variable arguments are omitted or empty, the @samp{##}
1677 operator causes the preprocessor to remove the comma before it. If you
1678 do provide some variable arguments in your macro invocation, GNU CPP
1679 does not complain about the paste operation and instead places the
1680 variable arguments after the comma. Just like any other pasted macro
1681 argument, these arguments are not macro expanded.
1682
1683 @node Escaped Newlines
1684 @section Slightly Looser Rules for Escaped Newlines
1685 @cindex escaped newlines
1686 @cindex newlines (escaped)
1687
1688 Recently, the preprocessor has relaxed its treatment of escaped
1689 newlines. Previously, the newline had to immediately follow a
1690 backslash. The current implementation allows whitespace in the form
1691 of spaces, horizontal and vertical tabs, and form feeds between the
1692 backslash and the subsequent newline. The preprocessor issues a
1693 warning, but treats it as a valid escaped newline and combines the two
1694 lines to form a single logical line. This works within comments and
1695 tokens, as well as between tokens. Comments are @emph{not} treated as
1696 whitespace for the purposes of this relaxation, since they have not
1697 yet been replaced with spaces.
1698
1699 @node Subscripting
1700 @section Non-Lvalue Arrays May Have Subscripts
1701 @cindex subscripting
1702 @cindex arrays, non-lvalue
1703
1704 @cindex subscripting and function values
1705 In ISO C99, arrays that are not lvalues still decay to pointers, and
1706 may be subscripted, although they may not be modified or used after
1707 the next sequence point and the unary @samp{&} operator may not be
1708 applied to them. As an extension, GNU C allows such arrays to be
1709 subscripted in C90 mode, though otherwise they do not decay to
1710 pointers outside C99 mode. For example,
1711 this is valid in GNU C though not valid in C90:
1712
1713 @smallexample
1714 @group
1715 struct foo @{int a[4];@};
1716
1717 struct foo f();
1718
1719 bar (int index)
1720 @{
1721 return f().a[index];
1722 @}
1723 @end group
1724 @end smallexample
1725
1726 @node Pointer Arith
1727 @section Arithmetic on @code{void}- and Function-Pointers
1728 @cindex void pointers, arithmetic
1729 @cindex void, size of pointer to
1730 @cindex function pointers, arithmetic
1731 @cindex function, size of pointer to
1732
1733 In GNU C, addition and subtraction operations are supported on pointers to
1734 @code{void} and on pointers to functions. This is done by treating the
1735 size of a @code{void} or of a function as 1.
1736
1737 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1738 and on function types, and returns 1.
1739
1740 @opindex Wpointer-arith
1741 The option @option{-Wpointer-arith} requests a warning if these extensions
1742 are used.
1743
1744 @node Initializers
1745 @section Non-Constant Initializers
1746 @cindex initializers, non-constant
1747 @cindex non-constant initializers
1748
1749 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1750 automatic variable are not required to be constant expressions in GNU C@.
1751 Here is an example of an initializer with run-time varying elements:
1752
1753 @smallexample
1754 foo (float f, float g)
1755 @{
1756 float beat_freqs[2] = @{ f-g, f+g @};
1757 /* @r{@dots{}} */
1758 @}
1759 @end smallexample
1760
1761 @node Compound Literals
1762 @section Compound Literals
1763 @cindex constructor expressions
1764 @cindex initializations in expressions
1765 @cindex structures, constructor expression
1766 @cindex expressions, constructor
1767 @cindex compound literals
1768 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1769
1770 ISO C99 supports compound literals. A compound literal looks like
1771 a cast containing an initializer. Its value is an object of the
1772 type specified in the cast, containing the elements specified in
1773 the initializer; it is an lvalue. As an extension, GCC supports
1774 compound literals in C90 mode and in C++, though the semantics are
1775 somewhat different in C++.
1776
1777 Usually, the specified type is a structure. Assume that
1778 @code{struct foo} and @code{structure} are declared as shown:
1779
1780 @smallexample
1781 struct foo @{int a; char b[2];@} structure;
1782 @end smallexample
1783
1784 @noindent
1785 Here is an example of constructing a @code{struct foo} with a compound literal:
1786
1787 @smallexample
1788 structure = ((struct foo) @{x + y, 'a', 0@});
1789 @end smallexample
1790
1791 @noindent
1792 This is equivalent to writing the following:
1793
1794 @smallexample
1795 @{
1796 struct foo temp = @{x + y, 'a', 0@};
1797 structure = temp;
1798 @}
1799 @end smallexample
1800
1801 You can also construct an array, though this is dangerous in C++, as
1802 explained below. If all the elements of the compound literal are
1803 (made up of) simple constant expressions, suitable for use in
1804 initializers of objects of static storage duration, then the compound
1805 literal can be coerced to a pointer to its first element and used in
1806 such an initializer, as shown here:
1807
1808 @smallexample
1809 char **foo = (char *[]) @{ "x", "y", "z" @};
1810 @end smallexample
1811
1812 Compound literals for scalar types and union types are
1813 also allowed, but then the compound literal is equivalent
1814 to a cast.
1815
1816 As a GNU extension, GCC allows initialization of objects with static storage
1817 duration by compound literals (which is not possible in ISO C99, because
1818 the initializer is not a constant).
1819 It is handled as if the object is initialized only with the bracket
1820 enclosed list if the types of the compound literal and the object match.
1821 The initializer list of the compound literal must be constant.
1822 If the object being initialized has array type of unknown size, the size is
1823 determined by compound literal size.
1824
1825 @smallexample
1826 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1827 static int y[] = (int []) @{1, 2, 3@};
1828 static int z[] = (int [3]) @{1@};
1829 @end smallexample
1830
1831 @noindent
1832 The above lines are equivalent to the following:
1833 @smallexample
1834 static struct foo x = @{1, 'a', 'b'@};
1835 static int y[] = @{1, 2, 3@};
1836 static int z[] = @{1, 0, 0@};
1837 @end smallexample
1838
1839 In C, a compound literal designates an unnamed object with static or
1840 automatic storage duration. In C++, a compound literal designates a
1841 temporary object, which only lives until the end of its
1842 full-expression. As a result, well-defined C code that takes the
1843 address of a subobject of a compound literal can be undefined in C++.
1844 For instance, if the array compound literal example above appeared
1845 inside a function, any subsequent use of @samp{foo} in C++ has
1846 undefined behavior because the lifetime of the array ends after the
1847 declaration of @samp{foo}. As a result, the C++ compiler now rejects
1848 the conversion of a temporary array to a pointer.
1849
1850 As an optimization, the C++ compiler sometimes gives array compound
1851 literals longer lifetimes: when the array either appears outside a
1852 function or has const-qualified type. If @samp{foo} and its
1853 initializer had elements of @samp{char *const} type rather than
1854 @samp{char *}, or if @samp{foo} were a global variable, the array
1855 would have static storage duration. But it is probably safest just to
1856 avoid the use of array compound literals in code compiled as C++.
1857
1858 @node Designated Inits
1859 @section Designated Initializers
1860 @cindex initializers with labeled elements
1861 @cindex labeled elements in initializers
1862 @cindex case labels in initializers
1863 @cindex designated initializers
1864
1865 Standard C90 requires the elements of an initializer to appear in a fixed
1866 order, the same as the order of the elements in the array or structure
1867 being initialized.
1868
1869 In ISO C99 you can give the elements in any order, specifying the array
1870 indices or structure field names they apply to, and GNU C allows this as
1871 an extension in C90 mode as well. This extension is not
1872 implemented in GNU C++.
1873
1874 To specify an array index, write
1875 @samp{[@var{index}] =} before the element value. For example,
1876
1877 @smallexample
1878 int a[6] = @{ [4] = 29, [2] = 15 @};
1879 @end smallexample
1880
1881 @noindent
1882 is equivalent to
1883
1884 @smallexample
1885 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1886 @end smallexample
1887
1888 @noindent
1889 The index values must be constant expressions, even if the array being
1890 initialized is automatic.
1891
1892 An alternative syntax for this that has been obsolete since GCC 2.5 but
1893 GCC still accepts is to write @samp{[@var{index}]} before the element
1894 value, with no @samp{=}.
1895
1896 To initialize a range of elements to the same value, write
1897 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1898 extension. For example,
1899
1900 @smallexample
1901 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1902 @end smallexample
1903
1904 @noindent
1905 If the value in it has side-effects, the side-effects happen only once,
1906 not for each initialized field by the range initializer.
1907
1908 @noindent
1909 Note that the length of the array is the highest value specified
1910 plus one.
1911
1912 In a structure initializer, specify the name of a field to initialize
1913 with @samp{.@var{fieldname} =} before the element value. For example,
1914 given the following structure,
1915
1916 @smallexample
1917 struct point @{ int x, y; @};
1918 @end smallexample
1919
1920 @noindent
1921 the following initialization
1922
1923 @smallexample
1924 struct point p = @{ .y = yvalue, .x = xvalue @};
1925 @end smallexample
1926
1927 @noindent
1928 is equivalent to
1929
1930 @smallexample
1931 struct point p = @{ xvalue, yvalue @};
1932 @end smallexample
1933
1934 Another syntax that has the same meaning, obsolete since GCC 2.5, is
1935 @samp{@var{fieldname}:}, as shown here:
1936
1937 @smallexample
1938 struct point p = @{ y: yvalue, x: xvalue @};
1939 @end smallexample
1940
1941 @cindex designators
1942 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
1943 @dfn{designator}. You can also use a designator (or the obsolete colon
1944 syntax) when initializing a union, to specify which element of the union
1945 should be used. For example,
1946
1947 @smallexample
1948 union foo @{ int i; double d; @};
1949
1950 union foo f = @{ .d = 4 @};
1951 @end smallexample
1952
1953 @noindent
1954 converts 4 to a @code{double} to store it in the union using
1955 the second element. By contrast, casting 4 to type @code{union foo}
1956 stores it into the union as the integer @code{i}, since it is
1957 an integer. (@xref{Cast to Union}.)
1958
1959 You can combine this technique of naming elements with ordinary C
1960 initialization of successive elements. Each initializer element that
1961 does not have a designator applies to the next consecutive element of the
1962 array or structure. For example,
1963
1964 @smallexample
1965 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
1966 @end smallexample
1967
1968 @noindent
1969 is equivalent to
1970
1971 @smallexample
1972 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
1973 @end smallexample
1974
1975 Labeling the elements of an array initializer is especially useful
1976 when the indices are characters or belong to an @code{enum} type.
1977 For example:
1978
1979 @smallexample
1980 int whitespace[256]
1981 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
1982 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
1983 @end smallexample
1984
1985 @cindex designator lists
1986 You can also write a series of @samp{.@var{fieldname}} and
1987 @samp{[@var{index}]} designators before an @samp{=} to specify a
1988 nested subobject to initialize; the list is taken relative to the
1989 subobject corresponding to the closest surrounding brace pair. For
1990 example, with the @samp{struct point} declaration above:
1991
1992 @smallexample
1993 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
1994 @end smallexample
1995
1996 @noindent
1997 If the same field is initialized multiple times, it has the value from
1998 the last initialization. If any such overridden initialization has
1999 side-effect, it is unspecified whether the side-effect happens or not.
2000 Currently, GCC discards them and issues a warning.
2001
2002 @node Case Ranges
2003 @section Case Ranges
2004 @cindex case ranges
2005 @cindex ranges in case statements
2006
2007 You can specify a range of consecutive values in a single @code{case} label,
2008 like this:
2009
2010 @smallexample
2011 case @var{low} ... @var{high}:
2012 @end smallexample
2013
2014 @noindent
2015 This has the same effect as the proper number of individual @code{case}
2016 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2017
2018 This feature is especially useful for ranges of ASCII character codes:
2019
2020 @smallexample
2021 case 'A' ... 'Z':
2022 @end smallexample
2023
2024 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2025 it may be parsed wrong when you use it with integer values. For example,
2026 write this:
2027
2028 @smallexample
2029 case 1 ... 5:
2030 @end smallexample
2031
2032 @noindent
2033 rather than this:
2034
2035 @smallexample
2036 case 1...5:
2037 @end smallexample
2038
2039 @node Cast to Union
2040 @section Cast to a Union Type
2041 @cindex cast to a union
2042 @cindex union, casting to a
2043
2044 A cast to union type is similar to other casts, except that the type
2045 specified is a union type. You can specify the type either with
2046 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2047 a constructor, not a cast, and hence does not yield an lvalue like
2048 normal casts. (@xref{Compound Literals}.)
2049
2050 The types that may be cast to the union type are those of the members
2051 of the union. Thus, given the following union and variables:
2052
2053 @smallexample
2054 union foo @{ int i; double d; @};
2055 int x;
2056 double y;
2057 @end smallexample
2058
2059 @noindent
2060 both @code{x} and @code{y} can be cast to type @code{union foo}.
2061
2062 Using the cast as the right-hand side of an assignment to a variable of
2063 union type is equivalent to storing in a member of the union:
2064
2065 @smallexample
2066 union foo u;
2067 /* @r{@dots{}} */
2068 u = (union foo) x @equiv{} u.i = x
2069 u = (union foo) y @equiv{} u.d = y
2070 @end smallexample
2071
2072 You can also use the union cast as a function argument:
2073
2074 @smallexample
2075 void hack (union foo);
2076 /* @r{@dots{}} */
2077 hack ((union foo) x);
2078 @end smallexample
2079
2080 @node Mixed Declarations
2081 @section Mixed Declarations and Code
2082 @cindex mixed declarations and code
2083 @cindex declarations, mixed with code
2084 @cindex code, mixed with declarations
2085
2086 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2087 within compound statements. As an extension, GNU C also allows this in
2088 C90 mode. For example, you could do:
2089
2090 @smallexample
2091 int i;
2092 /* @r{@dots{}} */
2093 i++;
2094 int j = i + 2;
2095 @end smallexample
2096
2097 Each identifier is visible from where it is declared until the end of
2098 the enclosing block.
2099
2100 @node Function Attributes
2101 @section Declaring Attributes of Functions
2102 @cindex function attributes
2103 @cindex declaring attributes of functions
2104 @cindex functions that never return
2105 @cindex functions that return more than once
2106 @cindex functions that have no side effects
2107 @cindex functions in arbitrary sections
2108 @cindex functions that behave like malloc
2109 @cindex @code{volatile} applied to function
2110 @cindex @code{const} applied to function
2111 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2112 @cindex functions with non-null pointer arguments
2113 @cindex functions that are passed arguments in registers on the 386
2114 @cindex functions that pop the argument stack on the 386
2115 @cindex functions that do not pop the argument stack on the 386
2116 @cindex functions that have different compilation options on the 386
2117 @cindex functions that have different optimization options
2118 @cindex functions that are dynamically resolved
2119
2120 In GNU C, you declare certain things about functions called in your program
2121 which help the compiler optimize function calls and check your code more
2122 carefully.
2123
2124 The keyword @code{__attribute__} allows you to specify special
2125 attributes when making a declaration. This keyword is followed by an
2126 attribute specification inside double parentheses. The following
2127 attributes are currently defined for functions on all targets:
2128 @code{aligned}, @code{alloc_size}, @code{noreturn},
2129 @code{returns_twice}, @code{noinline}, @code{noclone},
2130 @code{always_inline}, @code{flatten}, @code{pure}, @code{const},
2131 @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg},
2132 @code{no_instrument_function}, @code{no_split_stack},
2133 @code{section}, @code{constructor},
2134 @code{destructor}, @code{used}, @code{unused}, @code{deprecated},
2135 @code{weak}, @code{malloc}, @code{alias}, @code{ifunc},
2136 @code{warn_unused_result}, @code{nonnull}, @code{gnu_inline},
2137 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
2138 @code{no_sanitize_address}, @code{no_address_safety_analysis},
2139 @code{error} and @code{warning}.
2140 Several other attributes are defined for functions on particular
2141 target systems. Other attributes, including @code{section} are
2142 supported for variables declarations (@pxref{Variable Attributes})
2143 and for types (@pxref{Type Attributes}).
2144
2145 GCC plugins may provide their own attributes.
2146
2147 You may also specify attributes with @samp{__} preceding and following
2148 each keyword. This allows you to use them in header files without
2149 being concerned about a possible macro of the same name. For example,
2150 you may use @code{__noreturn__} instead of @code{noreturn}.
2151
2152 @xref{Attribute Syntax}, for details of the exact syntax for using
2153 attributes.
2154
2155 @table @code
2156 @c Keep this table alphabetized by attribute name. Treat _ as space.
2157
2158 @item alias ("@var{target}")
2159 @cindex @code{alias} attribute
2160 The @code{alias} attribute causes the declaration to be emitted as an
2161 alias for another symbol, which must be specified. For instance,
2162
2163 @smallexample
2164 void __f () @{ /* @r{Do something.} */; @}
2165 void f () __attribute__ ((weak, alias ("__f")));
2166 @end smallexample
2167
2168 @noindent
2169 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2170 mangled name for the target must be used. It is an error if @samp{__f}
2171 is not defined in the same translation unit.
2172
2173 Not all target machines support this attribute.
2174
2175 @item aligned (@var{alignment})
2176 @cindex @code{aligned} attribute
2177 This attribute specifies a minimum alignment for the function,
2178 measured in bytes.
2179
2180 You cannot use this attribute to decrease the alignment of a function,
2181 only to increase it. However, when you explicitly specify a function
2182 alignment this overrides the effect of the
2183 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2184 function.
2185
2186 Note that the effectiveness of @code{aligned} attributes may be
2187 limited by inherent limitations in your linker. On many systems, the
2188 linker is only able to arrange for functions to be aligned up to a
2189 certain maximum alignment. (For some linkers, the maximum supported
2190 alignment may be very very small.) See your linker documentation for
2191 further information.
2192
2193 The @code{aligned} attribute can also be used for variables and fields
2194 (@pxref{Variable Attributes}.)
2195
2196 @item alloc_size
2197 @cindex @code{alloc_size} attribute
2198 The @code{alloc_size} attribute is used to tell the compiler that the
2199 function return value points to memory, where the size is given by
2200 one or two of the functions parameters. GCC uses this
2201 information to improve the correctness of @code{__builtin_object_size}.
2202
2203 The function parameter(s) denoting the allocated size are specified by
2204 one or two integer arguments supplied to the attribute. The allocated size
2205 is either the value of the single function argument specified or the product
2206 of the two function arguments specified. Argument numbering starts at
2207 one.
2208
2209 For instance,
2210
2211 @smallexample
2212 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2213 void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2214 @end smallexample
2215
2216 @noindent
2217 declares that @code{my_calloc} returns memory of the size given by
2218 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2219 of the size given by parameter 2.
2220
2221 @item always_inline
2222 @cindex @code{always_inline} function attribute
2223 Generally, functions are not inlined unless optimization is specified.
2224 For functions declared inline, this attribute inlines the function even
2225 if no optimization level is specified.
2226
2227 @item gnu_inline
2228 @cindex @code{gnu_inline} function attribute
2229 This attribute should be used with a function that is also declared
2230 with the @code{inline} keyword. It directs GCC to treat the function
2231 as if it were defined in gnu90 mode even when compiling in C99 or
2232 gnu99 mode.
2233
2234 If the function is declared @code{extern}, then this definition of the
2235 function is used only for inlining. In no case is the function
2236 compiled as a standalone function, not even if you take its address
2237 explicitly. Such an address becomes an external reference, as if you
2238 had only declared the function, and had not defined it. This has
2239 almost the effect of a macro. The way to use this is to put a
2240 function definition in a header file with this attribute, and put
2241 another copy of the function, without @code{extern}, in a library
2242 file. The definition in the header file causes most calls to the
2243 function to be inlined. If any uses of the function remain, they
2244 refer to the single copy in the library. Note that the two
2245 definitions of the functions need not be precisely the same, although
2246 if they do not have the same effect your program may behave oddly.
2247
2248 In C, if the function is neither @code{extern} nor @code{static}, then
2249 the function is compiled as a standalone function, as well as being
2250 inlined where possible.
2251
2252 This is how GCC traditionally handled functions declared
2253 @code{inline}. Since ISO C99 specifies a different semantics for
2254 @code{inline}, this function attribute is provided as a transition
2255 measure and as a useful feature in its own right. This attribute is
2256 available in GCC 4.1.3 and later. It is available if either of the
2257 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2258 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2259 Function is As Fast As a Macro}.
2260
2261 In C++, this attribute does not depend on @code{extern} in any way,
2262 but it still requires the @code{inline} keyword to enable its special
2263 behavior.
2264
2265 @item artificial
2266 @cindex @code{artificial} function attribute
2267 This attribute is useful for small inline wrappers that if possible
2268 should appear during debugging as a unit. Depending on the debug
2269 info format it either means marking the function as artificial
2270 or using the caller location for all instructions within the inlined
2271 body.
2272
2273 @item bank_switch
2274 @cindex interrupt handler functions
2275 When added to an interrupt handler with the M32C port, causes the
2276 prologue and epilogue to use bank switching to preserve the registers
2277 rather than saving them on the stack.
2278
2279 @item flatten
2280 @cindex @code{flatten} function attribute
2281 Generally, inlining into a function is limited. For a function marked with
2282 this attribute, every call inside this function is inlined, if possible.
2283 Whether the function itself is considered for inlining depends on its size and
2284 the current inlining parameters.
2285
2286 @item error ("@var{message}")
2287 @cindex @code{error} function attribute
2288 If this attribute is used on a function declaration and a call to such a function
2289 is not eliminated through dead code elimination or other optimizations, an error
2290 that includes @var{message} is diagnosed. This is useful
2291 for compile-time checking, especially together with @code{__builtin_constant_p}
2292 and inline functions where checking the inline function arguments is not
2293 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2294 While it is possible to leave the function undefined and thus invoke
2295 a link failure, when using this attribute the problem is diagnosed
2296 earlier and with exact location of the call even in presence of inline
2297 functions or when not emitting debugging information.
2298
2299 @item warning ("@var{message}")
2300 @cindex @code{warning} function attribute
2301 If this attribute is used on a function declaration and a call to such a function
2302 is not eliminated through dead code elimination or other optimizations, a warning
2303 that includes @var{message} is diagnosed. This is useful
2304 for compile-time checking, especially together with @code{__builtin_constant_p}
2305 and inline functions. While it is possible to define the function with
2306 a message in @code{.gnu.warning*} section, when using this attribute the problem
2307 is diagnosed earlier and with exact location of the call even in presence
2308 of inline functions or when not emitting debugging information.
2309
2310 @item cdecl
2311 @cindex functions that do pop the argument stack on the 386
2312 @opindex mrtd
2313 On the Intel 386, the @code{cdecl} attribute causes the compiler to
2314 assume that the calling function pops off the stack space used to
2315 pass arguments. This is
2316 useful to override the effects of the @option{-mrtd} switch.
2317
2318 @item const
2319 @cindex @code{const} function attribute
2320 Many functions do not examine any values except their arguments, and
2321 have no effects except the return value. Basically this is just slightly
2322 more strict class than the @code{pure} attribute below, since function is not
2323 allowed to read global memory.
2324
2325 @cindex pointer arguments
2326 Note that a function that has pointer arguments and examines the data
2327 pointed to must @emph{not} be declared @code{const}. Likewise, a
2328 function that calls a non-@code{const} function usually must not be
2329 @code{const}. It does not make sense for a @code{const} function to
2330 return @code{void}.
2331
2332 The attribute @code{const} is not implemented in GCC versions earlier
2333 than 2.5. An alternative way to declare that a function has no side
2334 effects, which works in the current version and in some older versions,
2335 is as follows:
2336
2337 @smallexample
2338 typedef int intfn ();
2339
2340 extern const intfn square;
2341 @end smallexample
2342
2343 @noindent
2344 This approach does not work in GNU C++ from 2.6.0 on, since the language
2345 specifies that the @samp{const} must be attached to the return value.
2346
2347 @item constructor
2348 @itemx destructor
2349 @itemx constructor (@var{priority})
2350 @itemx destructor (@var{priority})
2351 @cindex @code{constructor} function attribute
2352 @cindex @code{destructor} function attribute
2353 The @code{constructor} attribute causes the function to be called
2354 automatically before execution enters @code{main ()}. Similarly, the
2355 @code{destructor} attribute causes the function to be called
2356 automatically after @code{main ()} completes or @code{exit ()} is
2357 called. Functions with these attributes are useful for
2358 initializing data that is used implicitly during the execution of
2359 the program.
2360
2361 You may provide an optional integer priority to control the order in
2362 which constructor and destructor functions are run. A constructor
2363 with a smaller priority number runs before a constructor with a larger
2364 priority number; the opposite relationship holds for destructors. So,
2365 if you have a constructor that allocates a resource and a destructor
2366 that deallocates the same resource, both functions typically have the
2367 same priority. The priorities for constructor and destructor
2368 functions are the same as those specified for namespace-scope C++
2369 objects (@pxref{C++ Attributes}).
2370
2371 These attributes are not currently implemented for Objective-C@.
2372
2373 @item deprecated
2374 @itemx deprecated (@var{msg})
2375 @cindex @code{deprecated} attribute.
2376 The @code{deprecated} attribute results in a warning if the function
2377 is used anywhere in the source file. This is useful when identifying
2378 functions that are expected to be removed in a future version of a
2379 program. The warning also includes the location of the declaration
2380 of the deprecated function, to enable users to easily find further
2381 information about why the function is deprecated, or what they should
2382 do instead. Note that the warnings only occurs for uses:
2383
2384 @smallexample
2385 int old_fn () __attribute__ ((deprecated));
2386 int old_fn ();
2387 int (*fn_ptr)() = old_fn;
2388 @end smallexample
2389
2390 @noindent
2391 results in a warning on line 3 but not line 2. The optional @var{msg}
2392 argument, which must be a string, is printed in the warning if
2393 present.
2394
2395 The @code{deprecated} attribute can also be used for variables and
2396 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2397
2398 @item disinterrupt
2399 @cindex @code{disinterrupt} attribute
2400 On Epiphany and MeP targets, this attribute causes the compiler to emit
2401 instructions to disable interrupts for the duration of the given
2402 function.
2403
2404 @item dllexport
2405 @cindex @code{__declspec(dllexport)}
2406 On Microsoft Windows targets and Symbian OS targets the
2407 @code{dllexport} attribute causes the compiler to provide a global
2408 pointer to a pointer in a DLL, so that it can be referenced with the
2409 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
2410 name is formed by combining @code{_imp__} and the function or variable
2411 name.
2412
2413 You can use @code{__declspec(dllexport)} as a synonym for
2414 @code{__attribute__ ((dllexport))} for compatibility with other
2415 compilers.
2416
2417 On systems that support the @code{visibility} attribute, this
2418 attribute also implies ``default'' visibility. It is an error to
2419 explicitly specify any other visibility.
2420
2421 In previous versions of GCC, the @code{dllexport} attribute was ignored
2422 for inlined functions, unless the @option{-fkeep-inline-functions} flag
2423 had been used. The default behavior now is to emit all dllexported
2424 inline functions; however, this can cause object file-size bloat, in
2425 which case the old behavior can be restored by using
2426 @option{-fno-keep-inline-dllexport}.
2427
2428 The attribute is also ignored for undefined symbols.
2429
2430 When applied to C++ classes, the attribute marks defined non-inlined
2431 member functions and static data members as exports. Static consts
2432 initialized in-class are not marked unless they are also defined
2433 out-of-class.
2434
2435 For Microsoft Windows targets there are alternative methods for
2436 including the symbol in the DLL's export table such as using a
2437 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
2438 the @option{--export-all} linker flag.
2439
2440 @item dllimport
2441 @cindex @code{__declspec(dllimport)}
2442 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
2443 attribute causes the compiler to reference a function or variable via
2444 a global pointer to a pointer that is set up by the DLL exporting the
2445 symbol. The attribute implies @code{extern}. On Microsoft Windows
2446 targets, the pointer name is formed by combining @code{_imp__} and the
2447 function or variable name.
2448
2449 You can use @code{__declspec(dllimport)} as a synonym for
2450 @code{__attribute__ ((dllimport))} for compatibility with other
2451 compilers.
2452
2453 On systems that support the @code{visibility} attribute, this
2454 attribute also implies ``default'' visibility. It is an error to
2455 explicitly specify any other visibility.
2456
2457 Currently, the attribute is ignored for inlined functions. If the
2458 attribute is applied to a symbol @emph{definition}, an error is reported.
2459 If a symbol previously declared @code{dllimport} is later defined, the
2460 attribute is ignored in subsequent references, and a warning is emitted.
2461 The attribute is also overridden by a subsequent declaration as
2462 @code{dllexport}.
2463
2464 When applied to C++ classes, the attribute marks non-inlined
2465 member functions and static data members as imports. However, the
2466 attribute is ignored for virtual methods to allow creation of vtables
2467 using thunks.
2468
2469 On the SH Symbian OS target the @code{dllimport} attribute also has
2470 another affect---it can cause the vtable and run-time type information
2471 for a class to be exported. This happens when the class has a
2472 dllimported constructor or a non-inline, non-pure virtual function
2473 and, for either of those two conditions, the class also has an inline
2474 constructor or destructor and has a key function that is defined in
2475 the current translation unit.
2476
2477 For Microsoft Windows targets the use of the @code{dllimport}
2478 attribute on functions is not necessary, but provides a small
2479 performance benefit by eliminating a thunk in the DLL@. The use of the
2480 @code{dllimport} attribute on imported variables was required on older
2481 versions of the GNU linker, but can now be avoided by passing the
2482 @option{--enable-auto-import} switch to the GNU linker. As with
2483 functions, using the attribute for a variable eliminates a thunk in
2484 the DLL@.
2485
2486 One drawback to using this attribute is that a pointer to a
2487 @emph{variable} marked as @code{dllimport} cannot be used as a constant
2488 address. However, a pointer to a @emph{function} with the
2489 @code{dllimport} attribute can be used as a constant initializer; in
2490 this case, the address of a stub function in the import lib is
2491 referenced. On Microsoft Windows targets, the attribute can be disabled
2492 for functions by setting the @option{-mnop-fun-dllimport} flag.
2493
2494 @item eightbit_data
2495 @cindex eight-bit data on the H8/300, H8/300H, and H8S
2496 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2497 variable should be placed into the eight-bit data section.
2498 The compiler generates more efficient code for certain operations
2499 on data in the eight-bit data area. Note the eight-bit data area is limited to
2500 256 bytes of data.
2501
2502 You must use GAS and GLD from GNU binutils version 2.7 or later for
2503 this attribute to work correctly.
2504
2505 @item exception_handler
2506 @cindex exception handler functions on the Blackfin processor
2507 Use this attribute on the Blackfin to indicate that the specified function
2508 is an exception handler. The compiler generates function entry and
2509 exit sequences suitable for use in an exception handler when this
2510 attribute is present.
2511
2512 @item externally_visible
2513 @cindex @code{externally_visible} attribute.
2514 This attribute, attached to a global variable or function, nullifies
2515 the effect of the @option{-fwhole-program} command-line option, so the
2516 object remains visible outside the current compilation unit.
2517
2518 If @option{-fwhole-program} is used together with @option{-flto} and
2519 @command{gold} is used as the linker plugin,
2520 @code{externally_visible} attributes are automatically added to functions
2521 (not variable yet due to a current @command{gold} issue)
2522 that are accessed outside of LTO objects according to resolution file
2523 produced by @command{gold}.
2524 For other linkers that cannot generate resolution file,
2525 explicit @code{externally_visible} attributes are still necessary.
2526
2527 @item far
2528 @cindex functions that handle memory bank switching
2529 On 68HC11 and 68HC12 the @code{far} attribute causes the compiler to
2530 use a calling convention that takes care of switching memory banks when
2531 entering and leaving a function. This calling convention is also the
2532 default when using the @option{-mlong-calls} option.
2533
2534 On 68HC12 the compiler uses the @code{call} and @code{rtc} instructions
2535 to call and return from a function.
2536
2537 On 68HC11 the compiler generates a sequence of instructions
2538 to invoke a board-specific routine to switch the memory bank and call the
2539 real function. The board-specific routine simulates a @code{call}.
2540 At the end of a function, it jumps to a board-specific routine
2541 instead of using @code{rts}. The board-specific return routine simulates
2542 the @code{rtc}.
2543
2544 On MeP targets this causes the compiler to use a calling convention
2545 that assumes the called function is too far away for the built-in
2546 addressing modes.
2547
2548 @item fast_interrupt
2549 @cindex interrupt handler functions
2550 Use this attribute on the M32C and RX ports to indicate that the specified
2551 function is a fast interrupt handler. This is just like the
2552 @code{interrupt} attribute, except that @code{freit} is used to return
2553 instead of @code{reit}.
2554
2555 @item fastcall
2556 @cindex functions that pop the argument stack on the 386
2557 On the Intel 386, the @code{fastcall} attribute causes the compiler to
2558 pass the first argument (if of integral type) in the register ECX and
2559 the second argument (if of integral type) in the register EDX@. Subsequent
2560 and other typed arguments are passed on the stack. The called function
2561 pops the arguments off the stack. If the number of arguments is variable all
2562 arguments are pushed on the stack.
2563
2564 @item thiscall
2565 @cindex functions that pop the argument stack on the 386
2566 On the Intel 386, the @code{thiscall} attribute causes the compiler to
2567 pass the first argument (if of integral type) in the register ECX.
2568 Subsequent and other typed arguments are passed on the stack. The called
2569 function pops the arguments off the stack.
2570 If the number of arguments is variable all arguments are pushed on the
2571 stack.
2572 The @code{thiscall} attribute is intended for C++ non-static member functions.
2573 As a GCC extension, this calling convention can be used for C functions
2574 and for static member methods.
2575
2576 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2577 @cindex @code{format} function attribute
2578 @opindex Wformat
2579 The @code{format} attribute specifies that a function takes @code{printf},
2580 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2581 should be type-checked against a format string. For example, the
2582 declaration:
2583
2584 @smallexample
2585 extern int
2586 my_printf (void *my_object, const char *my_format, ...)
2587 __attribute__ ((format (printf, 2, 3)));
2588 @end smallexample
2589
2590 @noindent
2591 causes the compiler to check the arguments in calls to @code{my_printf}
2592 for consistency with the @code{printf} style format string argument
2593 @code{my_format}.
2594
2595 The parameter @var{archetype} determines how the format string is
2596 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2597 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2598 @code{strfmon}. (You can also use @code{__printf__},
2599 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2600 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2601 @code{ms_strftime} are also present.
2602 @var{archetype} values such as @code{printf} refer to the formats accepted
2603 by the system's C runtime library,
2604 while values prefixed with @samp{gnu_} always refer
2605 to the formats accepted by the GNU C Library. On Microsoft Windows
2606 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2607 @file{msvcrt.dll} library.
2608 The parameter @var{string-index}
2609 specifies which argument is the format string argument (starting
2610 from 1), while @var{first-to-check} is the number of the first
2611 argument to check against the format string. For functions
2612 where the arguments are not available to be checked (such as
2613 @code{vprintf}), specify the third parameter as zero. In this case the
2614 compiler only checks the format string for consistency. For
2615 @code{strftime} formats, the third parameter is required to be zero.
2616 Since non-static C++ methods have an implicit @code{this} argument, the
2617 arguments of such methods should be counted from two, not one, when
2618 giving values for @var{string-index} and @var{first-to-check}.
2619
2620 In the example above, the format string (@code{my_format}) is the second
2621 argument of the function @code{my_print}, and the arguments to check
2622 start with the third argument, so the correct parameters for the format
2623 attribute are 2 and 3.
2624
2625 @opindex ffreestanding
2626 @opindex fno-builtin
2627 The @code{format} attribute allows you to identify your own functions
2628 that take format strings as arguments, so that GCC can check the
2629 calls to these functions for errors. The compiler always (unless
2630 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2631 for the standard library functions @code{printf}, @code{fprintf},
2632 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2633 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2634 warnings are requested (using @option{-Wformat}), so there is no need to
2635 modify the header file @file{stdio.h}. In C99 mode, the functions
2636 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2637 @code{vsscanf} are also checked. Except in strictly conforming C
2638 standard modes, the X/Open function @code{strfmon} is also checked as
2639 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2640 @xref{C Dialect Options,,Options Controlling C Dialect}.
2641
2642 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2643 recognized in the same context. Declarations including these format attributes
2644 are parsed for correct syntax, however the result of checking of such format
2645 strings is not yet defined, and is not carried out by this version of the
2646 compiler.
2647
2648 The target may also provide additional types of format checks.
2649 @xref{Target Format Checks,,Format Checks Specific to Particular
2650 Target Machines}.
2651
2652 @item format_arg (@var{string-index})
2653 @cindex @code{format_arg} function attribute
2654 @opindex Wformat-nonliteral
2655 The @code{format_arg} attribute specifies that a function takes a format
2656 string for a @code{printf}, @code{scanf}, @code{strftime} or
2657 @code{strfmon} style function and modifies it (for example, to translate
2658 it into another language), so the result can be passed to a
2659 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2660 function (with the remaining arguments to the format function the same
2661 as they would have been for the unmodified string). For example, the
2662 declaration:
2663
2664 @smallexample
2665 extern char *
2666 my_dgettext (char *my_domain, const char *my_format)
2667 __attribute__ ((format_arg (2)));
2668 @end smallexample
2669
2670 @noindent
2671 causes the compiler to check the arguments in calls to a @code{printf},
2672 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2673 format string argument is a call to the @code{my_dgettext} function, for
2674 consistency with the format string argument @code{my_format}. If the
2675 @code{format_arg} attribute had not been specified, all the compiler
2676 could tell in such calls to format functions would be that the format
2677 string argument is not constant; this would generate a warning when
2678 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2679 without the attribute.
2680
2681 The parameter @var{string-index} specifies which argument is the format
2682 string argument (starting from one). Since non-static C++ methods have
2683 an implicit @code{this} argument, the arguments of such methods should
2684 be counted from two.
2685
2686 The @code{format_arg} attribute allows you to identify your own
2687 functions that modify format strings, so that GCC can check the
2688 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2689 type function whose operands are a call to one of your own function.
2690 The compiler always treats @code{gettext}, @code{dgettext}, and
2691 @code{dcgettext} in this manner except when strict ISO C support is
2692 requested by @option{-ansi} or an appropriate @option{-std} option, or
2693 @option{-ffreestanding} or @option{-fno-builtin}
2694 is used. @xref{C Dialect Options,,Options
2695 Controlling C Dialect}.
2696
2697 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2698 @code{NSString} reference for compatibility with the @code{format} attribute
2699 above.
2700
2701 The target may also allow additional types in @code{format-arg} attributes.
2702 @xref{Target Format Checks,,Format Checks Specific to Particular
2703 Target Machines}.
2704
2705 @item function_vector
2706 @cindex calling functions through the function vector on H8/300, M16C, M32C and SH2A processors
2707 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
2708 function should be called through the function vector. Calling a
2709 function through the function vector reduces code size, however;
2710 the function vector has a limited size (maximum 128 entries on the H8/300
2711 and 64 entries on the H8/300H and H8S) and shares space with the interrupt vector.
2712
2713 On SH2A targets, this attribute declares a function to be called using the
2714 TBR relative addressing mode. The argument to this attribute is the entry
2715 number of the same function in a vector table containing all the TBR
2716 relative addressable functions. For correct operation the TBR must be setup
2717 accordingly to point to the start of the vector table before any functions with
2718 this attribute are invoked. Usually a good place to do the initialization is
2719 the startup routine. The TBR relative vector table can have at max 256 function
2720 entries. The jumps to these functions are generated using a SH2A specific,
2721 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
2722 from GNU binutils version 2.7 or later for this attribute to work correctly.
2723
2724 Please refer the example of M16C target, to see the use of this
2725 attribute while declaring a function,
2726
2727 In an application, for a function being called once, this attribute
2728 saves at least 8 bytes of code; and if other successive calls are being
2729 made to the same function, it saves 2 bytes of code per each of these
2730 calls.
2731
2732 On M16C/M32C targets, the @code{function_vector} attribute declares a
2733 special page subroutine call function. Use of this attribute reduces
2734 the code size by 2 bytes for each call generated to the
2735 subroutine. The argument to the attribute is the vector number entry
2736 from the special page vector table which contains the 16 low-order
2737 bits of the subroutine's entry address. Each vector table has special
2738 page number (18 to 255) that is used in @code{jsrs} instructions.
2739 Jump addresses of the routines are generated by adding 0x0F0000 (in
2740 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
2741 2-byte addresses set in the vector table. Therefore you need to ensure
2742 that all the special page vector routines should get mapped within the
2743 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
2744 (for M32C).
2745
2746 In the following example 2 bytes are saved for each call to
2747 function @code{foo}.
2748
2749 @smallexample
2750 void foo (void) __attribute__((function_vector(0x18)));
2751 void foo (void)
2752 @{
2753 @}
2754
2755 void bar (void)
2756 @{
2757 foo();
2758 @}
2759 @end smallexample
2760
2761 If functions are defined in one file and are called in another file,
2762 then be sure to write this declaration in both files.
2763
2764 This attribute is ignored for R8C target.
2765
2766 @item ifunc ("@var{resolver}")
2767 @cindex @code{ifunc} attribute
2768 The @code{ifunc} attribute is used to mark a function as an indirect
2769 function using the STT_GNU_IFUNC symbol type extension to the ELF
2770 standard. This allows the resolution of the symbol value to be
2771 determined dynamically at load time, and an optimized version of the
2772 routine can be selected for the particular processor or other system
2773 characteristics determined then. To use this attribute, first define
2774 the implementation functions available, and a resolver function that
2775 returns a pointer to the selected implementation function. The
2776 implementation functions' declarations must match the API of the
2777 function being implemented, the resolver's declaration is be a
2778 function returning pointer to void function returning void:
2779
2780 @smallexample
2781 void *my_memcpy (void *dst, const void *src, size_t len)
2782 @{
2783 @dots{}
2784 @}
2785
2786 static void (*resolve_memcpy (void)) (void)
2787 @{
2788 return my_memcpy; // we'll just always select this routine
2789 @}
2790 @end smallexample
2791
2792 @noindent
2793 The exported header file declaring the function the user calls would
2794 contain:
2795
2796 @smallexample
2797 extern void *memcpy (void *, const void *, size_t);
2798 @end smallexample
2799
2800 @noindent
2801 allowing the user to call this as a regular function, unaware of the
2802 implementation. Finally, the indirect function needs to be defined in
2803 the same translation unit as the resolver function:
2804
2805 @smallexample
2806 void *memcpy (void *, const void *, size_t)
2807 __attribute__ ((ifunc ("resolve_memcpy")));
2808 @end smallexample
2809
2810 Indirect functions cannot be weak, and require a recent binutils (at
2811 least version 2.20.1), and GNU C library (at least version 2.11.1).
2812
2813 @item interrupt
2814 @cindex interrupt handler functions
2815 Use this attribute on the ARM, AVR, CR16, Epiphany, M32C, M32R/D, m68k, MeP, MIPS,
2816 RL78, RX and Xstormy16 ports to indicate that the specified function is an
2817 interrupt handler. The compiler generates function entry and exit
2818 sequences suitable for use in an interrupt handler when this attribute
2819 is present. With Epiphany targets it may also generate a special section with
2820 code to initialize the interrupt vector table.
2821
2822 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
2823 and SH processors can be specified via the @code{interrupt_handler} attribute.
2824
2825 Note, on the AVR, the hardware globally disables interrupts when an
2826 interrupt is executed. The first instruction of an interrupt handler
2827 declared with this attribute is a @code{SEI} instruction to
2828 re-enable interrupts. See also the @code{signal} function attribute
2829 that does not insert a @code{SEI} instruction. If both @code{signal} and
2830 @code{interrupt} are specified for the same function, @code{signal}
2831 is silently ignored.
2832
2833 Note, for the ARM, you can specify the kind of interrupt to be handled by
2834 adding an optional parameter to the interrupt attribute like this:
2835
2836 @smallexample
2837 void f () __attribute__ ((interrupt ("IRQ")));
2838 @end smallexample
2839
2840 @noindent
2841 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
2842 @code{SWI}, @code{ABORT} and @code{UNDEF}.
2843
2844 On ARMv7-M the interrupt type is ignored, and the attribute means the function
2845 may be called with a word-aligned stack pointer.
2846
2847 On Epiphany targets one or more optional parameters can be added like this:
2848
2849 @smallexample
2850 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2851 @end smallexample
2852
2853 Permissible values for these parameters are: @w{@code{reset}},
2854 @w{@code{software_exception}}, @w{@code{page_miss}},
2855 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
2856 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
2857 Multiple parameters indicate that multiple entries in the interrupt
2858 vector table should be initialized for this function, i.e.@: for each
2859 parameter @w{@var{name}}, a jump to the function is emitted in
2860 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
2861 entirely, in which case no interrupt vector table entry is provided.
2862
2863 Note, on Epiphany targets, interrupts are enabled inside the function
2864 unless the @code{disinterrupt} attribute is also specified.
2865
2866 On Epiphany targets, you can also use the following attribute to
2867 modify the behavior of an interrupt handler:
2868 @table @code
2869 @item forwarder_section
2870 @cindex @code{forwarder_section} attribute
2871 The interrupt handler may be in external memory which cannot be
2872 reached by a branch instruction, so generate a local memory trampoline
2873 to transfer control. The single parameter identifies the section where
2874 the trampoline is placed.
2875 @end table
2876
2877 The following examples are all valid uses of these attributes on
2878 Epiphany targets:
2879 @smallexample
2880 void __attribute__ ((interrupt)) universal_handler ();
2881 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
2882 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
2883 void __attribute__ ((interrupt ("timer0"), disinterrupt))
2884 fast_timer_handler ();
2885 void __attribute__ ((interrupt ("dma0, dma1"), forwarder_section ("tramp")))
2886 external_dma_handler ();
2887 @end smallexample
2888
2889 On MIPS targets, you can use the following attributes to modify the behavior
2890 of an interrupt handler:
2891 @table @code
2892 @item use_shadow_register_set
2893 @cindex @code{use_shadow_register_set} attribute
2894 Assume that the handler uses a shadow register set, instead of
2895 the main general-purpose registers.
2896
2897 @item keep_interrupts_masked
2898 @cindex @code{keep_interrupts_masked} attribute
2899 Keep interrupts masked for the whole function. Without this attribute,
2900 GCC tries to reenable interrupts for as much of the function as it can.
2901
2902 @item use_debug_exception_return
2903 @cindex @code{use_debug_exception_return} attribute
2904 Return using the @code{deret} instruction. Interrupt handlers that don't
2905 have this attribute return using @code{eret} instead.
2906 @end table
2907
2908 You can use any combination of these attributes, as shown below:
2909 @smallexample
2910 void __attribute__ ((interrupt)) v0 ();
2911 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
2912 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
2913 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
2914 void __attribute__ ((interrupt, use_shadow_register_set,
2915 keep_interrupts_masked)) v4 ();
2916 void __attribute__ ((interrupt, use_shadow_register_set,
2917 use_debug_exception_return)) v5 ();
2918 void __attribute__ ((interrupt, keep_interrupts_masked,
2919 use_debug_exception_return)) v6 ();
2920 void __attribute__ ((interrupt, use_shadow_register_set,
2921 keep_interrupts_masked,
2922 use_debug_exception_return)) v7 ();
2923 @end smallexample
2924
2925 On RL78, use @code{brk_interrupt} instead of @code{interrupt} for
2926 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
2927 that must end with @code{RETB} instead of @code{RETI}).
2928
2929 @item interrupt_handler
2930 @cindex interrupt handler functions on the Blackfin, m68k, H8/300 and SH processors
2931 Use this attribute on the Blackfin, m68k, H8/300, H8/300H, H8S, and SH to
2932 indicate that the specified function is an interrupt handler. The compiler
2933 generates function entry and exit sequences suitable for use in an
2934 interrupt handler when this attribute is present.
2935
2936 @item interrupt_thread
2937 @cindex interrupt thread functions on fido
2938 Use this attribute on fido, a subarchitecture of the m68k, to indicate
2939 that the specified function is an interrupt handler that is designed
2940 to run as a thread. The compiler omits generate prologue/epilogue
2941 sequences and replaces the return instruction with a @code{sleep}
2942 instruction. This attribute is available only on fido.
2943
2944 @item isr
2945 @cindex interrupt service routines on ARM
2946 Use this attribute on ARM to write Interrupt Service Routines. This is an
2947 alias to the @code{interrupt} attribute above.
2948
2949 @item kspisusp
2950 @cindex User stack pointer in interrupts on the Blackfin
2951 When used together with @code{interrupt_handler}, @code{exception_handler}
2952 or @code{nmi_handler}, code is generated to load the stack pointer
2953 from the USP register in the function prologue.
2954
2955 @item l1_text
2956 @cindex @code{l1_text} function attribute
2957 This attribute specifies a function to be placed into L1 Instruction
2958 SRAM@. The function is put into a specific section named @code{.l1.text}.
2959 With @option{-mfdpic}, function calls with a such function as the callee
2960 or caller uses inlined PLT.
2961
2962 @item l2
2963 @cindex @code{l2} function attribute
2964 On the Blackfin, this attribute specifies a function to be placed into L2
2965 SRAM. The function is put into a specific section named
2966 @code{.l1.text}. With @option{-mfdpic}, callers of such functions use
2967 an inlined PLT.
2968
2969 @item leaf
2970 @cindex @code{leaf} function attribute
2971 Calls to external functions with this attribute must return to the current
2972 compilation unit only by return or by exception handling. In particular, leaf
2973 functions are not allowed to call callback function passed to it from the current
2974 compilation unit or directly call functions exported by the unit or longjmp
2975 into the unit. Leaf function might still call functions from other compilation
2976 units and thus they are not necessarily leaf in the sense that they contain no
2977 function calls at all.
2978
2979 The attribute is intended for library functions to improve dataflow analysis.
2980 The compiler takes the hint that any data not escaping the current compilation unit can
2981 not be used or modified by the leaf function. For example, the @code{sin} function
2982 is a leaf function, but @code{qsort} is not.
2983
2984 Note that leaf functions might invoke signals and signal handlers might be
2985 defined in the current compilation unit and use static variables. The only
2986 compliant way to write such a signal handler is to declare such variables
2987 @code{volatile}.
2988
2989 The attribute has no effect on functions defined within the current compilation
2990 unit. This is to allow easy merging of multiple compilation units into one,
2991 for example, by using the link-time optimization. For this reason the
2992 attribute is not allowed on types to annotate indirect calls.
2993
2994 @item long_call/short_call
2995 @cindex indirect calls on ARM
2996 This attribute specifies how a particular function is called on
2997 ARM and Epiphany. Both attributes override the
2998 @option{-mlong-calls} (@pxref{ARM Options})
2999 command-line switch and @code{#pragma long_calls} settings. The
3000 @code{long_call} attribute indicates that the function might be far
3001 away from the call site and require a different (more expensive)
3002 calling sequence. The @code{short_call} attribute always places
3003 the offset to the function from the call site into the @samp{BL}
3004 instruction directly.
3005
3006 @item longcall/shortcall
3007 @cindex functions called via pointer on the RS/6000 and PowerPC
3008 On the Blackfin, RS/6000 and PowerPC, the @code{longcall} attribute
3009 indicates that the function might be far away from the call site and
3010 require a different (more expensive) calling sequence. The
3011 @code{shortcall} attribute indicates that the function is always close
3012 enough for the shorter calling sequence to be used. These attributes
3013 override both the @option{-mlongcall} switch and, on the RS/6000 and
3014 PowerPC, the @code{#pragma longcall} setting.
3015
3016 @xref{RS/6000 and PowerPC Options}, for more information on whether long
3017 calls are necessary.
3018
3019 @item long_call/near/far
3020 @cindex indirect calls on MIPS
3021 These attributes specify how a particular function is called on MIPS@.
3022 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
3023 command-line switch. The @code{long_call} and @code{far} attributes are
3024 synonyms, and cause the compiler to always call
3025 the function by first loading its address into a register, and then using
3026 the contents of that register. The @code{near} attribute has the opposite
3027 effect; it specifies that non-PIC calls should be made using the more
3028 efficient @code{jal} instruction.
3029
3030 @item malloc
3031 @cindex @code{malloc} attribute
3032 The @code{malloc} attribute is used to tell the compiler that a function
3033 may be treated as if any non-@code{NULL} pointer it returns cannot
3034 alias any other pointer valid when the function returns and that the memory
3035 has undefined content.
3036 This often improves optimization.
3037 Standard functions with this property include @code{malloc} and
3038 @code{calloc}. @code{realloc}-like functions do not have this
3039 property as the memory pointed to does not have undefined content.
3040
3041 @item mips16/nomips16
3042 @cindex @code{mips16} attribute
3043 @cindex @code{nomips16} attribute
3044
3045 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
3046 function attributes to locally select or turn off MIPS16 code generation.
3047 A function with the @code{mips16} attribute is emitted as MIPS16 code,
3048 while MIPS16 code generation is disabled for functions with the
3049 @code{nomips16} attribute. These attributes override the
3050 @option{-mips16} and @option{-mno-mips16} options on the command line
3051 (@pxref{MIPS Options}).
3052
3053 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
3054 preprocessor symbol @code{__mips16} reflects the setting on the command line,
3055 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
3056 may interact badly with some GCC extensions such as @code{__builtin_apply}
3057 (@pxref{Constructing Calls}).
3058
3059 @item micromips/nomicromips
3060 @cindex @code{micromips} attribute
3061 @cindex @code{nomicromips} attribute
3062
3063 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
3064 function attributes to locally select or turn off microMIPS code generation.
3065 A function with the @code{micromips} attribute is emitted as microMIPS code,
3066 while microMIPS code generation is disabled for functions with the
3067 @code{nomicromips} attribute. These attributes override the
3068 @option{-mmicromips} and @option{-mno-micromips} options on the command line
3069 (@pxref{MIPS Options}).
3070
3071 When compiling files containing mixed microMIPS and non-microMIPS code, the
3072 preprocessor symbol @code{__mips_micromips} reflects the setting on the
3073 command line,
3074 not that within individual functions. Mixed microMIPS and non-microMIPS code
3075 may interact badly with some GCC extensions such as @code{__builtin_apply}
3076 (@pxref{Constructing Calls}).
3077
3078 @item model (@var{model-name})
3079 @cindex function addressability on the M32R/D
3080 @cindex variable addressability on the IA-64
3081
3082 On the M32R/D, use this attribute to set the addressability of an
3083 object, and of the code generated for a function. The identifier
3084 @var{model-name} is one of @code{small}, @code{medium}, or
3085 @code{large}, representing each of the code models.
3086
3087 Small model objects live in the lower 16MB of memory (so that their
3088 addresses can be loaded with the @code{ld24} instruction), and are
3089 callable with the @code{bl} instruction.
3090
3091 Medium model objects may live anywhere in the 32-bit address space (the
3092 compiler generates @code{seth/add3} instructions to load their addresses),
3093 and are callable with the @code{bl} instruction.
3094
3095 Large model objects may live anywhere in the 32-bit address space (the
3096 compiler generates @code{seth/add3} instructions to load their addresses),
3097 and may not be reachable with the @code{bl} instruction (the compiler
3098 generates the much slower @code{seth/add3/jl} instruction sequence).
3099
3100 On IA-64, use this attribute to set the addressability of an object.
3101 At present, the only supported identifier for @var{model-name} is
3102 @code{small}, indicating addressability via ``small'' (22-bit)
3103 addresses (so that their addresses can be loaded with the @code{addl}
3104 instruction). Caveat: such addressing is by definition not position
3105 independent and hence this attribute must not be used for objects
3106 defined by shared libraries.
3107
3108 @item ms_abi/sysv_abi
3109 @cindex @code{ms_abi} attribute
3110 @cindex @code{sysv_abi} attribute
3111
3112 On 32-bit and 64-bit (i?86|x86_64)-*-* targets, you can use an ABI attribute
3113 to indicate which calling convention should be used for a function. The
3114 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
3115 while the @code{sysv_abi} attribute tells the compiler to use the ABI
3116 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
3117 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
3118
3119 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
3120 requires the @option{-maccumulate-outgoing-args} option.
3121
3122 @item callee_pop_aggregate_return (@var{number})
3123 @cindex @code{callee_pop_aggregate_return} attribute
3124
3125 On 32-bit i?86-*-* targets, you can use this attribute to control how
3126 aggregates are returned in memory. If the caller is responsible for
3127 popping the hidden pointer together with the rest of the arguments, specify
3128 @var{number} equal to zero. If callee is responsible for popping the
3129 hidden pointer, specify @var{number} equal to one.
3130
3131 The default i386 ABI assumes that the callee pops the
3132 stack for hidden pointer. However, on 32-bit i386 Microsoft Windows targets,
3133 the compiler assumes that the
3134 caller pops the stack for hidden pointer.
3135
3136 @item ms_hook_prologue
3137 @cindex @code{ms_hook_prologue} attribute
3138
3139 On 32-bit i[34567]86-*-* targets and 64-bit x86_64-*-* targets, you can use
3140 this function attribute to make GCC generate the ``hot-patching'' function
3141 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
3142 and newer.
3143
3144 @item naked
3145 @cindex function without a prologue/epilogue code
3146 Use this attribute on the ARM, AVR, MCORE, RL78, RX and SPU ports to indicate that
3147 the specified function does not need prologue/epilogue sequences generated by
3148 the compiler. It is up to the programmer to provide these sequences. The
3149 only statements that can be safely included in naked functions are
3150 @code{asm} statements that do not have operands. All other statements,
3151 including declarations of local variables, @code{if} statements, and so
3152 forth, should be avoided. Naked functions should be used to implement the
3153 body of an assembly function, while allowing the compiler to construct
3154 the requisite function declaration for the assembler.
3155
3156 @item near
3157 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
3158 On 68HC11 and 68HC12 the @code{near} attribute causes the compiler to
3159 use the normal calling convention based on @code{jsr} and @code{rts}.
3160 This attribute can be used to cancel the effect of the @option{-mlong-calls}
3161 option.
3162
3163 On MeP targets this attribute causes the compiler to assume the called
3164 function is close enough to use the normal calling convention,
3165 overriding the @option{-mtf} command-line option.
3166
3167 @item nesting
3168 @cindex Allow nesting in an interrupt handler on the Blackfin processor.
3169 Use this attribute together with @code{interrupt_handler},
3170 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3171 entry code should enable nested interrupts or exceptions.
3172
3173 @item nmi_handler
3174 @cindex NMI handler functions on the Blackfin processor
3175 Use this attribute on the Blackfin to indicate that the specified function
3176 is an NMI handler. The compiler generates function entry and
3177 exit sequences suitable for use in an NMI handler when this
3178 attribute is present.
3179
3180 @item nocompression
3181 @cindex @code{nocompression} attribute
3182 On MIPS targets, you can use the @code{nocompression} function attribute
3183 to locally turn off MIPS16 and microMIPS code generation. This attribute
3184 overrides the @option{-mips16} and @option{-mmicromips} options on the
3185 command line (@pxref{MIPS Options}).
3186
3187 @item no_instrument_function
3188 @cindex @code{no_instrument_function} function attribute
3189 @opindex finstrument-functions
3190 If @option{-finstrument-functions} is given, profiling function calls are
3191 generated at entry and exit of most user-compiled functions.
3192 Functions with this attribute are not so instrumented.
3193
3194 @item no_split_stack
3195 @cindex @code{no_split_stack} function attribute
3196 @opindex fsplit-stack
3197 If @option{-fsplit-stack} is given, functions have a small
3198 prologue which decides whether to split the stack. Functions with the
3199 @code{no_split_stack} attribute do not have that prologue, and thus
3200 may run with only a small amount of stack space available.
3201
3202 @item noinline
3203 @cindex @code{noinline} function attribute
3204 This function attribute prevents a function from being considered for
3205 inlining.
3206 @c Don't enumerate the optimizations by name here; we try to be
3207 @c future-compatible with this mechanism.
3208 If the function does not have side-effects, there are optimizations
3209 other than inlining that cause function calls to be optimized away,
3210 although the function call is live. To keep such calls from being
3211 optimized away, put
3212 @smallexample
3213 asm ("");
3214 @end smallexample
3215
3216 @noindent
3217 (@pxref{Extended Asm}) in the called function, to serve as a special
3218 side-effect.
3219
3220 @item noclone
3221 @cindex @code{noclone} function attribute
3222 This function attribute prevents a function from being considered for
3223 cloning---a mechanism that produces specialized copies of functions
3224 and which is (currently) performed by interprocedural constant
3225 propagation.
3226
3227 @item nonnull (@var{arg-index}, @dots{})
3228 @cindex @code{nonnull} function attribute
3229 The @code{nonnull} attribute specifies that some function parameters should
3230 be non-null pointers. For instance, the declaration:
3231
3232 @smallexample
3233 extern void *
3234 my_memcpy (void *dest, const void *src, size_t len)
3235 __attribute__((nonnull (1, 2)));
3236 @end smallexample
3237
3238 @noindent
3239 causes the compiler to check that, in calls to @code{my_memcpy},
3240 arguments @var{dest} and @var{src} are non-null. If the compiler
3241 determines that a null pointer is passed in an argument slot marked
3242 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3243 is issued. The compiler may also choose to make optimizations based
3244 on the knowledge that certain function arguments will never be null.
3245
3246 If no argument index list is given to the @code{nonnull} attribute,
3247 all pointer arguments are marked as non-null. To illustrate, the
3248 following declaration is equivalent to the previous example:
3249
3250 @smallexample
3251 extern void *
3252 my_memcpy (void *dest, const void *src, size_t len)
3253 __attribute__((nonnull));
3254 @end smallexample
3255
3256 @item noreturn
3257 @cindex @code{noreturn} function attribute
3258 A few standard library functions, such as @code{abort} and @code{exit},
3259 cannot return. GCC knows this automatically. Some programs define
3260 their own functions that never return. You can declare them
3261 @code{noreturn} to tell the compiler this fact. For example,
3262
3263 @smallexample
3264 @group
3265 void fatal () __attribute__ ((noreturn));
3266
3267 void
3268 fatal (/* @r{@dots{}} */)
3269 @{
3270 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3271 exit (1);
3272 @}
3273 @end group
3274 @end smallexample
3275
3276 The @code{noreturn} keyword tells the compiler to assume that
3277 @code{fatal} cannot return. It can then optimize without regard to what
3278 would happen if @code{fatal} ever did return. This makes slightly
3279 better code. More importantly, it helps avoid spurious warnings of
3280 uninitialized variables.
3281
3282 The @code{noreturn} keyword does not affect the exceptional path when that
3283 applies: a @code{noreturn}-marked function may still return to the caller
3284 by throwing an exception or calling @code{longjmp}.
3285
3286 Do not assume that registers saved by the calling function are
3287 restored before calling the @code{noreturn} function.
3288
3289 It does not make sense for a @code{noreturn} function to have a return
3290 type other than @code{void}.
3291
3292 The attribute @code{noreturn} is not implemented in GCC versions
3293 earlier than 2.5. An alternative way to declare that a function does
3294 not return, which works in the current version and in some older
3295 versions, is as follows:
3296
3297 @smallexample
3298 typedef void voidfn ();
3299
3300 volatile voidfn fatal;
3301 @end smallexample
3302
3303 @noindent
3304 This approach does not work in GNU C++.
3305
3306 @item nothrow
3307 @cindex @code{nothrow} function attribute
3308 The @code{nothrow} attribute is used to inform the compiler that a
3309 function cannot throw an exception. For example, most functions in
3310 the standard C library can be guaranteed not to throw an exception
3311 with the notable exceptions of @code{qsort} and @code{bsearch} that
3312 take function pointer arguments. The @code{nothrow} attribute is not
3313 implemented in GCC versions earlier than 3.3.
3314
3315 @item nosave_low_regs
3316 @cindex @code{nosave_low_regs} attribute
3317 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
3318 function should not save and restore registers R0..R7. This can be used on SH3*
3319 and SH4* targets that have a second R0..R7 register bank for non-reentrant
3320 interrupt handlers.
3321
3322 @item optimize
3323 @cindex @code{optimize} function attribute
3324 The @code{optimize} attribute is used to specify that a function is to
3325 be compiled with different optimization options than specified on the
3326 command line. Arguments can either be numbers or strings. Numbers
3327 are assumed to be an optimization level. Strings that begin with
3328 @code{O} are assumed to be an optimization option, while other options
3329 are assumed to be used with a @code{-f} prefix. You can also use the
3330 @samp{#pragma GCC optimize} pragma to set the optimization options
3331 that affect more than one function.
3332 @xref{Function Specific Option Pragmas}, for details about the
3333 @samp{#pragma GCC optimize} pragma.
3334
3335 This can be used for instance to have frequently-executed functions
3336 compiled with more aggressive optimization options that produce faster
3337 and larger code, while other functions can be compiled with less
3338 aggressive options.
3339
3340 @item OS_main/OS_task
3341 @cindex @code{OS_main} AVR function attribute
3342 @cindex @code{OS_task} AVR function attribute
3343 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3344 do not save/restore any call-saved register in their prologue/epilogue.
3345
3346 The @code{OS_main} attribute can be used when there @emph{is
3347 guarantee} that interrupts are disabled at the time when the function
3348 is entered. This saves resources when the stack pointer has to be
3349 changed to set up a frame for local variables.
3350
3351 The @code{OS_task} attribute can be used when there is @emph{no
3352 guarantee} that interrupts are disabled at that time when the function
3353 is entered like for, e@.g@. task functions in a multi-threading operating
3354 system. In that case, changing the stack pointer register is
3355 guarded by save/clear/restore of the global interrupt enable flag.
3356
3357 The differences to the @code{naked} function attribute are:
3358 @itemize @bullet
3359 @item @code{naked} functions do not have a return instruction whereas
3360 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3361 @code{RETI} return instruction.
3362 @item @code{naked} functions do not set up a frame for local variables
3363 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3364 as needed.
3365 @end itemize
3366
3367 @item pcs
3368 @cindex @code{pcs} function attribute
3369
3370 The @code{pcs} attribute can be used to control the calling convention
3371 used for a function on ARM. The attribute takes an argument that specifies
3372 the calling convention to use.
3373
3374 When compiling using the AAPCS ABI (or a variant of it) then valid
3375 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3376 order to use a variant other than @code{"aapcs"} then the compiler must
3377 be permitted to use the appropriate co-processor registers (i.e., the
3378 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3379 For example,
3380
3381 @smallexample
3382 /* Argument passed in r0, and result returned in r0+r1. */
3383 double f2d (float) __attribute__((pcs("aapcs")));
3384 @end smallexample
3385
3386 Variadic functions always use the @code{"aapcs"} calling convention and
3387 the compiler rejects attempts to specify an alternative.
3388
3389 @item pure
3390 @cindex @code{pure} function attribute
3391 Many functions have no effects except the return value and their
3392 return value depends only on the parameters and/or global variables.
3393 Such a function can be subject
3394 to common subexpression elimination and loop optimization just as an
3395 arithmetic operator would be. These functions should be declared
3396 with the attribute @code{pure}. For example,
3397
3398 @smallexample
3399 int square (int) __attribute__ ((pure));
3400 @end smallexample
3401
3402 @noindent
3403 says that the hypothetical function @code{square} is safe to call
3404 fewer times than the program says.
3405
3406 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3407 Interesting non-pure functions are functions with infinite loops or those
3408 depending on volatile memory or other system resource, that may change between
3409 two consecutive calls (such as @code{feof} in a multithreading environment).
3410
3411 The attribute @code{pure} is not implemented in GCC versions earlier
3412 than 2.96.
3413
3414 @item hot
3415 @cindex @code{hot} function attribute
3416 The @code{hot} attribute on a function is used to inform the compiler that
3417 the function is a hot spot of the compiled program. The function is
3418 optimized more aggressively and on many target it is placed into special
3419 subsection of the text section so all hot functions appears close together
3420 improving locality.
3421
3422 When profile feedback is available, via @option{-fprofile-use}, hot functions
3423 are automatically detected and this attribute is ignored.
3424
3425 The @code{hot} attribute on functions is not implemented in GCC versions
3426 earlier than 4.3.
3427
3428 @cindex @code{hot} label attribute
3429 The @code{hot} attribute on a label is used to inform the compiler that
3430 path following the label are more likely than paths that are not so
3431 annotated. This attribute is used in cases where @code{__builtin_expect}
3432 cannot be used, for instance with computed goto or @code{asm goto}.
3433
3434 The @code{hot} attribute on labels is not implemented in GCC versions
3435 earlier than 4.8.
3436
3437 @item cold
3438 @cindex @code{cold} function attribute
3439 The @code{cold} attribute on functions is used to inform the compiler that
3440 the function is unlikely to be executed. The function is optimized for
3441 size rather than speed and on many targets it is placed into special
3442 subsection of the text section so all cold functions appears close together
3443 improving code locality of non-cold parts of program. The paths leading
3444 to call of cold functions within code are marked as unlikely by the branch
3445 prediction mechanism. It is thus useful to mark functions used to handle
3446 unlikely conditions, such as @code{perror}, as cold to improve optimization
3447 of hot functions that do call marked functions in rare occasions.
3448
3449 When profile feedback is available, via @option{-fprofile-use}, cold functions
3450 are automatically detected and this attribute is ignored.
3451
3452 The @code{cold} attribute on functions is not implemented in GCC versions
3453 earlier than 4.3.
3454
3455 @cindex @code{cold} label attribute
3456 The @code{cold} attribute on labels is used to inform the compiler that
3457 the path following the label is unlikely to be executed. This attribute
3458 is used in cases where @code{__builtin_expect} cannot be used, for instance
3459 with computed goto or @code{asm goto}.
3460
3461 The @code{cold} attribute on labels is not implemented in GCC versions
3462 earlier than 4.8.
3463
3464 @item no_sanitize_address
3465 @itemx no_address_safety_analysis
3466 @cindex @code{no_sanitize_address} function attribute
3467 The @code{no_sanitize_address} attribute on functions is used
3468 to inform the compiler that it should not instrument memory accesses
3469 in the function when compiling with the @option{-fsanitize=address} option.
3470 The @code{no_address_safety_analysis} is a deprecated alias of the
3471 @code{no_sanitize_address} attribute, new code should use
3472 @code{no_sanitize_address}.
3473
3474 @item regparm (@var{number})
3475 @cindex @code{regparm} attribute
3476 @cindex functions that are passed arguments in registers on the 386
3477 On the Intel 386, the @code{regparm} attribute causes the compiler to
3478 pass arguments number one to @var{number} if they are of integral type
3479 in registers EAX, EDX, and ECX instead of on the stack. Functions that
3480 take a variable number of arguments continue to be passed all of their
3481 arguments on the stack.
3482
3483 Beware that on some ELF systems this attribute is unsuitable for
3484 global functions in shared libraries with lazy binding (which is the
3485 default). Lazy binding sends the first call via resolving code in
3486 the loader, which might assume EAX, EDX and ECX can be clobbered, as
3487 per the standard calling conventions. Solaris 8 is affected by this.
3488 Systems with the GNU C Library version 2.1 or higher
3489 and FreeBSD are believed to be
3490 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
3491 disabled with the linker or the loader if desired, to avoid the
3492 problem.)
3493
3494 @item sseregparm
3495 @cindex @code{sseregparm} attribute
3496 On the Intel 386 with SSE support, the @code{sseregparm} attribute
3497 causes the compiler to pass up to 3 floating-point arguments in
3498 SSE registers instead of on the stack. Functions that take a
3499 variable number of arguments continue to pass all of their
3500 floating-point arguments on the stack.
3501
3502 @item force_align_arg_pointer
3503 @cindex @code{force_align_arg_pointer} attribute
3504 On the Intel x86, the @code{force_align_arg_pointer} attribute may be
3505 applied to individual function definitions, generating an alternate
3506 prologue and epilogue that realigns the run-time stack if necessary.
3507 This supports mixing legacy codes that run with a 4-byte aligned stack
3508 with modern codes that keep a 16-byte stack for SSE compatibility.
3509
3510 @item renesas
3511 @cindex @code{renesas} attribute
3512 On SH targets this attribute specifies that the function or struct follows the
3513 Renesas ABI.
3514
3515 @item resbank
3516 @cindex @code{resbank} attribute
3517 On the SH2A target, this attribute enables the high-speed register
3518 saving and restoration using a register bank for @code{interrupt_handler}
3519 routines. Saving to the bank is performed automatically after the CPU
3520 accepts an interrupt that uses a register bank.
3521
3522 The nineteen 32-bit registers comprising general register R0 to R14,
3523 control register GBR, and system registers MACH, MACL, and PR and the
3524 vector table address offset are saved into a register bank. Register
3525 banks are stacked in first-in last-out (FILO) sequence. Restoration
3526 from the bank is executed by issuing a RESBANK instruction.
3527
3528 @item returns_twice
3529 @cindex @code{returns_twice} attribute
3530 The @code{returns_twice} attribute tells the compiler that a function may
3531 return more than one time. The compiler ensures that all registers
3532 are dead before calling such a function and emits a warning about
3533 the variables that may be clobbered after the second return from the
3534 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3535 The @code{longjmp}-like counterpart of such function, if any, might need
3536 to be marked with the @code{noreturn} attribute.
3537
3538 @item saveall
3539 @cindex save all registers on the Blackfin, H8/300, H8/300H, and H8S
3540 Use this attribute on the Blackfin, H8/300, H8/300H, and H8S to indicate that
3541 all registers except the stack pointer should be saved in the prologue
3542 regardless of whether they are used or not.
3543
3544 @item save_volatiles
3545 @cindex save volatile registers on the MicroBlaze
3546 Use this attribute on the MicroBlaze to indicate that the function is
3547 an interrupt handler. All volatile registers (in addition to non-volatile
3548 registers) are saved in the function prologue. If the function is a leaf
3549 function, only volatiles used by the function are saved. A normal function
3550 return is generated instead of a return from interrupt.
3551
3552 @item section ("@var{section-name}")
3553 @cindex @code{section} function attribute
3554 Normally, the compiler places the code it generates in the @code{text} section.
3555 Sometimes, however, you need additional sections, or you need certain
3556 particular functions to appear in special sections. The @code{section}
3557 attribute specifies that a function lives in a particular section.
3558 For example, the declaration:
3559
3560 @smallexample
3561 extern void foobar (void) __attribute__ ((section ("bar")));
3562 @end smallexample
3563
3564 @noindent
3565 puts the function @code{foobar} in the @code{bar} section.
3566
3567 Some file formats do not support arbitrary sections so the @code{section}
3568 attribute is not available on all platforms.
3569 If you need to map the entire contents of a module to a particular
3570 section, consider using the facilities of the linker instead.
3571
3572 @item sentinel
3573 @cindex @code{sentinel} function attribute
3574 This function attribute ensures that a parameter in a function call is
3575 an explicit @code{NULL}. The attribute is only valid on variadic
3576 functions. By default, the sentinel is located at position zero, the
3577 last parameter of the function call. If an optional integer position
3578 argument P is supplied to the attribute, the sentinel must be located at
3579 position P counting backwards from the end of the argument list.
3580
3581 @smallexample
3582 __attribute__ ((sentinel))
3583 is equivalent to
3584 __attribute__ ((sentinel(0)))
3585 @end smallexample
3586
3587 The attribute is automatically set with a position of 0 for the built-in
3588 functions @code{execl} and @code{execlp}. The built-in function
3589 @code{execle} has the attribute set with a position of 1.
3590
3591 A valid @code{NULL} in this context is defined as zero with any pointer
3592 type. If your system defines the @code{NULL} macro with an integer type
3593 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3594 with a copy that redefines NULL appropriately.
3595
3596 The warnings for missing or incorrect sentinels are enabled with
3597 @option{-Wformat}.
3598
3599 @item short_call
3600 See @code{long_call/short_call}.
3601
3602 @item shortcall
3603 See @code{longcall/shortcall}.
3604
3605 @item signal
3606 @cindex interrupt handler functions on the AVR processors
3607 Use this attribute on the AVR to indicate that the specified
3608 function is an interrupt handler. The compiler generates function
3609 entry and exit sequences suitable for use in an interrupt handler when this
3610 attribute is present.
3611
3612 See also the @code{interrupt} function attribute.
3613
3614 The AVR hardware globally disables interrupts when an interrupt is executed.
3615 Interrupt handler functions defined with the @code{signal} attribute
3616 do not re-enable interrupts. It is save to enable interrupts in a
3617 @code{signal} handler. This ``save'' only applies to the code
3618 generated by the compiler and not to the IRQ layout of the
3619 application which is responsibility of the application.
3620
3621 If both @code{signal} and @code{interrupt} are specified for the same
3622 function, @code{signal} is silently ignored.
3623
3624 @item sp_switch
3625 @cindex @code{sp_switch} attribute
3626 Use this attribute on the SH to indicate an @code{interrupt_handler}
3627 function should switch to an alternate stack. It expects a string
3628 argument that names a global variable holding the address of the
3629 alternate stack.
3630
3631 @smallexample
3632 void *alt_stack;
3633 void f () __attribute__ ((interrupt_handler,
3634 sp_switch ("alt_stack")));
3635 @end smallexample
3636
3637 @item stdcall
3638 @cindex functions that pop the argument stack on the 386
3639 On the Intel 386, the @code{stdcall} attribute causes the compiler to
3640 assume that the called function pops off the stack space used to
3641 pass arguments, unless it takes a variable number of arguments.
3642
3643 @item syscall_linkage
3644 @cindex @code{syscall_linkage} attribute
3645 This attribute is used to modify the IA-64 calling convention by marking
3646 all input registers as live at all function exits. This makes it possible
3647 to restart a system call after an interrupt without having to save/restore
3648 the input registers. This also prevents kernel data from leaking into
3649 application code.
3650
3651 @item target
3652 @cindex @code{target} function attribute
3653 The @code{target} attribute is used to specify that a function is to
3654 be compiled with different target options than specified on the
3655 command line. This can be used for instance to have functions
3656 compiled with a different ISA (instruction set architecture) than the
3657 default. You can also use the @samp{#pragma GCC target} pragma to set
3658 more than one function to be compiled with specific target options.
3659 @xref{Function Specific Option Pragmas}, for details about the
3660 @samp{#pragma GCC target} pragma.
3661
3662 For instance on a 386, you could compile one function with
3663 @code{target("sse4.1,arch=core2")} and another with
3664 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3665 compiling the first function with @option{-msse4.1} and
3666 @option{-march=core2} options, and the second function with
3667 @option{-msse4a} and @option{-march=amdfam10} options. It is up to the
3668 user to make sure that a function is only invoked on a machine that
3669 supports the particular ISA it is compiled for (for example by using
3670 @code{cpuid} on 386 to determine what feature bits and architecture
3671 family are used).
3672
3673 @smallexample
3674 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3675 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3676 @end smallexample
3677
3678 On the 386, the following options are allowed:
3679
3680 @table @samp
3681 @item abm
3682 @itemx no-abm
3683 @cindex @code{target("abm")} attribute
3684 Enable/disable the generation of the advanced bit instructions.
3685
3686 @item aes
3687 @itemx no-aes
3688 @cindex @code{target("aes")} attribute
3689 Enable/disable the generation of the AES instructions.
3690
3691 @item default
3692 @cindex @code{target("default")} attribute
3693 @xref{Function Multiversioning}, where it is used to specify the
3694 default function version.
3695
3696 @item mmx
3697 @itemx no-mmx
3698 @cindex @code{target("mmx")} attribute
3699 Enable/disable the generation of the MMX instructions.
3700
3701 @item pclmul
3702 @itemx no-pclmul
3703 @cindex @code{target("pclmul")} attribute
3704 Enable/disable the generation of the PCLMUL instructions.
3705
3706 @item popcnt
3707 @itemx no-popcnt
3708 @cindex @code{target("popcnt")} attribute
3709 Enable/disable the generation of the POPCNT instruction.
3710
3711 @item sse
3712 @itemx no-sse
3713 @cindex @code{target("sse")} attribute
3714 Enable/disable the generation of the SSE instructions.
3715
3716 @item sse2
3717 @itemx no-sse2
3718 @cindex @code{target("sse2")} attribute
3719 Enable/disable the generation of the SSE2 instructions.
3720
3721 @item sse3
3722 @itemx no-sse3
3723 @cindex @code{target("sse3")} attribute
3724 Enable/disable the generation of the SSE3 instructions.
3725
3726 @item sse4
3727 @itemx no-sse4
3728 @cindex @code{target("sse4")} attribute
3729 Enable/disable the generation of the SSE4 instructions (both SSE4.1
3730 and SSE4.2).
3731
3732 @item sse4.1
3733 @itemx no-sse4.1
3734 @cindex @code{target("sse4.1")} attribute
3735 Enable/disable the generation of the sse4.1 instructions.
3736
3737 @item sse4.2
3738 @itemx no-sse4.2
3739 @cindex @code{target("sse4.2")} attribute
3740 Enable/disable the generation of the sse4.2 instructions.
3741
3742 @item sse4a
3743 @itemx no-sse4a
3744 @cindex @code{target("sse4a")} attribute
3745 Enable/disable the generation of the SSE4A instructions.
3746
3747 @item fma4
3748 @itemx no-fma4
3749 @cindex @code{target("fma4")} attribute
3750 Enable/disable the generation of the FMA4 instructions.
3751
3752 @item xop
3753 @itemx no-xop
3754 @cindex @code{target("xop")} attribute
3755 Enable/disable the generation of the XOP instructions.
3756
3757 @item lwp
3758 @itemx no-lwp
3759 @cindex @code{target("lwp")} attribute
3760 Enable/disable the generation of the LWP instructions.
3761
3762 @item ssse3
3763 @itemx no-ssse3
3764 @cindex @code{target("ssse3")} attribute
3765 Enable/disable the generation of the SSSE3 instructions.
3766
3767 @item cld
3768 @itemx no-cld
3769 @cindex @code{target("cld")} attribute
3770 Enable/disable the generation of the CLD before string moves.
3771
3772 @item fancy-math-387
3773 @itemx no-fancy-math-387
3774 @cindex @code{target("fancy-math-387")} attribute
3775 Enable/disable the generation of the @code{sin}, @code{cos}, and
3776 @code{sqrt} instructions on the 387 floating-point unit.
3777
3778 @item fused-madd
3779 @itemx no-fused-madd
3780 @cindex @code{target("fused-madd")} attribute
3781 Enable/disable the generation of the fused multiply/add instructions.
3782
3783 @item ieee-fp
3784 @itemx no-ieee-fp
3785 @cindex @code{target("ieee-fp")} attribute
3786 Enable/disable the generation of floating point that depends on IEEE arithmetic.
3787
3788 @item inline-all-stringops
3789 @itemx no-inline-all-stringops
3790 @cindex @code{target("inline-all-stringops")} attribute
3791 Enable/disable inlining of string operations.
3792
3793 @item inline-stringops-dynamically
3794 @itemx no-inline-stringops-dynamically
3795 @cindex @code{target("inline-stringops-dynamically")} attribute
3796 Enable/disable the generation of the inline code to do small string
3797 operations and calling the library routines for large operations.
3798
3799 @item align-stringops
3800 @itemx no-align-stringops
3801 @cindex @code{target("align-stringops")} attribute
3802 Do/do not align destination of inlined string operations.
3803
3804 @item recip
3805 @itemx no-recip
3806 @cindex @code{target("recip")} attribute
3807 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
3808 instructions followed an additional Newton-Raphson step instead of
3809 doing a floating-point division.
3810
3811 @item arch=@var{ARCH}
3812 @cindex @code{target("arch=@var{ARCH}")} attribute
3813 Specify the architecture to generate code for in compiling the function.
3814
3815 @item tune=@var{TUNE}
3816 @cindex @code{target("tune=@var{TUNE}")} attribute
3817 Specify the architecture to tune for in compiling the function.
3818
3819 @item fpmath=@var{FPMATH}
3820 @cindex @code{target("fpmath=@var{FPMATH}")} attribute
3821 Specify which floating-point unit to use. The
3822 @code{target("fpmath=sse,387")} option must be specified as
3823 @code{target("fpmath=sse+387")} because the comma would separate
3824 different options.
3825 @end table
3826
3827 On the PowerPC, the following options are allowed:
3828
3829 @table @samp
3830 @item altivec
3831 @itemx no-altivec
3832 @cindex @code{target("altivec")} attribute
3833 Generate code that uses (does not use) AltiVec instructions. In
3834 32-bit code, you cannot enable AltiVec instructions unless
3835 @option{-mabi=altivec} is used on the command line.
3836
3837 @item cmpb
3838 @itemx no-cmpb
3839 @cindex @code{target("cmpb")} attribute
3840 Generate code that uses (does not use) the compare bytes instruction
3841 implemented on the POWER6 processor and other processors that support
3842 the PowerPC V2.05 architecture.
3843
3844 @item dlmzb
3845 @itemx no-dlmzb
3846 @cindex @code{target("dlmzb")} attribute
3847 Generate code that uses (does not use) the string-search @samp{dlmzb}
3848 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
3849 generated by default when targeting those processors.
3850
3851 @item fprnd
3852 @itemx no-fprnd
3853 @cindex @code{target("fprnd")} attribute
3854 Generate code that uses (does not use) the FP round to integer
3855 instructions implemented on the POWER5+ processor and other processors
3856 that support the PowerPC V2.03 architecture.
3857
3858 @item hard-dfp
3859 @itemx no-hard-dfp
3860 @cindex @code{target("hard-dfp")} attribute
3861 Generate code that uses (does not use) the decimal floating-point
3862 instructions implemented on some POWER processors.
3863
3864 @item isel
3865 @itemx no-isel
3866 @cindex @code{target("isel")} attribute
3867 Generate code that uses (does not use) ISEL instruction.
3868
3869 @item mfcrf
3870 @itemx no-mfcrf
3871 @cindex @code{target("mfcrf")} attribute
3872 Generate code that uses (does not use) the move from condition
3873 register field instruction implemented on the POWER4 processor and
3874 other processors that support the PowerPC V2.01 architecture.
3875
3876 @item mfpgpr
3877 @itemx no-mfpgpr
3878 @cindex @code{target("mfpgpr")} attribute
3879 Generate code that uses (does not use) the FP move to/from general
3880 purpose register instructions implemented on the POWER6X processor and
3881 other processors that support the extended PowerPC V2.05 architecture.
3882
3883 @item mulhw
3884 @itemx no-mulhw
3885 @cindex @code{target("mulhw")} attribute
3886 Generate code that uses (does not use) the half-word multiply and
3887 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
3888 These instructions are generated by default when targeting those
3889 processors.
3890
3891 @item multiple
3892 @itemx no-multiple
3893 @cindex @code{target("multiple")} attribute
3894 Generate code that uses (does not use) the load multiple word
3895 instructions and the store multiple word instructions.
3896
3897 @item update
3898 @itemx no-update
3899 @cindex @code{target("update")} attribute
3900 Generate code that uses (does not use) the load or store instructions
3901 that update the base register to the address of the calculated memory
3902 location.
3903
3904 @item popcntb
3905 @itemx no-popcntb
3906 @cindex @code{target("popcntb")} attribute
3907 Generate code that uses (does not use) the popcount and double-precision
3908 FP reciprocal estimate instruction implemented on the POWER5
3909 processor and other processors that support the PowerPC V2.02
3910 architecture.
3911
3912 @item popcntd
3913 @itemx no-popcntd
3914 @cindex @code{target("popcntd")} attribute
3915 Generate code that uses (does not use) the popcount instruction
3916 implemented on the POWER7 processor and other processors that support
3917 the PowerPC V2.06 architecture.
3918
3919 @item powerpc-gfxopt
3920 @itemx no-powerpc-gfxopt
3921 @cindex @code{target("powerpc-gfxopt")} attribute
3922 Generate code that uses (does not use) the optional PowerPC
3923 architecture instructions in the Graphics group, including
3924 floating-point select.
3925
3926 @item powerpc-gpopt
3927 @itemx no-powerpc-gpopt
3928 @cindex @code{target("powerpc-gpopt")} attribute
3929 Generate code that uses (does not use) the optional PowerPC
3930 architecture instructions in the General Purpose group, including
3931 floating-point square root.
3932
3933 @item recip-precision
3934 @itemx no-recip-precision
3935 @cindex @code{target("recip-precision")} attribute
3936 Assume (do not assume) that the reciprocal estimate instructions
3937 provide higher-precision estimates than is mandated by the powerpc
3938 ABI.
3939
3940 @item string
3941 @itemx no-string
3942 @cindex @code{target("string")} attribute
3943 Generate code that uses (does not use) the load string instructions
3944 and the store string word instructions to save multiple registers and
3945 do small block moves.
3946
3947 @item vsx
3948 @itemx no-vsx
3949 @cindex @code{target("vsx")} attribute
3950 Generate code that uses (does not use) vector/scalar (VSX)
3951 instructions, and also enable the use of built-in functions that allow
3952 more direct access to the VSX instruction set. In 32-bit code, you
3953 cannot enable VSX or AltiVec instructions unless
3954 @option{-mabi=altivec} is used on the command line.
3955
3956 @item friz
3957 @itemx no-friz
3958 @cindex @code{target("friz")} attribute
3959 Generate (do not generate) the @code{friz} instruction when the
3960 @option{-funsafe-math-optimizations} option is used to optimize
3961 rounding a floating-point value to 64-bit integer and back to floating
3962 point. The @code{friz} instruction does not return the same value if
3963 the floating-point number is too large to fit in an integer.
3964
3965 @item avoid-indexed-addresses
3966 @itemx no-avoid-indexed-addresses
3967 @cindex @code{target("avoid-indexed-addresses")} attribute
3968 Generate code that tries to avoid (not avoid) the use of indexed load
3969 or store instructions.
3970
3971 @item paired
3972 @itemx no-paired
3973 @cindex @code{target("paired")} attribute
3974 Generate code that uses (does not use) the generation of PAIRED simd
3975 instructions.
3976
3977 @item longcall
3978 @itemx no-longcall
3979 @cindex @code{target("longcall")} attribute
3980 Generate code that assumes (does not assume) that all calls are far
3981 away so that a longer more expensive calling sequence is required.
3982
3983 @item cpu=@var{CPU}
3984 @cindex @code{target("cpu=@var{CPU}")} attribute
3985 Specify the architecture to generate code for when compiling the
3986 function. If you select the @code{target("cpu=power7")} attribute when
3987 generating 32-bit code, VSX and AltiVec instructions are not generated
3988 unless you use the @option{-mabi=altivec} option on the command line.
3989
3990 @item tune=@var{TUNE}
3991 @cindex @code{target("tune=@var{TUNE}")} attribute
3992 Specify the architecture to tune for when compiling the function. If
3993 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
3994 you do specify the @code{target("cpu=@var{CPU}")} attribute,
3995 compilation tunes for the @var{CPU} architecture, and not the
3996 default tuning specified on the command line.
3997 @end table
3998
3999 On the 386/x86_64 and PowerPC back ends, you can use either multiple
4000 strings to specify multiple options, or you can separate the option
4001 with a comma (@code{,}).
4002
4003 On the 386/x86_64 and PowerPC back ends, the inliner does not inline a
4004 function that has different target options than the caller, unless the
4005 callee has a subset of the target options of the caller. For example
4006 a function declared with @code{target("sse3")} can inline a function
4007 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
4008
4009 The @code{target} attribute is not implemented in GCC versions earlier
4010 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. It is
4011 not currently implemented for other back ends.
4012
4013 @item tiny_data
4014 @cindex tiny data section on the H8/300H and H8S
4015 Use this attribute on the H8/300H and H8S to indicate that the specified
4016 variable should be placed into the tiny data section.
4017 The compiler generates more efficient code for loads and stores
4018 on data in the tiny data section. Note the tiny data area is limited to
4019 slightly under 32KB of data.
4020
4021 @item trap_exit
4022 @cindex @code{trap_exit} attribute
4023 Use this attribute on the SH for an @code{interrupt_handler} to return using
4024 @code{trapa} instead of @code{rte}. This attribute expects an integer
4025 argument specifying the trap number to be used.
4026
4027 @item trapa_handler
4028 @cindex @code{trapa_handler} attribute
4029 On SH targets this function attribute is similar to @code{interrupt_handler}
4030 but it does not save and restore all registers.
4031
4032 @item unused
4033 @cindex @code{unused} attribute.
4034 This attribute, attached to a function, means that the function is meant
4035 to be possibly unused. GCC does not produce a warning for this
4036 function.
4037
4038 @item used
4039 @cindex @code{used} attribute.
4040 This attribute, attached to a function, means that code must be emitted
4041 for the function even if it appears that the function is not referenced.
4042 This is useful, for example, when the function is referenced only in
4043 inline assembly.
4044
4045 When applied to a member function of a C++ class template, the
4046 attribute also means that the function is instantiated if the
4047 class itself is instantiated.
4048
4049 @item version_id
4050 @cindex @code{version_id} attribute
4051 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4052 symbol to contain a version string, thus allowing for function level
4053 versioning. HP-UX system header files may use function level versioning
4054 for some system calls.
4055
4056 @smallexample
4057 extern int foo () __attribute__((version_id ("20040821")));
4058 @end smallexample
4059
4060 @noindent
4061 Calls to @var{foo} are mapped to calls to @var{foo@{20040821@}}.
4062
4063 @item visibility ("@var{visibility_type}")
4064 @cindex @code{visibility} attribute
4065 This attribute affects the linkage of the declaration to which it is attached.
4066 There are four supported @var{visibility_type} values: default,
4067 hidden, protected or internal visibility.
4068
4069 @smallexample
4070 void __attribute__ ((visibility ("protected")))
4071 f () @{ /* @r{Do something.} */; @}
4072 int i __attribute__ ((visibility ("hidden")));
4073 @end smallexample
4074
4075 The possible values of @var{visibility_type} correspond to the
4076 visibility settings in the ELF gABI.
4077
4078 @table @dfn
4079 @c keep this list of visibilities in alphabetical order.
4080
4081 @item default
4082 Default visibility is the normal case for the object file format.
4083 This value is available for the visibility attribute to override other
4084 options that may change the assumed visibility of entities.
4085
4086 On ELF, default visibility means that the declaration is visible to other
4087 modules and, in shared libraries, means that the declared entity may be
4088 overridden.
4089
4090 On Darwin, default visibility means that the declaration is visible to
4091 other modules.
4092
4093 Default visibility corresponds to ``external linkage'' in the language.
4094
4095 @item hidden
4096 Hidden visibility indicates that the entity declared has a new
4097 form of linkage, which we call ``hidden linkage''. Two
4098 declarations of an object with hidden linkage refer to the same object
4099 if they are in the same shared object.
4100
4101 @item internal
4102 Internal visibility is like hidden visibility, but with additional
4103 processor specific semantics. Unless otherwise specified by the
4104 psABI, GCC defines internal visibility to mean that a function is
4105 @emph{never} called from another module. Compare this with hidden
4106 functions which, while they cannot be referenced directly by other
4107 modules, can be referenced indirectly via function pointers. By
4108 indicating that a function cannot be called from outside the module,
4109 GCC may for instance omit the load of a PIC register since it is known
4110 that the calling function loaded the correct value.
4111
4112 @item protected
4113 Protected visibility is like default visibility except that it
4114 indicates that references within the defining module bind to the
4115 definition in that module. That is, the declared entity cannot be
4116 overridden by another module.
4117
4118 @end table
4119
4120 All visibilities are supported on many, but not all, ELF targets
4121 (supported when the assembler supports the @samp{.visibility}
4122 pseudo-op). Default visibility is supported everywhere. Hidden
4123 visibility is supported on Darwin targets.
4124
4125 The visibility attribute should be applied only to declarations that
4126 would otherwise have external linkage. The attribute should be applied
4127 consistently, so that the same entity should not be declared with
4128 different settings of the attribute.
4129
4130 In C++, the visibility attribute applies to types as well as functions
4131 and objects, because in C++ types have linkage. A class must not have
4132 greater visibility than its non-static data member types and bases,
4133 and class members default to the visibility of their class. Also, a
4134 declaration without explicit visibility is limited to the visibility
4135 of its type.
4136
4137 In C++, you can mark member functions and static member variables of a
4138 class with the visibility attribute. This is useful if you know a
4139 particular method or static member variable should only be used from
4140 one shared object; then you can mark it hidden while the rest of the
4141 class has default visibility. Care must be taken to avoid breaking
4142 the One Definition Rule; for example, it is usually not useful to mark
4143 an inline method as hidden without marking the whole class as hidden.
4144
4145 A C++ namespace declaration can also have the visibility attribute.
4146 This attribute applies only to the particular namespace body, not to
4147 other definitions of the same namespace; it is equivalent to using
4148 @samp{#pragma GCC visibility} before and after the namespace
4149 definition (@pxref{Visibility Pragmas}).
4150
4151 In C++, if a template argument has limited visibility, this
4152 restriction is implicitly propagated to the template instantiation.
4153 Otherwise, template instantiations and specializations default to the
4154 visibility of their template.
4155
4156 If both the template and enclosing class have explicit visibility, the
4157 visibility from the template is used.
4158
4159 @item vliw
4160 @cindex @code{vliw} attribute
4161 On MeP, the @code{vliw} attribute tells the compiler to emit
4162 instructions in VLIW mode instead of core mode. Note that this
4163 attribute is not allowed unless a VLIW coprocessor has been configured
4164 and enabled through command-line options.
4165
4166 @item warn_unused_result
4167 @cindex @code{warn_unused_result} attribute
4168 The @code{warn_unused_result} attribute causes a warning to be emitted
4169 if a caller of the function with this attribute does not use its
4170 return value. This is useful for functions where not checking
4171 the result is either a security problem or always a bug, such as
4172 @code{realloc}.
4173
4174 @smallexample
4175 int fn () __attribute__ ((warn_unused_result));
4176 int foo ()
4177 @{
4178 if (fn () < 0) return -1;
4179 fn ();
4180 return 0;
4181 @}
4182 @end smallexample
4183
4184 @noindent
4185 results in warning on line 5.
4186
4187 @item weak
4188 @cindex @code{weak} attribute
4189 The @code{weak} attribute causes the declaration to be emitted as a weak
4190 symbol rather than a global. This is primarily useful in defining
4191 library functions that can be overridden in user code, though it can
4192 also be used with non-function declarations. Weak symbols are supported
4193 for ELF targets, and also for a.out targets when using the GNU assembler
4194 and linker.
4195
4196 @item weakref
4197 @itemx weakref ("@var{target}")
4198 @cindex @code{weakref} attribute
4199 The @code{weakref} attribute marks a declaration as a weak reference.
4200 Without arguments, it should be accompanied by an @code{alias} attribute
4201 naming the target symbol. Optionally, the @var{target} may be given as
4202 an argument to @code{weakref} itself. In either case, @code{weakref}
4203 implicitly marks the declaration as @code{weak}. Without a
4204 @var{target}, given as an argument to @code{weakref} or to @code{alias},
4205 @code{weakref} is equivalent to @code{weak}.
4206
4207 @smallexample
4208 static int x() __attribute__ ((weakref ("y")));
4209 /* is equivalent to... */
4210 static int x() __attribute__ ((weak, weakref, alias ("y")));
4211 /* and to... */
4212 static int x() __attribute__ ((weakref));
4213 static int x() __attribute__ ((alias ("y")));
4214 @end smallexample
4215
4216 A weak reference is an alias that does not by itself require a
4217 definition to be given for the target symbol. If the target symbol is
4218 only referenced through weak references, then it becomes a @code{weak}
4219 undefined symbol. If it is directly referenced, however, then such
4220 strong references prevail, and a definition is required for the
4221 symbol, not necessarily in the same translation unit.
4222
4223 The effect is equivalent to moving all references to the alias to a
4224 separate translation unit, renaming the alias to the aliased symbol,
4225 declaring it as weak, compiling the two separate translation units and
4226 performing a reloadable link on them.
4227
4228 At present, a declaration to which @code{weakref} is attached can
4229 only be @code{static}.
4230
4231 @end table
4232
4233 You can specify multiple attributes in a declaration by separating them
4234 by commas within the double parentheses or by immediately following an
4235 attribute declaration with another attribute declaration.
4236
4237 @cindex @code{#pragma}, reason for not using
4238 @cindex pragma, reason for not using
4239 Some people object to the @code{__attribute__} feature, suggesting that
4240 ISO C's @code{#pragma} should be used instead. At the time
4241 @code{__attribute__} was designed, there were two reasons for not doing
4242 this.
4243
4244 @enumerate
4245 @item
4246 It is impossible to generate @code{#pragma} commands from a macro.
4247
4248 @item
4249 There is no telling what the same @code{#pragma} might mean in another
4250 compiler.
4251 @end enumerate
4252
4253 These two reasons applied to almost any application that might have been
4254 proposed for @code{#pragma}. It was basically a mistake to use
4255 @code{#pragma} for @emph{anything}.
4256
4257 The ISO C99 standard includes @code{_Pragma}, which now allows pragmas
4258 to be generated from macros. In addition, a @code{#pragma GCC}
4259 namespace is now in use for GCC-specific pragmas. However, it has been
4260 found convenient to use @code{__attribute__} to achieve a natural
4261 attachment of attributes to their corresponding declarations, whereas
4262 @code{#pragma GCC} is of use for constructs that do not naturally form
4263 part of the grammar. @xref{Pragmas,,Pragmas Accepted by GCC}.
4264
4265 @node Attribute Syntax
4266 @section Attribute Syntax
4267 @cindex attribute syntax
4268
4269 This section describes the syntax with which @code{__attribute__} may be
4270 used, and the constructs to which attribute specifiers bind, for the C
4271 language. Some details may vary for C++ and Objective-C@. Because of
4272 infelicities in the grammar for attributes, some forms described here
4273 may not be successfully parsed in all cases.
4274
4275 There are some problems with the semantics of attributes in C++. For
4276 example, there are no manglings for attributes, although they may affect
4277 code generation, so problems may arise when attributed types are used in
4278 conjunction with templates or overloading. Similarly, @code{typeid}
4279 does not distinguish between types with different attributes. Support
4280 for attributes in C++ may be restricted in future to attributes on
4281 declarations only, but not on nested declarators.
4282
4283 @xref{Function Attributes}, for details of the semantics of attributes
4284 applying to functions. @xref{Variable Attributes}, for details of the
4285 semantics of attributes applying to variables. @xref{Type Attributes},
4286 for details of the semantics of attributes applying to structure, union
4287 and enumerated types.
4288
4289 An @dfn{attribute specifier} is of the form
4290 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
4291 is a possibly empty comma-separated sequence of @dfn{attributes}, where
4292 each attribute is one of the following:
4293
4294 @itemize @bullet
4295 @item
4296 Empty. Empty attributes are ignored.
4297
4298 @item
4299 A word (which may be an identifier such as @code{unused}, or a reserved
4300 word such as @code{const}).
4301
4302 @item
4303 A word, followed by, in parentheses, parameters for the attribute.
4304 These parameters take one of the following forms:
4305
4306 @itemize @bullet
4307 @item
4308 An identifier. For example, @code{mode} attributes use this form.
4309
4310 @item
4311 An identifier followed by a comma and a non-empty comma-separated list
4312 of expressions. For example, @code{format} attributes use this form.
4313
4314 @item
4315 A possibly empty comma-separated list of expressions. For example,
4316 @code{format_arg} attributes use this form with the list being a single
4317 integer constant expression, and @code{alias} attributes use this form
4318 with the list being a single string constant.
4319 @end itemize
4320 @end itemize
4321
4322 An @dfn{attribute specifier list} is a sequence of one or more attribute
4323 specifiers, not separated by any other tokens.
4324
4325 In GNU C, an attribute specifier list may appear after the colon following a
4326 label, other than a @code{case} or @code{default} label. The only
4327 attribute it makes sense to use after a label is @code{unused}. This
4328 feature is intended for program-generated code that may contain unused labels,
4329 but which is compiled with @option{-Wall}. It is
4330 not normally appropriate to use in it human-written code, though it
4331 could be useful in cases where the code that jumps to the label is
4332 contained within an @code{#ifdef} conditional. GNU C++ only permits
4333 attributes on labels if the attribute specifier is immediately
4334 followed by a semicolon (i.e., the label applies to an empty
4335 statement). If the semicolon is missing, C++ label attributes are
4336 ambiguous, as it is permissible for a declaration, which could begin
4337 with an attribute list, to be labelled in C++. Declarations cannot be
4338 labelled in C90 or C99, so the ambiguity does not arise there.
4339
4340 An attribute specifier list may appear as part of a @code{struct},
4341 @code{union} or @code{enum} specifier. It may go either immediately
4342 after the @code{struct}, @code{union} or @code{enum} keyword, or after
4343 the closing brace. The former syntax is preferred.
4344 Where attribute specifiers follow the closing brace, they are considered
4345 to relate to the structure, union or enumerated type defined, not to any
4346 enclosing declaration the type specifier appears in, and the type
4347 defined is not complete until after the attribute specifiers.
4348 @c Otherwise, there would be the following problems: a shift/reduce
4349 @c conflict between attributes binding the struct/union/enum and
4350 @c binding to the list of specifiers/qualifiers; and "aligned"
4351 @c attributes could use sizeof for the structure, but the size could be
4352 @c changed later by "packed" attributes.
4353
4354 Otherwise, an attribute specifier appears as part of a declaration,
4355 counting declarations of unnamed parameters and type names, and relates
4356 to that declaration (which may be nested in another declaration, for
4357 example in the case of a parameter declaration), or to a particular declarator
4358 within a declaration. Where an
4359 attribute specifier is applied to a parameter declared as a function or
4360 an array, it should apply to the function or array rather than the
4361 pointer to which the parameter is implicitly converted, but this is not
4362 yet correctly implemented.
4363
4364 Any list of specifiers and qualifiers at the start of a declaration may
4365 contain attribute specifiers, whether or not such a list may in that
4366 context contain storage class specifiers. (Some attributes, however,
4367 are essentially in the nature of storage class specifiers, and only make
4368 sense where storage class specifiers may be used; for example,
4369 @code{section}.) There is one necessary limitation to this syntax: the
4370 first old-style parameter declaration in a function definition cannot
4371 begin with an attribute specifier, because such an attribute applies to
4372 the function instead by syntax described below (which, however, is not
4373 yet implemented in this case). In some other cases, attribute
4374 specifiers are permitted by this grammar but not yet supported by the
4375 compiler. All attribute specifiers in this place relate to the
4376 declaration as a whole. In the obsolescent usage where a type of
4377 @code{int} is implied by the absence of type specifiers, such a list of
4378 specifiers and qualifiers may be an attribute specifier list with no
4379 other specifiers or qualifiers.
4380
4381 At present, the first parameter in a function prototype must have some
4382 type specifier that is not an attribute specifier; this resolves an
4383 ambiguity in the interpretation of @code{void f(int
4384 (__attribute__((foo)) x))}, but is subject to change. At present, if
4385 the parentheses of a function declarator contain only attributes then
4386 those attributes are ignored, rather than yielding an error or warning
4387 or implying a single parameter of type int, but this is subject to
4388 change.
4389
4390 An attribute specifier list may appear immediately before a declarator
4391 (other than the first) in a comma-separated list of declarators in a
4392 declaration of more than one identifier using a single list of
4393 specifiers and qualifiers. Such attribute specifiers apply
4394 only to the identifier before whose declarator they appear. For
4395 example, in
4396
4397 @smallexample
4398 __attribute__((noreturn)) void d0 (void),
4399 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
4400 d2 (void)
4401 @end smallexample
4402
4403 @noindent
4404 the @code{noreturn} attribute applies to all the functions
4405 declared; the @code{format} attribute only applies to @code{d1}.
4406
4407 An attribute specifier list may appear immediately before the comma,
4408 @code{=} or semicolon terminating the declaration of an identifier other
4409 than a function definition. Such attribute specifiers apply
4410 to the declared object or function. Where an
4411 assembler name for an object or function is specified (@pxref{Asm
4412 Labels}), the attribute must follow the @code{asm}
4413 specification.
4414
4415 An attribute specifier list may, in future, be permitted to appear after
4416 the declarator in a function definition (before any old-style parameter
4417 declarations or the function body).
4418
4419 Attribute specifiers may be mixed with type qualifiers appearing inside
4420 the @code{[]} of a parameter array declarator, in the C99 construct by
4421 which such qualifiers are applied to the pointer to which the array is
4422 implicitly converted. Such attribute specifiers apply to the pointer,
4423 not to the array, but at present this is not implemented and they are
4424 ignored.
4425
4426 An attribute specifier list may appear at the start of a nested
4427 declarator. At present, there are some limitations in this usage: the
4428 attributes correctly apply to the declarator, but for most individual
4429 attributes the semantics this implies are not implemented.
4430 When attribute specifiers follow the @code{*} of a pointer
4431 declarator, they may be mixed with any type qualifiers present.
4432 The following describes the formal semantics of this syntax. It makes the
4433 most sense if you are familiar with the formal specification of
4434 declarators in the ISO C standard.
4435
4436 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
4437 D1}, where @code{T} contains declaration specifiers that specify a type
4438 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
4439 contains an identifier @var{ident}. The type specified for @var{ident}
4440 for derived declarators whose type does not include an attribute
4441 specifier is as in the ISO C standard.
4442
4443 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
4444 and the declaration @code{T D} specifies the type
4445 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4446 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4447 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
4448
4449 If @code{D1} has the form @code{*
4450 @var{type-qualifier-and-attribute-specifier-list} D}, and the
4451 declaration @code{T D} specifies the type
4452 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
4453 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
4454 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
4455 @var{ident}.
4456
4457 For example,
4458
4459 @smallexample
4460 void (__attribute__((noreturn)) ****f) (void);
4461 @end smallexample
4462
4463 @noindent
4464 specifies the type ``pointer to pointer to pointer to pointer to
4465 non-returning function returning @code{void}''. As another example,
4466
4467 @smallexample
4468 char *__attribute__((aligned(8))) *f;
4469 @end smallexample
4470
4471 @noindent
4472 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
4473 Note again that this does not work with most attributes; for example,
4474 the usage of @samp{aligned} and @samp{noreturn} attributes given above
4475 is not yet supported.
4476
4477 For compatibility with existing code written for compiler versions that
4478 did not implement attributes on nested declarators, some laxity is
4479 allowed in the placing of attributes. If an attribute that only applies
4480 to types is applied to a declaration, it is treated as applying to
4481 the type of that declaration. If an attribute that only applies to
4482 declarations is applied to the type of a declaration, it is treated
4483 as applying to that declaration; and, for compatibility with code
4484 placing the attributes immediately before the identifier declared, such
4485 an attribute applied to a function return type is treated as
4486 applying to the function type, and such an attribute applied to an array
4487 element type is treated as applying to the array type. If an
4488 attribute that only applies to function types is applied to a
4489 pointer-to-function type, it is treated as applying to the pointer
4490 target type; if such an attribute is applied to a function return type
4491 that is not a pointer-to-function type, it is treated as applying
4492 to the function type.
4493
4494 @node Function Prototypes
4495 @section Prototypes and Old-Style Function Definitions
4496 @cindex function prototype declarations
4497 @cindex old-style function definitions
4498 @cindex promotion of formal parameters
4499
4500 GNU C extends ISO C to allow a function prototype to override a later
4501 old-style non-prototype definition. Consider the following example:
4502
4503 @smallexample
4504 /* @r{Use prototypes unless the compiler is old-fashioned.} */
4505 #ifdef __STDC__
4506 #define P(x) x
4507 #else
4508 #define P(x) ()
4509 #endif
4510
4511 /* @r{Prototype function declaration.} */
4512 int isroot P((uid_t));
4513
4514 /* @r{Old-style function definition.} */
4515 int
4516 isroot (x) /* @r{??? lossage here ???} */
4517 uid_t x;
4518 @{
4519 return x == 0;
4520 @}
4521 @end smallexample
4522
4523 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
4524 not allow this example, because subword arguments in old-style
4525 non-prototype definitions are promoted. Therefore in this example the
4526 function definition's argument is really an @code{int}, which does not
4527 match the prototype argument type of @code{short}.
4528
4529 This restriction of ISO C makes it hard to write code that is portable
4530 to traditional C compilers, because the programmer does not know
4531 whether the @code{uid_t} type is @code{short}, @code{int}, or
4532 @code{long}. Therefore, in cases like these GNU C allows a prototype
4533 to override a later old-style definition. More precisely, in GNU C, a
4534 function prototype argument type overrides the argument type specified
4535 by a later old-style definition if the former type is the same as the
4536 latter type before promotion. Thus in GNU C the above example is
4537 equivalent to the following:
4538
4539 @smallexample
4540 int isroot (uid_t);
4541
4542 int
4543 isroot (uid_t x)
4544 @{
4545 return x == 0;
4546 @}
4547 @end smallexample
4548
4549 @noindent
4550 GNU C++ does not support old-style function definitions, so this
4551 extension is irrelevant.
4552
4553 @node C++ Comments
4554 @section C++ Style Comments
4555 @cindex @code{//}
4556 @cindex C++ comments
4557 @cindex comments, C++ style
4558
4559 In GNU C, you may use C++ style comments, which start with @samp{//} and
4560 continue until the end of the line. Many other C implementations allow
4561 such comments, and they are included in the 1999 C standard. However,
4562 C++ style comments are not recognized if you specify an @option{-std}
4563 option specifying a version of ISO C before C99, or @option{-ansi}
4564 (equivalent to @option{-std=c90}).
4565
4566 @node Dollar Signs
4567 @section Dollar Signs in Identifier Names
4568 @cindex $
4569 @cindex dollar signs in identifier names
4570 @cindex identifier names, dollar signs in
4571
4572 In GNU C, you may normally use dollar signs in identifier names.
4573 This is because many traditional C implementations allow such identifiers.
4574 However, dollar signs in identifiers are not supported on a few target
4575 machines, typically because the target assembler does not allow them.
4576
4577 @node Character Escapes
4578 @section The Character @key{ESC} in Constants
4579
4580 You can use the sequence @samp{\e} in a string or character constant to
4581 stand for the ASCII character @key{ESC}.
4582
4583 @node Variable Attributes
4584 @section Specifying Attributes of Variables
4585 @cindex attribute of variables
4586 @cindex variable attributes
4587
4588 The keyword @code{__attribute__} allows you to specify special
4589 attributes of variables or structure fields. This keyword is followed
4590 by an attribute specification inside double parentheses. Some
4591 attributes are currently defined generically for variables.
4592 Other attributes are defined for variables on particular target
4593 systems. Other attributes are available for functions
4594 (@pxref{Function Attributes}) and for types (@pxref{Type Attributes}).
4595 Other front ends might define more attributes
4596 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
4597
4598 You may also specify attributes with @samp{__} preceding and following
4599 each keyword. This allows you to use them in header files without
4600 being concerned about a possible macro of the same name. For example,
4601 you may use @code{__aligned__} instead of @code{aligned}.
4602
4603 @xref{Attribute Syntax}, for details of the exact syntax for using
4604 attributes.
4605
4606 @table @code
4607 @cindex @code{aligned} attribute
4608 @item aligned (@var{alignment})
4609 This attribute specifies a minimum alignment for the variable or
4610 structure field, measured in bytes. For example, the declaration:
4611
4612 @smallexample
4613 int x __attribute__ ((aligned (16))) = 0;
4614 @end smallexample
4615
4616 @noindent
4617 causes the compiler to allocate the global variable @code{x} on a
4618 16-byte boundary. On a 68040, this could be used in conjunction with
4619 an @code{asm} expression to access the @code{move16} instruction which
4620 requires 16-byte aligned operands.
4621
4622 You can also specify the alignment of structure fields. For example, to
4623 create a double-word aligned @code{int} pair, you could write:
4624
4625 @smallexample
4626 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
4627 @end smallexample
4628
4629 @noindent
4630 This is an alternative to creating a union with a @code{double} member,
4631 which forces the union to be double-word aligned.
4632
4633 As in the preceding examples, you can explicitly specify the alignment
4634 (in bytes) that you wish the compiler to use for a given variable or
4635 structure field. Alternatively, you can leave out the alignment factor
4636 and just ask the compiler to align a variable or field to the
4637 default alignment for the target architecture you are compiling for.
4638 The default alignment is sufficient for all scalar types, but may not be
4639 enough for all vector types on a target that supports vector operations.
4640 The default alignment is fixed for a particular target ABI.
4641
4642 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
4643 which is the largest alignment ever used for any data type on the
4644 target machine you are compiling for. For example, you could write:
4645
4646 @smallexample
4647 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
4648 @end smallexample
4649
4650 The compiler automatically sets the alignment for the declared
4651 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
4652 often make copy operations more efficient, because the compiler can
4653 use whatever instructions copy the biggest chunks of memory when
4654 performing copies to or from the variables or fields that you have
4655 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
4656 may change depending on command-line options.
4657
4658 When used on a struct, or struct member, the @code{aligned} attribute can
4659 only increase the alignment; in order to decrease it, the @code{packed}
4660 attribute must be specified as well. When used as part of a typedef, the
4661 @code{aligned} attribute can both increase and decrease alignment, and
4662 specifying the @code{packed} attribute generates a warning.
4663
4664 Note that the effectiveness of @code{aligned} attributes may be limited
4665 by inherent limitations in your linker. On many systems, the linker is
4666 only able to arrange for variables to be aligned up to a certain maximum
4667 alignment. (For some linkers, the maximum supported alignment may
4668 be very very small.) If your linker is only able to align variables
4669 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
4670 in an @code{__attribute__} still only provides you with 8-byte
4671 alignment. See your linker documentation for further information.
4672
4673 The @code{aligned} attribute can also be used for functions
4674 (@pxref{Function Attributes}.)
4675
4676 @item cleanup (@var{cleanup_function})
4677 @cindex @code{cleanup} attribute
4678 The @code{cleanup} attribute runs a function when the variable goes
4679 out of scope. This attribute can only be applied to auto function
4680 scope variables; it may not be applied to parameters or variables
4681 with static storage duration. The function must take one parameter,
4682 a pointer to a type compatible with the variable. The return value
4683 of the function (if any) is ignored.
4684
4685 If @option{-fexceptions} is enabled, then @var{cleanup_function}
4686 is run during the stack unwinding that happens during the
4687 processing of the exception. Note that the @code{cleanup} attribute
4688 does not allow the exception to be caught, only to perform an action.
4689 It is undefined what happens if @var{cleanup_function} does not
4690 return normally.
4691
4692 @item common
4693 @itemx nocommon
4694 @cindex @code{common} attribute
4695 @cindex @code{nocommon} attribute
4696 @opindex fcommon
4697 @opindex fno-common
4698 The @code{common} attribute requests GCC to place a variable in
4699 ``common'' storage. The @code{nocommon} attribute requests the
4700 opposite---to allocate space for it directly.
4701
4702 These attributes override the default chosen by the
4703 @option{-fno-common} and @option{-fcommon} flags respectively.
4704
4705 @item deprecated
4706 @itemx deprecated (@var{msg})
4707 @cindex @code{deprecated} attribute
4708 The @code{deprecated} attribute results in a warning if the variable
4709 is used anywhere in the source file. This is useful when identifying
4710 variables that are expected to be removed in a future version of a
4711 program. The warning also includes the location of the declaration
4712 of the deprecated variable, to enable users to easily find further
4713 information about why the variable is deprecated, or what they should
4714 do instead. Note that the warning only occurs for uses:
4715
4716 @smallexample
4717 extern int old_var __attribute__ ((deprecated));
4718 extern int old_var;
4719 int new_fn () @{ return old_var; @}
4720 @end smallexample
4721
4722 @noindent
4723 results in a warning on line 3 but not line 2. The optional @var{msg}
4724 argument, which must be a string, is printed in the warning if
4725 present.
4726
4727 The @code{deprecated} attribute can also be used for functions and
4728 types (@pxref{Function Attributes}, @pxref{Type Attributes}.)
4729
4730 @item mode (@var{mode})
4731 @cindex @code{mode} attribute
4732 This attribute specifies the data type for the declaration---whichever
4733 type corresponds to the mode @var{mode}. This in effect lets you
4734 request an integer or floating-point type according to its width.
4735
4736 You may also specify a mode of @code{byte} or @code{__byte__} to
4737 indicate the mode corresponding to a one-byte integer, @code{word} or
4738 @code{__word__} for the mode of a one-word integer, and @code{pointer}
4739 or @code{__pointer__} for the mode used to represent pointers.
4740
4741 @item packed
4742 @cindex @code{packed} attribute
4743 The @code{packed} attribute specifies that a variable or structure field
4744 should have the smallest possible alignment---one byte for a variable,
4745 and one bit for a field, unless you specify a larger value with the
4746 @code{aligned} attribute.
4747
4748 Here is a structure in which the field @code{x} is packed, so that it
4749 immediately follows @code{a}:
4750
4751 @smallexample
4752 struct foo
4753 @{
4754 char a;
4755 int x[2] __attribute__ ((packed));
4756 @};
4757 @end smallexample
4758
4759 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
4760 @code{packed} attribute on bit-fields of type @code{char}. This has
4761 been fixed in GCC 4.4 but the change can lead to differences in the
4762 structure layout. See the documentation of
4763 @option{-Wpacked-bitfield-compat} for more information.
4764
4765 @item section ("@var{section-name}")
4766 @cindex @code{section} variable attribute
4767 Normally, the compiler places the objects it generates in sections like
4768 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
4769 or you need certain particular variables to appear in special sections,
4770 for example to map to special hardware. The @code{section}
4771 attribute specifies that a variable (or function) lives in a particular
4772 section. For example, this small program uses several specific section names:
4773
4774 @smallexample
4775 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
4776 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
4777 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
4778 int init_data __attribute__ ((section ("INITDATA")));
4779
4780 main()
4781 @{
4782 /* @r{Initialize stack pointer} */
4783 init_sp (stack + sizeof (stack));
4784
4785 /* @r{Initialize initialized data} */
4786 memcpy (&init_data, &data, &edata - &data);
4787
4788 /* @r{Turn on the serial ports} */
4789 init_duart (&a);
4790 init_duart (&b);
4791 @}
4792 @end smallexample
4793
4794 @noindent
4795 Use the @code{section} attribute with
4796 @emph{global} variables and not @emph{local} variables,
4797 as shown in the example.
4798
4799 You may use the @code{section} attribute with initialized or
4800 uninitialized global variables but the linker requires
4801 each object be defined once, with the exception that uninitialized
4802 variables tentatively go in the @code{common} (or @code{bss}) section
4803 and can be multiply ``defined''. Using the @code{section} attribute
4804 changes what section the variable goes into and may cause the
4805 linker to issue an error if an uninitialized variable has multiple
4806 definitions. You can force a variable to be initialized with the
4807 @option{-fno-common} flag or the @code{nocommon} attribute.
4808
4809 Some file formats do not support arbitrary sections so the @code{section}
4810 attribute is not available on all platforms.
4811 If you need to map the entire contents of a module to a particular
4812 section, consider using the facilities of the linker instead.
4813
4814 @item shared
4815 @cindex @code{shared} variable attribute
4816 On Microsoft Windows, in addition to putting variable definitions in a named
4817 section, the section can also be shared among all running copies of an
4818 executable or DLL@. For example, this small program defines shared data
4819 by putting it in a named section @code{shared} and marking the section
4820 shareable:
4821
4822 @smallexample
4823 int foo __attribute__((section ("shared"), shared)) = 0;
4824
4825 int
4826 main()
4827 @{
4828 /* @r{Read and write foo. All running
4829 copies see the same value.} */
4830 return 0;
4831 @}
4832 @end smallexample
4833
4834 @noindent
4835 You may only use the @code{shared} attribute along with @code{section}
4836 attribute with a fully-initialized global definition because of the way
4837 linkers work. See @code{section} attribute for more information.
4838
4839 The @code{shared} attribute is only available on Microsoft Windows@.
4840
4841 @item tls_model ("@var{tls_model}")
4842 @cindex @code{tls_model} attribute
4843 The @code{tls_model} attribute sets thread-local storage model
4844 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
4845 overriding @option{-ftls-model=} command-line switch on a per-variable
4846 basis.
4847 The @var{tls_model} argument should be one of @code{global-dynamic},
4848 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
4849
4850 Not all targets support this attribute.
4851
4852 @item unused
4853 This attribute, attached to a variable, means that the variable is meant
4854 to be possibly unused. GCC does not produce a warning for this
4855 variable.
4856
4857 @item used
4858 This attribute, attached to a variable, means that the variable must be
4859 emitted even if it appears that the variable is not referenced.
4860
4861 When applied to a static data member of a C++ class template, the
4862 attribute also means that the member is instantiated if the
4863 class itself is instantiated.
4864
4865 @item vector_size (@var{bytes})
4866 This attribute specifies the vector size for the variable, measured in
4867 bytes. For example, the declaration:
4868
4869 @smallexample
4870 int foo __attribute__ ((vector_size (16)));
4871 @end smallexample
4872
4873 @noindent
4874 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
4875 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
4876 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
4877
4878 This attribute is only applicable to integral and float scalars,
4879 although arrays, pointers, and function return values are allowed in
4880 conjunction with this construct.
4881
4882 Aggregates with this attribute are invalid, even if they are of the same
4883 size as a corresponding scalar. For example, the declaration:
4884
4885 @smallexample
4886 struct S @{ int a; @};
4887 struct S __attribute__ ((vector_size (16))) foo;
4888 @end smallexample
4889
4890 @noindent
4891 is invalid even if the size of the structure is the same as the size of
4892 the @code{int}.
4893
4894 @item selectany
4895 The @code{selectany} attribute causes an initialized global variable to
4896 have link-once semantics. When multiple definitions of the variable are
4897 encountered by the linker, the first is selected and the remainder are
4898 discarded. Following usage by the Microsoft compiler, the linker is told
4899 @emph{not} to warn about size or content differences of the multiple
4900 definitions.
4901
4902 Although the primary usage of this attribute is for POD types, the
4903 attribute can also be applied to global C++ objects that are initialized
4904 by a constructor. In this case, the static initialization and destruction
4905 code for the object is emitted in each translation defining the object,
4906 but the calls to the constructor and destructor are protected by a
4907 link-once guard variable.
4908
4909 The @code{selectany} attribute is only available on Microsoft Windows
4910 targets. You can use @code{__declspec (selectany)} as a synonym for
4911 @code{__attribute__ ((selectany))} for compatibility with other
4912 compilers.
4913
4914 @item weak
4915 The @code{weak} attribute is described in @ref{Function Attributes}.
4916
4917 @item dllimport
4918 The @code{dllimport} attribute is described in @ref{Function Attributes}.
4919
4920 @item dllexport
4921 The @code{dllexport} attribute is described in @ref{Function Attributes}.
4922
4923 @end table
4924
4925 @anchor{AVR Variable Attributes}
4926 @subsection AVR Variable Attributes
4927
4928 @table @code
4929 @item progmem
4930 @cindex @code{progmem} AVR variable attribute
4931 The @code{progmem} attribute is used on the AVR to place read-only
4932 data in the non-volatile program memory (flash). The @code{progmem}
4933 attribute accomplishes this by putting respective variables into a
4934 section whose name starts with @code{.progmem}.
4935
4936 This attribute works similar to the @code{section} attribute
4937 but adds additional checking. Notice that just like the
4938 @code{section} attribute, @code{progmem} affects the location
4939 of the data but not how this data is accessed.
4940
4941 In order to read data located with the @code{progmem} attribute
4942 (inline) assembler must be used.
4943 @smallexample
4944 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
4945 #include <avr/pgmspace.h>
4946
4947 /* Locate var in flash memory */
4948 const int var[2] PROGMEM = @{ 1, 2 @};
4949
4950 int read_var (int i)
4951 @{
4952 /* Access var[] by accessor macro from avr/pgmspace.h */
4953 return (int) pgm_read_word (& var[i]);
4954 @}
4955 @end smallexample
4956
4957 AVR is a Harvard architecture processor and data and read-only data
4958 normally resides in the data memory (RAM).
4959
4960 See also the @ref{AVR Named Address Spaces} section for
4961 an alternate way to locate and access data in flash memory.
4962 @end table
4963
4964 @subsection Blackfin Variable Attributes
4965
4966 Three attributes are currently defined for the Blackfin.
4967
4968 @table @code
4969 @item l1_data
4970 @itemx l1_data_A
4971 @itemx l1_data_B
4972 @cindex @code{l1_data} variable attribute
4973 @cindex @code{l1_data_A} variable attribute
4974 @cindex @code{l1_data_B} variable attribute
4975 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
4976 Variables with @code{l1_data} attribute are put into the specific section
4977 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
4978 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
4979 attribute are put into the specific section named @code{.l1.data.B}.
4980
4981 @item l2
4982 @cindex @code{l2} variable attribute
4983 Use this attribute on the Blackfin to place the variable into L2 SRAM.
4984 Variables with @code{l2} attribute are put into the specific section
4985 named @code{.l2.data}.
4986 @end table
4987
4988 @subsection M32R/D Variable Attributes
4989
4990 One attribute is currently defined for the M32R/D@.
4991
4992 @table @code
4993 @item model (@var{model-name})
4994 @cindex variable addressability on the M32R/D
4995 Use this attribute on the M32R/D to set the addressability of an object.
4996 The identifier @var{model-name} is one of @code{small}, @code{medium},
4997 or @code{large}, representing each of the code models.
4998
4999 Small model objects live in the lower 16MB of memory (so that their
5000 addresses can be loaded with the @code{ld24} instruction).
5001
5002 Medium and large model objects may live anywhere in the 32-bit address space
5003 (the compiler generates @code{seth/add3} instructions to load their
5004 addresses).
5005 @end table
5006
5007 @anchor{MeP Variable Attributes}
5008 @subsection MeP Variable Attributes
5009
5010 The MeP target has a number of addressing modes and busses. The
5011 @code{near} space spans the standard memory space's first 16 megabytes
5012 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5013 The @code{based} space is a 128-byte region in the memory space that
5014 is addressed relative to the @code{$tp} register. The @code{tiny}
5015 space is a 65536-byte region relative to the @code{$gp} register. In
5016 addition to these memory regions, the MeP target has a separate 16-bit
5017 control bus which is specified with @code{cb} attributes.
5018
5019 @table @code
5020
5021 @item based
5022 Any variable with the @code{based} attribute is assigned to the
5023 @code{.based} section, and is accessed with relative to the
5024 @code{$tp} register.
5025
5026 @item tiny
5027 Likewise, the @code{tiny} attribute assigned variables to the
5028 @code{.tiny} section, relative to the @code{$gp} register.
5029
5030 @item near
5031 Variables with the @code{near} attribute are assumed to have addresses
5032 that fit in a 24-bit addressing mode. This is the default for large
5033 variables (@code{-mtiny=4} is the default) but this attribute can
5034 override @code{-mtiny=} for small variables, or override @code{-ml}.
5035
5036 @item far
5037 Variables with the @code{far} attribute are addressed using a full
5038 32-bit address. Since this covers the entire memory space, this
5039 allows modules to make no assumptions about where variables might be
5040 stored.
5041
5042 @item io
5043 @itemx io (@var{addr})
5044 Variables with the @code{io} attribute are used to address
5045 memory-mapped peripherals. If an address is specified, the variable
5046 is assigned that address, else it is not assigned an address (it is
5047 assumed some other module assigns an address). Example:
5048
5049 @smallexample
5050 int timer_count __attribute__((io(0x123)));
5051 @end smallexample
5052
5053 @item cb
5054 @itemx cb (@var{addr})
5055 Variables with the @code{cb} attribute are used to access the control
5056 bus, using special instructions. @code{addr} indicates the control bus
5057 address. Example:
5058
5059 @smallexample
5060 int cpu_clock __attribute__((cb(0x123)));
5061 @end smallexample
5062
5063 @end table
5064
5065 @anchor{i386 Variable Attributes}
5066 @subsection i386 Variable Attributes
5067
5068 Two attributes are currently defined for i386 configurations:
5069 @code{ms_struct} and @code{gcc_struct}
5070
5071 @table @code
5072 @item ms_struct
5073 @itemx gcc_struct
5074 @cindex @code{ms_struct} attribute
5075 @cindex @code{gcc_struct} attribute
5076
5077 If @code{packed} is used on a structure, or if bit-fields are used,
5078 it may be that the Microsoft ABI lays out the structure differently
5079 than the way GCC normally does. Particularly when moving packed
5080 data between functions compiled with GCC and the native Microsoft compiler
5081 (either via function call or as data in a file), it may be necessary to access
5082 either format.
5083
5084 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5085 compilers to match the native Microsoft compiler.
5086
5087 The Microsoft structure layout algorithm is fairly simple with the exception
5088 of the bit-field packing.
5089 The padding and alignment of members of structures and whether a bit-field
5090 can straddle a storage-unit boundary are determine by these rules:
5091
5092 @enumerate
5093 @item Structure members are stored sequentially in the order in which they are
5094 declared: the first member has the lowest memory address and the last member
5095 the highest.
5096
5097 @item Every data object has an alignment requirement. The alignment requirement
5098 for all data except structures, unions, and arrays is either the size of the
5099 object or the current packing size (specified with either the
5100 @code{aligned} attribute or the @code{pack} pragma),
5101 whichever is less. For structures, unions, and arrays,
5102 the alignment requirement is the largest alignment requirement of its members.
5103 Every object is allocated an offset so that:
5104
5105 @smallexample
5106 offset % alignment_requirement == 0
5107 @end smallexample
5108
5109 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
5110 unit if the integral types are the same size and if the next bit-field fits
5111 into the current allocation unit without crossing the boundary imposed by the
5112 common alignment requirements of the bit-fields.
5113 @end enumerate
5114
5115 MSVC interprets zero-length bit-fields in the following ways:
5116
5117 @enumerate
5118 @item If a zero-length bit-field is inserted between two bit-fields that
5119 are normally coalesced, the bit-fields are not coalesced.
5120
5121 For example:
5122
5123 @smallexample
5124 struct
5125 @{
5126 unsigned long bf_1 : 12;
5127 unsigned long : 0;
5128 unsigned long bf_2 : 12;
5129 @} t1;
5130 @end smallexample
5131
5132 @noindent
5133 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
5134 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
5135
5136 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
5137 alignment of the zero-length bit-field is greater than the member that follows it,
5138 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
5139
5140 For example:
5141
5142 @smallexample
5143 struct
5144 @{
5145 char foo : 4;
5146 short : 0;
5147 char bar;
5148 @} t2;
5149
5150 struct
5151 @{
5152 char foo : 4;
5153 short : 0;
5154 double bar;
5155 @} t3;
5156 @end smallexample
5157
5158 @noindent
5159 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
5160 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
5161 bit-field does not affect the alignment of @code{bar} or, as a result, the size
5162 of the structure.
5163
5164 Taking this into account, it is important to note the following:
5165
5166 @enumerate
5167 @item If a zero-length bit-field follows a normal bit-field, the type of the
5168 zero-length bit-field may affect the alignment of the structure as whole. For
5169 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
5170 normal bit-field, and is of type short.
5171
5172 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
5173 still affect the alignment of the structure:
5174
5175 @smallexample
5176 struct
5177 @{
5178 char foo : 6;
5179 long : 0;
5180 @} t4;
5181 @end smallexample
5182
5183 @noindent
5184 Here, @code{t4} takes up 4 bytes.
5185 @end enumerate
5186
5187 @item Zero-length bit-fields following non-bit-field members are ignored:
5188
5189 @smallexample
5190 struct
5191 @{
5192 char foo;
5193 long : 0;
5194 char bar;
5195 @} t5;
5196 @end smallexample
5197
5198 @noindent
5199 Here, @code{t5} takes up 2 bytes.
5200 @end enumerate
5201 @end table
5202
5203 @subsection PowerPC Variable Attributes
5204
5205 Three attributes currently are defined for PowerPC configurations:
5206 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5207
5208 For full documentation of the struct attributes please see the
5209 documentation in @ref{i386 Variable Attributes}.
5210
5211 For documentation of @code{altivec} attribute please see the
5212 documentation in @ref{PowerPC Type Attributes}.
5213
5214 @subsection SPU Variable Attributes
5215
5216 The SPU supports the @code{spu_vector} attribute for variables. For
5217 documentation of this attribute please see the documentation in
5218 @ref{SPU Type Attributes}.
5219
5220 @subsection Xstormy16 Variable Attributes
5221
5222 One attribute is currently defined for xstormy16 configurations:
5223 @code{below100}.
5224
5225 @table @code
5226 @item below100
5227 @cindex @code{below100} attribute
5228
5229 If a variable has the @code{below100} attribute (@code{BELOW100} is
5230 allowed also), GCC places the variable in the first 0x100 bytes of
5231 memory and use special opcodes to access it. Such variables are
5232 placed in either the @code{.bss_below100} section or the
5233 @code{.data_below100} section.
5234
5235 @end table
5236
5237 @node Type Attributes
5238 @section Specifying Attributes of Types
5239 @cindex attribute of types
5240 @cindex type attributes
5241
5242 The keyword @code{__attribute__} allows you to specify special
5243 attributes of @code{struct} and @code{union} types when you define
5244 such types. This keyword is followed by an attribute specification
5245 inside double parentheses. Seven attributes are currently defined for
5246 types: @code{aligned}, @code{packed}, @code{transparent_union},
5247 @code{unused}, @code{deprecated}, @code{visibility}, and
5248 @code{may_alias}. Other attributes are defined for functions
5249 (@pxref{Function Attributes}) and for variables (@pxref{Variable
5250 Attributes}).
5251
5252 You may also specify any one of these attributes with @samp{__}
5253 preceding and following its keyword. This allows you to use these
5254 attributes in header files without being concerned about a possible
5255 macro of the same name. For example, you may use @code{__aligned__}
5256 instead of @code{aligned}.
5257
5258 You may specify type attributes in an enum, struct or union type
5259 declaration or definition, or for other types in a @code{typedef}
5260 declaration.
5261
5262 For an enum, struct or union type, you may specify attributes either
5263 between the enum, struct or union tag and the name of the type, or
5264 just past the closing curly brace of the @emph{definition}. The
5265 former syntax is preferred.
5266
5267 @xref{Attribute Syntax}, for details of the exact syntax for using
5268 attributes.
5269
5270 @table @code
5271 @cindex @code{aligned} attribute
5272 @item aligned (@var{alignment})
5273 This attribute specifies a minimum alignment (in bytes) for variables
5274 of the specified type. For example, the declarations:
5275
5276 @smallexample
5277 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
5278 typedef int more_aligned_int __attribute__ ((aligned (8)));
5279 @end smallexample
5280
5281 @noindent
5282 force the compiler to ensure (as far as it can) that each variable whose
5283 type is @code{struct S} or @code{more_aligned_int} is allocated and
5284 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
5285 variables of type @code{struct S} aligned to 8-byte boundaries allows
5286 the compiler to use the @code{ldd} and @code{std} (doubleword load and
5287 store) instructions when copying one variable of type @code{struct S} to
5288 another, thus improving run-time efficiency.
5289
5290 Note that the alignment of any given @code{struct} or @code{union} type
5291 is required by the ISO C standard to be at least a perfect multiple of
5292 the lowest common multiple of the alignments of all of the members of
5293 the @code{struct} or @code{union} in question. This means that you @emph{can}
5294 effectively adjust the alignment of a @code{struct} or @code{union}
5295 type by attaching an @code{aligned} attribute to any one of the members
5296 of such a type, but the notation illustrated in the example above is a
5297 more obvious, intuitive, and readable way to request the compiler to
5298 adjust the alignment of an entire @code{struct} or @code{union} type.
5299
5300 As in the preceding example, you can explicitly specify the alignment
5301 (in bytes) that you wish the compiler to use for a given @code{struct}
5302 or @code{union} type. Alternatively, you can leave out the alignment factor
5303 and just ask the compiler to align a type to the maximum
5304 useful alignment for the target machine you are compiling for. For
5305 example, you could write:
5306
5307 @smallexample
5308 struct S @{ short f[3]; @} __attribute__ ((aligned));
5309 @end smallexample
5310
5311 Whenever you leave out the alignment factor in an @code{aligned}
5312 attribute specification, the compiler automatically sets the alignment
5313 for the type to the largest alignment that is ever used for any data
5314 type on the target machine you are compiling for. Doing this can often
5315 make copy operations more efficient, because the compiler can use
5316 whatever instructions copy the biggest chunks of memory when performing
5317 copies to or from the variables that have types that you have aligned
5318 this way.
5319
5320 In the example above, if the size of each @code{short} is 2 bytes, then
5321 the size of the entire @code{struct S} type is 6 bytes. The smallest
5322 power of two that is greater than or equal to that is 8, so the
5323 compiler sets the alignment for the entire @code{struct S} type to 8
5324 bytes.
5325
5326 Note that although you can ask the compiler to select a time-efficient
5327 alignment for a given type and then declare only individual stand-alone
5328 objects of that type, the compiler's ability to select a time-efficient
5329 alignment is primarily useful only when you plan to create arrays of
5330 variables having the relevant (efficiently aligned) type. If you
5331 declare or use arrays of variables of an efficiently-aligned type, then
5332 it is likely that your program also does pointer arithmetic (or
5333 subscripting, which amounts to the same thing) on pointers to the
5334 relevant type, and the code that the compiler generates for these
5335 pointer arithmetic operations is often more efficient for
5336 efficiently-aligned types than for other types.
5337
5338 The @code{aligned} attribute can only increase the alignment; but you
5339 can decrease it by specifying @code{packed} as well. See below.
5340
5341 Note that the effectiveness of @code{aligned} attributes may be limited
5342 by inherent limitations in your linker. On many systems, the linker is
5343 only able to arrange for variables to be aligned up to a certain maximum
5344 alignment. (For some linkers, the maximum supported alignment may
5345 be very very small.) If your linker is only able to align variables
5346 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5347 in an @code{__attribute__} still only provides you with 8-byte
5348 alignment. See your linker documentation for further information.
5349
5350 @item packed
5351 This attribute, attached to @code{struct} or @code{union} type
5352 definition, specifies that each member (other than zero-width bit-fields)
5353 of the structure or union is placed to minimize the memory required. When
5354 attached to an @code{enum} definition, it indicates that the smallest
5355 integral type should be used.
5356
5357 @opindex fshort-enums
5358 Specifying this attribute for @code{struct} and @code{union} types is
5359 equivalent to specifying the @code{packed} attribute on each of the
5360 structure or union members. Specifying the @option{-fshort-enums}
5361 flag on the line is equivalent to specifying the @code{packed}
5362 attribute on all @code{enum} definitions.
5363
5364 In the following example @code{struct my_packed_struct}'s members are
5365 packed closely together, but the internal layout of its @code{s} member
5366 is not packed---to do that, @code{struct my_unpacked_struct} needs to
5367 be packed too.
5368
5369 @smallexample
5370 struct my_unpacked_struct
5371 @{
5372 char c;
5373 int i;
5374 @};
5375
5376 struct __attribute__ ((__packed__)) my_packed_struct
5377 @{
5378 char c;
5379 int i;
5380 struct my_unpacked_struct s;
5381 @};
5382 @end smallexample
5383
5384 You may only specify this attribute on the definition of an @code{enum},
5385 @code{struct} or @code{union}, not on a @code{typedef} that does not
5386 also define the enumerated type, structure or union.
5387
5388 @item transparent_union
5389 This attribute, attached to a @code{union} type definition, indicates
5390 that any function parameter having that union type causes calls to that
5391 function to be treated in a special way.
5392
5393 First, the argument corresponding to a transparent union type can be of
5394 any type in the union; no cast is required. Also, if the union contains
5395 a pointer type, the corresponding argument can be a null pointer
5396 constant or a void pointer expression; and if the union contains a void
5397 pointer type, the corresponding argument can be any pointer expression.
5398 If the union member type is a pointer, qualifiers like @code{const} on
5399 the referenced type must be respected, just as with normal pointer
5400 conversions.
5401
5402 Second, the argument is passed to the function using the calling
5403 conventions of the first member of the transparent union, not the calling
5404 conventions of the union itself. All members of the union must have the
5405 same machine representation; this is necessary for this argument passing
5406 to work properly.
5407
5408 Transparent unions are designed for library functions that have multiple
5409 interfaces for compatibility reasons. For example, suppose the
5410 @code{wait} function must accept either a value of type @code{int *} to
5411 comply with POSIX, or a value of type @code{union wait *} to comply with
5412 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
5413 @code{wait} would accept both kinds of arguments, but it would also
5414 accept any other pointer type and this would make argument type checking
5415 less useful. Instead, @code{<sys/wait.h>} might define the interface
5416 as follows:
5417
5418 @smallexample
5419 typedef union __attribute__ ((__transparent_union__))
5420 @{
5421 int *__ip;
5422 union wait *__up;
5423 @} wait_status_ptr_t;
5424
5425 pid_t wait (wait_status_ptr_t);
5426 @end smallexample
5427
5428 @noindent
5429 This interface allows either @code{int *} or @code{union wait *}
5430 arguments to be passed, using the @code{int *} calling convention.
5431 The program can call @code{wait} with arguments of either type:
5432
5433 @smallexample
5434 int w1 () @{ int w; return wait (&w); @}
5435 int w2 () @{ union wait w; return wait (&w); @}
5436 @end smallexample
5437
5438 @noindent
5439 With this interface, @code{wait}'s implementation might look like this:
5440
5441 @smallexample
5442 pid_t wait (wait_status_ptr_t p)
5443 @{
5444 return waitpid (-1, p.__ip, 0);
5445 @}
5446 @end smallexample
5447
5448 @item unused
5449 When attached to a type (including a @code{union} or a @code{struct}),
5450 this attribute means that variables of that type are meant to appear
5451 possibly unused. GCC does not produce a warning for any variables of
5452 that type, even if the variable appears to do nothing. This is often
5453 the case with lock or thread classes, which are usually defined and then
5454 not referenced, but contain constructors and destructors that have
5455 nontrivial bookkeeping functions.
5456
5457 @item deprecated
5458 @itemx deprecated (@var{msg})
5459 The @code{deprecated} attribute results in a warning if the type
5460 is used anywhere in the source file. This is useful when identifying
5461 types that are expected to be removed in a future version of a program.
5462 If possible, the warning also includes the location of the declaration
5463 of the deprecated type, to enable users to easily find further
5464 information about why the type is deprecated, or what they should do
5465 instead. Note that the warnings only occur for uses and then only
5466 if the type is being applied to an identifier that itself is not being
5467 declared as deprecated.
5468
5469 @smallexample
5470 typedef int T1 __attribute__ ((deprecated));
5471 T1 x;
5472 typedef T1 T2;
5473 T2 y;
5474 typedef T1 T3 __attribute__ ((deprecated));
5475 T3 z __attribute__ ((deprecated));
5476 @end smallexample
5477
5478 @noindent
5479 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
5480 warning is issued for line 4 because T2 is not explicitly
5481 deprecated. Line 5 has no warning because T3 is explicitly
5482 deprecated. Similarly for line 6. The optional @var{msg}
5483 argument, which must be a string, is printed in the warning if
5484 present.
5485
5486 The @code{deprecated} attribute can also be used for functions and
5487 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
5488
5489 @item may_alias
5490 Accesses through pointers to types with this attribute are not subject
5491 to type-based alias analysis, but are instead assumed to be able to alias
5492 any other type of objects.
5493 In the context of section 6.5 paragraph 7 of the C99 standard,
5494 an lvalue expression
5495 dereferencing such a pointer is treated like having a character type.
5496 See @option{-fstrict-aliasing} for more information on aliasing issues.
5497 This extension exists to support some vector APIs, in which pointers to
5498 one vector type are permitted to alias pointers to a different vector type.
5499
5500 Note that an object of a type with this attribute does not have any
5501 special semantics.
5502
5503 Example of use:
5504
5505 @smallexample
5506 typedef short __attribute__((__may_alias__)) short_a;
5507
5508 int
5509 main (void)
5510 @{
5511 int a = 0x12345678;
5512 short_a *b = (short_a *) &a;
5513
5514 b[1] = 0;
5515
5516 if (a == 0x12345678)
5517 abort();
5518
5519 exit(0);
5520 @}
5521 @end smallexample
5522
5523 @noindent
5524 If you replaced @code{short_a} with @code{short} in the variable
5525 declaration, the above program would abort when compiled with
5526 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
5527 above in recent GCC versions.
5528
5529 @item visibility
5530 In C++, attribute visibility (@pxref{Function Attributes}) can also be
5531 applied to class, struct, union and enum types. Unlike other type
5532 attributes, the attribute must appear between the initial keyword and
5533 the name of the type; it cannot appear after the body of the type.
5534
5535 Note that the type visibility is applied to vague linkage entities
5536 associated with the class (vtable, typeinfo node, etc.). In
5537 particular, if a class is thrown as an exception in one shared object
5538 and caught in another, the class must have default visibility.
5539 Otherwise the two shared objects are unable to use the same
5540 typeinfo node and exception handling will break.
5541
5542 @end table
5543
5544 To specify multiple attributes, separate them by commas within the
5545 double parentheses: for example, @samp{__attribute__ ((aligned (16),
5546 packed))}.
5547
5548 @subsection ARM Type Attributes
5549
5550 On those ARM targets that support @code{dllimport} (such as Symbian
5551 OS), you can use the @code{notshared} attribute to indicate that the
5552 virtual table and other similar data for a class should not be
5553 exported from a DLL@. For example:
5554
5555 @smallexample
5556 class __declspec(notshared) C @{
5557 public:
5558 __declspec(dllimport) C();
5559 virtual void f();
5560 @}
5561
5562 __declspec(dllexport)
5563 C::C() @{@}
5564 @end smallexample
5565
5566 @noindent
5567 In this code, @code{C::C} is exported from the current DLL, but the
5568 virtual table for @code{C} is not exported. (You can use
5569 @code{__attribute__} instead of @code{__declspec} if you prefer, but
5570 most Symbian OS code uses @code{__declspec}.)
5571
5572 @anchor{MeP Type Attributes}
5573 @subsection MeP Type Attributes
5574
5575 Many of the MeP variable attributes may be applied to types as well.
5576 Specifically, the @code{based}, @code{tiny}, @code{near}, and
5577 @code{far} attributes may be applied to either. The @code{io} and
5578 @code{cb} attributes may not be applied to types.
5579
5580 @anchor{i386 Type Attributes}
5581 @subsection i386 Type Attributes
5582
5583 Two attributes are currently defined for i386 configurations:
5584 @code{ms_struct} and @code{gcc_struct}.
5585
5586 @table @code
5587
5588 @item ms_struct
5589 @itemx gcc_struct
5590 @cindex @code{ms_struct}
5591 @cindex @code{gcc_struct}
5592
5593 If @code{packed} is used on a structure, or if bit-fields are used
5594 it may be that the Microsoft ABI packs them differently
5595 than GCC normally packs them. Particularly when moving packed
5596 data between functions compiled with GCC and the native Microsoft compiler
5597 (either via function call or as data in a file), it may be necessary to access
5598 either format.
5599
5600 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows X86
5601 compilers to match the native Microsoft compiler.
5602 @end table
5603
5604 @anchor{PowerPC Type Attributes}
5605 @subsection PowerPC Type Attributes
5606
5607 Three attributes currently are defined for PowerPC configurations:
5608 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5609
5610 For full documentation of the @code{ms_struct} and @code{gcc_struct}
5611 attributes please see the documentation in @ref{i386 Type Attributes}.
5612
5613 The @code{altivec} attribute allows one to declare AltiVec vector data
5614 types supported by the AltiVec Programming Interface Manual. The
5615 attribute requires an argument to specify one of three vector types:
5616 @code{vector__}, @code{pixel__} (always followed by unsigned short),
5617 and @code{bool__} (always followed by unsigned).
5618
5619 @smallexample
5620 __attribute__((altivec(vector__)))
5621 __attribute__((altivec(pixel__))) unsigned short
5622 __attribute__((altivec(bool__))) unsigned
5623 @end smallexample
5624
5625 These attributes mainly are intended to support the @code{__vector},
5626 @code{__pixel}, and @code{__bool} AltiVec keywords.
5627
5628 @anchor{SPU Type Attributes}
5629 @subsection SPU Type Attributes
5630
5631 The SPU supports the @code{spu_vector} attribute for types. This attribute
5632 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
5633 Language Extensions Specification. It is intended to support the
5634 @code{__vector} keyword.
5635
5636 @node Alignment
5637 @section Inquiring on Alignment of Types or Variables
5638 @cindex alignment
5639 @cindex type alignment
5640 @cindex variable alignment
5641
5642 The keyword @code{__alignof__} allows you to inquire about how an object
5643 is aligned, or the minimum alignment usually required by a type. Its
5644 syntax is just like @code{sizeof}.
5645
5646 For example, if the target machine requires a @code{double} value to be
5647 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
5648 This is true on many RISC machines. On more traditional machine
5649 designs, @code{__alignof__ (double)} is 4 or even 2.
5650
5651 Some machines never actually require alignment; they allow reference to any
5652 data type even at an odd address. For these machines, @code{__alignof__}
5653 reports the smallest alignment that GCC gives the data type, usually as
5654 mandated by the target ABI.
5655
5656 If the operand of @code{__alignof__} is an lvalue rather than a type,
5657 its value is the required alignment for its type, taking into account
5658 any minimum alignment specified with GCC's @code{__attribute__}
5659 extension (@pxref{Variable Attributes}). For example, after this
5660 declaration:
5661
5662 @smallexample
5663 struct foo @{ int x; char y; @} foo1;
5664 @end smallexample
5665
5666 @noindent
5667 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
5668 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
5669
5670 It is an error to ask for the alignment of an incomplete type.
5671
5672
5673 @node Inline
5674 @section An Inline Function is As Fast As a Macro
5675 @cindex inline functions
5676 @cindex integrating function code
5677 @cindex open coding
5678 @cindex macros, inline alternative
5679
5680 By declaring a function inline, you can direct GCC to make
5681 calls to that function faster. One way GCC can achieve this is to
5682 integrate that function's code into the code for its callers. This
5683 makes execution faster by eliminating the function-call overhead; in
5684 addition, if any of the actual argument values are constant, their
5685 known values may permit simplifications at compile time so that not
5686 all of the inline function's code needs to be included. The effect on
5687 code size is less predictable; object code may be larger or smaller
5688 with function inlining, depending on the particular case. You can
5689 also direct GCC to try to integrate all ``simple enough'' functions
5690 into their callers with the option @option{-finline-functions}.
5691
5692 GCC implements three different semantics of declaring a function
5693 inline. One is available with @option{-std=gnu89} or
5694 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
5695 on all inline declarations, another when
5696 @option{-std=c99}, @option{-std=c11},
5697 @option{-std=gnu99} or @option{-std=gnu11}
5698 (without @option{-fgnu89-inline}), and the third
5699 is used when compiling C++.
5700
5701 To declare a function inline, use the @code{inline} keyword in its
5702 declaration, like this:
5703
5704 @smallexample
5705 static inline int
5706 inc (int *a)
5707 @{
5708 return (*a)++;
5709 @}
5710 @end smallexample
5711
5712 If you are writing a header file to be included in ISO C90 programs, write
5713 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
5714
5715 The three types of inlining behave similarly in two important cases:
5716 when the @code{inline} keyword is used on a @code{static} function,
5717 like the example above, and when a function is first declared without
5718 using the @code{inline} keyword and then is defined with
5719 @code{inline}, like this:
5720
5721 @smallexample
5722 extern int inc (int *a);
5723 inline int
5724 inc (int *a)
5725 @{
5726 return (*a)++;
5727 @}
5728 @end smallexample
5729
5730 In both of these common cases, the program behaves the same as if you
5731 had not used the @code{inline} keyword, except for its speed.
5732
5733 @cindex inline functions, omission of
5734 @opindex fkeep-inline-functions
5735 When a function is both inline and @code{static}, if all calls to the
5736 function are integrated into the caller, and the function's address is
5737 never used, then the function's own assembler code is never referenced.
5738 In this case, GCC does not actually output assembler code for the
5739 function, unless you specify the option @option{-fkeep-inline-functions}.
5740 Some calls cannot be integrated for various reasons (in particular,
5741 calls that precede the function's definition cannot be integrated, and
5742 neither can recursive calls within the definition). If there is a
5743 nonintegrated call, then the function is compiled to assembler code as
5744 usual. The function must also be compiled as usual if the program
5745 refers to its address, because that can't be inlined.
5746
5747 @opindex Winline
5748 Note that certain usages in a function definition can make it unsuitable
5749 for inline substitution. Among these usages are: variadic functions, use of
5750 @code{alloca}, use of variable-length data types (@pxref{Variable Length}),
5751 use of computed goto (@pxref{Labels as Values}), use of nonlocal goto,
5752 and nested functions (@pxref{Nested Functions}). Using @option{-Winline}
5753 warns when a function marked @code{inline} could not be substituted,
5754 and gives the reason for the failure.
5755
5756 @cindex automatic @code{inline} for C++ member fns
5757 @cindex @code{inline} automatic for C++ member fns
5758 @cindex member fns, automatically @code{inline}
5759 @cindex C++ member fns, automatically @code{inline}
5760 @opindex fno-default-inline
5761 As required by ISO C++, GCC considers member functions defined within
5762 the body of a class to be marked inline even if they are
5763 not explicitly declared with the @code{inline} keyword. You can
5764 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
5765 Options,,Options Controlling C++ Dialect}.
5766
5767 GCC does not inline any functions when not optimizing unless you specify
5768 the @samp{always_inline} attribute for the function, like this:
5769
5770 @smallexample
5771 /* @r{Prototype.} */
5772 inline void foo (const char) __attribute__((always_inline));
5773 @end smallexample
5774
5775 The remainder of this section is specific to GNU C90 inlining.
5776
5777 @cindex non-static inline function
5778 When an inline function is not @code{static}, then the compiler must assume
5779 that there may be calls from other source files; since a global symbol can
5780 be defined only once in any program, the function must not be defined in
5781 the other source files, so the calls therein cannot be integrated.
5782 Therefore, a non-@code{static} inline function is always compiled on its
5783 own in the usual fashion.
5784
5785 If you specify both @code{inline} and @code{extern} in the function
5786 definition, then the definition is used only for inlining. In no case
5787 is the function compiled on its own, not even if you refer to its
5788 address explicitly. Such an address becomes an external reference, as
5789 if you had only declared the function, and had not defined it.
5790
5791 This combination of @code{inline} and @code{extern} has almost the
5792 effect of a macro. The way to use it is to put a function definition in
5793 a header file with these keywords, and put another copy of the
5794 definition (lacking @code{inline} and @code{extern}) in a library file.
5795 The definition in the header file causes most calls to the function
5796 to be inlined. If any uses of the function remain, they refer to
5797 the single copy in the library.
5798
5799 @node Volatiles
5800 @section When is a Volatile Object Accessed?
5801 @cindex accessing volatiles
5802 @cindex volatile read
5803 @cindex volatile write
5804 @cindex volatile access
5805
5806 C has the concept of volatile objects. These are normally accessed by
5807 pointers and used for accessing hardware or inter-thread
5808 communication. The standard encourages compilers to refrain from
5809 optimizations concerning accesses to volatile objects, but leaves it
5810 implementation defined as to what constitutes a volatile access. The
5811 minimum requirement is that at a sequence point all previous accesses
5812 to volatile objects have stabilized and no subsequent accesses have
5813 occurred. Thus an implementation is free to reorder and combine
5814 volatile accesses that occur between sequence points, but cannot do
5815 so for accesses across a sequence point. The use of volatile does
5816 not allow you to violate the restriction on updating objects multiple
5817 times between two sequence points.
5818
5819 Accesses to non-volatile objects are not ordered with respect to
5820 volatile accesses. You cannot use a volatile object as a memory
5821 barrier to order a sequence of writes to non-volatile memory. For
5822 instance:
5823
5824 @smallexample
5825 int *ptr = @var{something};
5826 volatile int vobj;
5827 *ptr = @var{something};
5828 vobj = 1;
5829 @end smallexample
5830
5831 @noindent
5832 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
5833 that the write to @var{*ptr} occurs by the time the update
5834 of @var{vobj} happens. If you need this guarantee, you must use
5835 a stronger memory barrier such as:
5836
5837 @smallexample
5838 int *ptr = @var{something};
5839 volatile int vobj;
5840 *ptr = @var{something};
5841 asm volatile ("" : : : "memory");
5842 vobj = 1;
5843 @end smallexample
5844
5845 A scalar volatile object is read when it is accessed in a void context:
5846
5847 @smallexample
5848 volatile int *src = @var{somevalue};
5849 *src;
5850 @end smallexample
5851
5852 Such expressions are rvalues, and GCC implements this as a
5853 read of the volatile object being pointed to.
5854
5855 Assignments are also expressions and have an rvalue. However when
5856 assigning to a scalar volatile, the volatile object is not reread,
5857 regardless of whether the assignment expression's rvalue is used or
5858 not. If the assignment's rvalue is used, the value is that assigned
5859 to the volatile object. For instance, there is no read of @var{vobj}
5860 in all the following cases:
5861
5862 @smallexample
5863 int obj;
5864 volatile int vobj;
5865 vobj = @var{something};
5866 obj = vobj = @var{something};
5867 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
5868 obj = (@var{something}, vobj = @var{anotherthing});
5869 @end smallexample
5870
5871 If you need to read the volatile object after an assignment has
5872 occurred, you must use a separate expression with an intervening
5873 sequence point.
5874
5875 As bit-fields are not individually addressable, volatile bit-fields may
5876 be implicitly read when written to, or when adjacent bit-fields are
5877 accessed. Bit-field operations may be optimized such that adjacent
5878 bit-fields are only partially accessed, if they straddle a storage unit
5879 boundary. For these reasons it is unwise to use volatile bit-fields to
5880 access hardware.
5881
5882 @node Extended Asm
5883 @section Assembler Instructions with C Expression Operands
5884 @cindex extended @code{asm}
5885 @cindex @code{asm} expressions
5886 @cindex assembler instructions
5887 @cindex registers
5888
5889 In an assembler instruction using @code{asm}, you can specify the
5890 operands of the instruction using C expressions. This means you need not
5891 guess which registers or memory locations contain the data you want
5892 to use.
5893
5894 You must specify an assembler instruction template much like what
5895 appears in a machine description, plus an operand constraint string for
5896 each operand.
5897
5898 For example, here is how to use the 68881's @code{fsinx} instruction:
5899
5900 @smallexample
5901 asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
5902 @end smallexample
5903
5904 @noindent
5905 Here @code{angle} is the C expression for the input operand while
5906 @code{result} is that of the output operand. Each has @samp{"f"} as its
5907 operand constraint, saying that a floating-point register is required.
5908 The @samp{=} in @samp{=f} indicates that the operand is an output; all
5909 output operands' constraints must use @samp{=}. The constraints use the
5910 same language used in the machine description (@pxref{Constraints}).
5911
5912 Each operand is described by an operand-constraint string followed by
5913 the C expression in parentheses. A colon separates the assembler
5914 template from the first output operand and another separates the last
5915 output operand from the first input, if any. Commas separate the
5916 operands within each group. The total number of operands is currently
5917 limited to 30; this limitation may be lifted in some future version of
5918 GCC@.
5919
5920 If there are no output operands but there are input operands, you must
5921 place two consecutive colons surrounding the place where the output
5922 operands would go.
5923
5924 As of GCC version 3.1, it is also possible to specify input and output
5925 operands using symbolic names which can be referenced within the
5926 assembler code. These names are specified inside square brackets
5927 preceding the constraint string, and can be referenced inside the
5928 assembler code using @code{%[@var{name}]} instead of a percentage sign
5929 followed by the operand number. Using named operands the above example
5930 could look like:
5931
5932 @smallexample
5933 asm ("fsinx %[angle],%[output]"
5934 : [output] "=f" (result)
5935 : [angle] "f" (angle));
5936 @end smallexample
5937
5938 @noindent
5939 Note that the symbolic operand names have no relation whatsoever to
5940 other C identifiers. You may use any name you like, even those of
5941 existing C symbols, but you must ensure that no two operands within the same
5942 assembler construct use the same symbolic name.
5943
5944 Output operand expressions must be lvalues; the compiler can check this.
5945 The input operands need not be lvalues. The compiler cannot check
5946 whether the operands have data types that are reasonable for the
5947 instruction being executed. It does not parse the assembler instruction
5948 template and does not know what it means or even whether it is valid
5949 assembler input. The extended @code{asm} feature is most often used for
5950 machine instructions the compiler itself does not know exist. If
5951 the output expression cannot be directly addressed (for example, it is a
5952 bit-field), your constraint must allow a register. In that case, GCC
5953 uses the register as the output of the @code{asm}, and then stores
5954 that register into the output.
5955
5956 The ordinary output operands must be write-only; GCC assumes that
5957 the values in these operands before the instruction are dead and need
5958 not be generated. Extended asm supports input-output or read-write
5959 operands. Use the constraint character @samp{+} to indicate such an
5960 operand and list it with the output operands.
5961
5962 You may, as an alternative, logically split its function into two
5963 separate operands, one input operand and one write-only output
5964 operand. The connection between them is expressed by constraints
5965 that say they need to be in the same location when the instruction
5966 executes. You can use the same C expression for both operands, or
5967 different expressions. For example, here we write the (fictitious)
5968 @samp{combine} instruction with @code{bar} as its read-only source
5969 operand and @code{foo} as its read-write destination:
5970
5971 @smallexample
5972 asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
5973 @end smallexample
5974
5975 @noindent
5976 The constraint @samp{"0"} for operand 1 says that it must occupy the
5977 same location as operand 0. A number in constraint is allowed only in
5978 an input operand and it must refer to an output operand.
5979
5980 Only a number in the constraint can guarantee that one operand is in
5981 the same place as another. The mere fact that @code{foo} is the value
5982 of both operands is not enough to guarantee that they are in the
5983 same place in the generated assembler code. The following does not
5984 work reliably:
5985
5986 @smallexample
5987 asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
5988 @end smallexample
5989
5990 Various optimizations or reloading could cause operands 0 and 1 to be in
5991 different registers; GCC knows no reason not to do so. For example, the
5992 compiler might find a copy of the value of @code{foo} in one register and
5993 use it for operand 1, but generate the output operand 0 in a different
5994 register (copying it afterward to @code{foo}'s own address). Of course,
5995 since the register for operand 1 is not even mentioned in the assembler
5996 code, the result will not work, but GCC can't tell that.
5997
5998 As of GCC version 3.1, one may write @code{[@var{name}]} instead of
5999 the operand number for a matching constraint. For example:
6000
6001 @smallexample
6002 asm ("cmoveq %1,%2,%[result]"
6003 : [result] "=r"(result)
6004 : "r" (test), "r"(new), "[result]"(old));
6005 @end smallexample
6006
6007 Sometimes you need to make an @code{asm} operand be a specific register,
6008 but there's no matching constraint letter for that register @emph{by
6009 itself}. To force the operand into that register, use a local variable
6010 for the operand and specify the register in the variable declaration.
6011 @xref{Explicit Reg Vars}. Then for the @code{asm} operand, use any
6012 register constraint letter that matches the register:
6013
6014 @smallexample
6015 register int *p1 asm ("r0") = @dots{};
6016 register int *p2 asm ("r1") = @dots{};
6017 register int *result asm ("r0");
6018 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6019 @end smallexample
6020
6021 @anchor{Example of asm with clobbered asm reg}
6022 In the above example, beware that a register that is call-clobbered by
6023 the target ABI will be overwritten by any function call in the
6024 assignment, including library calls for arithmetic operators.
6025 Also a register may be clobbered when generating some operations,
6026 like variable shift, memory copy or memory move on x86.
6027 Assuming it is a call-clobbered register, this may happen to @code{r0}
6028 above by the assignment to @code{p2}. If you have to use such a
6029 register, use temporary variables for expressions between the register
6030 assignment and use:
6031
6032 @smallexample
6033 int t1 = @dots{};
6034 register int *p1 asm ("r0") = @dots{};
6035 register int *p2 asm ("r1") = t1;
6036 register int *result asm ("r0");
6037 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
6038 @end smallexample
6039
6040 Some instructions clobber specific hard registers. To describe this,
6041 write a third colon after the input operands, followed by the names of
6042 the clobbered hard registers (given as strings). Here is a realistic
6043 example for the VAX:
6044
6045 @smallexample
6046 asm volatile ("movc3 %0,%1,%2"
6047 : /* @r{no outputs} */
6048 : "g" (from), "g" (to), "g" (count)
6049 : "r0", "r1", "r2", "r3", "r4", "r5");
6050 @end smallexample
6051
6052 You may not write a clobber description in a way that overlaps with an
6053 input or output operand. For example, you may not have an operand
6054 describing a register class with one member if you mention that register
6055 in the clobber list. Variables declared to live in specific registers
6056 (@pxref{Explicit Reg Vars}), and used as asm input or output operands must
6057 have no part mentioned in the clobber description.
6058 There is no way for you to specify that an input
6059 operand is modified without also specifying it as an output
6060 operand. Note that if all the output operands you specify are for this
6061 purpose (and hence unused), you then also need to specify
6062 @code{volatile} for the @code{asm} construct, as described below, to
6063 prevent GCC from deleting the @code{asm} statement as unused.
6064
6065 If you refer to a particular hardware register from the assembler code,
6066 you probably have to list the register after the third colon to
6067 tell the compiler the register's value is modified. In some assemblers,
6068 the register names begin with @samp{%}; to produce one @samp{%} in the
6069 assembler code, you must write @samp{%%} in the input.
6070
6071 If your assembler instruction can alter the condition code register, add
6072 @samp{cc} to the list of clobbered registers. GCC on some machines
6073 represents the condition codes as a specific hardware register;
6074 @samp{cc} serves to name this register. On other machines, the
6075 condition code is handled differently, and specifying @samp{cc} has no
6076 effect. But it is valid no matter what the machine.
6077
6078 If your assembler instructions access memory in an unpredictable
6079 fashion, add @samp{memory} to the list of clobbered registers. This
6080 causes GCC to not keep memory values cached in registers across the
6081 assembler instruction and not optimize stores or loads to that memory.
6082 You also should add the @code{volatile} keyword if the memory
6083 affected is not listed in the inputs or outputs of the @code{asm}, as
6084 the @samp{memory} clobber does not count as a side-effect of the
6085 @code{asm}. If you know how large the accessed memory is, you can add
6086 it as input or output but if this is not known, you should add
6087 @samp{memory}. As an example, if you access ten bytes of a string, you
6088 can use a memory input like:
6089
6090 @smallexample
6091 @{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}.
6092 @end smallexample
6093
6094 Note that in the following example the memory input is necessary,
6095 otherwise GCC might optimize the store to @code{x} away:
6096 @smallexample
6097 int foo ()
6098 @{
6099 int x = 42;
6100 int *y = &x;
6101 int result;
6102 asm ("magic stuff accessing an 'int' pointed to by '%1'"
6103 : "=&d" (r) : "a" (y), "m" (*y));
6104 return result;
6105 @}
6106 @end smallexample
6107
6108 You can put multiple assembler instructions together in a single
6109 @code{asm} template, separated by the characters normally used in assembly
6110 code for the system. A combination that works in most places is a newline
6111 to break the line, plus a tab character to move to the instruction field
6112 (written as @samp{\n\t}). Sometimes semicolons can be used, if the
6113 assembler allows semicolons as a line-breaking character. Note that some
6114 assembler dialects use semicolons to start a comment.
6115 The input operands are guaranteed not to use any of the clobbered
6116 registers, and neither do the output operands' addresses, so you can
6117 read and write the clobbered registers as many times as you like. Here
6118 is an example of multiple instructions in a template; it assumes the
6119 subroutine @code{_foo} accepts arguments in registers 9 and 10:
6120
6121 @smallexample
6122 asm ("movl %0,r9\n\tmovl %1,r10\n\tcall _foo"
6123 : /* no outputs */
6124 : "g" (from), "g" (to)
6125 : "r9", "r10");
6126 @end smallexample
6127
6128 Unless an output operand has the @samp{&} constraint modifier, GCC
6129 may allocate it in the same register as an unrelated input operand, on
6130 the assumption the inputs are consumed before the outputs are produced.
6131 This assumption may be false if the assembler code actually consists of
6132 more than one instruction. In such a case, use @samp{&} for each output
6133 operand that may not overlap an input. @xref{Modifiers}.
6134
6135 If you want to test the condition code produced by an assembler
6136 instruction, you must include a branch and a label in the @code{asm}
6137 construct, as follows:
6138
6139 @smallexample
6140 asm ("clr %0\n\tfrob %1\n\tbeq 0f\n\tmov #1,%0\n0:"
6141 : "g" (result)
6142 : "g" (input));
6143 @end smallexample
6144
6145 @noindent
6146 This assumes your assembler supports local labels, as the GNU assembler
6147 and most Unix assemblers do.
6148
6149 Speaking of labels, jumps from one @code{asm} to another are not
6150 supported. The compiler's optimizers do not know about these jumps, and
6151 therefore they cannot take account of them when deciding how to
6152 optimize. @xref{Extended asm with goto}.
6153
6154 @cindex macros containing @code{asm}
6155 Usually the most convenient way to use these @code{asm} instructions is to
6156 encapsulate them in macros that look like functions. For example,
6157
6158 @smallexample
6159 #define sin(x) \
6160 (@{ double __value, __arg = (x); \
6161 asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
6162 __value; @})
6163 @end smallexample
6164
6165 @noindent
6166 Here the variable @code{__arg} is used to make sure that the instruction
6167 operates on a proper @code{double} value, and to accept only those
6168 arguments @code{x} that can convert automatically to a @code{double}.
6169
6170 Another way to make sure the instruction operates on the correct data
6171 type is to use a cast in the @code{asm}. This is different from using a
6172 variable @code{__arg} in that it converts more different types. For
6173 example, if the desired type is @code{int}, casting the argument to
6174 @code{int} accepts a pointer with no complaint, while assigning the
6175 argument to an @code{int} variable named @code{__arg} warns about
6176 using a pointer unless the caller explicitly casts it.
6177
6178 If an @code{asm} has output operands, GCC assumes for optimization
6179 purposes the instruction has no side effects except to change the output
6180 operands. This does not mean instructions with a side effect cannot be
6181 used, but you must be careful, because the compiler may eliminate them
6182 if the output operands aren't used, or move them out of loops, or
6183 replace two with one if they constitute a common subexpression. Also,
6184 if your instruction does have a side effect on a variable that otherwise
6185 appears not to change, the old value of the variable may be reused later
6186 if it happens to be found in a register.
6187
6188 You can prevent an @code{asm} instruction from being deleted
6189 by writing the keyword @code{volatile} after
6190 the @code{asm}. For example:
6191
6192 @smallexample
6193 #define get_and_set_priority(new) \
6194 (@{ int __old; \
6195 asm volatile ("get_and_set_priority %0, %1" \
6196 : "=g" (__old) : "g" (new)); \
6197 __old; @})
6198 @end smallexample
6199
6200 @noindent
6201 The @code{volatile} keyword indicates that the instruction has
6202 important side-effects. GCC does not delete a volatile @code{asm} if
6203 it is reachable. (The instruction can still be deleted if GCC can
6204 prove that control flow never reaches the location of the
6205 instruction.) Note that even a volatile @code{asm} instruction
6206 can be moved relative to other code, including across jump
6207 instructions. For example, on many targets there is a system
6208 register that can be set to control the rounding mode of
6209 floating-point operations. You might try
6210 setting it with a volatile @code{asm}, like this PowerPC example:
6211
6212 @smallexample
6213 asm volatile("mtfsf 255,%0" : : "f" (fpenv));
6214 sum = x + y;
6215 @end smallexample
6216
6217 @noindent
6218 This does not work reliably, as the compiler may move the addition back
6219 before the volatile @code{asm}. To make it work you need to add an
6220 artificial dependency to the @code{asm} referencing a variable in the code
6221 you don't want moved, for example:
6222
6223 @smallexample
6224 asm volatile ("mtfsf 255,%1" : "=X"(sum): "f"(fpenv));
6225 sum = x + y;
6226 @end smallexample
6227
6228 Similarly, you can't expect a
6229 sequence of volatile @code{asm} instructions to remain perfectly
6230 consecutive. If you want consecutive output, use a single @code{asm}.
6231 Also, GCC performs some optimizations across a volatile @code{asm}
6232 instruction; GCC does not ``forget everything'' when it encounters
6233 a volatile @code{asm} instruction the way some other compilers do.
6234
6235 An @code{asm} instruction without any output operands is treated
6236 identically to a volatile @code{asm} instruction.
6237
6238 It is a natural idea to look for a way to give access to the condition
6239 code left by the assembler instruction. However, when we attempted to
6240 implement this, we found no way to make it work reliably. The problem
6241 is that output operands might need reloading, which result in
6242 additional following ``store'' instructions. On most machines, these
6243 instructions alter the condition code before there is time to
6244 test it. This problem doesn't arise for ordinary ``test'' and
6245 ``compare'' instructions because they don't have any output operands.
6246
6247 For reasons similar to those described above, it is not possible to give
6248 an assembler instruction access to the condition code left by previous
6249 instructions.
6250
6251 @anchor{Extended asm with goto}
6252 As of GCC version 4.5, @code{asm goto} may be used to have the assembly
6253 jump to one or more C labels. In this form, a fifth section after the
6254 clobber list contains a list of all C labels to which the assembly may jump.
6255 Each label operand is implicitly self-named. The @code{asm} is also assumed
6256 to fall through to the next statement.
6257
6258 This form of @code{asm} is restricted to not have outputs. This is due
6259 to a internal restriction in the compiler that control transfer instructions
6260 cannot have outputs. This restriction on @code{asm goto} may be lifted
6261 in some future version of the compiler. In the meantime, @code{asm goto}
6262 may include a memory clobber, and so leave outputs in memory.
6263
6264 @smallexample
6265 int frob(int x)
6266 @{
6267 int y;
6268 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
6269 : : "r"(x), "r"(&y) : "r5", "memory" : error);
6270 return y;
6271 error:
6272 return -1;
6273 @}
6274 @end smallexample
6275
6276 @noindent
6277 In this (inefficient) example, the @code{frob} instruction sets the
6278 carry bit to indicate an error. The @code{jc} instruction detects
6279 this and branches to the @code{error} label. Finally, the output
6280 of the @code{frob} instruction (@code{%r5}) is stored into the memory
6281 for variable @code{y}, which is later read by the @code{return} statement.
6282
6283 @smallexample
6284 void doit(void)
6285 @{
6286 int i = 0;
6287 asm goto ("mfsr %%r1, 123; jmp %%r1;"
6288 ".pushsection doit_table;"
6289 ".long %l0, %l1, %l2, %l3;"
6290 ".popsection"
6291 : : : "r1" : label1, label2, label3, label4);
6292 __builtin_unreachable ();
6293
6294 label1:
6295 f1();
6296 return;
6297 label2:
6298 f2();
6299 return;
6300 label3:
6301 i = 1;
6302 label4:
6303 f3(i);
6304 @}
6305 @end smallexample
6306
6307 @noindent
6308 In this (also inefficient) example, the @code{mfsr} instruction reads
6309 an address from some out-of-band machine register, and the following
6310 @code{jmp} instruction branches to that address. The address read by
6311 the @code{mfsr} instruction is assumed to have been previously set via
6312 some application-specific mechanism to be one of the four values stored
6313 in the @code{doit_table} section. Finally, the @code{asm} is followed
6314 by a call to @code{__builtin_unreachable} to indicate that the @code{asm}
6315 does not in fact fall through.
6316
6317 @smallexample
6318 #define TRACE1(NUM) \
6319 do @{ \
6320 asm goto ("0: nop;" \
6321 ".pushsection trace_table;" \
6322 ".long 0b, %l0;" \
6323 ".popsection" \
6324 : : : : trace#NUM); \
6325 if (0) @{ trace#NUM: trace(); @} \
6326 @} while (0)
6327 #define TRACE TRACE1(__COUNTER__)
6328 @end smallexample
6329
6330 @noindent
6331 In this example (which in fact inspired the @code{asm goto} feature)
6332 we want on rare occasions to call the @code{trace} function; on other
6333 occasions we'd like to keep the overhead to the absolute minimum.
6334 The normal code path consists of a single @code{nop} instruction.
6335 However, we record the address of this @code{nop} together with the
6336 address of a label that calls the @code{trace} function. This allows
6337 the @code{nop} instruction to be patched at run time to be an
6338 unconditional branch to the stored label. It is assumed that an
6339 optimizing compiler moves the labeled block out of line, to
6340 optimize the fall through path from the @code{asm}.
6341
6342 If you are writing a header file that should be includable in ISO C
6343 programs, write @code{__asm__} instead of @code{asm}. @xref{Alternate
6344 Keywords}.
6345
6346 @subsection Size of an @code{asm}
6347
6348 Some targets require that GCC track the size of each instruction used in
6349 order to generate correct code. Because the final length of an
6350 @code{asm} is only known by the assembler, GCC must make an estimate as
6351 to how big it will be. The estimate is formed by counting the number of
6352 statements in the pattern of the @code{asm} and multiplying that by the
6353 length of the longest instruction on that processor. Statements in the
6354 @code{asm} are identified by newline characters and whatever statement
6355 separator characters are supported by the assembler; on most processors
6356 this is the @samp{;} character.
6357
6358 Normally, GCC's estimate is perfectly adequate to ensure that correct
6359 code is generated, but it is possible to confuse the compiler if you use
6360 pseudo instructions or assembler macros that expand into multiple real
6361 instructions or if you use assembler directives that expand to more
6362 space in the object file than is needed for a single instruction.
6363 If this happens then the assembler produces a diagnostic saying that
6364 a label is unreachable.
6365
6366 @subsection i386 floating-point asm operands
6367
6368 On i386 targets, there are several rules on the usage of stack-like registers
6369 in the operands of an @code{asm}. These rules apply only to the operands
6370 that are stack-like registers:
6371
6372 @enumerate
6373 @item
6374 Given a set of input registers that die in an @code{asm}, it is
6375 necessary to know which are implicitly popped by the @code{asm}, and
6376 which must be explicitly popped by GCC@.
6377
6378 An input register that is implicitly popped by the @code{asm} must be
6379 explicitly clobbered, unless it is constrained to match an
6380 output operand.
6381
6382 @item
6383 For any input register that is implicitly popped by an @code{asm}, it is
6384 necessary to know how to adjust the stack to compensate for the pop.
6385 If any non-popped input is closer to the top of the reg-stack than
6386 the implicitly popped register, it would not be possible to know what the
6387 stack looked like---it's not clear how the rest of the stack ``slides
6388 up''.
6389
6390 All implicitly popped input registers must be closer to the top of
6391 the reg-stack than any input that is not implicitly popped.
6392
6393 It is possible that if an input dies in an @code{asm}, the compiler might
6394 use the input register for an output reload. Consider this example:
6395
6396 @smallexample
6397 asm ("foo" : "=t" (a) : "f" (b));
6398 @end smallexample
6399
6400 @noindent
6401 This code says that input @code{b} is not popped by the @code{asm}, and that
6402 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
6403 deeper after the @code{asm} than it was before. But, it is possible that
6404 reload may think that it can use the same register for both the input and
6405 the output.
6406
6407 To prevent this from happening,
6408 if any input operand uses the @code{f} constraint, all output register
6409 constraints must use the @code{&} early-clobber modifier.
6410
6411 The example above would be correctly written as:
6412
6413 @smallexample
6414 asm ("foo" : "=&t" (a) : "f" (b));
6415 @end smallexample
6416
6417 @item
6418 Some operands need to be in particular places on the stack. All
6419 output operands fall in this category---GCC has no other way to
6420 know which registers the outputs appear in unless you indicate
6421 this in the constraints.
6422
6423 Output operands must specifically indicate which register an output
6424 appears in after an @code{asm}. @code{=f} is not allowed: the operand
6425 constraints must select a class with a single register.
6426
6427 @item
6428 Output operands may not be ``inserted'' between existing stack registers.
6429 Since no 387 opcode uses a read/write operand, all output operands
6430 are dead before the @code{asm}, and are pushed by the @code{asm}.
6431 It makes no sense to push anywhere but the top of the reg-stack.
6432
6433 Output operands must start at the top of the reg-stack: output
6434 operands may not ``skip'' a register.
6435
6436 @item
6437 Some @code{asm} statements may need extra stack space for internal
6438 calculations. This can be guaranteed by clobbering stack registers
6439 unrelated to the inputs and outputs.
6440
6441 @end enumerate
6442
6443 Here are a couple of reasonable @code{asm}s to want to write. This
6444 @code{asm}
6445 takes one input, which is internally popped, and produces two outputs.
6446
6447 @smallexample
6448 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
6449 @end smallexample
6450
6451 @noindent
6452 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
6453 and replaces them with one output. The @code{st(1)} clobber is necessary
6454 for the compiler to know that @code{fyl2xp1} pops both inputs.
6455
6456 @smallexample
6457 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
6458 @end smallexample
6459
6460 @include md.texi
6461
6462 @node Asm Labels
6463 @section Controlling Names Used in Assembler Code
6464 @cindex assembler names for identifiers
6465 @cindex names used in assembler code
6466 @cindex identifiers, names in assembler code
6467
6468 You can specify the name to be used in the assembler code for a C
6469 function or variable by writing the @code{asm} (or @code{__asm__})
6470 keyword after the declarator as follows:
6471
6472 @smallexample
6473 int foo asm ("myfoo") = 2;
6474 @end smallexample
6475
6476 @noindent
6477 This specifies that the name to be used for the variable @code{foo} in
6478 the assembler code should be @samp{myfoo} rather than the usual
6479 @samp{_foo}.
6480
6481 On systems where an underscore is normally prepended to the name of a C
6482 function or variable, this feature allows you to define names for the
6483 linker that do not start with an underscore.
6484
6485 It does not make sense to use this feature with a non-static local
6486 variable since such variables do not have assembler names. If you are
6487 trying to put the variable in a particular register, see @ref{Explicit
6488 Reg Vars}. GCC presently accepts such code with a warning, but will
6489 probably be changed to issue an error, rather than a warning, in the
6490 future.
6491
6492 You cannot use @code{asm} in this way in a function @emph{definition}; but
6493 you can get the same effect by writing a declaration for the function
6494 before its definition and putting @code{asm} there, like this:
6495
6496 @smallexample
6497 extern func () asm ("FUNC");
6498
6499 func (x, y)
6500 int x, y;
6501 /* @r{@dots{}} */
6502 @end smallexample
6503
6504 It is up to you to make sure that the assembler names you choose do not
6505 conflict with any other assembler symbols. Also, you must not use a
6506 register name; that would produce completely invalid assembler code. GCC
6507 does not as yet have the ability to store static variables in registers.
6508 Perhaps that will be added.
6509
6510 @node Explicit Reg Vars
6511 @section Variables in Specified Registers
6512 @cindex explicit register variables
6513 @cindex variables in specified registers
6514 @cindex specified registers
6515 @cindex registers, global allocation
6516
6517 GNU C allows you to put a few global variables into specified hardware
6518 registers. You can also specify the register in which an ordinary
6519 register variable should be allocated.
6520
6521 @itemize @bullet
6522 @item
6523 Global register variables reserve registers throughout the program.
6524 This may be useful in programs such as programming language
6525 interpreters that have a couple of global variables that are accessed
6526 very often.
6527
6528 @item
6529 Local register variables in specific registers do not reserve the
6530 registers, except at the point where they are used as input or output
6531 operands in an @code{asm} statement and the @code{asm} statement itself is
6532 not deleted. The compiler's data flow analysis is capable of determining
6533 where the specified registers contain live values, and where they are
6534 available for other uses. Stores into local register variables may be deleted
6535 when they appear to be dead according to dataflow analysis. References
6536 to local register variables may be deleted or moved or simplified.
6537
6538 These local variables are sometimes convenient for use with the extended
6539 @code{asm} feature (@pxref{Extended Asm}), if you want to write one
6540 output of the assembler instruction directly into a particular register.
6541 (This works provided the register you specify fits the constraints
6542 specified for that operand in the @code{asm}.)
6543 @end itemize
6544
6545 @menu
6546 * Global Reg Vars::
6547 * Local Reg Vars::
6548 @end menu
6549
6550 @node Global Reg Vars
6551 @subsection Defining Global Register Variables
6552 @cindex global register variables
6553 @cindex registers, global variables in
6554
6555 You can define a global register variable in GNU C like this:
6556
6557 @smallexample
6558 register int *foo asm ("a5");
6559 @end smallexample
6560
6561 @noindent
6562 Here @code{a5} is the name of the register that should be used. Choose a
6563 register that is normally saved and restored by function calls on your
6564 machine, so that library routines will not clobber it.
6565
6566 Naturally the register name is cpu-dependent, so you need to
6567 conditionalize your program according to cpu type. The register
6568 @code{a5} is a good choice on a 68000 for a variable of pointer
6569 type. On machines with register windows, be sure to choose a ``global''
6570 register that is not affected magically by the function call mechanism.
6571
6572 In addition, different operating systems on the same CPU may differ in how they
6573 name the registers; then you need additional conditionals. For
6574 example, some 68000 operating systems call this register @code{%a5}.
6575
6576 Eventually there may be a way of asking the compiler to choose a register
6577 automatically, but first we need to figure out how it should choose and
6578 how to enable you to guide the choice. No solution is evident.
6579
6580 Defining a global register variable in a certain register reserves that
6581 register entirely for this use, at least within the current compilation.
6582 The register is not allocated for any other purpose in the functions
6583 in the current compilation, and is not saved and restored by
6584 these functions. Stores into this register are never deleted even if they
6585 appear to be dead, but references may be deleted or moved or
6586 simplified.
6587
6588 It is not safe to access the global register variables from signal
6589 handlers, or from more than one thread of control, because the system
6590 library routines may temporarily use the register for other things (unless
6591 you recompile them specially for the task at hand).
6592
6593 @cindex @code{qsort}, and global register variables
6594 It is not safe for one function that uses a global register variable to
6595 call another such function @code{foo} by way of a third function
6596 @code{lose} that is compiled without knowledge of this variable (i.e.@: in a
6597 different source file in which the variable isn't declared). This is
6598 because @code{lose} might save the register and put some other value there.
6599 For example, you can't expect a global register variable to be available in
6600 the comparison-function that you pass to @code{qsort}, since @code{qsort}
6601 might have put something else in that register. (If you are prepared to
6602 recompile @code{qsort} with the same global register variable, you can
6603 solve this problem.)
6604
6605 If you want to recompile @code{qsort} or other source files that do not
6606 actually use your global register variable, so that they do not use that
6607 register for any other purpose, then it suffices to specify the compiler
6608 option @option{-ffixed-@var{reg}}. You need not actually add a global
6609 register declaration to their source code.
6610
6611 A function that can alter the value of a global register variable cannot
6612 safely be called from a function compiled without this variable, because it
6613 could clobber the value the caller expects to find there on return.
6614 Therefore, the function that is the entry point into the part of the
6615 program that uses the global register variable must explicitly save and
6616 restore the value that belongs to its caller.
6617
6618 @cindex register variable after @code{longjmp}
6619 @cindex global register after @code{longjmp}
6620 @cindex value after @code{longjmp}
6621 @findex longjmp
6622 @findex setjmp
6623 On most machines, @code{longjmp} restores to each global register
6624 variable the value it had at the time of the @code{setjmp}. On some
6625 machines, however, @code{longjmp} does not change the value of global
6626 register variables. To be portable, the function that called @code{setjmp}
6627 should make other arrangements to save the values of the global register
6628 variables, and to restore them in a @code{longjmp}. This way, the same
6629 thing happens regardless of what @code{longjmp} does.
6630
6631 All global register variable declarations must precede all function
6632 definitions. If such a declaration could appear after function
6633 definitions, the declaration would be too late to prevent the register from
6634 being used for other purposes in the preceding functions.
6635
6636 Global register variables may not have initial values, because an
6637 executable file has no means to supply initial contents for a register.
6638
6639 On the SPARC, there are reports that g3 @dots{} g7 are suitable
6640 registers, but certain library functions, such as @code{getwd}, as well
6641 as the subroutines for division and remainder, modify g3 and g4. g1 and
6642 g2 are local temporaries.
6643
6644 On the 68000, a2 @dots{} a5 should be suitable, as should d2 @dots{} d7.
6645 Of course, it does not do to use more than a few of those.
6646
6647 @node Local Reg Vars
6648 @subsection Specifying Registers for Local Variables
6649 @cindex local variables, specifying registers
6650 @cindex specifying registers for local variables
6651 @cindex registers for local variables
6652
6653 You can define a local register variable with a specified register
6654 like this:
6655
6656 @smallexample
6657 register int *foo asm ("a5");
6658 @end smallexample
6659
6660 @noindent
6661 Here @code{a5} is the name of the register that should be used. Note
6662 that this is the same syntax used for defining global register
6663 variables, but for a local variable it appears within a function.
6664
6665 Naturally the register name is cpu-dependent, but this is not a
6666 problem, since specific registers are most often useful with explicit
6667 assembler instructions (@pxref{Extended Asm}). Both of these things
6668 generally require that you conditionalize your program according to
6669 cpu type.
6670
6671 In addition, operating systems on one type of cpu may differ in how they
6672 name the registers; then you need additional conditionals. For
6673 example, some 68000 operating systems call this register @code{%a5}.
6674
6675 Defining such a register variable does not reserve the register; it
6676 remains available for other uses in places where flow control determines
6677 the variable's value is not live.
6678
6679 This option does not guarantee that GCC generates code that has
6680 this variable in the register you specify at all times. You may not
6681 code an explicit reference to this register in the @emph{assembler
6682 instruction template} part of an @code{asm} statement and assume it
6683 always refers to this variable. However, using the variable as an
6684 @code{asm} @emph{operand} guarantees that the specified register is used
6685 for the operand.
6686
6687 Stores into local register variables may be deleted when they appear to be dead
6688 according to dataflow analysis. References to local register variables may
6689 be deleted or moved or simplified.
6690
6691 As for global register variables, it's recommended that you choose a
6692 register that is normally saved and restored by function calls on
6693 your machine, so that library routines will not clobber it. A common
6694 pitfall is to initialize multiple call-clobbered registers with
6695 arbitrary expressions, where a function call or library call for an
6696 arithmetic operator overwrites a register value from a previous
6697 assignment, for example @code{r0} below:
6698 @smallexample
6699 register int *p1 asm ("r0") = @dots{};
6700 register int *p2 asm ("r1") = @dots{};
6701 @end smallexample
6702
6703 @noindent
6704 In those cases, a solution is to use a temporary variable for
6705 each arbitrary expression. @xref{Example of asm with clobbered asm reg}.
6706
6707 @node Alternate Keywords
6708 @section Alternate Keywords
6709 @cindex alternate keywords
6710 @cindex keywords, alternate
6711
6712 @option{-ansi} and the various @option{-std} options disable certain
6713 keywords. This causes trouble when you want to use GNU C extensions, or
6714 a general-purpose header file that should be usable by all programs,
6715 including ISO C programs. The keywords @code{asm}, @code{typeof} and
6716 @code{inline} are not available in programs compiled with
6717 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
6718 program compiled with @option{-std=c99} or @option{-std=c11}). The
6719 ISO C99 keyword
6720 @code{restrict} is only available when @option{-std=gnu99} (which will
6721 eventually be the default) or @option{-std=c99} (or the equivalent
6722 @option{-std=iso9899:1999}), or an option for a later standard
6723 version, is used.
6724
6725 The way to solve these problems is to put @samp{__} at the beginning and
6726 end of each problematical keyword. For example, use @code{__asm__}
6727 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
6728
6729 Other C compilers won't accept these alternative keywords; if you want to
6730 compile with another compiler, you can define the alternate keywords as
6731 macros to replace them with the customary keywords. It looks like this:
6732
6733 @smallexample
6734 #ifndef __GNUC__
6735 #define __asm__ asm
6736 #endif
6737 @end smallexample
6738
6739 @findex __extension__
6740 @opindex pedantic
6741 @option{-pedantic} and other options cause warnings for many GNU C extensions.
6742 You can
6743 prevent such warnings within one expression by writing
6744 @code{__extension__} before the expression. @code{__extension__} has no
6745 effect aside from this.
6746
6747 @node Incomplete Enums
6748 @section Incomplete @code{enum} Types
6749
6750 You can define an @code{enum} tag without specifying its possible values.
6751 This results in an incomplete type, much like what you get if you write
6752 @code{struct foo} without describing the elements. A later declaration
6753 that does specify the possible values completes the type.
6754
6755 You can't allocate variables or storage using the type while it is
6756 incomplete. However, you can work with pointers to that type.
6757
6758 This extension may not be very useful, but it makes the handling of
6759 @code{enum} more consistent with the way @code{struct} and @code{union}
6760 are handled.
6761
6762 This extension is not supported by GNU C++.
6763
6764 @node Function Names
6765 @section Function Names as Strings
6766 @cindex @code{__func__} identifier
6767 @cindex @code{__FUNCTION__} identifier
6768 @cindex @code{__PRETTY_FUNCTION__} identifier
6769
6770 GCC provides three magic variables that hold the name of the current
6771 function, as a string. The first of these is @code{__func__}, which
6772 is part of the C99 standard:
6773
6774 The identifier @code{__func__} is implicitly declared by the translator
6775 as if, immediately following the opening brace of each function
6776 definition, the declaration
6777
6778 @smallexample
6779 static const char __func__[] = "function-name";
6780 @end smallexample
6781
6782 @noindent
6783 appeared, where function-name is the name of the lexically-enclosing
6784 function. This name is the unadorned name of the function.
6785
6786 @code{__FUNCTION__} is another name for @code{__func__}. Older
6787 versions of GCC recognize only this name. However, it is not
6788 standardized. For maximum portability, we recommend you use
6789 @code{__func__}, but provide a fallback definition with the
6790 preprocessor:
6791
6792 @smallexample
6793 #if __STDC_VERSION__ < 199901L
6794 # if __GNUC__ >= 2
6795 # define __func__ __FUNCTION__
6796 # else
6797 # define __func__ "<unknown>"
6798 # endif
6799 #endif
6800 @end smallexample
6801
6802 In C, @code{__PRETTY_FUNCTION__} is yet another name for
6803 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
6804 the type signature of the function as well as its bare name. For
6805 example, this program:
6806
6807 @smallexample
6808 extern "C" @{
6809 extern int printf (char *, ...);
6810 @}
6811
6812 class a @{
6813 public:
6814 void sub (int i)
6815 @{
6816 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
6817 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
6818 @}
6819 @};
6820
6821 int
6822 main (void)
6823 @{
6824 a ax;
6825 ax.sub (0);
6826 return 0;
6827 @}
6828 @end smallexample
6829
6830 @noindent
6831 gives this output:
6832
6833 @smallexample
6834 __FUNCTION__ = sub
6835 __PRETTY_FUNCTION__ = void a::sub(int)
6836 @end smallexample
6837
6838 These identifiers are not preprocessor macros. In GCC 3.3 and
6839 earlier, in C only, @code{__FUNCTION__} and @code{__PRETTY_FUNCTION__}
6840 were treated as string literals; they could be used to initialize
6841 @code{char} arrays, and they could be concatenated with other string
6842 literals. GCC 3.4 and later treat them as variables, like
6843 @code{__func__}. In C++, @code{__FUNCTION__} and
6844 @code{__PRETTY_FUNCTION__} have always been variables.
6845
6846 @node Return Address
6847 @section Getting the Return or Frame Address of a Function
6848
6849 These functions may be used to get information about the callers of a
6850 function.
6851
6852 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
6853 This function returns the return address of the current function, or of
6854 one of its callers. The @var{level} argument is number of frames to
6855 scan up the call stack. A value of @code{0} yields the return address
6856 of the current function, a value of @code{1} yields the return address
6857 of the caller of the current function, and so forth. When inlining
6858 the expected behavior is that the function returns the address of
6859 the function that is returned to. To work around this behavior use
6860 the @code{noinline} function attribute.
6861
6862 The @var{level} argument must be a constant integer.
6863
6864 On some machines it may be impossible to determine the return address of
6865 any function other than the current one; in such cases, or when the top
6866 of the stack has been reached, this function returns @code{0} or a
6867 random value. In addition, @code{__builtin_frame_address} may be used
6868 to determine if the top of the stack has been reached.
6869
6870 Additional post-processing of the returned value may be needed, see
6871 @code{__builtin_extract_return_addr}.
6872
6873 This function should only be used with a nonzero argument for debugging
6874 purposes.
6875 @end deftypefn
6876
6877 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
6878 The address as returned by @code{__builtin_return_address} may have to be fed
6879 through this function to get the actual encoded address. For example, on the
6880 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
6881 platforms an offset has to be added for the true next instruction to be
6882 executed.
6883
6884 If no fixup is needed, this function simply passes through @var{addr}.
6885 @end deftypefn
6886
6887 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
6888 This function does the reverse of @code{__builtin_extract_return_addr}.
6889 @end deftypefn
6890
6891 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
6892 This function is similar to @code{__builtin_return_address}, but it
6893 returns the address of the function frame rather than the return address
6894 of the function. Calling @code{__builtin_frame_address} with a value of
6895 @code{0} yields the frame address of the current function, a value of
6896 @code{1} yields the frame address of the caller of the current function,
6897 and so forth.
6898
6899 The frame is the area on the stack that holds local variables and saved
6900 registers. The frame address is normally the address of the first word
6901 pushed on to the stack by the function. However, the exact definition
6902 depends upon the processor and the calling convention. If the processor
6903 has a dedicated frame pointer register, and the function has a frame,
6904 then @code{__builtin_frame_address} returns the value of the frame
6905 pointer register.
6906
6907 On some machines it may be impossible to determine the frame address of
6908 any function other than the current one; in such cases, or when the top
6909 of the stack has been reached, this function returns @code{0} if
6910 the first frame pointer is properly initialized by the startup code.
6911
6912 This function should only be used with a nonzero argument for debugging
6913 purposes.
6914 @end deftypefn
6915
6916 @node Vector Extensions
6917 @section Using Vector Instructions through Built-in Functions
6918
6919 On some targets, the instruction set contains SIMD vector instructions which
6920 operate on multiple values contained in one large register at the same time.
6921 For example, on the i386 the MMX, 3DNow!@: and SSE extensions can be used
6922 this way.
6923
6924 The first step in using these extensions is to provide the necessary data
6925 types. This should be done using an appropriate @code{typedef}:
6926
6927 @smallexample
6928 typedef int v4si __attribute__ ((vector_size (16)));
6929 @end smallexample
6930
6931 @noindent
6932 The @code{int} type specifies the base type, while the attribute specifies
6933 the vector size for the variable, measured in bytes. For example, the
6934 declaration above causes the compiler to set the mode for the @code{v4si}
6935 type to be 16 bytes wide and divided into @code{int} sized units. For
6936 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
6937 corresponding mode of @code{foo} is @acronym{V4SI}.
6938
6939 The @code{vector_size} attribute is only applicable to integral and
6940 float scalars, although arrays, pointers, and function return values
6941 are allowed in conjunction with this construct. Only sizes that are
6942 a power of two are currently allowed.
6943
6944 All the basic integer types can be used as base types, both as signed
6945 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
6946 @code{long long}. In addition, @code{float} and @code{double} can be
6947 used to build floating-point vector types.
6948
6949 Specifying a combination that is not valid for the current architecture
6950 causes GCC to synthesize the instructions using a narrower mode.
6951 For example, if you specify a variable of type @code{V4SI} and your
6952 architecture does not allow for this specific SIMD type, GCC
6953 produces code that uses 4 @code{SIs}.
6954
6955 The types defined in this manner can be used with a subset of normal C
6956 operations. Currently, GCC allows using the following operators
6957 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
6958
6959 The operations behave like C++ @code{valarrays}. Addition is defined as
6960 the addition of the corresponding elements of the operands. For
6961 example, in the code below, each of the 4 elements in @var{a} is
6962 added to the corresponding 4 elements in @var{b} and the resulting
6963 vector is stored in @var{c}.
6964
6965 @smallexample
6966 typedef int v4si __attribute__ ((vector_size (16)));
6967
6968 v4si a, b, c;
6969
6970 c = a + b;
6971 @end smallexample
6972
6973 Subtraction, multiplication, division, and the logical operations
6974 operate in a similar manner. Likewise, the result of using the unary
6975 minus or complement operators on a vector type is a vector whose
6976 elements are the negative or complemented values of the corresponding
6977 elements in the operand.
6978
6979 It is possible to use shifting operators @code{<<}, @code{>>} on
6980 integer-type vectors. The operation is defined as following: @code{@{a0,
6981 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
6982 @dots{}, an >> bn@}}@. Vector operands must have the same number of
6983 elements.
6984
6985 For convenience, it is allowed to use a binary vector operation
6986 where one operand is a scalar. In that case the compiler transforms
6987 the scalar operand into a vector where each element is the scalar from
6988 the operation. The transformation happens only if the scalar could be
6989 safely converted to the vector-element type.
6990 Consider the following code.
6991
6992 @smallexample
6993 typedef int v4si __attribute__ ((vector_size (16)));
6994
6995 v4si a, b, c;
6996 long l;
6997
6998 a = b + 1; /* a = b + @{1,1,1,1@}; */
6999 a = 2 * b; /* a = @{2,2,2,2@} * b; */
7000
7001 a = l + a; /* Error, cannot convert long to int. */
7002 @end smallexample
7003
7004 Vectors can be subscripted as if the vector were an array with
7005 the same number of elements and base type. Out of bound accesses
7006 invoke undefined behavior at run time. Warnings for out of bound
7007 accesses for vector subscription can be enabled with
7008 @option{-Warray-bounds}.
7009
7010 Vector comparison is supported with standard comparison
7011 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
7012 vector expressions of integer-type or real-type. Comparison between
7013 integer-type vectors and real-type vectors are not supported. The
7014 result of the comparison is a vector of the same width and number of
7015 elements as the comparison operands with a signed integral element
7016 type.
7017
7018 Vectors are compared element-wise producing 0 when comparison is false
7019 and -1 (constant of the appropriate type where all bits are set)
7020 otherwise. Consider the following example.
7021
7022 @smallexample
7023 typedef int v4si __attribute__ ((vector_size (16)));
7024
7025 v4si a = @{1,2,3,4@};
7026 v4si b = @{3,2,1,4@};
7027 v4si c;
7028
7029 c = a > b; /* The result would be @{0, 0,-1, 0@} */
7030 c = a == b; /* The result would be @{0,-1, 0,-1@} */
7031 @end smallexample
7032
7033 Vector shuffling is available using functions
7034 @code{__builtin_shuffle (vec, mask)} and
7035 @code{__builtin_shuffle (vec0, vec1, mask)}.
7036 Both functions construct a permutation of elements from one or two
7037 vectors and return a vector of the same type as the input vector(s).
7038 The @var{mask} is an integral vector with the same width (@var{W})
7039 and element count (@var{N}) as the output vector.
7040
7041 The elements of the input vectors are numbered in memory ordering of
7042 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
7043 elements of @var{mask} are considered modulo @var{N} in the single-operand
7044 case and modulo @math{2*@var{N}} in the two-operand case.
7045
7046 Consider the following example,
7047
7048 @smallexample
7049 typedef int v4si __attribute__ ((vector_size (16)));
7050
7051 v4si a = @{1,2,3,4@};
7052 v4si b = @{5,6,7,8@};
7053 v4si mask1 = @{0,1,1,3@};
7054 v4si mask2 = @{0,4,2,5@};
7055 v4si res;
7056
7057 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
7058 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
7059 @end smallexample
7060
7061 Note that @code{__builtin_shuffle} is intentionally semantically
7062 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
7063
7064 You can declare variables and use them in function calls and returns, as
7065 well as in assignments and some casts. You can specify a vector type as
7066 a return type for a function. Vector types can also be used as function
7067 arguments. It is possible to cast from one vector type to another,
7068 provided they are of the same size (in fact, you can also cast vectors
7069 to and from other datatypes of the same size).
7070
7071 You cannot operate between vectors of different lengths or different
7072 signedness without a cast.
7073
7074 @node Offsetof
7075 @section Offsetof
7076 @findex __builtin_offsetof
7077
7078 GCC implements for both C and C++ a syntactic extension to implement
7079 the @code{offsetof} macro.
7080
7081 @smallexample
7082 primary:
7083 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
7084
7085 offsetof_member_designator:
7086 @code{identifier}
7087 | offsetof_member_designator "." @code{identifier}
7088 | offsetof_member_designator "[" @code{expr} "]"
7089 @end smallexample
7090
7091 This extension is sufficient such that
7092
7093 @smallexample
7094 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
7095 @end smallexample
7096
7097 @noindent
7098 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
7099 may be dependent. In either case, @var{member} may consist of a single
7100 identifier, or a sequence of member accesses and array references.
7101
7102 @node __sync Builtins
7103 @section Legacy __sync Built-in Functions for Atomic Memory Access
7104
7105 The following built-in functions
7106 are intended to be compatible with those described
7107 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
7108 section 7.4. As such, they depart from the normal GCC practice of using
7109 the @samp{__builtin_} prefix, and further that they are overloaded such that
7110 they work on multiple types.
7111
7112 The definition given in the Intel documentation allows only for the use of
7113 the types @code{int}, @code{long}, @code{long long} as well as their unsigned
7114 counterparts. GCC allows any integral scalar or pointer type that is
7115 1, 2, 4 or 8 bytes in length.
7116
7117 Not all operations are supported by all target processors. If a particular
7118 operation cannot be implemented on the target processor, a warning is
7119 generated and a call an external function is generated. The external
7120 function carries the same name as the built-in version,
7121 with an additional suffix
7122 @samp{_@var{n}} where @var{n} is the size of the data type.
7123
7124 @c ??? Should we have a mechanism to suppress this warning? This is almost
7125 @c useful for implementing the operation under the control of an external
7126 @c mutex.
7127
7128 In most cases, these built-in functions are considered a @dfn{full barrier}.
7129 That is,
7130 no memory operand is moved across the operation, either forward or
7131 backward. Further, instructions are issued as necessary to prevent the
7132 processor from speculating loads across the operation and from queuing stores
7133 after the operation.
7134
7135 All of the routines are described in the Intel documentation to take
7136 ``an optional list of variables protected by the memory barrier''. It's
7137 not clear what is meant by that; it could mean that @emph{only} the
7138 following variables are protected, or it could mean that these variables
7139 should in addition be protected. At present GCC ignores this list and
7140 protects all variables that are globally accessible. If in the future
7141 we make some use of this list, an empty list will continue to mean all
7142 globally accessible variables.
7143
7144 @table @code
7145 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
7146 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
7147 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
7148 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
7149 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
7150 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
7151 @findex __sync_fetch_and_add
7152 @findex __sync_fetch_and_sub
7153 @findex __sync_fetch_and_or
7154 @findex __sync_fetch_and_and
7155 @findex __sync_fetch_and_xor
7156 @findex __sync_fetch_and_nand
7157 These built-in functions perform the operation suggested by the name, and
7158 returns the value that had previously been in memory. That is,
7159
7160 @smallexample
7161 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
7162 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
7163 @end smallexample
7164
7165 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
7166 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
7167
7168 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
7169 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
7170 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
7171 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
7172 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
7173 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
7174 @findex __sync_add_and_fetch
7175 @findex __sync_sub_and_fetch
7176 @findex __sync_or_and_fetch
7177 @findex __sync_and_and_fetch
7178 @findex __sync_xor_and_fetch
7179 @findex __sync_nand_and_fetch
7180 These built-in functions perform the operation suggested by the name, and
7181 return the new value. That is,
7182
7183 @smallexample
7184 @{ *ptr @var{op}= value; return *ptr; @}
7185 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
7186 @end smallexample
7187
7188 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
7189 as @code{*ptr = ~(*ptr & value)} instead of
7190 @code{*ptr = ~*ptr & value}.
7191
7192 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7193 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
7194 @findex __sync_bool_compare_and_swap
7195 @findex __sync_val_compare_and_swap
7196 These built-in functions perform an atomic compare and swap.
7197 That is, if the current
7198 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
7199 @code{*@var{ptr}}.
7200
7201 The ``bool'' version returns true if the comparison is successful and
7202 @var{newval} is written. The ``val'' version returns the contents
7203 of @code{*@var{ptr}} before the operation.
7204
7205 @item __sync_synchronize (...)
7206 @findex __sync_synchronize
7207 This built-in function issues a full memory barrier.
7208
7209 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
7210 @findex __sync_lock_test_and_set
7211 This built-in function, as described by Intel, is not a traditional test-and-set
7212 operation, but rather an atomic exchange operation. It writes @var{value}
7213 into @code{*@var{ptr}}, and returns the previous contents of
7214 @code{*@var{ptr}}.
7215
7216 Many targets have only minimal support for such locks, and do not support
7217 a full exchange operation. In this case, a target may support reduced
7218 functionality here by which the @emph{only} valid value to store is the
7219 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
7220 is implementation defined.
7221
7222 This built-in function is not a full barrier,
7223 but rather an @dfn{acquire barrier}.
7224 This means that references after the operation cannot move to (or be
7225 speculated to) before the operation, but previous memory stores may not
7226 be globally visible yet, and previous memory loads may not yet be
7227 satisfied.
7228
7229 @item void __sync_lock_release (@var{type} *ptr, ...)
7230 @findex __sync_lock_release
7231 This built-in function releases the lock acquired by
7232 @code{__sync_lock_test_and_set}.
7233 Normally this means writing the constant 0 to @code{*@var{ptr}}.
7234
7235 This built-in function is not a full barrier,
7236 but rather a @dfn{release barrier}.
7237 This means that all previous memory stores are globally visible, and all
7238 previous memory loads have been satisfied, but following memory reads
7239 are not prevented from being speculated to before the barrier.
7240 @end table
7241
7242 @node __atomic Builtins
7243 @section Built-in functions for memory model aware atomic operations
7244
7245 The following built-in functions approximately match the requirements for
7246 C++11 memory model. Many are similar to the @samp{__sync} prefixed built-in
7247 functions, but all also have a memory model parameter. These are all
7248 identified by being prefixed with @samp{__atomic}, and most are overloaded
7249 such that they work with multiple types.
7250
7251 GCC allows any integral scalar or pointer type that is 1, 2, 4, or 8
7252 bytes in length. 16-byte integral types are also allowed if
7253 @samp{__int128} (@pxref{__int128}) is supported by the architecture.
7254
7255 Target architectures are encouraged to provide their own patterns for
7256 each of these built-in functions. If no target is provided, the original
7257 non-memory model set of @samp{__sync} atomic built-in functions are
7258 utilized, along with any required synchronization fences surrounding it in
7259 order to achieve the proper behavior. Execution in this case is subject
7260 to the same restrictions as those built-in functions.
7261
7262 If there is no pattern or mechanism to provide a lock free instruction
7263 sequence, a call is made to an external routine with the same parameters
7264 to be resolved at run time.
7265
7266 The four non-arithmetic functions (load, store, exchange, and
7267 compare_exchange) all have a generic version as well. This generic
7268 version works on any data type. If the data type size maps to one
7269 of the integral sizes that may have lock free support, the generic
7270 version utilizes the lock free built-in function. Otherwise an
7271 external call is left to be resolved at run time. This external call is
7272 the same format with the addition of a @samp{size_t} parameter inserted
7273 as the first parameter indicating the size of the object being pointed to.
7274 All objects must be the same size.
7275
7276 There are 6 different memory models that can be specified. These map
7277 to the same names in the C++11 standard. Refer there or to the
7278 @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki on
7279 atomic synchronization} for more detailed definitions. These memory
7280 models integrate both barriers to code motion as well as synchronization
7281 requirements with other threads. These are listed in approximately
7282 ascending order of strength. It is also possible to use target specific
7283 flags for memory model flags, like Hardware Lock Elision.
7284
7285 @table @code
7286 @item __ATOMIC_RELAXED
7287 No barriers or synchronization.
7288 @item __ATOMIC_CONSUME
7289 Data dependency only for both barrier and synchronization with another
7290 thread.
7291 @item __ATOMIC_ACQUIRE
7292 Barrier to hoisting of code and synchronizes with release (or stronger)
7293 semantic stores from another thread.
7294 @item __ATOMIC_RELEASE
7295 Barrier to sinking of code and synchronizes with acquire (or stronger)
7296 semantic loads from another thread.
7297 @item __ATOMIC_ACQ_REL
7298 Full barrier in both directions and synchronizes with acquire loads and
7299 release stores in another thread.
7300 @item __ATOMIC_SEQ_CST
7301 Full barrier in both directions and synchronizes with acquire loads and
7302 release stores in all threads.
7303 @end table
7304
7305 When implementing patterns for these built-in functions, the memory model
7306 parameter can be ignored as long as the pattern implements the most
7307 restrictive @code{__ATOMIC_SEQ_CST} model. Any of the other memory models
7308 execute correctly with this memory model but they may not execute as
7309 efficiently as they could with a more appropriate implementation of the
7310 relaxed requirements.
7311
7312 Note that the C++11 standard allows for the memory model parameter to be
7313 determined at run time rather than at compile time. These built-in
7314 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
7315 than invoke a runtime library call or inline a switch statement. This is
7316 standard compliant, safe, and the simplest approach for now.
7317
7318 The memory model parameter is a signed int, but only the lower 8 bits are
7319 reserved for the memory model. The remainder of the signed int is reserved
7320 for future use and should be 0. Use of the predefined atomic values
7321 ensures proper usage.
7322
7323 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memmodel)
7324 This built-in function implements an atomic load operation. It returns the
7325 contents of @code{*@var{ptr}}.
7326
7327 The valid memory model variants are
7328 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7329 and @code{__ATOMIC_CONSUME}.
7330
7331 @end deftypefn
7332
7333 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memmodel)
7334 This is the generic version of an atomic load. It returns the
7335 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
7336
7337 @end deftypefn
7338
7339 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memmodel)
7340 This built-in function implements an atomic store operation. It writes
7341 @code{@var{val}} into @code{*@var{ptr}}.
7342
7343 The valid memory model variants are
7344 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
7345
7346 @end deftypefn
7347
7348 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memmodel)
7349 This is the generic version of an atomic store. It stores the value
7350 of @code{*@var{val}} into @code{*@var{ptr}}.
7351
7352 @end deftypefn
7353
7354 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memmodel)
7355 This built-in function implements an atomic exchange operation. It writes
7356 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
7357 @code{*@var{ptr}}.
7358
7359 The valid memory model variants are
7360 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
7361 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
7362
7363 @end deftypefn
7364
7365 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memmodel)
7366 This is the generic version of an atomic exchange. It stores the
7367 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
7368 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
7369
7370 @end deftypefn
7371
7372 @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)
7373 This built-in function implements an atomic compare and exchange operation.
7374 This compares the contents of @code{*@var{ptr}} with the contents of
7375 @code{*@var{expected}} and if equal, writes @var{desired} into
7376 @code{*@var{ptr}}. If they are not equal, the current contents of
7377 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
7378 for weak compare_exchange, and false for the strong variation. Many targets
7379 only offer the strong variation and ignore the parameter. When in doubt, use
7380 the strong variation.
7381
7382 True is returned if @var{desired} is written into
7383 @code{*@var{ptr}} and the execution is considered to conform to the
7384 memory model specified by @var{success_memmodel}. There are no
7385 restrictions on what memory model can be used here.
7386
7387 False is returned otherwise, and the execution is considered to conform
7388 to @var{failure_memmodel}. This memory model cannot be
7389 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
7390 stronger model than that specified by @var{success_memmodel}.
7391
7392 @end deftypefn
7393
7394 @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)
7395 This built-in function implements the generic version of
7396 @code{__atomic_compare_exchange}. The function is virtually identical to
7397 @code{__atomic_compare_exchange_n}, except the desired value is also a
7398 pointer.
7399
7400 @end deftypefn
7401
7402 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7403 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7404 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7405 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7406 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7407 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memmodel)
7408 These built-in functions perform the operation suggested by the name, and
7409 return the result of the operation. That is,
7410
7411 @smallexample
7412 @{ *ptr @var{op}= val; return *ptr; @}
7413 @end smallexample
7414
7415 All memory models are valid.
7416
7417 @end deftypefn
7418
7419 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memmodel)
7420 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memmodel)
7421 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memmodel)
7422 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memmodel)
7423 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memmodel)
7424 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memmodel)
7425 These built-in functions perform the operation suggested by the name, and
7426 return the value that had previously been in @code{*@var{ptr}}. That is,
7427
7428 @smallexample
7429 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
7430 @end smallexample
7431
7432 All memory models are valid.
7433
7434 @end deftypefn
7435
7436 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memmodel)
7437
7438 This built-in function performs an atomic test-and-set operation on
7439 the byte at @code{*@var{ptr}}. The byte is set to some implementation
7440 defined nonzero ``set'' value and the return value is @code{true} if and only
7441 if the previous contents were ``set''.
7442
7443 All memory models are valid.
7444
7445 @end deftypefn
7446
7447 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memmodel)
7448
7449 This built-in function performs an atomic clear operation on
7450 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
7451
7452 The valid memory model variants are
7453 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
7454 @code{__ATOMIC_RELEASE}.
7455
7456 @end deftypefn
7457
7458 @deftypefn {Built-in Function} void __atomic_thread_fence (int memmodel)
7459
7460 This built-in function acts as a synchronization fence between threads
7461 based on the specified memory model.
7462
7463 All memory orders are valid.
7464
7465 @end deftypefn
7466
7467 @deftypefn {Built-in Function} void __atomic_signal_fence (int memmodel)
7468
7469 This built-in function acts as a synchronization fence between a thread
7470 and signal handlers based in the same thread.
7471
7472 All memory orders are valid.
7473
7474 @end deftypefn
7475
7476 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
7477
7478 This built-in function returns true if objects of @var{size} bytes always
7479 generate lock free atomic instructions for the target architecture.
7480 @var{size} must resolve to a compile-time constant and the result also
7481 resolves to a compile-time constant.
7482
7483 @var{ptr} is an optional pointer to the object that may be used to determine
7484 alignment. A value of 0 indicates typical alignment should be used. The
7485 compiler may also ignore this parameter.
7486
7487 @smallexample
7488 if (_atomic_always_lock_free (sizeof (long long), 0))
7489 @end smallexample
7490
7491 @end deftypefn
7492
7493 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
7494
7495 This built-in function returns true if objects of @var{size} bytes always
7496 generate lock free atomic instructions for the target architecture. If
7497 it is not known to be lock free a call is made to a runtime routine named
7498 @code{__atomic_is_lock_free}.
7499
7500 @var{ptr} is an optional pointer to the object that may be used to determine
7501 alignment. A value of 0 indicates typical alignment should be used. The
7502 compiler may also ignore this parameter.
7503 @end deftypefn
7504
7505 @node x86 specific memory model extensions for transactional memory
7506 @section x86 specific memory model extensions for transactional memory
7507
7508 The i386 architecture supports additional memory ordering flags
7509 to mark lock critical sections for hardware lock elision.
7510 These must be specified in addition to an existing memory model to
7511 atomic intrinsics.
7512
7513 @table @code
7514 @item __ATOMIC_HLE_ACQUIRE
7515 Start lock elision on a lock variable.
7516 Memory model must be @code{__ATOMIC_ACQUIRE} or stronger.
7517 @item __ATOMIC_HLE_RELEASE
7518 End lock elision on a lock variable.
7519 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
7520 @end table
7521
7522 When a lock acquire fails it's required for good performance to abort
7523 the transaction quickly. This can be done with a @code{_mm_pause}
7524
7525 @smallexample
7526 #include <immintrin.h> // For _mm_pause
7527
7528 /* Acquire lock with lock elision */
7529 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
7530 _mm_pause(); /* Abort failed transaction */
7531 ...
7532 /* Free lock with lock elision */
7533 __atomic_clear(&lockvar, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
7534 @end smallexample
7535
7536 @node Object Size Checking
7537 @section Object Size Checking Built-in Functions
7538 @findex __builtin_object_size
7539 @findex __builtin___memcpy_chk
7540 @findex __builtin___mempcpy_chk
7541 @findex __builtin___memmove_chk
7542 @findex __builtin___memset_chk
7543 @findex __builtin___strcpy_chk
7544 @findex __builtin___stpcpy_chk
7545 @findex __builtin___strncpy_chk
7546 @findex __builtin___strcat_chk
7547 @findex __builtin___strncat_chk
7548 @findex __builtin___sprintf_chk
7549 @findex __builtin___snprintf_chk
7550 @findex __builtin___vsprintf_chk
7551 @findex __builtin___vsnprintf_chk
7552 @findex __builtin___printf_chk
7553 @findex __builtin___vprintf_chk
7554 @findex __builtin___fprintf_chk
7555 @findex __builtin___vfprintf_chk
7556
7557 GCC implements a limited buffer overflow protection mechanism
7558 that can prevent some buffer overflow attacks.
7559
7560 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
7561 is a built-in construct that returns a constant number of bytes from
7562 @var{ptr} to the end of the object @var{ptr} pointer points to
7563 (if known at compile time). @code{__builtin_object_size} never evaluates
7564 its arguments for side-effects. If there are any side-effects in them, it
7565 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7566 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
7567 point to and all of them are known at compile time, the returned number
7568 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
7569 0 and minimum if nonzero. If it is not possible to determine which objects
7570 @var{ptr} points to at compile time, @code{__builtin_object_size} should
7571 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
7572 for @var{type} 2 or 3.
7573
7574 @var{type} is an integer constant from 0 to 3. If the least significant
7575 bit is clear, objects are whole variables, if it is set, a closest
7576 surrounding subobject is considered the object a pointer points to.
7577 The second bit determines if maximum or minimum of remaining bytes
7578 is computed.
7579
7580 @smallexample
7581 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
7582 char *p = &var.buf1[1], *q = &var.b;
7583
7584 /* Here the object p points to is var. */
7585 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
7586 /* The subobject p points to is var.buf1. */
7587 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
7588 /* The object q points to is var. */
7589 assert (__builtin_object_size (q, 0)
7590 == (char *) (&var + 1) - (char *) &var.b);
7591 /* The subobject q points to is var.b. */
7592 assert (__builtin_object_size (q, 1) == sizeof (var.b));
7593 @end smallexample
7594 @end deftypefn
7595
7596 There are built-in functions added for many common string operation
7597 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
7598 built-in is provided. This built-in has an additional last argument,
7599 which is the number of bytes remaining in object the @var{dest}
7600 argument points to or @code{(size_t) -1} if the size is not known.
7601
7602 The built-in functions are optimized into the normal string functions
7603 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
7604 it is known at compile time that the destination object will not
7605 be overflown. If the compiler can determine at compile time the
7606 object will be always overflown, it issues a warning.
7607
7608 The intended use can be e.g.@:
7609
7610 @smallexample
7611 #undef memcpy
7612 #define bos0(dest) __builtin_object_size (dest, 0)
7613 #define memcpy(dest, src, n) \
7614 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
7615
7616 char *volatile p;
7617 char buf[10];
7618 /* It is unknown what object p points to, so this is optimized
7619 into plain memcpy - no checking is possible. */
7620 memcpy (p, "abcde", n);
7621 /* Destination is known and length too. It is known at compile
7622 time there will be no overflow. */
7623 memcpy (&buf[5], "abcde", 5);
7624 /* Destination is known, but the length is not known at compile time.
7625 This will result in __memcpy_chk call that can check for overflow
7626 at run time. */
7627 memcpy (&buf[5], "abcde", n);
7628 /* Destination is known and it is known at compile time there will
7629 be overflow. There will be a warning and __memcpy_chk call that
7630 will abort the program at run time. */
7631 memcpy (&buf[6], "abcde", 5);
7632 @end smallexample
7633
7634 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
7635 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
7636 @code{strcat} and @code{strncat}.
7637
7638 There are also checking built-in functions for formatted output functions.
7639 @smallexample
7640 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
7641 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7642 const char *fmt, ...);
7643 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
7644 va_list ap);
7645 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
7646 const char *fmt, va_list ap);
7647 @end smallexample
7648
7649 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
7650 etc.@: functions and can contain implementation specific flags on what
7651 additional security measures the checking function might take, such as
7652 handling @code{%n} differently.
7653
7654 The @var{os} argument is the object size @var{s} points to, like in the
7655 other built-in functions. There is a small difference in the behavior
7656 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
7657 optimized into the non-checking functions only if @var{flag} is 0, otherwise
7658 the checking function is called with @var{os} argument set to
7659 @code{(size_t) -1}.
7660
7661 In addition to this, there are checking built-in functions
7662 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
7663 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
7664 These have just one additional argument, @var{flag}, right before
7665 format string @var{fmt}. If the compiler is able to optimize them to
7666 @code{fputc} etc.@: functions, it does, otherwise the checking function
7667 is called and the @var{flag} argument passed to it.
7668
7669 @node Other Builtins
7670 @section Other Built-in Functions Provided by GCC
7671 @cindex built-in functions
7672 @findex __builtin_fpclassify
7673 @findex __builtin_isfinite
7674 @findex __builtin_isnormal
7675 @findex __builtin_isgreater
7676 @findex __builtin_isgreaterequal
7677 @findex __builtin_isinf_sign
7678 @findex __builtin_isless
7679 @findex __builtin_islessequal
7680 @findex __builtin_islessgreater
7681 @findex __builtin_isunordered
7682 @findex __builtin_powi
7683 @findex __builtin_powif
7684 @findex __builtin_powil
7685 @findex _Exit
7686 @findex _exit
7687 @findex abort
7688 @findex abs
7689 @findex acos
7690 @findex acosf
7691 @findex acosh
7692 @findex acoshf
7693 @findex acoshl
7694 @findex acosl
7695 @findex alloca
7696 @findex asin
7697 @findex asinf
7698 @findex asinh
7699 @findex asinhf
7700 @findex asinhl
7701 @findex asinl
7702 @findex atan
7703 @findex atan2
7704 @findex atan2f
7705 @findex atan2l
7706 @findex atanf
7707 @findex atanh
7708 @findex atanhf
7709 @findex atanhl
7710 @findex atanl
7711 @findex bcmp
7712 @findex bzero
7713 @findex cabs
7714 @findex cabsf
7715 @findex cabsl
7716 @findex cacos
7717 @findex cacosf
7718 @findex cacosh
7719 @findex cacoshf
7720 @findex cacoshl
7721 @findex cacosl
7722 @findex calloc
7723 @findex carg
7724 @findex cargf
7725 @findex cargl
7726 @findex casin
7727 @findex casinf
7728 @findex casinh
7729 @findex casinhf
7730 @findex casinhl
7731 @findex casinl
7732 @findex catan
7733 @findex catanf
7734 @findex catanh
7735 @findex catanhf
7736 @findex catanhl
7737 @findex catanl
7738 @findex cbrt
7739 @findex cbrtf
7740 @findex cbrtl
7741 @findex ccos
7742 @findex ccosf
7743 @findex ccosh
7744 @findex ccoshf
7745 @findex ccoshl
7746 @findex ccosl
7747 @findex ceil
7748 @findex ceilf
7749 @findex ceill
7750 @findex cexp
7751 @findex cexpf
7752 @findex cexpl
7753 @findex cimag
7754 @findex cimagf
7755 @findex cimagl
7756 @findex clog
7757 @findex clogf
7758 @findex clogl
7759 @findex conj
7760 @findex conjf
7761 @findex conjl
7762 @findex copysign
7763 @findex copysignf
7764 @findex copysignl
7765 @findex cos
7766 @findex cosf
7767 @findex cosh
7768 @findex coshf
7769 @findex coshl
7770 @findex cosl
7771 @findex cpow
7772 @findex cpowf
7773 @findex cpowl
7774 @findex cproj
7775 @findex cprojf
7776 @findex cprojl
7777 @findex creal
7778 @findex crealf
7779 @findex creall
7780 @findex csin
7781 @findex csinf
7782 @findex csinh
7783 @findex csinhf
7784 @findex csinhl
7785 @findex csinl
7786 @findex csqrt
7787 @findex csqrtf
7788 @findex csqrtl
7789 @findex ctan
7790 @findex ctanf
7791 @findex ctanh
7792 @findex ctanhf
7793 @findex ctanhl
7794 @findex ctanl
7795 @findex dcgettext
7796 @findex dgettext
7797 @findex drem
7798 @findex dremf
7799 @findex dreml
7800 @findex erf
7801 @findex erfc
7802 @findex erfcf
7803 @findex erfcl
7804 @findex erff
7805 @findex erfl
7806 @findex exit
7807 @findex exp
7808 @findex exp10
7809 @findex exp10f
7810 @findex exp10l
7811 @findex exp2
7812 @findex exp2f
7813 @findex exp2l
7814 @findex expf
7815 @findex expl
7816 @findex expm1
7817 @findex expm1f
7818 @findex expm1l
7819 @findex fabs
7820 @findex fabsf
7821 @findex fabsl
7822 @findex fdim
7823 @findex fdimf
7824 @findex fdiml
7825 @findex ffs
7826 @findex floor
7827 @findex floorf
7828 @findex floorl
7829 @findex fma
7830 @findex fmaf
7831 @findex fmal
7832 @findex fmax
7833 @findex fmaxf
7834 @findex fmaxl
7835 @findex fmin
7836 @findex fminf
7837 @findex fminl
7838 @findex fmod
7839 @findex fmodf
7840 @findex fmodl
7841 @findex fprintf
7842 @findex fprintf_unlocked
7843 @findex fputs
7844 @findex fputs_unlocked
7845 @findex frexp
7846 @findex frexpf
7847 @findex frexpl
7848 @findex fscanf
7849 @findex gamma
7850 @findex gammaf
7851 @findex gammal
7852 @findex gamma_r
7853 @findex gammaf_r
7854 @findex gammal_r
7855 @findex gettext
7856 @findex hypot
7857 @findex hypotf
7858 @findex hypotl
7859 @findex ilogb
7860 @findex ilogbf
7861 @findex ilogbl
7862 @findex imaxabs
7863 @findex index
7864 @findex isalnum
7865 @findex isalpha
7866 @findex isascii
7867 @findex isblank
7868 @findex iscntrl
7869 @findex isdigit
7870 @findex isgraph
7871 @findex islower
7872 @findex isprint
7873 @findex ispunct
7874 @findex isspace
7875 @findex isupper
7876 @findex iswalnum
7877 @findex iswalpha
7878 @findex iswblank
7879 @findex iswcntrl
7880 @findex iswdigit
7881 @findex iswgraph
7882 @findex iswlower
7883 @findex iswprint
7884 @findex iswpunct
7885 @findex iswspace
7886 @findex iswupper
7887 @findex iswxdigit
7888 @findex isxdigit
7889 @findex j0
7890 @findex j0f
7891 @findex j0l
7892 @findex j1
7893 @findex j1f
7894 @findex j1l
7895 @findex jn
7896 @findex jnf
7897 @findex jnl
7898 @findex labs
7899 @findex ldexp
7900 @findex ldexpf
7901 @findex ldexpl
7902 @findex lgamma
7903 @findex lgammaf
7904 @findex lgammal
7905 @findex lgamma_r
7906 @findex lgammaf_r
7907 @findex lgammal_r
7908 @findex llabs
7909 @findex llrint
7910 @findex llrintf
7911 @findex llrintl
7912 @findex llround
7913 @findex llroundf
7914 @findex llroundl
7915 @findex log
7916 @findex log10
7917 @findex log10f
7918 @findex log10l
7919 @findex log1p
7920 @findex log1pf
7921 @findex log1pl
7922 @findex log2
7923 @findex log2f
7924 @findex log2l
7925 @findex logb
7926 @findex logbf
7927 @findex logbl
7928 @findex logf
7929 @findex logl
7930 @findex lrint
7931 @findex lrintf
7932 @findex lrintl
7933 @findex lround
7934 @findex lroundf
7935 @findex lroundl
7936 @findex malloc
7937 @findex memchr
7938 @findex memcmp
7939 @findex memcpy
7940 @findex mempcpy
7941 @findex memset
7942 @findex modf
7943 @findex modff
7944 @findex modfl
7945 @findex nearbyint
7946 @findex nearbyintf
7947 @findex nearbyintl
7948 @findex nextafter
7949 @findex nextafterf
7950 @findex nextafterl
7951 @findex nexttoward
7952 @findex nexttowardf
7953 @findex nexttowardl
7954 @findex pow
7955 @findex pow10
7956 @findex pow10f
7957 @findex pow10l
7958 @findex powf
7959 @findex powl
7960 @findex printf
7961 @findex printf_unlocked
7962 @findex putchar
7963 @findex puts
7964 @findex remainder
7965 @findex remainderf
7966 @findex remainderl
7967 @findex remquo
7968 @findex remquof
7969 @findex remquol
7970 @findex rindex
7971 @findex rint
7972 @findex rintf
7973 @findex rintl
7974 @findex round
7975 @findex roundf
7976 @findex roundl
7977 @findex scalb
7978 @findex scalbf
7979 @findex scalbl
7980 @findex scalbln
7981 @findex scalblnf
7982 @findex scalblnf
7983 @findex scalbn
7984 @findex scalbnf
7985 @findex scanfnl
7986 @findex signbit
7987 @findex signbitf
7988 @findex signbitl
7989 @findex signbitd32
7990 @findex signbitd64
7991 @findex signbitd128
7992 @findex significand
7993 @findex significandf
7994 @findex significandl
7995 @findex sin
7996 @findex sincos
7997 @findex sincosf
7998 @findex sincosl
7999 @findex sinf
8000 @findex sinh
8001 @findex sinhf
8002 @findex sinhl
8003 @findex sinl
8004 @findex snprintf
8005 @findex sprintf
8006 @findex sqrt
8007 @findex sqrtf
8008 @findex sqrtl
8009 @findex sscanf
8010 @findex stpcpy
8011 @findex stpncpy
8012 @findex strcasecmp
8013 @findex strcat
8014 @findex strchr
8015 @findex strcmp
8016 @findex strcpy
8017 @findex strcspn
8018 @findex strdup
8019 @findex strfmon
8020 @findex strftime
8021 @findex strlen
8022 @findex strncasecmp
8023 @findex strncat
8024 @findex strncmp
8025 @findex strncpy
8026 @findex strndup
8027 @findex strpbrk
8028 @findex strrchr
8029 @findex strspn
8030 @findex strstr
8031 @findex tan
8032 @findex tanf
8033 @findex tanh
8034 @findex tanhf
8035 @findex tanhl
8036 @findex tanl
8037 @findex tgamma
8038 @findex tgammaf
8039 @findex tgammal
8040 @findex toascii
8041 @findex tolower
8042 @findex toupper
8043 @findex towlower
8044 @findex towupper
8045 @findex trunc
8046 @findex truncf
8047 @findex truncl
8048 @findex vfprintf
8049 @findex vfscanf
8050 @findex vprintf
8051 @findex vscanf
8052 @findex vsnprintf
8053 @findex vsprintf
8054 @findex vsscanf
8055 @findex y0
8056 @findex y0f
8057 @findex y0l
8058 @findex y1
8059 @findex y1f
8060 @findex y1l
8061 @findex yn
8062 @findex ynf
8063 @findex ynl
8064
8065 GCC provides a large number of built-in functions other than the ones
8066 mentioned above. Some of these are for internal use in the processing
8067 of exceptions or variable-length argument lists and are not
8068 documented here because they may change from time to time; we do not
8069 recommend general use of these functions.
8070
8071 The remaining functions are provided for optimization purposes.
8072
8073 @opindex fno-builtin
8074 GCC includes built-in versions of many of the functions in the standard
8075 C library. The versions prefixed with @code{__builtin_} are always
8076 treated as having the same meaning as the C library function even if you
8077 specify the @option{-fno-builtin} option. (@pxref{C Dialect Options})
8078 Many of these functions are only optimized in certain cases; if they are
8079 not optimized in a particular case, a call to the library function is
8080 emitted.
8081
8082 @opindex ansi
8083 @opindex std
8084 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
8085 @option{-std=c99} or @option{-std=c11}), the functions
8086 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
8087 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
8088 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
8089 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
8090 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
8091 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
8092 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
8093 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
8094 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
8095 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
8096 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
8097 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
8098 @code{signbitd64}, @code{signbitd128}, @code{significandf},
8099 @code{significandl}, @code{significand}, @code{sincosf},
8100 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
8101 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
8102 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
8103 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
8104 @code{yn}
8105 may be handled as built-in functions.
8106 All these functions have corresponding versions
8107 prefixed with @code{__builtin_}, which may be used even in strict C90
8108 mode.
8109
8110 The ISO C99 functions
8111 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
8112 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
8113 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
8114 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
8115 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
8116 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
8117 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
8118 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
8119 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
8120 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
8121 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
8122 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
8123 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
8124 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
8125 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
8126 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
8127 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
8128 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
8129 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
8130 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
8131 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
8132 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
8133 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
8134 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
8135 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
8136 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
8137 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
8138 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
8139 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
8140 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
8141 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
8142 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
8143 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
8144 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
8145 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
8146 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
8147 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
8148 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
8149 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
8150 are handled as built-in functions
8151 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8152
8153 There are also built-in versions of the ISO C99 functions
8154 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
8155 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
8156 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
8157 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
8158 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
8159 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
8160 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
8161 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
8162 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
8163 that are recognized in any mode since ISO C90 reserves these names for
8164 the purpose to which ISO C99 puts them. All these functions have
8165 corresponding versions prefixed with @code{__builtin_}.
8166
8167 The ISO C94 functions
8168 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
8169 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
8170 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
8171 @code{towupper}
8172 are handled as built-in functions
8173 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
8174
8175 The ISO C90 functions
8176 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
8177 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
8178 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
8179 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
8180 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
8181 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
8182 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
8183 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
8184 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
8185 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
8186 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
8187 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
8188 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
8189 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
8190 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
8191 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
8192 are all recognized as built-in functions unless
8193 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
8194 is specified for an individual function). All of these functions have
8195 corresponding versions prefixed with @code{__builtin_}.
8196
8197 GCC provides built-in versions of the ISO C99 floating-point comparison
8198 macros that avoid raising exceptions for unordered operands. They have
8199 the same names as the standard macros ( @code{isgreater},
8200 @code{isgreaterequal}, @code{isless}, @code{islessequal},
8201 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
8202 prefixed. We intend for a library implementor to be able to simply
8203 @code{#define} each standard macro to its built-in equivalent.
8204 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
8205 @code{isinf_sign} and @code{isnormal} built-ins used with
8206 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
8207 built-in functions appear both with and without the @code{__builtin_} prefix.
8208
8209 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
8210
8211 You can use the built-in function @code{__builtin_types_compatible_p} to
8212 determine whether two types are the same.
8213
8214 This built-in function returns 1 if the unqualified versions of the
8215 types @var{type1} and @var{type2} (which are types, not expressions) are
8216 compatible, 0 otherwise. The result of this built-in function can be
8217 used in integer constant expressions.
8218
8219 This built-in function ignores top level qualifiers (e.g., @code{const},
8220 @code{volatile}). For example, @code{int} is equivalent to @code{const
8221 int}.
8222
8223 The type @code{int[]} and @code{int[5]} are compatible. On the other
8224 hand, @code{int} and @code{char *} are not compatible, even if the size
8225 of their types, on the particular architecture are the same. Also, the
8226 amount of pointer indirection is taken into account when determining
8227 similarity. Consequently, @code{short *} is not similar to
8228 @code{short **}. Furthermore, two types that are typedefed are
8229 considered compatible if their underlying types are compatible.
8230
8231 An @code{enum} type is not considered to be compatible with another
8232 @code{enum} type even if both are compatible with the same integer
8233 type; this is what the C standard specifies.
8234 For example, @code{enum @{foo, bar@}} is not similar to
8235 @code{enum @{hot, dog@}}.
8236
8237 You typically use this function in code whose execution varies
8238 depending on the arguments' types. For example:
8239
8240 @smallexample
8241 #define foo(x) \
8242 (@{ \
8243 typeof (x) tmp = (x); \
8244 if (__builtin_types_compatible_p (typeof (x), long double)) \
8245 tmp = foo_long_double (tmp); \
8246 else if (__builtin_types_compatible_p (typeof (x), double)) \
8247 tmp = foo_double (tmp); \
8248 else if (__builtin_types_compatible_p (typeof (x), float)) \
8249 tmp = foo_float (tmp); \
8250 else \
8251 abort (); \
8252 tmp; \
8253 @})
8254 @end smallexample
8255
8256 @emph{Note:} This construct is only available for C@.
8257
8258 @end deftypefn
8259
8260 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
8261
8262 You can use the built-in function @code{__builtin_choose_expr} to
8263 evaluate code depending on the value of a constant expression. This
8264 built-in function returns @var{exp1} if @var{const_exp}, which is an
8265 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
8266
8267 This built-in function is analogous to the @samp{? :} operator in C,
8268 except that the expression returned has its type unaltered by promotion
8269 rules. Also, the built-in function does not evaluate the expression
8270 that is not chosen. For example, if @var{const_exp} evaluates to true,
8271 @var{exp2} is not evaluated even if it has side-effects.
8272
8273 This built-in function can return an lvalue if the chosen argument is an
8274 lvalue.
8275
8276 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
8277 type. Similarly, if @var{exp2} is returned, its return type is the same
8278 as @var{exp2}.
8279
8280 Example:
8281
8282 @smallexample
8283 #define foo(x) \
8284 __builtin_choose_expr ( \
8285 __builtin_types_compatible_p (typeof (x), double), \
8286 foo_double (x), \
8287 __builtin_choose_expr ( \
8288 __builtin_types_compatible_p (typeof (x), float), \
8289 foo_float (x), \
8290 /* @r{The void expression results in a compile-time error} \
8291 @r{when assigning the result to something.} */ \
8292 (void)0))
8293 @end smallexample
8294
8295 @emph{Note:} This construct is only available for C@. Furthermore, the
8296 unused expression (@var{exp1} or @var{exp2} depending on the value of
8297 @var{const_exp}) may still generate syntax errors. This may change in
8298 future revisions.
8299
8300 @end deftypefn
8301
8302 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
8303
8304 The built-in function @code{__builtin_complex} is provided for use in
8305 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
8306 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
8307 real binary floating-point type, and the result has the corresponding
8308 complex type with real and imaginary parts @var{real} and @var{imag}.
8309 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
8310 infinities, NaNs and negative zeros are involved.
8311
8312 @end deftypefn
8313
8314 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
8315 You can use the built-in function @code{__builtin_constant_p} to
8316 determine if a value is known to be constant at compile time and hence
8317 that GCC can perform constant-folding on expressions involving that
8318 value. The argument of the function is the value to test. The function
8319 returns the integer 1 if the argument is known to be a compile-time
8320 constant and 0 if it is not known to be a compile-time constant. A
8321 return of 0 does not indicate that the value is @emph{not} a constant,
8322 but merely that GCC cannot prove it is a constant with the specified
8323 value of the @option{-O} option.
8324
8325 You typically use this function in an embedded application where
8326 memory is a critical resource. If you have some complex calculation,
8327 you may want it to be folded if it involves constants, but need to call
8328 a function if it does not. For example:
8329
8330 @smallexample
8331 #define Scale_Value(X) \
8332 (__builtin_constant_p (X) \
8333 ? ((X) * SCALE + OFFSET) : Scale (X))
8334 @end smallexample
8335
8336 You may use this built-in function in either a macro or an inline
8337 function. However, if you use it in an inlined function and pass an
8338 argument of the function as the argument to the built-in, GCC
8339 never returns 1 when you call the inline function with a string constant
8340 or compound literal (@pxref{Compound Literals}) and does not return 1
8341 when you pass a constant numeric value to the inline function unless you
8342 specify the @option{-O} option.
8343
8344 You may also use @code{__builtin_constant_p} in initializers for static
8345 data. For instance, you can write
8346
8347 @smallexample
8348 static const int table[] = @{
8349 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
8350 /* @r{@dots{}} */
8351 @};
8352 @end smallexample
8353
8354 @noindent
8355 This is an acceptable initializer even if @var{EXPRESSION} is not a
8356 constant expression, including the case where
8357 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
8358 folded to a constant but @var{EXPRESSION} contains operands that are
8359 not otherwise permitted in a static initializer (for example,
8360 @code{0 && foo ()}). GCC must be more conservative about evaluating the
8361 built-in in this case, because it has no opportunity to perform
8362 optimization.
8363
8364 Previous versions of GCC did not accept this built-in in data
8365 initializers. The earliest version where it is completely safe is
8366 3.0.1.
8367 @end deftypefn
8368
8369 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
8370 @opindex fprofile-arcs
8371 You may use @code{__builtin_expect} to provide the compiler with
8372 branch prediction information. In general, you should prefer to
8373 use actual profile feedback for this (@option{-fprofile-arcs}), as
8374 programmers are notoriously bad at predicting how their programs
8375 actually perform. However, there are applications in which this
8376 data is hard to collect.
8377
8378 The return value is the value of @var{exp}, which should be an integral
8379 expression. The semantics of the built-in are that it is expected that
8380 @var{exp} == @var{c}. For example:
8381
8382 @smallexample
8383 if (__builtin_expect (x, 0))
8384 foo ();
8385 @end smallexample
8386
8387 @noindent
8388 indicates that we do not expect to call @code{foo}, since
8389 we expect @code{x} to be zero. Since you are limited to integral
8390 expressions for @var{exp}, you should use constructions such as
8391
8392 @smallexample
8393 if (__builtin_expect (ptr != NULL, 1))
8394 foo (*ptr);
8395 @end smallexample
8396
8397 @noindent
8398 when testing pointer or floating-point values.
8399 @end deftypefn
8400
8401 @deftypefn {Built-in Function} void __builtin_trap (void)
8402 This function causes the program to exit abnormally. GCC implements
8403 this function by using a target-dependent mechanism (such as
8404 intentionally executing an illegal instruction) or by calling
8405 @code{abort}. The mechanism used may vary from release to release so
8406 you should not rely on any particular implementation.
8407 @end deftypefn
8408
8409 @deftypefn {Built-in Function} void __builtin_unreachable (void)
8410 If control flow reaches the point of the @code{__builtin_unreachable},
8411 the program is undefined. It is useful in situations where the
8412 compiler cannot deduce the unreachability of the code.
8413
8414 One such case is immediately following an @code{asm} statement that
8415 either never terminates, or one that transfers control elsewhere
8416 and never returns. In this example, without the
8417 @code{__builtin_unreachable}, GCC issues a warning that control
8418 reaches the end of a non-void function. It also generates code
8419 to return after the @code{asm}.
8420
8421 @smallexample
8422 int f (int c, int v)
8423 @{
8424 if (c)
8425 @{
8426 return v;
8427 @}
8428 else
8429 @{
8430 asm("jmp error_handler");
8431 __builtin_unreachable ();
8432 @}
8433 @}
8434 @end smallexample
8435
8436 @noindent
8437 Because the @code{asm} statement unconditionally transfers control out
8438 of the function, control never reaches the end of the function
8439 body. The @code{__builtin_unreachable} is in fact unreachable and
8440 communicates this fact to the compiler.
8441
8442 Another use for @code{__builtin_unreachable} is following a call a
8443 function that never returns but that is not declared
8444 @code{__attribute__((noreturn))}, as in this example:
8445
8446 @smallexample
8447 void function_that_never_returns (void);
8448
8449 int g (int c)
8450 @{
8451 if (c)
8452 @{
8453 return 1;
8454 @}
8455 else
8456 @{
8457 function_that_never_returns ();
8458 __builtin_unreachable ();
8459 @}
8460 @}
8461 @end smallexample
8462
8463 @end deftypefn
8464
8465 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
8466 This function returns its first argument, and allows the compiler
8467 to assume that the returned pointer is at least @var{align} bytes
8468 aligned. This built-in can have either two or three arguments,
8469 if it has three, the third argument should have integer type, and
8470 if it is nonzero means misalignment offset. For example:
8471
8472 @smallexample
8473 void *x = __builtin_assume_aligned (arg, 16);
8474 @end smallexample
8475
8476 @noindent
8477 means that the compiler can assume @code{x}, set to @code{arg}, is at least
8478 16-byte aligned, while:
8479
8480 @smallexample
8481 void *x = __builtin_assume_aligned (arg, 32, 8);
8482 @end smallexample
8483
8484 @noindent
8485 means that the compiler can assume for @code{x}, set to @code{arg}, that
8486 @code{(char *) x - 8} is 32-byte aligned.
8487 @end deftypefn
8488
8489 @deftypefn {Built-in Function} int __builtin_LINE ()
8490 This function is the equivalent to the preprocessor @code{__LINE__}
8491 macro and returns the line number of the invocation of the built-in.
8492 @end deftypefn
8493
8494 @deftypefn {Built-in Function} int __builtin_FUNCTION ()
8495 This function is the equivalent to the preprocessor @code{__FUNCTION__}
8496 macro and returns the function name the invocation of the built-in is in.
8497 @end deftypefn
8498
8499 @deftypefn {Built-in Function} int __builtin_FILE ()
8500 This function is the equivalent to the preprocessor @code{__FILE__}
8501 macro and returns the file name the invocation of the built-in is in.
8502 @end deftypefn
8503
8504 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
8505 This function is used to flush the processor's instruction cache for
8506 the region of memory between @var{begin} inclusive and @var{end}
8507 exclusive. Some targets require that the instruction cache be
8508 flushed, after modifying memory containing code, in order to obtain
8509 deterministic behavior.
8510
8511 If the target does not require instruction cache flushes,
8512 @code{__builtin___clear_cache} has no effect. Otherwise either
8513 instructions are emitted in-line to clear the instruction cache or a
8514 call to the @code{__clear_cache} function in libgcc is made.
8515 @end deftypefn
8516
8517 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
8518 This function is used to minimize cache-miss latency by moving data into
8519 a cache before it is accessed.
8520 You can insert calls to @code{__builtin_prefetch} into code for which
8521 you know addresses of data in memory that is likely to be accessed soon.
8522 If the target supports them, data prefetch instructions are generated.
8523 If the prefetch is done early enough before the access then the data will
8524 be in the cache by the time it is accessed.
8525
8526 The value of @var{addr} is the address of the memory to prefetch.
8527 There are two optional arguments, @var{rw} and @var{locality}.
8528 The value of @var{rw} is a compile-time constant one or zero; one
8529 means that the prefetch is preparing for a write to the memory address
8530 and zero, the default, means that the prefetch is preparing for a read.
8531 The value @var{locality} must be a compile-time constant integer between
8532 zero and three. A value of zero means that the data has no temporal
8533 locality, so it need not be left in the cache after the access. A value
8534 of three means that the data has a high degree of temporal locality and
8535 should be left in all levels of cache possible. Values of one and two
8536 mean, respectively, a low or moderate degree of temporal locality. The
8537 default is three.
8538
8539 @smallexample
8540 for (i = 0; i < n; i++)
8541 @{
8542 a[i] = a[i] + b[i];
8543 __builtin_prefetch (&a[i+j], 1, 1);
8544 __builtin_prefetch (&b[i+j], 0, 1);
8545 /* @r{@dots{}} */
8546 @}
8547 @end smallexample
8548
8549 Data prefetch does not generate faults if @var{addr} is invalid, but
8550 the address expression itself must be valid. For example, a prefetch
8551 of @code{p->next} does not fault if @code{p->next} is not a valid
8552 address, but evaluation faults if @code{p} is not a valid address.
8553
8554 If the target does not support data prefetch, the address expression
8555 is evaluated if it includes side effects but no other code is generated
8556 and GCC does not issue a warning.
8557 @end deftypefn
8558
8559 @deftypefn {Built-in Function} double __builtin_huge_val (void)
8560 Returns a positive infinity, if supported by the floating-point format,
8561 else @code{DBL_MAX}. This function is suitable for implementing the
8562 ISO C macro @code{HUGE_VAL}.
8563 @end deftypefn
8564
8565 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
8566 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
8567 @end deftypefn
8568
8569 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
8570 Similar to @code{__builtin_huge_val}, except the return
8571 type is @code{long double}.
8572 @end deftypefn
8573
8574 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
8575 This built-in implements the C99 fpclassify functionality. The first
8576 five int arguments should be the target library's notion of the
8577 possible FP classes and are used for return values. They must be
8578 constant values and they must appear in this order: @code{FP_NAN},
8579 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
8580 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
8581 to classify. GCC treats the last argument as type-generic, which
8582 means it does not do default promotion from float to double.
8583 @end deftypefn
8584
8585 @deftypefn {Built-in Function} double __builtin_inf (void)
8586 Similar to @code{__builtin_huge_val}, except a warning is generated
8587 if the target floating-point format does not support infinities.
8588 @end deftypefn
8589
8590 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
8591 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
8592 @end deftypefn
8593
8594 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
8595 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
8596 @end deftypefn
8597
8598 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
8599 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
8600 @end deftypefn
8601
8602 @deftypefn {Built-in Function} float __builtin_inff (void)
8603 Similar to @code{__builtin_inf}, except the return type is @code{float}.
8604 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
8605 @end deftypefn
8606
8607 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
8608 Similar to @code{__builtin_inf}, except the return
8609 type is @code{long double}.
8610 @end deftypefn
8611
8612 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
8613 Similar to @code{isinf}, except the return value is negative for
8614 an argument of @code{-Inf}. Note while the parameter list is an
8615 ellipsis, this function only accepts exactly one floating-point
8616 argument. GCC treats this parameter as type-generic, which means it
8617 does not do default promotion from float to double.
8618 @end deftypefn
8619
8620 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
8621 This is an implementation of the ISO C99 function @code{nan}.
8622
8623 Since ISO C99 defines this function in terms of @code{strtod}, which we
8624 do not implement, a description of the parsing is in order. The string
8625 is parsed as by @code{strtol}; that is, the base is recognized by
8626 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
8627 in the significand such that the least significant bit of the number
8628 is at the least significant bit of the significand. The number is
8629 truncated to fit the significand field provided. The significand is
8630 forced to be a quiet NaN@.
8631
8632 This function, if given a string literal all of which would have been
8633 consumed by @code{strtol}, is evaluated early enough that it is considered a
8634 compile-time constant.
8635 @end deftypefn
8636
8637 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
8638 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
8639 @end deftypefn
8640
8641 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
8642 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
8643 @end deftypefn
8644
8645 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
8646 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
8647 @end deftypefn
8648
8649 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
8650 Similar to @code{__builtin_nan}, except the return type is @code{float}.
8651 @end deftypefn
8652
8653 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
8654 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
8655 @end deftypefn
8656
8657 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
8658 Similar to @code{__builtin_nan}, except the significand is forced
8659 to be a signaling NaN@. The @code{nans} function is proposed by
8660 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
8661 @end deftypefn
8662
8663 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
8664 Similar to @code{__builtin_nans}, except the return type is @code{float}.
8665 @end deftypefn
8666
8667 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
8668 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
8669 @end deftypefn
8670
8671 @deftypefn {Built-in Function} int __builtin_ffs (unsigned int x)
8672 Returns one plus the index of the least significant 1-bit of @var{x}, or
8673 if @var{x} is zero, returns zero.
8674 @end deftypefn
8675
8676 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
8677 Returns the number of leading 0-bits in @var{x}, starting at the most
8678 significant bit position. If @var{x} is 0, the result is undefined.
8679 @end deftypefn
8680
8681 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
8682 Returns the number of trailing 0-bits in @var{x}, starting at the least
8683 significant bit position. If @var{x} is 0, the result is undefined.
8684 @end deftypefn
8685
8686 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
8687 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
8688 number of bits following the most significant bit that are identical
8689 to it. There are no special cases for 0 or other values.
8690 @end deftypefn
8691
8692 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
8693 Returns the number of 1-bits in @var{x}.
8694 @end deftypefn
8695
8696 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
8697 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
8698 modulo 2.
8699 @end deftypefn
8700
8701 @deftypefn {Built-in Function} int __builtin_ffsl (unsigned long)
8702 Similar to @code{__builtin_ffs}, except the argument type is
8703 @code{unsigned long}.
8704 @end deftypefn
8705
8706 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
8707 Similar to @code{__builtin_clz}, except the argument type is
8708 @code{unsigned long}.
8709 @end deftypefn
8710
8711 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
8712 Similar to @code{__builtin_ctz}, except the argument type is
8713 @code{unsigned long}.
8714 @end deftypefn
8715
8716 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
8717 Similar to @code{__builtin_clrsb}, except the argument type is
8718 @code{long}.
8719 @end deftypefn
8720
8721 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
8722 Similar to @code{__builtin_popcount}, except the argument type is
8723 @code{unsigned long}.
8724 @end deftypefn
8725
8726 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
8727 Similar to @code{__builtin_parity}, except the argument type is
8728 @code{unsigned long}.
8729 @end deftypefn
8730
8731 @deftypefn {Built-in Function} int __builtin_ffsll (unsigned long long)
8732 Similar to @code{__builtin_ffs}, except the argument type is
8733 @code{unsigned long long}.
8734 @end deftypefn
8735
8736 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
8737 Similar to @code{__builtin_clz}, except the argument type is
8738 @code{unsigned long long}.
8739 @end deftypefn
8740
8741 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
8742 Similar to @code{__builtin_ctz}, except the argument type is
8743 @code{unsigned long long}.
8744 @end deftypefn
8745
8746 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
8747 Similar to @code{__builtin_clrsb}, except the argument type is
8748 @code{long long}.
8749 @end deftypefn
8750
8751 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
8752 Similar to @code{__builtin_popcount}, except the argument type is
8753 @code{unsigned long long}.
8754 @end deftypefn
8755
8756 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
8757 Similar to @code{__builtin_parity}, except the argument type is
8758 @code{unsigned long long}.
8759 @end deftypefn
8760
8761 @deftypefn {Built-in Function} double __builtin_powi (double, int)
8762 Returns the first argument raised to the power of the second. Unlike the
8763 @code{pow} function no guarantees about precision and rounding are made.
8764 @end deftypefn
8765
8766 @deftypefn {Built-in Function} float __builtin_powif (float, int)
8767 Similar to @code{__builtin_powi}, except the argument and return types
8768 are @code{float}.
8769 @end deftypefn
8770
8771 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
8772 Similar to @code{__builtin_powi}, except the argument and return types
8773 are @code{long double}.
8774 @end deftypefn
8775
8776 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
8777 Returns @var{x} with the order of the bytes reversed; for example,
8778 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
8779 exactly 8 bits.
8780 @end deftypefn
8781
8782 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
8783 Similar to @code{__builtin_bswap16}, except the argument and return types
8784 are 32 bit.
8785 @end deftypefn
8786
8787 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
8788 Similar to @code{__builtin_bswap32}, except the argument and return types
8789 are 64 bit.
8790 @end deftypefn
8791
8792 @node Cilk Plus Builtins
8793 @section Cilk Plus C/C++ language extension Built-in Functions.
8794
8795 GCC provides support for the following built-in reduction funtions if Cilk Plus
8796 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
8797
8798 @itemize @bullet
8799 @item __sec_implicit_index
8800 @item __sec_reduce
8801 @item __sec_reduce_add
8802 @item __sec_reduce_all_nonzero
8803 @item __sec_reduce_all_zero
8804 @item __sec_reduce_any_nonzero
8805 @item __sec_reduce_any_zero
8806 @item __sec_reduce_max
8807 @item __sec_reduce_min
8808 @item __sec_reduce_max_ind
8809 @item __sec_reduce_min_ind
8810 @item __sec_reduce_mul
8811 @item __sec_reduce_mutating
8812 @end itemize
8813
8814 Further details and examples about these built-in functions are described
8815 in the Cilk Plus language manual which can be found at
8816 @uref{http://www.cilkplus.org}.
8817
8818 @node Target Builtins
8819 @section Built-in Functions Specific to Particular Target Machines
8820
8821 On some target machines, GCC supports many built-in functions specific
8822 to those machines. Generally these generate calls to specific machine
8823 instructions, but allow the compiler to schedule those calls.
8824
8825 @menu
8826 * Alpha Built-in Functions::
8827 * ARM iWMMXt Built-in Functions::
8828 * ARM NEON Intrinsics::
8829 * AVR Built-in Functions::
8830 * Blackfin Built-in Functions::
8831 * FR-V Built-in Functions::
8832 * X86 Built-in Functions::
8833 * X86 transactional memory intrinsics::
8834 * MIPS DSP Built-in Functions::
8835 * MIPS Paired-Single Support::
8836 * MIPS Loongson Built-in Functions::
8837 * Other MIPS Built-in Functions::
8838 * picoChip Built-in Functions::
8839 * PowerPC Built-in Functions::
8840 * PowerPC AltiVec/VSX Built-in Functions::
8841 * RX Built-in Functions::
8842 * SH Built-in Functions::
8843 * SPARC VIS Built-in Functions::
8844 * SPU Built-in Functions::
8845 * TI C6X Built-in Functions::
8846 * TILE-Gx Built-in Functions::
8847 * TILEPro Built-in Functions::
8848 @end menu
8849
8850 @node Alpha Built-in Functions
8851 @subsection Alpha Built-in Functions
8852
8853 These built-in functions are available for the Alpha family of
8854 processors, depending on the command-line switches used.
8855
8856 The following built-in functions are always available. They
8857 all generate the machine instruction that is part of the name.
8858
8859 @smallexample
8860 long __builtin_alpha_implver (void)
8861 long __builtin_alpha_rpcc (void)
8862 long __builtin_alpha_amask (long)
8863 long __builtin_alpha_cmpbge (long, long)
8864 long __builtin_alpha_extbl (long, long)
8865 long __builtin_alpha_extwl (long, long)
8866 long __builtin_alpha_extll (long, long)
8867 long __builtin_alpha_extql (long, long)
8868 long __builtin_alpha_extwh (long, long)
8869 long __builtin_alpha_extlh (long, long)
8870 long __builtin_alpha_extqh (long, long)
8871 long __builtin_alpha_insbl (long, long)
8872 long __builtin_alpha_inswl (long, long)
8873 long __builtin_alpha_insll (long, long)
8874 long __builtin_alpha_insql (long, long)
8875 long __builtin_alpha_inswh (long, long)
8876 long __builtin_alpha_inslh (long, long)
8877 long __builtin_alpha_insqh (long, long)
8878 long __builtin_alpha_mskbl (long, long)
8879 long __builtin_alpha_mskwl (long, long)
8880 long __builtin_alpha_mskll (long, long)
8881 long __builtin_alpha_mskql (long, long)
8882 long __builtin_alpha_mskwh (long, long)
8883 long __builtin_alpha_msklh (long, long)
8884 long __builtin_alpha_mskqh (long, long)
8885 long __builtin_alpha_umulh (long, long)
8886 long __builtin_alpha_zap (long, long)
8887 long __builtin_alpha_zapnot (long, long)
8888 @end smallexample
8889
8890 The following built-in functions are always with @option{-mmax}
8891 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
8892 later. They all generate the machine instruction that is part
8893 of the name.
8894
8895 @smallexample
8896 long __builtin_alpha_pklb (long)
8897 long __builtin_alpha_pkwb (long)
8898 long __builtin_alpha_unpkbl (long)
8899 long __builtin_alpha_unpkbw (long)
8900 long __builtin_alpha_minub8 (long, long)
8901 long __builtin_alpha_minsb8 (long, long)
8902 long __builtin_alpha_minuw4 (long, long)
8903 long __builtin_alpha_minsw4 (long, long)
8904 long __builtin_alpha_maxub8 (long, long)
8905 long __builtin_alpha_maxsb8 (long, long)
8906 long __builtin_alpha_maxuw4 (long, long)
8907 long __builtin_alpha_maxsw4 (long, long)
8908 long __builtin_alpha_perr (long, long)
8909 @end smallexample
8910
8911 The following built-in functions are always with @option{-mcix}
8912 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
8913 later. They all generate the machine instruction that is part
8914 of the name.
8915
8916 @smallexample
8917 long __builtin_alpha_cttz (long)
8918 long __builtin_alpha_ctlz (long)
8919 long __builtin_alpha_ctpop (long)
8920 @end smallexample
8921
8922 The following built-in functions are available on systems that use the OSF/1
8923 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
8924 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
8925 @code{rdval} and @code{wrval}.
8926
8927 @smallexample
8928 void *__builtin_thread_pointer (void)
8929 void __builtin_set_thread_pointer (void *)
8930 @end smallexample
8931
8932 @node ARM iWMMXt Built-in Functions
8933 @subsection ARM iWMMXt Built-in Functions
8934
8935 These built-in functions are available for the ARM family of
8936 processors when the @option{-mcpu=iwmmxt} switch is used:
8937
8938 @smallexample
8939 typedef int v2si __attribute__ ((vector_size (8)));
8940 typedef short v4hi __attribute__ ((vector_size (8)));
8941 typedef char v8qi __attribute__ ((vector_size (8)));
8942
8943 int __builtin_arm_getwcgr0 (void)
8944 void __builtin_arm_setwcgr0 (int)
8945 int __builtin_arm_getwcgr1 (void)
8946 void __builtin_arm_setwcgr1 (int)
8947 int __builtin_arm_getwcgr2 (void)
8948 void __builtin_arm_setwcgr2 (int)
8949 int __builtin_arm_getwcgr3 (void)
8950 void __builtin_arm_setwcgr3 (int)
8951 int __builtin_arm_textrmsb (v8qi, int)
8952 int __builtin_arm_textrmsh (v4hi, int)
8953 int __builtin_arm_textrmsw (v2si, int)
8954 int __builtin_arm_textrmub (v8qi, int)
8955 int __builtin_arm_textrmuh (v4hi, int)
8956 int __builtin_arm_textrmuw (v2si, int)
8957 v8qi __builtin_arm_tinsrb (v8qi, int, int)
8958 v4hi __builtin_arm_tinsrh (v4hi, int, int)
8959 v2si __builtin_arm_tinsrw (v2si, int, int)
8960 long long __builtin_arm_tmia (long long, int, int)
8961 long long __builtin_arm_tmiabb (long long, int, int)
8962 long long __builtin_arm_tmiabt (long long, int, int)
8963 long long __builtin_arm_tmiaph (long long, int, int)
8964 long long __builtin_arm_tmiatb (long long, int, int)
8965 long long __builtin_arm_tmiatt (long long, int, int)
8966 int __builtin_arm_tmovmskb (v8qi)
8967 int __builtin_arm_tmovmskh (v4hi)
8968 int __builtin_arm_tmovmskw (v2si)
8969 long long __builtin_arm_waccb (v8qi)
8970 long long __builtin_arm_wacch (v4hi)
8971 long long __builtin_arm_waccw (v2si)
8972 v8qi __builtin_arm_waddb (v8qi, v8qi)
8973 v8qi __builtin_arm_waddbss (v8qi, v8qi)
8974 v8qi __builtin_arm_waddbus (v8qi, v8qi)
8975 v4hi __builtin_arm_waddh (v4hi, v4hi)
8976 v4hi __builtin_arm_waddhss (v4hi, v4hi)
8977 v4hi __builtin_arm_waddhus (v4hi, v4hi)
8978 v2si __builtin_arm_waddw (v2si, v2si)
8979 v2si __builtin_arm_waddwss (v2si, v2si)
8980 v2si __builtin_arm_waddwus (v2si, v2si)
8981 v8qi __builtin_arm_walign (v8qi, v8qi, int)
8982 long long __builtin_arm_wand(long long, long long)
8983 long long __builtin_arm_wandn (long long, long long)
8984 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
8985 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
8986 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
8987 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
8988 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
8989 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
8990 v2si __builtin_arm_wcmpeqw (v2si, v2si)
8991 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
8992 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
8993 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
8994 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
8995 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
8996 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
8997 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
8998 long long __builtin_arm_wmacsz (v4hi, v4hi)
8999 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
9000 long long __builtin_arm_wmacuz (v4hi, v4hi)
9001 v4hi __builtin_arm_wmadds (v4hi, v4hi)
9002 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
9003 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
9004 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
9005 v2si __builtin_arm_wmaxsw (v2si, v2si)
9006 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
9007 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
9008 v2si __builtin_arm_wmaxuw (v2si, v2si)
9009 v8qi __builtin_arm_wminsb (v8qi, v8qi)
9010 v4hi __builtin_arm_wminsh (v4hi, v4hi)
9011 v2si __builtin_arm_wminsw (v2si, v2si)
9012 v8qi __builtin_arm_wminub (v8qi, v8qi)
9013 v4hi __builtin_arm_wminuh (v4hi, v4hi)
9014 v2si __builtin_arm_wminuw (v2si, v2si)
9015 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
9016 v4hi __builtin_arm_wmulul (v4hi, v4hi)
9017 v4hi __builtin_arm_wmulum (v4hi, v4hi)
9018 long long __builtin_arm_wor (long long, long long)
9019 v2si __builtin_arm_wpackdss (long long, long long)
9020 v2si __builtin_arm_wpackdus (long long, long long)
9021 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
9022 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
9023 v4hi __builtin_arm_wpackwss (v2si, v2si)
9024 v4hi __builtin_arm_wpackwus (v2si, v2si)
9025 long long __builtin_arm_wrord (long long, long long)
9026 long long __builtin_arm_wrordi (long long, int)
9027 v4hi __builtin_arm_wrorh (v4hi, long long)
9028 v4hi __builtin_arm_wrorhi (v4hi, int)
9029 v2si __builtin_arm_wrorw (v2si, long long)
9030 v2si __builtin_arm_wrorwi (v2si, int)
9031 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
9032 v2si __builtin_arm_wsadbz (v8qi, v8qi)
9033 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
9034 v2si __builtin_arm_wsadhz (v4hi, v4hi)
9035 v4hi __builtin_arm_wshufh (v4hi, int)
9036 long long __builtin_arm_wslld (long long, long long)
9037 long long __builtin_arm_wslldi (long long, int)
9038 v4hi __builtin_arm_wsllh (v4hi, long long)
9039 v4hi __builtin_arm_wsllhi (v4hi, int)
9040 v2si __builtin_arm_wsllw (v2si, long long)
9041 v2si __builtin_arm_wsllwi (v2si, int)
9042 long long __builtin_arm_wsrad (long long, long long)
9043 long long __builtin_arm_wsradi (long long, int)
9044 v4hi __builtin_arm_wsrah (v4hi, long long)
9045 v4hi __builtin_arm_wsrahi (v4hi, int)
9046 v2si __builtin_arm_wsraw (v2si, long long)
9047 v2si __builtin_arm_wsrawi (v2si, int)
9048 long long __builtin_arm_wsrld (long long, long long)
9049 long long __builtin_arm_wsrldi (long long, int)
9050 v4hi __builtin_arm_wsrlh (v4hi, long long)
9051 v4hi __builtin_arm_wsrlhi (v4hi, int)
9052 v2si __builtin_arm_wsrlw (v2si, long long)
9053 v2si __builtin_arm_wsrlwi (v2si, int)
9054 v8qi __builtin_arm_wsubb (v8qi, v8qi)
9055 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
9056 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
9057 v4hi __builtin_arm_wsubh (v4hi, v4hi)
9058 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
9059 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
9060 v2si __builtin_arm_wsubw (v2si, v2si)
9061 v2si __builtin_arm_wsubwss (v2si, v2si)
9062 v2si __builtin_arm_wsubwus (v2si, v2si)
9063 v4hi __builtin_arm_wunpckehsb (v8qi)
9064 v2si __builtin_arm_wunpckehsh (v4hi)
9065 long long __builtin_arm_wunpckehsw (v2si)
9066 v4hi __builtin_arm_wunpckehub (v8qi)
9067 v2si __builtin_arm_wunpckehuh (v4hi)
9068 long long __builtin_arm_wunpckehuw (v2si)
9069 v4hi __builtin_arm_wunpckelsb (v8qi)
9070 v2si __builtin_arm_wunpckelsh (v4hi)
9071 long long __builtin_arm_wunpckelsw (v2si)
9072 v4hi __builtin_arm_wunpckelub (v8qi)
9073 v2si __builtin_arm_wunpckeluh (v4hi)
9074 long long __builtin_arm_wunpckeluw (v2si)
9075 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
9076 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
9077 v2si __builtin_arm_wunpckihw (v2si, v2si)
9078 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
9079 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
9080 v2si __builtin_arm_wunpckilw (v2si, v2si)
9081 long long __builtin_arm_wxor (long long, long long)
9082 long long __builtin_arm_wzero ()
9083 @end smallexample
9084
9085 @node ARM NEON Intrinsics
9086 @subsection ARM NEON Intrinsics
9087
9088 These built-in intrinsics for the ARM Advanced SIMD extension are available
9089 when the @option{-mfpu=neon} switch is used:
9090
9091 @include arm-neon-intrinsics.texi
9092
9093 @node AVR Built-in Functions
9094 @subsection AVR Built-in Functions
9095
9096 For each built-in function for AVR, there is an equally named,
9097 uppercase built-in macro defined. That way users can easily query if
9098 or if not a specific built-in is implemented or not. For example, if
9099 @code{__builtin_avr_nop} is available the macro
9100 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
9101
9102 The following built-in functions map to the respective machine
9103 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
9104 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
9105 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
9106 as library call if no hardware multiplier is available.
9107
9108 @smallexample
9109 void __builtin_avr_nop (void)
9110 void __builtin_avr_sei (void)
9111 void __builtin_avr_cli (void)
9112 void __builtin_avr_sleep (void)
9113 void __builtin_avr_wdr (void)
9114 unsigned char __builtin_avr_swap (unsigned char)
9115 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
9116 int __builtin_avr_fmuls (char, char)
9117 int __builtin_avr_fmulsu (char, unsigned char)
9118 @end smallexample
9119
9120 In order to delay execution for a specific number of cycles, GCC
9121 implements
9122 @smallexample
9123 void __builtin_avr_delay_cycles (unsigned long ticks)
9124 @end smallexample
9125
9126 @noindent
9127 @code{ticks} is the number of ticks to delay execution. Note that this
9128 built-in does not take into account the effect of interrupts that
9129 might increase delay time. @code{ticks} must be a compile-time
9130 integer constant; delays with a variable number of cycles are not supported.
9131
9132 @smallexample
9133 char __builtin_avr_flash_segment (const __memx void*)
9134 @end smallexample
9135
9136 @noindent
9137 This built-in takes a byte address to the 24-bit
9138 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
9139 the number of the flash segment (the 64 KiB chunk) where the address
9140 points to. Counting starts at @code{0}.
9141 If the address does not point to flash memory, return @code{-1}.
9142
9143 @smallexample
9144 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
9145 @end smallexample
9146
9147 @noindent
9148 Insert bits from @var{bits} into @var{val} and return the resulting
9149 value. The nibbles of @var{map} determine how the insertion is
9150 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
9151 @enumerate
9152 @item If @var{X} is @code{0xf},
9153 then the @var{n}-th bit of @var{val} is returned unaltered.
9154
9155 @item If X is in the range 0@dots{}7,
9156 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
9157
9158 @item If X is in the range 8@dots{}@code{0xe},
9159 then the @var{n}-th result bit is undefined.
9160 @end enumerate
9161
9162 @noindent
9163 One typical use case for this built-in is adjusting input and
9164 output values to non-contiguous port layouts. Some examples:
9165
9166 @smallexample
9167 // same as val, bits is unused
9168 __builtin_avr_insert_bits (0xffffffff, bits, val)
9169 @end smallexample
9170
9171 @smallexample
9172 // same as bits, val is unused
9173 __builtin_avr_insert_bits (0x76543210, bits, val)
9174 @end smallexample
9175
9176 @smallexample
9177 // same as rotating bits by 4
9178 __builtin_avr_insert_bits (0x32107654, bits, 0)
9179 @end smallexample
9180
9181 @smallexample
9182 // high nibble of result is the high nibble of val
9183 // low nibble of result is the low nibble of bits
9184 __builtin_avr_insert_bits (0xffff3210, bits, val)
9185 @end smallexample
9186
9187 @smallexample
9188 // reverse the bit order of bits
9189 __builtin_avr_insert_bits (0x01234567, bits, 0)
9190 @end smallexample
9191
9192 @node Blackfin Built-in Functions
9193 @subsection Blackfin Built-in Functions
9194
9195 Currently, there are two Blackfin-specific built-in functions. These are
9196 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
9197 using inline assembly; by using these built-in functions the compiler can
9198 automatically add workarounds for hardware errata involving these
9199 instructions. These functions are named as follows:
9200
9201 @smallexample
9202 void __builtin_bfin_csync (void)
9203 void __builtin_bfin_ssync (void)
9204 @end smallexample
9205
9206 @node FR-V Built-in Functions
9207 @subsection FR-V Built-in Functions
9208
9209 GCC provides many FR-V-specific built-in functions. In general,
9210 these functions are intended to be compatible with those described
9211 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
9212 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
9213 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
9214 pointer rather than by value.
9215
9216 Most of the functions are named after specific FR-V instructions.
9217 Such functions are said to be ``directly mapped'' and are summarized
9218 here in tabular form.
9219
9220 @menu
9221 * Argument Types::
9222 * Directly-mapped Integer Functions::
9223 * Directly-mapped Media Functions::
9224 * Raw read/write Functions::
9225 * Other Built-in Functions::
9226 @end menu
9227
9228 @node Argument Types
9229 @subsubsection Argument Types
9230
9231 The arguments to the built-in functions can be divided into three groups:
9232 register numbers, compile-time constants and run-time values. In order
9233 to make this classification clear at a glance, the arguments and return
9234 values are given the following pseudo types:
9235
9236 @multitable @columnfractions .20 .30 .15 .35
9237 @item Pseudo type @tab Real C type @tab Constant? @tab Description
9238 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
9239 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
9240 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
9241 @item @code{uw2} @tab @code{unsigned long long} @tab No
9242 @tab an unsigned doubleword
9243 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
9244 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
9245 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
9246 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
9247 @end multitable
9248
9249 These pseudo types are not defined by GCC, they are simply a notational
9250 convenience used in this manual.
9251
9252 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
9253 and @code{sw2} are evaluated at run time. They correspond to
9254 register operands in the underlying FR-V instructions.
9255
9256 @code{const} arguments represent immediate operands in the underlying
9257 FR-V instructions. They must be compile-time constants.
9258
9259 @code{acc} arguments are evaluated at compile time and specify the number
9260 of an accumulator register. For example, an @code{acc} argument of 2
9261 selects the ACC2 register.
9262
9263 @code{iacc} arguments are similar to @code{acc} arguments but specify the
9264 number of an IACC register. See @pxref{Other Built-in Functions}
9265 for more details.
9266
9267 @node Directly-mapped Integer Functions
9268 @subsubsection Directly-mapped Integer Functions
9269
9270 The functions listed below map directly to FR-V I-type instructions.
9271
9272 @multitable @columnfractions .45 .32 .23
9273 @item Function prototype @tab Example usage @tab Assembly output
9274 @item @code{sw1 __ADDSS (sw1, sw1)}
9275 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
9276 @tab @code{ADDSS @var{a},@var{b},@var{c}}
9277 @item @code{sw1 __SCAN (sw1, sw1)}
9278 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
9279 @tab @code{SCAN @var{a},@var{b},@var{c}}
9280 @item @code{sw1 __SCUTSS (sw1)}
9281 @tab @code{@var{b} = __SCUTSS (@var{a})}
9282 @tab @code{SCUTSS @var{a},@var{b}}
9283 @item @code{sw1 __SLASS (sw1, sw1)}
9284 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
9285 @tab @code{SLASS @var{a},@var{b},@var{c}}
9286 @item @code{void __SMASS (sw1, sw1)}
9287 @tab @code{__SMASS (@var{a}, @var{b})}
9288 @tab @code{SMASS @var{a},@var{b}}
9289 @item @code{void __SMSSS (sw1, sw1)}
9290 @tab @code{__SMSSS (@var{a}, @var{b})}
9291 @tab @code{SMSSS @var{a},@var{b}}
9292 @item @code{void __SMU (sw1, sw1)}
9293 @tab @code{__SMU (@var{a}, @var{b})}
9294 @tab @code{SMU @var{a},@var{b}}
9295 @item @code{sw2 __SMUL (sw1, sw1)}
9296 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
9297 @tab @code{SMUL @var{a},@var{b},@var{c}}
9298 @item @code{sw1 __SUBSS (sw1, sw1)}
9299 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
9300 @tab @code{SUBSS @var{a},@var{b},@var{c}}
9301 @item @code{uw2 __UMUL (uw1, uw1)}
9302 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
9303 @tab @code{UMUL @var{a},@var{b},@var{c}}
9304 @end multitable
9305
9306 @node Directly-mapped Media Functions
9307 @subsubsection Directly-mapped Media Functions
9308
9309 The functions listed below map directly to FR-V M-type instructions.
9310
9311 @multitable @columnfractions .45 .32 .23
9312 @item Function prototype @tab Example usage @tab Assembly output
9313 @item @code{uw1 __MABSHS (sw1)}
9314 @tab @code{@var{b} = __MABSHS (@var{a})}
9315 @tab @code{MABSHS @var{a},@var{b}}
9316 @item @code{void __MADDACCS (acc, acc)}
9317 @tab @code{__MADDACCS (@var{b}, @var{a})}
9318 @tab @code{MADDACCS @var{a},@var{b}}
9319 @item @code{sw1 __MADDHSS (sw1, sw1)}
9320 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
9321 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
9322 @item @code{uw1 __MADDHUS (uw1, uw1)}
9323 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
9324 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
9325 @item @code{uw1 __MAND (uw1, uw1)}
9326 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
9327 @tab @code{MAND @var{a},@var{b},@var{c}}
9328 @item @code{void __MASACCS (acc, acc)}
9329 @tab @code{__MASACCS (@var{b}, @var{a})}
9330 @tab @code{MASACCS @var{a},@var{b}}
9331 @item @code{uw1 __MAVEH (uw1, uw1)}
9332 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
9333 @tab @code{MAVEH @var{a},@var{b},@var{c}}
9334 @item @code{uw2 __MBTOH (uw1)}
9335 @tab @code{@var{b} = __MBTOH (@var{a})}
9336 @tab @code{MBTOH @var{a},@var{b}}
9337 @item @code{void __MBTOHE (uw1 *, uw1)}
9338 @tab @code{__MBTOHE (&@var{b}, @var{a})}
9339 @tab @code{MBTOHE @var{a},@var{b}}
9340 @item @code{void __MCLRACC (acc)}
9341 @tab @code{__MCLRACC (@var{a})}
9342 @tab @code{MCLRACC @var{a}}
9343 @item @code{void __MCLRACCA (void)}
9344 @tab @code{__MCLRACCA ()}
9345 @tab @code{MCLRACCA}
9346 @item @code{uw1 __Mcop1 (uw1, uw1)}
9347 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
9348 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
9349 @item @code{uw1 __Mcop2 (uw1, uw1)}
9350 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
9351 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
9352 @item @code{uw1 __MCPLHI (uw2, const)}
9353 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
9354 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
9355 @item @code{uw1 __MCPLI (uw2, const)}
9356 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
9357 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
9358 @item @code{void __MCPXIS (acc, sw1, sw1)}
9359 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
9360 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
9361 @item @code{void __MCPXIU (acc, uw1, uw1)}
9362 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
9363 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
9364 @item @code{void __MCPXRS (acc, sw1, sw1)}
9365 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
9366 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
9367 @item @code{void __MCPXRU (acc, uw1, uw1)}
9368 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
9369 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
9370 @item @code{uw1 __MCUT (acc, uw1)}
9371 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
9372 @tab @code{MCUT @var{a},@var{b},@var{c}}
9373 @item @code{uw1 __MCUTSS (acc, sw1)}
9374 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
9375 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
9376 @item @code{void __MDADDACCS (acc, acc)}
9377 @tab @code{__MDADDACCS (@var{b}, @var{a})}
9378 @tab @code{MDADDACCS @var{a},@var{b}}
9379 @item @code{void __MDASACCS (acc, acc)}
9380 @tab @code{__MDASACCS (@var{b}, @var{a})}
9381 @tab @code{MDASACCS @var{a},@var{b}}
9382 @item @code{uw2 __MDCUTSSI (acc, const)}
9383 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
9384 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
9385 @item @code{uw2 __MDPACKH (uw2, uw2)}
9386 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
9387 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
9388 @item @code{uw2 __MDROTLI (uw2, const)}
9389 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
9390 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
9391 @item @code{void __MDSUBACCS (acc, acc)}
9392 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
9393 @tab @code{MDSUBACCS @var{a},@var{b}}
9394 @item @code{void __MDUNPACKH (uw1 *, uw2)}
9395 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
9396 @tab @code{MDUNPACKH @var{a},@var{b}}
9397 @item @code{uw2 __MEXPDHD (uw1, const)}
9398 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
9399 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
9400 @item @code{uw1 __MEXPDHW (uw1, const)}
9401 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
9402 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
9403 @item @code{uw1 __MHDSETH (uw1, const)}
9404 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
9405 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
9406 @item @code{sw1 __MHDSETS (const)}
9407 @tab @code{@var{b} = __MHDSETS (@var{a})}
9408 @tab @code{MHDSETS #@var{a},@var{b}}
9409 @item @code{uw1 __MHSETHIH (uw1, const)}
9410 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
9411 @tab @code{MHSETHIH #@var{a},@var{b}}
9412 @item @code{sw1 __MHSETHIS (sw1, const)}
9413 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
9414 @tab @code{MHSETHIS #@var{a},@var{b}}
9415 @item @code{uw1 __MHSETLOH (uw1, const)}
9416 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
9417 @tab @code{MHSETLOH #@var{a},@var{b}}
9418 @item @code{sw1 __MHSETLOS (sw1, const)}
9419 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
9420 @tab @code{MHSETLOS #@var{a},@var{b}}
9421 @item @code{uw1 __MHTOB (uw2)}
9422 @tab @code{@var{b} = __MHTOB (@var{a})}
9423 @tab @code{MHTOB @var{a},@var{b}}
9424 @item @code{void __MMACHS (acc, sw1, sw1)}
9425 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
9426 @tab @code{MMACHS @var{a},@var{b},@var{c}}
9427 @item @code{void __MMACHU (acc, uw1, uw1)}
9428 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
9429 @tab @code{MMACHU @var{a},@var{b},@var{c}}
9430 @item @code{void __MMRDHS (acc, sw1, sw1)}
9431 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
9432 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
9433 @item @code{void __MMRDHU (acc, uw1, uw1)}
9434 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
9435 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
9436 @item @code{void __MMULHS (acc, sw1, sw1)}
9437 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
9438 @tab @code{MMULHS @var{a},@var{b},@var{c}}
9439 @item @code{void __MMULHU (acc, uw1, uw1)}
9440 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
9441 @tab @code{MMULHU @var{a},@var{b},@var{c}}
9442 @item @code{void __MMULXHS (acc, sw1, sw1)}
9443 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
9444 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
9445 @item @code{void __MMULXHU (acc, uw1, uw1)}
9446 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
9447 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
9448 @item @code{uw1 __MNOT (uw1)}
9449 @tab @code{@var{b} = __MNOT (@var{a})}
9450 @tab @code{MNOT @var{a},@var{b}}
9451 @item @code{uw1 __MOR (uw1, uw1)}
9452 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
9453 @tab @code{MOR @var{a},@var{b},@var{c}}
9454 @item @code{uw1 __MPACKH (uh, uh)}
9455 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
9456 @tab @code{MPACKH @var{a},@var{b},@var{c}}
9457 @item @code{sw2 __MQADDHSS (sw2, sw2)}
9458 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
9459 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
9460 @item @code{uw2 __MQADDHUS (uw2, uw2)}
9461 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
9462 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
9463 @item @code{void __MQCPXIS (acc, sw2, sw2)}
9464 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
9465 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
9466 @item @code{void __MQCPXIU (acc, uw2, uw2)}
9467 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
9468 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
9469 @item @code{void __MQCPXRS (acc, sw2, sw2)}
9470 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
9471 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
9472 @item @code{void __MQCPXRU (acc, uw2, uw2)}
9473 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
9474 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
9475 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
9476 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
9477 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
9478 @item @code{sw2 __MQLMTHS (sw2, sw2)}
9479 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
9480 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
9481 @item @code{void __MQMACHS (acc, sw2, sw2)}
9482 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
9483 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
9484 @item @code{void __MQMACHU (acc, uw2, uw2)}
9485 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
9486 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
9487 @item @code{void __MQMACXHS (acc, sw2, sw2)}
9488 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
9489 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
9490 @item @code{void __MQMULHS (acc, sw2, sw2)}
9491 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
9492 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
9493 @item @code{void __MQMULHU (acc, uw2, uw2)}
9494 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
9495 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
9496 @item @code{void __MQMULXHS (acc, sw2, sw2)}
9497 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
9498 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
9499 @item @code{void __MQMULXHU (acc, uw2, uw2)}
9500 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
9501 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
9502 @item @code{sw2 __MQSATHS (sw2, sw2)}
9503 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
9504 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
9505 @item @code{uw2 __MQSLLHI (uw2, int)}
9506 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
9507 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
9508 @item @code{sw2 __MQSRAHI (sw2, int)}
9509 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
9510 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
9511 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
9512 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
9513 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
9514 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
9515 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
9516 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
9517 @item @code{void __MQXMACHS (acc, sw2, sw2)}
9518 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
9519 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
9520 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
9521 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
9522 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
9523 @item @code{uw1 __MRDACC (acc)}
9524 @tab @code{@var{b} = __MRDACC (@var{a})}
9525 @tab @code{MRDACC @var{a},@var{b}}
9526 @item @code{uw1 __MRDACCG (acc)}
9527 @tab @code{@var{b} = __MRDACCG (@var{a})}
9528 @tab @code{MRDACCG @var{a},@var{b}}
9529 @item @code{uw1 __MROTLI (uw1, const)}
9530 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
9531 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
9532 @item @code{uw1 __MROTRI (uw1, const)}
9533 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
9534 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
9535 @item @code{sw1 __MSATHS (sw1, sw1)}
9536 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
9537 @tab @code{MSATHS @var{a},@var{b},@var{c}}
9538 @item @code{uw1 __MSATHU (uw1, uw1)}
9539 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
9540 @tab @code{MSATHU @var{a},@var{b},@var{c}}
9541 @item @code{uw1 __MSLLHI (uw1, const)}
9542 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
9543 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
9544 @item @code{sw1 __MSRAHI (sw1, const)}
9545 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
9546 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
9547 @item @code{uw1 __MSRLHI (uw1, const)}
9548 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
9549 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
9550 @item @code{void __MSUBACCS (acc, acc)}
9551 @tab @code{__MSUBACCS (@var{b}, @var{a})}
9552 @tab @code{MSUBACCS @var{a},@var{b}}
9553 @item @code{sw1 __MSUBHSS (sw1, sw1)}
9554 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
9555 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
9556 @item @code{uw1 __MSUBHUS (uw1, uw1)}
9557 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
9558 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
9559 @item @code{void __MTRAP (void)}
9560 @tab @code{__MTRAP ()}
9561 @tab @code{MTRAP}
9562 @item @code{uw2 __MUNPACKH (uw1)}
9563 @tab @code{@var{b} = __MUNPACKH (@var{a})}
9564 @tab @code{MUNPACKH @var{a},@var{b}}
9565 @item @code{uw1 __MWCUT (uw2, uw1)}
9566 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
9567 @tab @code{MWCUT @var{a},@var{b},@var{c}}
9568 @item @code{void __MWTACC (acc, uw1)}
9569 @tab @code{__MWTACC (@var{b}, @var{a})}
9570 @tab @code{MWTACC @var{a},@var{b}}
9571 @item @code{void __MWTACCG (acc, uw1)}
9572 @tab @code{__MWTACCG (@var{b}, @var{a})}
9573 @tab @code{MWTACCG @var{a},@var{b}}
9574 @item @code{uw1 __MXOR (uw1, uw1)}
9575 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
9576 @tab @code{MXOR @var{a},@var{b},@var{c}}
9577 @end multitable
9578
9579 @node Raw read/write Functions
9580 @subsubsection Raw read/write Functions
9581
9582 This sections describes built-in functions related to read and write
9583 instructions to access memory. These functions generate
9584 @code{membar} instructions to flush the I/O load and stores where
9585 appropriate, as described in Fujitsu's manual described above.
9586
9587 @table @code
9588
9589 @item unsigned char __builtin_read8 (void *@var{data})
9590 @item unsigned short __builtin_read16 (void *@var{data})
9591 @item unsigned long __builtin_read32 (void *@var{data})
9592 @item unsigned long long __builtin_read64 (void *@var{data})
9593
9594 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
9595 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
9596 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
9597 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
9598 @end table
9599
9600 @node Other Built-in Functions
9601 @subsubsection Other Built-in Functions
9602
9603 This section describes built-in functions that are not named after
9604 a specific FR-V instruction.
9605
9606 @table @code
9607 @item sw2 __IACCreadll (iacc @var{reg})
9608 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
9609 for future expansion and must be 0.
9610
9611 @item sw1 __IACCreadl (iacc @var{reg})
9612 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
9613 Other values of @var{reg} are rejected as invalid.
9614
9615 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
9616 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
9617 is reserved for future expansion and must be 0.
9618
9619 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
9620 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
9621 is 1. Other values of @var{reg} are rejected as invalid.
9622
9623 @item void __data_prefetch0 (const void *@var{x})
9624 Use the @code{dcpl} instruction to load the contents of address @var{x}
9625 into the data cache.
9626
9627 @item void __data_prefetch (const void *@var{x})
9628 Use the @code{nldub} instruction to load the contents of address @var{x}
9629 into the data cache. The instruction is issued in slot I1@.
9630 @end table
9631
9632 @node X86 Built-in Functions
9633 @subsection X86 Built-in Functions
9634
9635 These built-in functions are available for the i386 and x86-64 family
9636 of computers, depending on the command-line switches used.
9637
9638 If you specify command-line switches such as @option{-msse},
9639 the compiler could use the extended instruction sets even if the built-ins
9640 are not used explicitly in the program. For this reason, applications
9641 that perform run-time CPU detection must compile separate files for each
9642 supported architecture, using the appropriate flags. In particular,
9643 the file containing the CPU detection code should be compiled without
9644 these options.
9645
9646 The following machine modes are available for use with MMX built-in functions
9647 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
9648 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
9649 vector of eight 8-bit integers. Some of the built-in functions operate on
9650 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
9651
9652 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
9653 of two 32-bit floating-point values.
9654
9655 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
9656 floating-point values. Some instructions use a vector of four 32-bit
9657 integers, these use @code{V4SI}. Finally, some instructions operate on an
9658 entire vector register, interpreting it as a 128-bit integer, these use mode
9659 @code{TI}.
9660
9661 In 64-bit mode, the x86-64 family of processors uses additional built-in
9662 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
9663 floating point and @code{TC} 128-bit complex floating-point values.
9664
9665 The following floating-point built-in functions are available in 64-bit
9666 mode. All of them implement the function that is part of the name.
9667
9668 @smallexample
9669 __float128 __builtin_fabsq (__float128)
9670 __float128 __builtin_copysignq (__float128, __float128)
9671 @end smallexample
9672
9673 The following built-in function is always available.
9674
9675 @table @code
9676 @item void __builtin_ia32_pause (void)
9677 Generates the @code{pause} machine instruction with a compiler memory
9678 barrier.
9679 @end table
9680
9681 The following floating-point built-in functions are made available in the
9682 64-bit mode.
9683
9684 @table @code
9685 @item __float128 __builtin_infq (void)
9686 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
9687 @findex __builtin_infq
9688
9689 @item __float128 __builtin_huge_valq (void)
9690 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
9691 @findex __builtin_huge_valq
9692 @end table
9693
9694 The following built-in functions are always available and can be used to
9695 check the target platform type.
9696
9697 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
9698 This function runs the CPU detection code to check the type of CPU and the
9699 features supported. This built-in function needs to be invoked along with the built-in functions
9700 to check CPU type and features, @code{__builtin_cpu_is} and
9701 @code{__builtin_cpu_supports}, only when used in a function that is
9702 executed before any constructors are called. The CPU detection code is
9703 automatically executed in a very high priority constructor.
9704
9705 For example, this function has to be used in @code{ifunc} resolvers that
9706 check for CPU type using the built-in functions @code{__builtin_cpu_is}
9707 and @code{__builtin_cpu_supports}, or in constructors on targets that
9708 don't support constructor priority.
9709 @smallexample
9710
9711 static void (*resolve_memcpy (void)) (void)
9712 @{
9713 // ifunc resolvers fire before constructors, explicitly call the init
9714 // function.
9715 __builtin_cpu_init ();
9716 if (__builtin_cpu_supports ("ssse3"))
9717 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
9718 else
9719 return default_memcpy;
9720 @}
9721
9722 void *memcpy (void *, const void *, size_t)
9723 __attribute__ ((ifunc ("resolve_memcpy")));
9724 @end smallexample
9725
9726 @end deftypefn
9727
9728 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
9729 This function returns a positive integer if the run-time CPU
9730 is of type @var{cpuname}
9731 and returns @code{0} otherwise. The following CPU names can be detected:
9732
9733 @table @samp
9734 @item intel
9735 Intel CPU.
9736
9737 @item atom
9738 Intel Atom CPU.
9739
9740 @item core2
9741 Intel Core 2 CPU.
9742
9743 @item corei7
9744 Intel Core i7 CPU.
9745
9746 @item nehalem
9747 Intel Core i7 Nehalem CPU.
9748
9749 @item westmere
9750 Intel Core i7 Westmere CPU.
9751
9752 @item sandybridge
9753 Intel Core i7 Sandy Bridge CPU.
9754
9755 @item amd
9756 AMD CPU.
9757
9758 @item amdfam10h
9759 AMD Family 10h CPU.
9760
9761 @item barcelona
9762 AMD Family 10h Barcelona CPU.
9763
9764 @item shanghai
9765 AMD Family 10h Shanghai CPU.
9766
9767 @item istanbul
9768 AMD Family 10h Istanbul CPU.
9769
9770 @item btver1
9771 AMD Family 14h CPU.
9772
9773 @item amdfam15h
9774 AMD Family 15h CPU.
9775
9776 @item bdver1
9777 AMD Family 15h Bulldozer version 1.
9778
9779 @item bdver2
9780 AMD Family 15h Bulldozer version 2.
9781
9782 @item bdver3
9783 AMD Family 15h Bulldozer version 3.
9784
9785 @item btver2
9786 AMD Family 16h CPU.
9787 @end table
9788
9789 Here is an example:
9790 @smallexample
9791 if (__builtin_cpu_is ("corei7"))
9792 @{
9793 do_corei7 (); // Core i7 specific implementation.
9794 @}
9795 else
9796 @{
9797 do_generic (); // Generic implementation.
9798 @}
9799 @end smallexample
9800 @end deftypefn
9801
9802 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
9803 This function returns a positive integer if the run-time CPU
9804 supports @var{feature}
9805 and returns @code{0} otherwise. The following features can be detected:
9806
9807 @table @samp
9808 @item cmov
9809 CMOV instruction.
9810 @item mmx
9811 MMX instructions.
9812 @item popcnt
9813 POPCNT instruction.
9814 @item sse
9815 SSE instructions.
9816 @item sse2
9817 SSE2 instructions.
9818 @item sse3
9819 SSE3 instructions.
9820 @item ssse3
9821 SSSE3 instructions.
9822 @item sse4.1
9823 SSE4.1 instructions.
9824 @item sse4.2
9825 SSE4.2 instructions.
9826 @item avx
9827 AVX instructions.
9828 @item avx2
9829 AVX2 instructions.
9830 @end table
9831
9832 Here is an example:
9833 @smallexample
9834 if (__builtin_cpu_supports ("popcnt"))
9835 @{
9836 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
9837 @}
9838 else
9839 @{
9840 count = generic_countbits (n); //generic implementation.
9841 @}
9842 @end smallexample
9843 @end deftypefn
9844
9845
9846 The following built-in functions are made available by @option{-mmmx}.
9847 All of them generate the machine instruction that is part of the name.
9848
9849 @smallexample
9850 v8qi __builtin_ia32_paddb (v8qi, v8qi)
9851 v4hi __builtin_ia32_paddw (v4hi, v4hi)
9852 v2si __builtin_ia32_paddd (v2si, v2si)
9853 v8qi __builtin_ia32_psubb (v8qi, v8qi)
9854 v4hi __builtin_ia32_psubw (v4hi, v4hi)
9855 v2si __builtin_ia32_psubd (v2si, v2si)
9856 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
9857 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
9858 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
9859 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
9860 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
9861 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
9862 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
9863 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
9864 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
9865 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
9866 di __builtin_ia32_pand (di, di)
9867 di __builtin_ia32_pandn (di,di)
9868 di __builtin_ia32_por (di, di)
9869 di __builtin_ia32_pxor (di, di)
9870 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
9871 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
9872 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
9873 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
9874 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
9875 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
9876 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
9877 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
9878 v2si __builtin_ia32_punpckhdq (v2si, v2si)
9879 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
9880 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
9881 v2si __builtin_ia32_punpckldq (v2si, v2si)
9882 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
9883 v4hi __builtin_ia32_packssdw (v2si, v2si)
9884 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
9885
9886 v4hi __builtin_ia32_psllw (v4hi, v4hi)
9887 v2si __builtin_ia32_pslld (v2si, v2si)
9888 v1di __builtin_ia32_psllq (v1di, v1di)
9889 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
9890 v2si __builtin_ia32_psrld (v2si, v2si)
9891 v1di __builtin_ia32_psrlq (v1di, v1di)
9892 v4hi __builtin_ia32_psraw (v4hi, v4hi)
9893 v2si __builtin_ia32_psrad (v2si, v2si)
9894 v4hi __builtin_ia32_psllwi (v4hi, int)
9895 v2si __builtin_ia32_pslldi (v2si, int)
9896 v1di __builtin_ia32_psllqi (v1di, int)
9897 v4hi __builtin_ia32_psrlwi (v4hi, int)
9898 v2si __builtin_ia32_psrldi (v2si, int)
9899 v1di __builtin_ia32_psrlqi (v1di, int)
9900 v4hi __builtin_ia32_psrawi (v4hi, int)
9901 v2si __builtin_ia32_psradi (v2si, int)
9902
9903 @end smallexample
9904
9905 The following built-in functions are made available either with
9906 @option{-msse}, or with a combination of @option{-m3dnow} and
9907 @option{-march=athlon}. All of them generate the machine
9908 instruction that is part of the name.
9909
9910 @smallexample
9911 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
9912 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
9913 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
9914 v1di __builtin_ia32_psadbw (v8qi, v8qi)
9915 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
9916 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
9917 v8qi __builtin_ia32_pminub (v8qi, v8qi)
9918 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
9919 int __builtin_ia32_pextrw (v4hi, int)
9920 v4hi __builtin_ia32_pinsrw (v4hi, int, int)
9921 int __builtin_ia32_pmovmskb (v8qi)
9922 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
9923 void __builtin_ia32_movntq (di *, di)
9924 void __builtin_ia32_sfence (void)
9925 @end smallexample
9926
9927 The following built-in functions are available when @option{-msse} is used.
9928 All of them generate the machine instruction that is part of the name.
9929
9930 @smallexample
9931 int __builtin_ia32_comieq (v4sf, v4sf)
9932 int __builtin_ia32_comineq (v4sf, v4sf)
9933 int __builtin_ia32_comilt (v4sf, v4sf)
9934 int __builtin_ia32_comile (v4sf, v4sf)
9935 int __builtin_ia32_comigt (v4sf, v4sf)
9936 int __builtin_ia32_comige (v4sf, v4sf)
9937 int __builtin_ia32_ucomieq (v4sf, v4sf)
9938 int __builtin_ia32_ucomineq (v4sf, v4sf)
9939 int __builtin_ia32_ucomilt (v4sf, v4sf)
9940 int __builtin_ia32_ucomile (v4sf, v4sf)
9941 int __builtin_ia32_ucomigt (v4sf, v4sf)
9942 int __builtin_ia32_ucomige (v4sf, v4sf)
9943 v4sf __builtin_ia32_addps (v4sf, v4sf)
9944 v4sf __builtin_ia32_subps (v4sf, v4sf)
9945 v4sf __builtin_ia32_mulps (v4sf, v4sf)
9946 v4sf __builtin_ia32_divps (v4sf, v4sf)
9947 v4sf __builtin_ia32_addss (v4sf, v4sf)
9948 v4sf __builtin_ia32_subss (v4sf, v4sf)
9949 v4sf __builtin_ia32_mulss (v4sf, v4sf)
9950 v4sf __builtin_ia32_divss (v4sf, v4sf)
9951 v4si __builtin_ia32_cmpeqps (v4sf, v4sf)
9952 v4si __builtin_ia32_cmpltps (v4sf, v4sf)
9953 v4si __builtin_ia32_cmpleps (v4sf, v4sf)
9954 v4si __builtin_ia32_cmpgtps (v4sf, v4sf)
9955 v4si __builtin_ia32_cmpgeps (v4sf, v4sf)
9956 v4si __builtin_ia32_cmpunordps (v4sf, v4sf)
9957 v4si __builtin_ia32_cmpneqps (v4sf, v4sf)
9958 v4si __builtin_ia32_cmpnltps (v4sf, v4sf)
9959 v4si __builtin_ia32_cmpnleps (v4sf, v4sf)
9960 v4si __builtin_ia32_cmpngtps (v4sf, v4sf)
9961 v4si __builtin_ia32_cmpngeps (v4sf, v4sf)
9962 v4si __builtin_ia32_cmpordps (v4sf, v4sf)
9963 v4si __builtin_ia32_cmpeqss (v4sf, v4sf)
9964 v4si __builtin_ia32_cmpltss (v4sf, v4sf)
9965 v4si __builtin_ia32_cmpless (v4sf, v4sf)
9966 v4si __builtin_ia32_cmpunordss (v4sf, v4sf)
9967 v4si __builtin_ia32_cmpneqss (v4sf, v4sf)
9968 v4si __builtin_ia32_cmpnlts (v4sf, v4sf)
9969 v4si __builtin_ia32_cmpnless (v4sf, v4sf)
9970 v4si __builtin_ia32_cmpordss (v4sf, v4sf)
9971 v4sf __builtin_ia32_maxps (v4sf, v4sf)
9972 v4sf __builtin_ia32_maxss (v4sf, v4sf)
9973 v4sf __builtin_ia32_minps (v4sf, v4sf)
9974 v4sf __builtin_ia32_minss (v4sf, v4sf)
9975 v4sf __builtin_ia32_andps (v4sf, v4sf)
9976 v4sf __builtin_ia32_andnps (v4sf, v4sf)
9977 v4sf __builtin_ia32_orps (v4sf, v4sf)
9978 v4sf __builtin_ia32_xorps (v4sf, v4sf)
9979 v4sf __builtin_ia32_movss (v4sf, v4sf)
9980 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
9981 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
9982 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
9983 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
9984 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
9985 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
9986 v2si __builtin_ia32_cvtps2pi (v4sf)
9987 int __builtin_ia32_cvtss2si (v4sf)
9988 v2si __builtin_ia32_cvttps2pi (v4sf)
9989 int __builtin_ia32_cvttss2si (v4sf)
9990 v4sf __builtin_ia32_rcpps (v4sf)
9991 v4sf __builtin_ia32_rsqrtps (v4sf)
9992 v4sf __builtin_ia32_sqrtps (v4sf)
9993 v4sf __builtin_ia32_rcpss (v4sf)
9994 v4sf __builtin_ia32_rsqrtss (v4sf)
9995 v4sf __builtin_ia32_sqrtss (v4sf)
9996 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
9997 void __builtin_ia32_movntps (float *, v4sf)
9998 int __builtin_ia32_movmskps (v4sf)
9999 @end smallexample
10000
10001 The following built-in functions are available when @option{-msse} is used.
10002
10003 @table @code
10004 @item v4sf __builtin_ia32_loadaps (float *)
10005 Generates the @code{movaps} machine instruction as a load from memory.
10006 @item void __builtin_ia32_storeaps (float *, v4sf)
10007 Generates the @code{movaps} machine instruction as a store to memory.
10008 @item v4sf __builtin_ia32_loadups (float *)
10009 Generates the @code{movups} machine instruction as a load from memory.
10010 @item void __builtin_ia32_storeups (float *, v4sf)
10011 Generates the @code{movups} machine instruction as a store to memory.
10012 @item v4sf __builtin_ia32_loadsss (float *)
10013 Generates the @code{movss} machine instruction as a load from memory.
10014 @item void __builtin_ia32_storess (float *, v4sf)
10015 Generates the @code{movss} machine instruction as a store to memory.
10016 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
10017 Generates the @code{movhps} machine instruction as a load from memory.
10018 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
10019 Generates the @code{movlps} machine instruction as a load from memory
10020 @item void __builtin_ia32_storehps (v2sf *, v4sf)
10021 Generates the @code{movhps} machine instruction as a store to memory.
10022 @item void __builtin_ia32_storelps (v2sf *, v4sf)
10023 Generates the @code{movlps} machine instruction as a store to memory.
10024 @end table
10025
10026 The following built-in functions are available when @option{-msse2} is used.
10027 All of them generate the machine instruction that is part of the name.
10028
10029 @smallexample
10030 int __builtin_ia32_comisdeq (v2df, v2df)
10031 int __builtin_ia32_comisdlt (v2df, v2df)
10032 int __builtin_ia32_comisdle (v2df, v2df)
10033 int __builtin_ia32_comisdgt (v2df, v2df)
10034 int __builtin_ia32_comisdge (v2df, v2df)
10035 int __builtin_ia32_comisdneq (v2df, v2df)
10036 int __builtin_ia32_ucomisdeq (v2df, v2df)
10037 int __builtin_ia32_ucomisdlt (v2df, v2df)
10038 int __builtin_ia32_ucomisdle (v2df, v2df)
10039 int __builtin_ia32_ucomisdgt (v2df, v2df)
10040 int __builtin_ia32_ucomisdge (v2df, v2df)
10041 int __builtin_ia32_ucomisdneq (v2df, v2df)
10042 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
10043 v2df __builtin_ia32_cmpltpd (v2df, v2df)
10044 v2df __builtin_ia32_cmplepd (v2df, v2df)
10045 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
10046 v2df __builtin_ia32_cmpgepd (v2df, v2df)
10047 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
10048 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
10049 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
10050 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
10051 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
10052 v2df __builtin_ia32_cmpngepd (v2df, v2df)
10053 v2df __builtin_ia32_cmpordpd (v2df, v2df)
10054 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
10055 v2df __builtin_ia32_cmpltsd (v2df, v2df)
10056 v2df __builtin_ia32_cmplesd (v2df, v2df)
10057 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
10058 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
10059 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
10060 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
10061 v2df __builtin_ia32_cmpordsd (v2df, v2df)
10062 v2di __builtin_ia32_paddq (v2di, v2di)
10063 v2di __builtin_ia32_psubq (v2di, v2di)
10064 v2df __builtin_ia32_addpd (v2df, v2df)
10065 v2df __builtin_ia32_subpd (v2df, v2df)
10066 v2df __builtin_ia32_mulpd (v2df, v2df)
10067 v2df __builtin_ia32_divpd (v2df, v2df)
10068 v2df __builtin_ia32_addsd (v2df, v2df)
10069 v2df __builtin_ia32_subsd (v2df, v2df)
10070 v2df __builtin_ia32_mulsd (v2df, v2df)
10071 v2df __builtin_ia32_divsd (v2df, v2df)
10072 v2df __builtin_ia32_minpd (v2df, v2df)
10073 v2df __builtin_ia32_maxpd (v2df, v2df)
10074 v2df __builtin_ia32_minsd (v2df, v2df)
10075 v2df __builtin_ia32_maxsd (v2df, v2df)
10076 v2df __builtin_ia32_andpd (v2df, v2df)
10077 v2df __builtin_ia32_andnpd (v2df, v2df)
10078 v2df __builtin_ia32_orpd (v2df, v2df)
10079 v2df __builtin_ia32_xorpd (v2df, v2df)
10080 v2df __builtin_ia32_movsd (v2df, v2df)
10081 v2df __builtin_ia32_unpckhpd (v2df, v2df)
10082 v2df __builtin_ia32_unpcklpd (v2df, v2df)
10083 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
10084 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
10085 v4si __builtin_ia32_paddd128 (v4si, v4si)
10086 v2di __builtin_ia32_paddq128 (v2di, v2di)
10087 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
10088 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
10089 v4si __builtin_ia32_psubd128 (v4si, v4si)
10090 v2di __builtin_ia32_psubq128 (v2di, v2di)
10091 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
10092 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
10093 v2di __builtin_ia32_pand128 (v2di, v2di)
10094 v2di __builtin_ia32_pandn128 (v2di, v2di)
10095 v2di __builtin_ia32_por128 (v2di, v2di)
10096 v2di __builtin_ia32_pxor128 (v2di, v2di)
10097 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
10098 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
10099 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
10100 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
10101 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
10102 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
10103 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
10104 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
10105 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
10106 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
10107 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
10108 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
10109 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
10110 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
10111 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
10112 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
10113 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
10114 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
10115 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
10116 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
10117 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
10118 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
10119 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
10120 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
10121 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
10122 v2df __builtin_ia32_loadupd (double *)
10123 void __builtin_ia32_storeupd (double *, v2df)
10124 v2df __builtin_ia32_loadhpd (v2df, double const *)
10125 v2df __builtin_ia32_loadlpd (v2df, double const *)
10126 int __builtin_ia32_movmskpd (v2df)
10127 int __builtin_ia32_pmovmskb128 (v16qi)
10128 void __builtin_ia32_movnti (int *, int)
10129 void __builtin_ia32_movnti64 (long long int *, long long int)
10130 void __builtin_ia32_movntpd (double *, v2df)
10131 void __builtin_ia32_movntdq (v2df *, v2df)
10132 v4si __builtin_ia32_pshufd (v4si, int)
10133 v8hi __builtin_ia32_pshuflw (v8hi, int)
10134 v8hi __builtin_ia32_pshufhw (v8hi, int)
10135 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
10136 v2df __builtin_ia32_sqrtpd (v2df)
10137 v2df __builtin_ia32_sqrtsd (v2df)
10138 v2df __builtin_ia32_shufpd (v2df, v2df, int)
10139 v2df __builtin_ia32_cvtdq2pd (v4si)
10140 v4sf __builtin_ia32_cvtdq2ps (v4si)
10141 v4si __builtin_ia32_cvtpd2dq (v2df)
10142 v2si __builtin_ia32_cvtpd2pi (v2df)
10143 v4sf __builtin_ia32_cvtpd2ps (v2df)
10144 v4si __builtin_ia32_cvttpd2dq (v2df)
10145 v2si __builtin_ia32_cvttpd2pi (v2df)
10146 v2df __builtin_ia32_cvtpi2pd (v2si)
10147 int __builtin_ia32_cvtsd2si (v2df)
10148 int __builtin_ia32_cvttsd2si (v2df)
10149 long long __builtin_ia32_cvtsd2si64 (v2df)
10150 long long __builtin_ia32_cvttsd2si64 (v2df)
10151 v4si __builtin_ia32_cvtps2dq (v4sf)
10152 v2df __builtin_ia32_cvtps2pd (v4sf)
10153 v4si __builtin_ia32_cvttps2dq (v4sf)
10154 v2df __builtin_ia32_cvtsi2sd (v2df, int)
10155 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
10156 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
10157 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
10158 void __builtin_ia32_clflush (const void *)
10159 void __builtin_ia32_lfence (void)
10160 void __builtin_ia32_mfence (void)
10161 v16qi __builtin_ia32_loaddqu (const char *)
10162 void __builtin_ia32_storedqu (char *, v16qi)
10163 v1di __builtin_ia32_pmuludq (v2si, v2si)
10164 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
10165 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
10166 v4si __builtin_ia32_pslld128 (v4si, v4si)
10167 v2di __builtin_ia32_psllq128 (v2di, v2di)
10168 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
10169 v4si __builtin_ia32_psrld128 (v4si, v4si)
10170 v2di __builtin_ia32_psrlq128 (v2di, v2di)
10171 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
10172 v4si __builtin_ia32_psrad128 (v4si, v4si)
10173 v2di __builtin_ia32_pslldqi128 (v2di, int)
10174 v8hi __builtin_ia32_psllwi128 (v8hi, int)
10175 v4si __builtin_ia32_pslldi128 (v4si, int)
10176 v2di __builtin_ia32_psllqi128 (v2di, int)
10177 v2di __builtin_ia32_psrldqi128 (v2di, int)
10178 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
10179 v4si __builtin_ia32_psrldi128 (v4si, int)
10180 v2di __builtin_ia32_psrlqi128 (v2di, int)
10181 v8hi __builtin_ia32_psrawi128 (v8hi, int)
10182 v4si __builtin_ia32_psradi128 (v4si, int)
10183 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
10184 v2di __builtin_ia32_movq128 (v2di)
10185 @end smallexample
10186
10187 The following built-in functions are available when @option{-msse3} is used.
10188 All of them generate the machine instruction that is part of the name.
10189
10190 @smallexample
10191 v2df __builtin_ia32_addsubpd (v2df, v2df)
10192 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
10193 v2df __builtin_ia32_haddpd (v2df, v2df)
10194 v4sf __builtin_ia32_haddps (v4sf, v4sf)
10195 v2df __builtin_ia32_hsubpd (v2df, v2df)
10196 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
10197 v16qi __builtin_ia32_lddqu (char const *)
10198 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
10199 v2df __builtin_ia32_movddup (v2df)
10200 v4sf __builtin_ia32_movshdup (v4sf)
10201 v4sf __builtin_ia32_movsldup (v4sf)
10202 void __builtin_ia32_mwait (unsigned int, unsigned int)
10203 @end smallexample
10204
10205 The following built-in functions are available when @option{-msse3} is used.
10206
10207 @table @code
10208 @item v2df __builtin_ia32_loadddup (double const *)
10209 Generates the @code{movddup} machine instruction as a load from memory.
10210 @end table
10211
10212 The following built-in functions are available when @option{-mssse3} is used.
10213 All of them generate the machine instruction that is part of the name
10214 with MMX registers.
10215
10216 @smallexample
10217 v2si __builtin_ia32_phaddd (v2si, v2si)
10218 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
10219 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
10220 v2si __builtin_ia32_phsubd (v2si, v2si)
10221 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
10222 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
10223 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
10224 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
10225 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
10226 v8qi __builtin_ia32_psignb (v8qi, v8qi)
10227 v2si __builtin_ia32_psignd (v2si, v2si)
10228 v4hi __builtin_ia32_psignw (v4hi, v4hi)
10229 v1di __builtin_ia32_palignr (v1di, v1di, int)
10230 v8qi __builtin_ia32_pabsb (v8qi)
10231 v2si __builtin_ia32_pabsd (v2si)
10232 v4hi __builtin_ia32_pabsw (v4hi)
10233 @end smallexample
10234
10235 The following built-in functions are available when @option{-mssse3} is used.
10236 All of them generate the machine instruction that is part of the name
10237 with SSE registers.
10238
10239 @smallexample
10240 v4si __builtin_ia32_phaddd128 (v4si, v4si)
10241 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
10242 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
10243 v4si __builtin_ia32_phsubd128 (v4si, v4si)
10244 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
10245 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
10246 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
10247 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
10248 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
10249 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
10250 v4si __builtin_ia32_psignd128 (v4si, v4si)
10251 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
10252 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
10253 v16qi __builtin_ia32_pabsb128 (v16qi)
10254 v4si __builtin_ia32_pabsd128 (v4si)
10255 v8hi __builtin_ia32_pabsw128 (v8hi)
10256 @end smallexample
10257
10258 The following built-in functions are available when @option{-msse4.1} is
10259 used. All of them generate the machine instruction that is part of the
10260 name.
10261
10262 @smallexample
10263 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
10264 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
10265 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
10266 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
10267 v2df __builtin_ia32_dppd (v2df, v2df, const int)
10268 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
10269 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
10270 v2di __builtin_ia32_movntdqa (v2di *);
10271 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
10272 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
10273 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
10274 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
10275 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
10276 v8hi __builtin_ia32_phminposuw128 (v8hi)
10277 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
10278 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
10279 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
10280 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
10281 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
10282 v4si __builtin_ia32_pminsd128 (v4si, v4si)
10283 v4si __builtin_ia32_pminud128 (v4si, v4si)
10284 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
10285 v4si __builtin_ia32_pmovsxbd128 (v16qi)
10286 v2di __builtin_ia32_pmovsxbq128 (v16qi)
10287 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
10288 v2di __builtin_ia32_pmovsxdq128 (v4si)
10289 v4si __builtin_ia32_pmovsxwd128 (v8hi)
10290 v2di __builtin_ia32_pmovsxwq128 (v8hi)
10291 v4si __builtin_ia32_pmovzxbd128 (v16qi)
10292 v2di __builtin_ia32_pmovzxbq128 (v16qi)
10293 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
10294 v2di __builtin_ia32_pmovzxdq128 (v4si)
10295 v4si __builtin_ia32_pmovzxwd128 (v8hi)
10296 v2di __builtin_ia32_pmovzxwq128 (v8hi)
10297 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
10298 v4si __builtin_ia32_pmulld128 (v4si, v4si)
10299 int __builtin_ia32_ptestc128 (v2di, v2di)
10300 int __builtin_ia32_ptestnzc128 (v2di, v2di)
10301 int __builtin_ia32_ptestz128 (v2di, v2di)
10302 v2df __builtin_ia32_roundpd (v2df, const int)
10303 v4sf __builtin_ia32_roundps (v4sf, const int)
10304 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
10305 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
10306 @end smallexample
10307
10308 The following built-in functions are available when @option{-msse4.1} is
10309 used.
10310
10311 @table @code
10312 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
10313 Generates the @code{insertps} machine instruction.
10314 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
10315 Generates the @code{pextrb} machine instruction.
10316 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
10317 Generates the @code{pinsrb} machine instruction.
10318 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
10319 Generates the @code{pinsrd} machine instruction.
10320 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
10321 Generates the @code{pinsrq} machine instruction in 64bit mode.
10322 @end table
10323
10324 The following built-in functions are changed to generate new SSE4.1
10325 instructions when @option{-msse4.1} is used.
10326
10327 @table @code
10328 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
10329 Generates the @code{extractps} machine instruction.
10330 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
10331 Generates the @code{pextrd} machine instruction.
10332 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
10333 Generates the @code{pextrq} machine instruction in 64bit mode.
10334 @end table
10335
10336 The following built-in functions are available when @option{-msse4.2} is
10337 used. All of them generate the machine instruction that is part of the
10338 name.
10339
10340 @smallexample
10341 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
10342 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
10343 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
10344 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
10345 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
10346 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
10347 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
10348 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
10349 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
10350 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
10351 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
10352 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
10353 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
10354 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
10355 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
10356 @end smallexample
10357
10358 The following built-in functions are available when @option{-msse4.2} is
10359 used.
10360
10361 @table @code
10362 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
10363 Generates the @code{crc32b} machine instruction.
10364 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
10365 Generates the @code{crc32w} machine instruction.
10366 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
10367 Generates the @code{crc32l} machine instruction.
10368 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
10369 Generates the @code{crc32q} machine instruction.
10370 @end table
10371
10372 The following built-in functions are changed to generate new SSE4.2
10373 instructions when @option{-msse4.2} is used.
10374
10375 @table @code
10376 @item int __builtin_popcount (unsigned int)
10377 Generates the @code{popcntl} machine instruction.
10378 @item int __builtin_popcountl (unsigned long)
10379 Generates the @code{popcntl} or @code{popcntq} machine instruction,
10380 depending on the size of @code{unsigned long}.
10381 @item int __builtin_popcountll (unsigned long long)
10382 Generates the @code{popcntq} machine instruction.
10383 @end table
10384
10385 The following built-in functions are available when @option{-mavx} is
10386 used. All of them generate the machine instruction that is part of the
10387 name.
10388
10389 @smallexample
10390 v4df __builtin_ia32_addpd256 (v4df,v4df)
10391 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
10392 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
10393 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
10394 v4df __builtin_ia32_andnpd256 (v4df,v4df)
10395 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
10396 v4df __builtin_ia32_andpd256 (v4df,v4df)
10397 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
10398 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
10399 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
10400 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
10401 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
10402 v2df __builtin_ia32_cmppd (v2df,v2df,int)
10403 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
10404 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
10405 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
10406 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
10407 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
10408 v4df __builtin_ia32_cvtdq2pd256 (v4si)
10409 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
10410 v4si __builtin_ia32_cvtpd2dq256 (v4df)
10411 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
10412 v8si __builtin_ia32_cvtps2dq256 (v8sf)
10413 v4df __builtin_ia32_cvtps2pd256 (v4sf)
10414 v4si __builtin_ia32_cvttpd2dq256 (v4df)
10415 v8si __builtin_ia32_cvttps2dq256 (v8sf)
10416 v4df __builtin_ia32_divpd256 (v4df,v4df)
10417 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
10418 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
10419 v4df __builtin_ia32_haddpd256 (v4df,v4df)
10420 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
10421 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
10422 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
10423 v32qi __builtin_ia32_lddqu256 (pcchar)
10424 v32qi __builtin_ia32_loaddqu256 (pcchar)
10425 v4df __builtin_ia32_loadupd256 (pcdouble)
10426 v8sf __builtin_ia32_loadups256 (pcfloat)
10427 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
10428 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
10429 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
10430 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
10431 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
10432 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
10433 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
10434 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
10435 v4df __builtin_ia32_maxpd256 (v4df,v4df)
10436 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
10437 v4df __builtin_ia32_minpd256 (v4df,v4df)
10438 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
10439 v4df __builtin_ia32_movddup256 (v4df)
10440 int __builtin_ia32_movmskpd256 (v4df)
10441 int __builtin_ia32_movmskps256 (v8sf)
10442 v8sf __builtin_ia32_movshdup256 (v8sf)
10443 v8sf __builtin_ia32_movsldup256 (v8sf)
10444 v4df __builtin_ia32_mulpd256 (v4df,v4df)
10445 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
10446 v4df __builtin_ia32_orpd256 (v4df,v4df)
10447 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
10448 v2df __builtin_ia32_pd_pd256 (v4df)
10449 v4df __builtin_ia32_pd256_pd (v2df)
10450 v4sf __builtin_ia32_ps_ps256 (v8sf)
10451 v8sf __builtin_ia32_ps256_ps (v4sf)
10452 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
10453 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
10454 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
10455 v8sf __builtin_ia32_rcpps256 (v8sf)
10456 v4df __builtin_ia32_roundpd256 (v4df,int)
10457 v8sf __builtin_ia32_roundps256 (v8sf,int)
10458 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
10459 v8sf __builtin_ia32_rsqrtps256 (v8sf)
10460 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
10461 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
10462 v4si __builtin_ia32_si_si256 (v8si)
10463 v8si __builtin_ia32_si256_si (v4si)
10464 v4df __builtin_ia32_sqrtpd256 (v4df)
10465 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
10466 v8sf __builtin_ia32_sqrtps256 (v8sf)
10467 void __builtin_ia32_storedqu256 (pchar,v32qi)
10468 void __builtin_ia32_storeupd256 (pdouble,v4df)
10469 void __builtin_ia32_storeups256 (pfloat,v8sf)
10470 v4df __builtin_ia32_subpd256 (v4df,v4df)
10471 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
10472 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
10473 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
10474 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
10475 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
10476 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
10477 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
10478 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
10479 v4sf __builtin_ia32_vbroadcastss (pcfloat)
10480 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
10481 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
10482 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
10483 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
10484 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
10485 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
10486 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
10487 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
10488 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
10489 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
10490 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
10491 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
10492 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
10493 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
10494 v2df __builtin_ia32_vpermilpd (v2df,int)
10495 v4df __builtin_ia32_vpermilpd256 (v4df,int)
10496 v4sf __builtin_ia32_vpermilps (v4sf,int)
10497 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
10498 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
10499 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
10500 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
10501 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
10502 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
10503 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
10504 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
10505 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
10506 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
10507 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
10508 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
10509 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
10510 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
10511 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
10512 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
10513 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
10514 void __builtin_ia32_vzeroall (void)
10515 void __builtin_ia32_vzeroupper (void)
10516 v4df __builtin_ia32_xorpd256 (v4df,v4df)
10517 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
10518 @end smallexample
10519
10520 The following built-in functions are available when @option{-mavx2} is
10521 used. All of them generate the machine instruction that is part of the
10522 name.
10523
10524 @smallexample
10525 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,v32qi,int)
10526 v32qi __builtin_ia32_pabsb256 (v32qi)
10527 v16hi __builtin_ia32_pabsw256 (v16hi)
10528 v8si __builtin_ia32_pabsd256 (v8si)
10529 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
10530 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
10531 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
10532 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
10533 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
10534 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
10535 v8si __builtin_ia32_paddd256 (v8si,v8si)
10536 v4di __builtin_ia32_paddq256 (v4di,v4di)
10537 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
10538 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
10539 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
10540 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
10541 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
10542 v4di __builtin_ia32_andsi256 (v4di,v4di)
10543 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
10544 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
10545 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
10546 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
10547 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
10548 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
10549 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
10550 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
10551 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
10552 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
10553 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
10554 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
10555 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
10556 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
10557 v8si __builtin_ia32_phaddd256 (v8si,v8si)
10558 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
10559 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
10560 v8si __builtin_ia32_phsubd256 (v8si,v8si)
10561 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
10562 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
10563 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
10564 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
10565 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
10566 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
10567 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
10568 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
10569 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
10570 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
10571 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
10572 v8si __builtin_ia32_pminsd256 (v8si,v8si)
10573 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
10574 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
10575 v8si __builtin_ia32_pminud256 (v8si,v8si)
10576 int __builtin_ia32_pmovmskb256 (v32qi)
10577 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
10578 v8si __builtin_ia32_pmovsxbd256 (v16qi)
10579 v4di __builtin_ia32_pmovsxbq256 (v16qi)
10580 v8si __builtin_ia32_pmovsxwd256 (v8hi)
10581 v4di __builtin_ia32_pmovsxwq256 (v8hi)
10582 v4di __builtin_ia32_pmovsxdq256 (v4si)
10583 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
10584 v8si __builtin_ia32_pmovzxbd256 (v16qi)
10585 v4di __builtin_ia32_pmovzxbq256 (v16qi)
10586 v8si __builtin_ia32_pmovzxwd256 (v8hi)
10587 v4di __builtin_ia32_pmovzxwq256 (v8hi)
10588 v4di __builtin_ia32_pmovzxdq256 (v4si)
10589 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
10590 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
10591 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
10592 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
10593 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
10594 v8si __builtin_ia32_pmulld256 (v8si,v8si)
10595 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
10596 v4di __builtin_ia32_por256 (v4di,v4di)
10597 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
10598 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
10599 v8si __builtin_ia32_pshufd256 (v8si,int)
10600 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
10601 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
10602 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
10603 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
10604 v8si __builtin_ia32_psignd256 (v8si,v8si)
10605 v4di __builtin_ia32_pslldqi256 (v4di,int)
10606 v16hi __builtin_ia32_psllwi256 (16hi,int)
10607 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
10608 v8si __builtin_ia32_pslldi256 (v8si,int)
10609 v8si __builtin_ia32_pslld256(v8si,v4si)
10610 v4di __builtin_ia32_psllqi256 (v4di,int)
10611 v4di __builtin_ia32_psllq256(v4di,v2di)
10612 v16hi __builtin_ia32_psrawi256 (v16hi,int)
10613 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
10614 v8si __builtin_ia32_psradi256 (v8si,int)
10615 v8si __builtin_ia32_psrad256 (v8si,v4si)
10616 v4di __builtin_ia32_psrldqi256 (v4di, int)
10617 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
10618 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
10619 v8si __builtin_ia32_psrldi256 (v8si,int)
10620 v8si __builtin_ia32_psrld256 (v8si,v4si)
10621 v4di __builtin_ia32_psrlqi256 (v4di,int)
10622 v4di __builtin_ia32_psrlq256(v4di,v2di)
10623 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
10624 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
10625 v8si __builtin_ia32_psubd256 (v8si,v8si)
10626 v4di __builtin_ia32_psubq256 (v4di,v4di)
10627 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
10628 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
10629 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
10630 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
10631 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
10632 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
10633 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
10634 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
10635 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
10636 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
10637 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
10638 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
10639 v4di __builtin_ia32_pxor256 (v4di,v4di)
10640 v4di __builtin_ia32_movntdqa256 (pv4di)
10641 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
10642 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
10643 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
10644 v4di __builtin_ia32_vbroadcastsi256 (v2di)
10645 v4si __builtin_ia32_pblendd128 (v4si,v4si)
10646 v8si __builtin_ia32_pblendd256 (v8si,v8si)
10647 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
10648 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
10649 v8si __builtin_ia32_pbroadcastd256 (v4si)
10650 v4di __builtin_ia32_pbroadcastq256 (v2di)
10651 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
10652 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
10653 v4si __builtin_ia32_pbroadcastd128 (v4si)
10654 v2di __builtin_ia32_pbroadcastq128 (v2di)
10655 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
10656 v4df __builtin_ia32_permdf256 (v4df,int)
10657 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
10658 v4di __builtin_ia32_permdi256 (v4di,int)
10659 v4di __builtin_ia32_permti256 (v4di,v4di,int)
10660 v4di __builtin_ia32_extract128i256 (v4di,int)
10661 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
10662 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
10663 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
10664 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
10665 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
10666 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
10667 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
10668 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
10669 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
10670 v8si __builtin_ia32_psllv8si (v8si,v8si)
10671 v4si __builtin_ia32_psllv4si (v4si,v4si)
10672 v4di __builtin_ia32_psllv4di (v4di,v4di)
10673 v2di __builtin_ia32_psllv2di (v2di,v2di)
10674 v8si __builtin_ia32_psrav8si (v8si,v8si)
10675 v4si __builtin_ia32_psrav4si (v4si,v4si)
10676 v8si __builtin_ia32_psrlv8si (v8si,v8si)
10677 v4si __builtin_ia32_psrlv4si (v4si,v4si)
10678 v4di __builtin_ia32_psrlv4di (v4di,v4di)
10679 v2di __builtin_ia32_psrlv2di (v2di,v2di)
10680 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
10681 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
10682 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
10683 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
10684 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
10685 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
10686 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
10687 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
10688 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
10689 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
10690 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
10691 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
10692 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
10693 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
10694 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
10695 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
10696 @end smallexample
10697
10698 The following built-in functions are available when @option{-maes} is
10699 used. All of them generate the machine instruction that is part of the
10700 name.
10701
10702 @smallexample
10703 v2di __builtin_ia32_aesenc128 (v2di, v2di)
10704 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
10705 v2di __builtin_ia32_aesdec128 (v2di, v2di)
10706 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
10707 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
10708 v2di __builtin_ia32_aesimc128 (v2di)
10709 @end smallexample
10710
10711 The following built-in function is available when @option{-mpclmul} is
10712 used.
10713
10714 @table @code
10715 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
10716 Generates the @code{pclmulqdq} machine instruction.
10717 @end table
10718
10719 The following built-in function is available when @option{-mfsgsbase} is
10720 used. All of them generate the machine instruction that is part of the
10721 name.
10722
10723 @smallexample
10724 unsigned int __builtin_ia32_rdfsbase32 (void)
10725 unsigned long long __builtin_ia32_rdfsbase64 (void)
10726 unsigned int __builtin_ia32_rdgsbase32 (void)
10727 unsigned long long __builtin_ia32_rdgsbase64 (void)
10728 void _writefsbase_u32 (unsigned int)
10729 void _writefsbase_u64 (unsigned long long)
10730 void _writegsbase_u32 (unsigned int)
10731 void _writegsbase_u64 (unsigned long long)
10732 @end smallexample
10733
10734 The following built-in function is available when @option{-mrdrnd} is
10735 used. All of them generate the machine instruction that is part of the
10736 name.
10737
10738 @smallexample
10739 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
10740 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
10741 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
10742 @end smallexample
10743
10744 The following built-in functions are available when @option{-msse4a} is used.
10745 All of them generate the machine instruction that is part of the name.
10746
10747 @smallexample
10748 void __builtin_ia32_movntsd (double *, v2df)
10749 void __builtin_ia32_movntss (float *, v4sf)
10750 v2di __builtin_ia32_extrq (v2di, v16qi)
10751 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
10752 v2di __builtin_ia32_insertq (v2di, v2di)
10753 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
10754 @end smallexample
10755
10756 The following built-in functions are available when @option{-mxop} is used.
10757 @smallexample
10758 v2df __builtin_ia32_vfrczpd (v2df)
10759 v4sf __builtin_ia32_vfrczps (v4sf)
10760 v2df __builtin_ia32_vfrczsd (v2df, v2df)
10761 v4sf __builtin_ia32_vfrczss (v4sf, v4sf)
10762 v4df __builtin_ia32_vfrczpd256 (v4df)
10763 v8sf __builtin_ia32_vfrczps256 (v8sf)
10764 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
10765 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
10766 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
10767 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
10768 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
10769 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
10770 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
10771 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
10772 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
10773 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
10774 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
10775 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
10776 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
10777 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
10778 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10779 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
10780 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
10781 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
10782 v4si __builtin_ia32_vpcomequd (v4si, v4si)
10783 v2di __builtin_ia32_vpcomequq (v2di, v2di)
10784 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
10785 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
10786 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
10787 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
10788 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
10789 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
10790 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
10791 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
10792 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
10793 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
10794 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
10795 v4si __builtin_ia32_vpcomged (v4si, v4si)
10796 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
10797 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
10798 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
10799 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
10800 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
10801 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
10802 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
10803 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
10804 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
10805 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
10806 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
10807 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
10808 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
10809 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
10810 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
10811 v4si __builtin_ia32_vpcomled (v4si, v4si)
10812 v2di __builtin_ia32_vpcomleq (v2di, v2di)
10813 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
10814 v4si __builtin_ia32_vpcomleud (v4si, v4si)
10815 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
10816 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
10817 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
10818 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
10819 v4si __builtin_ia32_vpcomltd (v4si, v4si)
10820 v2di __builtin_ia32_vpcomltq (v2di, v2di)
10821 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
10822 v4si __builtin_ia32_vpcomltud (v4si, v4si)
10823 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
10824 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
10825 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
10826 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
10827 v4si __builtin_ia32_vpcomned (v4si, v4si)
10828 v2di __builtin_ia32_vpcomneq (v2di, v2di)
10829 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
10830 v4si __builtin_ia32_vpcomneud (v4si, v4si)
10831 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
10832 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
10833 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
10834 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
10835 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
10836 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
10837 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
10838 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
10839 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
10840 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
10841 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
10842 v4si __builtin_ia32_vphaddbd (v16qi)
10843 v2di __builtin_ia32_vphaddbq (v16qi)
10844 v8hi __builtin_ia32_vphaddbw (v16qi)
10845 v2di __builtin_ia32_vphadddq (v4si)
10846 v4si __builtin_ia32_vphaddubd (v16qi)
10847 v2di __builtin_ia32_vphaddubq (v16qi)
10848 v8hi __builtin_ia32_vphaddubw (v16qi)
10849 v2di __builtin_ia32_vphaddudq (v4si)
10850 v4si __builtin_ia32_vphadduwd (v8hi)
10851 v2di __builtin_ia32_vphadduwq (v8hi)
10852 v4si __builtin_ia32_vphaddwd (v8hi)
10853 v2di __builtin_ia32_vphaddwq (v8hi)
10854 v8hi __builtin_ia32_vphsubbw (v16qi)
10855 v2di __builtin_ia32_vphsubdq (v4si)
10856 v4si __builtin_ia32_vphsubwd (v8hi)
10857 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
10858 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
10859 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
10860 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
10861 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
10862 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
10863 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
10864 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
10865 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
10866 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
10867 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
10868 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
10869 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
10870 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
10871 v4si __builtin_ia32_vprotd (v4si, v4si)
10872 v2di __builtin_ia32_vprotq (v2di, v2di)
10873 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
10874 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
10875 v4si __builtin_ia32_vpshad (v4si, v4si)
10876 v2di __builtin_ia32_vpshaq (v2di, v2di)
10877 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
10878 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
10879 v4si __builtin_ia32_vpshld (v4si, v4si)
10880 v2di __builtin_ia32_vpshlq (v2di, v2di)
10881 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
10882 @end smallexample
10883
10884 The following built-in functions are available when @option{-mfma4} is used.
10885 All of them generate the machine instruction that is part of the name
10886 with MMX registers.
10887
10888 @smallexample
10889 v2df __builtin_ia32_fmaddpd (v2df, v2df, v2df)
10890 v4sf __builtin_ia32_fmaddps (v4sf, v4sf, v4sf)
10891 v2df __builtin_ia32_fmaddsd (v2df, v2df, v2df)
10892 v4sf __builtin_ia32_fmaddss (v4sf, v4sf, v4sf)
10893 v2df __builtin_ia32_fmsubpd (v2df, v2df, v2df)
10894 v4sf __builtin_ia32_fmsubps (v4sf, v4sf, v4sf)
10895 v2df __builtin_ia32_fmsubsd (v2df, v2df, v2df)
10896 v4sf __builtin_ia32_fmsubss (v4sf, v4sf, v4sf)
10897 v2df __builtin_ia32_fnmaddpd (v2df, v2df, v2df)
10898 v4sf __builtin_ia32_fnmaddps (v4sf, v4sf, v4sf)
10899 v2df __builtin_ia32_fnmaddsd (v2df, v2df, v2df)
10900 v4sf __builtin_ia32_fnmaddss (v4sf, v4sf, v4sf)
10901 v2df __builtin_ia32_fnmsubpd (v2df, v2df, v2df)
10902 v4sf __builtin_ia32_fnmsubps (v4sf, v4sf, v4sf)
10903 v2df __builtin_ia32_fnmsubsd (v2df, v2df, v2df)
10904 v4sf __builtin_ia32_fnmsubss (v4sf, v4sf, v4sf)
10905 v2df __builtin_ia32_fmaddsubpd (v2df, v2df, v2df)
10906 v4sf __builtin_ia32_fmaddsubps (v4sf, v4sf, v4sf)
10907 v2df __builtin_ia32_fmsubaddpd (v2df, v2df, v2df)
10908 v4sf __builtin_ia32_fmsubaddps (v4sf, v4sf, v4sf)
10909 v4df __builtin_ia32_fmaddpd256 (v4df, v4df, v4df)
10910 v8sf __builtin_ia32_fmaddps256 (v8sf, v8sf, v8sf)
10911 v4df __builtin_ia32_fmsubpd256 (v4df, v4df, v4df)
10912 v8sf __builtin_ia32_fmsubps256 (v8sf, v8sf, v8sf)
10913 v4df __builtin_ia32_fnmaddpd256 (v4df, v4df, v4df)
10914 v8sf __builtin_ia32_fnmaddps256 (v8sf, v8sf, v8sf)
10915 v4df __builtin_ia32_fnmsubpd256 (v4df, v4df, v4df)
10916 v8sf __builtin_ia32_fnmsubps256 (v8sf, v8sf, v8sf)
10917 v4df __builtin_ia32_fmaddsubpd256 (v4df, v4df, v4df)
10918 v8sf __builtin_ia32_fmaddsubps256 (v8sf, v8sf, v8sf)
10919 v4df __builtin_ia32_fmsubaddpd256 (v4df, v4df, v4df)
10920 v8sf __builtin_ia32_fmsubaddps256 (v8sf, v8sf, v8sf)
10921
10922 @end smallexample
10923
10924 The following built-in functions are available when @option{-mlwp} is used.
10925
10926 @smallexample
10927 void __builtin_ia32_llwpcb16 (void *);
10928 void __builtin_ia32_llwpcb32 (void *);
10929 void __builtin_ia32_llwpcb64 (void *);
10930 void * __builtin_ia32_llwpcb16 (void);
10931 void * __builtin_ia32_llwpcb32 (void);
10932 void * __builtin_ia32_llwpcb64 (void);
10933 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
10934 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
10935 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
10936 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
10937 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
10938 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
10939 @end smallexample
10940
10941 The following built-in functions are available when @option{-mbmi} is used.
10942 All of them generate the machine instruction that is part of the name.
10943 @smallexample
10944 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
10945 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
10946 @end smallexample
10947
10948 The following built-in functions are available when @option{-mbmi2} is used.
10949 All of them generate the machine instruction that is part of the name.
10950 @smallexample
10951 unsigned int _bzhi_u32 (unsigned int, unsigned int)
10952 unsigned int _pdep_u32 (unsigned int, unsigned int)
10953 unsigned int _pext_u32 (unsigned int, unsigned int)
10954 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
10955 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
10956 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
10957 @end smallexample
10958
10959 The following built-in functions are available when @option{-mlzcnt} is used.
10960 All of them generate the machine instruction that is part of the name.
10961 @smallexample
10962 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
10963 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
10964 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
10965 @end smallexample
10966
10967 The following built-in functions are available when @option{-mtbm} is used.
10968 Both of them generate the immediate form of the bextr machine instruction.
10969 @smallexample
10970 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
10971 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
10972 @end smallexample
10973
10974
10975 The following built-in functions are available when @option{-m3dnow} is used.
10976 All of them generate the machine instruction that is part of the name.
10977
10978 @smallexample
10979 void __builtin_ia32_femms (void)
10980 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
10981 v2si __builtin_ia32_pf2id (v2sf)
10982 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
10983 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
10984 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
10985 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
10986 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
10987 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
10988 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
10989 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
10990 v2sf __builtin_ia32_pfrcp (v2sf)
10991 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
10992 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
10993 v2sf __builtin_ia32_pfrsqrt (v2sf)
10994 v2sf __builtin_ia32_pfrsqrtit1 (v2sf, v2sf)
10995 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
10996 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
10997 v2sf __builtin_ia32_pi2fd (v2si)
10998 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
10999 @end smallexample
11000
11001 The following built-in functions are available when both @option{-m3dnow}
11002 and @option{-march=athlon} are used. All of them generate the machine
11003 instruction that is part of the name.
11004
11005 @smallexample
11006 v2si __builtin_ia32_pf2iw (v2sf)
11007 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
11008 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
11009 v2sf __builtin_ia32_pi2fw (v2si)
11010 v2sf __builtin_ia32_pswapdsf (v2sf)
11011 v2si __builtin_ia32_pswapdsi (v2si)
11012 @end smallexample
11013
11014 The following built-in functions are available when @option{-mrtm} is used
11015 They are used for restricted transactional memory. These are the internal
11016 low level functions. Normally the functions in
11017 @ref{X86 transactional memory intrinsics} should be used instead.
11018
11019 @smallexample
11020 int __builtin_ia32_xbegin ()
11021 void __builtin_ia32_xend ()
11022 void __builtin_ia32_xabort (status)
11023 int __builtin_ia32_xtest ()
11024 @end smallexample
11025
11026 @node X86 transactional memory intrinsics
11027 @subsection X86 transaction memory intrinsics
11028
11029 Hardware transactional memory intrinsics for i386. These allow to use
11030 memory transactions with RTM (Restricted Transactional Memory).
11031 For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
11032 This support is enabled with the @option{-mrtm} option.
11033
11034 A memory transaction commits all changes to memory in an atomic way,
11035 as visible to other threads. If the transaction fails it is rolled back
11036 and all side effects discarded.
11037
11038 Generally there is no guarantee that a memory transaction ever suceeds
11039 and suitable fallback code always needs to be supplied.
11040
11041 @deftypefn {RTM Function} {unsigned} _xbegin ()
11042 Start a RTM (Restricted Transactional Memory) transaction.
11043 Returns _XBEGIN_STARTED when the transaction
11044 started successfully (note this is not 0, so the constant has to be
11045 explicitely tested). When the transaction aborts all side effects
11046 are undone and an abort code is returned. There is no guarantee
11047 any transaction ever succeeds, so there always needs to be a valid
11048 tested fallback path.
11049 @end deftypefn
11050
11051 @smallexample
11052 #include <immintrin.h>
11053
11054 if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
11055 ... transaction code...
11056 _xend ();
11057 @} else @{
11058 ... non transactional fallback path...
11059 @}
11060 @end smallexample
11061
11062 Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
11063
11064 @table @code
11065 @item _XABORT_EXPLICIT
11066 Transaction explicitely aborted with @code{_xabort}. The parameter passed
11067 to @code{_xabort} is available with @code{_XABORT_CODE(status)}
11068 @item _XABORT_RETRY
11069 Transaction retry is possible.
11070 @item _XABORT_CONFLICT
11071 Transaction abort due to a memory conflict with another thread
11072 @item _XABORT_CAPACITY
11073 Transaction abort due to the transaction using too much memory
11074 @item _XABORT_DEBUG
11075 Transaction abort due to a debug trap
11076 @item _XABORT_NESTED
11077 Transaction abort in a inner nested transaction
11078 @end table
11079
11080 @deftypefn {RTM Function} {void} _xend ()
11081 Commit the current transaction. When no transaction is active this will
11082 fault. All memory side effects of the transactions will become visible
11083 to other threads in an atomic matter.
11084 @end deftypefn
11085
11086 @deftypefn {RTM Function} {int} _xtest ()
11087 Return a value not zero when a transaction is currently active, otherwise 0.
11088 @end deftypefn
11089
11090 @deftypefn {RTM Function} {void} _xabort (status)
11091 Abort the current transaction. When no transaction is active this is a no-op.
11092 status must be a 8bit constant, that is included in the status code returned
11093 by @code{_xbegin}
11094 @end deftypefn
11095
11096 @node MIPS DSP Built-in Functions
11097 @subsection MIPS DSP Built-in Functions
11098
11099 The MIPS DSP Application-Specific Extension (ASE) includes new
11100 instructions that are designed to improve the performance of DSP and
11101 media applications. It provides instructions that operate on packed
11102 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
11103
11104 GCC supports MIPS DSP operations using both the generic
11105 vector extensions (@pxref{Vector Extensions}) and a collection of
11106 MIPS-specific built-in functions. Both kinds of support are
11107 enabled by the @option{-mdsp} command-line option.
11108
11109 Revision 2 of the ASE was introduced in the second half of 2006.
11110 This revision adds extra instructions to the original ASE, but is
11111 otherwise backwards-compatible with it. You can select revision 2
11112 using the command-line option @option{-mdspr2}; this option implies
11113 @option{-mdsp}.
11114
11115 The SCOUNT and POS bits of the DSP control register are global. The
11116 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
11117 POS bits. During optimization, the compiler does not delete these
11118 instructions and it does not delete calls to functions containing
11119 these instructions.
11120
11121 At present, GCC only provides support for operations on 32-bit
11122 vectors. The vector type associated with 8-bit integer data is
11123 usually called @code{v4i8}, the vector type associated with Q7
11124 is usually called @code{v4q7}, the vector type associated with 16-bit
11125 integer data is usually called @code{v2i16}, and the vector type
11126 associated with Q15 is usually called @code{v2q15}. They can be
11127 defined in C as follows:
11128
11129 @smallexample
11130 typedef signed char v4i8 __attribute__ ((vector_size(4)));
11131 typedef signed char v4q7 __attribute__ ((vector_size(4)));
11132 typedef short v2i16 __attribute__ ((vector_size(4)));
11133 typedef short v2q15 __attribute__ ((vector_size(4)));
11134 @end smallexample
11135
11136 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
11137 initialized in the same way as aggregates. For example:
11138
11139 @smallexample
11140 v4i8 a = @{1, 2, 3, 4@};
11141 v4i8 b;
11142 b = (v4i8) @{5, 6, 7, 8@};
11143
11144 v2q15 c = @{0x0fcb, 0x3a75@};
11145 v2q15 d;
11146 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
11147 @end smallexample
11148
11149 @emph{Note:} The CPU's endianness determines the order in which values
11150 are packed. On little-endian targets, the first value is the least
11151 significant and the last value is the most significant. The opposite
11152 order applies to big-endian targets. For example, the code above
11153 sets the lowest byte of @code{a} to @code{1} on little-endian targets
11154 and @code{4} on big-endian targets.
11155
11156 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
11157 representation. As shown in this example, the integer representation
11158 of a Q7 value can be obtained by multiplying the fractional value by
11159 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
11160 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
11161 @code{0x1.0p31}.
11162
11163 The table below lists the @code{v4i8} and @code{v2q15} operations for which
11164 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
11165 and @code{c} and @code{d} are @code{v2q15} values.
11166
11167 @multitable @columnfractions .50 .50
11168 @item C code @tab MIPS instruction
11169 @item @code{a + b} @tab @code{addu.qb}
11170 @item @code{c + d} @tab @code{addq.ph}
11171 @item @code{a - b} @tab @code{subu.qb}
11172 @item @code{c - d} @tab @code{subq.ph}
11173 @end multitable
11174
11175 The table below lists the @code{v2i16} operation for which
11176 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
11177 @code{v2i16} values.
11178
11179 @multitable @columnfractions .50 .50
11180 @item C code @tab MIPS instruction
11181 @item @code{e * f} @tab @code{mul.ph}
11182 @end multitable
11183
11184 It is easier to describe the DSP built-in functions if we first define
11185 the following types:
11186
11187 @smallexample
11188 typedef int q31;
11189 typedef int i32;
11190 typedef unsigned int ui32;
11191 typedef long long a64;
11192 @end smallexample
11193
11194 @code{q31} and @code{i32} are actually the same as @code{int}, but we
11195 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
11196 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
11197 @code{long long}, but we use @code{a64} to indicate values that are
11198 placed in one of the four DSP accumulators (@code{$ac0},
11199 @code{$ac1}, @code{$ac2} or @code{$ac3}).
11200
11201 Also, some built-in functions prefer or require immediate numbers as
11202 parameters, because the corresponding DSP instructions accept both immediate
11203 numbers and register operands, or accept immediate numbers only. The
11204 immediate parameters are listed as follows.
11205
11206 @smallexample
11207 imm0_3: 0 to 3.
11208 imm0_7: 0 to 7.
11209 imm0_15: 0 to 15.
11210 imm0_31: 0 to 31.
11211 imm0_63: 0 to 63.
11212 imm0_255: 0 to 255.
11213 imm_n32_31: -32 to 31.
11214 imm_n512_511: -512 to 511.
11215 @end smallexample
11216
11217 The following built-in functions map directly to a particular MIPS DSP
11218 instruction. Please refer to the architecture specification
11219 for details on what each instruction does.
11220
11221 @smallexample
11222 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
11223 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
11224 q31 __builtin_mips_addq_s_w (q31, q31)
11225 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
11226 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
11227 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
11228 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
11229 q31 __builtin_mips_subq_s_w (q31, q31)
11230 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
11231 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
11232 i32 __builtin_mips_addsc (i32, i32)
11233 i32 __builtin_mips_addwc (i32, i32)
11234 i32 __builtin_mips_modsub (i32, i32)
11235 i32 __builtin_mips_raddu_w_qb (v4i8)
11236 v2q15 __builtin_mips_absq_s_ph (v2q15)
11237 q31 __builtin_mips_absq_s_w (q31)
11238 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
11239 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
11240 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
11241 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
11242 q31 __builtin_mips_preceq_w_phl (v2q15)
11243 q31 __builtin_mips_preceq_w_phr (v2q15)
11244 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
11245 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
11246 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
11247 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
11248 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
11249 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
11250 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
11251 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
11252 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
11253 v4i8 __builtin_mips_shll_qb (v4i8, i32)
11254 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
11255 v2q15 __builtin_mips_shll_ph (v2q15, i32)
11256 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
11257 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
11258 q31 __builtin_mips_shll_s_w (q31, imm0_31)
11259 q31 __builtin_mips_shll_s_w (q31, i32)
11260 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
11261 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
11262 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
11263 v2q15 __builtin_mips_shra_ph (v2q15, i32)
11264 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
11265 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
11266 q31 __builtin_mips_shra_r_w (q31, imm0_31)
11267 q31 __builtin_mips_shra_r_w (q31, i32)
11268 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
11269 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
11270 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
11271 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
11272 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
11273 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
11274 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
11275 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
11276 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
11277 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
11278 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
11279 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
11280 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
11281 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
11282 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
11283 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
11284 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
11285 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
11286 i32 __builtin_mips_bitrev (i32)
11287 i32 __builtin_mips_insv (i32, i32)
11288 v4i8 __builtin_mips_repl_qb (imm0_255)
11289 v4i8 __builtin_mips_repl_qb (i32)
11290 v2q15 __builtin_mips_repl_ph (imm_n512_511)
11291 v2q15 __builtin_mips_repl_ph (i32)
11292 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
11293 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
11294 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
11295 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
11296 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
11297 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
11298 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
11299 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
11300 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
11301 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
11302 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
11303 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
11304 i32 __builtin_mips_extr_w (a64, imm0_31)
11305 i32 __builtin_mips_extr_w (a64, i32)
11306 i32 __builtin_mips_extr_r_w (a64, imm0_31)
11307 i32 __builtin_mips_extr_s_h (a64, i32)
11308 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
11309 i32 __builtin_mips_extr_rs_w (a64, i32)
11310 i32 __builtin_mips_extr_s_h (a64, imm0_31)
11311 i32 __builtin_mips_extr_r_w (a64, i32)
11312 i32 __builtin_mips_extp (a64, imm0_31)
11313 i32 __builtin_mips_extp (a64, i32)
11314 i32 __builtin_mips_extpdp (a64, imm0_31)
11315 i32 __builtin_mips_extpdp (a64, i32)
11316 a64 __builtin_mips_shilo (a64, imm_n32_31)
11317 a64 __builtin_mips_shilo (a64, i32)
11318 a64 __builtin_mips_mthlip (a64, i32)
11319 void __builtin_mips_wrdsp (i32, imm0_63)
11320 i32 __builtin_mips_rddsp (imm0_63)
11321 i32 __builtin_mips_lbux (void *, i32)
11322 i32 __builtin_mips_lhx (void *, i32)
11323 i32 __builtin_mips_lwx (void *, i32)
11324 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
11325 i32 __builtin_mips_bposge32 (void)
11326 a64 __builtin_mips_madd (a64, i32, i32);
11327 a64 __builtin_mips_maddu (a64, ui32, ui32);
11328 a64 __builtin_mips_msub (a64, i32, i32);
11329 a64 __builtin_mips_msubu (a64, ui32, ui32);
11330 a64 __builtin_mips_mult (i32, i32);
11331 a64 __builtin_mips_multu (ui32, ui32);
11332 @end smallexample
11333
11334 The following built-in functions map directly to a particular MIPS DSP REV 2
11335 instruction. Please refer to the architecture specification
11336 for details on what each instruction does.
11337
11338 @smallexample
11339 v4q7 __builtin_mips_absq_s_qb (v4q7);
11340 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
11341 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
11342 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
11343 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
11344 i32 __builtin_mips_append (i32, i32, imm0_31);
11345 i32 __builtin_mips_balign (i32, i32, imm0_3);
11346 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
11347 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
11348 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
11349 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
11350 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
11351 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
11352 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
11353 q31 __builtin_mips_mulq_rs_w (q31, q31);
11354 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
11355 q31 __builtin_mips_mulq_s_w (q31, q31);
11356 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
11357 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
11358 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
11359 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
11360 i32 __builtin_mips_prepend (i32, i32, imm0_31);
11361 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
11362 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
11363 v4i8 __builtin_mips_shra_qb (v4i8, i32);
11364 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
11365 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
11366 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
11367 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
11368 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
11369 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
11370 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
11371 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
11372 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
11373 q31 __builtin_mips_addqh_w (q31, q31);
11374 q31 __builtin_mips_addqh_r_w (q31, q31);
11375 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
11376 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
11377 q31 __builtin_mips_subqh_w (q31, q31);
11378 q31 __builtin_mips_subqh_r_w (q31, q31);
11379 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
11380 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
11381 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
11382 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
11383 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
11384 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
11385 @end smallexample
11386
11387
11388 @node MIPS Paired-Single Support
11389 @subsection MIPS Paired-Single Support
11390
11391 The MIPS64 architecture includes a number of instructions that
11392 operate on pairs of single-precision floating-point values.
11393 Each pair is packed into a 64-bit floating-point register,
11394 with one element being designated the ``upper half'' and
11395 the other being designated the ``lower half''.
11396
11397 GCC supports paired-single operations using both the generic
11398 vector extensions (@pxref{Vector Extensions}) and a collection of
11399 MIPS-specific built-in functions. Both kinds of support are
11400 enabled by the @option{-mpaired-single} command-line option.
11401
11402 The vector type associated with paired-single values is usually
11403 called @code{v2sf}. It can be defined in C as follows:
11404
11405 @smallexample
11406 typedef float v2sf __attribute__ ((vector_size (8)));
11407 @end smallexample
11408
11409 @code{v2sf} values are initialized in the same way as aggregates.
11410 For example:
11411
11412 @smallexample
11413 v2sf a = @{1.5, 9.1@};
11414 v2sf b;
11415 float e, f;
11416 b = (v2sf) @{e, f@};
11417 @end smallexample
11418
11419 @emph{Note:} The CPU's endianness determines which value is stored in
11420 the upper half of a register and which value is stored in the lower half.
11421 On little-endian targets, the first value is the lower one and the second
11422 value is the upper one. The opposite order applies to big-endian targets.
11423 For example, the code above sets the lower half of @code{a} to
11424 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
11425
11426 @node MIPS Loongson Built-in Functions
11427 @subsection MIPS Loongson Built-in Functions
11428
11429 GCC provides intrinsics to access the SIMD instructions provided by the
11430 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
11431 available after inclusion of the @code{loongson.h} header file,
11432 operate on the following 64-bit vector types:
11433
11434 @itemize
11435 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
11436 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
11437 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
11438 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
11439 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
11440 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
11441 @end itemize
11442
11443 The intrinsics provided are listed below; each is named after the
11444 machine instruction to which it corresponds, with suffixes added as
11445 appropriate to distinguish intrinsics that expand to the same machine
11446 instruction yet have different argument types. Refer to the architecture
11447 documentation for a description of the functionality of each
11448 instruction.
11449
11450 @smallexample
11451 int16x4_t packsswh (int32x2_t s, int32x2_t t);
11452 int8x8_t packsshb (int16x4_t s, int16x4_t t);
11453 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
11454 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
11455 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
11456 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
11457 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
11458 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
11459 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
11460 uint64_t paddd_u (uint64_t s, uint64_t t);
11461 int64_t paddd_s (int64_t s, int64_t t);
11462 int16x4_t paddsh (int16x4_t s, int16x4_t t);
11463 int8x8_t paddsb (int8x8_t s, int8x8_t t);
11464 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
11465 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
11466 uint64_t pandn_ud (uint64_t s, uint64_t t);
11467 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
11468 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
11469 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
11470 int64_t pandn_sd (int64_t s, int64_t t);
11471 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
11472 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
11473 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
11474 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
11475 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
11476 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
11477 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
11478 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
11479 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
11480 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
11481 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
11482 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
11483 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
11484 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
11485 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
11486 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
11487 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
11488 uint16x4_t pextrh_u (uint16x4_t s, int field);
11489 int16x4_t pextrh_s (int16x4_t s, int field);
11490 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
11491 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
11492 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
11493 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
11494 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
11495 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
11496 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
11497 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
11498 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
11499 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
11500 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
11501 int16x4_t pminsh (int16x4_t s, int16x4_t t);
11502 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
11503 uint8x8_t pmovmskb_u (uint8x8_t s);
11504 int8x8_t pmovmskb_s (int8x8_t s);
11505 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
11506 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
11507 int16x4_t pmullh (int16x4_t s, int16x4_t t);
11508 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
11509 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
11510 uint16x4_t biadd (uint8x8_t s);
11511 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
11512 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
11513 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
11514 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
11515 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
11516 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
11517 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
11518 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
11519 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
11520 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
11521 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
11522 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
11523 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
11524 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
11525 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
11526 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
11527 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
11528 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
11529 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
11530 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
11531 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
11532 uint64_t psubd_u (uint64_t s, uint64_t t);
11533 int64_t psubd_s (int64_t s, int64_t t);
11534 int16x4_t psubsh (int16x4_t s, int16x4_t t);
11535 int8x8_t psubsb (int8x8_t s, int8x8_t t);
11536 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
11537 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
11538 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
11539 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
11540 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
11541 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
11542 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
11543 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
11544 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
11545 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
11546 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
11547 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
11548 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
11549 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
11550 @end smallexample
11551
11552 @menu
11553 * Paired-Single Arithmetic::
11554 * Paired-Single Built-in Functions::
11555 * MIPS-3D Built-in Functions::
11556 @end menu
11557
11558 @node Paired-Single Arithmetic
11559 @subsubsection Paired-Single Arithmetic
11560
11561 The table below lists the @code{v2sf} operations for which hardware
11562 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
11563 values and @code{x} is an integral value.
11564
11565 @multitable @columnfractions .50 .50
11566 @item C code @tab MIPS instruction
11567 @item @code{a + b} @tab @code{add.ps}
11568 @item @code{a - b} @tab @code{sub.ps}
11569 @item @code{-a} @tab @code{neg.ps}
11570 @item @code{a * b} @tab @code{mul.ps}
11571 @item @code{a * b + c} @tab @code{madd.ps}
11572 @item @code{a * b - c} @tab @code{msub.ps}
11573 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
11574 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
11575 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
11576 @end multitable
11577
11578 Note that the multiply-accumulate instructions can be disabled
11579 using the command-line option @code{-mno-fused-madd}.
11580
11581 @node Paired-Single Built-in Functions
11582 @subsubsection Paired-Single Built-in Functions
11583
11584 The following paired-single functions map directly to a particular
11585 MIPS instruction. Please refer to the architecture specification
11586 for details on what each instruction does.
11587
11588 @table @code
11589 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
11590 Pair lower lower (@code{pll.ps}).
11591
11592 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
11593 Pair upper lower (@code{pul.ps}).
11594
11595 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
11596 Pair lower upper (@code{plu.ps}).
11597
11598 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
11599 Pair upper upper (@code{puu.ps}).
11600
11601 @item v2sf __builtin_mips_cvt_ps_s (float, float)
11602 Convert pair to paired single (@code{cvt.ps.s}).
11603
11604 @item float __builtin_mips_cvt_s_pl (v2sf)
11605 Convert pair lower to single (@code{cvt.s.pl}).
11606
11607 @item float __builtin_mips_cvt_s_pu (v2sf)
11608 Convert pair upper to single (@code{cvt.s.pu}).
11609
11610 @item v2sf __builtin_mips_abs_ps (v2sf)
11611 Absolute value (@code{abs.ps}).
11612
11613 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
11614 Align variable (@code{alnv.ps}).
11615
11616 @emph{Note:} The value of the third parameter must be 0 or 4
11617 modulo 8, otherwise the result is unpredictable. Please read the
11618 instruction description for details.
11619 @end table
11620
11621 The following multi-instruction functions are also available.
11622 In each case, @var{cond} can be any of the 16 floating-point conditions:
11623 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11624 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
11625 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11626
11627 @table @code
11628 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11629 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11630 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
11631 @code{movt.ps}/@code{movf.ps}).
11632
11633 The @code{movt} functions return the value @var{x} computed by:
11634
11635 @smallexample
11636 c.@var{cond}.ps @var{cc},@var{a},@var{b}
11637 mov.ps @var{x},@var{c}
11638 movt.ps @var{x},@var{d},@var{cc}
11639 @end smallexample
11640
11641 The @code{movf} functions are similar but use @code{movf.ps} instead
11642 of @code{movt.ps}.
11643
11644 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11645 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11646 Comparison of two paired-single values (@code{c.@var{cond}.ps},
11647 @code{bc1t}/@code{bc1f}).
11648
11649 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11650 and return either the upper or lower half of the result. For example:
11651
11652 @smallexample
11653 v2sf a, b;
11654 if (__builtin_mips_upper_c_eq_ps (a, b))
11655 upper_halves_are_equal ();
11656 else
11657 upper_halves_are_unequal ();
11658
11659 if (__builtin_mips_lower_c_eq_ps (a, b))
11660 lower_halves_are_equal ();
11661 else
11662 lower_halves_are_unequal ();
11663 @end smallexample
11664 @end table
11665
11666 @node MIPS-3D Built-in Functions
11667 @subsubsection MIPS-3D Built-in Functions
11668
11669 The MIPS-3D Application-Specific Extension (ASE) includes additional
11670 paired-single instructions that are designed to improve the performance
11671 of 3D graphics operations. Support for these instructions is controlled
11672 by the @option{-mips3d} command-line option.
11673
11674 The functions listed below map directly to a particular MIPS-3D
11675 instruction. Please refer to the architecture specification for
11676 more details on what each instruction does.
11677
11678 @table @code
11679 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
11680 Reduction add (@code{addr.ps}).
11681
11682 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
11683 Reduction multiply (@code{mulr.ps}).
11684
11685 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
11686 Convert paired single to paired word (@code{cvt.pw.ps}).
11687
11688 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
11689 Convert paired word to paired single (@code{cvt.ps.pw}).
11690
11691 @item float __builtin_mips_recip1_s (float)
11692 @itemx double __builtin_mips_recip1_d (double)
11693 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
11694 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
11695
11696 @item float __builtin_mips_recip2_s (float, float)
11697 @itemx double __builtin_mips_recip2_d (double, double)
11698 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
11699 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
11700
11701 @item float __builtin_mips_rsqrt1_s (float)
11702 @itemx double __builtin_mips_rsqrt1_d (double)
11703 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
11704 Reduced-precision reciprocal square root (sequence step 1)
11705 (@code{rsqrt1.@var{fmt}}).
11706
11707 @item float __builtin_mips_rsqrt2_s (float, float)
11708 @itemx double __builtin_mips_rsqrt2_d (double, double)
11709 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
11710 Reduced-precision reciprocal square root (sequence step 2)
11711 (@code{rsqrt2.@var{fmt}}).
11712 @end table
11713
11714 The following multi-instruction functions are also available.
11715 In each case, @var{cond} can be any of the 16 floating-point conditions:
11716 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
11717 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
11718 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
11719
11720 @table @code
11721 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
11722 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
11723 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
11724 @code{bc1t}/@code{bc1f}).
11725
11726 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
11727 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
11728 For example:
11729
11730 @smallexample
11731 float a, b;
11732 if (__builtin_mips_cabs_eq_s (a, b))
11733 true ();
11734 else
11735 false ();
11736 @end smallexample
11737
11738 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11739 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11740 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
11741 @code{bc1t}/@code{bc1f}).
11742
11743 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
11744 and return either the upper or lower half of the result. For example:
11745
11746 @smallexample
11747 v2sf a, b;
11748 if (__builtin_mips_upper_cabs_eq_ps (a, b))
11749 upper_halves_are_equal ();
11750 else
11751 upper_halves_are_unequal ();
11752
11753 if (__builtin_mips_lower_cabs_eq_ps (a, b))
11754 lower_halves_are_equal ();
11755 else
11756 lower_halves_are_unequal ();
11757 @end smallexample
11758
11759 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11760 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11761 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
11762 @code{movt.ps}/@code{movf.ps}).
11763
11764 The @code{movt} functions return the value @var{x} computed by:
11765
11766 @smallexample
11767 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
11768 mov.ps @var{x},@var{c}
11769 movt.ps @var{x},@var{d},@var{cc}
11770 @end smallexample
11771
11772 The @code{movf} functions are similar but use @code{movf.ps} instead
11773 of @code{movt.ps}.
11774
11775 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11776 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11777 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11778 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
11779 Comparison of two paired-single values
11780 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11781 @code{bc1any2t}/@code{bc1any2f}).
11782
11783 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
11784 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
11785 result is true and the @code{all} forms return true if both results are true.
11786 For example:
11787
11788 @smallexample
11789 v2sf a, b;
11790 if (__builtin_mips_any_c_eq_ps (a, b))
11791 one_is_true ();
11792 else
11793 both_are_false ();
11794
11795 if (__builtin_mips_all_c_eq_ps (a, b))
11796 both_are_true ();
11797 else
11798 one_is_false ();
11799 @end smallexample
11800
11801 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11802 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11803 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11804 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
11805 Comparison of four paired-single values
11806 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
11807 @code{bc1any4t}/@code{bc1any4f}).
11808
11809 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
11810 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
11811 The @code{any} forms return true if any of the four results are true
11812 and the @code{all} forms return true if all four results are true.
11813 For example:
11814
11815 @smallexample
11816 v2sf a, b, c, d;
11817 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
11818 some_are_true ();
11819 else
11820 all_are_false ();
11821
11822 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
11823 all_are_true ();
11824 else
11825 some_are_false ();
11826 @end smallexample
11827 @end table
11828
11829 @node Other MIPS Built-in Functions
11830 @subsection Other MIPS Built-in Functions
11831
11832 GCC provides other MIPS-specific built-in functions:
11833
11834 @table @code
11835 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
11836 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
11837 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
11838 when this function is available.
11839 @end table
11840
11841 @node picoChip Built-in Functions
11842 @subsection picoChip Built-in Functions
11843
11844 GCC provides an interface to selected machine instructions from the
11845 picoChip instruction set.
11846
11847 @table @code
11848 @item int __builtin_sbc (int @var{value})
11849 Sign bit count. Return the number of consecutive bits in @var{value}
11850 that have the same value as the sign bit. The result is the number of
11851 leading sign bits minus one, giving the number of redundant sign bits in
11852 @var{value}.
11853
11854 @item int __builtin_byteswap (int @var{value})
11855 Byte swap. Return the result of swapping the upper and lower bytes of
11856 @var{value}.
11857
11858 @item int __builtin_brev (int @var{value})
11859 Bit reversal. Return the result of reversing the bits in
11860 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
11861 and so on.
11862
11863 @item int __builtin_adds (int @var{x}, int @var{y})
11864 Saturating addition. Return the result of adding @var{x} and @var{y},
11865 storing the value 32767 if the result overflows.
11866
11867 @item int __builtin_subs (int @var{x}, int @var{y})
11868 Saturating subtraction. Return the result of subtracting @var{y} from
11869 @var{x}, storing the value @minus{}32768 if the result overflows.
11870
11871 @item void __builtin_halt (void)
11872 Halt. The processor stops execution. This built-in is useful for
11873 implementing assertions.
11874
11875 @end table
11876
11877 @node PowerPC Built-in Functions
11878 @subsection PowerPC Built-in Functions
11879
11880 These built-in functions are available for the PowerPC family of
11881 processors:
11882 @smallexample
11883 float __builtin_recipdivf (float, float);
11884 float __builtin_rsqrtf (float);
11885 double __builtin_recipdiv (double, double);
11886 double __builtin_rsqrt (double);
11887 long __builtin_bpermd (long, long);
11888 uint64_t __builtin_ppc_get_timebase ();
11889 unsigned long __builtin_ppc_mftb ();
11890 @end smallexample
11891
11892 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
11893 @code{__builtin_rsqrtf} functions generate multiple instructions to
11894 implement the reciprocal sqrt functionality using reciprocal sqrt
11895 estimate instructions.
11896
11897 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
11898 functions generate multiple instructions to implement division using
11899 the reciprocal estimate instructions.
11900
11901 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
11902 functions generate instructions to read the Time Base Register. The
11903 @code{__builtin_ppc_get_timebase} function may generate multiple
11904 instructions and always returns the 64 bits of the Time Base Register.
11905 The @code{__builtin_ppc_mftb} function always generates one instruction and
11906 returns the Time Base Register value as an unsigned long, throwing away
11907 the most significant word on 32-bit environments.
11908
11909 @node PowerPC AltiVec/VSX Built-in Functions
11910 @subsection PowerPC AltiVec Built-in Functions
11911
11912 GCC provides an interface for the PowerPC family of processors to access
11913 the AltiVec operations described in Motorola's AltiVec Programming
11914 Interface Manual. The interface is made available by including
11915 @code{<altivec.h>} and using @option{-maltivec} and
11916 @option{-mabi=altivec}. The interface supports the following vector
11917 types.
11918
11919 @smallexample
11920 vector unsigned char
11921 vector signed char
11922 vector bool char
11923
11924 vector unsigned short
11925 vector signed short
11926 vector bool short
11927 vector pixel
11928
11929 vector unsigned int
11930 vector signed int
11931 vector bool int
11932 vector float
11933 @end smallexample
11934
11935 If @option{-mvsx} is used the following additional vector types are
11936 implemented.
11937
11938 @smallexample
11939 vector unsigned long
11940 vector signed long
11941 vector double
11942 @end smallexample
11943
11944 The long types are only implemented for 64-bit code generation, and
11945 the long type is only used in the floating point/integer conversion
11946 instructions.
11947
11948 GCC's implementation of the high-level language interface available from
11949 C and C++ code differs from Motorola's documentation in several ways.
11950
11951 @itemize @bullet
11952
11953 @item
11954 A vector constant is a list of constant expressions within curly braces.
11955
11956 @item
11957 A vector initializer requires no cast if the vector constant is of the
11958 same type as the variable it is initializing.
11959
11960 @item
11961 If @code{signed} or @code{unsigned} is omitted, the signedness of the
11962 vector type is the default signedness of the base type. The default
11963 varies depending on the operating system, so a portable program should
11964 always specify the signedness.
11965
11966 @item
11967 Compiling with @option{-maltivec} adds keywords @code{__vector},
11968 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
11969 @code{bool}. When compiling ISO C, the context-sensitive substitution
11970 of the keywords @code{vector}, @code{pixel} and @code{bool} is
11971 disabled. To use them, you must include @code{<altivec.h>} instead.
11972
11973 @item
11974 GCC allows using a @code{typedef} name as the type specifier for a
11975 vector type.
11976
11977 @item
11978 For C, overloaded functions are implemented with macros so the following
11979 does not work:
11980
11981 @smallexample
11982 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
11983 @end smallexample
11984
11985 @noindent
11986 Since @code{vec_add} is a macro, the vector constant in the example
11987 is treated as four separate arguments. Wrap the entire argument in
11988 parentheses for this to work.
11989 @end itemize
11990
11991 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
11992 Internally, GCC uses built-in functions to achieve the functionality in
11993 the aforementioned header file, but they are not supported and are
11994 subject to change without notice.
11995
11996 The following interfaces are supported for the generic and specific
11997 AltiVec operations and the AltiVec predicates. In cases where there
11998 is a direct mapping between generic and specific operations, only the
11999 generic names are shown here, although the specific operations can also
12000 be used.
12001
12002 Arguments that are documented as @code{const int} require literal
12003 integral values within the range required for that operation.
12004
12005 @smallexample
12006 vector signed char vec_abs (vector signed char);
12007 vector signed short vec_abs (vector signed short);
12008 vector signed int vec_abs (vector signed int);
12009 vector float vec_abs (vector float);
12010
12011 vector signed char vec_abss (vector signed char);
12012 vector signed short vec_abss (vector signed short);
12013 vector signed int vec_abss (vector signed int);
12014
12015 vector signed char vec_add (vector bool char, vector signed char);
12016 vector signed char vec_add (vector signed char, vector bool char);
12017 vector signed char vec_add (vector signed char, vector signed char);
12018 vector unsigned char vec_add (vector bool char, vector unsigned char);
12019 vector unsigned char vec_add (vector unsigned char, vector bool char);
12020 vector unsigned char vec_add (vector unsigned char,
12021 vector unsigned char);
12022 vector signed short vec_add (vector bool short, vector signed short);
12023 vector signed short vec_add (vector signed short, vector bool short);
12024 vector signed short vec_add (vector signed short, vector signed short);
12025 vector unsigned short vec_add (vector bool short,
12026 vector unsigned short);
12027 vector unsigned short vec_add (vector unsigned short,
12028 vector bool short);
12029 vector unsigned short vec_add (vector unsigned short,
12030 vector unsigned short);
12031 vector signed int vec_add (vector bool int, vector signed int);
12032 vector signed int vec_add (vector signed int, vector bool int);
12033 vector signed int vec_add (vector signed int, vector signed int);
12034 vector unsigned int vec_add (vector bool int, vector unsigned int);
12035 vector unsigned int vec_add (vector unsigned int, vector bool int);
12036 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
12037 vector float vec_add (vector float, vector float);
12038
12039 vector float vec_vaddfp (vector float, vector float);
12040
12041 vector signed int vec_vadduwm (vector bool int, vector signed int);
12042 vector signed int vec_vadduwm (vector signed int, vector bool int);
12043 vector signed int vec_vadduwm (vector signed int, vector signed int);
12044 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
12045 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
12046 vector unsigned int vec_vadduwm (vector unsigned int,
12047 vector unsigned int);
12048
12049 vector signed short vec_vadduhm (vector bool short,
12050 vector signed short);
12051 vector signed short vec_vadduhm (vector signed short,
12052 vector bool short);
12053 vector signed short vec_vadduhm (vector signed short,
12054 vector signed short);
12055 vector unsigned short vec_vadduhm (vector bool short,
12056 vector unsigned short);
12057 vector unsigned short vec_vadduhm (vector unsigned short,
12058 vector bool short);
12059 vector unsigned short vec_vadduhm (vector unsigned short,
12060 vector unsigned short);
12061
12062 vector signed char vec_vaddubm (vector bool char, vector signed char);
12063 vector signed char vec_vaddubm (vector signed char, vector bool char);
12064 vector signed char vec_vaddubm (vector signed char, vector signed char);
12065 vector unsigned char vec_vaddubm (vector bool char,
12066 vector unsigned char);
12067 vector unsigned char vec_vaddubm (vector unsigned char,
12068 vector bool char);
12069 vector unsigned char vec_vaddubm (vector unsigned char,
12070 vector unsigned char);
12071
12072 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
12073
12074 vector unsigned char vec_adds (vector bool char, vector unsigned char);
12075 vector unsigned char vec_adds (vector unsigned char, vector bool char);
12076 vector unsigned char vec_adds (vector unsigned char,
12077 vector unsigned char);
12078 vector signed char vec_adds (vector bool char, vector signed char);
12079 vector signed char vec_adds (vector signed char, vector bool char);
12080 vector signed char vec_adds (vector signed char, vector signed char);
12081 vector unsigned short vec_adds (vector bool short,
12082 vector unsigned short);
12083 vector unsigned short vec_adds (vector unsigned short,
12084 vector bool short);
12085 vector unsigned short vec_adds (vector unsigned short,
12086 vector unsigned short);
12087 vector signed short vec_adds (vector bool short, vector signed short);
12088 vector signed short vec_adds (vector signed short, vector bool short);
12089 vector signed short vec_adds (vector signed short, vector signed short);
12090 vector unsigned int vec_adds (vector bool int, vector unsigned int);
12091 vector unsigned int vec_adds (vector unsigned int, vector bool int);
12092 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
12093 vector signed int vec_adds (vector bool int, vector signed int);
12094 vector signed int vec_adds (vector signed int, vector bool int);
12095 vector signed int vec_adds (vector signed int, vector signed int);
12096
12097 vector signed int vec_vaddsws (vector bool int, vector signed int);
12098 vector signed int vec_vaddsws (vector signed int, vector bool int);
12099 vector signed int vec_vaddsws (vector signed int, vector signed int);
12100
12101 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
12102 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
12103 vector unsigned int vec_vadduws (vector unsigned int,
12104 vector unsigned int);
12105
12106 vector signed short vec_vaddshs (vector bool short,
12107 vector signed short);
12108 vector signed short vec_vaddshs (vector signed short,
12109 vector bool short);
12110 vector signed short vec_vaddshs (vector signed short,
12111 vector signed short);
12112
12113 vector unsigned short vec_vadduhs (vector bool short,
12114 vector unsigned short);
12115 vector unsigned short vec_vadduhs (vector unsigned short,
12116 vector bool short);
12117 vector unsigned short vec_vadduhs (vector unsigned short,
12118 vector unsigned short);
12119
12120 vector signed char vec_vaddsbs (vector bool char, vector signed char);
12121 vector signed char vec_vaddsbs (vector signed char, vector bool char);
12122 vector signed char vec_vaddsbs (vector signed char, vector signed char);
12123
12124 vector unsigned char vec_vaddubs (vector bool char,
12125 vector unsigned char);
12126 vector unsigned char vec_vaddubs (vector unsigned char,
12127 vector bool char);
12128 vector unsigned char vec_vaddubs (vector unsigned char,
12129 vector unsigned char);
12130
12131 vector float vec_and (vector float, vector float);
12132 vector float vec_and (vector float, vector bool int);
12133 vector float vec_and (vector bool int, vector float);
12134 vector bool int vec_and (vector bool int, vector bool int);
12135 vector signed int vec_and (vector bool int, vector signed int);
12136 vector signed int vec_and (vector signed int, vector bool int);
12137 vector signed int vec_and (vector signed int, vector signed int);
12138 vector unsigned int vec_and (vector bool int, vector unsigned int);
12139 vector unsigned int vec_and (vector unsigned int, vector bool int);
12140 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
12141 vector bool short vec_and (vector bool short, vector bool short);
12142 vector signed short vec_and (vector bool short, vector signed short);
12143 vector signed short vec_and (vector signed short, vector bool short);
12144 vector signed short vec_and (vector signed short, vector signed short);
12145 vector unsigned short vec_and (vector bool short,
12146 vector unsigned short);
12147 vector unsigned short vec_and (vector unsigned short,
12148 vector bool short);
12149 vector unsigned short vec_and (vector unsigned short,
12150 vector unsigned short);
12151 vector signed char vec_and (vector bool char, vector signed char);
12152 vector bool char vec_and (vector bool char, vector bool char);
12153 vector signed char vec_and (vector signed char, vector bool char);
12154 vector signed char vec_and (vector signed char, vector signed char);
12155 vector unsigned char vec_and (vector bool char, vector unsigned char);
12156 vector unsigned char vec_and (vector unsigned char, vector bool char);
12157 vector unsigned char vec_and (vector unsigned char,
12158 vector unsigned char);
12159
12160 vector float vec_andc (vector float, vector float);
12161 vector float vec_andc (vector float, vector bool int);
12162 vector float vec_andc (vector bool int, vector float);
12163 vector bool int vec_andc (vector bool int, vector bool int);
12164 vector signed int vec_andc (vector bool int, vector signed int);
12165 vector signed int vec_andc (vector signed int, vector bool int);
12166 vector signed int vec_andc (vector signed int, vector signed int);
12167 vector unsigned int vec_andc (vector bool int, vector unsigned int);
12168 vector unsigned int vec_andc (vector unsigned int, vector bool int);
12169 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
12170 vector bool short vec_andc (vector bool short, vector bool short);
12171 vector signed short vec_andc (vector bool short, vector signed short);
12172 vector signed short vec_andc (vector signed short, vector bool short);
12173 vector signed short vec_andc (vector signed short, vector signed short);
12174 vector unsigned short vec_andc (vector bool short,
12175 vector unsigned short);
12176 vector unsigned short vec_andc (vector unsigned short,
12177 vector bool short);
12178 vector unsigned short vec_andc (vector unsigned short,
12179 vector unsigned short);
12180 vector signed char vec_andc (vector bool char, vector signed char);
12181 vector bool char vec_andc (vector bool char, vector bool char);
12182 vector signed char vec_andc (vector signed char, vector bool char);
12183 vector signed char vec_andc (vector signed char, vector signed char);
12184 vector unsigned char vec_andc (vector bool char, vector unsigned char);
12185 vector unsigned char vec_andc (vector unsigned char, vector bool char);
12186 vector unsigned char vec_andc (vector unsigned char,
12187 vector unsigned char);
12188
12189 vector unsigned char vec_avg (vector unsigned char,
12190 vector unsigned char);
12191 vector signed char vec_avg (vector signed char, vector signed char);
12192 vector unsigned short vec_avg (vector unsigned short,
12193 vector unsigned short);
12194 vector signed short vec_avg (vector signed short, vector signed short);
12195 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
12196 vector signed int vec_avg (vector signed int, vector signed int);
12197
12198 vector signed int vec_vavgsw (vector signed int, vector signed int);
12199
12200 vector unsigned int vec_vavguw (vector unsigned int,
12201 vector unsigned int);
12202
12203 vector signed short vec_vavgsh (vector signed short,
12204 vector signed short);
12205
12206 vector unsigned short vec_vavguh (vector unsigned short,
12207 vector unsigned short);
12208
12209 vector signed char vec_vavgsb (vector signed char, vector signed char);
12210
12211 vector unsigned char vec_vavgub (vector unsigned char,
12212 vector unsigned char);
12213
12214 vector float vec_copysign (vector float);
12215
12216 vector float vec_ceil (vector float);
12217
12218 vector signed int vec_cmpb (vector float, vector float);
12219
12220 vector bool char vec_cmpeq (vector signed char, vector signed char);
12221 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
12222 vector bool short vec_cmpeq (vector signed short, vector signed short);
12223 vector bool short vec_cmpeq (vector unsigned short,
12224 vector unsigned short);
12225 vector bool int vec_cmpeq (vector signed int, vector signed int);
12226 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
12227 vector bool int vec_cmpeq (vector float, vector float);
12228
12229 vector bool int vec_vcmpeqfp (vector float, vector float);
12230
12231 vector bool int vec_vcmpequw (vector signed int, vector signed int);
12232 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
12233
12234 vector bool short vec_vcmpequh (vector signed short,
12235 vector signed short);
12236 vector bool short vec_vcmpequh (vector unsigned short,
12237 vector unsigned short);
12238
12239 vector bool char vec_vcmpequb (vector signed char, vector signed char);
12240 vector bool char vec_vcmpequb (vector unsigned char,
12241 vector unsigned char);
12242
12243 vector bool int vec_cmpge (vector float, vector float);
12244
12245 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
12246 vector bool char vec_cmpgt (vector signed char, vector signed char);
12247 vector bool short vec_cmpgt (vector unsigned short,
12248 vector unsigned short);
12249 vector bool short vec_cmpgt (vector signed short, vector signed short);
12250 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
12251 vector bool int vec_cmpgt (vector signed int, vector signed int);
12252 vector bool int vec_cmpgt (vector float, vector float);
12253
12254 vector bool int vec_vcmpgtfp (vector float, vector float);
12255
12256 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
12257
12258 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
12259
12260 vector bool short vec_vcmpgtsh (vector signed short,
12261 vector signed short);
12262
12263 vector bool short vec_vcmpgtuh (vector unsigned short,
12264 vector unsigned short);
12265
12266 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
12267
12268 vector bool char vec_vcmpgtub (vector unsigned char,
12269 vector unsigned char);
12270
12271 vector bool int vec_cmple (vector float, vector float);
12272
12273 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
12274 vector bool char vec_cmplt (vector signed char, vector signed char);
12275 vector bool short vec_cmplt (vector unsigned short,
12276 vector unsigned short);
12277 vector bool short vec_cmplt (vector signed short, vector signed short);
12278 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
12279 vector bool int vec_cmplt (vector signed int, vector signed int);
12280 vector bool int vec_cmplt (vector float, vector float);
12281
12282 vector float vec_ctf (vector unsigned int, const int);
12283 vector float vec_ctf (vector signed int, const int);
12284
12285 vector float vec_vcfsx (vector signed int, const int);
12286
12287 vector float vec_vcfux (vector unsigned int, const int);
12288
12289 vector signed int vec_cts (vector float, const int);
12290
12291 vector unsigned int vec_ctu (vector float, const int);
12292
12293 void vec_dss (const int);
12294
12295 void vec_dssall (void);
12296
12297 void vec_dst (const vector unsigned char *, int, const int);
12298 void vec_dst (const vector signed char *, int, const int);
12299 void vec_dst (const vector bool char *, int, const int);
12300 void vec_dst (const vector unsigned short *, int, const int);
12301 void vec_dst (const vector signed short *, int, const int);
12302 void vec_dst (const vector bool short *, int, const int);
12303 void vec_dst (const vector pixel *, int, const int);
12304 void vec_dst (const vector unsigned int *, int, const int);
12305 void vec_dst (const vector signed int *, int, const int);
12306 void vec_dst (const vector bool int *, int, const int);
12307 void vec_dst (const vector float *, int, const int);
12308 void vec_dst (const unsigned char *, int, const int);
12309 void vec_dst (const signed char *, int, const int);
12310 void vec_dst (const unsigned short *, int, const int);
12311 void vec_dst (const short *, int, const int);
12312 void vec_dst (const unsigned int *, int, const int);
12313 void vec_dst (const int *, int, const int);
12314 void vec_dst (const unsigned long *, int, const int);
12315 void vec_dst (const long *, int, const int);
12316 void vec_dst (const float *, int, const int);
12317
12318 void vec_dstst (const vector unsigned char *, int, const int);
12319 void vec_dstst (const vector signed char *, int, const int);
12320 void vec_dstst (const vector bool char *, int, const int);
12321 void vec_dstst (const vector unsigned short *, int, const int);
12322 void vec_dstst (const vector signed short *, int, const int);
12323 void vec_dstst (const vector bool short *, int, const int);
12324 void vec_dstst (const vector pixel *, int, const int);
12325 void vec_dstst (const vector unsigned int *, int, const int);
12326 void vec_dstst (const vector signed int *, int, const int);
12327 void vec_dstst (const vector bool int *, int, const int);
12328 void vec_dstst (const vector float *, int, const int);
12329 void vec_dstst (const unsigned char *, int, const int);
12330 void vec_dstst (const signed char *, int, const int);
12331 void vec_dstst (const unsigned short *, int, const int);
12332 void vec_dstst (const short *, int, const int);
12333 void vec_dstst (const unsigned int *, int, const int);
12334 void vec_dstst (const int *, int, const int);
12335 void vec_dstst (const unsigned long *, int, const int);
12336 void vec_dstst (const long *, int, const int);
12337 void vec_dstst (const float *, int, const int);
12338
12339 void vec_dststt (const vector unsigned char *, int, const int);
12340 void vec_dststt (const vector signed char *, int, const int);
12341 void vec_dststt (const vector bool char *, int, const int);
12342 void vec_dststt (const vector unsigned short *, int, const int);
12343 void vec_dststt (const vector signed short *, int, const int);
12344 void vec_dststt (const vector bool short *, int, const int);
12345 void vec_dststt (const vector pixel *, int, const int);
12346 void vec_dststt (const vector unsigned int *, int, const int);
12347 void vec_dststt (const vector signed int *, int, const int);
12348 void vec_dststt (const vector bool int *, int, const int);
12349 void vec_dststt (const vector float *, int, const int);
12350 void vec_dststt (const unsigned char *, int, const int);
12351 void vec_dststt (const signed char *, int, const int);
12352 void vec_dststt (const unsigned short *, int, const int);
12353 void vec_dststt (const short *, int, const int);
12354 void vec_dststt (const unsigned int *, int, const int);
12355 void vec_dststt (const int *, int, const int);
12356 void vec_dststt (const unsigned long *, int, const int);
12357 void vec_dststt (const long *, int, const int);
12358 void vec_dststt (const float *, int, const int);
12359
12360 void vec_dstt (const vector unsigned char *, int, const int);
12361 void vec_dstt (const vector signed char *, int, const int);
12362 void vec_dstt (const vector bool char *, int, const int);
12363 void vec_dstt (const vector unsigned short *, int, const int);
12364 void vec_dstt (const vector signed short *, int, const int);
12365 void vec_dstt (const vector bool short *, int, const int);
12366 void vec_dstt (const vector pixel *, int, const int);
12367 void vec_dstt (const vector unsigned int *, int, const int);
12368 void vec_dstt (const vector signed int *, int, const int);
12369 void vec_dstt (const vector bool int *, int, const int);
12370 void vec_dstt (const vector float *, int, const int);
12371 void vec_dstt (const unsigned char *, int, const int);
12372 void vec_dstt (const signed char *, int, const int);
12373 void vec_dstt (const unsigned short *, int, const int);
12374 void vec_dstt (const short *, int, const int);
12375 void vec_dstt (const unsigned int *, int, const int);
12376 void vec_dstt (const int *, int, const int);
12377 void vec_dstt (const unsigned long *, int, const int);
12378 void vec_dstt (const long *, int, const int);
12379 void vec_dstt (const float *, int, const int);
12380
12381 vector float vec_expte (vector float);
12382
12383 vector float vec_floor (vector float);
12384
12385 vector float vec_ld (int, const vector float *);
12386 vector float vec_ld (int, const float *);
12387 vector bool int vec_ld (int, const vector bool int *);
12388 vector signed int vec_ld (int, const vector signed int *);
12389 vector signed int vec_ld (int, const int *);
12390 vector signed int vec_ld (int, const long *);
12391 vector unsigned int vec_ld (int, const vector unsigned int *);
12392 vector unsigned int vec_ld (int, const unsigned int *);
12393 vector unsigned int vec_ld (int, const unsigned long *);
12394 vector bool short vec_ld (int, const vector bool short *);
12395 vector pixel vec_ld (int, const vector pixel *);
12396 vector signed short vec_ld (int, const vector signed short *);
12397 vector signed short vec_ld (int, const short *);
12398 vector unsigned short vec_ld (int, const vector unsigned short *);
12399 vector unsigned short vec_ld (int, const unsigned short *);
12400 vector bool char vec_ld (int, const vector bool char *);
12401 vector signed char vec_ld (int, const vector signed char *);
12402 vector signed char vec_ld (int, const signed char *);
12403 vector unsigned char vec_ld (int, const vector unsigned char *);
12404 vector unsigned char vec_ld (int, const unsigned char *);
12405
12406 vector signed char vec_lde (int, const signed char *);
12407 vector unsigned char vec_lde (int, const unsigned char *);
12408 vector signed short vec_lde (int, const short *);
12409 vector unsigned short vec_lde (int, const unsigned short *);
12410 vector float vec_lde (int, const float *);
12411 vector signed int vec_lde (int, const int *);
12412 vector unsigned int vec_lde (int, const unsigned int *);
12413 vector signed int vec_lde (int, const long *);
12414 vector unsigned int vec_lde (int, const unsigned long *);
12415
12416 vector float vec_lvewx (int, float *);
12417 vector signed int vec_lvewx (int, int *);
12418 vector unsigned int vec_lvewx (int, unsigned int *);
12419 vector signed int vec_lvewx (int, long *);
12420 vector unsigned int vec_lvewx (int, unsigned long *);
12421
12422 vector signed short vec_lvehx (int, short *);
12423 vector unsigned short vec_lvehx (int, unsigned short *);
12424
12425 vector signed char vec_lvebx (int, char *);
12426 vector unsigned char vec_lvebx (int, unsigned char *);
12427
12428 vector float vec_ldl (int, const vector float *);
12429 vector float vec_ldl (int, const float *);
12430 vector bool int vec_ldl (int, const vector bool int *);
12431 vector signed int vec_ldl (int, const vector signed int *);
12432 vector signed int vec_ldl (int, const int *);
12433 vector signed int vec_ldl (int, const long *);
12434 vector unsigned int vec_ldl (int, const vector unsigned int *);
12435 vector unsigned int vec_ldl (int, const unsigned int *);
12436 vector unsigned int vec_ldl (int, const unsigned long *);
12437 vector bool short vec_ldl (int, const vector bool short *);
12438 vector pixel vec_ldl (int, const vector pixel *);
12439 vector signed short vec_ldl (int, const vector signed short *);
12440 vector signed short vec_ldl (int, const short *);
12441 vector unsigned short vec_ldl (int, const vector unsigned short *);
12442 vector unsigned short vec_ldl (int, const unsigned short *);
12443 vector bool char vec_ldl (int, const vector bool char *);
12444 vector signed char vec_ldl (int, const vector signed char *);
12445 vector signed char vec_ldl (int, const signed char *);
12446 vector unsigned char vec_ldl (int, const vector unsigned char *);
12447 vector unsigned char vec_ldl (int, const unsigned char *);
12448
12449 vector float vec_loge (vector float);
12450
12451 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
12452 vector unsigned char vec_lvsl (int, const volatile signed char *);
12453 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
12454 vector unsigned char vec_lvsl (int, const volatile short *);
12455 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
12456 vector unsigned char vec_lvsl (int, const volatile int *);
12457 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
12458 vector unsigned char vec_lvsl (int, const volatile long *);
12459 vector unsigned char vec_lvsl (int, const volatile float *);
12460
12461 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
12462 vector unsigned char vec_lvsr (int, const volatile signed char *);
12463 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
12464 vector unsigned char vec_lvsr (int, const volatile short *);
12465 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
12466 vector unsigned char vec_lvsr (int, const volatile int *);
12467 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
12468 vector unsigned char vec_lvsr (int, const volatile long *);
12469 vector unsigned char vec_lvsr (int, const volatile float *);
12470
12471 vector float vec_madd (vector float, vector float, vector float);
12472
12473 vector signed short vec_madds (vector signed short,
12474 vector signed short,
12475 vector signed short);
12476
12477 vector unsigned char vec_max (vector bool char, vector unsigned char);
12478 vector unsigned char vec_max (vector unsigned char, vector bool char);
12479 vector unsigned char vec_max (vector unsigned char,
12480 vector unsigned char);
12481 vector signed char vec_max (vector bool char, vector signed char);
12482 vector signed char vec_max (vector signed char, vector bool char);
12483 vector signed char vec_max (vector signed char, vector signed char);
12484 vector unsigned short vec_max (vector bool short,
12485 vector unsigned short);
12486 vector unsigned short vec_max (vector unsigned short,
12487 vector bool short);
12488 vector unsigned short vec_max (vector unsigned short,
12489 vector unsigned short);
12490 vector signed short vec_max (vector bool short, vector signed short);
12491 vector signed short vec_max (vector signed short, vector bool short);
12492 vector signed short vec_max (vector signed short, vector signed short);
12493 vector unsigned int vec_max (vector bool int, vector unsigned int);
12494 vector unsigned int vec_max (vector unsigned int, vector bool int);
12495 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
12496 vector signed int vec_max (vector bool int, vector signed int);
12497 vector signed int vec_max (vector signed int, vector bool int);
12498 vector signed int vec_max (vector signed int, vector signed int);
12499 vector float vec_max (vector float, vector float);
12500
12501 vector float vec_vmaxfp (vector float, vector float);
12502
12503 vector signed int vec_vmaxsw (vector bool int, vector signed int);
12504 vector signed int vec_vmaxsw (vector signed int, vector bool int);
12505 vector signed int vec_vmaxsw (vector signed int, vector signed int);
12506
12507 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
12508 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
12509 vector unsigned int vec_vmaxuw (vector unsigned int,
12510 vector unsigned int);
12511
12512 vector signed short vec_vmaxsh (vector bool short, vector signed short);
12513 vector signed short vec_vmaxsh (vector signed short, vector bool short);
12514 vector signed short vec_vmaxsh (vector signed short,
12515 vector signed short);
12516
12517 vector unsigned short vec_vmaxuh (vector bool short,
12518 vector unsigned short);
12519 vector unsigned short vec_vmaxuh (vector unsigned short,
12520 vector bool short);
12521 vector unsigned short vec_vmaxuh (vector unsigned short,
12522 vector unsigned short);
12523
12524 vector signed char vec_vmaxsb (vector bool char, vector signed char);
12525 vector signed char vec_vmaxsb (vector signed char, vector bool char);
12526 vector signed char vec_vmaxsb (vector signed char, vector signed char);
12527
12528 vector unsigned char vec_vmaxub (vector bool char,
12529 vector unsigned char);
12530 vector unsigned char vec_vmaxub (vector unsigned char,
12531 vector bool char);
12532 vector unsigned char vec_vmaxub (vector unsigned char,
12533 vector unsigned char);
12534
12535 vector bool char vec_mergeh (vector bool char, vector bool char);
12536 vector signed char vec_mergeh (vector signed char, vector signed char);
12537 vector unsigned char vec_mergeh (vector unsigned char,
12538 vector unsigned char);
12539 vector bool short vec_mergeh (vector bool short, vector bool short);
12540 vector pixel vec_mergeh (vector pixel, vector pixel);
12541 vector signed short vec_mergeh (vector signed short,
12542 vector signed short);
12543 vector unsigned short vec_mergeh (vector unsigned short,
12544 vector unsigned short);
12545 vector float vec_mergeh (vector float, vector float);
12546 vector bool int vec_mergeh (vector bool int, vector bool int);
12547 vector signed int vec_mergeh (vector signed int, vector signed int);
12548 vector unsigned int vec_mergeh (vector unsigned int,
12549 vector unsigned int);
12550
12551 vector float vec_vmrghw (vector float, vector float);
12552 vector bool int vec_vmrghw (vector bool int, vector bool int);
12553 vector signed int vec_vmrghw (vector signed int, vector signed int);
12554 vector unsigned int vec_vmrghw (vector unsigned int,
12555 vector unsigned int);
12556
12557 vector bool short vec_vmrghh (vector bool short, vector bool short);
12558 vector signed short vec_vmrghh (vector signed short,
12559 vector signed short);
12560 vector unsigned short vec_vmrghh (vector unsigned short,
12561 vector unsigned short);
12562 vector pixel vec_vmrghh (vector pixel, vector pixel);
12563
12564 vector bool char vec_vmrghb (vector bool char, vector bool char);
12565 vector signed char vec_vmrghb (vector signed char, vector signed char);
12566 vector unsigned char vec_vmrghb (vector unsigned char,
12567 vector unsigned char);
12568
12569 vector bool char vec_mergel (vector bool char, vector bool char);
12570 vector signed char vec_mergel (vector signed char, vector signed char);
12571 vector unsigned char vec_mergel (vector unsigned char,
12572 vector unsigned char);
12573 vector bool short vec_mergel (vector bool short, vector bool short);
12574 vector pixel vec_mergel (vector pixel, vector pixel);
12575 vector signed short vec_mergel (vector signed short,
12576 vector signed short);
12577 vector unsigned short vec_mergel (vector unsigned short,
12578 vector unsigned short);
12579 vector float vec_mergel (vector float, vector float);
12580 vector bool int vec_mergel (vector bool int, vector bool int);
12581 vector signed int vec_mergel (vector signed int, vector signed int);
12582 vector unsigned int vec_mergel (vector unsigned int,
12583 vector unsigned int);
12584
12585 vector float vec_vmrglw (vector float, vector float);
12586 vector signed int vec_vmrglw (vector signed int, vector signed int);
12587 vector unsigned int vec_vmrglw (vector unsigned int,
12588 vector unsigned int);
12589 vector bool int vec_vmrglw (vector bool int, vector bool int);
12590
12591 vector bool short vec_vmrglh (vector bool short, vector bool short);
12592 vector signed short vec_vmrglh (vector signed short,
12593 vector signed short);
12594 vector unsigned short vec_vmrglh (vector unsigned short,
12595 vector unsigned short);
12596 vector pixel vec_vmrglh (vector pixel, vector pixel);
12597
12598 vector bool char vec_vmrglb (vector bool char, vector bool char);
12599 vector signed char vec_vmrglb (vector signed char, vector signed char);
12600 vector unsigned char vec_vmrglb (vector unsigned char,
12601 vector unsigned char);
12602
12603 vector unsigned short vec_mfvscr (void);
12604
12605 vector unsigned char vec_min (vector bool char, vector unsigned char);
12606 vector unsigned char vec_min (vector unsigned char, vector bool char);
12607 vector unsigned char vec_min (vector unsigned char,
12608 vector unsigned char);
12609 vector signed char vec_min (vector bool char, vector signed char);
12610 vector signed char vec_min (vector signed char, vector bool char);
12611 vector signed char vec_min (vector signed char, vector signed char);
12612 vector unsigned short vec_min (vector bool short,
12613 vector unsigned short);
12614 vector unsigned short vec_min (vector unsigned short,
12615 vector bool short);
12616 vector unsigned short vec_min (vector unsigned short,
12617 vector unsigned short);
12618 vector signed short vec_min (vector bool short, vector signed short);
12619 vector signed short vec_min (vector signed short, vector bool short);
12620 vector signed short vec_min (vector signed short, vector signed short);
12621 vector unsigned int vec_min (vector bool int, vector unsigned int);
12622 vector unsigned int vec_min (vector unsigned int, vector bool int);
12623 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
12624 vector signed int vec_min (vector bool int, vector signed int);
12625 vector signed int vec_min (vector signed int, vector bool int);
12626 vector signed int vec_min (vector signed int, vector signed int);
12627 vector float vec_min (vector float, vector float);
12628
12629 vector float vec_vminfp (vector float, vector float);
12630
12631 vector signed int vec_vminsw (vector bool int, vector signed int);
12632 vector signed int vec_vminsw (vector signed int, vector bool int);
12633 vector signed int vec_vminsw (vector signed int, vector signed int);
12634
12635 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
12636 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
12637 vector unsigned int vec_vminuw (vector unsigned int,
12638 vector unsigned int);
12639
12640 vector signed short vec_vminsh (vector bool short, vector signed short);
12641 vector signed short vec_vminsh (vector signed short, vector bool short);
12642 vector signed short vec_vminsh (vector signed short,
12643 vector signed short);
12644
12645 vector unsigned short vec_vminuh (vector bool short,
12646 vector unsigned short);
12647 vector unsigned short vec_vminuh (vector unsigned short,
12648 vector bool short);
12649 vector unsigned short vec_vminuh (vector unsigned short,
12650 vector unsigned short);
12651
12652 vector signed char vec_vminsb (vector bool char, vector signed char);
12653 vector signed char vec_vminsb (vector signed char, vector bool char);
12654 vector signed char vec_vminsb (vector signed char, vector signed char);
12655
12656 vector unsigned char vec_vminub (vector bool char,
12657 vector unsigned char);
12658 vector unsigned char vec_vminub (vector unsigned char,
12659 vector bool char);
12660 vector unsigned char vec_vminub (vector unsigned char,
12661 vector unsigned char);
12662
12663 vector signed short vec_mladd (vector signed short,
12664 vector signed short,
12665 vector signed short);
12666 vector signed short vec_mladd (vector signed short,
12667 vector unsigned short,
12668 vector unsigned short);
12669 vector signed short vec_mladd (vector unsigned short,
12670 vector signed short,
12671 vector signed short);
12672 vector unsigned short vec_mladd (vector unsigned short,
12673 vector unsigned short,
12674 vector unsigned short);
12675
12676 vector signed short vec_mradds (vector signed short,
12677 vector signed short,
12678 vector signed short);
12679
12680 vector unsigned int vec_msum (vector unsigned char,
12681 vector unsigned char,
12682 vector unsigned int);
12683 vector signed int vec_msum (vector signed char,
12684 vector unsigned char,
12685 vector signed int);
12686 vector unsigned int vec_msum (vector unsigned short,
12687 vector unsigned short,
12688 vector unsigned int);
12689 vector signed int vec_msum (vector signed short,
12690 vector signed short,
12691 vector signed int);
12692
12693 vector signed int vec_vmsumshm (vector signed short,
12694 vector signed short,
12695 vector signed int);
12696
12697 vector unsigned int vec_vmsumuhm (vector unsigned short,
12698 vector unsigned short,
12699 vector unsigned int);
12700
12701 vector signed int vec_vmsummbm (vector signed char,
12702 vector unsigned char,
12703 vector signed int);
12704
12705 vector unsigned int vec_vmsumubm (vector unsigned char,
12706 vector unsigned char,
12707 vector unsigned int);
12708
12709 vector unsigned int vec_msums (vector unsigned short,
12710 vector unsigned short,
12711 vector unsigned int);
12712 vector signed int vec_msums (vector signed short,
12713 vector signed short,
12714 vector signed int);
12715
12716 vector signed int vec_vmsumshs (vector signed short,
12717 vector signed short,
12718 vector signed int);
12719
12720 vector unsigned int vec_vmsumuhs (vector unsigned short,
12721 vector unsigned short,
12722 vector unsigned int);
12723
12724 void vec_mtvscr (vector signed int);
12725 void vec_mtvscr (vector unsigned int);
12726 void vec_mtvscr (vector bool int);
12727 void vec_mtvscr (vector signed short);
12728 void vec_mtvscr (vector unsigned short);
12729 void vec_mtvscr (vector bool short);
12730 void vec_mtvscr (vector pixel);
12731 void vec_mtvscr (vector signed char);
12732 void vec_mtvscr (vector unsigned char);
12733 void vec_mtvscr (vector bool char);
12734
12735 vector unsigned short vec_mule (vector unsigned char,
12736 vector unsigned char);
12737 vector signed short vec_mule (vector signed char,
12738 vector signed char);
12739 vector unsigned int vec_mule (vector unsigned short,
12740 vector unsigned short);
12741 vector signed int vec_mule (vector signed short, vector signed short);
12742
12743 vector signed int vec_vmulesh (vector signed short,
12744 vector signed short);
12745
12746 vector unsigned int vec_vmuleuh (vector unsigned short,
12747 vector unsigned short);
12748
12749 vector signed short vec_vmulesb (vector signed char,
12750 vector signed char);
12751
12752 vector unsigned short vec_vmuleub (vector unsigned char,
12753 vector unsigned char);
12754
12755 vector unsigned short vec_mulo (vector unsigned char,
12756 vector unsigned char);
12757 vector signed short vec_mulo (vector signed char, vector signed char);
12758 vector unsigned int vec_mulo (vector unsigned short,
12759 vector unsigned short);
12760 vector signed int vec_mulo (vector signed short, vector signed short);
12761
12762 vector signed int vec_vmulosh (vector signed short,
12763 vector signed short);
12764
12765 vector unsigned int vec_vmulouh (vector unsigned short,
12766 vector unsigned short);
12767
12768 vector signed short vec_vmulosb (vector signed char,
12769 vector signed char);
12770
12771 vector unsigned short vec_vmuloub (vector unsigned char,
12772 vector unsigned char);
12773
12774 vector float vec_nmsub (vector float, vector float, vector float);
12775
12776 vector float vec_nor (vector float, vector float);
12777 vector signed int vec_nor (vector signed int, vector signed int);
12778 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
12779 vector bool int vec_nor (vector bool int, vector bool int);
12780 vector signed short vec_nor (vector signed short, vector signed short);
12781 vector unsigned short vec_nor (vector unsigned short,
12782 vector unsigned short);
12783 vector bool short vec_nor (vector bool short, vector bool short);
12784 vector signed char vec_nor (vector signed char, vector signed char);
12785 vector unsigned char vec_nor (vector unsigned char,
12786 vector unsigned char);
12787 vector bool char vec_nor (vector bool char, vector bool char);
12788
12789 vector float vec_or (vector float, vector float);
12790 vector float vec_or (vector float, vector bool int);
12791 vector float vec_or (vector bool int, vector float);
12792 vector bool int vec_or (vector bool int, vector bool int);
12793 vector signed int vec_or (vector bool int, vector signed int);
12794 vector signed int vec_or (vector signed int, vector bool int);
12795 vector signed int vec_or (vector signed int, vector signed int);
12796 vector unsigned int vec_or (vector bool int, vector unsigned int);
12797 vector unsigned int vec_or (vector unsigned int, vector bool int);
12798 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
12799 vector bool short vec_or (vector bool short, vector bool short);
12800 vector signed short vec_or (vector bool short, vector signed short);
12801 vector signed short vec_or (vector signed short, vector bool short);
12802 vector signed short vec_or (vector signed short, vector signed short);
12803 vector unsigned short vec_or (vector bool short, vector unsigned short);
12804 vector unsigned short vec_or (vector unsigned short, vector bool short);
12805 vector unsigned short vec_or (vector unsigned short,
12806 vector unsigned short);
12807 vector signed char vec_or (vector bool char, vector signed char);
12808 vector bool char vec_or (vector bool char, vector bool char);
12809 vector signed char vec_or (vector signed char, vector bool char);
12810 vector signed char vec_or (vector signed char, vector signed char);
12811 vector unsigned char vec_or (vector bool char, vector unsigned char);
12812 vector unsigned char vec_or (vector unsigned char, vector bool char);
12813 vector unsigned char vec_or (vector unsigned char,
12814 vector unsigned char);
12815
12816 vector signed char vec_pack (vector signed short, vector signed short);
12817 vector unsigned char vec_pack (vector unsigned short,
12818 vector unsigned short);
12819 vector bool char vec_pack (vector bool short, vector bool short);
12820 vector signed short vec_pack (vector signed int, vector signed int);
12821 vector unsigned short vec_pack (vector unsigned int,
12822 vector unsigned int);
12823 vector bool short vec_pack (vector bool int, vector bool int);
12824
12825 vector bool short vec_vpkuwum (vector bool int, vector bool int);
12826 vector signed short vec_vpkuwum (vector signed int, vector signed int);
12827 vector unsigned short vec_vpkuwum (vector unsigned int,
12828 vector unsigned int);
12829
12830 vector bool char vec_vpkuhum (vector bool short, vector bool short);
12831 vector signed char vec_vpkuhum (vector signed short,
12832 vector signed short);
12833 vector unsigned char vec_vpkuhum (vector unsigned short,
12834 vector unsigned short);
12835
12836 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
12837
12838 vector unsigned char vec_packs (vector unsigned short,
12839 vector unsigned short);
12840 vector signed char vec_packs (vector signed short, vector signed short);
12841 vector unsigned short vec_packs (vector unsigned int,
12842 vector unsigned int);
12843 vector signed short vec_packs (vector signed int, vector signed int);
12844
12845 vector signed short vec_vpkswss (vector signed int, vector signed int);
12846
12847 vector unsigned short vec_vpkuwus (vector unsigned int,
12848 vector unsigned int);
12849
12850 vector signed char vec_vpkshss (vector signed short,
12851 vector signed short);
12852
12853 vector unsigned char vec_vpkuhus (vector unsigned short,
12854 vector unsigned short);
12855
12856 vector unsigned char vec_packsu (vector unsigned short,
12857 vector unsigned short);
12858 vector unsigned char vec_packsu (vector signed short,
12859 vector signed short);
12860 vector unsigned short vec_packsu (vector unsigned int,
12861 vector unsigned int);
12862 vector unsigned short vec_packsu (vector signed int, vector signed int);
12863
12864 vector unsigned short vec_vpkswus (vector signed int,
12865 vector signed int);
12866
12867 vector unsigned char vec_vpkshus (vector signed short,
12868 vector signed short);
12869
12870 vector float vec_perm (vector float,
12871 vector float,
12872 vector unsigned char);
12873 vector signed int vec_perm (vector signed int,
12874 vector signed int,
12875 vector unsigned char);
12876 vector unsigned int vec_perm (vector unsigned int,
12877 vector unsigned int,
12878 vector unsigned char);
12879 vector bool int vec_perm (vector bool int,
12880 vector bool int,
12881 vector unsigned char);
12882 vector signed short vec_perm (vector signed short,
12883 vector signed short,
12884 vector unsigned char);
12885 vector unsigned short vec_perm (vector unsigned short,
12886 vector unsigned short,
12887 vector unsigned char);
12888 vector bool short vec_perm (vector bool short,
12889 vector bool short,
12890 vector unsigned char);
12891 vector pixel vec_perm (vector pixel,
12892 vector pixel,
12893 vector unsigned char);
12894 vector signed char vec_perm (vector signed char,
12895 vector signed char,
12896 vector unsigned char);
12897 vector unsigned char vec_perm (vector unsigned char,
12898 vector unsigned char,
12899 vector unsigned char);
12900 vector bool char vec_perm (vector bool char,
12901 vector bool char,
12902 vector unsigned char);
12903
12904 vector float vec_re (vector float);
12905
12906 vector signed char vec_rl (vector signed char,
12907 vector unsigned char);
12908 vector unsigned char vec_rl (vector unsigned char,
12909 vector unsigned char);
12910 vector signed short vec_rl (vector signed short, vector unsigned short);
12911 vector unsigned short vec_rl (vector unsigned short,
12912 vector unsigned short);
12913 vector signed int vec_rl (vector signed int, vector unsigned int);
12914 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
12915
12916 vector signed int vec_vrlw (vector signed int, vector unsigned int);
12917 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
12918
12919 vector signed short vec_vrlh (vector signed short,
12920 vector unsigned short);
12921 vector unsigned short vec_vrlh (vector unsigned short,
12922 vector unsigned short);
12923
12924 vector signed char vec_vrlb (vector signed char, vector unsigned char);
12925 vector unsigned char vec_vrlb (vector unsigned char,
12926 vector unsigned char);
12927
12928 vector float vec_round (vector float);
12929
12930 vector float vec_recip (vector float, vector float);
12931
12932 vector float vec_rsqrt (vector float);
12933
12934 vector float vec_rsqrte (vector float);
12935
12936 vector float vec_sel (vector float, vector float, vector bool int);
12937 vector float vec_sel (vector float, vector float, vector unsigned int);
12938 vector signed int vec_sel (vector signed int,
12939 vector signed int,
12940 vector bool int);
12941 vector signed int vec_sel (vector signed int,
12942 vector signed int,
12943 vector unsigned int);
12944 vector unsigned int vec_sel (vector unsigned int,
12945 vector unsigned int,
12946 vector bool int);
12947 vector unsigned int vec_sel (vector unsigned int,
12948 vector unsigned int,
12949 vector unsigned int);
12950 vector bool int vec_sel (vector bool int,
12951 vector bool int,
12952 vector bool int);
12953 vector bool int vec_sel (vector bool int,
12954 vector bool int,
12955 vector unsigned int);
12956 vector signed short vec_sel (vector signed short,
12957 vector signed short,
12958 vector bool short);
12959 vector signed short vec_sel (vector signed short,
12960 vector signed short,
12961 vector unsigned short);
12962 vector unsigned short vec_sel (vector unsigned short,
12963 vector unsigned short,
12964 vector bool short);
12965 vector unsigned short vec_sel (vector unsigned short,
12966 vector unsigned short,
12967 vector unsigned short);
12968 vector bool short vec_sel (vector bool short,
12969 vector bool short,
12970 vector bool short);
12971 vector bool short vec_sel (vector bool short,
12972 vector bool short,
12973 vector unsigned short);
12974 vector signed char vec_sel (vector signed char,
12975 vector signed char,
12976 vector bool char);
12977 vector signed char vec_sel (vector signed char,
12978 vector signed char,
12979 vector unsigned char);
12980 vector unsigned char vec_sel (vector unsigned char,
12981 vector unsigned char,
12982 vector bool char);
12983 vector unsigned char vec_sel (vector unsigned char,
12984 vector unsigned char,
12985 vector unsigned char);
12986 vector bool char vec_sel (vector bool char,
12987 vector bool char,
12988 vector bool char);
12989 vector bool char vec_sel (vector bool char,
12990 vector bool char,
12991 vector unsigned char);
12992
12993 vector signed char vec_sl (vector signed char,
12994 vector unsigned char);
12995 vector unsigned char vec_sl (vector unsigned char,
12996 vector unsigned char);
12997 vector signed short vec_sl (vector signed short, vector unsigned short);
12998 vector unsigned short vec_sl (vector unsigned short,
12999 vector unsigned short);
13000 vector signed int vec_sl (vector signed int, vector unsigned int);
13001 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
13002
13003 vector signed int vec_vslw (vector signed int, vector unsigned int);
13004 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
13005
13006 vector signed short vec_vslh (vector signed short,
13007 vector unsigned short);
13008 vector unsigned short vec_vslh (vector unsigned short,
13009 vector unsigned short);
13010
13011 vector signed char vec_vslb (vector signed char, vector unsigned char);
13012 vector unsigned char vec_vslb (vector unsigned char,
13013 vector unsigned char);
13014
13015 vector float vec_sld (vector float, vector float, const int);
13016 vector signed int vec_sld (vector signed int,
13017 vector signed int,
13018 const int);
13019 vector unsigned int vec_sld (vector unsigned int,
13020 vector unsigned int,
13021 const int);
13022 vector bool int vec_sld (vector bool int,
13023 vector bool int,
13024 const int);
13025 vector signed short vec_sld (vector signed short,
13026 vector signed short,
13027 const int);
13028 vector unsigned short vec_sld (vector unsigned short,
13029 vector unsigned short,
13030 const int);
13031 vector bool short vec_sld (vector bool short,
13032 vector bool short,
13033 const int);
13034 vector pixel vec_sld (vector pixel,
13035 vector pixel,
13036 const int);
13037 vector signed char vec_sld (vector signed char,
13038 vector signed char,
13039 const int);
13040 vector unsigned char vec_sld (vector unsigned char,
13041 vector unsigned char,
13042 const int);
13043 vector bool char vec_sld (vector bool char,
13044 vector bool char,
13045 const int);
13046
13047 vector signed int vec_sll (vector signed int,
13048 vector unsigned int);
13049 vector signed int vec_sll (vector signed int,
13050 vector unsigned short);
13051 vector signed int vec_sll (vector signed int,
13052 vector unsigned char);
13053 vector unsigned int vec_sll (vector unsigned int,
13054 vector unsigned int);
13055 vector unsigned int vec_sll (vector unsigned int,
13056 vector unsigned short);
13057 vector unsigned int vec_sll (vector unsigned int,
13058 vector unsigned char);
13059 vector bool int vec_sll (vector bool int,
13060 vector unsigned int);
13061 vector bool int vec_sll (vector bool int,
13062 vector unsigned short);
13063 vector bool int vec_sll (vector bool int,
13064 vector unsigned char);
13065 vector signed short vec_sll (vector signed short,
13066 vector unsigned int);
13067 vector signed short vec_sll (vector signed short,
13068 vector unsigned short);
13069 vector signed short vec_sll (vector signed short,
13070 vector unsigned char);
13071 vector unsigned short vec_sll (vector unsigned short,
13072 vector unsigned int);
13073 vector unsigned short vec_sll (vector unsigned short,
13074 vector unsigned short);
13075 vector unsigned short vec_sll (vector unsigned short,
13076 vector unsigned char);
13077 vector bool short vec_sll (vector bool short, vector unsigned int);
13078 vector bool short vec_sll (vector bool short, vector unsigned short);
13079 vector bool short vec_sll (vector bool short, vector unsigned char);
13080 vector pixel vec_sll (vector pixel, vector unsigned int);
13081 vector pixel vec_sll (vector pixel, vector unsigned short);
13082 vector pixel vec_sll (vector pixel, vector unsigned char);
13083 vector signed char vec_sll (vector signed char, vector unsigned int);
13084 vector signed char vec_sll (vector signed char, vector unsigned short);
13085 vector signed char vec_sll (vector signed char, vector unsigned char);
13086 vector unsigned char vec_sll (vector unsigned char,
13087 vector unsigned int);
13088 vector unsigned char vec_sll (vector unsigned char,
13089 vector unsigned short);
13090 vector unsigned char vec_sll (vector unsigned char,
13091 vector unsigned char);
13092 vector bool char vec_sll (vector bool char, vector unsigned int);
13093 vector bool char vec_sll (vector bool char, vector unsigned short);
13094 vector bool char vec_sll (vector bool char, vector unsigned char);
13095
13096 vector float vec_slo (vector float, vector signed char);
13097 vector float vec_slo (vector float, vector unsigned char);
13098 vector signed int vec_slo (vector signed int, vector signed char);
13099 vector signed int vec_slo (vector signed int, vector unsigned char);
13100 vector unsigned int vec_slo (vector unsigned int, vector signed char);
13101 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
13102 vector signed short vec_slo (vector signed short, vector signed char);
13103 vector signed short vec_slo (vector signed short, vector unsigned char);
13104 vector unsigned short vec_slo (vector unsigned short,
13105 vector signed char);
13106 vector unsigned short vec_slo (vector unsigned short,
13107 vector unsigned char);
13108 vector pixel vec_slo (vector pixel, vector signed char);
13109 vector pixel vec_slo (vector pixel, vector unsigned char);
13110 vector signed char vec_slo (vector signed char, vector signed char);
13111 vector signed char vec_slo (vector signed char, vector unsigned char);
13112 vector unsigned char vec_slo (vector unsigned char, vector signed char);
13113 vector unsigned char vec_slo (vector unsigned char,
13114 vector unsigned char);
13115
13116 vector signed char vec_splat (vector signed char, const int);
13117 vector unsigned char vec_splat (vector unsigned char, const int);
13118 vector bool char vec_splat (vector bool char, const int);
13119 vector signed short vec_splat (vector signed short, const int);
13120 vector unsigned short vec_splat (vector unsigned short, const int);
13121 vector bool short vec_splat (vector bool short, const int);
13122 vector pixel vec_splat (vector pixel, const int);
13123 vector float vec_splat (vector float, const int);
13124 vector signed int vec_splat (vector signed int, const int);
13125 vector unsigned int vec_splat (vector unsigned int, const int);
13126 vector bool int vec_splat (vector bool int, const int);
13127
13128 vector float vec_vspltw (vector float, const int);
13129 vector signed int vec_vspltw (vector signed int, const int);
13130 vector unsigned int vec_vspltw (vector unsigned int, const int);
13131 vector bool int vec_vspltw (vector bool int, const int);
13132
13133 vector bool short vec_vsplth (vector bool short, const int);
13134 vector signed short vec_vsplth (vector signed short, const int);
13135 vector unsigned short vec_vsplth (vector unsigned short, const int);
13136 vector pixel vec_vsplth (vector pixel, const int);
13137
13138 vector signed char vec_vspltb (vector signed char, const int);
13139 vector unsigned char vec_vspltb (vector unsigned char, const int);
13140 vector bool char vec_vspltb (vector bool char, const int);
13141
13142 vector signed char vec_splat_s8 (const int);
13143
13144 vector signed short vec_splat_s16 (const int);
13145
13146 vector signed int vec_splat_s32 (const int);
13147
13148 vector unsigned char vec_splat_u8 (const int);
13149
13150 vector unsigned short vec_splat_u16 (const int);
13151
13152 vector unsigned int vec_splat_u32 (const int);
13153
13154 vector signed char vec_sr (vector signed char, vector unsigned char);
13155 vector unsigned char vec_sr (vector unsigned char,
13156 vector unsigned char);
13157 vector signed short vec_sr (vector signed short,
13158 vector unsigned short);
13159 vector unsigned short vec_sr (vector unsigned short,
13160 vector unsigned short);
13161 vector signed int vec_sr (vector signed int, vector unsigned int);
13162 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
13163
13164 vector signed int vec_vsrw (vector signed int, vector unsigned int);
13165 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
13166
13167 vector signed short vec_vsrh (vector signed short,
13168 vector unsigned short);
13169 vector unsigned short vec_vsrh (vector unsigned short,
13170 vector unsigned short);
13171
13172 vector signed char vec_vsrb (vector signed char, vector unsigned char);
13173 vector unsigned char vec_vsrb (vector unsigned char,
13174 vector unsigned char);
13175
13176 vector signed char vec_sra (vector signed char, vector unsigned char);
13177 vector unsigned char vec_sra (vector unsigned char,
13178 vector unsigned char);
13179 vector signed short vec_sra (vector signed short,
13180 vector unsigned short);
13181 vector unsigned short vec_sra (vector unsigned short,
13182 vector unsigned short);
13183 vector signed int vec_sra (vector signed int, vector unsigned int);
13184 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
13185
13186 vector signed int vec_vsraw (vector signed int, vector unsigned int);
13187 vector unsigned int vec_vsraw (vector unsigned int,
13188 vector unsigned int);
13189
13190 vector signed short vec_vsrah (vector signed short,
13191 vector unsigned short);
13192 vector unsigned short vec_vsrah (vector unsigned short,
13193 vector unsigned short);
13194
13195 vector signed char vec_vsrab (vector signed char, vector unsigned char);
13196 vector unsigned char vec_vsrab (vector unsigned char,
13197 vector unsigned char);
13198
13199 vector signed int vec_srl (vector signed int, vector unsigned int);
13200 vector signed int vec_srl (vector signed int, vector unsigned short);
13201 vector signed int vec_srl (vector signed int, vector unsigned char);
13202 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
13203 vector unsigned int vec_srl (vector unsigned int,
13204 vector unsigned short);
13205 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
13206 vector bool int vec_srl (vector bool int, vector unsigned int);
13207 vector bool int vec_srl (vector bool int, vector unsigned short);
13208 vector bool int vec_srl (vector bool int, vector unsigned char);
13209 vector signed short vec_srl (vector signed short, vector unsigned int);
13210 vector signed short vec_srl (vector signed short,
13211 vector unsigned short);
13212 vector signed short vec_srl (vector signed short, vector unsigned char);
13213 vector unsigned short vec_srl (vector unsigned short,
13214 vector unsigned int);
13215 vector unsigned short vec_srl (vector unsigned short,
13216 vector unsigned short);
13217 vector unsigned short vec_srl (vector unsigned short,
13218 vector unsigned char);
13219 vector bool short vec_srl (vector bool short, vector unsigned int);
13220 vector bool short vec_srl (vector bool short, vector unsigned short);
13221 vector bool short vec_srl (vector bool short, vector unsigned char);
13222 vector pixel vec_srl (vector pixel, vector unsigned int);
13223 vector pixel vec_srl (vector pixel, vector unsigned short);
13224 vector pixel vec_srl (vector pixel, vector unsigned char);
13225 vector signed char vec_srl (vector signed char, vector unsigned int);
13226 vector signed char vec_srl (vector signed char, vector unsigned short);
13227 vector signed char vec_srl (vector signed char, vector unsigned char);
13228 vector unsigned char vec_srl (vector unsigned char,
13229 vector unsigned int);
13230 vector unsigned char vec_srl (vector unsigned char,
13231 vector unsigned short);
13232 vector unsigned char vec_srl (vector unsigned char,
13233 vector unsigned char);
13234 vector bool char vec_srl (vector bool char, vector unsigned int);
13235 vector bool char vec_srl (vector bool char, vector unsigned short);
13236 vector bool char vec_srl (vector bool char, vector unsigned char);
13237
13238 vector float vec_sro (vector float, vector signed char);
13239 vector float vec_sro (vector float, vector unsigned char);
13240 vector signed int vec_sro (vector signed int, vector signed char);
13241 vector signed int vec_sro (vector signed int, vector unsigned char);
13242 vector unsigned int vec_sro (vector unsigned int, vector signed char);
13243 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
13244 vector signed short vec_sro (vector signed short, vector signed char);
13245 vector signed short vec_sro (vector signed short, vector unsigned char);
13246 vector unsigned short vec_sro (vector unsigned short,
13247 vector signed char);
13248 vector unsigned short vec_sro (vector unsigned short,
13249 vector unsigned char);
13250 vector pixel vec_sro (vector pixel, vector signed char);
13251 vector pixel vec_sro (vector pixel, vector unsigned char);
13252 vector signed char vec_sro (vector signed char, vector signed char);
13253 vector signed char vec_sro (vector signed char, vector unsigned char);
13254 vector unsigned char vec_sro (vector unsigned char, vector signed char);
13255 vector unsigned char vec_sro (vector unsigned char,
13256 vector unsigned char);
13257
13258 void vec_st (vector float, int, vector float *);
13259 void vec_st (vector float, int, float *);
13260 void vec_st (vector signed int, int, vector signed int *);
13261 void vec_st (vector signed int, int, int *);
13262 void vec_st (vector unsigned int, int, vector unsigned int *);
13263 void vec_st (vector unsigned int, int, unsigned int *);
13264 void vec_st (vector bool int, int, vector bool int *);
13265 void vec_st (vector bool int, int, unsigned int *);
13266 void vec_st (vector bool int, int, int *);
13267 void vec_st (vector signed short, int, vector signed short *);
13268 void vec_st (vector signed short, int, short *);
13269 void vec_st (vector unsigned short, int, vector unsigned short *);
13270 void vec_st (vector unsigned short, int, unsigned short *);
13271 void vec_st (vector bool short, int, vector bool short *);
13272 void vec_st (vector bool short, int, unsigned short *);
13273 void vec_st (vector pixel, int, vector pixel *);
13274 void vec_st (vector pixel, int, unsigned short *);
13275 void vec_st (vector pixel, int, short *);
13276 void vec_st (vector bool short, int, short *);
13277 void vec_st (vector signed char, int, vector signed char *);
13278 void vec_st (vector signed char, int, signed char *);
13279 void vec_st (vector unsigned char, int, vector unsigned char *);
13280 void vec_st (vector unsigned char, int, unsigned char *);
13281 void vec_st (vector bool char, int, vector bool char *);
13282 void vec_st (vector bool char, int, unsigned char *);
13283 void vec_st (vector bool char, int, signed char *);
13284
13285 void vec_ste (vector signed char, int, signed char *);
13286 void vec_ste (vector unsigned char, int, unsigned char *);
13287 void vec_ste (vector bool char, int, signed char *);
13288 void vec_ste (vector bool char, int, unsigned char *);
13289 void vec_ste (vector signed short, int, short *);
13290 void vec_ste (vector unsigned short, int, unsigned short *);
13291 void vec_ste (vector bool short, int, short *);
13292 void vec_ste (vector bool short, int, unsigned short *);
13293 void vec_ste (vector pixel, int, short *);
13294 void vec_ste (vector pixel, int, unsigned short *);
13295 void vec_ste (vector float, int, float *);
13296 void vec_ste (vector signed int, int, int *);
13297 void vec_ste (vector unsigned int, int, unsigned int *);
13298 void vec_ste (vector bool int, int, int *);
13299 void vec_ste (vector bool int, int, unsigned int *);
13300
13301 void vec_stvewx (vector float, int, float *);
13302 void vec_stvewx (vector signed int, int, int *);
13303 void vec_stvewx (vector unsigned int, int, unsigned int *);
13304 void vec_stvewx (vector bool int, int, int *);
13305 void vec_stvewx (vector bool int, int, unsigned int *);
13306
13307 void vec_stvehx (vector signed short, int, short *);
13308 void vec_stvehx (vector unsigned short, int, unsigned short *);
13309 void vec_stvehx (vector bool short, int, short *);
13310 void vec_stvehx (vector bool short, int, unsigned short *);
13311 void vec_stvehx (vector pixel, int, short *);
13312 void vec_stvehx (vector pixel, int, unsigned short *);
13313
13314 void vec_stvebx (vector signed char, int, signed char *);
13315 void vec_stvebx (vector unsigned char, int, unsigned char *);
13316 void vec_stvebx (vector bool char, int, signed char *);
13317 void vec_stvebx (vector bool char, int, unsigned char *);
13318
13319 void vec_stl (vector float, int, vector float *);
13320 void vec_stl (vector float, int, float *);
13321 void vec_stl (vector signed int, int, vector signed int *);
13322 void vec_stl (vector signed int, int, int *);
13323 void vec_stl (vector unsigned int, int, vector unsigned int *);
13324 void vec_stl (vector unsigned int, int, unsigned int *);
13325 void vec_stl (vector bool int, int, vector bool int *);
13326 void vec_stl (vector bool int, int, unsigned int *);
13327 void vec_stl (vector bool int, int, int *);
13328 void vec_stl (vector signed short, int, vector signed short *);
13329 void vec_stl (vector signed short, int, short *);
13330 void vec_stl (vector unsigned short, int, vector unsigned short *);
13331 void vec_stl (vector unsigned short, int, unsigned short *);
13332 void vec_stl (vector bool short, int, vector bool short *);
13333 void vec_stl (vector bool short, int, unsigned short *);
13334 void vec_stl (vector bool short, int, short *);
13335 void vec_stl (vector pixel, int, vector pixel *);
13336 void vec_stl (vector pixel, int, unsigned short *);
13337 void vec_stl (vector pixel, int, short *);
13338 void vec_stl (vector signed char, int, vector signed char *);
13339 void vec_stl (vector signed char, int, signed char *);
13340 void vec_stl (vector unsigned char, int, vector unsigned char *);
13341 void vec_stl (vector unsigned char, int, unsigned char *);
13342 void vec_stl (vector bool char, int, vector bool char *);
13343 void vec_stl (vector bool char, int, unsigned char *);
13344 void vec_stl (vector bool char, int, signed char *);
13345
13346 vector signed char vec_sub (vector bool char, vector signed char);
13347 vector signed char vec_sub (vector signed char, vector bool char);
13348 vector signed char vec_sub (vector signed char, vector signed char);
13349 vector unsigned char vec_sub (vector bool char, vector unsigned char);
13350 vector unsigned char vec_sub (vector unsigned char, vector bool char);
13351 vector unsigned char vec_sub (vector unsigned char,
13352 vector unsigned char);
13353 vector signed short vec_sub (vector bool short, vector signed short);
13354 vector signed short vec_sub (vector signed short, vector bool short);
13355 vector signed short vec_sub (vector signed short, vector signed short);
13356 vector unsigned short vec_sub (vector bool short,
13357 vector unsigned short);
13358 vector unsigned short vec_sub (vector unsigned short,
13359 vector bool short);
13360 vector unsigned short vec_sub (vector unsigned short,
13361 vector unsigned short);
13362 vector signed int vec_sub (vector bool int, vector signed int);
13363 vector signed int vec_sub (vector signed int, vector bool int);
13364 vector signed int vec_sub (vector signed int, vector signed int);
13365 vector unsigned int vec_sub (vector bool int, vector unsigned int);
13366 vector unsigned int vec_sub (vector unsigned int, vector bool int);
13367 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
13368 vector float vec_sub (vector float, vector float);
13369
13370 vector float vec_vsubfp (vector float, vector float);
13371
13372 vector signed int vec_vsubuwm (vector bool int, vector signed int);
13373 vector signed int vec_vsubuwm (vector signed int, vector bool int);
13374 vector signed int vec_vsubuwm (vector signed int, vector signed int);
13375 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
13376 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
13377 vector unsigned int vec_vsubuwm (vector unsigned int,
13378 vector unsigned int);
13379
13380 vector signed short vec_vsubuhm (vector bool short,
13381 vector signed short);
13382 vector signed short vec_vsubuhm (vector signed short,
13383 vector bool short);
13384 vector signed short vec_vsubuhm (vector signed short,
13385 vector signed short);
13386 vector unsigned short vec_vsubuhm (vector bool short,
13387 vector unsigned short);
13388 vector unsigned short vec_vsubuhm (vector unsigned short,
13389 vector bool short);
13390 vector unsigned short vec_vsubuhm (vector unsigned short,
13391 vector unsigned short);
13392
13393 vector signed char vec_vsububm (vector bool char, vector signed char);
13394 vector signed char vec_vsububm (vector signed char, vector bool char);
13395 vector signed char vec_vsububm (vector signed char, vector signed char);
13396 vector unsigned char vec_vsububm (vector bool char,
13397 vector unsigned char);
13398 vector unsigned char vec_vsububm (vector unsigned char,
13399 vector bool char);
13400 vector unsigned char vec_vsububm (vector unsigned char,
13401 vector unsigned char);
13402
13403 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
13404
13405 vector unsigned char vec_subs (vector bool char, vector unsigned char);
13406 vector unsigned char vec_subs (vector unsigned char, vector bool char);
13407 vector unsigned char vec_subs (vector unsigned char,
13408 vector unsigned char);
13409 vector signed char vec_subs (vector bool char, vector signed char);
13410 vector signed char vec_subs (vector signed char, vector bool char);
13411 vector signed char vec_subs (vector signed char, vector signed char);
13412 vector unsigned short vec_subs (vector bool short,
13413 vector unsigned short);
13414 vector unsigned short vec_subs (vector unsigned short,
13415 vector bool short);
13416 vector unsigned short vec_subs (vector unsigned short,
13417 vector unsigned short);
13418 vector signed short vec_subs (vector bool short, vector signed short);
13419 vector signed short vec_subs (vector signed short, vector bool short);
13420 vector signed short vec_subs (vector signed short, vector signed short);
13421 vector unsigned int vec_subs (vector bool int, vector unsigned int);
13422 vector unsigned int vec_subs (vector unsigned int, vector bool int);
13423 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
13424 vector signed int vec_subs (vector bool int, vector signed int);
13425 vector signed int vec_subs (vector signed int, vector bool int);
13426 vector signed int vec_subs (vector signed int, vector signed int);
13427
13428 vector signed int vec_vsubsws (vector bool int, vector signed int);
13429 vector signed int vec_vsubsws (vector signed int, vector bool int);
13430 vector signed int vec_vsubsws (vector signed int, vector signed int);
13431
13432 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
13433 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
13434 vector unsigned int vec_vsubuws (vector unsigned int,
13435 vector unsigned int);
13436
13437 vector signed short vec_vsubshs (vector bool short,
13438 vector signed short);
13439 vector signed short vec_vsubshs (vector signed short,
13440 vector bool short);
13441 vector signed short vec_vsubshs (vector signed short,
13442 vector signed short);
13443
13444 vector unsigned short vec_vsubuhs (vector bool short,
13445 vector unsigned short);
13446 vector unsigned short vec_vsubuhs (vector unsigned short,
13447 vector bool short);
13448 vector unsigned short vec_vsubuhs (vector unsigned short,
13449 vector unsigned short);
13450
13451 vector signed char vec_vsubsbs (vector bool char, vector signed char);
13452 vector signed char vec_vsubsbs (vector signed char, vector bool char);
13453 vector signed char vec_vsubsbs (vector signed char, vector signed char);
13454
13455 vector unsigned char vec_vsububs (vector bool char,
13456 vector unsigned char);
13457 vector unsigned char vec_vsububs (vector unsigned char,
13458 vector bool char);
13459 vector unsigned char vec_vsububs (vector unsigned char,
13460 vector unsigned char);
13461
13462 vector unsigned int vec_sum4s (vector unsigned char,
13463 vector unsigned int);
13464 vector signed int vec_sum4s (vector signed char, vector signed int);
13465 vector signed int vec_sum4s (vector signed short, vector signed int);
13466
13467 vector signed int vec_vsum4shs (vector signed short, vector signed int);
13468
13469 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
13470
13471 vector unsigned int vec_vsum4ubs (vector unsigned char,
13472 vector unsigned int);
13473
13474 vector signed int vec_sum2s (vector signed int, vector signed int);
13475
13476 vector signed int vec_sums (vector signed int, vector signed int);
13477
13478 vector float vec_trunc (vector float);
13479
13480 vector signed short vec_unpackh (vector signed char);
13481 vector bool short vec_unpackh (vector bool char);
13482 vector signed int vec_unpackh (vector signed short);
13483 vector bool int vec_unpackh (vector bool short);
13484 vector unsigned int vec_unpackh (vector pixel);
13485
13486 vector bool int vec_vupkhsh (vector bool short);
13487 vector signed int vec_vupkhsh (vector signed short);
13488
13489 vector unsigned int vec_vupkhpx (vector pixel);
13490
13491 vector bool short vec_vupkhsb (vector bool char);
13492 vector signed short vec_vupkhsb (vector signed char);
13493
13494 vector signed short vec_unpackl (vector signed char);
13495 vector bool short vec_unpackl (vector bool char);
13496 vector unsigned int vec_unpackl (vector pixel);
13497 vector signed int vec_unpackl (vector signed short);
13498 vector bool int vec_unpackl (vector bool short);
13499
13500 vector unsigned int vec_vupklpx (vector pixel);
13501
13502 vector bool int vec_vupklsh (vector bool short);
13503 vector signed int vec_vupklsh (vector signed short);
13504
13505 vector bool short vec_vupklsb (vector bool char);
13506 vector signed short vec_vupklsb (vector signed char);
13507
13508 vector float vec_xor (vector float, vector float);
13509 vector float vec_xor (vector float, vector bool int);
13510 vector float vec_xor (vector bool int, vector float);
13511 vector bool int vec_xor (vector bool int, vector bool int);
13512 vector signed int vec_xor (vector bool int, vector signed int);
13513 vector signed int vec_xor (vector signed int, vector bool int);
13514 vector signed int vec_xor (vector signed int, vector signed int);
13515 vector unsigned int vec_xor (vector bool int, vector unsigned int);
13516 vector unsigned int vec_xor (vector unsigned int, vector bool int);
13517 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
13518 vector bool short vec_xor (vector bool short, vector bool short);
13519 vector signed short vec_xor (vector bool short, vector signed short);
13520 vector signed short vec_xor (vector signed short, vector bool short);
13521 vector signed short vec_xor (vector signed short, vector signed short);
13522 vector unsigned short vec_xor (vector bool short,
13523 vector unsigned short);
13524 vector unsigned short vec_xor (vector unsigned short,
13525 vector bool short);
13526 vector unsigned short vec_xor (vector unsigned short,
13527 vector unsigned short);
13528 vector signed char vec_xor (vector bool char, vector signed char);
13529 vector bool char vec_xor (vector bool char, vector bool char);
13530 vector signed char vec_xor (vector signed char, vector bool char);
13531 vector signed char vec_xor (vector signed char, vector signed char);
13532 vector unsigned char vec_xor (vector bool char, vector unsigned char);
13533 vector unsigned char vec_xor (vector unsigned char, vector bool char);
13534 vector unsigned char vec_xor (vector unsigned char,
13535 vector unsigned char);
13536
13537 int vec_all_eq (vector signed char, vector bool char);
13538 int vec_all_eq (vector signed char, vector signed char);
13539 int vec_all_eq (vector unsigned char, vector bool char);
13540 int vec_all_eq (vector unsigned char, vector unsigned char);
13541 int vec_all_eq (vector bool char, vector bool char);
13542 int vec_all_eq (vector bool char, vector unsigned char);
13543 int vec_all_eq (vector bool char, vector signed char);
13544 int vec_all_eq (vector signed short, vector bool short);
13545 int vec_all_eq (vector signed short, vector signed short);
13546 int vec_all_eq (vector unsigned short, vector bool short);
13547 int vec_all_eq (vector unsigned short, vector unsigned short);
13548 int vec_all_eq (vector bool short, vector bool short);
13549 int vec_all_eq (vector bool short, vector unsigned short);
13550 int vec_all_eq (vector bool short, vector signed short);
13551 int vec_all_eq (vector pixel, vector pixel);
13552 int vec_all_eq (vector signed int, vector bool int);
13553 int vec_all_eq (vector signed int, vector signed int);
13554 int vec_all_eq (vector unsigned int, vector bool int);
13555 int vec_all_eq (vector unsigned int, vector unsigned int);
13556 int vec_all_eq (vector bool int, vector bool int);
13557 int vec_all_eq (vector bool int, vector unsigned int);
13558 int vec_all_eq (vector bool int, vector signed int);
13559 int vec_all_eq (vector float, vector float);
13560
13561 int vec_all_ge (vector bool char, vector unsigned char);
13562 int vec_all_ge (vector unsigned char, vector bool char);
13563 int vec_all_ge (vector unsigned char, vector unsigned char);
13564 int vec_all_ge (vector bool char, vector signed char);
13565 int vec_all_ge (vector signed char, vector bool char);
13566 int vec_all_ge (vector signed char, vector signed char);
13567 int vec_all_ge (vector bool short, vector unsigned short);
13568 int vec_all_ge (vector unsigned short, vector bool short);
13569 int vec_all_ge (vector unsigned short, vector unsigned short);
13570 int vec_all_ge (vector signed short, vector signed short);
13571 int vec_all_ge (vector bool short, vector signed short);
13572 int vec_all_ge (vector signed short, vector bool short);
13573 int vec_all_ge (vector bool int, vector unsigned int);
13574 int vec_all_ge (vector unsigned int, vector bool int);
13575 int vec_all_ge (vector unsigned int, vector unsigned int);
13576 int vec_all_ge (vector bool int, vector signed int);
13577 int vec_all_ge (vector signed int, vector bool int);
13578 int vec_all_ge (vector signed int, vector signed int);
13579 int vec_all_ge (vector float, vector float);
13580
13581 int vec_all_gt (vector bool char, vector unsigned char);
13582 int vec_all_gt (vector unsigned char, vector bool char);
13583 int vec_all_gt (vector unsigned char, vector unsigned char);
13584 int vec_all_gt (vector bool char, vector signed char);
13585 int vec_all_gt (vector signed char, vector bool char);
13586 int vec_all_gt (vector signed char, vector signed char);
13587 int vec_all_gt (vector bool short, vector unsigned short);
13588 int vec_all_gt (vector unsigned short, vector bool short);
13589 int vec_all_gt (vector unsigned short, vector unsigned short);
13590 int vec_all_gt (vector bool short, vector signed short);
13591 int vec_all_gt (vector signed short, vector bool short);
13592 int vec_all_gt (vector signed short, vector signed short);
13593 int vec_all_gt (vector bool int, vector unsigned int);
13594 int vec_all_gt (vector unsigned int, vector bool int);
13595 int vec_all_gt (vector unsigned int, vector unsigned int);
13596 int vec_all_gt (vector bool int, vector signed int);
13597 int vec_all_gt (vector signed int, vector bool int);
13598 int vec_all_gt (vector signed int, vector signed int);
13599 int vec_all_gt (vector float, vector float);
13600
13601 int vec_all_in (vector float, vector float);
13602
13603 int vec_all_le (vector bool char, vector unsigned char);
13604 int vec_all_le (vector unsigned char, vector bool char);
13605 int vec_all_le (vector unsigned char, vector unsigned char);
13606 int vec_all_le (vector bool char, vector signed char);
13607 int vec_all_le (vector signed char, vector bool char);
13608 int vec_all_le (vector signed char, vector signed char);
13609 int vec_all_le (vector bool short, vector unsigned short);
13610 int vec_all_le (vector unsigned short, vector bool short);
13611 int vec_all_le (vector unsigned short, vector unsigned short);
13612 int vec_all_le (vector bool short, vector signed short);
13613 int vec_all_le (vector signed short, vector bool short);
13614 int vec_all_le (vector signed short, vector signed short);
13615 int vec_all_le (vector bool int, vector unsigned int);
13616 int vec_all_le (vector unsigned int, vector bool int);
13617 int vec_all_le (vector unsigned int, vector unsigned int);
13618 int vec_all_le (vector bool int, vector signed int);
13619 int vec_all_le (vector signed int, vector bool int);
13620 int vec_all_le (vector signed int, vector signed int);
13621 int vec_all_le (vector float, vector float);
13622
13623 int vec_all_lt (vector bool char, vector unsigned char);
13624 int vec_all_lt (vector unsigned char, vector bool char);
13625 int vec_all_lt (vector unsigned char, vector unsigned char);
13626 int vec_all_lt (vector bool char, vector signed char);
13627 int vec_all_lt (vector signed char, vector bool char);
13628 int vec_all_lt (vector signed char, vector signed char);
13629 int vec_all_lt (vector bool short, vector unsigned short);
13630 int vec_all_lt (vector unsigned short, vector bool short);
13631 int vec_all_lt (vector unsigned short, vector unsigned short);
13632 int vec_all_lt (vector bool short, vector signed short);
13633 int vec_all_lt (vector signed short, vector bool short);
13634 int vec_all_lt (vector signed short, vector signed short);
13635 int vec_all_lt (vector bool int, vector unsigned int);
13636 int vec_all_lt (vector unsigned int, vector bool int);
13637 int vec_all_lt (vector unsigned int, vector unsigned int);
13638 int vec_all_lt (vector bool int, vector signed int);
13639 int vec_all_lt (vector signed int, vector bool int);
13640 int vec_all_lt (vector signed int, vector signed int);
13641 int vec_all_lt (vector float, vector float);
13642
13643 int vec_all_nan (vector float);
13644
13645 int vec_all_ne (vector signed char, vector bool char);
13646 int vec_all_ne (vector signed char, vector signed char);
13647 int vec_all_ne (vector unsigned char, vector bool char);
13648 int vec_all_ne (vector unsigned char, vector unsigned char);
13649 int vec_all_ne (vector bool char, vector bool char);
13650 int vec_all_ne (vector bool char, vector unsigned char);
13651 int vec_all_ne (vector bool char, vector signed char);
13652 int vec_all_ne (vector signed short, vector bool short);
13653 int vec_all_ne (vector signed short, vector signed short);
13654 int vec_all_ne (vector unsigned short, vector bool short);
13655 int vec_all_ne (vector unsigned short, vector unsigned short);
13656 int vec_all_ne (vector bool short, vector bool short);
13657 int vec_all_ne (vector bool short, vector unsigned short);
13658 int vec_all_ne (vector bool short, vector signed short);
13659 int vec_all_ne (vector pixel, vector pixel);
13660 int vec_all_ne (vector signed int, vector bool int);
13661 int vec_all_ne (vector signed int, vector signed int);
13662 int vec_all_ne (vector unsigned int, vector bool int);
13663 int vec_all_ne (vector unsigned int, vector unsigned int);
13664 int vec_all_ne (vector bool int, vector bool int);
13665 int vec_all_ne (vector bool int, vector unsigned int);
13666 int vec_all_ne (vector bool int, vector signed int);
13667 int vec_all_ne (vector float, vector float);
13668
13669 int vec_all_nge (vector float, vector float);
13670
13671 int vec_all_ngt (vector float, vector float);
13672
13673 int vec_all_nle (vector float, vector float);
13674
13675 int vec_all_nlt (vector float, vector float);
13676
13677 int vec_all_numeric (vector float);
13678
13679 int vec_any_eq (vector signed char, vector bool char);
13680 int vec_any_eq (vector signed char, vector signed char);
13681 int vec_any_eq (vector unsigned char, vector bool char);
13682 int vec_any_eq (vector unsigned char, vector unsigned char);
13683 int vec_any_eq (vector bool char, vector bool char);
13684 int vec_any_eq (vector bool char, vector unsigned char);
13685 int vec_any_eq (vector bool char, vector signed char);
13686 int vec_any_eq (vector signed short, vector bool short);
13687 int vec_any_eq (vector signed short, vector signed short);
13688 int vec_any_eq (vector unsigned short, vector bool short);
13689 int vec_any_eq (vector unsigned short, vector unsigned short);
13690 int vec_any_eq (vector bool short, vector bool short);
13691 int vec_any_eq (vector bool short, vector unsigned short);
13692 int vec_any_eq (vector bool short, vector signed short);
13693 int vec_any_eq (vector pixel, vector pixel);
13694 int vec_any_eq (vector signed int, vector bool int);
13695 int vec_any_eq (vector signed int, vector signed int);
13696 int vec_any_eq (vector unsigned int, vector bool int);
13697 int vec_any_eq (vector unsigned int, vector unsigned int);
13698 int vec_any_eq (vector bool int, vector bool int);
13699 int vec_any_eq (vector bool int, vector unsigned int);
13700 int vec_any_eq (vector bool int, vector signed int);
13701 int vec_any_eq (vector float, vector float);
13702
13703 int vec_any_ge (vector signed char, vector bool char);
13704 int vec_any_ge (vector unsigned char, vector bool char);
13705 int vec_any_ge (vector unsigned char, vector unsigned char);
13706 int vec_any_ge (vector signed char, vector signed char);
13707 int vec_any_ge (vector bool char, vector unsigned char);
13708 int vec_any_ge (vector bool char, vector signed char);
13709 int vec_any_ge (vector unsigned short, vector bool short);
13710 int vec_any_ge (vector unsigned short, vector unsigned short);
13711 int vec_any_ge (vector signed short, vector signed short);
13712 int vec_any_ge (vector signed short, vector bool short);
13713 int vec_any_ge (vector bool short, vector unsigned short);
13714 int vec_any_ge (vector bool short, vector signed short);
13715 int vec_any_ge (vector signed int, vector bool int);
13716 int vec_any_ge (vector unsigned int, vector bool int);
13717 int vec_any_ge (vector unsigned int, vector unsigned int);
13718 int vec_any_ge (vector signed int, vector signed int);
13719 int vec_any_ge (vector bool int, vector unsigned int);
13720 int vec_any_ge (vector bool int, vector signed int);
13721 int vec_any_ge (vector float, vector float);
13722
13723 int vec_any_gt (vector bool char, vector unsigned char);
13724 int vec_any_gt (vector unsigned char, vector bool char);
13725 int vec_any_gt (vector unsigned char, vector unsigned char);
13726 int vec_any_gt (vector bool char, vector signed char);
13727 int vec_any_gt (vector signed char, vector bool char);
13728 int vec_any_gt (vector signed char, vector signed char);
13729 int vec_any_gt (vector bool short, vector unsigned short);
13730 int vec_any_gt (vector unsigned short, vector bool short);
13731 int vec_any_gt (vector unsigned short, vector unsigned short);
13732 int vec_any_gt (vector bool short, vector signed short);
13733 int vec_any_gt (vector signed short, vector bool short);
13734 int vec_any_gt (vector signed short, vector signed short);
13735 int vec_any_gt (vector bool int, vector unsigned int);
13736 int vec_any_gt (vector unsigned int, vector bool int);
13737 int vec_any_gt (vector unsigned int, vector unsigned int);
13738 int vec_any_gt (vector bool int, vector signed int);
13739 int vec_any_gt (vector signed int, vector bool int);
13740 int vec_any_gt (vector signed int, vector signed int);
13741 int vec_any_gt (vector float, vector float);
13742
13743 int vec_any_le (vector bool char, vector unsigned char);
13744 int vec_any_le (vector unsigned char, vector bool char);
13745 int vec_any_le (vector unsigned char, vector unsigned char);
13746 int vec_any_le (vector bool char, vector signed char);
13747 int vec_any_le (vector signed char, vector bool char);
13748 int vec_any_le (vector signed char, vector signed char);
13749 int vec_any_le (vector bool short, vector unsigned short);
13750 int vec_any_le (vector unsigned short, vector bool short);
13751 int vec_any_le (vector unsigned short, vector unsigned short);
13752 int vec_any_le (vector bool short, vector signed short);
13753 int vec_any_le (vector signed short, vector bool short);
13754 int vec_any_le (vector signed short, vector signed short);
13755 int vec_any_le (vector bool int, vector unsigned int);
13756 int vec_any_le (vector unsigned int, vector bool int);
13757 int vec_any_le (vector unsigned int, vector unsigned int);
13758 int vec_any_le (vector bool int, vector signed int);
13759 int vec_any_le (vector signed int, vector bool int);
13760 int vec_any_le (vector signed int, vector signed int);
13761 int vec_any_le (vector float, vector float);
13762
13763 int vec_any_lt (vector bool char, vector unsigned char);
13764 int vec_any_lt (vector unsigned char, vector bool char);
13765 int vec_any_lt (vector unsigned char, vector unsigned char);
13766 int vec_any_lt (vector bool char, vector signed char);
13767 int vec_any_lt (vector signed char, vector bool char);
13768 int vec_any_lt (vector signed char, vector signed char);
13769 int vec_any_lt (vector bool short, vector unsigned short);
13770 int vec_any_lt (vector unsigned short, vector bool short);
13771 int vec_any_lt (vector unsigned short, vector unsigned short);
13772 int vec_any_lt (vector bool short, vector signed short);
13773 int vec_any_lt (vector signed short, vector bool short);
13774 int vec_any_lt (vector signed short, vector signed short);
13775 int vec_any_lt (vector bool int, vector unsigned int);
13776 int vec_any_lt (vector unsigned int, vector bool int);
13777 int vec_any_lt (vector unsigned int, vector unsigned int);
13778 int vec_any_lt (vector bool int, vector signed int);
13779 int vec_any_lt (vector signed int, vector bool int);
13780 int vec_any_lt (vector signed int, vector signed int);
13781 int vec_any_lt (vector float, vector float);
13782
13783 int vec_any_nan (vector float);
13784
13785 int vec_any_ne (vector signed char, vector bool char);
13786 int vec_any_ne (vector signed char, vector signed char);
13787 int vec_any_ne (vector unsigned char, vector bool char);
13788 int vec_any_ne (vector unsigned char, vector unsigned char);
13789 int vec_any_ne (vector bool char, vector bool char);
13790 int vec_any_ne (vector bool char, vector unsigned char);
13791 int vec_any_ne (vector bool char, vector signed char);
13792 int vec_any_ne (vector signed short, vector bool short);
13793 int vec_any_ne (vector signed short, vector signed short);
13794 int vec_any_ne (vector unsigned short, vector bool short);
13795 int vec_any_ne (vector unsigned short, vector unsigned short);
13796 int vec_any_ne (vector bool short, vector bool short);
13797 int vec_any_ne (vector bool short, vector unsigned short);
13798 int vec_any_ne (vector bool short, vector signed short);
13799 int vec_any_ne (vector pixel, vector pixel);
13800 int vec_any_ne (vector signed int, vector bool int);
13801 int vec_any_ne (vector signed int, vector signed int);
13802 int vec_any_ne (vector unsigned int, vector bool int);
13803 int vec_any_ne (vector unsigned int, vector unsigned int);
13804 int vec_any_ne (vector bool int, vector bool int);
13805 int vec_any_ne (vector bool int, vector unsigned int);
13806 int vec_any_ne (vector bool int, vector signed int);
13807 int vec_any_ne (vector float, vector float);
13808
13809 int vec_any_nge (vector float, vector float);
13810
13811 int vec_any_ngt (vector float, vector float);
13812
13813 int vec_any_nle (vector float, vector float);
13814
13815 int vec_any_nlt (vector float, vector float);
13816
13817 int vec_any_numeric (vector float);
13818
13819 int vec_any_out (vector float, vector float);
13820 @end smallexample
13821
13822 If the vector/scalar (VSX) instruction set is available, the following
13823 additional functions are available:
13824
13825 @smallexample
13826 vector double vec_abs (vector double);
13827 vector double vec_add (vector double, vector double);
13828 vector double vec_and (vector double, vector double);
13829 vector double vec_and (vector double, vector bool long);
13830 vector double vec_and (vector bool long, vector double);
13831 vector double vec_andc (vector double, vector double);
13832 vector double vec_andc (vector double, vector bool long);
13833 vector double vec_andc (vector bool long, vector double);
13834 vector double vec_ceil (vector double);
13835 vector bool long vec_cmpeq (vector double, vector double);
13836 vector bool long vec_cmpge (vector double, vector double);
13837 vector bool long vec_cmpgt (vector double, vector double);
13838 vector bool long vec_cmple (vector double, vector double);
13839 vector bool long vec_cmplt (vector double, vector double);
13840 vector float vec_div (vector float, vector float);
13841 vector double vec_div (vector double, vector double);
13842 vector double vec_floor (vector double);
13843 vector double vec_ld (int, const vector double *);
13844 vector double vec_ld (int, const double *);
13845 vector double vec_ldl (int, const vector double *);
13846 vector double vec_ldl (int, const double *);
13847 vector unsigned char vec_lvsl (int, const volatile double *);
13848 vector unsigned char vec_lvsr (int, const volatile double *);
13849 vector double vec_madd (vector double, vector double, vector double);
13850 vector double vec_max (vector double, vector double);
13851 vector double vec_min (vector double, vector double);
13852 vector float vec_msub (vector float, vector float, vector float);
13853 vector double vec_msub (vector double, vector double, vector double);
13854 vector float vec_mul (vector float, vector float);
13855 vector double vec_mul (vector double, vector double);
13856 vector float vec_nearbyint (vector float);
13857 vector double vec_nearbyint (vector double);
13858 vector float vec_nmadd (vector float, vector float, vector float);
13859 vector double vec_nmadd (vector double, vector double, vector double);
13860 vector double vec_nmsub (vector double, vector double, vector double);
13861 vector double vec_nor (vector double, vector double);
13862 vector double vec_or (vector double, vector double);
13863 vector double vec_or (vector double, vector bool long);
13864 vector double vec_or (vector bool long, vector double);
13865 vector double vec_perm (vector double,
13866 vector double,
13867 vector unsigned char);
13868 vector double vec_rint (vector double);
13869 vector double vec_recip (vector double, vector double);
13870 vector double vec_rsqrt (vector double);
13871 vector double vec_rsqrte (vector double);
13872 vector double vec_sel (vector double, vector double, vector bool long);
13873 vector double vec_sel (vector double, vector double, vector unsigned long);
13874 vector double vec_sub (vector double, vector double);
13875 vector float vec_sqrt (vector float);
13876 vector double vec_sqrt (vector double);
13877 void vec_st (vector double, int, vector double *);
13878 void vec_st (vector double, int, double *);
13879 vector double vec_trunc (vector double);
13880 vector double vec_xor (vector double, vector double);
13881 vector double vec_xor (vector double, vector bool long);
13882 vector double vec_xor (vector bool long, vector double);
13883 int vec_all_eq (vector double, vector double);
13884 int vec_all_ge (vector double, vector double);
13885 int vec_all_gt (vector double, vector double);
13886 int vec_all_le (vector double, vector double);
13887 int vec_all_lt (vector double, vector double);
13888 int vec_all_nan (vector double);
13889 int vec_all_ne (vector double, vector double);
13890 int vec_all_nge (vector double, vector double);
13891 int vec_all_ngt (vector double, vector double);
13892 int vec_all_nle (vector double, vector double);
13893 int vec_all_nlt (vector double, vector double);
13894 int vec_all_numeric (vector double);
13895 int vec_any_eq (vector double, vector double);
13896 int vec_any_ge (vector double, vector double);
13897 int vec_any_gt (vector double, vector double);
13898 int vec_any_le (vector double, vector double);
13899 int vec_any_lt (vector double, vector double);
13900 int vec_any_nan (vector double);
13901 int vec_any_ne (vector double, vector double);
13902 int vec_any_nge (vector double, vector double);
13903 int vec_any_ngt (vector double, vector double);
13904 int vec_any_nle (vector double, vector double);
13905 int vec_any_nlt (vector double, vector double);
13906 int vec_any_numeric (vector double);
13907
13908 vector double vec_vsx_ld (int, const vector double *);
13909 vector double vec_vsx_ld (int, const double *);
13910 vector float vec_vsx_ld (int, const vector float *);
13911 vector float vec_vsx_ld (int, const float *);
13912 vector bool int vec_vsx_ld (int, const vector bool int *);
13913 vector signed int vec_vsx_ld (int, const vector signed int *);
13914 vector signed int vec_vsx_ld (int, const int *);
13915 vector signed int vec_vsx_ld (int, const long *);
13916 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
13917 vector unsigned int vec_vsx_ld (int, const unsigned int *);
13918 vector unsigned int vec_vsx_ld (int, const unsigned long *);
13919 vector bool short vec_vsx_ld (int, const vector bool short *);
13920 vector pixel vec_vsx_ld (int, const vector pixel *);
13921 vector signed short vec_vsx_ld (int, const vector signed short *);
13922 vector signed short vec_vsx_ld (int, const short *);
13923 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
13924 vector unsigned short vec_vsx_ld (int, const unsigned short *);
13925 vector bool char vec_vsx_ld (int, const vector bool char *);
13926 vector signed char vec_vsx_ld (int, const vector signed char *);
13927 vector signed char vec_vsx_ld (int, const signed char *);
13928 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
13929 vector unsigned char vec_vsx_ld (int, const unsigned char *);
13930
13931 void vec_vsx_st (vector double, int, vector double *);
13932 void vec_vsx_st (vector double, int, double *);
13933 void vec_vsx_st (vector float, int, vector float *);
13934 void vec_vsx_st (vector float, int, float *);
13935 void vec_vsx_st (vector signed int, int, vector signed int *);
13936 void vec_vsx_st (vector signed int, int, int *);
13937 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
13938 void vec_vsx_st (vector unsigned int, int, unsigned int *);
13939 void vec_vsx_st (vector bool int, int, vector bool int *);
13940 void vec_vsx_st (vector bool int, int, unsigned int *);
13941 void vec_vsx_st (vector bool int, int, int *);
13942 void vec_vsx_st (vector signed short, int, vector signed short *);
13943 void vec_vsx_st (vector signed short, int, short *);
13944 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
13945 void vec_vsx_st (vector unsigned short, int, unsigned short *);
13946 void vec_vsx_st (vector bool short, int, vector bool short *);
13947 void vec_vsx_st (vector bool short, int, unsigned short *);
13948 void vec_vsx_st (vector pixel, int, vector pixel *);
13949 void vec_vsx_st (vector pixel, int, unsigned short *);
13950 void vec_vsx_st (vector pixel, int, short *);
13951 void vec_vsx_st (vector bool short, int, short *);
13952 void vec_vsx_st (vector signed char, int, vector signed char *);
13953 void vec_vsx_st (vector signed char, int, signed char *);
13954 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
13955 void vec_vsx_st (vector unsigned char, int, unsigned char *);
13956 void vec_vsx_st (vector bool char, int, vector bool char *);
13957 void vec_vsx_st (vector bool char, int, unsigned char *);
13958 void vec_vsx_st (vector bool char, int, signed char *);
13959 @end smallexample
13960
13961 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
13962 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
13963 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
13964 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
13965 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
13966
13967 If the ISA 2.07 additions to the vector/scalar (power8-vector)
13968 instruction set is available, the following additional functions are
13969 available for both 32-bit and 64-bit targets. For 64-bit targets, you
13970 can use @var{vector long} instead of @var{vector long long},
13971 @var{vector bool long} instead of @var{vector bool long long}, and
13972 @var{vector unsigned long} instead of @var{vector unsigned long long}.
13973
13974 @smallexample
13975 vector long long vec_abs (vector long long);
13976
13977 vector long long vec_add (vector long long, vector long long);
13978 vector unsigned long long vec_add (vector unsigned long long,
13979 vector unsigned long long);
13980
13981 int vec_all_eq (vector long long, vector long long);
13982 int vec_all_ge (vector long long, vector long long);
13983 int vec_all_gt (vector long long, vector long long);
13984 int vec_all_le (vector long long, vector long long);
13985 int vec_all_lt (vector long long, vector long long);
13986 int vec_all_ne (vector long long, vector long long);
13987 int vec_any_eq (vector long long, vector long long);
13988 int vec_any_ge (vector long long, vector long long);
13989 int vec_any_gt (vector long long, vector long long);
13990 int vec_any_le (vector long long, vector long long);
13991 int vec_any_lt (vector long long, vector long long);
13992 int vec_any_ne (vector long long, vector long long);
13993
13994 vector long long vec_eqv (vector long long, vector long long);
13995 vector long long vec_eqv (vector bool long long, vector long long);
13996 vector long long vec_eqv (vector long long, vector bool long long);
13997 vector unsigned long long vec_eqv (vector unsigned long long,
13998 vector unsigned long long);
13999 vector unsigned long long vec_eqv (vector bool long long,
14000 vector unsigned long long);
14001 vector unsigned long long vec_eqv (vector unsigned long long,
14002 vector bool long long);
14003 vector int vec_eqv (vector int, vector int);
14004 vector int vec_eqv (vector bool int, vector int);
14005 vector int vec_eqv (vector int, vector bool int);
14006 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
14007 vector unsigned int vec_eqv (vector bool unsigned int,
14008 vector unsigned int);
14009 vector unsigned int vec_eqv (vector unsigned int,
14010 vector bool unsigned int);
14011 vector short vec_eqv (vector short, vector short);
14012 vector short vec_eqv (vector bool short, vector short);
14013 vector short vec_eqv (vector short, vector bool short);
14014 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
14015 vector unsigned short vec_eqv (vector bool unsigned short,
14016 vector unsigned short);
14017 vector unsigned short vec_eqv (vector unsigned short,
14018 vector bool unsigned short);
14019 vector signed char vec_eqv (vector signed char, vector signed char);
14020 vector signed char vec_eqv (vector bool signed char, vector signed char);
14021 vector signed char vec_eqv (vector signed char, vector bool signed char);
14022 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
14023 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
14024 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
14025
14026 vector long long vec_max (vector long long, vector long long);
14027 vector unsigned long long vec_max (vector unsigned long long,
14028 vector unsigned long long);
14029
14030 vector long long vec_min (vector long long, vector long long);
14031 vector unsigned long long vec_min (vector unsigned long long,
14032 vector unsigned long long);
14033
14034 vector long long vec_nand (vector long long, vector long long);
14035 vector long long vec_nand (vector bool long long, vector long long);
14036 vector long long vec_nand (vector long long, vector bool long long);
14037 vector unsigned long long vec_nand (vector unsigned long long,
14038 vector unsigned long long);
14039 vector unsigned long long vec_nand (vector bool long long,
14040 vector unsigned long long);
14041 vector unsigned long long vec_nand (vector unsigned long long,
14042 vector bool long long);
14043 vector int vec_nand (vector int, vector int);
14044 vector int vec_nand (vector bool int, vector int);
14045 vector int vec_nand (vector int, vector bool int);
14046 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
14047 vector unsigned int vec_nand (vector bool unsigned int,
14048 vector unsigned int);
14049 vector unsigned int vec_nand (vector unsigned int,
14050 vector bool unsigned int);
14051 vector short vec_nand (vector short, vector short);
14052 vector short vec_nand (vector bool short, vector short);
14053 vector short vec_nand (vector short, vector bool short);
14054 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
14055 vector unsigned short vec_nand (vector bool unsigned short,
14056 vector unsigned short);
14057 vector unsigned short vec_nand (vector unsigned short,
14058 vector bool unsigned short);
14059 vector signed char vec_nand (vector signed char, vector signed char);
14060 vector signed char vec_nand (vector bool signed char, vector signed char);
14061 vector signed char vec_nand (vector signed char, vector bool signed char);
14062 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
14063 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
14064 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
14065
14066 vector long long vec_orc (vector long long, vector long long);
14067 vector long long vec_orc (vector bool long long, vector long long);
14068 vector long long vec_orc (vector long long, vector bool long long);
14069 vector unsigned long long vec_orc (vector unsigned long long,
14070 vector unsigned long long);
14071 vector unsigned long long vec_orc (vector bool long long,
14072 vector unsigned long long);
14073 vector unsigned long long vec_orc (vector unsigned long long,
14074 vector bool long long);
14075 vector int vec_orc (vector int, vector int);
14076 vector int vec_orc (vector bool int, vector int);
14077 vector int vec_orc (vector int, vector bool int);
14078 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
14079 vector unsigned int vec_orc (vector bool unsigned int,
14080 vector unsigned int);
14081 vector unsigned int vec_orc (vector unsigned int,
14082 vector bool unsigned int);
14083 vector short vec_orc (vector short, vector short);
14084 vector short vec_orc (vector bool short, vector short);
14085 vector short vec_orc (vector short, vector bool short);
14086 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
14087 vector unsigned short vec_orc (vector bool unsigned short,
14088 vector unsigned short);
14089 vector unsigned short vec_orc (vector unsigned short,
14090 vector bool unsigned short);
14091 vector signed char vec_orc (vector signed char, vector signed char);
14092 vector signed char vec_orc (vector bool signed char, vector signed char);
14093 vector signed char vec_orc (vector signed char, vector bool signed char);
14094 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
14095 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
14096 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
14097
14098 vector int vec_pack (vector long long, vector long long);
14099 vector unsigned int vec_pack (vector unsigned long long,
14100 vector unsigned long long);
14101 vector bool int vec_pack (vector bool long long, vector bool long long);
14102
14103 vector int vec_packs (vector long long, vector long long);
14104 vector unsigned int vec_packs (vector unsigned long long,
14105 vector unsigned long long);
14106
14107 vector unsigned int vec_packsu (vector long long, vector long long);
14108
14109 vector long long vec_rl (vector long long,
14110 vector unsigned long long);
14111 vector long long vec_rl (vector unsigned long long,
14112 vector unsigned long long);
14113
14114 vector long long vec_sl (vector long long, vector unsigned long long);
14115 vector long long vec_sl (vector unsigned long long,
14116 vector unsigned long long);
14117
14118 vector long long vec_sr (vector long long, vector unsigned long long);
14119 vector unsigned long long char vec_sr (vector unsigned long long,
14120 vector unsigned long long);
14121
14122 vector long long vec_sra (vector long long, vector unsigned long long);
14123 vector unsigned long long vec_sra (vector unsigned long long,
14124 vector unsigned long long);
14125
14126 vector long long vec_sub (vector long long, vector long long);
14127 vector unsigned long long vec_sub (vector unsigned long long,
14128 vector unsigned long long);
14129
14130 vector long long vec_unpackh (vector int);
14131 vector unsigned long long vec_unpackh (vector unsigned int);
14132
14133 vector long long vec_unpackl (vector int);
14134 vector unsigned long long vec_unpackl (vector unsigned int);
14135
14136 vector long long vec_vaddudm (vector long long, vector long long);
14137 vector long long vec_vaddudm (vector bool long long, vector long long);
14138 vector long long vec_vaddudm (vector long long, vector bool long long);
14139 vector unsigned long long vec_vaddudm (vector unsigned long long,
14140 vector unsigned long long);
14141 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
14142 vector unsigned long long);
14143 vector unsigned long long vec_vaddudm (vector unsigned long long,
14144 vector bool unsigned long long);
14145
14146 vector long long vec_vclz (vector long long);
14147 vector unsigned long long vec_vclz (vector unsigned long long);
14148 vector int vec_vclz (vector int);
14149 vector unsigned int vec_vclz (vector int);
14150 vector short vec_vclz (vector short);
14151 vector unsigned short vec_vclz (vector unsigned short);
14152 vector signed char vec_vclz (vector signed char);
14153 vector unsigned char vec_vclz (vector unsigned char);
14154
14155 vector signed char vec_vclzb (vector signed char);
14156 vector unsigned char vec_vclzb (vector unsigned char);
14157
14158 vector long long vec_vclzd (vector long long);
14159 vector unsigned long long vec_vclzd (vector unsigned long long);
14160
14161 vector short vec_vclzh (vector short);
14162 vector unsigned short vec_vclzh (vector unsigned short);
14163
14164 vector int vec_vclzw (vector int);
14165 vector unsigned int vec_vclzw (vector int);
14166
14167 vector long long vec_vmaxsd (vector long long, vector long long);
14168
14169 vector unsigned long long vec_vmaxud (vector unsigned long long,
14170 unsigned vector long long);
14171
14172 vector long long vec_vminsd (vector long long, vector long long);
14173
14174 vector unsigned long long vec_vminud (vector long long,
14175 vector long long);
14176
14177 vector int vec_vpksdss (vector long long, vector long long);
14178 vector unsigned int vec_vpksdss (vector long long, vector long long);
14179
14180 vector unsigned int vec_vpkudus (vector unsigned long long,
14181 vector unsigned long long);
14182
14183 vector int vec_vpkudum (vector long long, vector long long);
14184 vector unsigned int vec_vpkudum (vector unsigned long long,
14185 vector unsigned long long);
14186 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
14187
14188 vector long long vec_vpopcnt (vector long long);
14189 vector unsigned long long vec_vpopcnt (vector unsigned long long);
14190 vector int vec_vpopcnt (vector int);
14191 vector unsigned int vec_vpopcnt (vector int);
14192 vector short vec_vpopcnt (vector short);
14193 vector unsigned short vec_vpopcnt (vector unsigned short);
14194 vector signed char vec_vpopcnt (vector signed char);
14195 vector unsigned char vec_vpopcnt (vector unsigned char);
14196
14197 vector signed char vec_vpopcntb (vector signed char);
14198 vector unsigned char vec_vpopcntb (vector unsigned char);
14199
14200 vector long long vec_vpopcntd (vector long long);
14201 vector unsigned long long vec_vpopcntd (vector unsigned long long);
14202
14203 vector short vec_vpopcnth (vector short);
14204 vector unsigned short vec_vpopcnth (vector unsigned short);
14205
14206 vector int vec_vpopcntw (vector int);
14207 vector unsigned int vec_vpopcntw (vector int);
14208
14209 vector long long vec_vrld (vector long long, vector unsigned long long);
14210 vector unsigned long long vec_vrld (vector unsigned long long,
14211 vector unsigned long long);
14212
14213 vector long long vec_vsld (vector long long, vector unsigned long long);
14214 vector long long vec_vsld (vector unsigned long long,
14215 vector unsigned long long);
14216
14217 vector long long vec_vsrad (vector long long, vector unsigned long long);
14218 vector unsigned long long vec_vsrad (vector unsigned long long,
14219 vector unsigned long long);
14220
14221 vector long long vec_vsrd (vector long long, vector unsigned long long);
14222 vector unsigned long long char vec_vsrd (vector unsigned long long,
14223 vector unsigned long long);
14224
14225 vector long long vec_vsubudm (vector long long, vector long long);
14226 vector long long vec_vsubudm (vector bool long long, vector long long);
14227 vector long long vec_vsubudm (vector long long, vector bool long long);
14228 vector unsigned long long vec_vsubudm (vector unsigned long long,
14229 vector unsigned long long);
14230 vector unsigned long long vec_vsubudm (vector bool long long,
14231 vector unsigned long long);
14232 vector unsigned long long vec_vsubudm (vector unsigned long long,
14233 vector bool long long);
14234
14235 vector long long vec_vupkhsw (vector int);
14236 vector unsigned long long vec_vupkhsw (vector unsigned int);
14237
14238 vector long long vec_vupklsw (vector int);
14239 vector unsigned long long vec_vupklsw (vector int);
14240 @end smallexample
14241
14242 If the cryptographic instructions are enabled (@option{-mcrypto} or
14243 @option{-mcpu=power8}), the following builtins are enabled.
14244
14245 @smallexample
14246 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
14247
14248 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
14249 vector unsigned long long);
14250
14251 vector unsigned long long __builtin_crypto_vcipherlast
14252 (vector unsigned long long,
14253 vector unsigned long long);
14254
14255 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
14256 vector unsigned long long);
14257
14258 vector unsigned long long __builtin_crypto_vncipherlast
14259 (vector unsigned long long,
14260 vector unsigned long long);
14261
14262 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
14263 vector unsigned char,
14264 vector unsigned char);
14265
14266 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
14267 vector unsigned short,
14268 vector unsigned short);
14269
14270 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
14271 vector unsigned int,
14272 vector unsigned int);
14273
14274 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
14275 vector unsigned long long,
14276 vector unsigned long long);
14277
14278 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
14279 vector unsigned char);
14280
14281 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
14282 vector unsigned short);
14283
14284 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
14285 vector unsigned int);
14286
14287 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
14288 vector unsigned long long);
14289
14290 vector unsigned long long __builtin_crypto_vshasigmad
14291 (vector unsigned long long, int, int);
14292
14293 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
14294 int, int);
14295 @end smallexample
14296
14297 The second argument to the @var{__builtin_crypto_vshasigmad} and
14298 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
14299 integer that is 0 or 1. The third argument to these builtin functions
14300 must be a constant integer in the range of 0 to 15.
14301
14302 @node RX Built-in Functions
14303 @subsection RX Built-in Functions
14304 GCC supports some of the RX instructions which cannot be expressed in
14305 the C programming language via the use of built-in functions. The
14306 following functions are supported:
14307
14308 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
14309 Generates the @code{brk} machine instruction.
14310 @end deftypefn
14311
14312 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
14313 Generates the @code{clrpsw} machine instruction to clear the specified
14314 bit in the processor status word.
14315 @end deftypefn
14316
14317 @deftypefn {Built-in Function} void __builtin_rx_int (int)
14318 Generates the @code{int} machine instruction to generate an interrupt
14319 with the specified value.
14320 @end deftypefn
14321
14322 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
14323 Generates the @code{machi} machine instruction to add the result of
14324 multiplying the top 16 bits of the two arguments into the
14325 accumulator.
14326 @end deftypefn
14327
14328 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
14329 Generates the @code{maclo} machine instruction to add the result of
14330 multiplying the bottom 16 bits of the two arguments into the
14331 accumulator.
14332 @end deftypefn
14333
14334 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
14335 Generates the @code{mulhi} machine instruction to place the result of
14336 multiplying the top 16 bits of the two arguments into the
14337 accumulator.
14338 @end deftypefn
14339
14340 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
14341 Generates the @code{mullo} machine instruction to place the result of
14342 multiplying the bottom 16 bits of the two arguments into the
14343 accumulator.
14344 @end deftypefn
14345
14346 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
14347 Generates the @code{mvfachi} machine instruction to read the top
14348 32 bits of the accumulator.
14349 @end deftypefn
14350
14351 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
14352 Generates the @code{mvfacmi} machine instruction to read the middle
14353 32 bits of the accumulator.
14354 @end deftypefn
14355
14356 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
14357 Generates the @code{mvfc} machine instruction which reads the control
14358 register specified in its argument and returns its value.
14359 @end deftypefn
14360
14361 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
14362 Generates the @code{mvtachi} machine instruction to set the top
14363 32 bits of the accumulator.
14364 @end deftypefn
14365
14366 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
14367 Generates the @code{mvtaclo} machine instruction to set the bottom
14368 32 bits of the accumulator.
14369 @end deftypefn
14370
14371 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
14372 Generates the @code{mvtc} machine instruction which sets control
14373 register number @code{reg} to @code{val}.
14374 @end deftypefn
14375
14376 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
14377 Generates the @code{mvtipl} machine instruction set the interrupt
14378 priority level.
14379 @end deftypefn
14380
14381 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
14382 Generates the @code{racw} machine instruction to round the accumulator
14383 according to the specified mode.
14384 @end deftypefn
14385
14386 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
14387 Generates the @code{revw} machine instruction which swaps the bytes in
14388 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
14389 and also bits 16--23 occupy bits 24--31 and vice versa.
14390 @end deftypefn
14391
14392 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
14393 Generates the @code{rmpa} machine instruction which initiates a
14394 repeated multiply and accumulate sequence.
14395 @end deftypefn
14396
14397 @deftypefn {Built-in Function} void __builtin_rx_round (float)
14398 Generates the @code{round} machine instruction which returns the
14399 floating-point argument rounded according to the current rounding mode
14400 set in the floating-point status word register.
14401 @end deftypefn
14402
14403 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
14404 Generates the @code{sat} machine instruction which returns the
14405 saturated value of the argument.
14406 @end deftypefn
14407
14408 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
14409 Generates the @code{setpsw} machine instruction to set the specified
14410 bit in the processor status word.
14411 @end deftypefn
14412
14413 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
14414 Generates the @code{wait} machine instruction.
14415 @end deftypefn
14416
14417 @node SH Built-in Functions
14418 @subsection SH Built-in Functions
14419 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
14420 families of processors:
14421
14422 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
14423 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
14424 used by system code that manages threads and execution contexts. The compiler
14425 normally does not generate code that modifies the contents of @samp{GBR} and
14426 thus the value is preserved across function calls. Changing the @samp{GBR}
14427 value in user code must be done with caution, since the compiler might use
14428 @samp{GBR} in order to access thread local variables.
14429
14430 @end deftypefn
14431
14432 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
14433 Returns the value that is currently set in the @samp{GBR} register.
14434 Memory loads and stores that use the thread pointer as a base address are
14435 turned into @samp{GBR} based displacement loads and stores, if possible.
14436 For example:
14437 @smallexample
14438 struct my_tcb
14439 @{
14440 int a, b, c, d, e;
14441 @};
14442
14443 int get_tcb_value (void)
14444 @{
14445 // Generate @samp{mov.l @@(8,gbr),r0} instruction
14446 return ((my_tcb*)__builtin_thread_pointer ())->c;
14447 @}
14448
14449 @end smallexample
14450 @end deftypefn
14451
14452 @node SPARC VIS Built-in Functions
14453 @subsection SPARC VIS Built-in Functions
14454
14455 GCC supports SIMD operations on the SPARC using both the generic vector
14456 extensions (@pxref{Vector Extensions}) as well as built-in functions for
14457 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
14458 switch, the VIS extension is exposed as the following built-in functions:
14459
14460 @smallexample
14461 typedef int v1si __attribute__ ((vector_size (4)));
14462 typedef int v2si __attribute__ ((vector_size (8)));
14463 typedef short v4hi __attribute__ ((vector_size (8)));
14464 typedef short v2hi __attribute__ ((vector_size (4)));
14465 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
14466 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
14467
14468 void __builtin_vis_write_gsr (int64_t);
14469 int64_t __builtin_vis_read_gsr (void);
14470
14471 void * __builtin_vis_alignaddr (void *, long);
14472 void * __builtin_vis_alignaddrl (void *, long);
14473 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
14474 v2si __builtin_vis_faligndatav2si (v2si, v2si);
14475 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
14476 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
14477
14478 v4hi __builtin_vis_fexpand (v4qi);
14479
14480 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
14481 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
14482 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
14483 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
14484 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
14485 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
14486 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
14487
14488 v4qi __builtin_vis_fpack16 (v4hi);
14489 v8qi __builtin_vis_fpack32 (v2si, v8qi);
14490 v2hi __builtin_vis_fpackfix (v2si);
14491 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
14492
14493 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
14494
14495 long __builtin_vis_edge8 (void *, void *);
14496 long __builtin_vis_edge8l (void *, void *);
14497 long __builtin_vis_edge16 (void *, void *);
14498 long __builtin_vis_edge16l (void *, void *);
14499 long __builtin_vis_edge32 (void *, void *);
14500 long __builtin_vis_edge32l (void *, void *);
14501
14502 long __builtin_vis_fcmple16 (v4hi, v4hi);
14503 long __builtin_vis_fcmple32 (v2si, v2si);
14504 long __builtin_vis_fcmpne16 (v4hi, v4hi);
14505 long __builtin_vis_fcmpne32 (v2si, v2si);
14506 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
14507 long __builtin_vis_fcmpgt32 (v2si, v2si);
14508 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
14509 long __builtin_vis_fcmpeq32 (v2si, v2si);
14510
14511 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
14512 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
14513 v2si __builtin_vis_fpadd32 (v2si, v2si);
14514 v1si __builtin_vis_fpadd32s (v1si, v1si);
14515 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
14516 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
14517 v2si __builtin_vis_fpsub32 (v2si, v2si);
14518 v1si __builtin_vis_fpsub32s (v1si, v1si);
14519
14520 long __builtin_vis_array8 (long, long);
14521 long __builtin_vis_array16 (long, long);
14522 long __builtin_vis_array32 (long, long);
14523 @end smallexample
14524
14525 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
14526 functions also become available:
14527
14528 @smallexample
14529 long __builtin_vis_bmask (long, long);
14530 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
14531 v2si __builtin_vis_bshufflev2si (v2si, v2si);
14532 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
14533 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
14534
14535 long __builtin_vis_edge8n (void *, void *);
14536 long __builtin_vis_edge8ln (void *, void *);
14537 long __builtin_vis_edge16n (void *, void *);
14538 long __builtin_vis_edge16ln (void *, void *);
14539 long __builtin_vis_edge32n (void *, void *);
14540 long __builtin_vis_edge32ln (void *, void *);
14541 @end smallexample
14542
14543 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
14544 functions also become available:
14545
14546 @smallexample
14547 void __builtin_vis_cmask8 (long);
14548 void __builtin_vis_cmask16 (long);
14549 void __builtin_vis_cmask32 (long);
14550
14551 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
14552
14553 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
14554 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
14555 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
14556 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
14557 v2si __builtin_vis_fsll16 (v2si, v2si);
14558 v2si __builtin_vis_fslas16 (v2si, v2si);
14559 v2si __builtin_vis_fsrl16 (v2si, v2si);
14560 v2si __builtin_vis_fsra16 (v2si, v2si);
14561
14562 long __builtin_vis_pdistn (v8qi, v8qi);
14563
14564 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
14565
14566 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
14567 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
14568
14569 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
14570 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
14571 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
14572 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
14573 v2si __builtin_vis_fpadds32 (v2si, v2si);
14574 v1si __builtin_vis_fpadds32s (v1si, v1si);
14575 v2si __builtin_vis_fpsubs32 (v2si, v2si);
14576 v1si __builtin_vis_fpsubs32s (v1si, v1si);
14577
14578 long __builtin_vis_fucmple8 (v8qi, v8qi);
14579 long __builtin_vis_fucmpne8 (v8qi, v8qi);
14580 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
14581 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
14582
14583 float __builtin_vis_fhadds (float, float);
14584 double __builtin_vis_fhaddd (double, double);
14585 float __builtin_vis_fhsubs (float, float);
14586 double __builtin_vis_fhsubd (double, double);
14587 float __builtin_vis_fnhadds (float, float);
14588 double __builtin_vis_fnhaddd (double, double);
14589
14590 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
14591 int64_t __builtin_vis_xmulx (int64_t, int64_t);
14592 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
14593 @end smallexample
14594
14595 @node SPU Built-in Functions
14596 @subsection SPU Built-in Functions
14597
14598 GCC provides extensions for the SPU processor as described in the
14599 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
14600 found at @uref{http://cell.scei.co.jp/} or
14601 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
14602 implementation differs in several ways.
14603
14604 @itemize @bullet
14605
14606 @item
14607 The optional extension of specifying vector constants in parentheses is
14608 not supported.
14609
14610 @item
14611 A vector initializer requires no cast if the vector constant is of the
14612 same type as the variable it is initializing.
14613
14614 @item
14615 If @code{signed} or @code{unsigned} is omitted, the signedness of the
14616 vector type is the default signedness of the base type. The default
14617 varies depending on the operating system, so a portable program should
14618 always specify the signedness.
14619
14620 @item
14621 By default, the keyword @code{__vector} is added. The macro
14622 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
14623 undefined.
14624
14625 @item
14626 GCC allows using a @code{typedef} name as the type specifier for a
14627 vector type.
14628
14629 @item
14630 For C, overloaded functions are implemented with macros so the following
14631 does not work:
14632
14633 @smallexample
14634 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14635 @end smallexample
14636
14637 @noindent
14638 Since @code{spu_add} is a macro, the vector constant in the example
14639 is treated as four separate arguments. Wrap the entire argument in
14640 parentheses for this to work.
14641
14642 @item
14643 The extended version of @code{__builtin_expect} is not supported.
14644
14645 @end itemize
14646
14647 @emph{Note:} Only the interface described in the aforementioned
14648 specification is supported. Internally, GCC uses built-in functions to
14649 implement the required functionality, but these are not supported and
14650 are subject to change without notice.
14651
14652 @node TI C6X Built-in Functions
14653 @subsection TI C6X Built-in Functions
14654
14655 GCC provides intrinsics to access certain instructions of the TI C6X
14656 processors. These intrinsics, listed below, are available after
14657 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
14658 to C6X instructions.
14659
14660 @smallexample
14661
14662 int _sadd (int, int)
14663 int _ssub (int, int)
14664 int _sadd2 (int, int)
14665 int _ssub2 (int, int)
14666 long long _mpy2 (int, int)
14667 long long _smpy2 (int, int)
14668 int _add4 (int, int)
14669 int _sub4 (int, int)
14670 int _saddu4 (int, int)
14671
14672 int _smpy (int, int)
14673 int _smpyh (int, int)
14674 int _smpyhl (int, int)
14675 int _smpylh (int, int)
14676
14677 int _sshl (int, int)
14678 int _subc (int, int)
14679
14680 int _avg2 (int, int)
14681 int _avgu4 (int, int)
14682
14683 int _clrr (int, int)
14684 int _extr (int, int)
14685 int _extru (int, int)
14686 int _abs (int)
14687 int _abs2 (int)
14688
14689 @end smallexample
14690
14691 @node TILE-Gx Built-in Functions
14692 @subsection TILE-Gx Built-in Functions
14693
14694 GCC provides intrinsics to access every instruction of the TILE-Gx
14695 processor. The intrinsics are of the form:
14696
14697 @smallexample
14698
14699 unsigned long long __insn_@var{op} (...)
14700
14701 @end smallexample
14702
14703 Where @var{op} is the name of the instruction. Refer to the ISA manual
14704 for the complete list of instructions.
14705
14706 GCC also provides intrinsics to directly access the network registers.
14707 The intrinsics are:
14708
14709 @smallexample
14710
14711 unsigned long long __tile_idn0_receive (void)
14712 unsigned long long __tile_idn1_receive (void)
14713 unsigned long long __tile_udn0_receive (void)
14714 unsigned long long __tile_udn1_receive (void)
14715 unsigned long long __tile_udn2_receive (void)
14716 unsigned long long __tile_udn3_receive (void)
14717 void __tile_idn_send (unsigned long long)
14718 void __tile_udn_send (unsigned long long)
14719
14720 @end smallexample
14721
14722 The intrinsic @code{void __tile_network_barrier (void)} is used to
14723 guarantee that no network operations before it are reordered with
14724 those after it.
14725
14726 @node TILEPro Built-in Functions
14727 @subsection TILEPro Built-in Functions
14728
14729 GCC provides intrinsics to access every instruction of the TILEPro
14730 processor. The intrinsics are of the form:
14731
14732 @smallexample
14733
14734 unsigned __insn_@var{op} (...)
14735
14736 @end smallexample
14737
14738 @noindent
14739 where @var{op} is the name of the instruction. Refer to the ISA manual
14740 for the complete list of instructions.
14741
14742 GCC also provides intrinsics to directly access the network registers.
14743 The intrinsics are:
14744
14745 @smallexample
14746
14747 unsigned __tile_idn0_receive (void)
14748 unsigned __tile_idn1_receive (void)
14749 unsigned __tile_sn_receive (void)
14750 unsigned __tile_udn0_receive (void)
14751 unsigned __tile_udn1_receive (void)
14752 unsigned __tile_udn2_receive (void)
14753 unsigned __tile_udn3_receive (void)
14754 void __tile_idn_send (unsigned)
14755 void __tile_sn_send (unsigned)
14756 void __tile_udn_send (unsigned)
14757
14758 @end smallexample
14759
14760 The intrinsic @code{void __tile_network_barrier (void)} is used to
14761 guarantee that no network operations before it are reordered with
14762 those after it.
14763
14764 @node Target Format Checks
14765 @section Format Checks Specific to Particular Target Machines
14766
14767 For some target machines, GCC supports additional options to the
14768 format attribute
14769 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
14770
14771 @menu
14772 * Solaris Format Checks::
14773 * Darwin Format Checks::
14774 @end menu
14775
14776 @node Solaris Format Checks
14777 @subsection Solaris Format Checks
14778
14779 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
14780 check. @code{cmn_err} accepts a subset of the standard @code{printf}
14781 conversions, and the two-argument @code{%b} conversion for displaying
14782 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
14783
14784 @node Darwin Format Checks
14785 @subsection Darwin Format Checks
14786
14787 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
14788 attribute context. Declarations made with such attribution are parsed for correct syntax
14789 and format argument types. However, parsing of the format string itself is currently undefined
14790 and is not carried out by this version of the compiler.
14791
14792 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
14793 also be used as format arguments. Note that the relevant headers are only likely to be
14794 available on Darwin (OSX) installations. On such installations, the XCode and system
14795 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
14796 associated functions.
14797
14798 @node Pragmas
14799 @section Pragmas Accepted by GCC
14800 @cindex pragmas
14801 @cindex @code{#pragma}
14802
14803 GCC supports several types of pragmas, primarily in order to compile
14804 code originally written for other compilers. Note that in general
14805 we do not recommend the use of pragmas; @xref{Function Attributes},
14806 for further explanation.
14807
14808 @menu
14809 * ARM Pragmas::
14810 * M32C Pragmas::
14811 * MeP Pragmas::
14812 * RS/6000 and PowerPC Pragmas::
14813 * Darwin Pragmas::
14814 * Solaris Pragmas::
14815 * Symbol-Renaming Pragmas::
14816 * Structure-Packing Pragmas::
14817 * Weak Pragmas::
14818 * Diagnostic Pragmas::
14819 * Visibility Pragmas::
14820 * Push/Pop Macro Pragmas::
14821 * Function Specific Option Pragmas::
14822 @end menu
14823
14824 @node ARM Pragmas
14825 @subsection ARM Pragmas
14826
14827 The ARM target defines pragmas for controlling the default addition of
14828 @code{long_call} and @code{short_call} attributes to functions.
14829 @xref{Function Attributes}, for information about the effects of these
14830 attributes.
14831
14832 @table @code
14833 @item long_calls
14834 @cindex pragma, long_calls
14835 Set all subsequent functions to have the @code{long_call} attribute.
14836
14837 @item no_long_calls
14838 @cindex pragma, no_long_calls
14839 Set all subsequent functions to have the @code{short_call} attribute.
14840
14841 @item long_calls_off
14842 @cindex pragma, long_calls_off
14843 Do not affect the @code{long_call} or @code{short_call} attributes of
14844 subsequent functions.
14845 @end table
14846
14847 @node M32C Pragmas
14848 @subsection M32C Pragmas
14849
14850 @table @code
14851 @item GCC memregs @var{number}
14852 @cindex pragma, memregs
14853 Overrides the command-line option @code{-memregs=} for the current
14854 file. Use with care! This pragma must be before any function in the
14855 file, and mixing different memregs values in different objects may
14856 make them incompatible. This pragma is useful when a
14857 performance-critical function uses a memreg for temporary values,
14858 as it may allow you to reduce the number of memregs used.
14859
14860 @item ADDRESS @var{name} @var{address}
14861 @cindex pragma, address
14862 For any declared symbols matching @var{name}, this does three things
14863 to that symbol: it forces the symbol to be located at the given
14864 address (a number), it forces the symbol to be volatile, and it
14865 changes the symbol's scope to be static. This pragma exists for
14866 compatibility with other compilers, but note that the common
14867 @code{1234H} numeric syntax is not supported (use @code{0x1234}
14868 instead). Example:
14869
14870 @smallexample
14871 #pragma ADDRESS port3 0x103
14872 char port3;
14873 @end smallexample
14874
14875 @end table
14876
14877 @node MeP Pragmas
14878 @subsection MeP Pragmas
14879
14880 @table @code
14881
14882 @item custom io_volatile (on|off)
14883 @cindex pragma, custom io_volatile
14884 Overrides the command-line option @code{-mio-volatile} for the current
14885 file. Note that for compatibility with future GCC releases, this
14886 option should only be used once before any @code{io} variables in each
14887 file.
14888
14889 @item GCC coprocessor available @var{registers}
14890 @cindex pragma, coprocessor available
14891 Specifies which coprocessor registers are available to the register
14892 allocator. @var{registers} may be a single register, register range
14893 separated by ellipses, or comma-separated list of those. Example:
14894
14895 @smallexample
14896 #pragma GCC coprocessor available $c0...$c10, $c28
14897 @end smallexample
14898
14899 @item GCC coprocessor call_saved @var{registers}
14900 @cindex pragma, coprocessor call_saved
14901 Specifies which coprocessor registers are to be saved and restored by
14902 any function using them. @var{registers} may be a single register,
14903 register range separated by ellipses, or comma-separated list of
14904 those. Example:
14905
14906 @smallexample
14907 #pragma GCC coprocessor call_saved $c4...$c6, $c31
14908 @end smallexample
14909
14910 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
14911 @cindex pragma, coprocessor subclass
14912 Creates and defines a register class. These register classes can be
14913 used by inline @code{asm} constructs. @var{registers} may be a single
14914 register, register range separated by ellipses, or comma-separated
14915 list of those. Example:
14916
14917 @smallexample
14918 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
14919
14920 asm ("cpfoo %0" : "=B" (x));
14921 @end smallexample
14922
14923 @item GCC disinterrupt @var{name} , @var{name} @dots{}
14924 @cindex pragma, disinterrupt
14925 For the named functions, the compiler adds code to disable interrupts
14926 for the duration of those functions. If any functions so named
14927 are not encountered in the source, a warning is emitted that the pragma is
14928 not used. Examples:
14929
14930 @smallexample
14931 #pragma disinterrupt foo
14932 #pragma disinterrupt bar, grill
14933 int foo () @{ @dots{} @}
14934 @end smallexample
14935
14936 @item GCC call @var{name} , @var{name} @dots{}
14937 @cindex pragma, call
14938 For the named functions, the compiler always uses a register-indirect
14939 call model when calling the named functions. Examples:
14940
14941 @smallexample
14942 extern int foo ();
14943 #pragma call foo
14944 @end smallexample
14945
14946 @end table
14947
14948 @node RS/6000 and PowerPC Pragmas
14949 @subsection RS/6000 and PowerPC Pragmas
14950
14951 The RS/6000 and PowerPC targets define one pragma for controlling
14952 whether or not the @code{longcall} attribute is added to function
14953 declarations by default. This pragma overrides the @option{-mlongcall}
14954 option, but not the @code{longcall} and @code{shortcall} attributes.
14955 @xref{RS/6000 and PowerPC Options}, for more information about when long
14956 calls are and are not necessary.
14957
14958 @table @code
14959 @item longcall (1)
14960 @cindex pragma, longcall
14961 Apply the @code{longcall} attribute to all subsequent function
14962 declarations.
14963
14964 @item longcall (0)
14965 Do not apply the @code{longcall} attribute to subsequent function
14966 declarations.
14967 @end table
14968
14969 @c Describe h8300 pragmas here.
14970 @c Describe sh pragmas here.
14971 @c Describe v850 pragmas here.
14972
14973 @node Darwin Pragmas
14974 @subsection Darwin Pragmas
14975
14976 The following pragmas are available for all architectures running the
14977 Darwin operating system. These are useful for compatibility with other
14978 Mac OS compilers.
14979
14980 @table @code
14981 @item mark @var{tokens}@dots{}
14982 @cindex pragma, mark
14983 This pragma is accepted, but has no effect.
14984
14985 @item options align=@var{alignment}
14986 @cindex pragma, options align
14987 This pragma sets the alignment of fields in structures. The values of
14988 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
14989 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
14990 properly; to restore the previous setting, use @code{reset} for the
14991 @var{alignment}.
14992
14993 @item segment @var{tokens}@dots{}
14994 @cindex pragma, segment
14995 This pragma is accepted, but has no effect.
14996
14997 @item unused (@var{var} [, @var{var}]@dots{})
14998 @cindex pragma, unused
14999 This pragma declares variables to be possibly unused. GCC does not
15000 produce warnings for the listed variables. The effect is similar to
15001 that of the @code{unused} attribute, except that this pragma may appear
15002 anywhere within the variables' scopes.
15003 @end table
15004
15005 @node Solaris Pragmas
15006 @subsection Solaris Pragmas
15007
15008 The Solaris target supports @code{#pragma redefine_extname}
15009 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
15010 @code{#pragma} directives for compatibility with the system compiler.
15011
15012 @table @code
15013 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
15014 @cindex pragma, align
15015
15016 Increase the minimum alignment of each @var{variable} to @var{alignment}.
15017 This is the same as GCC's @code{aligned} attribute @pxref{Variable
15018 Attributes}). Macro expansion occurs on the arguments to this pragma
15019 when compiling C and Objective-C@. It does not currently occur when
15020 compiling C++, but this is a bug which may be fixed in a future
15021 release.
15022
15023 @item fini (@var{function} [, @var{function}]...)
15024 @cindex pragma, fini
15025
15026 This pragma causes each listed @var{function} to be called after
15027 main, or during shared module unloading, by adding a call to the
15028 @code{.fini} section.
15029
15030 @item init (@var{function} [, @var{function}]...)
15031 @cindex pragma, init
15032
15033 This pragma causes each listed @var{function} to be called during
15034 initialization (before @code{main}) or during shared module loading, by
15035 adding a call to the @code{.init} section.
15036
15037 @end table
15038
15039 @node Symbol-Renaming Pragmas
15040 @subsection Symbol-Renaming Pragmas
15041
15042 For compatibility with the Solaris system headers, GCC
15043 supports two @code{#pragma} directives that change the name used in
15044 assembly for a given declaration. To get this effect
15045 on all platforms supported by GCC, use the asm labels extension (@pxref{Asm
15046 Labels}).
15047
15048 @table @code
15049 @item redefine_extname @var{oldname} @var{newname}
15050 @cindex pragma, redefine_extname
15051
15052 This pragma gives the C function @var{oldname} the assembly symbol
15053 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
15054 is defined if this pragma is available (currently on all platforms).
15055 @end table
15056
15057 This pragma and the asm labels extension interact in a complicated
15058 manner. Here are some corner cases you may want to be aware of.
15059
15060 @enumerate
15061 @item Both pragmas silently apply only to declarations with external
15062 linkage. Asm labels do not have this restriction.
15063
15064 @item In C++, both pragmas silently apply only to declarations with
15065 ``C'' linkage. Again, asm labels do not have this restriction.
15066
15067 @item If any of the three ways of changing the assembly name of a
15068 declaration is applied to a declaration whose assembly name has
15069 already been determined (either by a previous use of one of these
15070 features, or because the compiler needed the assembly name in order to
15071 generate code), and the new name is different, a warning issues and
15072 the name does not change.
15073
15074 @item The @var{oldname} used by @code{#pragma redefine_extname} is
15075 always the C-language name.
15076 @end enumerate
15077
15078 @node Structure-Packing Pragmas
15079 @subsection Structure-Packing Pragmas
15080
15081 For compatibility with Microsoft Windows compilers, GCC supports a
15082 set of @code{#pragma} directives that change the maximum alignment of
15083 members of structures (other than zero-width bit-fields), unions, and
15084 classes subsequently defined. The @var{n} value below always is required
15085 to be a small power of two and specifies the new alignment in bytes.
15086
15087 @enumerate
15088 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
15089 @item @code{#pragma pack()} sets the alignment to the one that was in
15090 effect when compilation started (see also command-line option
15091 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
15092 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
15093 setting on an internal stack and then optionally sets the new alignment.
15094 @item @code{#pragma pack(pop)} restores the alignment setting to the one
15095 saved at the top of the internal stack (and removes that stack entry).
15096 Note that @code{#pragma pack([@var{n}])} does not influence this internal
15097 stack; thus it is possible to have @code{#pragma pack(push)} followed by
15098 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
15099 @code{#pragma pack(pop)}.
15100 @end enumerate
15101
15102 Some targets, e.g.@: i386 and PowerPC, support the @code{ms_struct}
15103 @code{#pragma} which lays out a structure as the documented
15104 @code{__attribute__ ((ms_struct))}.
15105 @enumerate
15106 @item @code{#pragma ms_struct on} turns on the layout for structures
15107 declared.
15108 @item @code{#pragma ms_struct off} turns off the layout for structures
15109 declared.
15110 @item @code{#pragma ms_struct reset} goes back to the default layout.
15111 @end enumerate
15112
15113 @node Weak Pragmas
15114 @subsection Weak Pragmas
15115
15116 For compatibility with SVR4, GCC supports a set of @code{#pragma}
15117 directives for declaring symbols to be weak, and defining weak
15118 aliases.
15119
15120 @table @code
15121 @item #pragma weak @var{symbol}
15122 @cindex pragma, weak
15123 This pragma declares @var{symbol} to be weak, as if the declaration
15124 had the attribute of the same name. The pragma may appear before
15125 or after the declaration of @var{symbol}. It is not an error for
15126 @var{symbol} to never be defined at all.
15127
15128 @item #pragma weak @var{symbol1} = @var{symbol2}
15129 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
15130 It is an error if @var{symbol2} is not defined in the current
15131 translation unit.
15132 @end table
15133
15134 @node Diagnostic Pragmas
15135 @subsection Diagnostic Pragmas
15136
15137 GCC allows the user to selectively enable or disable certain types of
15138 diagnostics, and change the kind of the diagnostic. For example, a
15139 project's policy might require that all sources compile with
15140 @option{-Werror} but certain files might have exceptions allowing
15141 specific types of warnings. Or, a project might selectively enable
15142 diagnostics and treat them as errors depending on which preprocessor
15143 macros are defined.
15144
15145 @table @code
15146 @item #pragma GCC diagnostic @var{kind} @var{option}
15147 @cindex pragma, diagnostic
15148
15149 Modifies the disposition of a diagnostic. Note that not all
15150 diagnostics are modifiable; at the moment only warnings (normally
15151 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
15152 Use @option{-fdiagnostics-show-option} to determine which diagnostics
15153 are controllable and which option controls them.
15154
15155 @var{kind} is @samp{error} to treat this diagnostic as an error,
15156 @samp{warning} to treat it like a warning (even if @option{-Werror} is
15157 in effect), or @samp{ignored} if the diagnostic is to be ignored.
15158 @var{option} is a double quoted string that matches the command-line
15159 option.
15160
15161 @smallexample
15162 #pragma GCC diagnostic warning "-Wformat"
15163 #pragma GCC diagnostic error "-Wformat"
15164 #pragma GCC diagnostic ignored "-Wformat"
15165 @end smallexample
15166
15167 Note that these pragmas override any command-line options. GCC keeps
15168 track of the location of each pragma, and issues diagnostics according
15169 to the state as of that point in the source file. Thus, pragmas occurring
15170 after a line do not affect diagnostics caused by that line.
15171
15172 @item #pragma GCC diagnostic push
15173 @itemx #pragma GCC diagnostic pop
15174
15175 Causes GCC to remember the state of the diagnostics as of each
15176 @code{push}, and restore to that point at each @code{pop}. If a
15177 @code{pop} has no matching @code{push}, the command-line options are
15178 restored.
15179
15180 @smallexample
15181 #pragma GCC diagnostic error "-Wuninitialized"
15182 foo(a); /* error is given for this one */
15183 #pragma GCC diagnostic push
15184 #pragma GCC diagnostic ignored "-Wuninitialized"
15185 foo(b); /* no diagnostic for this one */
15186 #pragma GCC diagnostic pop
15187 foo(c); /* error is given for this one */
15188 #pragma GCC diagnostic pop
15189 foo(d); /* depends on command-line options */
15190 @end smallexample
15191
15192 @end table
15193
15194 GCC also offers a simple mechanism for printing messages during
15195 compilation.
15196
15197 @table @code
15198 @item #pragma message @var{string}
15199 @cindex pragma, diagnostic
15200
15201 Prints @var{string} as a compiler message on compilation. The message
15202 is informational only, and is neither a compilation warning nor an error.
15203
15204 @smallexample
15205 #pragma message "Compiling " __FILE__ "..."
15206 @end smallexample
15207
15208 @var{string} may be parenthesized, and is printed with location
15209 information. For example,
15210
15211 @smallexample
15212 #define DO_PRAGMA(x) _Pragma (#x)
15213 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
15214
15215 TODO(Remember to fix this)
15216 @end smallexample
15217
15218 @noindent
15219 prints @samp{/tmp/file.c:4: note: #pragma message:
15220 TODO - Remember to fix this}.
15221
15222 @end table
15223
15224 @node Visibility Pragmas
15225 @subsection Visibility Pragmas
15226
15227 @table @code
15228 @item #pragma GCC visibility push(@var{visibility})
15229 @itemx #pragma GCC visibility pop
15230 @cindex pragma, visibility
15231
15232 This pragma allows the user to set the visibility for multiple
15233 declarations without having to give each a visibility attribute
15234 @xref{Function Attributes}, for more information about visibility and
15235 the attribute syntax.
15236
15237 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
15238 declarations. Class members and template specializations are not
15239 affected; if you want to override the visibility for a particular
15240 member or instantiation, you must use an attribute.
15241
15242 @end table
15243
15244
15245 @node Push/Pop Macro Pragmas
15246 @subsection Push/Pop Macro Pragmas
15247
15248 For compatibility with Microsoft Windows compilers, GCC supports
15249 @samp{#pragma push_macro(@var{"macro_name"})}
15250 and @samp{#pragma pop_macro(@var{"macro_name"})}.
15251
15252 @table @code
15253 @item #pragma push_macro(@var{"macro_name"})
15254 @cindex pragma, push_macro
15255 This pragma saves the value of the macro named as @var{macro_name} to
15256 the top of the stack for this macro.
15257
15258 @item #pragma pop_macro(@var{"macro_name"})
15259 @cindex pragma, pop_macro
15260 This pragma sets the value of the macro named as @var{macro_name} to
15261 the value on top of the stack for this macro. If the stack for
15262 @var{macro_name} is empty, the value of the macro remains unchanged.
15263 @end table
15264
15265 For example:
15266
15267 @smallexample
15268 #define X 1
15269 #pragma push_macro("X")
15270 #undef X
15271 #define X -1
15272 #pragma pop_macro("X")
15273 int x [X];
15274 @end smallexample
15275
15276 @noindent
15277 In this example, the definition of X as 1 is saved by @code{#pragma
15278 push_macro} and restored by @code{#pragma pop_macro}.
15279
15280 @node Function Specific Option Pragmas
15281 @subsection Function Specific Option Pragmas
15282
15283 @table @code
15284 @item #pragma GCC target (@var{"string"}...)
15285 @cindex pragma GCC target
15286
15287 This pragma allows you to set target specific options for functions
15288 defined later in the source file. One or more strings can be
15289 specified. Each function that is defined after this point is as
15290 if @code{attribute((target("STRING")))} was specified for that
15291 function. The parenthesis around the options is optional.
15292 @xref{Function Attributes}, for more information about the
15293 @code{target} attribute and the attribute syntax.
15294
15295 The @code{#pragma GCC target} attribute is not implemented in GCC versions earlier
15296 than 4.4 for the i386/x86_64 and 4.6 for the PowerPC back ends. At
15297 present, it is not implemented for other back ends.
15298 @end table
15299
15300 @table @code
15301 @item #pragma GCC optimize (@var{"string"}...)
15302 @cindex pragma GCC optimize
15303
15304 This pragma allows you to set global optimization options for functions
15305 defined later in the source file. One or more strings can be
15306 specified. Each function that is defined after this point is as
15307 if @code{attribute((optimize("STRING")))} was specified for that
15308 function. The parenthesis around the options is optional.
15309 @xref{Function Attributes}, for more information about the
15310 @code{optimize} attribute and the attribute syntax.
15311
15312 The @samp{#pragma GCC optimize} pragma is not implemented in GCC
15313 versions earlier than 4.4.
15314 @end table
15315
15316 @table @code
15317 @item #pragma GCC push_options
15318 @itemx #pragma GCC pop_options
15319 @cindex pragma GCC push_options
15320 @cindex pragma GCC pop_options
15321
15322 These pragmas maintain a stack of the current target and optimization
15323 options. It is intended for include files where you temporarily want
15324 to switch to using a different @samp{#pragma GCC target} or
15325 @samp{#pragma GCC optimize} and then to pop back to the previous
15326 options.
15327
15328 The @samp{#pragma GCC push_options} and @samp{#pragma GCC pop_options}
15329 pragmas are not implemented in GCC versions earlier than 4.4.
15330 @end table
15331
15332 @table @code
15333 @item #pragma GCC reset_options
15334 @cindex pragma GCC reset_options
15335
15336 This pragma clears the current @code{#pragma GCC target} and
15337 @code{#pragma GCC optimize} to use the default switches as specified
15338 on the command line.
15339
15340 The @samp{#pragma GCC reset_options} pragma is not implemented in GCC
15341 versions earlier than 4.4.
15342 @end table
15343
15344 @node Unnamed Fields
15345 @section Unnamed struct/union fields within structs/unions
15346 @cindex @code{struct}
15347 @cindex @code{union}
15348
15349 As permitted by ISO C11 and for compatibility with other compilers,
15350 GCC allows you to define
15351 a structure or union that contains, as fields, structures and unions
15352 without names. For example:
15353
15354 @smallexample
15355 struct @{
15356 int a;
15357 union @{
15358 int b;
15359 float c;
15360 @};
15361 int d;
15362 @} foo;
15363 @end smallexample
15364
15365 @noindent
15366 In this example, you are able to access members of the unnamed
15367 union with code like @samp{foo.b}. Note that only unnamed structs and
15368 unions are allowed, you may not have, for example, an unnamed
15369 @code{int}.
15370
15371 You must never create such structures that cause ambiguous field definitions.
15372 For example, in this structure:
15373
15374 @smallexample
15375 struct @{
15376 int a;
15377 struct @{
15378 int a;
15379 @};
15380 @} foo;
15381 @end smallexample
15382
15383 @noindent
15384 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
15385 The compiler gives errors for such constructs.
15386
15387 @opindex fms-extensions
15388 Unless @option{-fms-extensions} is used, the unnamed field must be a
15389 structure or union definition without a tag (for example, @samp{struct
15390 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
15391 also be a definition with a tag such as @samp{struct foo @{ int a;
15392 @};}, a reference to a previously defined structure or union such as
15393 @samp{struct foo;}, or a reference to a @code{typedef} name for a
15394 previously defined structure or union type.
15395
15396 @opindex fplan9-extensions
15397 The option @option{-fplan9-extensions} enables
15398 @option{-fms-extensions} as well as two other extensions. First, a
15399 pointer to a structure is automatically converted to a pointer to an
15400 anonymous field for assignments and function calls. For example:
15401
15402 @smallexample
15403 struct s1 @{ int a; @};
15404 struct s2 @{ struct s1; @};
15405 extern void f1 (struct s1 *);
15406 void f2 (struct s2 *p) @{ f1 (p); @}
15407 @end smallexample
15408
15409 @noindent
15410 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
15411 converted into a pointer to the anonymous field.
15412
15413 Second, when the type of an anonymous field is a @code{typedef} for a
15414 @code{struct} or @code{union}, code may refer to the field using the
15415 name of the @code{typedef}.
15416
15417 @smallexample
15418 typedef struct @{ int a; @} s1;
15419 struct s2 @{ s1; @};
15420 s1 f1 (struct s2 *p) @{ return p->s1; @}
15421 @end smallexample
15422
15423 These usages are only permitted when they are not ambiguous.
15424
15425 @node Thread-Local
15426 @section Thread-Local Storage
15427 @cindex Thread-Local Storage
15428 @cindex @acronym{TLS}
15429 @cindex @code{__thread}
15430
15431 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
15432 are allocated such that there is one instance of the variable per extant
15433 thread. The runtime model GCC uses to implement this originates
15434 in the IA-64 processor-specific ABI, but has since been migrated
15435 to other processors as well. It requires significant support from
15436 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
15437 system libraries (@file{libc.so} and @file{libpthread.so}), so it
15438 is not available everywhere.
15439
15440 At the user level, the extension is visible with a new storage
15441 class keyword: @code{__thread}. For example:
15442
15443 @smallexample
15444 __thread int i;
15445 extern __thread struct state s;
15446 static __thread char *p;
15447 @end smallexample
15448
15449 The @code{__thread} specifier may be used alone, with the @code{extern}
15450 or @code{static} specifiers, but with no other storage class specifier.
15451 When used with @code{extern} or @code{static}, @code{__thread} must appear
15452 immediately after the other storage class specifier.
15453
15454 The @code{__thread} specifier may be applied to any global, file-scoped
15455 static, function-scoped static, or static data member of a class. It may
15456 not be applied to block-scoped automatic or non-static data member.
15457
15458 When the address-of operator is applied to a thread-local variable, it is
15459 evaluated at run time and returns the address of the current thread's
15460 instance of that variable. An address so obtained may be used by any
15461 thread. When a thread terminates, any pointers to thread-local variables
15462 in that thread become invalid.
15463
15464 No static initialization may refer to the address of a thread-local variable.
15465
15466 In C++, if an initializer is present for a thread-local variable, it must
15467 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
15468 standard.
15469
15470 See @uref{http://www.akkadia.org/drepper/tls.pdf,
15471 ELF Handling For Thread-Local Storage} for a detailed explanation of
15472 the four thread-local storage addressing models, and how the runtime
15473 is expected to function.
15474
15475 @menu
15476 * C99 Thread-Local Edits::
15477 * C++98 Thread-Local Edits::
15478 @end menu
15479
15480 @node C99 Thread-Local Edits
15481 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
15482
15483 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
15484 that document the exact semantics of the language extension.
15485
15486 @itemize @bullet
15487 @item
15488 @cite{5.1.2 Execution environments}
15489
15490 Add new text after paragraph 1
15491
15492 @quotation
15493 Within either execution environment, a @dfn{thread} is a flow of
15494 control within a program. It is implementation defined whether
15495 or not there may be more than one thread associated with a program.
15496 It is implementation defined how threads beyond the first are
15497 created, the name and type of the function called at thread
15498 startup, and how threads may be terminated. However, objects
15499 with thread storage duration shall be initialized before thread
15500 startup.
15501 @end quotation
15502
15503 @item
15504 @cite{6.2.4 Storage durations of objects}
15505
15506 Add new text before paragraph 3
15507
15508 @quotation
15509 An object whose identifier is declared with the storage-class
15510 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
15511 Its lifetime is the entire execution of the thread, and its
15512 stored value is initialized only once, prior to thread startup.
15513 @end quotation
15514
15515 @item
15516 @cite{6.4.1 Keywords}
15517
15518 Add @code{__thread}.
15519
15520 @item
15521 @cite{6.7.1 Storage-class specifiers}
15522
15523 Add @code{__thread} to the list of storage class specifiers in
15524 paragraph 1.
15525
15526 Change paragraph 2 to
15527
15528 @quotation
15529 With the exception of @code{__thread}, at most one storage-class
15530 specifier may be given [@dots{}]. The @code{__thread} specifier may
15531 be used alone, or immediately following @code{extern} or
15532 @code{static}.
15533 @end quotation
15534
15535 Add new text after paragraph 6
15536
15537 @quotation
15538 The declaration of an identifier for a variable that has
15539 block scope that specifies @code{__thread} shall also
15540 specify either @code{extern} or @code{static}.
15541
15542 The @code{__thread} specifier shall be used only with
15543 variables.
15544 @end quotation
15545 @end itemize
15546
15547 @node C++98 Thread-Local Edits
15548 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
15549
15550 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
15551 that document the exact semantics of the language extension.
15552
15553 @itemize @bullet
15554 @item
15555 @b{[intro.execution]}
15556
15557 New text after paragraph 4
15558
15559 @quotation
15560 A @dfn{thread} is a flow of control within the abstract machine.
15561 It is implementation defined whether or not there may be more than
15562 one thread.
15563 @end quotation
15564
15565 New text after paragraph 7
15566
15567 @quotation
15568 It is unspecified whether additional action must be taken to
15569 ensure when and whether side effects are visible to other threads.
15570 @end quotation
15571
15572 @item
15573 @b{[lex.key]}
15574
15575 Add @code{__thread}.
15576
15577 @item
15578 @b{[basic.start.main]}
15579
15580 Add after paragraph 5
15581
15582 @quotation
15583 The thread that begins execution at the @code{main} function is called
15584 the @dfn{main thread}. It is implementation defined how functions
15585 beginning threads other than the main thread are designated or typed.
15586 A function so designated, as well as the @code{main} function, is called
15587 a @dfn{thread startup function}. It is implementation defined what
15588 happens if a thread startup function returns. It is implementation
15589 defined what happens to other threads when any thread calls @code{exit}.
15590 @end quotation
15591
15592 @item
15593 @b{[basic.start.init]}
15594
15595 Add after paragraph 4
15596
15597 @quotation
15598 The storage for an object of thread storage duration shall be
15599 statically initialized before the first statement of the thread startup
15600 function. An object of thread storage duration shall not require
15601 dynamic initialization.
15602 @end quotation
15603
15604 @item
15605 @b{[basic.start.term]}
15606
15607 Add after paragraph 3
15608
15609 @quotation
15610 The type of an object with thread storage duration shall not have a
15611 non-trivial destructor, nor shall it be an array type whose elements
15612 (directly or indirectly) have non-trivial destructors.
15613 @end quotation
15614
15615 @item
15616 @b{[basic.stc]}
15617
15618 Add ``thread storage duration'' to the list in paragraph 1.
15619
15620 Change paragraph 2
15621
15622 @quotation
15623 Thread, static, and automatic storage durations are associated with
15624 objects introduced by declarations [@dots{}].
15625 @end quotation
15626
15627 Add @code{__thread} to the list of specifiers in paragraph 3.
15628
15629 @item
15630 @b{[basic.stc.thread]}
15631
15632 New section before @b{[basic.stc.static]}
15633
15634 @quotation
15635 The keyword @code{__thread} applied to a non-local object gives the
15636 object thread storage duration.
15637
15638 A local variable or class data member declared both @code{static}
15639 and @code{__thread} gives the variable or member thread storage
15640 duration.
15641 @end quotation
15642
15643 @item
15644 @b{[basic.stc.static]}
15645
15646 Change paragraph 1
15647
15648 @quotation
15649 All objects that have neither thread storage duration, dynamic
15650 storage duration nor are local [@dots{}].
15651 @end quotation
15652
15653 @item
15654 @b{[dcl.stc]}
15655
15656 Add @code{__thread} to the list in paragraph 1.
15657
15658 Change paragraph 1
15659
15660 @quotation
15661 With the exception of @code{__thread}, at most one
15662 @var{storage-class-specifier} shall appear in a given
15663 @var{decl-specifier-seq}. The @code{__thread} specifier may
15664 be used alone, or immediately following the @code{extern} or
15665 @code{static} specifiers. [@dots{}]
15666 @end quotation
15667
15668 Add after paragraph 5
15669
15670 @quotation
15671 The @code{__thread} specifier can be applied only to the names of objects
15672 and to anonymous unions.
15673 @end quotation
15674
15675 @item
15676 @b{[class.mem]}
15677
15678 Add after paragraph 6
15679
15680 @quotation
15681 Non-@code{static} members shall not be @code{__thread}.
15682 @end quotation
15683 @end itemize
15684
15685 @node Binary constants
15686 @section Binary constants using the @samp{0b} prefix
15687 @cindex Binary constants using the @samp{0b} prefix
15688
15689 Integer constants can be written as binary constants, consisting of a
15690 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
15691 @samp{0B}. This is particularly useful in environments that operate a
15692 lot on the bit level (like microcontrollers).
15693
15694 The following statements are identical:
15695
15696 @smallexample
15697 i = 42;
15698 i = 0x2a;
15699 i = 052;
15700 i = 0b101010;
15701 @end smallexample
15702
15703 The type of these constants follows the same rules as for octal or
15704 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
15705 can be applied.
15706
15707 @node C++ Extensions
15708 @chapter Extensions to the C++ Language
15709 @cindex extensions, C++ language
15710 @cindex C++ language extensions
15711
15712 The GNU compiler provides these extensions to the C++ language (and you
15713 can also use most of the C language extensions in your C++ programs). If you
15714 want to write code that checks whether these features are available, you can
15715 test for the GNU compiler the same way as for C programs: check for a
15716 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
15717 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
15718 Predefined Macros,cpp,The GNU C Preprocessor}).
15719
15720 @menu
15721 * C++ Volatiles:: What constitutes an access to a volatile object.
15722 * Restricted Pointers:: C99 restricted pointers and references.
15723 * Vague Linkage:: Where G++ puts inlines, vtables and such.
15724 * C++ Interface:: You can use a single C++ header file for both
15725 declarations and definitions.
15726 * Template Instantiation:: Methods for ensuring that exactly one copy of
15727 each needed template instantiation is emitted.
15728 * Bound member functions:: You can extract a function pointer to the
15729 method denoted by a @samp{->*} or @samp{.*} expression.
15730 * C++ Attributes:: Variable, function, and type attributes for C++ only.
15731 * Function Multiversioning:: Declaring multiple function versions.
15732 * Namespace Association:: Strong using-directives for namespace association.
15733 * Type Traits:: Compiler support for type traits
15734 * Java Exceptions:: Tweaking exception handling to work with Java.
15735 * Deprecated Features:: Things will disappear from G++.
15736 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
15737 @end menu
15738
15739 @node C++ Volatiles
15740 @section When is a Volatile C++ Object Accessed?
15741 @cindex accessing volatiles
15742 @cindex volatile read
15743 @cindex volatile write
15744 @cindex volatile access
15745
15746 The C++ standard differs from the C standard in its treatment of
15747 volatile objects. It fails to specify what constitutes a volatile
15748 access, except to say that C++ should behave in a similar manner to C
15749 with respect to volatiles, where possible. However, the different
15750 lvalueness of expressions between C and C++ complicate the behavior.
15751 G++ behaves the same as GCC for volatile access, @xref{C
15752 Extensions,,Volatiles}, for a description of GCC's behavior.
15753
15754 The C and C++ language specifications differ when an object is
15755 accessed in a void context:
15756
15757 @smallexample
15758 volatile int *src = @var{somevalue};
15759 *src;
15760 @end smallexample
15761
15762 The C++ standard specifies that such expressions do not undergo lvalue
15763 to rvalue conversion, and that the type of the dereferenced object may
15764 be incomplete. The C++ standard does not specify explicitly that it
15765 is lvalue to rvalue conversion that is responsible for causing an
15766 access. There is reason to believe that it is, because otherwise
15767 certain simple expressions become undefined. However, because it
15768 would surprise most programmers, G++ treats dereferencing a pointer to
15769 volatile object of complete type as GCC would do for an equivalent
15770 type in C@. When the object has incomplete type, G++ issues a
15771 warning; if you wish to force an error, you must force a conversion to
15772 rvalue with, for instance, a static cast.
15773
15774 When using a reference to volatile, G++ does not treat equivalent
15775 expressions as accesses to volatiles, but instead issues a warning that
15776 no volatile is accessed. The rationale for this is that otherwise it
15777 becomes difficult to determine where volatile access occur, and not
15778 possible to ignore the return value from functions returning volatile
15779 references. Again, if you wish to force a read, cast the reference to
15780 an rvalue.
15781
15782 G++ implements the same behavior as GCC does when assigning to a
15783 volatile object---there is no reread of the assigned-to object, the
15784 assigned rvalue is reused. Note that in C++ assignment expressions
15785 are lvalues, and if used as an lvalue, the volatile object is
15786 referred to. For instance, @var{vref} refers to @var{vobj}, as
15787 expected, in the following example:
15788
15789 @smallexample
15790 volatile int vobj;
15791 volatile int &vref = vobj = @var{something};
15792 @end smallexample
15793
15794 @node Restricted Pointers
15795 @section Restricting Pointer Aliasing
15796 @cindex restricted pointers
15797 @cindex restricted references
15798 @cindex restricted this pointer
15799
15800 As with the C front end, G++ understands the C99 feature of restricted pointers,
15801 specified with the @code{__restrict__}, or @code{__restrict} type
15802 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
15803 language flag, @code{restrict} is not a keyword in C++.
15804
15805 In addition to allowing restricted pointers, you can specify restricted
15806 references, which indicate that the reference is not aliased in the local
15807 context.
15808
15809 @smallexample
15810 void fn (int *__restrict__ rptr, int &__restrict__ rref)
15811 @{
15812 /* @r{@dots{}} */
15813 @}
15814 @end smallexample
15815
15816 @noindent
15817 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
15818 @var{rref} refers to a (different) unaliased integer.
15819
15820 You may also specify whether a member function's @var{this} pointer is
15821 unaliased by using @code{__restrict__} as a member function qualifier.
15822
15823 @smallexample
15824 void T::fn () __restrict__
15825 @{
15826 /* @r{@dots{}} */
15827 @}
15828 @end smallexample
15829
15830 @noindent
15831 Within the body of @code{T::fn}, @var{this} has the effective
15832 definition @code{T *__restrict__ const this}. Notice that the
15833 interpretation of a @code{__restrict__} member function qualifier is
15834 different to that of @code{const} or @code{volatile} qualifier, in that it
15835 is applied to the pointer rather than the object. This is consistent with
15836 other compilers that implement restricted pointers.
15837
15838 As with all outermost parameter qualifiers, @code{__restrict__} is
15839 ignored in function definition matching. This means you only need to
15840 specify @code{__restrict__} in a function definition, rather than
15841 in a function prototype as well.
15842
15843 @node Vague Linkage
15844 @section Vague Linkage
15845 @cindex vague linkage
15846
15847 There are several constructs in C++ that require space in the object
15848 file but are not clearly tied to a single translation unit. We say that
15849 these constructs have ``vague linkage''. Typically such constructs are
15850 emitted wherever they are needed, though sometimes we can be more
15851 clever.
15852
15853 @table @asis
15854 @item Inline Functions
15855 Inline functions are typically defined in a header file which can be
15856 included in many different compilations. Hopefully they can usually be
15857 inlined, but sometimes an out-of-line copy is necessary, if the address
15858 of the function is taken or if inlining fails. In general, we emit an
15859 out-of-line copy in all translation units where one is needed. As an
15860 exception, we only emit inline virtual functions with the vtable, since
15861 it always requires a copy.
15862
15863 Local static variables and string constants used in an inline function
15864 are also considered to have vague linkage, since they must be shared
15865 between all inlined and out-of-line instances of the function.
15866
15867 @item VTables
15868 @cindex vtable
15869 C++ virtual functions are implemented in most compilers using a lookup
15870 table, known as a vtable. The vtable contains pointers to the virtual
15871 functions provided by a class, and each object of the class contains a
15872 pointer to its vtable (or vtables, in some multiple-inheritance
15873 situations). If the class declares any non-inline, non-pure virtual
15874 functions, the first one is chosen as the ``key method'' for the class,
15875 and the vtable is only emitted in the translation unit where the key
15876 method is defined.
15877
15878 @emph{Note:} If the chosen key method is later defined as inline, the
15879 vtable is still emitted in every translation unit that defines it.
15880 Make sure that any inline virtuals are declared inline in the class
15881 body, even if they are not defined there.
15882
15883 @item @code{type_info} objects
15884 @cindex @code{type_info}
15885 @cindex RTTI
15886 C++ requires information about types to be written out in order to
15887 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
15888 For polymorphic classes (classes with virtual functions), the @samp{type_info}
15889 object is written out along with the vtable so that @samp{dynamic_cast}
15890 can determine the dynamic type of a class object at run time. For all
15891 other types, we write out the @samp{type_info} object when it is used: when
15892 applying @samp{typeid} to an expression, throwing an object, or
15893 referring to a type in a catch clause or exception specification.
15894
15895 @item Template Instantiations
15896 Most everything in this section also applies to template instantiations,
15897 but there are other options as well.
15898 @xref{Template Instantiation,,Where's the Template?}.
15899
15900 @end table
15901
15902 When used with GNU ld version 2.8 or later on an ELF system such as
15903 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
15904 these constructs will be discarded at link time. This is known as
15905 COMDAT support.
15906
15907 On targets that don't support COMDAT, but do support weak symbols, GCC
15908 uses them. This way one copy overrides all the others, but
15909 the unused copies still take up space in the executable.
15910
15911 For targets that do not support either COMDAT or weak symbols,
15912 most entities with vague linkage are emitted as local symbols to
15913 avoid duplicate definition errors from the linker. This does not happen
15914 for local statics in inlines, however, as having multiple copies
15915 almost certainly breaks things.
15916
15917 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
15918 another way to control placement of these constructs.
15919
15920 @node C++ Interface
15921 @section #pragma interface and implementation
15922
15923 @cindex interface and implementation headers, C++
15924 @cindex C++ interface and implementation headers
15925 @cindex pragmas, interface and implementation
15926
15927 @code{#pragma interface} and @code{#pragma implementation} provide the
15928 user with a way of explicitly directing the compiler to emit entities
15929 with vague linkage (and debugging information) in a particular
15930 translation unit.
15931
15932 @emph{Note:} As of GCC 2.7.2, these @code{#pragma}s are not useful in
15933 most cases, because of COMDAT support and the ``key method'' heuristic
15934 mentioned in @ref{Vague Linkage}. Using them can actually cause your
15935 program to grow due to unnecessary out-of-line copies of inline
15936 functions. Currently (3.4) the only benefit of these
15937 @code{#pragma}s is reduced duplication of debugging information, and
15938 that should be addressed soon on DWARF 2 targets with the use of
15939 COMDAT groups.
15940
15941 @table @code
15942 @item #pragma interface
15943 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
15944 @kindex #pragma interface
15945 Use this directive in @emph{header files} that define object classes, to save
15946 space in most of the object files that use those classes. Normally,
15947 local copies of certain information (backup copies of inline member
15948 functions, debugging information, and the internal tables that implement
15949 virtual functions) must be kept in each object file that includes class
15950 definitions. You can use this pragma to avoid such duplication. When a
15951 header file containing @samp{#pragma interface} is included in a
15952 compilation, this auxiliary information is not generated (unless
15953 the main input source file itself uses @samp{#pragma implementation}).
15954 Instead, the object files contain references to be resolved at link
15955 time.
15956
15957 The second form of this directive is useful for the case where you have
15958 multiple headers with the same name in different directories. If you
15959 use this form, you must specify the same string to @samp{#pragma
15960 implementation}.
15961
15962 @item #pragma implementation
15963 @itemx #pragma implementation "@var{objects}.h"
15964 @kindex #pragma implementation
15965 Use this pragma in a @emph{main input file}, when you want full output from
15966 included header files to be generated (and made globally visible). The
15967 included header file, in turn, should use @samp{#pragma interface}.
15968 Backup copies of inline member functions, debugging information, and the
15969 internal tables used to implement virtual functions are all generated in
15970 implementation files.
15971
15972 @cindex implied @code{#pragma implementation}
15973 @cindex @code{#pragma implementation}, implied
15974 @cindex naming convention, implementation headers
15975 If you use @samp{#pragma implementation} with no argument, it applies to
15976 an include file with the same basename@footnote{A file's @dfn{basename}
15977 is the name stripped of all leading path information and of trailing
15978 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
15979 file. For example, in @file{allclass.cc}, giving just
15980 @samp{#pragma implementation}
15981 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
15982
15983 In versions of GNU C++ prior to 2.6.0 @file{allclass.h} was treated as
15984 an implementation file whenever you would include it from
15985 @file{allclass.cc} even if you never specified @samp{#pragma
15986 implementation}. This was deemed to be more trouble than it was worth,
15987 however, and disabled.
15988
15989 Use the string argument if you want a single implementation file to
15990 include code from multiple header files. (You must also use
15991 @samp{#include} to include the header file; @samp{#pragma
15992 implementation} only specifies how to use the file---it doesn't actually
15993 include it.)
15994
15995 There is no way to split up the contents of a single header file into
15996 multiple implementation files.
15997 @end table
15998
15999 @cindex inlining and C++ pragmas
16000 @cindex C++ pragmas, effect on inlining
16001 @cindex pragmas in C++, effect on inlining
16002 @samp{#pragma implementation} and @samp{#pragma interface} also have an
16003 effect on function inlining.
16004
16005 If you define a class in a header file marked with @samp{#pragma
16006 interface}, the effect on an inline function defined in that class is
16007 similar to an explicit @code{extern} declaration---the compiler emits
16008 no code at all to define an independent version of the function. Its
16009 definition is used only for inlining with its callers.
16010
16011 @opindex fno-implement-inlines
16012 Conversely, when you include the same header file in a main source file
16013 that declares it as @samp{#pragma implementation}, the compiler emits
16014 code for the function itself; this defines a version of the function
16015 that can be found via pointers (or by callers compiled without
16016 inlining). If all calls to the function can be inlined, you can avoid
16017 emitting the function by compiling with @option{-fno-implement-inlines}.
16018 If any calls are not inlined, you will get linker errors.
16019
16020 @node Template Instantiation
16021 @section Where's the Template?
16022 @cindex template instantiation
16023
16024 C++ templates are the first language feature to require more
16025 intelligence from the environment than one usually finds on a UNIX
16026 system. Somehow the compiler and linker have to make sure that each
16027 template instance occurs exactly once in the executable if it is needed,
16028 and not at all otherwise. There are two basic approaches to this
16029 problem, which are referred to as the Borland model and the Cfront model.
16030
16031 @table @asis
16032 @item Borland model
16033 Borland C++ solved the template instantiation problem by adding the code
16034 equivalent of common blocks to their linker; the compiler emits template
16035 instances in each translation unit that uses them, and the linker
16036 collapses them together. The advantage of this model is that the linker
16037 only has to consider the object files themselves; there is no external
16038 complexity to worry about. This disadvantage is that compilation time
16039 is increased because the template code is being compiled repeatedly.
16040 Code written for this model tends to include definitions of all
16041 templates in the header file, since they must be seen to be
16042 instantiated.
16043
16044 @item Cfront model
16045 The AT&T C++ translator, Cfront, solved the template instantiation
16046 problem by creating the notion of a template repository, an
16047 automatically maintained place where template instances are stored. A
16048 more modern version of the repository works as follows: As individual
16049 object files are built, the compiler places any template definitions and
16050 instantiations encountered in the repository. At link time, the link
16051 wrapper adds in the objects in the repository and compiles any needed
16052 instances that were not previously emitted. The advantages of this
16053 model are more optimal compilation speed and the ability to use the
16054 system linker; to implement the Borland model a compiler vendor also
16055 needs to replace the linker. The disadvantages are vastly increased
16056 complexity, and thus potential for error; for some code this can be
16057 just as transparent, but in practice it can been very difficult to build
16058 multiple programs in one directory and one program in multiple
16059 directories. Code written for this model tends to separate definitions
16060 of non-inline member templates into a separate file, which should be
16061 compiled separately.
16062 @end table
16063
16064 When used with GNU ld version 2.8 or later on an ELF system such as
16065 GNU/Linux or Solaris 2, or on Microsoft Windows, G++ supports the
16066 Borland model. On other systems, G++ implements neither automatic
16067 model.
16068
16069 You have the following options for dealing with template instantiations:
16070
16071 @enumerate
16072 @item
16073 @opindex frepo
16074 Compile your template-using code with @option{-frepo}. The compiler
16075 generates files with the extension @samp{.rpo} listing all of the
16076 template instantiations used in the corresponding object files that
16077 could be instantiated there; the link wrapper, @samp{collect2},
16078 then updates the @samp{.rpo} files to tell the compiler where to place
16079 those instantiations and rebuild any affected object files. The
16080 link-time overhead is negligible after the first pass, as the compiler
16081 continues to place the instantiations in the same files.
16082
16083 This is your best option for application code written for the Borland
16084 model, as it just works. Code written for the Cfront model
16085 needs to be modified so that the template definitions are available at
16086 one or more points of instantiation; usually this is as simple as adding
16087 @code{#include <tmethods.cc>} to the end of each template header.
16088
16089 For library code, if you want the library to provide all of the template
16090 instantiations it needs, just try to link all of its object files
16091 together; the link will fail, but cause the instantiations to be
16092 generated as a side effect. Be warned, however, that this may cause
16093 conflicts if multiple libraries try to provide the same instantiations.
16094 For greater control, use explicit instantiation as described in the next
16095 option.
16096
16097 @item
16098 @opindex fno-implicit-templates
16099 Compile your code with @option{-fno-implicit-templates} to disable the
16100 implicit generation of template instances, and explicitly instantiate
16101 all the ones you use. This approach requires more knowledge of exactly
16102 which instances you need than do the others, but it's less
16103 mysterious and allows greater control. You can scatter the explicit
16104 instantiations throughout your program, perhaps putting them in the
16105 translation units where the instances are used or the translation units
16106 that define the templates themselves; you can put all of the explicit
16107 instantiations you need into one big file; or you can create small files
16108 like
16109
16110 @smallexample
16111 #include "Foo.h"
16112 #include "Foo.cc"
16113
16114 template class Foo<int>;
16115 template ostream& operator <<
16116 (ostream&, const Foo<int>&);
16117 @end smallexample
16118
16119 @noindent
16120 for each of the instances you need, and create a template instantiation
16121 library from those.
16122
16123 If you are using Cfront-model code, you can probably get away with not
16124 using @option{-fno-implicit-templates} when compiling files that don't
16125 @samp{#include} the member template definitions.
16126
16127 If you use one big file to do the instantiations, you may want to
16128 compile it without @option{-fno-implicit-templates} so you get all of the
16129 instances required by your explicit instantiations (but not by any
16130 other files) without having to specify them as well.
16131
16132 The ISO C++ 2011 standard allows forward declaration of explicit
16133 instantiations (with @code{extern}). G++ supports explicit instantiation
16134 declarations in C++98 mode and has extended the template instantiation
16135 syntax to support instantiation of the compiler support data for a
16136 template class (i.e.@: the vtable) without instantiating any of its
16137 members (with @code{inline}), and instantiation of only the static data
16138 members of a template class, without the support data or member
16139 functions (with (@code{static}):
16140
16141 @smallexample
16142 extern template int max (int, int);
16143 inline template class Foo<int>;
16144 static template class Foo<int>;
16145 @end smallexample
16146
16147 @item
16148 Do nothing. Pretend G++ does implement automatic instantiation
16149 management. Code written for the Borland model works fine, but
16150 each translation unit contains instances of each of the templates it
16151 uses. In a large program, this can lead to an unacceptable amount of code
16152 duplication.
16153 @end enumerate
16154
16155 @node Bound member functions
16156 @section Extracting the function pointer from a bound pointer to member function
16157 @cindex pmf
16158 @cindex pointer to member function
16159 @cindex bound pointer to member function
16160
16161 In C++, pointer to member functions (PMFs) are implemented using a wide
16162 pointer of sorts to handle all the possible call mechanisms; the PMF
16163 needs to store information about how to adjust the @samp{this} pointer,
16164 and if the function pointed to is virtual, where to find the vtable, and
16165 where in the vtable to look for the member function. If you are using
16166 PMFs in an inner loop, you should really reconsider that decision. If
16167 that is not an option, you can extract the pointer to the function that
16168 would be called for a given object/PMF pair and call it directly inside
16169 the inner loop, to save a bit of time.
16170
16171 Note that you still pay the penalty for the call through a
16172 function pointer; on most modern architectures, such a call defeats the
16173 branch prediction features of the CPU@. This is also true of normal
16174 virtual function calls.
16175
16176 The syntax for this extension is
16177
16178 @smallexample
16179 extern A a;
16180 extern int (A::*fp)();
16181 typedef int (*fptr)(A *);
16182
16183 fptr p = (fptr)(a.*fp);
16184 @end smallexample
16185
16186 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
16187 no object is needed to obtain the address of the function. They can be
16188 converted to function pointers directly:
16189
16190 @smallexample
16191 fptr p1 = (fptr)(&A::foo);
16192 @end smallexample
16193
16194 @opindex Wno-pmf-conversions
16195 You must specify @option{-Wno-pmf-conversions} to use this extension.
16196
16197 @node C++ Attributes
16198 @section C++-Specific Variable, Function, and Type Attributes
16199
16200 Some attributes only make sense for C++ programs.
16201
16202 @table @code
16203 @item abi_tag ("@var{tag}", ...)
16204 @cindex @code{abi_tag} attribute
16205 The @code{abi_tag} attribute can be applied to a function or class
16206 declaration. It modifies the mangled name of the function or class to
16207 incorporate the tag name, in order to distinguish the function or
16208 class from an earlier version with a different ABI; perhaps the class
16209 has changed size, or the function has a different return type that is
16210 not encoded in the mangled name.
16211
16212 The argument can be a list of strings of arbitrary length. The
16213 strings are sorted on output, so the order of the list is
16214 unimportant.
16215
16216 A redeclaration of a function or class must not add new ABI tags,
16217 since doing so would change the mangled name.
16218
16219 The @option{-Wabi-tag} flag enables a warning about a class which does
16220 not have all the ABI tags used by its subobjects and virtual functions; for users with code
16221 that needs to coexist with an earlier ABI, using this option can help
16222 to find all affected types that need to be tagged.
16223
16224 @item init_priority (@var{priority})
16225 @cindex @code{init_priority} attribute
16226
16227
16228 In Standard C++, objects defined at namespace scope are guaranteed to be
16229 initialized in an order in strict accordance with that of their definitions
16230 @emph{in a given translation unit}. No guarantee is made for initializations
16231 across translation units. However, GNU C++ allows users to control the
16232 order of initialization of objects defined at namespace scope with the
16233 @code{init_priority} attribute by specifying a relative @var{priority},
16234 a constant integral expression currently bounded between 101 and 65535
16235 inclusive. Lower numbers indicate a higher priority.
16236
16237 In the following example, @code{A} would normally be created before
16238 @code{B}, but the @code{init_priority} attribute reverses that order:
16239
16240 @smallexample
16241 Some_Class A __attribute__ ((init_priority (2000)));
16242 Some_Class B __attribute__ ((init_priority (543)));
16243 @end smallexample
16244
16245 @noindent
16246 Note that the particular values of @var{priority} do not matter; only their
16247 relative ordering.
16248
16249 @item java_interface
16250 @cindex @code{java_interface} attribute
16251
16252 This type attribute informs C++ that the class is a Java interface. It may
16253 only be applied to classes declared within an @code{extern "Java"} block.
16254 Calls to methods declared in this interface are dispatched using GCJ's
16255 interface table mechanism, instead of regular virtual table dispatch.
16256
16257 @end table
16258
16259 See also @ref{Namespace Association}.
16260
16261 @node Function Multiversioning
16262 @section Function Multiversioning
16263 @cindex function versions
16264
16265 With the GNU C++ front end, for target i386, you may specify multiple
16266 versions of a function, where each function is specialized for a
16267 specific target feature. At runtime, the appropriate version of the
16268 function is automatically executed depending on the characteristics of
16269 the execution platform. Here is an example.
16270
16271 @smallexample
16272 __attribute__ ((target ("default")))
16273 int foo ()
16274 @{
16275 // The default version of foo.
16276 return 0;
16277 @}
16278
16279 __attribute__ ((target ("sse4.2")))
16280 int foo ()
16281 @{
16282 // foo version for SSE4.2
16283 return 1;
16284 @}
16285
16286 __attribute__ ((target ("arch=atom")))
16287 int foo ()
16288 @{
16289 // foo version for the Intel ATOM processor
16290 return 2;
16291 @}
16292
16293 __attribute__ ((target ("arch=amdfam10")))
16294 int foo ()
16295 @{
16296 // foo version for the AMD Family 0x10 processors.
16297 return 3;
16298 @}
16299
16300 int main ()
16301 @{
16302 int (*p)() = &foo;
16303 assert ((*p) () == foo ());
16304 return 0;
16305 @}
16306 @end smallexample
16307
16308 In the above example, four versions of function foo are created. The
16309 first version of foo with the target attribute "default" is the default
16310 version. This version gets executed when no other target specific
16311 version qualifies for execution on a particular platform. A new version
16312 of foo is created by using the same function signature but with a
16313 different target string. Function foo is called or a pointer to it is
16314 taken just like a regular function. GCC takes care of doing the
16315 dispatching to call the right version at runtime. Refer to the
16316 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
16317 Function Multiversioning} for more details.
16318
16319 @node Namespace Association
16320 @section Namespace Association
16321
16322 @strong{Caution:} The semantics of this extension are equivalent
16323 to C++ 2011 inline namespaces. Users should use inline namespaces
16324 instead as this extension will be removed in future versions of G++.
16325
16326 A using-directive with @code{__attribute ((strong))} is stronger
16327 than a normal using-directive in two ways:
16328
16329 @itemize @bullet
16330 @item
16331 Templates from the used namespace can be specialized and explicitly
16332 instantiated as though they were members of the using namespace.
16333
16334 @item
16335 The using namespace is considered an associated namespace of all
16336 templates in the used namespace for purposes of argument-dependent
16337 name lookup.
16338 @end itemize
16339
16340 The used namespace must be nested within the using namespace so that
16341 normal unqualified lookup works properly.
16342
16343 This is useful for composing a namespace transparently from
16344 implementation namespaces. For example:
16345
16346 @smallexample
16347 namespace std @{
16348 namespace debug @{
16349 template <class T> struct A @{ @};
16350 @}
16351 using namespace debug __attribute ((__strong__));
16352 template <> struct A<int> @{ @}; // @r{ok to specialize}
16353
16354 template <class T> void f (A<T>);
16355 @}
16356
16357 int main()
16358 @{
16359 f (std::A<float>()); // @r{lookup finds} std::f
16360 f (std::A<int>());
16361 @}
16362 @end smallexample
16363
16364 @node Type Traits
16365 @section Type Traits
16366
16367 The C++ front end implements syntactic extensions that allow
16368 compile-time determination of
16369 various characteristics of a type (or of a
16370 pair of types).
16371
16372 @table @code
16373 @item __has_nothrow_assign (type)
16374 If @code{type} is const qualified or is a reference type then the trait is
16375 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
16376 is true, else if @code{type} is a cv class or union type with copy assignment
16377 operators that are known not to throw an exception then the trait is true,
16378 else it is false. Requires: @code{type} shall be a complete type,
16379 (possibly cv-qualified) @code{void}, or an array of unknown bound.
16380
16381 @item __has_nothrow_copy (type)
16382 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
16383 @code{type} is a cv class or union type with copy constructors that
16384 are known not to throw an exception then the trait is true, else it is false.
16385 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
16386 @code{void}, or an array of unknown bound.
16387
16388 @item __has_nothrow_constructor (type)
16389 If @code{__has_trivial_constructor (type)} is true then the trait is
16390 true, else if @code{type} is a cv class or union type (or array
16391 thereof) with a default constructor that is known not to throw an
16392 exception then the trait is true, else it is false. Requires:
16393 @code{type} shall be a complete type, (possibly cv-qualified)
16394 @code{void}, or an array of unknown bound.
16395
16396 @item __has_trivial_assign (type)
16397 If @code{type} is const qualified or is a reference type then the trait is
16398 false. Otherwise if @code{__is_pod (type)} is true then the trait is
16399 true, else if @code{type} is a cv class or union type with a trivial
16400 copy assignment ([class.copy]) then the trait is true, else it is
16401 false. Requires: @code{type} shall be a complete type, (possibly
16402 cv-qualified) @code{void}, or an array of unknown bound.
16403
16404 @item __has_trivial_copy (type)
16405 If @code{__is_pod (type)} is true or @code{type} is a reference type
16406 then the trait is true, else if @code{type} is a cv class or union type
16407 with a trivial copy constructor ([class.copy]) then the trait
16408 is true, else it is false. Requires: @code{type} shall be a complete
16409 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16410
16411 @item __has_trivial_constructor (type)
16412 If @code{__is_pod (type)} is true then the trait is true, else if
16413 @code{type} is a cv class or union type (or array thereof) with a
16414 trivial default constructor ([class.ctor]) then the trait is true,
16415 else it is false. Requires: @code{type} shall be a complete
16416 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16417
16418 @item __has_trivial_destructor (type)
16419 If @code{__is_pod (type)} is true or @code{type} is a reference type then
16420 the trait is true, else if @code{type} is a cv class or union type (or
16421 array thereof) with a trivial destructor ([class.dtor]) then the trait
16422 is true, else it is false. Requires: @code{type} shall be a complete
16423 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16424
16425 @item __has_virtual_destructor (type)
16426 If @code{type} is a class type with a virtual destructor
16427 ([class.dtor]) then the trait is true, else it is false. Requires:
16428 @code{type} shall be a complete type, (possibly cv-qualified)
16429 @code{void}, or an array of unknown bound.
16430
16431 @item __is_abstract (type)
16432 If @code{type} is an abstract class ([class.abstract]) then the trait
16433 is true, else it is false. Requires: @code{type} shall be a complete
16434 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16435
16436 @item __is_base_of (base_type, derived_type)
16437 If @code{base_type} is a base class of @code{derived_type}
16438 ([class.derived]) then the trait is true, otherwise it is false.
16439 Top-level cv qualifications of @code{base_type} and
16440 @code{derived_type} are ignored. For the purposes of this trait, a
16441 class type is considered is own base. Requires: if @code{__is_class
16442 (base_type)} and @code{__is_class (derived_type)} are true and
16443 @code{base_type} and @code{derived_type} are not the same type
16444 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
16445 type. Diagnostic is produced if this requirement is not met.
16446
16447 @item __is_class (type)
16448 If @code{type} is a cv class type, and not a union type
16449 ([basic.compound]) the trait is true, else it is false.
16450
16451 @item __is_empty (type)
16452 If @code{__is_class (type)} is false then the trait is false.
16453 Otherwise @code{type} is considered empty if and only if: @code{type}
16454 has no non-static data members, or all non-static data members, if
16455 any, are bit-fields of length 0, and @code{type} has no virtual
16456 members, and @code{type} has no virtual base classes, and @code{type}
16457 has no base classes @code{base_type} for which
16458 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
16459 be a complete type, (possibly cv-qualified) @code{void}, or an array
16460 of unknown bound.
16461
16462 @item __is_enum (type)
16463 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
16464 true, else it is false.
16465
16466 @item __is_literal_type (type)
16467 If @code{type} is a literal type ([basic.types]) the trait is
16468 true, else it is false. Requires: @code{type} shall be a complete type,
16469 (possibly cv-qualified) @code{void}, or an array of unknown bound.
16470
16471 @item __is_pod (type)
16472 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
16473 else it is false. Requires: @code{type} shall be a complete type,
16474 (possibly cv-qualified) @code{void}, or an array of unknown bound.
16475
16476 @item __is_polymorphic (type)
16477 If @code{type} is a polymorphic class ([class.virtual]) then the trait
16478 is true, else it is false. Requires: @code{type} shall be a complete
16479 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16480
16481 @item __is_standard_layout (type)
16482 If @code{type} is a standard-layout type ([basic.types]) the trait is
16483 true, else it is false. Requires: @code{type} shall be a complete
16484 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16485
16486 @item __is_trivial (type)
16487 If @code{type} is a trivial type ([basic.types]) the trait is
16488 true, else it is false. Requires: @code{type} shall be a complete
16489 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
16490
16491 @item __is_union (type)
16492 If @code{type} is a cv union type ([basic.compound]) the trait is
16493 true, else it is false.
16494
16495 @item __underlying_type (type)
16496 The underlying type of @code{type}. Requires: @code{type} shall be
16497 an enumeration type ([dcl.enum]).
16498
16499 @end table
16500
16501 @node Java Exceptions
16502 @section Java Exceptions
16503
16504 The Java language uses a slightly different exception handling model
16505 from C++. Normally, GNU C++ automatically detects when you are
16506 writing C++ code that uses Java exceptions, and handle them
16507 appropriately. However, if C++ code only needs to execute destructors
16508 when Java exceptions are thrown through it, GCC guesses incorrectly.
16509 Sample problematic code is:
16510
16511 @smallexample
16512 struct S @{ ~S(); @};
16513 extern void bar(); // @r{is written in Java, and may throw exceptions}
16514 void foo()
16515 @{
16516 S s;
16517 bar();
16518 @}
16519 @end smallexample
16520
16521 @noindent
16522 The usual effect of an incorrect guess is a link failure, complaining of
16523 a missing routine called @samp{__gxx_personality_v0}.
16524
16525 You can inform the compiler that Java exceptions are to be used in a
16526 translation unit, irrespective of what it might think, by writing
16527 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
16528 @samp{#pragma} must appear before any functions that throw or catch
16529 exceptions, or run destructors when exceptions are thrown through them.
16530
16531 You cannot mix Java and C++ exceptions in the same translation unit. It
16532 is believed to be safe to throw a C++ exception from one file through
16533 another file compiled for the Java exception model, or vice versa, but
16534 there may be bugs in this area.
16535
16536 @node Deprecated Features
16537 @section Deprecated Features
16538
16539 In the past, the GNU C++ compiler was extended to experiment with new
16540 features, at a time when the C++ language was still evolving. Now that
16541 the C++ standard is complete, some of those features are superseded by
16542 superior alternatives. Using the old features might cause a warning in
16543 some cases that the feature will be dropped in the future. In other
16544 cases, the feature might be gone already.
16545
16546 While the list below is not exhaustive, it documents some of the options
16547 that are now deprecated:
16548
16549 @table @code
16550 @item -fexternal-templates
16551 @itemx -falt-external-templates
16552 These are two of the many ways for G++ to implement template
16553 instantiation. @xref{Template Instantiation}. The C++ standard clearly
16554 defines how template definitions have to be organized across
16555 implementation units. G++ has an implicit instantiation mechanism that
16556 should work just fine for standard-conforming code.
16557
16558 @item -fstrict-prototype
16559 @itemx -fno-strict-prototype
16560 Previously it was possible to use an empty prototype parameter list to
16561 indicate an unspecified number of parameters (like C), rather than no
16562 parameters, as C++ demands. This feature has been removed, except where
16563 it is required for backwards compatibility. @xref{Backwards Compatibility}.
16564 @end table
16565
16566 G++ allows a virtual function returning @samp{void *} to be overridden
16567 by one returning a different pointer type. This extension to the
16568 covariant return type rules is now deprecated and will be removed from a
16569 future version.
16570
16571 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
16572 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
16573 and are now removed from G++. Code using these operators should be
16574 modified to use @code{std::min} and @code{std::max} instead.
16575
16576 The named return value extension has been deprecated, and is now
16577 removed from G++.
16578
16579 The use of initializer lists with new expressions has been deprecated,
16580 and is now removed from G++.
16581
16582 Floating and complex non-type template parameters have been deprecated,
16583 and are now removed from G++.
16584
16585 The implicit typename extension has been deprecated and is now
16586 removed from G++.
16587
16588 The use of default arguments in function pointers, function typedefs
16589 and other places where they are not permitted by the standard is
16590 deprecated and will be removed from a future version of G++.
16591
16592 G++ allows floating-point literals to appear in integral constant expressions,
16593 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
16594 This extension is deprecated and will be removed from a future version.
16595
16596 G++ allows static data members of const floating-point type to be declared
16597 with an initializer in a class definition. The standard only allows
16598 initializers for static members of const integral types and const
16599 enumeration types so this extension has been deprecated and will be removed
16600 from a future version.
16601
16602 @node Backwards Compatibility
16603 @section Backwards Compatibility
16604 @cindex Backwards Compatibility
16605 @cindex ARM [Annotated C++ Reference Manual]
16606
16607 Now that there is a definitive ISO standard C++, G++ has a specification
16608 to adhere to. The C++ language evolved over time, and features that
16609 used to be acceptable in previous drafts of the standard, such as the ARM
16610 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
16611 compilation of C++ written to such drafts, G++ contains some backwards
16612 compatibilities. @emph{All such backwards compatibility features are
16613 liable to disappear in future versions of G++.} They should be considered
16614 deprecated. @xref{Deprecated Features}.
16615
16616 @table @code
16617 @item For scope
16618 If a variable is declared at for scope, it used to remain in scope until
16619 the end of the scope that contained the for statement (rather than just
16620 within the for scope). G++ retains this, but issues a warning, if such a
16621 variable is accessed outside the for scope.
16622
16623 @item Implicit C language
16624 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
16625 scope to set the language. On such systems, all header files are
16626 implicitly scoped inside a C language scope. Also, an empty prototype
16627 @code{()} is treated as an unspecified number of arguments, rather
16628 than no arguments, as C++ demands.
16629 @end table