extend.texi (SPU Built-in Functions): Remove stale references to material formerly...
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2016 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF
920 debug info format can represent this, so use of DWARF is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
926
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{_Float@var{n}} data types
931 @cindex @code{_Float@var{n}x} data types
932 @cindex @code{__float80} data type
933 @cindex @code{__float128} data type
934 @cindex @code{__ibm128} data type
935 @cindex @code{w} floating point suffix
936 @cindex @code{q} floating point suffix
937 @cindex @code{W} floating point suffix
938 @cindex @code{Q} floating point suffix
939
940 ISO/IEC TS 18661-3:2015 defines C support for additional floating
941 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
942 these type names; the set of types supported depends on the target
943 architecture. These types are not supported when compiling C++.
944 Constants with these types use suffixes @code{f@var{n}} or
945 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
946 names can be used together with @code{_Complex} to declare complex
947 types.
948
949 As an extension, GNU C and GNU C++ support additional floating
950 types, @code{__float80} and @code{__float128} to support 80-bit
951 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types; these are
952 aliases for the type names @code{_Float64x} and @code{_Float128}.
953 Support for additional types includes the arithmetic operators:
954 add, subtract, multiply, divide; unary arithmetic operators;
955 relational operators; equality operators; and conversions to and from
956 integer and other floating types. Use a suffix @samp{w} or @samp{W}
957 in a literal constant of type @code{__float80} or type
958 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
959
960 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
961 types using the corresponding internal complex type, @code{XCmode} for
962 @code{__float80} type and @code{TCmode} for @code{__float128} type:
963
964 @smallexample
965 typedef _Complex float __attribute__((mode(TC))) _Complex128;
966 typedef _Complex float __attribute__((mode(XC))) _Complex80;
967 @end smallexample
968
969 In order to use @code{_Float128}, @code{__float128} and
970 @code{__ibm128} on PowerPC Linux
971 systems, you must use the @option{-mfloat128}. It is expected in
972 future versions of GCC that @code{_Float128} and @code{__float128}
973 will be enabled
974 automatically. In addition, there are currently problems in using the
975 complex @code{__float128} type. When these problems are fixed, you
976 would use the following syntax to declare @code{_Complex128} to be a
977 complex @code{__float128} type:
978
979 On the PowerPC Linux VSX targets, you can declare complex types using
980 the corresponding internal complex type, @code{KCmode} for
981 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
982
983 @smallexample
984 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
985 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
986 @end smallexample
987
988 Not all targets support additional floating-point types.
989 @code{__float80} and @code{__float128} types are supported on x86 and
990 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
991 The @code{__float128} type is supported on PowerPC 64-bit Linux
992 systems by default if the vector scalar instruction set (VSX) is
993 enabled. The @code{_Float128} type is supported on all systems where
994 @code{__float128} is supported or where @code{long double} has the
995 IEEE binary128 format. The @code{_Float64x} type is supported on all
996 systems where @code{__float128} is supported. The @code{_Float32}
997 type is supported on all systems supporting IEEE binary32; the
998 @code{_Float64} and @code{Float32x} types are supported on all systems
999 supporting IEEE binary64. GCC does not currently support
1000 @code{_Float16} or @code{_Float128x} on any systems.
1001
1002 On the PowerPC, @code{__ibm128} provides access to the IBM extended
1003 double format, and it is intended to be used by the library functions
1004 that handle conversions if/when long double is changed to be IEEE
1005 128-bit floating point.
1006
1007 @node Half-Precision
1008 @section Half-Precision Floating Point
1009 @cindex half-precision floating point
1010 @cindex @code{__fp16} data type
1011
1012 On ARM targets, GCC supports half-precision (16-bit) floating point via
1013 the @code{__fp16} type. You must enable this type explicitly
1014 with the @option{-mfp16-format} command-line option in order to use it.
1015
1016 ARM supports two incompatible representations for half-precision
1017 floating-point values. You must choose one of the representations and
1018 use it consistently in your program.
1019
1020 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1021 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1022 There are 11 bits of significand precision, approximately 3
1023 decimal digits.
1024
1025 Specifying @option{-mfp16-format=alternative} selects the ARM
1026 alternative format. This representation is similar to the IEEE
1027 format, but does not support infinities or NaNs. Instead, the range
1028 of exponents is extended, so that this format can represent normalized
1029 values in the range of @math{2^{-14}} to 131008.
1030
1031 The @code{__fp16} type is a storage format only. For purposes
1032 of arithmetic and other operations, @code{__fp16} values in C or C++
1033 expressions are automatically promoted to @code{float}. In addition,
1034 you cannot declare a function with a return value or parameters
1035 of type @code{__fp16}.
1036
1037 Note that conversions from @code{double} to @code{__fp16}
1038 involve an intermediate conversion to @code{float}. Because
1039 of rounding, this can sometimes produce a different result than a
1040 direct conversion.
1041
1042 ARM provides hardware support for conversions between
1043 @code{__fp16} and @code{float} values
1044 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1045 code using these hardware instructions if you compile with
1046 options to select an FPU that provides them;
1047 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1048 in addition to the @option{-mfp16-format} option to select
1049 a half-precision format.
1050
1051 Language-level support for the @code{__fp16} data type is
1052 independent of whether GCC generates code using hardware floating-point
1053 instructions. In cases where hardware support is not specified, GCC
1054 implements conversions between @code{__fp16} and @code{float} values
1055 as library calls.
1056
1057 @node Decimal Float
1058 @section Decimal Floating Types
1059 @cindex decimal floating types
1060 @cindex @code{_Decimal32} data type
1061 @cindex @code{_Decimal64} data type
1062 @cindex @code{_Decimal128} data type
1063 @cindex @code{df} integer suffix
1064 @cindex @code{dd} integer suffix
1065 @cindex @code{dl} integer suffix
1066 @cindex @code{DF} integer suffix
1067 @cindex @code{DD} integer suffix
1068 @cindex @code{DL} integer suffix
1069
1070 As an extension, GNU C supports decimal floating types as
1071 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1072 floating types in GCC will evolve as the draft technical report changes.
1073 Calling conventions for any target might also change. Not all targets
1074 support decimal floating types.
1075
1076 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1077 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1078 @code{float}, @code{double}, and @code{long double} whose radix is not
1079 specified by the C standard but is usually two.
1080
1081 Support for decimal floating types includes the arithmetic operators
1082 add, subtract, multiply, divide; unary arithmetic operators;
1083 relational operators; equality operators; and conversions to and from
1084 integer and other floating types. Use a suffix @samp{df} or
1085 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1086 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1087 @code{_Decimal128}.
1088
1089 GCC support of decimal float as specified by the draft technical report
1090 is incomplete:
1091
1092 @itemize @bullet
1093 @item
1094 When the value of a decimal floating type cannot be represented in the
1095 integer type to which it is being converted, the result is undefined
1096 rather than the result value specified by the draft technical report.
1097
1098 @item
1099 GCC does not provide the C library functionality associated with
1100 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1101 @file{wchar.h}, which must come from a separate C library implementation.
1102 Because of this the GNU C compiler does not define macro
1103 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1104 the technical report.
1105 @end itemize
1106
1107 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1108 are supported by the DWARF debug information format.
1109
1110 @node Hex Floats
1111 @section Hex Floats
1112 @cindex hex floats
1113
1114 ISO C99 supports floating-point numbers written not only in the usual
1115 decimal notation, such as @code{1.55e1}, but also numbers such as
1116 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1117 supports this in C90 mode (except in some cases when strictly
1118 conforming) and in C++. In that format the
1119 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1120 mandatory. The exponent is a decimal number that indicates the power of
1121 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1122 @tex
1123 $1 {15\over16}$,
1124 @end tex
1125 @ifnottex
1126 1 15/16,
1127 @end ifnottex
1128 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1129 is the same as @code{1.55e1}.
1130
1131 Unlike for floating-point numbers in the decimal notation the exponent
1132 is always required in the hexadecimal notation. Otherwise the compiler
1133 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1134 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1135 extension for floating-point constants of type @code{float}.
1136
1137 @node Fixed-Point
1138 @section Fixed-Point Types
1139 @cindex fixed-point types
1140 @cindex @code{_Fract} data type
1141 @cindex @code{_Accum} data type
1142 @cindex @code{_Sat} data type
1143 @cindex @code{hr} fixed-suffix
1144 @cindex @code{r} fixed-suffix
1145 @cindex @code{lr} fixed-suffix
1146 @cindex @code{llr} fixed-suffix
1147 @cindex @code{uhr} fixed-suffix
1148 @cindex @code{ur} fixed-suffix
1149 @cindex @code{ulr} fixed-suffix
1150 @cindex @code{ullr} fixed-suffix
1151 @cindex @code{hk} fixed-suffix
1152 @cindex @code{k} fixed-suffix
1153 @cindex @code{lk} fixed-suffix
1154 @cindex @code{llk} fixed-suffix
1155 @cindex @code{uhk} fixed-suffix
1156 @cindex @code{uk} fixed-suffix
1157 @cindex @code{ulk} fixed-suffix
1158 @cindex @code{ullk} fixed-suffix
1159 @cindex @code{HR} fixed-suffix
1160 @cindex @code{R} fixed-suffix
1161 @cindex @code{LR} fixed-suffix
1162 @cindex @code{LLR} fixed-suffix
1163 @cindex @code{UHR} fixed-suffix
1164 @cindex @code{UR} fixed-suffix
1165 @cindex @code{ULR} fixed-suffix
1166 @cindex @code{ULLR} fixed-suffix
1167 @cindex @code{HK} fixed-suffix
1168 @cindex @code{K} fixed-suffix
1169 @cindex @code{LK} fixed-suffix
1170 @cindex @code{LLK} fixed-suffix
1171 @cindex @code{UHK} fixed-suffix
1172 @cindex @code{UK} fixed-suffix
1173 @cindex @code{ULK} fixed-suffix
1174 @cindex @code{ULLK} fixed-suffix
1175
1176 As an extension, GNU C supports fixed-point types as
1177 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1178 types in GCC will evolve as the draft technical report changes.
1179 Calling conventions for any target might also change. Not all targets
1180 support fixed-point types.
1181
1182 The fixed-point types are
1183 @code{short _Fract},
1184 @code{_Fract},
1185 @code{long _Fract},
1186 @code{long long _Fract},
1187 @code{unsigned short _Fract},
1188 @code{unsigned _Fract},
1189 @code{unsigned long _Fract},
1190 @code{unsigned long long _Fract},
1191 @code{_Sat short _Fract},
1192 @code{_Sat _Fract},
1193 @code{_Sat long _Fract},
1194 @code{_Sat long long _Fract},
1195 @code{_Sat unsigned short _Fract},
1196 @code{_Sat unsigned _Fract},
1197 @code{_Sat unsigned long _Fract},
1198 @code{_Sat unsigned long long _Fract},
1199 @code{short _Accum},
1200 @code{_Accum},
1201 @code{long _Accum},
1202 @code{long long _Accum},
1203 @code{unsigned short _Accum},
1204 @code{unsigned _Accum},
1205 @code{unsigned long _Accum},
1206 @code{unsigned long long _Accum},
1207 @code{_Sat short _Accum},
1208 @code{_Sat _Accum},
1209 @code{_Sat long _Accum},
1210 @code{_Sat long long _Accum},
1211 @code{_Sat unsigned short _Accum},
1212 @code{_Sat unsigned _Accum},
1213 @code{_Sat unsigned long _Accum},
1214 @code{_Sat unsigned long long _Accum}.
1215
1216 Fixed-point data values contain fractional and optional integral parts.
1217 The format of fixed-point data varies and depends on the target machine.
1218
1219 Support for fixed-point types includes:
1220 @itemize @bullet
1221 @item
1222 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1223 @item
1224 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1225 @item
1226 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1227 @item
1228 binary shift operators (@code{<<}, @code{>>})
1229 @item
1230 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1231 @item
1232 equality operators (@code{==}, @code{!=})
1233 @item
1234 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1235 @code{<<=}, @code{>>=})
1236 @item
1237 conversions to and from integer, floating-point, or fixed-point types
1238 @end itemize
1239
1240 Use a suffix in a fixed-point literal constant:
1241 @itemize
1242 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1243 @code{_Sat short _Fract}
1244 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1245 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1246 @code{_Sat long _Fract}
1247 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1248 @code{_Sat long long _Fract}
1249 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1250 @code{_Sat unsigned short _Fract}
1251 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1252 @code{_Sat unsigned _Fract}
1253 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1254 @code{_Sat unsigned long _Fract}
1255 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1256 and @code{_Sat unsigned long long _Fract}
1257 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1258 @code{_Sat short _Accum}
1259 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1260 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1261 @code{_Sat long _Accum}
1262 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1263 @code{_Sat long long _Accum}
1264 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1265 @code{_Sat unsigned short _Accum}
1266 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1267 @code{_Sat unsigned _Accum}
1268 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1269 @code{_Sat unsigned long _Accum}
1270 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1271 and @code{_Sat unsigned long long _Accum}
1272 @end itemize
1273
1274 GCC support of fixed-point types as specified by the draft technical report
1275 is incomplete:
1276
1277 @itemize @bullet
1278 @item
1279 Pragmas to control overflow and rounding behaviors are not implemented.
1280 @end itemize
1281
1282 Fixed-point types are supported by the DWARF debug information format.
1283
1284 @node Named Address Spaces
1285 @section Named Address Spaces
1286 @cindex Named Address Spaces
1287
1288 As an extension, GNU C supports named address spaces as
1289 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1290 address spaces in GCC will evolve as the draft technical report
1291 changes. Calling conventions for any target might also change. At
1292 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1293 address spaces other than the generic address space.
1294
1295 Address space identifiers may be used exactly like any other C type
1296 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1297 document for more details.
1298
1299 @anchor{AVR Named Address Spaces}
1300 @subsection AVR Named Address Spaces
1301
1302 On the AVR target, there are several address spaces that can be used
1303 in order to put read-only data into the flash memory and access that
1304 data by means of the special instructions @code{LPM} or @code{ELPM}
1305 needed to read from flash.
1306
1307 Per default, any data including read-only data is located in RAM
1308 (the generic address space) so that non-generic address spaces are
1309 needed to locate read-only data in flash memory
1310 @emph{and} to generate the right instructions to access this data
1311 without using (inline) assembler code.
1312
1313 @table @code
1314 @item __flash
1315 @cindex @code{__flash} AVR Named Address Spaces
1316 The @code{__flash} qualifier locates data in the
1317 @code{.progmem.data} section. Data is read using the @code{LPM}
1318 instruction. Pointers to this address space are 16 bits wide.
1319
1320 @item __flash1
1321 @itemx __flash2
1322 @itemx __flash3
1323 @itemx __flash4
1324 @itemx __flash5
1325 @cindex @code{__flash1} AVR Named Address Spaces
1326 @cindex @code{__flash2} AVR Named Address Spaces
1327 @cindex @code{__flash3} AVR Named Address Spaces
1328 @cindex @code{__flash4} AVR Named Address Spaces
1329 @cindex @code{__flash5} AVR Named Address Spaces
1330 These are 16-bit address spaces locating data in section
1331 @code{.progmem@var{N}.data} where @var{N} refers to
1332 address space @code{__flash@var{N}}.
1333 The compiler sets the @code{RAMPZ} segment register appropriately
1334 before reading data by means of the @code{ELPM} instruction.
1335
1336 @item __memx
1337 @cindex @code{__memx} AVR Named Address Spaces
1338 This is a 24-bit address space that linearizes flash and RAM:
1339 If the high bit of the address is set, data is read from
1340 RAM using the lower two bytes as RAM address.
1341 If the high bit of the address is clear, data is read from flash
1342 with @code{RAMPZ} set according to the high byte of the address.
1343 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1344
1345 Objects in this address space are located in @code{.progmemx.data}.
1346 @end table
1347
1348 @b{Example}
1349
1350 @smallexample
1351 char my_read (const __flash char ** p)
1352 @{
1353 /* p is a pointer to RAM that points to a pointer to flash.
1354 The first indirection of p reads that flash pointer
1355 from RAM and the second indirection reads a char from this
1356 flash address. */
1357
1358 return **p;
1359 @}
1360
1361 /* Locate array[] in flash memory */
1362 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1363
1364 int i = 1;
1365
1366 int main (void)
1367 @{
1368 /* Return 17 by reading from flash memory */
1369 return array[array[i]];
1370 @}
1371 @end smallexample
1372
1373 @noindent
1374 For each named address space supported by avr-gcc there is an equally
1375 named but uppercase built-in macro defined.
1376 The purpose is to facilitate testing if respective address space
1377 support is available or not:
1378
1379 @smallexample
1380 #ifdef __FLASH
1381 const __flash int var = 1;
1382
1383 int read_var (void)
1384 @{
1385 return var;
1386 @}
1387 #else
1388 #include <avr/pgmspace.h> /* From AVR-LibC */
1389
1390 const int var PROGMEM = 1;
1391
1392 int read_var (void)
1393 @{
1394 return (int) pgm_read_word (&var);
1395 @}
1396 #endif /* __FLASH */
1397 @end smallexample
1398
1399 @noindent
1400 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1401 locates data in flash but
1402 accesses to these data read from generic address space, i.e.@:
1403 from RAM,
1404 so that you need special accessors like @code{pgm_read_byte}
1405 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1406 together with attribute @code{progmem}.
1407
1408 @noindent
1409 @b{Limitations and caveats}
1410
1411 @itemize
1412 @item
1413 Reading across the 64@tie{}KiB section boundary of
1414 the @code{__flash} or @code{__flash@var{N}} address spaces
1415 shows undefined behavior. The only address space that
1416 supports reading across the 64@tie{}KiB flash segment boundaries is
1417 @code{__memx}.
1418
1419 @item
1420 If you use one of the @code{__flash@var{N}} address spaces
1421 you must arrange your linker script to locate the
1422 @code{.progmem@var{N}.data} sections according to your needs.
1423
1424 @item
1425 Any data or pointers to the non-generic address spaces must
1426 be qualified as @code{const}, i.e.@: as read-only data.
1427 This still applies if the data in one of these address
1428 spaces like software version number or calibration lookup table are intended to
1429 be changed after load time by, say, a boot loader. In this case
1430 the right qualification is @code{const} @code{volatile} so that the compiler
1431 must not optimize away known values or insert them
1432 as immediates into operands of instructions.
1433
1434 @item
1435 The following code initializes a variable @code{pfoo}
1436 located in static storage with a 24-bit address:
1437 @smallexample
1438 extern const __memx char foo;
1439 const __memx void *pfoo = &foo;
1440 @end smallexample
1441
1442 @noindent
1443 Such code requires at least binutils 2.23, see
1444 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1445
1446 @item
1447 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1448 Data can be put into and read from flash memory by means of
1449 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1450
1451 @end itemize
1452
1453 @subsection M32C Named Address Spaces
1454 @cindex @code{__far} M32C Named Address Spaces
1455
1456 On the M32C target, with the R8C and M16C CPU variants, variables
1457 qualified with @code{__far} are accessed using 32-bit addresses in
1458 order to access memory beyond the first 64@tie{}Ki bytes. If
1459 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1460 effect.
1461
1462 @subsection RL78 Named Address Spaces
1463 @cindex @code{__far} RL78 Named Address Spaces
1464
1465 On the RL78 target, variables qualified with @code{__far} are accessed
1466 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1467 addresses. Non-far variables are assumed to appear in the topmost
1468 64@tie{}KiB of the address space.
1469
1470 @subsection SPU Named Address Spaces
1471 @cindex @code{__ea} SPU Named Address Spaces
1472
1473 On the SPU target variables may be declared as
1474 belonging to another address space by qualifying the type with the
1475 @code{__ea} address space identifier:
1476
1477 @smallexample
1478 extern int __ea i;
1479 @end smallexample
1480
1481 @noindent
1482 The compiler generates special code to access the variable @code{i}.
1483 It may use runtime library
1484 support, or generate special machine instructions to access that address
1485 space.
1486
1487 @subsection x86 Named Address Spaces
1488 @cindex x86 named address spaces
1489
1490 On the x86 target, variables may be declared as being relative
1491 to the @code{%fs} or @code{%gs} segments.
1492
1493 @table @code
1494 @item __seg_fs
1495 @itemx __seg_gs
1496 @cindex @code{__seg_fs} x86 named address space
1497 @cindex @code{__seg_gs} x86 named address space
1498 The object is accessed with the respective segment override prefix.
1499
1500 The respective segment base must be set via some method specific to
1501 the operating system. Rather than require an expensive system call
1502 to retrieve the segment base, these address spaces are not considered
1503 to be subspaces of the generic (flat) address space. This means that
1504 explicit casts are required to convert pointers between these address
1505 spaces and the generic address space. In practice the application
1506 should cast to @code{uintptr_t} and apply the segment base offset
1507 that it installed previously.
1508
1509 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1510 defined when these address spaces are supported.
1511 @end table
1512
1513 @node Zero Length
1514 @section Arrays of Length Zero
1515 @cindex arrays of length zero
1516 @cindex zero-length arrays
1517 @cindex length-zero arrays
1518 @cindex flexible array members
1519
1520 Zero-length arrays are allowed in GNU C@. They are very useful as the
1521 last element of a structure that is really a header for a variable-length
1522 object:
1523
1524 @smallexample
1525 struct line @{
1526 int length;
1527 char contents[0];
1528 @};
1529
1530 struct line *thisline = (struct line *)
1531 malloc (sizeof (struct line) + this_length);
1532 thisline->length = this_length;
1533 @end smallexample
1534
1535 In ISO C90, you would have to give @code{contents} a length of 1, which
1536 means either you waste space or complicate the argument to @code{malloc}.
1537
1538 In ISO C99, you would use a @dfn{flexible array member}, which is
1539 slightly different in syntax and semantics:
1540
1541 @itemize @bullet
1542 @item
1543 Flexible array members are written as @code{contents[]} without
1544 the @code{0}.
1545
1546 @item
1547 Flexible array members have incomplete type, and so the @code{sizeof}
1548 operator may not be applied. As a quirk of the original implementation
1549 of zero-length arrays, @code{sizeof} evaluates to zero.
1550
1551 @item
1552 Flexible array members may only appear as the last member of a
1553 @code{struct} that is otherwise non-empty.
1554
1555 @item
1556 A structure containing a flexible array member, or a union containing
1557 such a structure (possibly recursively), may not be a member of a
1558 structure or an element of an array. (However, these uses are
1559 permitted by GCC as extensions.)
1560 @end itemize
1561
1562 Non-empty initialization of zero-length
1563 arrays is treated like any case where there are more initializer
1564 elements than the array holds, in that a suitable warning about ``excess
1565 elements in array'' is given, and the excess elements (all of them, in
1566 this case) are ignored.
1567
1568 GCC allows static initialization of flexible array members.
1569 This is equivalent to defining a new structure containing the original
1570 structure followed by an array of sufficient size to contain the data.
1571 E.g.@: in the following, @code{f1} is constructed as if it were declared
1572 like @code{f2}.
1573
1574 @smallexample
1575 struct f1 @{
1576 int x; int y[];
1577 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1578
1579 struct f2 @{
1580 struct f1 f1; int data[3];
1581 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1582 @end smallexample
1583
1584 @noindent
1585 The convenience of this extension is that @code{f1} has the desired
1586 type, eliminating the need to consistently refer to @code{f2.f1}.
1587
1588 This has symmetry with normal static arrays, in that an array of
1589 unknown size is also written with @code{[]}.
1590
1591 Of course, this extension only makes sense if the extra data comes at
1592 the end of a top-level object, as otherwise we would be overwriting
1593 data at subsequent offsets. To avoid undue complication and confusion
1594 with initialization of deeply nested arrays, we simply disallow any
1595 non-empty initialization except when the structure is the top-level
1596 object. For example:
1597
1598 @smallexample
1599 struct foo @{ int x; int y[]; @};
1600 struct bar @{ struct foo z; @};
1601
1602 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1603 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1604 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1605 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1606 @end smallexample
1607
1608 @node Empty Structures
1609 @section Structures with No Members
1610 @cindex empty structures
1611 @cindex zero-size structures
1612
1613 GCC permits a C structure to have no members:
1614
1615 @smallexample
1616 struct empty @{
1617 @};
1618 @end smallexample
1619
1620 The structure has size zero. In C++, empty structures are part
1621 of the language. G++ treats empty structures as if they had a single
1622 member of type @code{char}.
1623
1624 @node Variable Length
1625 @section Arrays of Variable Length
1626 @cindex variable-length arrays
1627 @cindex arrays of variable length
1628 @cindex VLAs
1629
1630 Variable-length automatic arrays are allowed in ISO C99, and as an
1631 extension GCC accepts them in C90 mode and in C++. These arrays are
1632 declared like any other automatic arrays, but with a length that is not
1633 a constant expression. The storage is allocated at the point of
1634 declaration and deallocated when the block scope containing the declaration
1635 exits. For
1636 example:
1637
1638 @smallexample
1639 FILE *
1640 concat_fopen (char *s1, char *s2, char *mode)
1641 @{
1642 char str[strlen (s1) + strlen (s2) + 1];
1643 strcpy (str, s1);
1644 strcat (str, s2);
1645 return fopen (str, mode);
1646 @}
1647 @end smallexample
1648
1649 @cindex scope of a variable length array
1650 @cindex variable-length array scope
1651 @cindex deallocating variable length arrays
1652 Jumping or breaking out of the scope of the array name deallocates the
1653 storage. Jumping into the scope is not allowed; you get an error
1654 message for it.
1655
1656 @cindex variable-length array in a structure
1657 As an extension, GCC accepts variable-length arrays as a member of
1658 a structure or a union. For example:
1659
1660 @smallexample
1661 void
1662 foo (int n)
1663 @{
1664 struct S @{ int x[n]; @};
1665 @}
1666 @end smallexample
1667
1668 @cindex @code{alloca} vs variable-length arrays
1669 You can use the function @code{alloca} to get an effect much like
1670 variable-length arrays. The function @code{alloca} is available in
1671 many other C implementations (but not in all). On the other hand,
1672 variable-length arrays are more elegant.
1673
1674 There are other differences between these two methods. Space allocated
1675 with @code{alloca} exists until the containing @emph{function} returns.
1676 The space for a variable-length array is deallocated as soon as the array
1677 name's scope ends, unless you also use @code{alloca} in this scope.
1678
1679 You can also use variable-length arrays as arguments to functions:
1680
1681 @smallexample
1682 struct entry
1683 tester (int len, char data[len][len])
1684 @{
1685 /* @r{@dots{}} */
1686 @}
1687 @end smallexample
1688
1689 The length of an array is computed once when the storage is allocated
1690 and is remembered for the scope of the array in case you access it with
1691 @code{sizeof}.
1692
1693 If you want to pass the array first and the length afterward, you can
1694 use a forward declaration in the parameter list---another GNU extension.
1695
1696 @smallexample
1697 struct entry
1698 tester (int len; char data[len][len], int len)
1699 @{
1700 /* @r{@dots{}} */
1701 @}
1702 @end smallexample
1703
1704 @cindex parameter forward declaration
1705 The @samp{int len} before the semicolon is a @dfn{parameter forward
1706 declaration}, and it serves the purpose of making the name @code{len}
1707 known when the declaration of @code{data} is parsed.
1708
1709 You can write any number of such parameter forward declarations in the
1710 parameter list. They can be separated by commas or semicolons, but the
1711 last one must end with a semicolon, which is followed by the ``real''
1712 parameter declarations. Each forward declaration must match a ``real''
1713 declaration in parameter name and data type. ISO C99 does not support
1714 parameter forward declarations.
1715
1716 @node Variadic Macros
1717 @section Macros with a Variable Number of Arguments.
1718 @cindex variable number of arguments
1719 @cindex macro with variable arguments
1720 @cindex rest argument (in macro)
1721 @cindex variadic macros
1722
1723 In the ISO C standard of 1999, a macro can be declared to accept a
1724 variable number of arguments much as a function can. The syntax for
1725 defining the macro is similar to that of a function. Here is an
1726 example:
1727
1728 @smallexample
1729 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1730 @end smallexample
1731
1732 @noindent
1733 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1734 such a macro, it represents the zero or more tokens until the closing
1735 parenthesis that ends the invocation, including any commas. This set of
1736 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1737 wherever it appears. See the CPP manual for more information.
1738
1739 GCC has long supported variadic macros, and used a different syntax that
1740 allowed you to give a name to the variable arguments just like any other
1741 argument. Here is an example:
1742
1743 @smallexample
1744 #define debug(format, args...) fprintf (stderr, format, args)
1745 @end smallexample
1746
1747 @noindent
1748 This is in all ways equivalent to the ISO C example above, but arguably
1749 more readable and descriptive.
1750
1751 GNU CPP has two further variadic macro extensions, and permits them to
1752 be used with either of the above forms of macro definition.
1753
1754 In standard C, you are not allowed to leave the variable argument out
1755 entirely; but you are allowed to pass an empty argument. For example,
1756 this invocation is invalid in ISO C, because there is no comma after
1757 the string:
1758
1759 @smallexample
1760 debug ("A message")
1761 @end smallexample
1762
1763 GNU CPP permits you to completely omit the variable arguments in this
1764 way. In the above examples, the compiler would complain, though since
1765 the expansion of the macro still has the extra comma after the format
1766 string.
1767
1768 To help solve this problem, CPP behaves specially for variable arguments
1769 used with the token paste operator, @samp{##}. If instead you write
1770
1771 @smallexample
1772 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1773 @end smallexample
1774
1775 @noindent
1776 and if the variable arguments are omitted or empty, the @samp{##}
1777 operator causes the preprocessor to remove the comma before it. If you
1778 do provide some variable arguments in your macro invocation, GNU CPP
1779 does not complain about the paste operation and instead places the
1780 variable arguments after the comma. Just like any other pasted macro
1781 argument, these arguments are not macro expanded.
1782
1783 @node Escaped Newlines
1784 @section Slightly Looser Rules for Escaped Newlines
1785 @cindex escaped newlines
1786 @cindex newlines (escaped)
1787
1788 The preprocessor treatment of escaped newlines is more relaxed
1789 than that specified by the C90 standard, which requires the newline
1790 to immediately follow a backslash.
1791 GCC's implementation allows whitespace in the form
1792 of spaces, horizontal and vertical tabs, and form feeds between the
1793 backslash and the subsequent newline. The preprocessor issues a
1794 warning, but treats it as a valid escaped newline and combines the two
1795 lines to form a single logical line. This works within comments and
1796 tokens, as well as between tokens. Comments are @emph{not} treated as
1797 whitespace for the purposes of this relaxation, since they have not
1798 yet been replaced with spaces.
1799
1800 @node Subscripting
1801 @section Non-Lvalue Arrays May Have Subscripts
1802 @cindex subscripting
1803 @cindex arrays, non-lvalue
1804
1805 @cindex subscripting and function values
1806 In ISO C99, arrays that are not lvalues still decay to pointers, and
1807 may be subscripted, although they may not be modified or used after
1808 the next sequence point and the unary @samp{&} operator may not be
1809 applied to them. As an extension, GNU C allows such arrays to be
1810 subscripted in C90 mode, though otherwise they do not decay to
1811 pointers outside C99 mode. For example,
1812 this is valid in GNU C though not valid in C90:
1813
1814 @smallexample
1815 @group
1816 struct foo @{int a[4];@};
1817
1818 struct foo f();
1819
1820 bar (int index)
1821 @{
1822 return f().a[index];
1823 @}
1824 @end group
1825 @end smallexample
1826
1827 @node Pointer Arith
1828 @section Arithmetic on @code{void}- and Function-Pointers
1829 @cindex void pointers, arithmetic
1830 @cindex void, size of pointer to
1831 @cindex function pointers, arithmetic
1832 @cindex function, size of pointer to
1833
1834 In GNU C, addition and subtraction operations are supported on pointers to
1835 @code{void} and on pointers to functions. This is done by treating the
1836 size of a @code{void} or of a function as 1.
1837
1838 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1839 and on function types, and returns 1.
1840
1841 @opindex Wpointer-arith
1842 The option @option{-Wpointer-arith} requests a warning if these extensions
1843 are used.
1844
1845 @node Pointers to Arrays
1846 @section Pointers to Arrays with Qualifiers Work as Expected
1847 @cindex pointers to arrays
1848 @cindex const qualifier
1849
1850 In GNU C, pointers to arrays with qualifiers work similar to pointers
1851 to other qualified types. For example, a value of type @code{int (*)[5]}
1852 can be used to initialize a variable of type @code{const int (*)[5]}.
1853 These types are incompatible in ISO C because the @code{const} qualifier
1854 is formally attached to the element type of the array and not the
1855 array itself.
1856
1857 @smallexample
1858 extern void
1859 transpose (int N, int M, double out[M][N], const double in[N][M]);
1860 double x[3][2];
1861 double y[2][3];
1862 @r{@dots{}}
1863 transpose(3, 2, y, x);
1864 @end smallexample
1865
1866 @node Initializers
1867 @section Non-Constant Initializers
1868 @cindex initializers, non-constant
1869 @cindex non-constant initializers
1870
1871 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1872 automatic variable are not required to be constant expressions in GNU C@.
1873 Here is an example of an initializer with run-time varying elements:
1874
1875 @smallexample
1876 foo (float f, float g)
1877 @{
1878 float beat_freqs[2] = @{ f-g, f+g @};
1879 /* @r{@dots{}} */
1880 @}
1881 @end smallexample
1882
1883 @node Compound Literals
1884 @section Compound Literals
1885 @cindex constructor expressions
1886 @cindex initializations in expressions
1887 @cindex structures, constructor expression
1888 @cindex expressions, constructor
1889 @cindex compound literals
1890 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1891
1892 A compound literal looks like a cast of a brace-enclosed aggregate
1893 initializer list. Its value is an object of the type specified in
1894 the cast, containing the elements specified in the initializer.
1895 Unlike the result of a cast, a compound literal is an lvalue. ISO
1896 C99 and later support compound literals. As an extension, GCC
1897 supports compound literals also in C90 mode and in C++, although
1898 as explained below, the C++ semantics are somewhat different.
1899
1900 Usually, the specified type of a compound literal is a structure. Assume
1901 that @code{struct foo} and @code{structure} are declared as shown:
1902
1903 @smallexample
1904 struct foo @{int a; char b[2];@} structure;
1905 @end smallexample
1906
1907 @noindent
1908 Here is an example of constructing a @code{struct foo} with a compound literal:
1909
1910 @smallexample
1911 structure = ((struct foo) @{x + y, 'a', 0@});
1912 @end smallexample
1913
1914 @noindent
1915 This is equivalent to writing the following:
1916
1917 @smallexample
1918 @{
1919 struct foo temp = @{x + y, 'a', 0@};
1920 structure = temp;
1921 @}
1922 @end smallexample
1923
1924 You can also construct an array, though this is dangerous in C++, as
1925 explained below. If all the elements of the compound literal are
1926 (made up of) simple constant expressions suitable for use in
1927 initializers of objects of static storage duration, then the compound
1928 literal can be coerced to a pointer to its first element and used in
1929 such an initializer, as shown here:
1930
1931 @smallexample
1932 char **foo = (char *[]) @{ "x", "y", "z" @};
1933 @end smallexample
1934
1935 Compound literals for scalar types and union types are also allowed. In
1936 the following example the variable @code{i} is initialized to the value
1937 @code{2}, the result of incrementing the unnamed object created by
1938 the compound literal.
1939
1940 @smallexample
1941 int i = ++(int) @{ 1 @};
1942 @end smallexample
1943
1944 As a GNU extension, GCC allows initialization of objects with static storage
1945 duration by compound literals (which is not possible in ISO C99 because
1946 the initializer is not a constant).
1947 It is handled as if the object were initialized only with the brace-enclosed
1948 list if the types of the compound literal and the object match.
1949 The elements of the compound literal must be constant.
1950 If the object being initialized has array type of unknown size, the size is
1951 determined by the size of the compound literal.
1952
1953 @smallexample
1954 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1955 static int y[] = (int []) @{1, 2, 3@};
1956 static int z[] = (int [3]) @{1@};
1957 @end smallexample
1958
1959 @noindent
1960 The above lines are equivalent to the following:
1961 @smallexample
1962 static struct foo x = @{1, 'a', 'b'@};
1963 static int y[] = @{1, 2, 3@};
1964 static int z[] = @{1, 0, 0@};
1965 @end smallexample
1966
1967 In C, a compound literal designates an unnamed object with static or
1968 automatic storage duration. In C++, a compound literal designates a
1969 temporary object that only lives until the end of its full-expression.
1970 As a result, well-defined C code that takes the address of a subobject
1971 of a compound literal can be undefined in C++, so G++ rejects
1972 the conversion of a temporary array to a pointer. For instance, if
1973 the array compound literal example above appeared inside a function,
1974 any subsequent use of @code{foo} in C++ would have undefined behavior
1975 because the lifetime of the array ends after the declaration of @code{foo}.
1976
1977 As an optimization, G++ sometimes gives array compound literals longer
1978 lifetimes: when the array either appears outside a function or has
1979 a @code{const}-qualified type. If @code{foo} and its initializer had
1980 elements of type @code{char *const} rather than @code{char *}, or if
1981 @code{foo} were a global variable, the array would have static storage
1982 duration. But it is probably safest just to avoid the use of array
1983 compound literals in C++ code.
1984
1985 @node Designated Inits
1986 @section Designated Initializers
1987 @cindex initializers with labeled elements
1988 @cindex labeled elements in initializers
1989 @cindex case labels in initializers
1990 @cindex designated initializers
1991
1992 Standard C90 requires the elements of an initializer to appear in a fixed
1993 order, the same as the order of the elements in the array or structure
1994 being initialized.
1995
1996 In ISO C99 you can give the elements in any order, specifying the array
1997 indices or structure field names they apply to, and GNU C allows this as
1998 an extension in C90 mode as well. This extension is not
1999 implemented in GNU C++.
2000
2001 To specify an array index, write
2002 @samp{[@var{index}] =} before the element value. For example,
2003
2004 @smallexample
2005 int a[6] = @{ [4] = 29, [2] = 15 @};
2006 @end smallexample
2007
2008 @noindent
2009 is equivalent to
2010
2011 @smallexample
2012 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2013 @end smallexample
2014
2015 @noindent
2016 The index values must be constant expressions, even if the array being
2017 initialized is automatic.
2018
2019 An alternative syntax for this that has been obsolete since GCC 2.5 but
2020 GCC still accepts is to write @samp{[@var{index}]} before the element
2021 value, with no @samp{=}.
2022
2023 To initialize a range of elements to the same value, write
2024 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2025 extension. For example,
2026
2027 @smallexample
2028 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2029 @end smallexample
2030
2031 @noindent
2032 If the value in it has side-effects, the side-effects happen only once,
2033 not for each initialized field by the range initializer.
2034
2035 @noindent
2036 Note that the length of the array is the highest value specified
2037 plus one.
2038
2039 In a structure initializer, specify the name of a field to initialize
2040 with @samp{.@var{fieldname} =} before the element value. For example,
2041 given the following structure,
2042
2043 @smallexample
2044 struct point @{ int x, y; @};
2045 @end smallexample
2046
2047 @noindent
2048 the following initialization
2049
2050 @smallexample
2051 struct point p = @{ .y = yvalue, .x = xvalue @};
2052 @end smallexample
2053
2054 @noindent
2055 is equivalent to
2056
2057 @smallexample
2058 struct point p = @{ xvalue, yvalue @};
2059 @end smallexample
2060
2061 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2062 @samp{@var{fieldname}:}, as shown here:
2063
2064 @smallexample
2065 struct point p = @{ y: yvalue, x: xvalue @};
2066 @end smallexample
2067
2068 Omitted field members are implicitly initialized the same as objects
2069 that have static storage duration.
2070
2071 @cindex designators
2072 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2073 @dfn{designator}. You can also use a designator (or the obsolete colon
2074 syntax) when initializing a union, to specify which element of the union
2075 should be used. For example,
2076
2077 @smallexample
2078 union foo @{ int i; double d; @};
2079
2080 union foo f = @{ .d = 4 @};
2081 @end smallexample
2082
2083 @noindent
2084 converts 4 to a @code{double} to store it in the union using
2085 the second element. By contrast, casting 4 to type @code{union foo}
2086 stores it into the union as the integer @code{i}, since it is
2087 an integer. (@xref{Cast to Union}.)
2088
2089 You can combine this technique of naming elements with ordinary C
2090 initialization of successive elements. Each initializer element that
2091 does not have a designator applies to the next consecutive element of the
2092 array or structure. For example,
2093
2094 @smallexample
2095 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2096 @end smallexample
2097
2098 @noindent
2099 is equivalent to
2100
2101 @smallexample
2102 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2103 @end smallexample
2104
2105 Labeling the elements of an array initializer is especially useful
2106 when the indices are characters or belong to an @code{enum} type.
2107 For example:
2108
2109 @smallexample
2110 int whitespace[256]
2111 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2112 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2113 @end smallexample
2114
2115 @cindex designator lists
2116 You can also write a series of @samp{.@var{fieldname}} and
2117 @samp{[@var{index}]} designators before an @samp{=} to specify a
2118 nested subobject to initialize; the list is taken relative to the
2119 subobject corresponding to the closest surrounding brace pair. For
2120 example, with the @samp{struct point} declaration above:
2121
2122 @smallexample
2123 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2124 @end smallexample
2125
2126 @noindent
2127 If the same field is initialized multiple times, it has the value from
2128 the last initialization. If any such overridden initialization has
2129 side-effect, it is unspecified whether the side-effect happens or not.
2130 Currently, GCC discards them and issues a warning.
2131
2132 @node Case Ranges
2133 @section Case Ranges
2134 @cindex case ranges
2135 @cindex ranges in case statements
2136
2137 You can specify a range of consecutive values in a single @code{case} label,
2138 like this:
2139
2140 @smallexample
2141 case @var{low} ... @var{high}:
2142 @end smallexample
2143
2144 @noindent
2145 This has the same effect as the proper number of individual @code{case}
2146 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2147
2148 This feature is especially useful for ranges of ASCII character codes:
2149
2150 @smallexample
2151 case 'A' ... 'Z':
2152 @end smallexample
2153
2154 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2155 it may be parsed wrong when you use it with integer values. For example,
2156 write this:
2157
2158 @smallexample
2159 case 1 ... 5:
2160 @end smallexample
2161
2162 @noindent
2163 rather than this:
2164
2165 @smallexample
2166 case 1...5:
2167 @end smallexample
2168
2169 @node Cast to Union
2170 @section Cast to a Union Type
2171 @cindex cast to a union
2172 @cindex union, casting to a
2173
2174 A cast to union type looks similar to other casts, except that the type
2175 specified is a union type. You can specify the type either with the
2176 @code{union} keyword or with a @code{typedef} name that refers to
2177 a union. A cast to a union actually creates a compound literal and
2178 yields an lvalue, not an rvalue like true casts do.
2179 (@xref{Compound Literals}.)
2180
2181 The types that may be cast to the union type are those of the members
2182 of the union. Thus, given the following union and variables:
2183
2184 @smallexample
2185 union foo @{ int i; double d; @};
2186 int x;
2187 double y;
2188 @end smallexample
2189
2190 @noindent
2191 both @code{x} and @code{y} can be cast to type @code{union foo}.
2192
2193 Using the cast as the right-hand side of an assignment to a variable of
2194 union type is equivalent to storing in a member of the union:
2195
2196 @smallexample
2197 union foo u;
2198 /* @r{@dots{}} */
2199 u = (union foo) x @equiv{} u.i = x
2200 u = (union foo) y @equiv{} u.d = y
2201 @end smallexample
2202
2203 You can also use the union cast as a function argument:
2204
2205 @smallexample
2206 void hack (union foo);
2207 /* @r{@dots{}} */
2208 hack ((union foo) x);
2209 @end smallexample
2210
2211 @node Mixed Declarations
2212 @section Mixed Declarations and Code
2213 @cindex mixed declarations and code
2214 @cindex declarations, mixed with code
2215 @cindex code, mixed with declarations
2216
2217 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2218 within compound statements. As an extension, GNU C also allows this in
2219 C90 mode. For example, you could do:
2220
2221 @smallexample
2222 int i;
2223 /* @r{@dots{}} */
2224 i++;
2225 int j = i + 2;
2226 @end smallexample
2227
2228 Each identifier is visible from where it is declared until the end of
2229 the enclosing block.
2230
2231 @node Function Attributes
2232 @section Declaring Attributes of Functions
2233 @cindex function attributes
2234 @cindex declaring attributes of functions
2235 @cindex @code{volatile} applied to function
2236 @cindex @code{const} applied to function
2237
2238 In GNU C, you can use function attributes to declare certain things
2239 about functions called in your program which help the compiler
2240 optimize calls and check your code more carefully. For example, you
2241 can use attributes to declare that a function never returns
2242 (@code{noreturn}), returns a value depending only on its arguments
2243 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2244
2245 You can also use attributes to control memory placement, code
2246 generation options or call/return conventions within the function
2247 being annotated. Many of these attributes are target-specific. For
2248 example, many targets support attributes for defining interrupt
2249 handler functions, which typically must follow special register usage
2250 and return conventions.
2251
2252 Function attributes are introduced by the @code{__attribute__} keyword
2253 on a declaration, followed by an attribute specification inside double
2254 parentheses. You can specify multiple attributes in a declaration by
2255 separating them by commas within the double parentheses or by
2256 immediately following an attribute declaration with another attribute
2257 declaration. @xref{Attribute Syntax}, for the exact rules on
2258 attribute syntax and placement.
2259
2260 GCC also supports attributes on
2261 variable declarations (@pxref{Variable Attributes}),
2262 labels (@pxref{Label Attributes}),
2263 enumerators (@pxref{Enumerator Attributes}),
2264 and types (@pxref{Type Attributes}).
2265
2266 There is some overlap between the purposes of attributes and pragmas
2267 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2268 found convenient to use @code{__attribute__} to achieve a natural
2269 attachment of attributes to their corresponding declarations, whereas
2270 @code{#pragma} is of use for compatibility with other compilers
2271 or constructs that do not naturally form part of the grammar.
2272
2273 In addition to the attributes documented here,
2274 GCC plugins may provide their own attributes.
2275
2276 @menu
2277 * Common Function Attributes::
2278 * AArch64 Function Attributes::
2279 * ARC Function Attributes::
2280 * ARM Function Attributes::
2281 * AVR Function Attributes::
2282 * Blackfin Function Attributes::
2283 * CR16 Function Attributes::
2284 * Epiphany Function Attributes::
2285 * H8/300 Function Attributes::
2286 * IA-64 Function Attributes::
2287 * M32C Function Attributes::
2288 * M32R/D Function Attributes::
2289 * m68k Function Attributes::
2290 * MCORE Function Attributes::
2291 * MeP Function Attributes::
2292 * MicroBlaze Function Attributes::
2293 * Microsoft Windows Function Attributes::
2294 * MIPS Function Attributes::
2295 * MSP430 Function Attributes::
2296 * NDS32 Function Attributes::
2297 * Nios II Function Attributes::
2298 * Nvidia PTX Function Attributes::
2299 * PowerPC Function Attributes::
2300 * RL78 Function Attributes::
2301 * RX Function Attributes::
2302 * S/390 Function Attributes::
2303 * SH Function Attributes::
2304 * SPU Function Attributes::
2305 * Symbian OS Function Attributes::
2306 * V850 Function Attributes::
2307 * Visium Function Attributes::
2308 * x86 Function Attributes::
2309 * Xstormy16 Function Attributes::
2310 @end menu
2311
2312 @node Common Function Attributes
2313 @subsection Common Function Attributes
2314
2315 The following attributes are supported on most targets.
2316
2317 @table @code
2318 @c Keep this table alphabetized by attribute name. Treat _ as space.
2319
2320 @item alias ("@var{target}")
2321 @cindex @code{alias} function attribute
2322 The @code{alias} attribute causes the declaration to be emitted as an
2323 alias for another symbol, which must be specified. For instance,
2324
2325 @smallexample
2326 void __f () @{ /* @r{Do something.} */; @}
2327 void f () __attribute__ ((weak, alias ("__f")));
2328 @end smallexample
2329
2330 @noindent
2331 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2332 mangled name for the target must be used. It is an error if @samp{__f}
2333 is not defined in the same translation unit.
2334
2335 This attribute requires assembler and object file support,
2336 and may not be available on all targets.
2337
2338 @item aligned (@var{alignment})
2339 @cindex @code{aligned} function attribute
2340 This attribute specifies a minimum alignment for the function,
2341 measured in bytes.
2342
2343 You cannot use this attribute to decrease the alignment of a function,
2344 only to increase it. However, when you explicitly specify a function
2345 alignment this overrides the effect of the
2346 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2347 function.
2348
2349 Note that the effectiveness of @code{aligned} attributes may be
2350 limited by inherent limitations in your linker. On many systems, the
2351 linker is only able to arrange for functions to be aligned up to a
2352 certain maximum alignment. (For some linkers, the maximum supported
2353 alignment may be very very small.) See your linker documentation for
2354 further information.
2355
2356 The @code{aligned} attribute can also be used for variables and fields
2357 (@pxref{Variable Attributes}.)
2358
2359 @item alloc_align
2360 @cindex @code{alloc_align} function attribute
2361 The @code{alloc_align} attribute is used to tell the compiler that the
2362 function return value points to memory, where the returned pointer minimum
2363 alignment is given by one of the functions parameters. GCC uses this
2364 information to improve pointer alignment analysis.
2365
2366 The function parameter denoting the allocated alignment is specified by
2367 one integer argument, whose number is the argument of the attribute.
2368 Argument numbering starts at one.
2369
2370 For instance,
2371
2372 @smallexample
2373 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2374 @end smallexample
2375
2376 @noindent
2377 declares that @code{my_memalign} returns memory with minimum alignment
2378 given by parameter 1.
2379
2380 @item alloc_size
2381 @cindex @code{alloc_size} function attribute
2382 The @code{alloc_size} attribute is used to tell the compiler that the
2383 function return value points to memory, where the size is given by
2384 one or two of the functions parameters. GCC uses this
2385 information to improve the correctness of @code{__builtin_object_size}.
2386
2387 The function parameter(s) denoting the allocated size are specified by
2388 one or two integer arguments supplied to the attribute. The allocated size
2389 is either the value of the single function argument specified or the product
2390 of the two function arguments specified. Argument numbering starts at
2391 one.
2392
2393 For instance,
2394
2395 @smallexample
2396 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2397 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2398 @end smallexample
2399
2400 @noindent
2401 declares that @code{my_calloc} returns memory of the size given by
2402 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2403 of the size given by parameter 2.
2404
2405 @item always_inline
2406 @cindex @code{always_inline} function attribute
2407 Generally, functions are not inlined unless optimization is specified.
2408 For functions declared inline, this attribute inlines the function
2409 independent of any restrictions that otherwise apply to inlining.
2410 Failure to inline such a function is diagnosed as an error.
2411 Note that if such a function is called indirectly the compiler may
2412 or may not inline it depending on optimization level and a failure
2413 to inline an indirect call may or may not be diagnosed.
2414
2415 @item artificial
2416 @cindex @code{artificial} function attribute
2417 This attribute is useful for small inline wrappers that if possible
2418 should appear during debugging as a unit. Depending on the debug
2419 info format it either means marking the function as artificial
2420 or using the caller location for all instructions within the inlined
2421 body.
2422
2423 @item assume_aligned
2424 @cindex @code{assume_aligned} function attribute
2425 The @code{assume_aligned} attribute is used to tell the compiler that the
2426 function return value points to memory, where the returned pointer minimum
2427 alignment is given by the first argument.
2428 If the attribute has two arguments, the second argument is misalignment offset.
2429
2430 For instance
2431
2432 @smallexample
2433 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2434 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2435 @end smallexample
2436
2437 @noindent
2438 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2439 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2440 to 8.
2441
2442 @item bnd_instrument
2443 @cindex @code{bnd_instrument} function attribute
2444 The @code{bnd_instrument} attribute on functions is used to inform the
2445 compiler that the function should be instrumented when compiled
2446 with the @option{-fchkp-instrument-marked-only} option.
2447
2448 @item bnd_legacy
2449 @cindex @code{bnd_legacy} function attribute
2450 @cindex Pointer Bounds Checker attributes
2451 The @code{bnd_legacy} attribute on functions is used to inform the
2452 compiler that the function should not be instrumented when compiled
2453 with the @option{-fcheck-pointer-bounds} option.
2454
2455 @item cold
2456 @cindex @code{cold} function attribute
2457 The @code{cold} attribute on functions is used to inform the compiler that
2458 the function is unlikely to be executed. The function is optimized for
2459 size rather than speed and on many targets it is placed into a special
2460 subsection of the text section so all cold functions appear close together,
2461 improving code locality of non-cold parts of program. The paths leading
2462 to calls of cold functions within code are marked as unlikely by the branch
2463 prediction mechanism. It is thus useful to mark functions used to handle
2464 unlikely conditions, such as @code{perror}, as cold to improve optimization
2465 of hot functions that do call marked functions in rare occasions.
2466
2467 When profile feedback is available, via @option{-fprofile-use}, cold functions
2468 are automatically detected and this attribute is ignored.
2469
2470 @item const
2471 @cindex @code{const} function attribute
2472 @cindex functions that have no side effects
2473 Many functions do not examine any values except their arguments, and
2474 have no effects except the return value. Basically this is just slightly
2475 more strict class than the @code{pure} attribute below, since function is not
2476 allowed to read global memory.
2477
2478 @cindex pointer arguments
2479 Note that a function that has pointer arguments and examines the data
2480 pointed to must @emph{not} be declared @code{const}. Likewise, a
2481 function that calls a non-@code{const} function usually must not be
2482 @code{const}. It does not make sense for a @code{const} function to
2483 return @code{void}.
2484
2485 @item constructor
2486 @itemx destructor
2487 @itemx constructor (@var{priority})
2488 @itemx destructor (@var{priority})
2489 @cindex @code{constructor} function attribute
2490 @cindex @code{destructor} function attribute
2491 The @code{constructor} attribute causes the function to be called
2492 automatically before execution enters @code{main ()}. Similarly, the
2493 @code{destructor} attribute causes the function to be called
2494 automatically after @code{main ()} completes or @code{exit ()} is
2495 called. Functions with these attributes are useful for
2496 initializing data that is used implicitly during the execution of
2497 the program.
2498
2499 You may provide an optional integer priority to control the order in
2500 which constructor and destructor functions are run. A constructor
2501 with a smaller priority number runs before a constructor with a larger
2502 priority number; the opposite relationship holds for destructors. So,
2503 if you have a constructor that allocates a resource and a destructor
2504 that deallocates the same resource, both functions typically have the
2505 same priority. The priorities for constructor and destructor
2506 functions are the same as those specified for namespace-scope C++
2507 objects (@pxref{C++ Attributes}).
2508
2509 These attributes are not currently implemented for Objective-C@.
2510
2511 @item deprecated
2512 @itemx deprecated (@var{msg})
2513 @cindex @code{deprecated} function attribute
2514 The @code{deprecated} attribute results in a warning if the function
2515 is used anywhere in the source file. This is useful when identifying
2516 functions that are expected to be removed in a future version of a
2517 program. The warning also includes the location of the declaration
2518 of the deprecated function, to enable users to easily find further
2519 information about why the function is deprecated, or what they should
2520 do instead. Note that the warnings only occurs for uses:
2521
2522 @smallexample
2523 int old_fn () __attribute__ ((deprecated));
2524 int old_fn ();
2525 int (*fn_ptr)() = old_fn;
2526 @end smallexample
2527
2528 @noindent
2529 results in a warning on line 3 but not line 2. The optional @var{msg}
2530 argument, which must be a string, is printed in the warning if
2531 present.
2532
2533 The @code{deprecated} attribute can also be used for variables and
2534 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2535
2536 @item error ("@var{message}")
2537 @itemx warning ("@var{message}")
2538 @cindex @code{error} function attribute
2539 @cindex @code{warning} function attribute
2540 If the @code{error} or @code{warning} attribute
2541 is used on a function declaration and a call to such a function
2542 is not eliminated through dead code elimination or other optimizations,
2543 an error or warning (respectively) that includes @var{message} is diagnosed.
2544 This is useful
2545 for compile-time checking, especially together with @code{__builtin_constant_p}
2546 and inline functions where checking the inline function arguments is not
2547 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2548
2549 While it is possible to leave the function undefined and thus invoke
2550 a link failure (to define the function with
2551 a message in @code{.gnu.warning*} section),
2552 when using these attributes the problem is diagnosed
2553 earlier and with exact location of the call even in presence of inline
2554 functions or when not emitting debugging information.
2555
2556 @item externally_visible
2557 @cindex @code{externally_visible} function attribute
2558 This attribute, attached to a global variable or function, nullifies
2559 the effect of the @option{-fwhole-program} command-line option, so the
2560 object remains visible outside the current compilation unit.
2561
2562 If @option{-fwhole-program} is used together with @option{-flto} and
2563 @command{gold} is used as the linker plugin,
2564 @code{externally_visible} attributes are automatically added to functions
2565 (not variable yet due to a current @command{gold} issue)
2566 that are accessed outside of LTO objects according to resolution file
2567 produced by @command{gold}.
2568 For other linkers that cannot generate resolution file,
2569 explicit @code{externally_visible} attributes are still necessary.
2570
2571 @item flatten
2572 @cindex @code{flatten} function attribute
2573 Generally, inlining into a function is limited. For a function marked with
2574 this attribute, every call inside this function is inlined, if possible.
2575 Whether the function itself is considered for inlining depends on its size and
2576 the current inlining parameters.
2577
2578 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2579 @cindex @code{format} function attribute
2580 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2581 @opindex Wformat
2582 The @code{format} attribute specifies that a function takes @code{printf},
2583 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2584 should be type-checked against a format string. For example, the
2585 declaration:
2586
2587 @smallexample
2588 extern int
2589 my_printf (void *my_object, const char *my_format, ...)
2590 __attribute__ ((format (printf, 2, 3)));
2591 @end smallexample
2592
2593 @noindent
2594 causes the compiler to check the arguments in calls to @code{my_printf}
2595 for consistency with the @code{printf} style format string argument
2596 @code{my_format}.
2597
2598 The parameter @var{archetype} determines how the format string is
2599 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2600 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2601 @code{strfmon}. (You can also use @code{__printf__},
2602 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2603 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2604 @code{ms_strftime} are also present.
2605 @var{archetype} values such as @code{printf} refer to the formats accepted
2606 by the system's C runtime library,
2607 while values prefixed with @samp{gnu_} always refer
2608 to the formats accepted by the GNU C Library. On Microsoft Windows
2609 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2610 @file{msvcrt.dll} library.
2611 The parameter @var{string-index}
2612 specifies which argument is the format string argument (starting
2613 from 1), while @var{first-to-check} is the number of the first
2614 argument to check against the format string. For functions
2615 where the arguments are not available to be checked (such as
2616 @code{vprintf}), specify the third parameter as zero. In this case the
2617 compiler only checks the format string for consistency. For
2618 @code{strftime} formats, the third parameter is required to be zero.
2619 Since non-static C++ methods have an implicit @code{this} argument, the
2620 arguments of such methods should be counted from two, not one, when
2621 giving values for @var{string-index} and @var{first-to-check}.
2622
2623 In the example above, the format string (@code{my_format}) is the second
2624 argument of the function @code{my_print}, and the arguments to check
2625 start with the third argument, so the correct parameters for the format
2626 attribute are 2 and 3.
2627
2628 @opindex ffreestanding
2629 @opindex fno-builtin
2630 The @code{format} attribute allows you to identify your own functions
2631 that take format strings as arguments, so that GCC can check the
2632 calls to these functions for errors. The compiler always (unless
2633 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2634 for the standard library functions @code{printf}, @code{fprintf},
2635 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2636 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2637 warnings are requested (using @option{-Wformat}), so there is no need to
2638 modify the header file @file{stdio.h}. In C99 mode, the functions
2639 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2640 @code{vsscanf} are also checked. Except in strictly conforming C
2641 standard modes, the X/Open function @code{strfmon} is also checked as
2642 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2643 @xref{C Dialect Options,,Options Controlling C Dialect}.
2644
2645 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2646 recognized in the same context. Declarations including these format attributes
2647 are parsed for correct syntax, however the result of checking of such format
2648 strings is not yet defined, and is not carried out by this version of the
2649 compiler.
2650
2651 The target may also provide additional types of format checks.
2652 @xref{Target Format Checks,,Format Checks Specific to Particular
2653 Target Machines}.
2654
2655 @item format_arg (@var{string-index})
2656 @cindex @code{format_arg} function attribute
2657 @opindex Wformat-nonliteral
2658 The @code{format_arg} attribute specifies that a function takes a format
2659 string for a @code{printf}, @code{scanf}, @code{strftime} or
2660 @code{strfmon} style function and modifies it (for example, to translate
2661 it into another language), so the result can be passed to a
2662 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2663 function (with the remaining arguments to the format function the same
2664 as they would have been for the unmodified string). For example, the
2665 declaration:
2666
2667 @smallexample
2668 extern char *
2669 my_dgettext (char *my_domain, const char *my_format)
2670 __attribute__ ((format_arg (2)));
2671 @end smallexample
2672
2673 @noindent
2674 causes the compiler to check the arguments in calls to a @code{printf},
2675 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2676 format string argument is a call to the @code{my_dgettext} function, for
2677 consistency with the format string argument @code{my_format}. If the
2678 @code{format_arg} attribute had not been specified, all the compiler
2679 could tell in such calls to format functions would be that the format
2680 string argument is not constant; this would generate a warning when
2681 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2682 without the attribute.
2683
2684 The parameter @var{string-index} specifies which argument is the format
2685 string argument (starting from one). Since non-static C++ methods have
2686 an implicit @code{this} argument, the arguments of such methods should
2687 be counted from two.
2688
2689 The @code{format_arg} attribute allows you to identify your own
2690 functions that modify format strings, so that GCC can check the
2691 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2692 type function whose operands are a call to one of your own function.
2693 The compiler always treats @code{gettext}, @code{dgettext}, and
2694 @code{dcgettext} in this manner except when strict ISO C support is
2695 requested by @option{-ansi} or an appropriate @option{-std} option, or
2696 @option{-ffreestanding} or @option{-fno-builtin}
2697 is used. @xref{C Dialect Options,,Options
2698 Controlling C Dialect}.
2699
2700 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2701 @code{NSString} reference for compatibility with the @code{format} attribute
2702 above.
2703
2704 The target may also allow additional types in @code{format-arg} attributes.
2705 @xref{Target Format Checks,,Format Checks Specific to Particular
2706 Target Machines}.
2707
2708 @item gnu_inline
2709 @cindex @code{gnu_inline} function attribute
2710 This attribute should be used with a function that is also declared
2711 with the @code{inline} keyword. It directs GCC to treat the function
2712 as if it were defined in gnu90 mode even when compiling in C99 or
2713 gnu99 mode.
2714
2715 If the function is declared @code{extern}, then this definition of the
2716 function is used only for inlining. In no case is the function
2717 compiled as a standalone function, not even if you take its address
2718 explicitly. Such an address becomes an external reference, as if you
2719 had only declared the function, and had not defined it. This has
2720 almost the effect of a macro. The way to use this is to put a
2721 function definition in a header file with this attribute, and put
2722 another copy of the function, without @code{extern}, in a library
2723 file. The definition in the header file causes most calls to the
2724 function to be inlined. If any uses of the function remain, they
2725 refer to the single copy in the library. Note that the two
2726 definitions of the functions need not be precisely the same, although
2727 if they do not have the same effect your program may behave oddly.
2728
2729 In C, if the function is neither @code{extern} nor @code{static}, then
2730 the function is compiled as a standalone function, as well as being
2731 inlined where possible.
2732
2733 This is how GCC traditionally handled functions declared
2734 @code{inline}. Since ISO C99 specifies a different semantics for
2735 @code{inline}, this function attribute is provided as a transition
2736 measure and as a useful feature in its own right. This attribute is
2737 available in GCC 4.1.3 and later. It is available if either of the
2738 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2739 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2740 Function is As Fast As a Macro}.
2741
2742 In C++, this attribute does not depend on @code{extern} in any way,
2743 but it still requires the @code{inline} keyword to enable its special
2744 behavior.
2745
2746 @item hot
2747 @cindex @code{hot} function attribute
2748 The @code{hot} attribute on a function is used to inform the compiler that
2749 the function is a hot spot of the compiled program. The function is
2750 optimized more aggressively and on many targets it is placed into a special
2751 subsection of the text section so all hot functions appear close together,
2752 improving locality.
2753
2754 When profile feedback is available, via @option{-fprofile-use}, hot functions
2755 are automatically detected and this attribute is ignored.
2756
2757 @item ifunc ("@var{resolver}")
2758 @cindex @code{ifunc} function attribute
2759 @cindex indirect functions
2760 @cindex functions that are dynamically resolved
2761 The @code{ifunc} attribute is used to mark a function as an indirect
2762 function using the STT_GNU_IFUNC symbol type extension to the ELF
2763 standard. This allows the resolution of the symbol value to be
2764 determined dynamically at load time, and an optimized version of the
2765 routine can be selected for the particular processor or other system
2766 characteristics determined then. To use this attribute, first define
2767 the implementation functions available, and a resolver function that
2768 returns a pointer to the selected implementation function. The
2769 implementation functions' declarations must match the API of the
2770 function being implemented, the resolver's declaration is be a
2771 function returning pointer to void function returning void:
2772
2773 @smallexample
2774 void *my_memcpy (void *dst, const void *src, size_t len)
2775 @{
2776 @dots{}
2777 @}
2778
2779 static void (*resolve_memcpy (void)) (void)
2780 @{
2781 return my_memcpy; // we'll just always select this routine
2782 @}
2783 @end smallexample
2784
2785 @noindent
2786 The exported header file declaring the function the user calls would
2787 contain:
2788
2789 @smallexample
2790 extern void *memcpy (void *, const void *, size_t);
2791 @end smallexample
2792
2793 @noindent
2794 allowing the user to call this as a regular function, unaware of the
2795 implementation. Finally, the indirect function needs to be defined in
2796 the same translation unit as the resolver function:
2797
2798 @smallexample
2799 void *memcpy (void *, const void *, size_t)
2800 __attribute__ ((ifunc ("resolve_memcpy")));
2801 @end smallexample
2802
2803 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2804 and GNU C Library version 2.11.1 are required to use this feature.
2805
2806 @item interrupt
2807 @itemx interrupt_handler
2808 Many GCC back ends support attributes to indicate that a function is
2809 an interrupt handler, which tells the compiler to generate function
2810 entry and exit sequences that differ from those from regular
2811 functions. The exact syntax and behavior are target-specific;
2812 refer to the following subsections for details.
2813
2814 @item leaf
2815 @cindex @code{leaf} function attribute
2816 Calls to external functions with this attribute must return to the
2817 current compilation unit only by return or by exception handling. In
2818 particular, a leaf function is not allowed to invoke callback functions
2819 passed to it from the current compilation unit, directly call functions
2820 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2821 might still call functions from other compilation units and thus they
2822 are not necessarily leaf in the sense that they contain no function
2823 calls at all.
2824
2825 The attribute is intended for library functions to improve dataflow
2826 analysis. The compiler takes the hint that any data not escaping the
2827 current compilation unit cannot be used or modified by the leaf
2828 function. For example, the @code{sin} function is a leaf function, but
2829 @code{qsort} is not.
2830
2831 Note that leaf functions might indirectly run a signal handler defined
2832 in the current compilation unit that uses static variables. Similarly,
2833 when lazy symbol resolution is in effect, leaf functions might invoke
2834 indirect functions whose resolver function or implementation function is
2835 defined in the current compilation unit and uses static variables. There
2836 is no standard-compliant way to write such a signal handler, resolver
2837 function, or implementation function, and the best that you can do is to
2838 remove the @code{leaf} attribute or mark all such static variables
2839 @code{volatile}. Lastly, for ELF-based systems that support symbol
2840 interposition, care should be taken that functions defined in the
2841 current compilation unit do not unexpectedly interpose other symbols
2842 based on the defined standards mode and defined feature test macros;
2843 otherwise an inadvertent callback would be added.
2844
2845 The attribute has no effect on functions defined within the current
2846 compilation unit. This is to allow easy merging of multiple compilation
2847 units into one, for example, by using the link-time optimization. For
2848 this reason the attribute is not allowed on types to annotate indirect
2849 calls.
2850
2851 @item malloc
2852 @cindex @code{malloc} function attribute
2853 @cindex functions that behave like malloc
2854 This tells the compiler that a function is @code{malloc}-like, i.e.,
2855 that the pointer @var{P} returned by the function cannot alias any
2856 other pointer valid when the function returns, and moreover no
2857 pointers to valid objects occur in any storage addressed by @var{P}.
2858
2859 Using this attribute can improve optimization. Functions like
2860 @code{malloc} and @code{calloc} have this property because they return
2861 a pointer to uninitialized or zeroed-out storage. However, functions
2862 like @code{realloc} do not have this property, as they can return a
2863 pointer to storage containing pointers.
2864
2865 @item no_icf
2866 @cindex @code{no_icf} function attribute
2867 This function attribute prevents a functions from being merged with another
2868 semantically equivalent function.
2869
2870 @item no_instrument_function
2871 @cindex @code{no_instrument_function} function attribute
2872 @opindex finstrument-functions
2873 If @option{-finstrument-functions} is given, profiling function calls are
2874 generated at entry and exit of most user-compiled functions.
2875 Functions with this attribute are not so instrumented.
2876
2877 @item no_profile_instrument_function
2878 @cindex @code{no_profile_instrument_function} function attribute
2879 The @code{no_profile_instrument_function} attribute on functions is used
2880 to inform the compiler that it should not process any profile feedback based
2881 optimization code instrumentation.
2882
2883 @item no_reorder
2884 @cindex @code{no_reorder} function attribute
2885 Do not reorder functions or variables marked @code{no_reorder}
2886 against each other or top level assembler statements the executable.
2887 The actual order in the program will depend on the linker command
2888 line. Static variables marked like this are also not removed.
2889 This has a similar effect
2890 as the @option{-fno-toplevel-reorder} option, but only applies to the
2891 marked symbols.
2892
2893 @item no_sanitize_address
2894 @itemx no_address_safety_analysis
2895 @cindex @code{no_sanitize_address} function attribute
2896 The @code{no_sanitize_address} attribute on functions is used
2897 to inform the compiler that it should not instrument memory accesses
2898 in the function when compiling with the @option{-fsanitize=address} option.
2899 The @code{no_address_safety_analysis} is a deprecated alias of the
2900 @code{no_sanitize_address} attribute, new code should use
2901 @code{no_sanitize_address}.
2902
2903 @item no_sanitize_thread
2904 @cindex @code{no_sanitize_thread} function attribute
2905 The @code{no_sanitize_thread} attribute on functions is used
2906 to inform the compiler that it should not instrument memory accesses
2907 in the function when compiling with the @option{-fsanitize=thread} option.
2908
2909 @item no_sanitize_undefined
2910 @cindex @code{no_sanitize_undefined} function attribute
2911 The @code{no_sanitize_undefined} attribute on functions is used
2912 to inform the compiler that it should not check for undefined behavior
2913 in the function when compiling with the @option{-fsanitize=undefined} option.
2914
2915 @item no_split_stack
2916 @cindex @code{no_split_stack} function attribute
2917 @opindex fsplit-stack
2918 If @option{-fsplit-stack} is given, functions have a small
2919 prologue which decides whether to split the stack. Functions with the
2920 @code{no_split_stack} attribute do not have that prologue, and thus
2921 may run with only a small amount of stack space available.
2922
2923 @item no_stack_limit
2924 @cindex @code{no_stack_limit} function attribute
2925 This attribute locally overrides the @option{-fstack-limit-register}
2926 and @option{-fstack-limit-symbol} command-line options; it has the effect
2927 of disabling stack limit checking in the function it applies to.
2928
2929 @item noclone
2930 @cindex @code{noclone} function attribute
2931 This function attribute prevents a function from being considered for
2932 cloning---a mechanism that produces specialized copies of functions
2933 and which is (currently) performed by interprocedural constant
2934 propagation.
2935
2936 @item noinline
2937 @cindex @code{noinline} function attribute
2938 This function attribute prevents a function from being considered for
2939 inlining.
2940 @c Don't enumerate the optimizations by name here; we try to be
2941 @c future-compatible with this mechanism.
2942 If the function does not have side-effects, there are optimizations
2943 other than inlining that cause function calls to be optimized away,
2944 although the function call is live. To keep such calls from being
2945 optimized away, put
2946 @smallexample
2947 asm ("");
2948 @end smallexample
2949
2950 @noindent
2951 (@pxref{Extended Asm}) in the called function, to serve as a special
2952 side-effect.
2953
2954 @item nonnull (@var{arg-index}, @dots{})
2955 @cindex @code{nonnull} function attribute
2956 @cindex functions with non-null pointer arguments
2957 The @code{nonnull} attribute specifies that some function parameters should
2958 be non-null pointers. For instance, the declaration:
2959
2960 @smallexample
2961 extern void *
2962 my_memcpy (void *dest, const void *src, size_t len)
2963 __attribute__((nonnull (1, 2)));
2964 @end smallexample
2965
2966 @noindent
2967 causes the compiler to check that, in calls to @code{my_memcpy},
2968 arguments @var{dest} and @var{src} are non-null. If the compiler
2969 determines that a null pointer is passed in an argument slot marked
2970 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2971 is issued. The compiler may also choose to make optimizations based
2972 on the knowledge that certain function arguments will never be null.
2973
2974 If no argument index list is given to the @code{nonnull} attribute,
2975 all pointer arguments are marked as non-null. To illustrate, the
2976 following declaration is equivalent to the previous example:
2977
2978 @smallexample
2979 extern void *
2980 my_memcpy (void *dest, const void *src, size_t len)
2981 __attribute__((nonnull));
2982 @end smallexample
2983
2984 @item noplt
2985 @cindex @code{noplt} function attribute
2986 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2987 Calls to functions marked with this attribute in position-independent code
2988 do not use the PLT.
2989
2990 @smallexample
2991 @group
2992 /* Externally defined function foo. */
2993 int foo () __attribute__ ((noplt));
2994
2995 int
2996 main (/* @r{@dots{}} */)
2997 @{
2998 /* @r{@dots{}} */
2999 foo ();
3000 /* @r{@dots{}} */
3001 @}
3002 @end group
3003 @end smallexample
3004
3005 The @code{noplt} attribute on function @code{foo}
3006 tells the compiler to assume that
3007 the function @code{foo} is externally defined and that the call to
3008 @code{foo} must avoid the PLT
3009 in position-independent code.
3010
3011 In position-dependent code, a few targets also convert calls to
3012 functions that are marked to not use the PLT to use the GOT instead.
3013
3014 @item noreturn
3015 @cindex @code{noreturn} function attribute
3016 @cindex functions that never return
3017 A few standard library functions, such as @code{abort} and @code{exit},
3018 cannot return. GCC knows this automatically. Some programs define
3019 their own functions that never return. You can declare them
3020 @code{noreturn} to tell the compiler this fact. For example,
3021
3022 @smallexample
3023 @group
3024 void fatal () __attribute__ ((noreturn));
3025
3026 void
3027 fatal (/* @r{@dots{}} */)
3028 @{
3029 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3030 exit (1);
3031 @}
3032 @end group
3033 @end smallexample
3034
3035 The @code{noreturn} keyword tells the compiler to assume that
3036 @code{fatal} cannot return. It can then optimize without regard to what
3037 would happen if @code{fatal} ever did return. This makes slightly
3038 better code. More importantly, it helps avoid spurious warnings of
3039 uninitialized variables.
3040
3041 The @code{noreturn} keyword does not affect the exceptional path when that
3042 applies: a @code{noreturn}-marked function may still return to the caller
3043 by throwing an exception or calling @code{longjmp}.
3044
3045 Do not assume that registers saved by the calling function are
3046 restored before calling the @code{noreturn} function.
3047
3048 It does not make sense for a @code{noreturn} function to have a return
3049 type other than @code{void}.
3050
3051 @item nothrow
3052 @cindex @code{nothrow} function attribute
3053 The @code{nothrow} attribute is used to inform the compiler that a
3054 function cannot throw an exception. For example, most functions in
3055 the standard C library can be guaranteed not to throw an exception
3056 with the notable exceptions of @code{qsort} and @code{bsearch} that
3057 take function pointer arguments.
3058
3059 @item optimize
3060 @cindex @code{optimize} function attribute
3061 The @code{optimize} attribute is used to specify that a function is to
3062 be compiled with different optimization options than specified on the
3063 command line. Arguments can either be numbers or strings. Numbers
3064 are assumed to be an optimization level. Strings that begin with
3065 @code{O} are assumed to be an optimization option, while other options
3066 are assumed to be used with a @code{-f} prefix. You can also use the
3067 @samp{#pragma GCC optimize} pragma to set the optimization options
3068 that affect more than one function.
3069 @xref{Function Specific Option Pragmas}, for details about the
3070 @samp{#pragma GCC optimize} pragma.
3071
3072 This attribute should be used for debugging purposes only. It is not
3073 suitable in production code.
3074
3075 @item pure
3076 @cindex @code{pure} function attribute
3077 @cindex functions that have no side effects
3078 Many functions have no effects except the return value and their
3079 return value depends only on the parameters and/or global variables.
3080 Such a function can be subject
3081 to common subexpression elimination and loop optimization just as an
3082 arithmetic operator would be. These functions should be declared
3083 with the attribute @code{pure}. For example,
3084
3085 @smallexample
3086 int square (int) __attribute__ ((pure));
3087 @end smallexample
3088
3089 @noindent
3090 says that the hypothetical function @code{square} is safe to call
3091 fewer times than the program says.
3092
3093 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3094 Interesting non-pure functions are functions with infinite loops or those
3095 depending on volatile memory or other system resource, that may change between
3096 two consecutive calls (such as @code{feof} in a multithreading environment).
3097
3098 @item returns_nonnull
3099 @cindex @code{returns_nonnull} function attribute
3100 The @code{returns_nonnull} attribute specifies that the function
3101 return value should be a non-null pointer. For instance, the declaration:
3102
3103 @smallexample
3104 extern void *
3105 mymalloc (size_t len) __attribute__((returns_nonnull));
3106 @end smallexample
3107
3108 @noindent
3109 lets the compiler optimize callers based on the knowledge
3110 that the return value will never be null.
3111
3112 @item returns_twice
3113 @cindex @code{returns_twice} function attribute
3114 @cindex functions that return more than once
3115 The @code{returns_twice} attribute tells the compiler that a function may
3116 return more than one time. The compiler ensures that all registers
3117 are dead before calling such a function and emits a warning about
3118 the variables that may be clobbered after the second return from the
3119 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3120 The @code{longjmp}-like counterpart of such function, if any, might need
3121 to be marked with the @code{noreturn} attribute.
3122
3123 @item section ("@var{section-name}")
3124 @cindex @code{section} function attribute
3125 @cindex functions in arbitrary sections
3126 Normally, the compiler places the code it generates in the @code{text} section.
3127 Sometimes, however, you need additional sections, or you need certain
3128 particular functions to appear in special sections. The @code{section}
3129 attribute specifies that a function lives in a particular section.
3130 For example, the declaration:
3131
3132 @smallexample
3133 extern void foobar (void) __attribute__ ((section ("bar")));
3134 @end smallexample
3135
3136 @noindent
3137 puts the function @code{foobar} in the @code{bar} section.
3138
3139 Some file formats do not support arbitrary sections so the @code{section}
3140 attribute is not available on all platforms.
3141 If you need to map the entire contents of a module to a particular
3142 section, consider using the facilities of the linker instead.
3143
3144 @item sentinel
3145 @cindex @code{sentinel} function attribute
3146 This function attribute ensures that a parameter in a function call is
3147 an explicit @code{NULL}. The attribute is only valid on variadic
3148 functions. By default, the sentinel is located at position zero, the
3149 last parameter of the function call. If an optional integer position
3150 argument P is supplied to the attribute, the sentinel must be located at
3151 position P counting backwards from the end of the argument list.
3152
3153 @smallexample
3154 __attribute__ ((sentinel))
3155 is equivalent to
3156 __attribute__ ((sentinel(0)))
3157 @end smallexample
3158
3159 The attribute is automatically set with a position of 0 for the built-in
3160 functions @code{execl} and @code{execlp}. The built-in function
3161 @code{execle} has the attribute set with a position of 1.
3162
3163 A valid @code{NULL} in this context is defined as zero with any pointer
3164 type. If your system defines the @code{NULL} macro with an integer type
3165 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3166 with a copy that redefines NULL appropriately.
3167
3168 The warnings for missing or incorrect sentinels are enabled with
3169 @option{-Wformat}.
3170
3171 @item simd
3172 @itemx simd("@var{mask}")
3173 @cindex @code{simd} function attribute
3174 This attribute enables creation of one or more function versions that
3175 can process multiple arguments using SIMD instructions from a
3176 single invocation. Specifying this attribute allows compiler to
3177 assume that such versions are available at link time (provided
3178 in the same or another translation unit). Generated versions are
3179 target-dependent and described in the corresponding Vector ABI document. For
3180 x86_64 target this document can be found
3181 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3182
3183 The optional argument @var{mask} may have the value
3184 @code{notinbranch} or @code{inbranch},
3185 and instructs the compiler to generate non-masked or masked
3186 clones correspondingly. By default, all clones are generated.
3187
3188 The attribute should not be used together with Cilk Plus @code{vector}
3189 attribute on the same function.
3190
3191 If the attribute is specified and @code{#pragma omp declare simd} is
3192 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3193 switch is specified, then the attribute is ignored.
3194
3195 @item stack_protect
3196 @cindex @code{stack_protect} function attribute
3197 This attribute adds stack protection code to the function if
3198 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3199 or @option{-fstack-protector-explicit} are set.
3200
3201 @item target (@var{options})
3202 @cindex @code{target} function attribute
3203 Multiple target back ends implement the @code{target} attribute
3204 to specify that a function is to
3205 be compiled with different target options than specified on the
3206 command line. This can be used for instance to have functions
3207 compiled with a different ISA (instruction set architecture) than the
3208 default. You can also use the @samp{#pragma GCC target} pragma to set
3209 more than one function to be compiled with specific target options.
3210 @xref{Function Specific Option Pragmas}, for details about the
3211 @samp{#pragma GCC target} pragma.
3212
3213 For instance, on an x86, you could declare one function with the
3214 @code{target("sse4.1,arch=core2")} attribute and another with
3215 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3216 compiling the first function with @option{-msse4.1} and
3217 @option{-march=core2} options, and the second function with
3218 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3219 to make sure that a function is only invoked on a machine that
3220 supports the particular ISA it is compiled for (for example by using
3221 @code{cpuid} on x86 to determine what feature bits and architecture
3222 family are used).
3223
3224 @smallexample
3225 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3226 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3227 @end smallexample
3228
3229 You can either use multiple
3230 strings separated by commas to specify multiple options,
3231 or separate the options with a comma (@samp{,}) within a single string.
3232
3233 The options supported are specific to each target; refer to @ref{x86
3234 Function Attributes}, @ref{PowerPC Function Attributes},
3235 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3236 for details.
3237
3238 @item target_clones (@var{options})
3239 @cindex @code{target_clones} function attribute
3240 The @code{target_clones} attribute is used to specify that a function
3241 be cloned into multiple versions compiled with different target options
3242 than specified on the command line. The supported options and restrictions
3243 are the same as for @code{target} attribute.
3244
3245 For instance, on an x86, you could compile a function with
3246 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3247 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3248 It also creates a resolver function (see the @code{ifunc} attribute
3249 above) that dynamically selects a clone suitable for current architecture.
3250
3251 @item unused
3252 @cindex @code{unused} function attribute
3253 This attribute, attached to a function, means that the function is meant
3254 to be possibly unused. GCC does not produce a warning for this
3255 function.
3256
3257 @item used
3258 @cindex @code{used} function attribute
3259 This attribute, attached to a function, means that code must be emitted
3260 for the function even if it appears that the function is not referenced.
3261 This is useful, for example, when the function is referenced only in
3262 inline assembly.
3263
3264 When applied to a member function of a C++ class template, the
3265 attribute also means that the function is instantiated if the
3266 class itself is instantiated.
3267
3268 @item visibility ("@var{visibility_type}")
3269 @cindex @code{visibility} function attribute
3270 This attribute affects the linkage of the declaration to which it is attached.
3271 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3272 (@pxref{Common Type Attributes}) as well as functions.
3273
3274 There are four supported @var{visibility_type} values: default,
3275 hidden, protected or internal visibility.
3276
3277 @smallexample
3278 void __attribute__ ((visibility ("protected")))
3279 f () @{ /* @r{Do something.} */; @}
3280 int i __attribute__ ((visibility ("hidden")));
3281 @end smallexample
3282
3283 The possible values of @var{visibility_type} correspond to the
3284 visibility settings in the ELF gABI.
3285
3286 @table @code
3287 @c keep this list of visibilities in alphabetical order.
3288
3289 @item default
3290 Default visibility is the normal case for the object file format.
3291 This value is available for the visibility attribute to override other
3292 options that may change the assumed visibility of entities.
3293
3294 On ELF, default visibility means that the declaration is visible to other
3295 modules and, in shared libraries, means that the declared entity may be
3296 overridden.
3297
3298 On Darwin, default visibility means that the declaration is visible to
3299 other modules.
3300
3301 Default visibility corresponds to ``external linkage'' in the language.
3302
3303 @item hidden
3304 Hidden visibility indicates that the entity declared has a new
3305 form of linkage, which we call ``hidden linkage''. Two
3306 declarations of an object with hidden linkage refer to the same object
3307 if they are in the same shared object.
3308
3309 @item internal
3310 Internal visibility is like hidden visibility, but with additional
3311 processor specific semantics. Unless otherwise specified by the
3312 psABI, GCC defines internal visibility to mean that a function is
3313 @emph{never} called from another module. Compare this with hidden
3314 functions which, while they cannot be referenced directly by other
3315 modules, can be referenced indirectly via function pointers. By
3316 indicating that a function cannot be called from outside the module,
3317 GCC may for instance omit the load of a PIC register since it is known
3318 that the calling function loaded the correct value.
3319
3320 @item protected
3321 Protected visibility is like default visibility except that it
3322 indicates that references within the defining module bind to the
3323 definition in that module. That is, the declared entity cannot be
3324 overridden by another module.
3325
3326 @end table
3327
3328 All visibilities are supported on many, but not all, ELF targets
3329 (supported when the assembler supports the @samp{.visibility}
3330 pseudo-op). Default visibility is supported everywhere. Hidden
3331 visibility is supported on Darwin targets.
3332
3333 The visibility attribute should be applied only to declarations that
3334 would otherwise have external linkage. The attribute should be applied
3335 consistently, so that the same entity should not be declared with
3336 different settings of the attribute.
3337
3338 In C++, the visibility attribute applies to types as well as functions
3339 and objects, because in C++ types have linkage. A class must not have
3340 greater visibility than its non-static data member types and bases,
3341 and class members default to the visibility of their class. Also, a
3342 declaration without explicit visibility is limited to the visibility
3343 of its type.
3344
3345 In C++, you can mark member functions and static member variables of a
3346 class with the visibility attribute. This is useful if you know a
3347 particular method or static member variable should only be used from
3348 one shared object; then you can mark it hidden while the rest of the
3349 class has default visibility. Care must be taken to avoid breaking
3350 the One Definition Rule; for example, it is usually not useful to mark
3351 an inline method as hidden without marking the whole class as hidden.
3352
3353 A C++ namespace declaration can also have the visibility attribute.
3354
3355 @smallexample
3356 namespace nspace1 __attribute__ ((visibility ("protected")))
3357 @{ /* @r{Do something.} */; @}
3358 @end smallexample
3359
3360 This attribute applies only to the particular namespace body, not to
3361 other definitions of the same namespace; it is equivalent to using
3362 @samp{#pragma GCC visibility} before and after the namespace
3363 definition (@pxref{Visibility Pragmas}).
3364
3365 In C++, if a template argument has limited visibility, this
3366 restriction is implicitly propagated to the template instantiation.
3367 Otherwise, template instantiations and specializations default to the
3368 visibility of their template.
3369
3370 If both the template and enclosing class have explicit visibility, the
3371 visibility from the template is used.
3372
3373 @item warn_unused_result
3374 @cindex @code{warn_unused_result} function attribute
3375 The @code{warn_unused_result} attribute causes a warning to be emitted
3376 if a caller of the function with this attribute does not use its
3377 return value. This is useful for functions where not checking
3378 the result is either a security problem or always a bug, such as
3379 @code{realloc}.
3380
3381 @smallexample
3382 int fn () __attribute__ ((warn_unused_result));
3383 int foo ()
3384 @{
3385 if (fn () < 0) return -1;
3386 fn ();
3387 return 0;
3388 @}
3389 @end smallexample
3390
3391 @noindent
3392 results in warning on line 5.
3393
3394 @item weak
3395 @cindex @code{weak} function attribute
3396 The @code{weak} attribute causes the declaration to be emitted as a weak
3397 symbol rather than a global. This is primarily useful in defining
3398 library functions that can be overridden in user code, though it can
3399 also be used with non-function declarations. Weak symbols are supported
3400 for ELF targets, and also for a.out targets when using the GNU assembler
3401 and linker.
3402
3403 @item weakref
3404 @itemx weakref ("@var{target}")
3405 @cindex @code{weakref} function attribute
3406 The @code{weakref} attribute marks a declaration as a weak reference.
3407 Without arguments, it should be accompanied by an @code{alias} attribute
3408 naming the target symbol. Optionally, the @var{target} may be given as
3409 an argument to @code{weakref} itself. In either case, @code{weakref}
3410 implicitly marks the declaration as @code{weak}. Without a
3411 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3412 @code{weakref} is equivalent to @code{weak}.
3413
3414 @smallexample
3415 static int x() __attribute__ ((weakref ("y")));
3416 /* is equivalent to... */
3417 static int x() __attribute__ ((weak, weakref, alias ("y")));
3418 /* and to... */
3419 static int x() __attribute__ ((weakref));
3420 static int x() __attribute__ ((alias ("y")));
3421 @end smallexample
3422
3423 A weak reference is an alias that does not by itself require a
3424 definition to be given for the target symbol. If the target symbol is
3425 only referenced through weak references, then it becomes a @code{weak}
3426 undefined symbol. If it is directly referenced, however, then such
3427 strong references prevail, and a definition is required for the
3428 symbol, not necessarily in the same translation unit.
3429
3430 The effect is equivalent to moving all references to the alias to a
3431 separate translation unit, renaming the alias to the aliased symbol,
3432 declaring it as weak, compiling the two separate translation units and
3433 performing a reloadable link on them.
3434
3435 At present, a declaration to which @code{weakref} is attached can
3436 only be @code{static}.
3437
3438
3439 @end table
3440
3441 @c This is the end of the target-independent attribute table
3442
3443 @node AArch64 Function Attributes
3444 @subsection AArch64 Function Attributes
3445
3446 The following target-specific function attributes are available for the
3447 AArch64 target. For the most part, these options mirror the behavior of
3448 similar command-line options (@pxref{AArch64 Options}), but on a
3449 per-function basis.
3450
3451 @table @code
3452 @item general-regs-only
3453 @cindex @code{general-regs-only} function attribute, AArch64
3454 Indicates that no floating-point or Advanced SIMD registers should be
3455 used when generating code for this function. If the function explicitly
3456 uses floating-point code, then the compiler gives an error. This is
3457 the same behavior as that of the command-line option
3458 @option{-mgeneral-regs-only}.
3459
3460 @item fix-cortex-a53-835769
3461 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3462 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3463 applied to this function. To explicitly disable the workaround for this
3464 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3465 This corresponds to the behavior of the command line options
3466 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3467
3468 @item cmodel=
3469 @cindex @code{cmodel=} function attribute, AArch64
3470 Indicates that code should be generated for a particular code model for
3471 this function. The behavior and permissible arguments are the same as
3472 for the command line option @option{-mcmodel=}.
3473
3474 @item strict-align
3475 @cindex @code{strict-align} function attribute, AArch64
3476 Indicates that the compiler should not assume that unaligned memory references
3477 are handled by the system. The behavior is the same as for the command-line
3478 option @option{-mstrict-align}.
3479
3480 @item omit-leaf-frame-pointer
3481 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3482 Indicates that the frame pointer should be omitted for a leaf function call.
3483 To keep the frame pointer, the inverse attribute
3484 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3485 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3486 and @option{-mno-omit-leaf-frame-pointer}.
3487
3488 @item tls-dialect=
3489 @cindex @code{tls-dialect=} function attribute, AArch64
3490 Specifies the TLS dialect to use for this function. The behavior and
3491 permissible arguments are the same as for the command-line option
3492 @option{-mtls-dialect=}.
3493
3494 @item arch=
3495 @cindex @code{arch=} function attribute, AArch64
3496 Specifies the architecture version and architectural extensions to use
3497 for this function. The behavior and permissible arguments are the same as
3498 for the @option{-march=} command-line option.
3499
3500 @item tune=
3501 @cindex @code{tune=} function attribute, AArch64
3502 Specifies the core for which to tune the performance of this function.
3503 The behavior and permissible arguments are the same as for the @option{-mtune=}
3504 command-line option.
3505
3506 @item cpu=
3507 @cindex @code{cpu=} function attribute, AArch64
3508 Specifies the core for which to tune the performance of this function and also
3509 whose architectural features to use. The behavior and valid arguments are the
3510 same as for the @option{-mcpu=} command-line option.
3511
3512 @end table
3513
3514 The above target attributes can be specified as follows:
3515
3516 @smallexample
3517 __attribute__((target("@var{attr-string}")))
3518 int
3519 f (int a)
3520 @{
3521 return a + 5;
3522 @}
3523 @end smallexample
3524
3525 where @code{@var{attr-string}} is one of the attribute strings specified above.
3526
3527 Additionally, the architectural extension string may be specified on its
3528 own. This can be used to turn on and off particular architectural extensions
3529 without having to specify a particular architecture version or core. Example:
3530
3531 @smallexample
3532 __attribute__((target("+crc+nocrypto")))
3533 int
3534 foo (int a)
3535 @{
3536 return a + 5;
3537 @}
3538 @end smallexample
3539
3540 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3541 extension and disables the @code{crypto} extension for the function @code{foo}
3542 without modifying an existing @option{-march=} or @option{-mcpu} option.
3543
3544 Multiple target function attributes can be specified by separating them with
3545 a comma. For example:
3546 @smallexample
3547 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3548 int
3549 foo (int a)
3550 @{
3551 return a + 5;
3552 @}
3553 @end smallexample
3554
3555 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3556 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3557
3558 @subsubsection Inlining rules
3559 Specifying target attributes on individual functions or performing link-time
3560 optimization across translation units compiled with different target options
3561 can affect function inlining rules:
3562
3563 In particular, a caller function can inline a callee function only if the
3564 architectural features available to the callee are a subset of the features
3565 available to the caller.
3566 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3567 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3568 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3569 because the all the architectural features that function @code{bar} requires
3570 are available to function @code{foo}. Conversely, function @code{bar} cannot
3571 inline function @code{foo}.
3572
3573 Additionally inlining a function compiled with @option{-mstrict-align} into a
3574 function compiled without @code{-mstrict-align} is not allowed.
3575 However, inlining a function compiled without @option{-mstrict-align} into a
3576 function compiled with @option{-mstrict-align} is allowed.
3577
3578 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3579 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3580 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3581 architectural feature rules specified above.
3582
3583 @node ARC Function Attributes
3584 @subsection ARC Function Attributes
3585
3586 These function attributes are supported by the ARC back end:
3587
3588 @table @code
3589 @item interrupt
3590 @cindex @code{interrupt} function attribute, ARC
3591 Use this attribute to indicate
3592 that the specified function is an interrupt handler. The compiler generates
3593 function entry and exit sequences suitable for use in an interrupt handler
3594 when this attribute is present.
3595
3596 On the ARC, you must specify the kind of interrupt to be handled
3597 in a parameter to the interrupt attribute like this:
3598
3599 @smallexample
3600 void f () __attribute__ ((interrupt ("ilink1")));
3601 @end smallexample
3602
3603 Permissible values for this parameter are: @w{@code{ilink1}} and
3604 @w{@code{ilink2}}.
3605
3606 @item long_call
3607 @itemx medium_call
3608 @itemx short_call
3609 @cindex @code{long_call} function attribute, ARC
3610 @cindex @code{medium_call} function attribute, ARC
3611 @cindex @code{short_call} function attribute, ARC
3612 @cindex indirect calls, ARC
3613 These attributes specify how a particular function is called.
3614 These attributes override the
3615 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3616 command-line switches and @code{#pragma long_calls} settings.
3617
3618 For ARC, a function marked with the @code{long_call} attribute is
3619 always called using register-indirect jump-and-link instructions,
3620 thereby enabling the called function to be placed anywhere within the
3621 32-bit address space. A function marked with the @code{medium_call}
3622 attribute will always be close enough to be called with an unconditional
3623 branch-and-link instruction, which has a 25-bit offset from
3624 the call site. A function marked with the @code{short_call}
3625 attribute will always be close enough to be called with a conditional
3626 branch-and-link instruction, which has a 21-bit offset from
3627 the call site.
3628 @end table
3629
3630 @node ARM Function Attributes
3631 @subsection ARM Function Attributes
3632
3633 These function attributes are supported for ARM targets:
3634
3635 @table @code
3636 @item interrupt
3637 @cindex @code{interrupt} function attribute, ARM
3638 Use this attribute to indicate
3639 that the specified function is an interrupt handler. The compiler generates
3640 function entry and exit sequences suitable for use in an interrupt handler
3641 when this attribute is present.
3642
3643 You can specify the kind of interrupt to be handled by
3644 adding an optional parameter to the interrupt attribute like this:
3645
3646 @smallexample
3647 void f () __attribute__ ((interrupt ("IRQ")));
3648 @end smallexample
3649
3650 @noindent
3651 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3652 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3653
3654 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3655 may be called with a word-aligned stack pointer.
3656
3657 @item isr
3658 @cindex @code{isr} function attribute, ARM
3659 Use this attribute on ARM to write Interrupt Service Routines. This is an
3660 alias to the @code{interrupt} attribute above.
3661
3662 @item long_call
3663 @itemx short_call
3664 @cindex @code{long_call} function attribute, ARM
3665 @cindex @code{short_call} function attribute, ARM
3666 @cindex indirect calls, ARM
3667 These attributes specify how a particular function is called.
3668 These attributes override the
3669 @option{-mlong-calls} (@pxref{ARM Options})
3670 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3671 @code{long_call} attribute indicates that the function might be far
3672 away from the call site and require a different (more expensive)
3673 calling sequence. The @code{short_call} attribute always places
3674 the offset to the function from the call site into the @samp{BL}
3675 instruction directly.
3676
3677 @item naked
3678 @cindex @code{naked} function attribute, ARM
3679 This attribute allows the compiler to construct the
3680 requisite function declaration, while allowing the body of the
3681 function to be assembly code. The specified function will not have
3682 prologue/epilogue sequences generated by the compiler. Only basic
3683 @code{asm} statements can safely be included in naked functions
3684 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3685 basic @code{asm} and C code may appear to work, they cannot be
3686 depended upon to work reliably and are not supported.
3687
3688 @item pcs
3689 @cindex @code{pcs} function attribute, ARM
3690
3691 The @code{pcs} attribute can be used to control the calling convention
3692 used for a function on ARM. The attribute takes an argument that specifies
3693 the calling convention to use.
3694
3695 When compiling using the AAPCS ABI (or a variant of it) then valid
3696 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3697 order to use a variant other than @code{"aapcs"} then the compiler must
3698 be permitted to use the appropriate co-processor registers (i.e., the
3699 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3700 For example,
3701
3702 @smallexample
3703 /* Argument passed in r0, and result returned in r0+r1. */
3704 double f2d (float) __attribute__((pcs("aapcs")));
3705 @end smallexample
3706
3707 Variadic functions always use the @code{"aapcs"} calling convention and
3708 the compiler rejects attempts to specify an alternative.
3709
3710 @item target (@var{options})
3711 @cindex @code{target} function attribute
3712 As discussed in @ref{Common Function Attributes}, this attribute
3713 allows specification of target-specific compilation options.
3714
3715 On ARM, the following options are allowed:
3716
3717 @table @samp
3718 @item thumb
3719 @cindex @code{target("thumb")} function attribute, ARM
3720 Force code generation in the Thumb (T16/T32) ISA, depending on the
3721 architecture level.
3722
3723 @item arm
3724 @cindex @code{target("arm")} function attribute, ARM
3725 Force code generation in the ARM (A32) ISA.
3726
3727 Functions from different modes can be inlined in the caller's mode.
3728
3729 @item fpu=
3730 @cindex @code{target("fpu=")} function attribute, ARM
3731 Specifies the fpu for which to tune the performance of this function.
3732 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3733 command-line option.
3734
3735 @end table
3736
3737 @end table
3738
3739 @node AVR Function Attributes
3740 @subsection AVR Function Attributes
3741
3742 These function attributes are supported by the AVR back end:
3743
3744 @table @code
3745 @item interrupt
3746 @cindex @code{interrupt} function attribute, AVR
3747 Use this attribute to indicate
3748 that the specified function is an interrupt handler. The compiler generates
3749 function entry and exit sequences suitable for use in an interrupt handler
3750 when this attribute is present.
3751
3752 On the AVR, the hardware globally disables interrupts when an
3753 interrupt is executed. The first instruction of an interrupt handler
3754 declared with this attribute is a @code{SEI} instruction to
3755 re-enable interrupts. See also the @code{signal} function attribute
3756 that does not insert a @code{SEI} instruction. If both @code{signal} and
3757 @code{interrupt} are specified for the same function, @code{signal}
3758 is silently ignored.
3759
3760 @item naked
3761 @cindex @code{naked} function attribute, AVR
3762 This attribute allows the compiler to construct the
3763 requisite function declaration, while allowing the body of the
3764 function to be assembly code. The specified function will not have
3765 prologue/epilogue sequences generated by the compiler. Only basic
3766 @code{asm} statements can safely be included in naked functions
3767 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3768 basic @code{asm} and C code may appear to work, they cannot be
3769 depended upon to work reliably and are not supported.
3770
3771 @item OS_main
3772 @itemx OS_task
3773 @cindex @code{OS_main} function attribute, AVR
3774 @cindex @code{OS_task} function attribute, AVR
3775 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3776 do not save/restore any call-saved register in their prologue/epilogue.
3777
3778 The @code{OS_main} attribute can be used when there @emph{is
3779 guarantee} that interrupts are disabled at the time when the function
3780 is entered. This saves resources when the stack pointer has to be
3781 changed to set up a frame for local variables.
3782
3783 The @code{OS_task} attribute can be used when there is @emph{no
3784 guarantee} that interrupts are disabled at that time when the function
3785 is entered like for, e@.g@. task functions in a multi-threading operating
3786 system. In that case, changing the stack pointer register is
3787 guarded by save/clear/restore of the global interrupt enable flag.
3788
3789 The differences to the @code{naked} function attribute are:
3790 @itemize @bullet
3791 @item @code{naked} functions do not have a return instruction whereas
3792 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3793 @code{RETI} return instruction.
3794 @item @code{naked} functions do not set up a frame for local variables
3795 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3796 as needed.
3797 @end itemize
3798
3799 @item signal
3800 @cindex @code{signal} function attribute, AVR
3801 Use this attribute on the AVR to indicate that the specified
3802 function is an interrupt handler. The compiler generates function
3803 entry and exit sequences suitable for use in an interrupt handler when this
3804 attribute is present.
3805
3806 See also the @code{interrupt} function attribute.
3807
3808 The AVR hardware globally disables interrupts when an interrupt is executed.
3809 Interrupt handler functions defined with the @code{signal} attribute
3810 do not re-enable interrupts. It is save to enable interrupts in a
3811 @code{signal} handler. This ``save'' only applies to the code
3812 generated by the compiler and not to the IRQ layout of the
3813 application which is responsibility of the application.
3814
3815 If both @code{signal} and @code{interrupt} are specified for the same
3816 function, @code{signal} is silently ignored.
3817 @end table
3818
3819 @node Blackfin Function Attributes
3820 @subsection Blackfin Function Attributes
3821
3822 These function attributes are supported by the Blackfin back end:
3823
3824 @table @code
3825
3826 @item exception_handler
3827 @cindex @code{exception_handler} function attribute
3828 @cindex exception handler functions, Blackfin
3829 Use this attribute on the Blackfin to indicate that the specified function
3830 is an exception handler. The compiler generates function entry and
3831 exit sequences suitable for use in an exception handler when this
3832 attribute is present.
3833
3834 @item interrupt_handler
3835 @cindex @code{interrupt_handler} function attribute, Blackfin
3836 Use this attribute to
3837 indicate that the specified function is an interrupt handler. The compiler
3838 generates function entry and exit sequences suitable for use in an
3839 interrupt handler when this attribute is present.
3840
3841 @item kspisusp
3842 @cindex @code{kspisusp} function attribute, Blackfin
3843 @cindex User stack pointer in interrupts on the Blackfin
3844 When used together with @code{interrupt_handler}, @code{exception_handler}
3845 or @code{nmi_handler}, code is generated to load the stack pointer
3846 from the USP register in the function prologue.
3847
3848 @item l1_text
3849 @cindex @code{l1_text} function attribute, Blackfin
3850 This attribute specifies a function to be placed into L1 Instruction
3851 SRAM@. The function is put into a specific section named @code{.l1.text}.
3852 With @option{-mfdpic}, function calls with a such function as the callee
3853 or caller uses inlined PLT.
3854
3855 @item l2
3856 @cindex @code{l2} function attribute, Blackfin
3857 This attribute specifies a function to be placed into L2
3858 SRAM. The function is put into a specific section named
3859 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3860 an inlined PLT.
3861
3862 @item longcall
3863 @itemx shortcall
3864 @cindex indirect calls, Blackfin
3865 @cindex @code{longcall} function attribute, Blackfin
3866 @cindex @code{shortcall} function attribute, Blackfin
3867 The @code{longcall} attribute
3868 indicates that the function might be far away from the call site and
3869 require a different (more expensive) calling sequence. The
3870 @code{shortcall} attribute indicates that the function is always close
3871 enough for the shorter calling sequence to be used. These attributes
3872 override the @option{-mlongcall} switch.
3873
3874 @item nesting
3875 @cindex @code{nesting} function attribute, Blackfin
3876 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3877 Use this attribute together with @code{interrupt_handler},
3878 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3879 entry code should enable nested interrupts or exceptions.
3880
3881 @item nmi_handler
3882 @cindex @code{nmi_handler} function attribute, Blackfin
3883 @cindex NMI handler functions on the Blackfin processor
3884 Use this attribute on the Blackfin to indicate that the specified function
3885 is an NMI handler. The compiler generates function entry and
3886 exit sequences suitable for use in an NMI handler when this
3887 attribute is present.
3888
3889 @item saveall
3890 @cindex @code{saveall} function attribute, Blackfin
3891 @cindex save all registers on the Blackfin
3892 Use this attribute to indicate that
3893 all registers except the stack pointer should be saved in the prologue
3894 regardless of whether they are used or not.
3895 @end table
3896
3897 @node CR16 Function Attributes
3898 @subsection CR16 Function Attributes
3899
3900 These function attributes are supported by the CR16 back end:
3901
3902 @table @code
3903 @item interrupt
3904 @cindex @code{interrupt} function attribute, CR16
3905 Use this attribute to indicate
3906 that the specified function is an interrupt handler. The compiler generates
3907 function entry and exit sequences suitable for use in an interrupt handler
3908 when this attribute is present.
3909 @end table
3910
3911 @node Epiphany Function Attributes
3912 @subsection Epiphany Function Attributes
3913
3914 These function attributes are supported by the Epiphany back end:
3915
3916 @table @code
3917 @item disinterrupt
3918 @cindex @code{disinterrupt} function attribute, Epiphany
3919 This attribute causes the compiler to emit
3920 instructions to disable interrupts for the duration of the given
3921 function.
3922
3923 @item forwarder_section
3924 @cindex @code{forwarder_section} function attribute, Epiphany
3925 This attribute modifies the behavior of an interrupt handler.
3926 The interrupt handler may be in external memory which cannot be
3927 reached by a branch instruction, so generate a local memory trampoline
3928 to transfer control. The single parameter identifies the section where
3929 the trampoline is placed.
3930
3931 @item interrupt
3932 @cindex @code{interrupt} function attribute, Epiphany
3933 Use this attribute to indicate
3934 that the specified function is an interrupt handler. The compiler generates
3935 function entry and exit sequences suitable for use in an interrupt handler
3936 when this attribute is present. It may also generate
3937 a special section with code to initialize the interrupt vector table.
3938
3939 On Epiphany targets one or more optional parameters can be added like this:
3940
3941 @smallexample
3942 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3943 @end smallexample
3944
3945 Permissible values for these parameters are: @w{@code{reset}},
3946 @w{@code{software_exception}}, @w{@code{page_miss}},
3947 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3948 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3949 Multiple parameters indicate that multiple entries in the interrupt
3950 vector table should be initialized for this function, i.e.@: for each
3951 parameter @w{@var{name}}, a jump to the function is emitted in
3952 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3953 entirely, in which case no interrupt vector table entry is provided.
3954
3955 Note that interrupts are enabled inside the function
3956 unless the @code{disinterrupt} attribute is also specified.
3957
3958 The following examples are all valid uses of these attributes on
3959 Epiphany targets:
3960 @smallexample
3961 void __attribute__ ((interrupt)) universal_handler ();
3962 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3963 void __attribute__ ((interrupt ("dma0, dma1")))
3964 universal_dma_handler ();
3965 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3966 fast_timer_handler ();
3967 void __attribute__ ((interrupt ("dma0, dma1"),
3968 forwarder_section ("tramp")))
3969 external_dma_handler ();
3970 @end smallexample
3971
3972 @item long_call
3973 @itemx short_call
3974 @cindex @code{long_call} function attribute, Epiphany
3975 @cindex @code{short_call} function attribute, Epiphany
3976 @cindex indirect calls, Epiphany
3977 These attributes specify how a particular function is called.
3978 These attributes override the
3979 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3980 command-line switch and @code{#pragma long_calls} settings.
3981 @end table
3982
3983
3984 @node H8/300 Function Attributes
3985 @subsection H8/300 Function Attributes
3986
3987 These function attributes are available for H8/300 targets:
3988
3989 @table @code
3990 @item function_vector
3991 @cindex @code{function_vector} function attribute, H8/300
3992 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3993 that the specified function should be called through the function vector.
3994 Calling a function through the function vector reduces code size; however,
3995 the function vector has a limited size (maximum 128 entries on the H8/300
3996 and 64 entries on the H8/300H and H8S)
3997 and shares space with the interrupt vector.
3998
3999 @item interrupt_handler
4000 @cindex @code{interrupt_handler} function attribute, H8/300
4001 Use this attribute on the H8/300, H8/300H, and H8S to
4002 indicate that the specified function is an interrupt handler. The compiler
4003 generates function entry and exit sequences suitable for use in an
4004 interrupt handler when this attribute is present.
4005
4006 @item saveall
4007 @cindex @code{saveall} function attribute, H8/300
4008 @cindex save all registers on the H8/300, H8/300H, and H8S
4009 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4010 all registers except the stack pointer should be saved in the prologue
4011 regardless of whether they are used or not.
4012 @end table
4013
4014 @node IA-64 Function Attributes
4015 @subsection IA-64 Function Attributes
4016
4017 These function attributes are supported on IA-64 targets:
4018
4019 @table @code
4020 @item syscall_linkage
4021 @cindex @code{syscall_linkage} function attribute, IA-64
4022 This attribute is used to modify the IA-64 calling convention by marking
4023 all input registers as live at all function exits. This makes it possible
4024 to restart a system call after an interrupt without having to save/restore
4025 the input registers. This also prevents kernel data from leaking into
4026 application code.
4027
4028 @item version_id
4029 @cindex @code{version_id} function attribute, IA-64
4030 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4031 symbol to contain a version string, thus allowing for function level
4032 versioning. HP-UX system header files may use function level versioning
4033 for some system calls.
4034
4035 @smallexample
4036 extern int foo () __attribute__((version_id ("20040821")));
4037 @end smallexample
4038
4039 @noindent
4040 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4041 @end table
4042
4043 @node M32C Function Attributes
4044 @subsection M32C Function Attributes
4045
4046 These function attributes are supported by the M32C back end:
4047
4048 @table @code
4049 @item bank_switch
4050 @cindex @code{bank_switch} function attribute, M32C
4051 When added to an interrupt handler with the M32C port, causes the
4052 prologue and epilogue to use bank switching to preserve the registers
4053 rather than saving them on the stack.
4054
4055 @item fast_interrupt
4056 @cindex @code{fast_interrupt} function attribute, M32C
4057 Use this attribute on the M32C port to indicate that the specified
4058 function is a fast interrupt handler. This is just like the
4059 @code{interrupt} attribute, except that @code{freit} is used to return
4060 instead of @code{reit}.
4061
4062 @item function_vector
4063 @cindex @code{function_vector} function attribute, M16C/M32C
4064 On M16C/M32C targets, the @code{function_vector} attribute declares a
4065 special page subroutine call function. Use of this attribute reduces
4066 the code size by 2 bytes for each call generated to the
4067 subroutine. The argument to the attribute is the vector number entry
4068 from the special page vector table which contains the 16 low-order
4069 bits of the subroutine's entry address. Each vector table has special
4070 page number (18 to 255) that is used in @code{jsrs} instructions.
4071 Jump addresses of the routines are generated by adding 0x0F0000 (in
4072 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4073 2-byte addresses set in the vector table. Therefore you need to ensure
4074 that all the special page vector routines should get mapped within the
4075 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4076 (for M32C).
4077
4078 In the following example 2 bytes are saved for each call to
4079 function @code{foo}.
4080
4081 @smallexample
4082 void foo (void) __attribute__((function_vector(0x18)));
4083 void foo (void)
4084 @{
4085 @}
4086
4087 void bar (void)
4088 @{
4089 foo();
4090 @}
4091 @end smallexample
4092
4093 If functions are defined in one file and are called in another file,
4094 then be sure to write this declaration in both files.
4095
4096 This attribute is ignored for R8C target.
4097
4098 @item interrupt
4099 @cindex @code{interrupt} function attribute, M32C
4100 Use this attribute to indicate
4101 that the specified function is an interrupt handler. The compiler generates
4102 function entry and exit sequences suitable for use in an interrupt handler
4103 when this attribute is present.
4104 @end table
4105
4106 @node M32R/D Function Attributes
4107 @subsection M32R/D Function Attributes
4108
4109 These function attributes are supported by the M32R/D back end:
4110
4111 @table @code
4112 @item interrupt
4113 @cindex @code{interrupt} function attribute, M32R/D
4114 Use this attribute to indicate
4115 that the specified function is an interrupt handler. The compiler generates
4116 function entry and exit sequences suitable for use in an interrupt handler
4117 when this attribute is present.
4118
4119 @item model (@var{model-name})
4120 @cindex @code{model} function attribute, M32R/D
4121 @cindex function addressability on the M32R/D
4122
4123 On the M32R/D, use this attribute to set the addressability of an
4124 object, and of the code generated for a function. The identifier
4125 @var{model-name} is one of @code{small}, @code{medium}, or
4126 @code{large}, representing each of the code models.
4127
4128 Small model objects live in the lower 16MB of memory (so that their
4129 addresses can be loaded with the @code{ld24} instruction), and are
4130 callable with the @code{bl} instruction.
4131
4132 Medium model objects may live anywhere in the 32-bit address space (the
4133 compiler generates @code{seth/add3} instructions to load their addresses),
4134 and are callable with the @code{bl} instruction.
4135
4136 Large model objects may live anywhere in the 32-bit address space (the
4137 compiler generates @code{seth/add3} instructions to load their addresses),
4138 and may not be reachable with the @code{bl} instruction (the compiler
4139 generates the much slower @code{seth/add3/jl} instruction sequence).
4140 @end table
4141
4142 @node m68k Function Attributes
4143 @subsection m68k Function Attributes
4144
4145 These function attributes are supported by the m68k back end:
4146
4147 @table @code
4148 @item interrupt
4149 @itemx interrupt_handler
4150 @cindex @code{interrupt} function attribute, m68k
4151 @cindex @code{interrupt_handler} function attribute, m68k
4152 Use this attribute to
4153 indicate that the specified function is an interrupt handler. The compiler
4154 generates function entry and exit sequences suitable for use in an
4155 interrupt handler when this attribute is present. Either name may be used.
4156
4157 @item interrupt_thread
4158 @cindex @code{interrupt_thread} function attribute, fido
4159 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4160 that the specified function is an interrupt handler that is designed
4161 to run as a thread. The compiler omits generate prologue/epilogue
4162 sequences and replaces the return instruction with a @code{sleep}
4163 instruction. This attribute is available only on fido.
4164 @end table
4165
4166 @node MCORE Function Attributes
4167 @subsection MCORE Function Attributes
4168
4169 These function attributes are supported by the MCORE back end:
4170
4171 @table @code
4172 @item naked
4173 @cindex @code{naked} function attribute, MCORE
4174 This attribute allows the compiler to construct the
4175 requisite function declaration, while allowing the body of the
4176 function to be assembly code. The specified function will not have
4177 prologue/epilogue sequences generated by the compiler. Only basic
4178 @code{asm} statements can safely be included in naked functions
4179 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4180 basic @code{asm} and C code may appear to work, they cannot be
4181 depended upon to work reliably and are not supported.
4182 @end table
4183
4184 @node MeP Function Attributes
4185 @subsection MeP Function Attributes
4186
4187 These function attributes are supported by the MeP back end:
4188
4189 @table @code
4190 @item disinterrupt
4191 @cindex @code{disinterrupt} function attribute, MeP
4192 On MeP targets, this attribute causes the compiler to emit
4193 instructions to disable interrupts for the duration of the given
4194 function.
4195
4196 @item interrupt
4197 @cindex @code{interrupt} function attribute, MeP
4198 Use this attribute to indicate
4199 that the specified function is an interrupt handler. The compiler generates
4200 function entry and exit sequences suitable for use in an interrupt handler
4201 when this attribute is present.
4202
4203 @item near
4204 @cindex @code{near} function attribute, MeP
4205 This attribute causes the compiler to assume the called
4206 function is close enough to use the normal calling convention,
4207 overriding the @option{-mtf} command-line option.
4208
4209 @item far
4210 @cindex @code{far} function attribute, MeP
4211 On MeP targets this causes the compiler to use a calling convention
4212 that assumes the called function is too far away for the built-in
4213 addressing modes.
4214
4215 @item vliw
4216 @cindex @code{vliw} function attribute, MeP
4217 The @code{vliw} attribute tells the compiler to emit
4218 instructions in VLIW mode instead of core mode. Note that this
4219 attribute is not allowed unless a VLIW coprocessor has been configured
4220 and enabled through command-line options.
4221 @end table
4222
4223 @node MicroBlaze Function Attributes
4224 @subsection MicroBlaze Function Attributes
4225
4226 These function attributes are supported on MicroBlaze targets:
4227
4228 @table @code
4229 @item save_volatiles
4230 @cindex @code{save_volatiles} function attribute, MicroBlaze
4231 Use this attribute to indicate that the function is
4232 an interrupt handler. All volatile registers (in addition to non-volatile
4233 registers) are saved in the function prologue. If the function is a leaf
4234 function, only volatiles used by the function are saved. A normal function
4235 return is generated instead of a return from interrupt.
4236
4237 @item break_handler
4238 @cindex @code{break_handler} function attribute, MicroBlaze
4239 @cindex break handler functions
4240 Use this attribute to indicate that
4241 the specified function is a break handler. The compiler generates function
4242 entry and exit sequences suitable for use in an break handler when this
4243 attribute is present. The return from @code{break_handler} is done through
4244 the @code{rtbd} instead of @code{rtsd}.
4245
4246 @smallexample
4247 void f () __attribute__ ((break_handler));
4248 @end smallexample
4249
4250 @item interrupt_handler
4251 @itemx fast_interrupt
4252 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4253 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4254 These attributes indicate that the specified function is an interrupt
4255 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4256 used in low-latency interrupt mode, and @code{interrupt_handler} for
4257 interrupts that do not use low-latency handlers. In both cases, GCC
4258 emits appropriate prologue code and generates a return from the handler
4259 using @code{rtid} instead of @code{rtsd}.
4260 @end table
4261
4262 @node Microsoft Windows Function Attributes
4263 @subsection Microsoft Windows Function Attributes
4264
4265 The following attributes are available on Microsoft Windows and Symbian OS
4266 targets.
4267
4268 @table @code
4269 @item dllexport
4270 @cindex @code{dllexport} function attribute
4271 @cindex @code{__declspec(dllexport)}
4272 On Microsoft Windows targets and Symbian OS targets the
4273 @code{dllexport} attribute causes the compiler to provide a global
4274 pointer to a pointer in a DLL, so that it can be referenced with the
4275 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4276 name is formed by combining @code{_imp__} and the function or variable
4277 name.
4278
4279 You can use @code{__declspec(dllexport)} as a synonym for
4280 @code{__attribute__ ((dllexport))} for compatibility with other
4281 compilers.
4282
4283 On systems that support the @code{visibility} attribute, this
4284 attribute also implies ``default'' visibility. It is an error to
4285 explicitly specify any other visibility.
4286
4287 GCC's default behavior is to emit all inline functions with the
4288 @code{dllexport} attribute. Since this can cause object file-size bloat,
4289 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4290 ignore the attribute for inlined functions unless the
4291 @option{-fkeep-inline-functions} flag is used instead.
4292
4293 The attribute is ignored for undefined symbols.
4294
4295 When applied to C++ classes, the attribute marks defined non-inlined
4296 member functions and static data members as exports. Static consts
4297 initialized in-class are not marked unless they are also defined
4298 out-of-class.
4299
4300 For Microsoft Windows targets there are alternative methods for
4301 including the symbol in the DLL's export table such as using a
4302 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4303 the @option{--export-all} linker flag.
4304
4305 @item dllimport
4306 @cindex @code{dllimport} function attribute
4307 @cindex @code{__declspec(dllimport)}
4308 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4309 attribute causes the compiler to reference a function or variable via
4310 a global pointer to a pointer that is set up by the DLL exporting the
4311 symbol. The attribute implies @code{extern}. On Microsoft Windows
4312 targets, the pointer name is formed by combining @code{_imp__} and the
4313 function or variable name.
4314
4315 You can use @code{__declspec(dllimport)} as a synonym for
4316 @code{__attribute__ ((dllimport))} for compatibility with other
4317 compilers.
4318
4319 On systems that support the @code{visibility} attribute, this
4320 attribute also implies ``default'' visibility. It is an error to
4321 explicitly specify any other visibility.
4322
4323 Currently, the attribute is ignored for inlined functions. If the
4324 attribute is applied to a symbol @emph{definition}, an error is reported.
4325 If a symbol previously declared @code{dllimport} is later defined, the
4326 attribute is ignored in subsequent references, and a warning is emitted.
4327 The attribute is also overridden by a subsequent declaration as
4328 @code{dllexport}.
4329
4330 When applied to C++ classes, the attribute marks non-inlined
4331 member functions and static data members as imports. However, the
4332 attribute is ignored for virtual methods to allow creation of vtables
4333 using thunks.
4334
4335 On the SH Symbian OS target the @code{dllimport} attribute also has
4336 another affect---it can cause the vtable and run-time type information
4337 for a class to be exported. This happens when the class has a
4338 dllimported constructor or a non-inline, non-pure virtual function
4339 and, for either of those two conditions, the class also has an inline
4340 constructor or destructor and has a key function that is defined in
4341 the current translation unit.
4342
4343 For Microsoft Windows targets the use of the @code{dllimport}
4344 attribute on functions is not necessary, but provides a small
4345 performance benefit by eliminating a thunk in the DLL@. The use of the
4346 @code{dllimport} attribute on imported variables can be avoided by passing the
4347 @option{--enable-auto-import} switch to the GNU linker. As with
4348 functions, using the attribute for a variable eliminates a thunk in
4349 the DLL@.
4350
4351 One drawback to using this attribute is that a pointer to a
4352 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4353 address. However, a pointer to a @emph{function} with the
4354 @code{dllimport} attribute can be used as a constant initializer; in
4355 this case, the address of a stub function in the import lib is
4356 referenced. On Microsoft Windows targets, the attribute can be disabled
4357 for functions by setting the @option{-mnop-fun-dllimport} flag.
4358 @end table
4359
4360 @node MIPS Function Attributes
4361 @subsection MIPS Function Attributes
4362
4363 These function attributes are supported by the MIPS back end:
4364
4365 @table @code
4366 @item interrupt
4367 @cindex @code{interrupt} function attribute, MIPS
4368 Use this attribute to indicate that the specified function is an interrupt
4369 handler. The compiler generates function entry and exit sequences suitable
4370 for use in an interrupt handler when this attribute is present.
4371 An optional argument is supported for the interrupt attribute which allows
4372 the interrupt mode to be described. By default GCC assumes the external
4373 interrupt controller (EIC) mode is in use, this can be explicitly set using
4374 @code{eic}. When interrupts are non-masked then the requested Interrupt
4375 Priority Level (IPL) is copied to the current IPL which has the effect of only
4376 enabling higher priority interrupts. To use vectored interrupt mode use
4377 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4378 the behavior of the non-masked interrupt support and GCC will arrange to mask
4379 all interrupts from sw0 up to and including the specified interrupt vector.
4380
4381 You can use the following attributes to modify the behavior
4382 of an interrupt handler:
4383 @table @code
4384 @item use_shadow_register_set
4385 @cindex @code{use_shadow_register_set} function attribute, MIPS
4386 Assume that the handler uses a shadow register set, instead of
4387 the main general-purpose registers. An optional argument @code{intstack} is
4388 supported to indicate that the shadow register set contains a valid stack
4389 pointer.
4390
4391 @item keep_interrupts_masked
4392 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4393 Keep interrupts masked for the whole function. Without this attribute,
4394 GCC tries to reenable interrupts for as much of the function as it can.
4395
4396 @item use_debug_exception_return
4397 @cindex @code{use_debug_exception_return} function attribute, MIPS
4398 Return using the @code{deret} instruction. Interrupt handlers that don't
4399 have this attribute return using @code{eret} instead.
4400 @end table
4401
4402 You can use any combination of these attributes, as shown below:
4403 @smallexample
4404 void __attribute__ ((interrupt)) v0 ();
4405 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4406 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4407 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4408 void __attribute__ ((interrupt, use_shadow_register_set,
4409 keep_interrupts_masked)) v4 ();
4410 void __attribute__ ((interrupt, use_shadow_register_set,
4411 use_debug_exception_return)) v5 ();
4412 void __attribute__ ((interrupt, keep_interrupts_masked,
4413 use_debug_exception_return)) v6 ();
4414 void __attribute__ ((interrupt, use_shadow_register_set,
4415 keep_interrupts_masked,
4416 use_debug_exception_return)) v7 ();
4417 void __attribute__ ((interrupt("eic"))) v8 ();
4418 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4419 @end smallexample
4420
4421 @item long_call
4422 @itemx near
4423 @itemx far
4424 @cindex indirect calls, MIPS
4425 @cindex @code{long_call} function attribute, MIPS
4426 @cindex @code{near} function attribute, MIPS
4427 @cindex @code{far} function attribute, MIPS
4428 These attributes specify how a particular function is called on MIPS@.
4429 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4430 command-line switch. The @code{long_call} and @code{far} attributes are
4431 synonyms, and cause the compiler to always call
4432 the function by first loading its address into a register, and then using
4433 the contents of that register. The @code{near} attribute has the opposite
4434 effect; it specifies that non-PIC calls should be made using the more
4435 efficient @code{jal} instruction.
4436
4437 @item mips16
4438 @itemx nomips16
4439 @cindex @code{mips16} function attribute, MIPS
4440 @cindex @code{nomips16} function attribute, MIPS
4441
4442 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4443 function attributes to locally select or turn off MIPS16 code generation.
4444 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4445 while MIPS16 code generation is disabled for functions with the
4446 @code{nomips16} attribute. These attributes override the
4447 @option{-mips16} and @option{-mno-mips16} options on the command line
4448 (@pxref{MIPS Options}).
4449
4450 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4451 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4452 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4453 may interact badly with some GCC extensions such as @code{__builtin_apply}
4454 (@pxref{Constructing Calls}).
4455
4456 @item micromips, MIPS
4457 @itemx nomicromips, MIPS
4458 @cindex @code{micromips} function attribute
4459 @cindex @code{nomicromips} function attribute
4460
4461 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4462 function attributes to locally select or turn off microMIPS code generation.
4463 A function with the @code{micromips} attribute is emitted as microMIPS code,
4464 while microMIPS code generation is disabled for functions with the
4465 @code{nomicromips} attribute. These attributes override the
4466 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4467 (@pxref{MIPS Options}).
4468
4469 When compiling files containing mixed microMIPS and non-microMIPS code, the
4470 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4471 command line,
4472 not that within individual functions. Mixed microMIPS and non-microMIPS code
4473 may interact badly with some GCC extensions such as @code{__builtin_apply}
4474 (@pxref{Constructing Calls}).
4475
4476 @item nocompression
4477 @cindex @code{nocompression} function attribute, MIPS
4478 On MIPS targets, you can use the @code{nocompression} function attribute
4479 to locally turn off MIPS16 and microMIPS code generation. This attribute
4480 overrides the @option{-mips16} and @option{-mmicromips} options on the
4481 command line (@pxref{MIPS Options}).
4482 @end table
4483
4484 @node MSP430 Function Attributes
4485 @subsection MSP430 Function Attributes
4486
4487 These function attributes are supported by the MSP430 back end:
4488
4489 @table @code
4490 @item critical
4491 @cindex @code{critical} function attribute, MSP430
4492 Critical functions disable interrupts upon entry and restore the
4493 previous interrupt state upon exit. Critical functions cannot also
4494 have the @code{naked} or @code{reentrant} attributes. They can have
4495 the @code{interrupt} attribute.
4496
4497 @item interrupt
4498 @cindex @code{interrupt} function attribute, MSP430
4499 Use this attribute to indicate
4500 that the specified function is an interrupt handler. The compiler generates
4501 function entry and exit sequences suitable for use in an interrupt handler
4502 when this attribute is present.
4503
4504 You can provide an argument to the interrupt
4505 attribute which specifies a name or number. If the argument is a
4506 number it indicates the slot in the interrupt vector table (0 - 31) to
4507 which this handler should be assigned. If the argument is a name it
4508 is treated as a symbolic name for the vector slot. These names should
4509 match up with appropriate entries in the linker script. By default
4510 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4511 @code{reset} for vector 31 are recognized.
4512
4513 @item naked
4514 @cindex @code{naked} function attribute, MSP430
4515 This attribute allows the compiler to construct the
4516 requisite function declaration, while allowing the body of the
4517 function to be assembly code. The specified function will not have
4518 prologue/epilogue sequences generated by the compiler. Only basic
4519 @code{asm} statements can safely be included in naked functions
4520 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4521 basic @code{asm} and C code may appear to work, they cannot be
4522 depended upon to work reliably and are not supported.
4523
4524 @item reentrant
4525 @cindex @code{reentrant} function attribute, MSP430
4526 Reentrant functions disable interrupts upon entry and enable them
4527 upon exit. Reentrant functions cannot also have the @code{naked}
4528 or @code{critical} attributes. They can have the @code{interrupt}
4529 attribute.
4530
4531 @item wakeup
4532 @cindex @code{wakeup} function attribute, MSP430
4533 This attribute only applies to interrupt functions. It is silently
4534 ignored if applied to a non-interrupt function. A wakeup interrupt
4535 function will rouse the processor from any low-power state that it
4536 might be in when the function exits.
4537
4538 @item lower
4539 @itemx upper
4540 @itemx either
4541 @cindex @code{lower} function attribute, MSP430
4542 @cindex @code{upper} function attribute, MSP430
4543 @cindex @code{either} function attribute, MSP430
4544 On the MSP430 target these attributes can be used to specify whether
4545 the function or variable should be placed into low memory, high
4546 memory, or the placement should be left to the linker to decide. The
4547 attributes are only significant if compiling for the MSP430X
4548 architecture.
4549
4550 The attributes work in conjunction with a linker script that has been
4551 augmented to specify where to place sections with a @code{.lower} and
4552 a @code{.upper} prefix. So, for example, as well as placing the
4553 @code{.data} section, the script also specifies the placement of a
4554 @code{.lower.data} and a @code{.upper.data} section. The intention
4555 is that @code{lower} sections are placed into a small but easier to
4556 access memory region and the upper sections are placed into a larger, but
4557 slower to access, region.
4558
4559 The @code{either} attribute is special. It tells the linker to place
4560 the object into the corresponding @code{lower} section if there is
4561 room for it. If there is insufficient room then the object is placed
4562 into the corresponding @code{upper} section instead. Note that the
4563 placement algorithm is not very sophisticated. It does not attempt to
4564 find an optimal packing of the @code{lower} sections. It just makes
4565 one pass over the objects and does the best that it can. Using the
4566 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4567 options can help the packing, however, since they produce smaller,
4568 easier to pack regions.
4569 @end table
4570
4571 @node NDS32 Function Attributes
4572 @subsection NDS32 Function Attributes
4573
4574 These function attributes are supported by the NDS32 back end:
4575
4576 @table @code
4577 @item exception
4578 @cindex @code{exception} function attribute
4579 @cindex exception handler functions, NDS32
4580 Use this attribute on the NDS32 target to indicate that the specified function
4581 is an exception handler. The compiler will generate corresponding sections
4582 for use in an exception handler.
4583
4584 @item interrupt
4585 @cindex @code{interrupt} function attribute, NDS32
4586 On NDS32 target, this attribute indicates that the specified function
4587 is an interrupt handler. The compiler generates corresponding sections
4588 for use in an interrupt handler. You can use the following attributes
4589 to modify the behavior:
4590 @table @code
4591 @item nested
4592 @cindex @code{nested} function attribute, NDS32
4593 This interrupt service routine is interruptible.
4594 @item not_nested
4595 @cindex @code{not_nested} function attribute, NDS32
4596 This interrupt service routine is not interruptible.
4597 @item nested_ready
4598 @cindex @code{nested_ready} function attribute, NDS32
4599 This interrupt service routine is interruptible after @code{PSW.GIE}
4600 (global interrupt enable) is set. This allows interrupt service routine to
4601 finish some short critical code before enabling interrupts.
4602 @item save_all
4603 @cindex @code{save_all} function attribute, NDS32
4604 The system will help save all registers into stack before entering
4605 interrupt handler.
4606 @item partial_save
4607 @cindex @code{partial_save} function attribute, NDS32
4608 The system will help save caller registers into stack before entering
4609 interrupt handler.
4610 @end table
4611
4612 @item naked
4613 @cindex @code{naked} function attribute, NDS32
4614 This attribute allows the compiler to construct the
4615 requisite function declaration, while allowing the body of the
4616 function to be assembly code. The specified function will not have
4617 prologue/epilogue sequences generated by the compiler. Only basic
4618 @code{asm} statements can safely be included in naked functions
4619 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4620 basic @code{asm} and C code may appear to work, they cannot be
4621 depended upon to work reliably and are not supported.
4622
4623 @item reset
4624 @cindex @code{reset} function attribute, NDS32
4625 @cindex reset handler functions
4626 Use this attribute on the NDS32 target to indicate that the specified function
4627 is a reset handler. The compiler will generate corresponding sections
4628 for use in a reset handler. You can use the following attributes
4629 to provide extra exception handling:
4630 @table @code
4631 @item nmi
4632 @cindex @code{nmi} function attribute, NDS32
4633 Provide a user-defined function to handle NMI exception.
4634 @item warm
4635 @cindex @code{warm} function attribute, NDS32
4636 Provide a user-defined function to handle warm reset exception.
4637 @end table
4638 @end table
4639
4640 @node Nios II Function Attributes
4641 @subsection Nios II Function Attributes
4642
4643 These function attributes are supported by the Nios II back end:
4644
4645 @table @code
4646 @item target (@var{options})
4647 @cindex @code{target} function attribute
4648 As discussed in @ref{Common Function Attributes}, this attribute
4649 allows specification of target-specific compilation options.
4650
4651 When compiling for Nios II, the following options are allowed:
4652
4653 @table @samp
4654 @item custom-@var{insn}=@var{N}
4655 @itemx no-custom-@var{insn}
4656 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4657 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4658 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4659 custom instruction with encoding @var{N} when generating code that uses
4660 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4661 the custom instruction @var{insn}.
4662 These target attributes correspond to the
4663 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4664 command-line options, and support the same set of @var{insn} keywords.
4665 @xref{Nios II Options}, for more information.
4666
4667 @item custom-fpu-cfg=@var{name}
4668 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4669 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4670 command-line option, to select a predefined set of custom instructions
4671 named @var{name}.
4672 @xref{Nios II Options}, for more information.
4673 @end table
4674 @end table
4675
4676 @node Nvidia PTX Function Attributes
4677 @subsection Nvidia PTX Function Attributes
4678
4679 These function attributes are supported by the Nvidia PTX back end:
4680
4681 @table @code
4682 @item kernel
4683 @cindex @code{kernel} attribute, Nvidia PTX
4684 This attribute indicates that the corresponding function should be compiled
4685 as a kernel function, which can be invoked from the host via the CUDA RT
4686 library.
4687 By default functions are only callable only from other PTX functions.
4688
4689 Kernel functions must have @code{void} return type.
4690 @end table
4691
4692 @node PowerPC Function Attributes
4693 @subsection PowerPC Function Attributes
4694
4695 These function attributes are supported by the PowerPC back end:
4696
4697 @table @code
4698 @item longcall
4699 @itemx shortcall
4700 @cindex indirect calls, PowerPC
4701 @cindex @code{longcall} function attribute, PowerPC
4702 @cindex @code{shortcall} function attribute, PowerPC
4703 The @code{longcall} attribute
4704 indicates that the function might be far away from the call site and
4705 require a different (more expensive) calling sequence. The
4706 @code{shortcall} attribute indicates that the function is always close
4707 enough for the shorter calling sequence to be used. These attributes
4708 override both the @option{-mlongcall} switch and
4709 the @code{#pragma longcall} setting.
4710
4711 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4712 calls are necessary.
4713
4714 @item target (@var{options})
4715 @cindex @code{target} function attribute
4716 As discussed in @ref{Common Function Attributes}, this attribute
4717 allows specification of target-specific compilation options.
4718
4719 On the PowerPC, the following options are allowed:
4720
4721 @table @samp
4722 @item altivec
4723 @itemx no-altivec
4724 @cindex @code{target("altivec")} function attribute, PowerPC
4725 Generate code that uses (does not use) AltiVec instructions. In
4726 32-bit code, you cannot enable AltiVec instructions unless
4727 @option{-mabi=altivec} is used on the command line.
4728
4729 @item cmpb
4730 @itemx no-cmpb
4731 @cindex @code{target("cmpb")} function attribute, PowerPC
4732 Generate code that uses (does not use) the compare bytes instruction
4733 implemented on the POWER6 processor and other processors that support
4734 the PowerPC V2.05 architecture.
4735
4736 @item dlmzb
4737 @itemx no-dlmzb
4738 @cindex @code{target("dlmzb")} function attribute, PowerPC
4739 Generate code that uses (does not use) the string-search @samp{dlmzb}
4740 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4741 generated by default when targeting those processors.
4742
4743 @item fprnd
4744 @itemx no-fprnd
4745 @cindex @code{target("fprnd")} function attribute, PowerPC
4746 Generate code that uses (does not use) the FP round to integer
4747 instructions implemented on the POWER5+ processor and other processors
4748 that support the PowerPC V2.03 architecture.
4749
4750 @item hard-dfp
4751 @itemx no-hard-dfp
4752 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4753 Generate code that uses (does not use) the decimal floating-point
4754 instructions implemented on some POWER processors.
4755
4756 @item isel
4757 @itemx no-isel
4758 @cindex @code{target("isel")} function attribute, PowerPC
4759 Generate code that uses (does not use) ISEL instruction.
4760
4761 @item mfcrf
4762 @itemx no-mfcrf
4763 @cindex @code{target("mfcrf")} function attribute, PowerPC
4764 Generate code that uses (does not use) the move from condition
4765 register field instruction implemented on the POWER4 processor and
4766 other processors that support the PowerPC V2.01 architecture.
4767
4768 @item mfpgpr
4769 @itemx no-mfpgpr
4770 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4771 Generate code that uses (does not use) the FP move to/from general
4772 purpose register instructions implemented on the POWER6X processor and
4773 other processors that support the extended PowerPC V2.05 architecture.
4774
4775 @item mulhw
4776 @itemx no-mulhw
4777 @cindex @code{target("mulhw")} function attribute, PowerPC
4778 Generate code that uses (does not use) the half-word multiply and
4779 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4780 These instructions are generated by default when targeting those
4781 processors.
4782
4783 @item multiple
4784 @itemx no-multiple
4785 @cindex @code{target("multiple")} function attribute, PowerPC
4786 Generate code that uses (does not use) the load multiple word
4787 instructions and the store multiple word instructions.
4788
4789 @item update
4790 @itemx no-update
4791 @cindex @code{target("update")} function attribute, PowerPC
4792 Generate code that uses (does not use) the load or store instructions
4793 that update the base register to the address of the calculated memory
4794 location.
4795
4796 @item popcntb
4797 @itemx no-popcntb
4798 @cindex @code{target("popcntb")} function attribute, PowerPC
4799 Generate code that uses (does not use) the popcount and double-precision
4800 FP reciprocal estimate instruction implemented on the POWER5
4801 processor and other processors that support the PowerPC V2.02
4802 architecture.
4803
4804 @item popcntd
4805 @itemx no-popcntd
4806 @cindex @code{target("popcntd")} function attribute, PowerPC
4807 Generate code that uses (does not use) the popcount instruction
4808 implemented on the POWER7 processor and other processors that support
4809 the PowerPC V2.06 architecture.
4810
4811 @item powerpc-gfxopt
4812 @itemx no-powerpc-gfxopt
4813 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4814 Generate code that uses (does not use) the optional PowerPC
4815 architecture instructions in the Graphics group, including
4816 floating-point select.
4817
4818 @item powerpc-gpopt
4819 @itemx no-powerpc-gpopt
4820 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4821 Generate code that uses (does not use) the optional PowerPC
4822 architecture instructions in the General Purpose group, including
4823 floating-point square root.
4824
4825 @item recip-precision
4826 @itemx no-recip-precision
4827 @cindex @code{target("recip-precision")} function attribute, PowerPC
4828 Assume (do not assume) that the reciprocal estimate instructions
4829 provide higher-precision estimates than is mandated by the PowerPC
4830 ABI.
4831
4832 @item string
4833 @itemx no-string
4834 @cindex @code{target("string")} function attribute, PowerPC
4835 Generate code that uses (does not use) the load string instructions
4836 and the store string word instructions to save multiple registers and
4837 do small block moves.
4838
4839 @item vsx
4840 @itemx no-vsx
4841 @cindex @code{target("vsx")} function attribute, PowerPC
4842 Generate code that uses (does not use) vector/scalar (VSX)
4843 instructions, and also enable the use of built-in functions that allow
4844 more direct access to the VSX instruction set. In 32-bit code, you
4845 cannot enable VSX or AltiVec instructions unless
4846 @option{-mabi=altivec} is used on the command line.
4847
4848 @item friz
4849 @itemx no-friz
4850 @cindex @code{target("friz")} function attribute, PowerPC
4851 Generate (do not generate) the @code{friz} instruction when the
4852 @option{-funsafe-math-optimizations} option is used to optimize
4853 rounding a floating-point value to 64-bit integer and back to floating
4854 point. The @code{friz} instruction does not return the same value if
4855 the floating-point number is too large to fit in an integer.
4856
4857 @item avoid-indexed-addresses
4858 @itemx no-avoid-indexed-addresses
4859 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4860 Generate code that tries to avoid (not avoid) the use of indexed load
4861 or store instructions.
4862
4863 @item paired
4864 @itemx no-paired
4865 @cindex @code{target("paired")} function attribute, PowerPC
4866 Generate code that uses (does not use) the generation of PAIRED simd
4867 instructions.
4868
4869 @item longcall
4870 @itemx no-longcall
4871 @cindex @code{target("longcall")} function attribute, PowerPC
4872 Generate code that assumes (does not assume) that all calls are far
4873 away so that a longer more expensive calling sequence is required.
4874
4875 @item cpu=@var{CPU}
4876 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4877 Specify the architecture to generate code for when compiling the
4878 function. If you select the @code{target("cpu=power7")} attribute when
4879 generating 32-bit code, VSX and AltiVec instructions are not generated
4880 unless you use the @option{-mabi=altivec} option on the command line.
4881
4882 @item tune=@var{TUNE}
4883 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4884 Specify the architecture to tune for when compiling the function. If
4885 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4886 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4887 compilation tunes for the @var{CPU} architecture, and not the
4888 default tuning specified on the command line.
4889 @end table
4890
4891 On the PowerPC, the inliner does not inline a
4892 function that has different target options than the caller, unless the
4893 callee has a subset of the target options of the caller.
4894 @end table
4895
4896 @node RL78 Function Attributes
4897 @subsection RL78 Function Attributes
4898
4899 These function attributes are supported by the RL78 back end:
4900
4901 @table @code
4902 @item interrupt
4903 @itemx brk_interrupt
4904 @cindex @code{interrupt} function attribute, RL78
4905 @cindex @code{brk_interrupt} function attribute, RL78
4906 These attributes indicate
4907 that the specified function is an interrupt handler. The compiler generates
4908 function entry and exit sequences suitable for use in an interrupt handler
4909 when this attribute is present.
4910
4911 Use @code{brk_interrupt} instead of @code{interrupt} for
4912 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4913 that must end with @code{RETB} instead of @code{RETI}).
4914
4915 @item naked
4916 @cindex @code{naked} function attribute, RL78
4917 This attribute allows the compiler to construct the
4918 requisite function declaration, while allowing the body of the
4919 function to be assembly code. The specified function will not have
4920 prologue/epilogue sequences generated by the compiler. Only basic
4921 @code{asm} statements can safely be included in naked functions
4922 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4923 basic @code{asm} and C code may appear to work, they cannot be
4924 depended upon to work reliably and are not supported.
4925 @end table
4926
4927 @node RX Function Attributes
4928 @subsection RX Function Attributes
4929
4930 These function attributes are supported by the RX back end:
4931
4932 @table @code
4933 @item fast_interrupt
4934 @cindex @code{fast_interrupt} function attribute, RX
4935 Use this attribute on the RX port to indicate that the specified
4936 function is a fast interrupt handler. This is just like the
4937 @code{interrupt} attribute, except that @code{freit} is used to return
4938 instead of @code{reit}.
4939
4940 @item interrupt
4941 @cindex @code{interrupt} function attribute, RX
4942 Use this attribute to indicate
4943 that the specified function is an interrupt handler. The compiler generates
4944 function entry and exit sequences suitable for use in an interrupt handler
4945 when this attribute is present.
4946
4947 On RX targets, you may specify one or more vector numbers as arguments
4948 to the attribute, as well as naming an alternate table name.
4949 Parameters are handled sequentially, so one handler can be assigned to
4950 multiple entries in multiple tables. One may also pass the magic
4951 string @code{"$default"} which causes the function to be used for any
4952 unfilled slots in the current table.
4953
4954 This example shows a simple assignment of a function to one vector in
4955 the default table (note that preprocessor macros may be used for
4956 chip-specific symbolic vector names):
4957 @smallexample
4958 void __attribute__ ((interrupt (5))) txd1_handler ();
4959 @end smallexample
4960
4961 This example assigns a function to two slots in the default table
4962 (using preprocessor macros defined elsewhere) and makes it the default
4963 for the @code{dct} table:
4964 @smallexample
4965 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4966 txd1_handler ();
4967 @end smallexample
4968
4969 @item naked
4970 @cindex @code{naked} function attribute, RX
4971 This attribute allows the compiler to construct the
4972 requisite function declaration, while allowing the body of the
4973 function to be assembly code. The specified function will not have
4974 prologue/epilogue sequences generated by the compiler. Only basic
4975 @code{asm} statements can safely be included in naked functions
4976 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4977 basic @code{asm} and C code may appear to work, they cannot be
4978 depended upon to work reliably and are not supported.
4979
4980 @item vector
4981 @cindex @code{vector} function attribute, RX
4982 This RX attribute is similar to the @code{interrupt} attribute, including its
4983 parameters, but does not make the function an interrupt-handler type
4984 function (i.e. it retains the normal C function calling ABI). See the
4985 @code{interrupt} attribute for a description of its arguments.
4986 @end table
4987
4988 @node S/390 Function Attributes
4989 @subsection S/390 Function Attributes
4990
4991 These function attributes are supported on the S/390:
4992
4993 @table @code
4994 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4995 @cindex @code{hotpatch} function attribute, S/390
4996
4997 On S/390 System z targets, you can use this function attribute to
4998 make GCC generate a ``hot-patching'' function prologue. If the
4999 @option{-mhotpatch=} command-line option is used at the same time,
5000 the @code{hotpatch} attribute takes precedence. The first of the
5001 two arguments specifies the number of halfwords to be added before
5002 the function label. A second argument can be used to specify the
5003 number of halfwords to be added after the function label. For
5004 both arguments the maximum allowed value is 1000000.
5005
5006 If both arguments are zero, hotpatching is disabled.
5007
5008 @item target (@var{options})
5009 @cindex @code{target} function attribute
5010 As discussed in @ref{Common Function Attributes}, this attribute
5011 allows specification of target-specific compilation options.
5012
5013 On S/390, the following options are supported:
5014
5015 @table @samp
5016 @item arch=
5017 @item tune=
5018 @item stack-guard=
5019 @item stack-size=
5020 @item branch-cost=
5021 @item warn-framesize=
5022 @item backchain
5023 @itemx no-backchain
5024 @item hard-dfp
5025 @itemx no-hard-dfp
5026 @item hard-float
5027 @itemx soft-float
5028 @item htm
5029 @itemx no-htm
5030 @item vx
5031 @itemx no-vx
5032 @item packed-stack
5033 @itemx no-packed-stack
5034 @item small-exec
5035 @itemx no-small-exec
5036 @item mvcle
5037 @itemx no-mvcle
5038 @item warn-dynamicstack
5039 @itemx no-warn-dynamicstack
5040 @end table
5041
5042 The options work exactly like the S/390 specific command line
5043 options (without the prefix @option{-m}) except that they do not
5044 change any feature macros. For example,
5045
5046 @smallexample
5047 @code{target("no-vx")}
5048 @end smallexample
5049
5050 does not undefine the @code{__VEC__} macro.
5051 @end table
5052
5053 @node SH Function Attributes
5054 @subsection SH Function Attributes
5055
5056 These function attributes are supported on the SH family of processors:
5057
5058 @table @code
5059 @item function_vector
5060 @cindex @code{function_vector} function attribute, SH
5061 @cindex calling functions through the function vector on SH2A
5062 On SH2A targets, this attribute declares a function to be called using the
5063 TBR relative addressing mode. The argument to this attribute is the entry
5064 number of the same function in a vector table containing all the TBR
5065 relative addressable functions. For correct operation the TBR must be setup
5066 accordingly to point to the start of the vector table before any functions with
5067 this attribute are invoked. Usually a good place to do the initialization is
5068 the startup routine. The TBR relative vector table can have at max 256 function
5069 entries. The jumps to these functions are generated using a SH2A specific,
5070 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5071 from GNU binutils version 2.7 or later for this attribute to work correctly.
5072
5073 In an application, for a function being called once, this attribute
5074 saves at least 8 bytes of code; and if other successive calls are being
5075 made to the same function, it saves 2 bytes of code per each of these
5076 calls.
5077
5078 @item interrupt_handler
5079 @cindex @code{interrupt_handler} function attribute, SH
5080 Use this attribute to
5081 indicate that the specified function is an interrupt handler. The compiler
5082 generates function entry and exit sequences suitable for use in an
5083 interrupt handler when this attribute is present.
5084
5085 @item nosave_low_regs
5086 @cindex @code{nosave_low_regs} function attribute, SH
5087 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5088 function should not save and restore registers R0..R7. This can be used on SH3*
5089 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5090 interrupt handlers.
5091
5092 @item renesas
5093 @cindex @code{renesas} function attribute, SH
5094 On SH targets this attribute specifies that the function or struct follows the
5095 Renesas ABI.
5096
5097 @item resbank
5098 @cindex @code{resbank} function attribute, SH
5099 On the SH2A target, this attribute enables the high-speed register
5100 saving and restoration using a register bank for @code{interrupt_handler}
5101 routines. Saving to the bank is performed automatically after the CPU
5102 accepts an interrupt that uses a register bank.
5103
5104 The nineteen 32-bit registers comprising general register R0 to R14,
5105 control register GBR, and system registers MACH, MACL, and PR and the
5106 vector table address offset are saved into a register bank. Register
5107 banks are stacked in first-in last-out (FILO) sequence. Restoration
5108 from the bank is executed by issuing a RESBANK instruction.
5109
5110 @item sp_switch
5111 @cindex @code{sp_switch} function attribute, SH
5112 Use this attribute on the SH to indicate an @code{interrupt_handler}
5113 function should switch to an alternate stack. It expects a string
5114 argument that names a global variable holding the address of the
5115 alternate stack.
5116
5117 @smallexample
5118 void *alt_stack;
5119 void f () __attribute__ ((interrupt_handler,
5120 sp_switch ("alt_stack")));
5121 @end smallexample
5122
5123 @item trap_exit
5124 @cindex @code{trap_exit} function attribute, SH
5125 Use this attribute on the SH for an @code{interrupt_handler} to return using
5126 @code{trapa} instead of @code{rte}. This attribute expects an integer
5127 argument specifying the trap number to be used.
5128
5129 @item trapa_handler
5130 @cindex @code{trapa_handler} function attribute, SH
5131 On SH targets this function attribute is similar to @code{interrupt_handler}
5132 but it does not save and restore all registers.
5133 @end table
5134
5135 @node SPU Function Attributes
5136 @subsection SPU Function Attributes
5137
5138 These function attributes are supported by the SPU back end:
5139
5140 @table @code
5141 @item naked
5142 @cindex @code{naked} function attribute, SPU
5143 This attribute allows the compiler to construct the
5144 requisite function declaration, while allowing the body of the
5145 function to be assembly code. The specified function will not have
5146 prologue/epilogue sequences generated by the compiler. Only basic
5147 @code{asm} statements can safely be included in naked functions
5148 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5149 basic @code{asm} and C code may appear to work, they cannot be
5150 depended upon to work reliably and are not supported.
5151 @end table
5152
5153 @node Symbian OS Function Attributes
5154 @subsection Symbian OS Function Attributes
5155
5156 @xref{Microsoft Windows Function Attributes}, for discussion of the
5157 @code{dllexport} and @code{dllimport} attributes.
5158
5159 @node V850 Function Attributes
5160 @subsection V850 Function Attributes
5161
5162 The V850 back end supports these function attributes:
5163
5164 @table @code
5165 @item interrupt
5166 @itemx interrupt_handler
5167 @cindex @code{interrupt} function attribute, V850
5168 @cindex @code{interrupt_handler} function attribute, V850
5169 Use these attributes to indicate
5170 that the specified function is an interrupt handler. The compiler generates
5171 function entry and exit sequences suitable for use in an interrupt handler
5172 when either attribute is present.
5173 @end table
5174
5175 @node Visium Function Attributes
5176 @subsection Visium Function Attributes
5177
5178 These function attributes are supported by the Visium back end:
5179
5180 @table @code
5181 @item interrupt
5182 @cindex @code{interrupt} function attribute, Visium
5183 Use this attribute to indicate
5184 that the specified function is an interrupt handler. The compiler generates
5185 function entry and exit sequences suitable for use in an interrupt handler
5186 when this attribute is present.
5187 @end table
5188
5189 @node x86 Function Attributes
5190 @subsection x86 Function Attributes
5191
5192 These function attributes are supported by the x86 back end:
5193
5194 @table @code
5195 @item cdecl
5196 @cindex @code{cdecl} function attribute, x86-32
5197 @cindex functions that pop the argument stack on x86-32
5198 @opindex mrtd
5199 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5200 assume that the calling function pops off the stack space used to
5201 pass arguments. This is
5202 useful to override the effects of the @option{-mrtd} switch.
5203
5204 @item fastcall
5205 @cindex @code{fastcall} function attribute, x86-32
5206 @cindex functions that pop the argument stack on x86-32
5207 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5208 pass the first argument (if of integral type) in the register ECX and
5209 the second argument (if of integral type) in the register EDX@. Subsequent
5210 and other typed arguments are passed on the stack. The called function
5211 pops the arguments off the stack. If the number of arguments is variable all
5212 arguments are pushed on the stack.
5213
5214 @item thiscall
5215 @cindex @code{thiscall} function attribute, x86-32
5216 @cindex functions that pop the argument stack on x86-32
5217 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5218 pass the first argument (if of integral type) in the register ECX.
5219 Subsequent and other typed arguments are passed on the stack. The called
5220 function pops the arguments off the stack.
5221 If the number of arguments is variable all arguments are pushed on the
5222 stack.
5223 The @code{thiscall} attribute is intended for C++ non-static member functions.
5224 As a GCC extension, this calling convention can be used for C functions
5225 and for static member methods.
5226
5227 @item ms_abi
5228 @itemx sysv_abi
5229 @cindex @code{ms_abi} function attribute, x86
5230 @cindex @code{sysv_abi} function attribute, x86
5231
5232 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5233 to indicate which calling convention should be used for a function. The
5234 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5235 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5236 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5237 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5238
5239 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5240 requires the @option{-maccumulate-outgoing-args} option.
5241
5242 @item callee_pop_aggregate_return (@var{number})
5243 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5244
5245 On x86-32 targets, you can use this attribute to control how
5246 aggregates are returned in memory. If the caller is responsible for
5247 popping the hidden pointer together with the rest of the arguments, specify
5248 @var{number} equal to zero. If callee is responsible for popping the
5249 hidden pointer, specify @var{number} equal to one.
5250
5251 The default x86-32 ABI assumes that the callee pops the
5252 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5253 the compiler assumes that the
5254 caller pops the stack for hidden pointer.
5255
5256 @item ms_hook_prologue
5257 @cindex @code{ms_hook_prologue} function attribute, x86
5258
5259 On 32-bit and 64-bit x86 targets, you can use
5260 this function attribute to make GCC generate the ``hot-patching'' function
5261 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5262 and newer.
5263
5264 @item regparm (@var{number})
5265 @cindex @code{regparm} function attribute, x86
5266 @cindex functions that are passed arguments in registers on x86-32
5267 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5268 pass arguments number one to @var{number} if they are of integral type
5269 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5270 take a variable number of arguments continue to be passed all of their
5271 arguments on the stack.
5272
5273 Beware that on some ELF systems this attribute is unsuitable for
5274 global functions in shared libraries with lazy binding (which is the
5275 default). Lazy binding sends the first call via resolving code in
5276 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5277 per the standard calling conventions. Solaris 8 is affected by this.
5278 Systems with the GNU C Library version 2.1 or higher
5279 and FreeBSD are believed to be
5280 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5281 disabled with the linker or the loader if desired, to avoid the
5282 problem.)
5283
5284 @item sseregparm
5285 @cindex @code{sseregparm} function attribute, x86
5286 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5287 causes the compiler to pass up to 3 floating-point arguments in
5288 SSE registers instead of on the stack. Functions that take a
5289 variable number of arguments continue to pass all of their
5290 floating-point arguments on the stack.
5291
5292 @item force_align_arg_pointer
5293 @cindex @code{force_align_arg_pointer} function attribute, x86
5294 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5295 applied to individual function definitions, generating an alternate
5296 prologue and epilogue that realigns the run-time stack if necessary.
5297 This supports mixing legacy codes that run with a 4-byte aligned stack
5298 with modern codes that keep a 16-byte stack for SSE compatibility.
5299
5300 @item stdcall
5301 @cindex @code{stdcall} function attribute, x86-32
5302 @cindex functions that pop the argument stack on x86-32
5303 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5304 assume that the called function pops off the stack space used to
5305 pass arguments, unless it takes a variable number of arguments.
5306
5307 @item no_caller_saved_registers
5308 @cindex @code{no_caller_saved_registers} function attribute, x86
5309 Use this attribute to indicate that the specified function has no
5310 caller-saved registers. That is, all registers are callee-saved. For
5311 example, this attribute can be used for a function called from an
5312 interrupt handler. The compiler generates proper function entry and
5313 exit sequences to save and restore any modified registers, except for
5314 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5315 states, the GCC option @option{-mgeneral-regs-only} should be used to
5316 compile functions with @code{no_caller_saved_registers} attribute.
5317
5318 @item interrupt
5319 @cindex @code{interrupt} function attribute, x86
5320 Use this attribute to indicate that the specified function is an
5321 interrupt handler or an exception handler (depending on parameters passed
5322 to the function, explained further). The compiler generates function
5323 entry and exit sequences suitable for use in an interrupt handler when
5324 this attribute is present. The @code{IRET} instruction, instead of the
5325 @code{RET} instruction, is used to return from interrupt handlers. All
5326 registers, except for the EFLAGS register which is restored by the
5327 @code{IRET} instruction, are preserved by the compiler. Since GCC
5328 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5329 @option{-mgeneral-regs-only} should be used to compile interrupt and
5330 exception handlers.
5331
5332 Any interruptible-without-stack-switch code must be compiled with
5333 @option{-mno-red-zone} since interrupt handlers can and will, because
5334 of the hardware design, touch the red zone.
5335
5336 An interrupt handler must be declared with a mandatory pointer
5337 argument:
5338
5339 @smallexample
5340 struct interrupt_frame;
5341
5342 __attribute__ ((interrupt))
5343 void
5344 f (struct interrupt_frame *frame)
5345 @{
5346 @}
5347 @end smallexample
5348
5349 @noindent
5350 and you must define @code{struct interrupt_frame} as described in the
5351 processor's manual.
5352
5353 Exception handlers differ from interrupt handlers because the system
5354 pushes an error code on the stack. An exception handler declaration is
5355 similar to that for an interrupt handler, but with a different mandatory
5356 function signature. The compiler arranges to pop the error code off the
5357 stack before the @code{IRET} instruction.
5358
5359 @smallexample
5360 #ifdef __x86_64__
5361 typedef unsigned long long int uword_t;
5362 #else
5363 typedef unsigned int uword_t;
5364 #endif
5365
5366 struct interrupt_frame;
5367
5368 __attribute__ ((interrupt))
5369 void
5370 f (struct interrupt_frame *frame, uword_t error_code)
5371 @{
5372 ...
5373 @}
5374 @end smallexample
5375
5376 Exception handlers should only be used for exceptions that push an error
5377 code; you should use an interrupt handler in other cases. The system
5378 will crash if the wrong kind of handler is used.
5379
5380 @item target (@var{options})
5381 @cindex @code{target} function attribute
5382 As discussed in @ref{Common Function Attributes}, this attribute
5383 allows specification of target-specific compilation options.
5384
5385 On the x86, the following options are allowed:
5386 @table @samp
5387 @item abm
5388 @itemx no-abm
5389 @cindex @code{target("abm")} function attribute, x86
5390 Enable/disable the generation of the advanced bit instructions.
5391
5392 @item aes
5393 @itemx no-aes
5394 @cindex @code{target("aes")} function attribute, x86
5395 Enable/disable the generation of the AES instructions.
5396
5397 @item default
5398 @cindex @code{target("default")} function attribute, x86
5399 @xref{Function Multiversioning}, where it is used to specify the
5400 default function version.
5401
5402 @item mmx
5403 @itemx no-mmx
5404 @cindex @code{target("mmx")} function attribute, x86
5405 Enable/disable the generation of the MMX instructions.
5406
5407 @item pclmul
5408 @itemx no-pclmul
5409 @cindex @code{target("pclmul")} function attribute, x86
5410 Enable/disable the generation of the PCLMUL instructions.
5411
5412 @item popcnt
5413 @itemx no-popcnt
5414 @cindex @code{target("popcnt")} function attribute, x86
5415 Enable/disable the generation of the POPCNT instruction.
5416
5417 @item sse
5418 @itemx no-sse
5419 @cindex @code{target("sse")} function attribute, x86
5420 Enable/disable the generation of the SSE instructions.
5421
5422 @item sse2
5423 @itemx no-sse2
5424 @cindex @code{target("sse2")} function attribute, x86
5425 Enable/disable the generation of the SSE2 instructions.
5426
5427 @item sse3
5428 @itemx no-sse3
5429 @cindex @code{target("sse3")} function attribute, x86
5430 Enable/disable the generation of the SSE3 instructions.
5431
5432 @item sse4
5433 @itemx no-sse4
5434 @cindex @code{target("sse4")} function attribute, x86
5435 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5436 and SSE4.2).
5437
5438 @item sse4.1
5439 @itemx no-sse4.1
5440 @cindex @code{target("sse4.1")} function attribute, x86
5441 Enable/disable the generation of the sse4.1 instructions.
5442
5443 @item sse4.2
5444 @itemx no-sse4.2
5445 @cindex @code{target("sse4.2")} function attribute, x86
5446 Enable/disable the generation of the sse4.2 instructions.
5447
5448 @item sse4a
5449 @itemx no-sse4a
5450 @cindex @code{target("sse4a")} function attribute, x86
5451 Enable/disable the generation of the SSE4A instructions.
5452
5453 @item fma4
5454 @itemx no-fma4
5455 @cindex @code{target("fma4")} function attribute, x86
5456 Enable/disable the generation of the FMA4 instructions.
5457
5458 @item xop
5459 @itemx no-xop
5460 @cindex @code{target("xop")} function attribute, x86
5461 Enable/disable the generation of the XOP instructions.
5462
5463 @item lwp
5464 @itemx no-lwp
5465 @cindex @code{target("lwp")} function attribute, x86
5466 Enable/disable the generation of the LWP instructions.
5467
5468 @item ssse3
5469 @itemx no-ssse3
5470 @cindex @code{target("ssse3")} function attribute, x86
5471 Enable/disable the generation of the SSSE3 instructions.
5472
5473 @item cld
5474 @itemx no-cld
5475 @cindex @code{target("cld")} function attribute, x86
5476 Enable/disable the generation of the CLD before string moves.
5477
5478 @item fancy-math-387
5479 @itemx no-fancy-math-387
5480 @cindex @code{target("fancy-math-387")} function attribute, x86
5481 Enable/disable the generation of the @code{sin}, @code{cos}, and
5482 @code{sqrt} instructions on the 387 floating-point unit.
5483
5484 @item fused-madd
5485 @itemx no-fused-madd
5486 @cindex @code{target("fused-madd")} function attribute, x86
5487 Enable/disable the generation of the fused multiply/add instructions.
5488
5489 @item ieee-fp
5490 @itemx no-ieee-fp
5491 @cindex @code{target("ieee-fp")} function attribute, x86
5492 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5493
5494 @item inline-all-stringops
5495 @itemx no-inline-all-stringops
5496 @cindex @code{target("inline-all-stringops")} function attribute, x86
5497 Enable/disable inlining of string operations.
5498
5499 @item inline-stringops-dynamically
5500 @itemx no-inline-stringops-dynamically
5501 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5502 Enable/disable the generation of the inline code to do small string
5503 operations and calling the library routines for large operations.
5504
5505 @item align-stringops
5506 @itemx no-align-stringops
5507 @cindex @code{target("align-stringops")} function attribute, x86
5508 Do/do not align destination of inlined string operations.
5509
5510 @item recip
5511 @itemx no-recip
5512 @cindex @code{target("recip")} function attribute, x86
5513 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5514 instructions followed an additional Newton-Raphson step instead of
5515 doing a floating-point division.
5516
5517 @item arch=@var{ARCH}
5518 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5519 Specify the architecture to generate code for in compiling the function.
5520
5521 @item tune=@var{TUNE}
5522 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5523 Specify the architecture to tune for in compiling the function.
5524
5525 @item fpmath=@var{FPMATH}
5526 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5527 Specify which floating-point unit to use. You must specify the
5528 @code{target("fpmath=sse,387")} option as
5529 @code{target("fpmath=sse+387")} because the comma would separate
5530 different options.
5531 @end table
5532
5533 On the x86, the inliner does not inline a
5534 function that has different target options than the caller, unless the
5535 callee has a subset of the target options of the caller. For example
5536 a function declared with @code{target("sse3")} can inline a function
5537 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5538 @end table
5539
5540 @node Xstormy16 Function Attributes
5541 @subsection Xstormy16 Function Attributes
5542
5543 These function attributes are supported by the Xstormy16 back end:
5544
5545 @table @code
5546 @item interrupt
5547 @cindex @code{interrupt} function attribute, Xstormy16
5548 Use this attribute to indicate
5549 that the specified function is an interrupt handler. The compiler generates
5550 function entry and exit sequences suitable for use in an interrupt handler
5551 when this attribute is present.
5552 @end table
5553
5554 @node Variable Attributes
5555 @section Specifying Attributes of Variables
5556 @cindex attribute of variables
5557 @cindex variable attributes
5558
5559 The keyword @code{__attribute__} allows you to specify special
5560 attributes of variables or structure fields. This keyword is followed
5561 by an attribute specification inside double parentheses. Some
5562 attributes are currently defined generically for variables.
5563 Other attributes are defined for variables on particular target
5564 systems. Other attributes are available for functions
5565 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5566 enumerators (@pxref{Enumerator Attributes}), and for types
5567 (@pxref{Type Attributes}).
5568 Other front ends might define more attributes
5569 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5570
5571 @xref{Attribute Syntax}, for details of the exact syntax for using
5572 attributes.
5573
5574 @menu
5575 * Common Variable Attributes::
5576 * AVR Variable Attributes::
5577 * Blackfin Variable Attributes::
5578 * H8/300 Variable Attributes::
5579 * IA-64 Variable Attributes::
5580 * M32R/D Variable Attributes::
5581 * MeP Variable Attributes::
5582 * Microsoft Windows Variable Attributes::
5583 * MSP430 Variable Attributes::
5584 * PowerPC Variable Attributes::
5585 * RL78 Variable Attributes::
5586 * SPU Variable Attributes::
5587 * V850 Variable Attributes::
5588 * x86 Variable Attributes::
5589 * Xstormy16 Variable Attributes::
5590 @end menu
5591
5592 @node Common Variable Attributes
5593 @subsection Common Variable Attributes
5594
5595 The following attributes are supported on most targets.
5596
5597 @table @code
5598 @cindex @code{aligned} variable attribute
5599 @item aligned (@var{alignment})
5600 This attribute specifies a minimum alignment for the variable or
5601 structure field, measured in bytes. For example, the declaration:
5602
5603 @smallexample
5604 int x __attribute__ ((aligned (16))) = 0;
5605 @end smallexample
5606
5607 @noindent
5608 causes the compiler to allocate the global variable @code{x} on a
5609 16-byte boundary. On a 68040, this could be used in conjunction with
5610 an @code{asm} expression to access the @code{move16} instruction which
5611 requires 16-byte aligned operands.
5612
5613 You can also specify the alignment of structure fields. For example, to
5614 create a double-word aligned @code{int} pair, you could write:
5615
5616 @smallexample
5617 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5618 @end smallexample
5619
5620 @noindent
5621 This is an alternative to creating a union with a @code{double} member,
5622 which forces the union to be double-word aligned.
5623
5624 As in the preceding examples, you can explicitly specify the alignment
5625 (in bytes) that you wish the compiler to use for a given variable or
5626 structure field. Alternatively, you can leave out the alignment factor
5627 and just ask the compiler to align a variable or field to the
5628 default alignment for the target architecture you are compiling for.
5629 The default alignment is sufficient for all scalar types, but may not be
5630 enough for all vector types on a target that supports vector operations.
5631 The default alignment is fixed for a particular target ABI.
5632
5633 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5634 which is the largest alignment ever used for any data type on the
5635 target machine you are compiling for. For example, you could write:
5636
5637 @smallexample
5638 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5639 @end smallexample
5640
5641 The compiler automatically sets the alignment for the declared
5642 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5643 often make copy operations more efficient, because the compiler can
5644 use whatever instructions copy the biggest chunks of memory when
5645 performing copies to or from the variables or fields that you have
5646 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5647 may change depending on command-line options.
5648
5649 When used on a struct, or struct member, the @code{aligned} attribute can
5650 only increase the alignment; in order to decrease it, the @code{packed}
5651 attribute must be specified as well. When used as part of a typedef, the
5652 @code{aligned} attribute can both increase and decrease alignment, and
5653 specifying the @code{packed} attribute generates a warning.
5654
5655 Note that the effectiveness of @code{aligned} attributes may be limited
5656 by inherent limitations in your linker. On many systems, the linker is
5657 only able to arrange for variables to be aligned up to a certain maximum
5658 alignment. (For some linkers, the maximum supported alignment may
5659 be very very small.) If your linker is only able to align variables
5660 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5661 in an @code{__attribute__} still only provides you with 8-byte
5662 alignment. See your linker documentation for further information.
5663
5664 The @code{aligned} attribute can also be used for functions
5665 (@pxref{Common Function Attributes}.)
5666
5667 @item cleanup (@var{cleanup_function})
5668 @cindex @code{cleanup} variable attribute
5669 The @code{cleanup} attribute runs a function when the variable goes
5670 out of scope. This attribute can only be applied to auto function
5671 scope variables; it may not be applied to parameters or variables
5672 with static storage duration. The function must take one parameter,
5673 a pointer to a type compatible with the variable. The return value
5674 of the function (if any) is ignored.
5675
5676 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5677 is run during the stack unwinding that happens during the
5678 processing of the exception. Note that the @code{cleanup} attribute
5679 does not allow the exception to be caught, only to perform an action.
5680 It is undefined what happens if @var{cleanup_function} does not
5681 return normally.
5682
5683 @item common
5684 @itemx nocommon
5685 @cindex @code{common} variable attribute
5686 @cindex @code{nocommon} variable attribute
5687 @opindex fcommon
5688 @opindex fno-common
5689 The @code{common} attribute requests GCC to place a variable in
5690 ``common'' storage. The @code{nocommon} attribute requests the
5691 opposite---to allocate space for it directly.
5692
5693 These attributes override the default chosen by the
5694 @option{-fno-common} and @option{-fcommon} flags respectively.
5695
5696 @item deprecated
5697 @itemx deprecated (@var{msg})
5698 @cindex @code{deprecated} variable attribute
5699 The @code{deprecated} attribute results in a warning if the variable
5700 is used anywhere in the source file. This is useful when identifying
5701 variables that are expected to be removed in a future version of a
5702 program. The warning also includes the location of the declaration
5703 of the deprecated variable, to enable users to easily find further
5704 information about why the variable is deprecated, or what they should
5705 do instead. Note that the warning only occurs for uses:
5706
5707 @smallexample
5708 extern int old_var __attribute__ ((deprecated));
5709 extern int old_var;
5710 int new_fn () @{ return old_var; @}
5711 @end smallexample
5712
5713 @noindent
5714 results in a warning on line 3 but not line 2. The optional @var{msg}
5715 argument, which must be a string, is printed in the warning if
5716 present.
5717
5718 The @code{deprecated} attribute can also be used for functions and
5719 types (@pxref{Common Function Attributes},
5720 @pxref{Common Type Attributes}).
5721
5722 @item mode (@var{mode})
5723 @cindex @code{mode} variable attribute
5724 This attribute specifies the data type for the declaration---whichever
5725 type corresponds to the mode @var{mode}. This in effect lets you
5726 request an integer or floating-point type according to its width.
5727
5728 You may also specify a mode of @code{byte} or @code{__byte__} to
5729 indicate the mode corresponding to a one-byte integer, @code{word} or
5730 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5731 or @code{__pointer__} for the mode used to represent pointers.
5732
5733 @item packed
5734 @cindex @code{packed} variable attribute
5735 The @code{packed} attribute specifies that a variable or structure field
5736 should have the smallest possible alignment---one byte for a variable,
5737 and one bit for a field, unless you specify a larger value with the
5738 @code{aligned} attribute.
5739
5740 Here is a structure in which the field @code{x} is packed, so that it
5741 immediately follows @code{a}:
5742
5743 @smallexample
5744 struct foo
5745 @{
5746 char a;
5747 int x[2] __attribute__ ((packed));
5748 @};
5749 @end smallexample
5750
5751 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5752 @code{packed} attribute on bit-fields of type @code{char}. This has
5753 been fixed in GCC 4.4 but the change can lead to differences in the
5754 structure layout. See the documentation of
5755 @option{-Wpacked-bitfield-compat} for more information.
5756
5757 @item section ("@var{section-name}")
5758 @cindex @code{section} variable attribute
5759 Normally, the compiler places the objects it generates in sections like
5760 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5761 or you need certain particular variables to appear in special sections,
5762 for example to map to special hardware. The @code{section}
5763 attribute specifies that a variable (or function) lives in a particular
5764 section. For example, this small program uses several specific section names:
5765
5766 @smallexample
5767 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5768 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5769 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5770 int init_data __attribute__ ((section ("INITDATA")));
5771
5772 main()
5773 @{
5774 /* @r{Initialize stack pointer} */
5775 init_sp (stack + sizeof (stack));
5776
5777 /* @r{Initialize initialized data} */
5778 memcpy (&init_data, &data, &edata - &data);
5779
5780 /* @r{Turn on the serial ports} */
5781 init_duart (&a);
5782 init_duart (&b);
5783 @}
5784 @end smallexample
5785
5786 @noindent
5787 Use the @code{section} attribute with
5788 @emph{global} variables and not @emph{local} variables,
5789 as shown in the example.
5790
5791 You may use the @code{section} attribute with initialized or
5792 uninitialized global variables but the linker requires
5793 each object be defined once, with the exception that uninitialized
5794 variables tentatively go in the @code{common} (or @code{bss}) section
5795 and can be multiply ``defined''. Using the @code{section} attribute
5796 changes what section the variable goes into and may cause the
5797 linker to issue an error if an uninitialized variable has multiple
5798 definitions. You can force a variable to be initialized with the
5799 @option{-fno-common} flag or the @code{nocommon} attribute.
5800
5801 Some file formats do not support arbitrary sections so the @code{section}
5802 attribute is not available on all platforms.
5803 If you need to map the entire contents of a module to a particular
5804 section, consider using the facilities of the linker instead.
5805
5806 @item tls_model ("@var{tls_model}")
5807 @cindex @code{tls_model} variable attribute
5808 The @code{tls_model} attribute sets thread-local storage model
5809 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5810 overriding @option{-ftls-model=} command-line switch on a per-variable
5811 basis.
5812 The @var{tls_model} argument should be one of @code{global-dynamic},
5813 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5814
5815 Not all targets support this attribute.
5816
5817 @item unused
5818 @cindex @code{unused} variable attribute
5819 This attribute, attached to a variable, means that the variable is meant
5820 to be possibly unused. GCC does not produce a warning for this
5821 variable.
5822
5823 @item used
5824 @cindex @code{used} variable attribute
5825 This attribute, attached to a variable with static storage, means that
5826 the variable must be emitted even if it appears that the variable is not
5827 referenced.
5828
5829 When applied to a static data member of a C++ class template, the
5830 attribute also means that the member is instantiated if the
5831 class itself is instantiated.
5832
5833 @item vector_size (@var{bytes})
5834 @cindex @code{vector_size} variable attribute
5835 This attribute specifies the vector size for the variable, measured in
5836 bytes. For example, the declaration:
5837
5838 @smallexample
5839 int foo __attribute__ ((vector_size (16)));
5840 @end smallexample
5841
5842 @noindent
5843 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5844 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5845 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5846
5847 This attribute is only applicable to integral and float scalars,
5848 although arrays, pointers, and function return values are allowed in
5849 conjunction with this construct.
5850
5851 Aggregates with this attribute are invalid, even if they are of the same
5852 size as a corresponding scalar. For example, the declaration:
5853
5854 @smallexample
5855 struct S @{ int a; @};
5856 struct S __attribute__ ((vector_size (16))) foo;
5857 @end smallexample
5858
5859 @noindent
5860 is invalid even if the size of the structure is the same as the size of
5861 the @code{int}.
5862
5863 @item visibility ("@var{visibility_type}")
5864 @cindex @code{visibility} variable attribute
5865 This attribute affects the linkage of the declaration to which it is attached.
5866 The @code{visibility} attribute is described in
5867 @ref{Common Function Attributes}.
5868
5869 @item weak
5870 @cindex @code{weak} variable attribute
5871 The @code{weak} attribute is described in
5872 @ref{Common Function Attributes}.
5873
5874 @end table
5875
5876 @node AVR Variable Attributes
5877 @subsection AVR Variable Attributes
5878
5879 @table @code
5880 @item progmem
5881 @cindex @code{progmem} variable attribute, AVR
5882 The @code{progmem} attribute is used on the AVR to place read-only
5883 data in the non-volatile program memory (flash). The @code{progmem}
5884 attribute accomplishes this by putting respective variables into a
5885 section whose name starts with @code{.progmem}.
5886
5887 This attribute works similar to the @code{section} attribute
5888 but adds additional checking.
5889
5890 @table @asis
5891 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5892 @code{progmem} affects the location
5893 of the data but not how this data is accessed.
5894 In order to read data located with the @code{progmem} attribute
5895 (inline) assembler must be used.
5896 @smallexample
5897 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5898 #include <avr/pgmspace.h>
5899
5900 /* Locate var in flash memory */
5901 const int var[2] PROGMEM = @{ 1, 2 @};
5902
5903 int read_var (int i)
5904 @{
5905 /* Access var[] by accessor macro from avr/pgmspace.h */
5906 return (int) pgm_read_word (& var[i]);
5907 @}
5908 @end smallexample
5909
5910 AVR is a Harvard architecture processor and data and read-only data
5911 normally resides in the data memory (RAM).
5912
5913 See also the @ref{AVR Named Address Spaces} section for
5914 an alternate way to locate and access data in flash memory.
5915
5916 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5917 The compiler adds @code{0x4000}
5918 to the addresses of objects and declarations in @code{progmem} and locates
5919 the objects in flash memory, namely in section @code{.progmem.data}.
5920 The offset is needed because the flash memory is visible in the RAM
5921 address space starting at address @code{0x4000}.
5922
5923 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5924 no special functions or macros are needed.
5925
5926 @smallexample
5927 /* var is located in flash memory */
5928 extern const int var[2] __attribute__((progmem));
5929
5930 int read_var (int i)
5931 @{
5932 return var[i];
5933 @}
5934 @end smallexample
5935
5936 @end table
5937
5938 @item io
5939 @itemx io (@var{addr})
5940 @cindex @code{io} variable attribute, AVR
5941 Variables with the @code{io} attribute are used to address
5942 memory-mapped peripherals in the io address range.
5943 If an address is specified, the variable
5944 is assigned that address, and the value is interpreted as an
5945 address in the data address space.
5946 Example:
5947
5948 @smallexample
5949 volatile int porta __attribute__((io (0x22)));
5950 @end smallexample
5951
5952 The address specified in the address in the data address range.
5953
5954 Otherwise, the variable it is not assigned an address, but the
5955 compiler will still use in/out instructions where applicable,
5956 assuming some other module assigns an address in the io address range.
5957 Example:
5958
5959 @smallexample
5960 extern volatile int porta __attribute__((io));
5961 @end smallexample
5962
5963 @item io_low
5964 @itemx io_low (@var{addr})
5965 @cindex @code{io_low} variable attribute, AVR
5966 This is like the @code{io} attribute, but additionally it informs the
5967 compiler that the object lies in the lower half of the I/O area,
5968 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5969 instructions.
5970
5971 @item address
5972 @itemx address (@var{addr})
5973 @cindex @code{address} variable attribute, AVR
5974 Variables with the @code{address} attribute are used to address
5975 memory-mapped peripherals that may lie outside the io address range.
5976
5977 @smallexample
5978 volatile int porta __attribute__((address (0x600)));
5979 @end smallexample
5980
5981 @end table
5982
5983 @node Blackfin Variable Attributes
5984 @subsection Blackfin Variable Attributes
5985
5986 Three attributes are currently defined for the Blackfin.
5987
5988 @table @code
5989 @item l1_data
5990 @itemx l1_data_A
5991 @itemx l1_data_B
5992 @cindex @code{l1_data} variable attribute, Blackfin
5993 @cindex @code{l1_data_A} variable attribute, Blackfin
5994 @cindex @code{l1_data_B} variable attribute, Blackfin
5995 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5996 Variables with @code{l1_data} attribute are put into the specific section
5997 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5998 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5999 attribute are put into the specific section named @code{.l1.data.B}.
6000
6001 @item l2
6002 @cindex @code{l2} variable attribute, Blackfin
6003 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6004 Variables with @code{l2} attribute are put into the specific section
6005 named @code{.l2.data}.
6006 @end table
6007
6008 @node H8/300 Variable Attributes
6009 @subsection H8/300 Variable Attributes
6010
6011 These variable attributes are available for H8/300 targets:
6012
6013 @table @code
6014 @item eightbit_data
6015 @cindex @code{eightbit_data} variable attribute, H8/300
6016 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6017 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6018 variable should be placed into the eight-bit data section.
6019 The compiler generates more efficient code for certain operations
6020 on data in the eight-bit data area. Note the eight-bit data area is limited to
6021 256 bytes of data.
6022
6023 You must use GAS and GLD from GNU binutils version 2.7 or later for
6024 this attribute to work correctly.
6025
6026 @item tiny_data
6027 @cindex @code{tiny_data} variable attribute, H8/300
6028 @cindex tiny data section on the H8/300H and H8S
6029 Use this attribute on the H8/300H and H8S to indicate that the specified
6030 variable should be placed into the tiny data section.
6031 The compiler generates more efficient code for loads and stores
6032 on data in the tiny data section. Note the tiny data area is limited to
6033 slightly under 32KB of data.
6034
6035 @end table
6036
6037 @node IA-64 Variable Attributes
6038 @subsection IA-64 Variable Attributes
6039
6040 The IA-64 back end supports the following variable attribute:
6041
6042 @table @code
6043 @item model (@var{model-name})
6044 @cindex @code{model} variable attribute, IA-64
6045
6046 On IA-64, use this attribute to set the addressability of an object.
6047 At present, the only supported identifier for @var{model-name} is
6048 @code{small}, indicating addressability via ``small'' (22-bit)
6049 addresses (so that their addresses can be loaded with the @code{addl}
6050 instruction). Caveat: such addressing is by definition not position
6051 independent and hence this attribute must not be used for objects
6052 defined by shared libraries.
6053
6054 @end table
6055
6056 @node M32R/D Variable Attributes
6057 @subsection M32R/D Variable Attributes
6058
6059 One attribute is currently defined for the M32R/D@.
6060
6061 @table @code
6062 @item model (@var{model-name})
6063 @cindex @code{model-name} variable attribute, M32R/D
6064 @cindex variable addressability on the M32R/D
6065 Use this attribute on the M32R/D to set the addressability of an object.
6066 The identifier @var{model-name} is one of @code{small}, @code{medium},
6067 or @code{large}, representing each of the code models.
6068
6069 Small model objects live in the lower 16MB of memory (so that their
6070 addresses can be loaded with the @code{ld24} instruction).
6071
6072 Medium and large model objects may live anywhere in the 32-bit address space
6073 (the compiler generates @code{seth/add3} instructions to load their
6074 addresses).
6075 @end table
6076
6077 @node MeP Variable Attributes
6078 @subsection MeP Variable Attributes
6079
6080 The MeP target has a number of addressing modes and busses. The
6081 @code{near} space spans the standard memory space's first 16 megabytes
6082 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6083 The @code{based} space is a 128-byte region in the memory space that
6084 is addressed relative to the @code{$tp} register. The @code{tiny}
6085 space is a 65536-byte region relative to the @code{$gp} register. In
6086 addition to these memory regions, the MeP target has a separate 16-bit
6087 control bus which is specified with @code{cb} attributes.
6088
6089 @table @code
6090
6091 @item based
6092 @cindex @code{based} variable attribute, MeP
6093 Any variable with the @code{based} attribute is assigned to the
6094 @code{.based} section, and is accessed with relative to the
6095 @code{$tp} register.
6096
6097 @item tiny
6098 @cindex @code{tiny} variable attribute, MeP
6099 Likewise, the @code{tiny} attribute assigned variables to the
6100 @code{.tiny} section, relative to the @code{$gp} register.
6101
6102 @item near
6103 @cindex @code{near} variable attribute, MeP
6104 Variables with the @code{near} attribute are assumed to have addresses
6105 that fit in a 24-bit addressing mode. This is the default for large
6106 variables (@code{-mtiny=4} is the default) but this attribute can
6107 override @code{-mtiny=} for small variables, or override @code{-ml}.
6108
6109 @item far
6110 @cindex @code{far} variable attribute, MeP
6111 Variables with the @code{far} attribute are addressed using a full
6112 32-bit address. Since this covers the entire memory space, this
6113 allows modules to make no assumptions about where variables might be
6114 stored.
6115
6116 @item io
6117 @cindex @code{io} variable attribute, MeP
6118 @itemx io (@var{addr})
6119 Variables with the @code{io} attribute are used to address
6120 memory-mapped peripherals. If an address is specified, the variable
6121 is assigned that address, else it is not assigned an address (it is
6122 assumed some other module assigns an address). Example:
6123
6124 @smallexample
6125 int timer_count __attribute__((io(0x123)));
6126 @end smallexample
6127
6128 @item cb
6129 @itemx cb (@var{addr})
6130 @cindex @code{cb} variable attribute, MeP
6131 Variables with the @code{cb} attribute are used to access the control
6132 bus, using special instructions. @code{addr} indicates the control bus
6133 address. Example:
6134
6135 @smallexample
6136 int cpu_clock __attribute__((cb(0x123)));
6137 @end smallexample
6138
6139 @end table
6140
6141 @node Microsoft Windows Variable Attributes
6142 @subsection Microsoft Windows Variable Attributes
6143
6144 You can use these attributes on Microsoft Windows targets.
6145 @ref{x86 Variable Attributes} for additional Windows compatibility
6146 attributes available on all x86 targets.
6147
6148 @table @code
6149 @item dllimport
6150 @itemx dllexport
6151 @cindex @code{dllimport} variable attribute
6152 @cindex @code{dllexport} variable attribute
6153 The @code{dllimport} and @code{dllexport} attributes are described in
6154 @ref{Microsoft Windows Function Attributes}.
6155
6156 @item selectany
6157 @cindex @code{selectany} variable attribute
6158 The @code{selectany} attribute causes an initialized global variable to
6159 have link-once semantics. When multiple definitions of the variable are
6160 encountered by the linker, the first is selected and the remainder are
6161 discarded. Following usage by the Microsoft compiler, the linker is told
6162 @emph{not} to warn about size or content differences of the multiple
6163 definitions.
6164
6165 Although the primary usage of this attribute is for POD types, the
6166 attribute can also be applied to global C++ objects that are initialized
6167 by a constructor. In this case, the static initialization and destruction
6168 code for the object is emitted in each translation defining the object,
6169 but the calls to the constructor and destructor are protected by a
6170 link-once guard variable.
6171
6172 The @code{selectany} attribute is only available on Microsoft Windows
6173 targets. You can use @code{__declspec (selectany)} as a synonym for
6174 @code{__attribute__ ((selectany))} for compatibility with other
6175 compilers.
6176
6177 @item shared
6178 @cindex @code{shared} variable attribute
6179 On Microsoft Windows, in addition to putting variable definitions in a named
6180 section, the section can also be shared among all running copies of an
6181 executable or DLL@. For example, this small program defines shared data
6182 by putting it in a named section @code{shared} and marking the section
6183 shareable:
6184
6185 @smallexample
6186 int foo __attribute__((section ("shared"), shared)) = 0;
6187
6188 int
6189 main()
6190 @{
6191 /* @r{Read and write foo. All running
6192 copies see the same value.} */
6193 return 0;
6194 @}
6195 @end smallexample
6196
6197 @noindent
6198 You may only use the @code{shared} attribute along with @code{section}
6199 attribute with a fully-initialized global definition because of the way
6200 linkers work. See @code{section} attribute for more information.
6201
6202 The @code{shared} attribute is only available on Microsoft Windows@.
6203
6204 @end table
6205
6206 @node MSP430 Variable Attributes
6207 @subsection MSP430 Variable Attributes
6208
6209 @table @code
6210 @item noinit
6211 @cindex @code{noinit} variable attribute, MSP430
6212 Any data with the @code{noinit} attribute will not be initialised by
6213 the C runtime startup code, or the program loader. Not initialising
6214 data in this way can reduce program startup times.
6215
6216 @item persistent
6217 @cindex @code{persistent} variable attribute, MSP430
6218 Any variable with the @code{persistent} attribute will not be
6219 initialised by the C runtime startup code. Instead its value will be
6220 set once, when the application is loaded, and then never initialised
6221 again, even if the processor is reset or the program restarts.
6222 Persistent data is intended to be placed into FLASH RAM, where its
6223 value will be retained across resets. The linker script being used to
6224 create the application should ensure that persistent data is correctly
6225 placed.
6226
6227 @item lower
6228 @itemx upper
6229 @itemx either
6230 @cindex @code{lower} variable attribute, MSP430
6231 @cindex @code{upper} variable attribute, MSP430
6232 @cindex @code{either} variable attribute, MSP430
6233 These attributes are the same as the MSP430 function attributes of the
6234 same name (@pxref{MSP430 Function Attributes}).
6235 These attributes can be applied to both functions and variables.
6236 @end table
6237
6238 @node PowerPC Variable Attributes
6239 @subsection PowerPC Variable Attributes
6240
6241 Three attributes currently are defined for PowerPC configurations:
6242 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6243
6244 @cindex @code{ms_struct} variable attribute, PowerPC
6245 @cindex @code{gcc_struct} variable attribute, PowerPC
6246 For full documentation of the struct attributes please see the
6247 documentation in @ref{x86 Variable Attributes}.
6248
6249 @cindex @code{altivec} variable attribute, PowerPC
6250 For documentation of @code{altivec} attribute please see the
6251 documentation in @ref{PowerPC Type Attributes}.
6252
6253 @node RL78 Variable Attributes
6254 @subsection RL78 Variable Attributes
6255
6256 @cindex @code{saddr} variable attribute, RL78
6257 The RL78 back end supports the @code{saddr} variable attribute. This
6258 specifies placement of the corresponding variable in the SADDR area,
6259 which can be accessed more efficiently than the default memory region.
6260
6261 @node SPU Variable Attributes
6262 @subsection SPU Variable Attributes
6263
6264 @cindex @code{spu_vector} variable attribute, SPU
6265 The SPU supports the @code{spu_vector} attribute for variables. For
6266 documentation of this attribute please see the documentation in
6267 @ref{SPU Type Attributes}.
6268
6269 @node V850 Variable Attributes
6270 @subsection V850 Variable Attributes
6271
6272 These variable attributes are supported by the V850 back end:
6273
6274 @table @code
6275
6276 @item sda
6277 @cindex @code{sda} variable attribute, V850
6278 Use this attribute to explicitly place a variable in the small data area,
6279 which can hold up to 64 kilobytes.
6280
6281 @item tda
6282 @cindex @code{tda} variable attribute, V850
6283 Use this attribute to explicitly place a variable in the tiny data area,
6284 which can hold up to 256 bytes in total.
6285
6286 @item zda
6287 @cindex @code{zda} variable attribute, V850
6288 Use this attribute to explicitly place a variable in the first 32 kilobytes
6289 of memory.
6290 @end table
6291
6292 @node x86 Variable Attributes
6293 @subsection x86 Variable Attributes
6294
6295 Two attributes are currently defined for x86 configurations:
6296 @code{ms_struct} and @code{gcc_struct}.
6297
6298 @table @code
6299 @item ms_struct
6300 @itemx gcc_struct
6301 @cindex @code{ms_struct} variable attribute, x86
6302 @cindex @code{gcc_struct} variable attribute, x86
6303
6304 If @code{packed} is used on a structure, or if bit-fields are used,
6305 it may be that the Microsoft ABI lays out the structure differently
6306 than the way GCC normally does. Particularly when moving packed
6307 data between functions compiled with GCC and the native Microsoft compiler
6308 (either via function call or as data in a file), it may be necessary to access
6309 either format.
6310
6311 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6312 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6313 command-line options, respectively;
6314 see @ref{x86 Options}, for details of how structure layout is affected.
6315 @xref{x86 Type Attributes}, for information about the corresponding
6316 attributes on types.
6317
6318 @end table
6319
6320 @node Xstormy16 Variable Attributes
6321 @subsection Xstormy16 Variable Attributes
6322
6323 One attribute is currently defined for xstormy16 configurations:
6324 @code{below100}.
6325
6326 @table @code
6327 @item below100
6328 @cindex @code{below100} variable attribute, Xstormy16
6329
6330 If a variable has the @code{below100} attribute (@code{BELOW100} is
6331 allowed also), GCC places the variable in the first 0x100 bytes of
6332 memory and use special opcodes to access it. Such variables are
6333 placed in either the @code{.bss_below100} section or the
6334 @code{.data_below100} section.
6335
6336 @end table
6337
6338 @node Type Attributes
6339 @section Specifying Attributes of Types
6340 @cindex attribute of types
6341 @cindex type attributes
6342
6343 The keyword @code{__attribute__} allows you to specify special
6344 attributes of types. Some type attributes apply only to @code{struct}
6345 and @code{union} types, while others can apply to any type defined
6346 via a @code{typedef} declaration. Other attributes are defined for
6347 functions (@pxref{Function Attributes}), labels (@pxref{Label
6348 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6349 variables (@pxref{Variable Attributes}).
6350
6351 The @code{__attribute__} keyword is followed by an attribute specification
6352 inside double parentheses.
6353
6354 You may specify type attributes in an enum, struct or union type
6355 declaration or definition by placing them immediately after the
6356 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6357 syntax is to place them just past the closing curly brace of the
6358 definition.
6359
6360 You can also include type attributes in a @code{typedef} declaration.
6361 @xref{Attribute Syntax}, for details of the exact syntax for using
6362 attributes.
6363
6364 @menu
6365 * Common Type Attributes::
6366 * ARM Type Attributes::
6367 * MeP Type Attributes::
6368 * PowerPC Type Attributes::
6369 * SPU Type Attributes::
6370 * x86 Type Attributes::
6371 @end menu
6372
6373 @node Common Type Attributes
6374 @subsection Common Type Attributes
6375
6376 The following type attributes are supported on most targets.
6377
6378 @table @code
6379 @cindex @code{aligned} type attribute
6380 @item aligned (@var{alignment})
6381 This attribute specifies a minimum alignment (in bytes) for variables
6382 of the specified type. For example, the declarations:
6383
6384 @smallexample
6385 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6386 typedef int more_aligned_int __attribute__ ((aligned (8)));
6387 @end smallexample
6388
6389 @noindent
6390 force the compiler to ensure (as far as it can) that each variable whose
6391 type is @code{struct S} or @code{more_aligned_int} is allocated and
6392 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6393 variables of type @code{struct S} aligned to 8-byte boundaries allows
6394 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6395 store) instructions when copying one variable of type @code{struct S} to
6396 another, thus improving run-time efficiency.
6397
6398 Note that the alignment of any given @code{struct} or @code{union} type
6399 is required by the ISO C standard to be at least a perfect multiple of
6400 the lowest common multiple of the alignments of all of the members of
6401 the @code{struct} or @code{union} in question. This means that you @emph{can}
6402 effectively adjust the alignment of a @code{struct} or @code{union}
6403 type by attaching an @code{aligned} attribute to any one of the members
6404 of such a type, but the notation illustrated in the example above is a
6405 more obvious, intuitive, and readable way to request the compiler to
6406 adjust the alignment of an entire @code{struct} or @code{union} type.
6407
6408 As in the preceding example, you can explicitly specify the alignment
6409 (in bytes) that you wish the compiler to use for a given @code{struct}
6410 or @code{union} type. Alternatively, you can leave out the alignment factor
6411 and just ask the compiler to align a type to the maximum
6412 useful alignment for the target machine you are compiling for. For
6413 example, you could write:
6414
6415 @smallexample
6416 struct S @{ short f[3]; @} __attribute__ ((aligned));
6417 @end smallexample
6418
6419 Whenever you leave out the alignment factor in an @code{aligned}
6420 attribute specification, the compiler automatically sets the alignment
6421 for the type to the largest alignment that is ever used for any data
6422 type on the target machine you are compiling for. Doing this can often
6423 make copy operations more efficient, because the compiler can use
6424 whatever instructions copy the biggest chunks of memory when performing
6425 copies to or from the variables that have types that you have aligned
6426 this way.
6427
6428 In the example above, if the size of each @code{short} is 2 bytes, then
6429 the size of the entire @code{struct S} type is 6 bytes. The smallest
6430 power of two that is greater than or equal to that is 8, so the
6431 compiler sets the alignment for the entire @code{struct S} type to 8
6432 bytes.
6433
6434 Note that although you can ask the compiler to select a time-efficient
6435 alignment for a given type and then declare only individual stand-alone
6436 objects of that type, the compiler's ability to select a time-efficient
6437 alignment is primarily useful only when you plan to create arrays of
6438 variables having the relevant (efficiently aligned) type. If you
6439 declare or use arrays of variables of an efficiently-aligned type, then
6440 it is likely that your program also does pointer arithmetic (or
6441 subscripting, which amounts to the same thing) on pointers to the
6442 relevant type, and the code that the compiler generates for these
6443 pointer arithmetic operations is often more efficient for
6444 efficiently-aligned types than for other types.
6445
6446 Note that the effectiveness of @code{aligned} attributes may be limited
6447 by inherent limitations in your linker. On many systems, the linker is
6448 only able to arrange for variables to be aligned up to a certain maximum
6449 alignment. (For some linkers, the maximum supported alignment may
6450 be very very small.) If your linker is only able to align variables
6451 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6452 in an @code{__attribute__} still only provides you with 8-byte
6453 alignment. See your linker documentation for further information.
6454
6455 The @code{aligned} attribute can only increase alignment. Alignment
6456 can be decreased by specifying the @code{packed} attribute. See below.
6457
6458 @item bnd_variable_size
6459 @cindex @code{bnd_variable_size} type attribute
6460 @cindex Pointer Bounds Checker attributes
6461 When applied to a structure field, this attribute tells Pointer
6462 Bounds Checker that the size of this field should not be computed
6463 using static type information. It may be used to mark variably-sized
6464 static array fields placed at the end of a structure.
6465
6466 @smallexample
6467 struct S
6468 @{
6469 int size;
6470 char data[1];
6471 @}
6472 S *p = (S *)malloc (sizeof(S) + 100);
6473 p->data[10] = 0; //Bounds violation
6474 @end smallexample
6475
6476 @noindent
6477 By using an attribute for the field we may avoid unwanted bound
6478 violation checks:
6479
6480 @smallexample
6481 struct S
6482 @{
6483 int size;
6484 char data[1] __attribute__((bnd_variable_size));
6485 @}
6486 S *p = (S *)malloc (sizeof(S) + 100);
6487 p->data[10] = 0; //OK
6488 @end smallexample
6489
6490 @item deprecated
6491 @itemx deprecated (@var{msg})
6492 @cindex @code{deprecated} type attribute
6493 The @code{deprecated} attribute results in a warning if the type
6494 is used anywhere in the source file. This is useful when identifying
6495 types that are expected to be removed in a future version of a program.
6496 If possible, the warning also includes the location of the declaration
6497 of the deprecated type, to enable users to easily find further
6498 information about why the type is deprecated, or what they should do
6499 instead. Note that the warnings only occur for uses and then only
6500 if the type is being applied to an identifier that itself is not being
6501 declared as deprecated.
6502
6503 @smallexample
6504 typedef int T1 __attribute__ ((deprecated));
6505 T1 x;
6506 typedef T1 T2;
6507 T2 y;
6508 typedef T1 T3 __attribute__ ((deprecated));
6509 T3 z __attribute__ ((deprecated));
6510 @end smallexample
6511
6512 @noindent
6513 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6514 warning is issued for line 4 because T2 is not explicitly
6515 deprecated. Line 5 has no warning because T3 is explicitly
6516 deprecated. Similarly for line 6. The optional @var{msg}
6517 argument, which must be a string, is printed in the warning if
6518 present.
6519
6520 The @code{deprecated} attribute can also be used for functions and
6521 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6522
6523 @item designated_init
6524 @cindex @code{designated_init} type attribute
6525 This attribute may only be applied to structure types. It indicates
6526 that any initialization of an object of this type must use designated
6527 initializers rather than positional initializers. The intent of this
6528 attribute is to allow the programmer to indicate that a structure's
6529 layout may change, and that therefore relying on positional
6530 initialization will result in future breakage.
6531
6532 GCC emits warnings based on this attribute by default; use
6533 @option{-Wno-designated-init} to suppress them.
6534
6535 @item may_alias
6536 @cindex @code{may_alias} type attribute
6537 Accesses through pointers to types with this attribute are not subject
6538 to type-based alias analysis, but are instead assumed to be able to alias
6539 any other type of objects.
6540 In the context of section 6.5 paragraph 7 of the C99 standard,
6541 an lvalue expression
6542 dereferencing such a pointer is treated like having a character type.
6543 See @option{-fstrict-aliasing} for more information on aliasing issues.
6544 This extension exists to support some vector APIs, in which pointers to
6545 one vector type are permitted to alias pointers to a different vector type.
6546
6547 Note that an object of a type with this attribute does not have any
6548 special semantics.
6549
6550 Example of use:
6551
6552 @smallexample
6553 typedef short __attribute__((__may_alias__)) short_a;
6554
6555 int
6556 main (void)
6557 @{
6558 int a = 0x12345678;
6559 short_a *b = (short_a *) &a;
6560
6561 b[1] = 0;
6562
6563 if (a == 0x12345678)
6564 abort();
6565
6566 exit(0);
6567 @}
6568 @end smallexample
6569
6570 @noindent
6571 If you replaced @code{short_a} with @code{short} in the variable
6572 declaration, the above program would abort when compiled with
6573 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6574 above.
6575
6576 @item packed
6577 @cindex @code{packed} type attribute
6578 This attribute, attached to @code{struct} or @code{union} type
6579 definition, specifies that each member (other than zero-width bit-fields)
6580 of the structure or union is placed to minimize the memory required. When
6581 attached to an @code{enum} definition, it indicates that the smallest
6582 integral type should be used.
6583
6584 @opindex fshort-enums
6585 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6586 types is equivalent to specifying the @code{packed} attribute on each
6587 of the structure or union members. Specifying the @option{-fshort-enums}
6588 flag on the command line is equivalent to specifying the @code{packed}
6589 attribute on all @code{enum} definitions.
6590
6591 In the following example @code{struct my_packed_struct}'s members are
6592 packed closely together, but the internal layout of its @code{s} member
6593 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6594 be packed too.
6595
6596 @smallexample
6597 struct my_unpacked_struct
6598 @{
6599 char c;
6600 int i;
6601 @};
6602
6603 struct __attribute__ ((__packed__)) my_packed_struct
6604 @{
6605 char c;
6606 int i;
6607 struct my_unpacked_struct s;
6608 @};
6609 @end smallexample
6610
6611 You may only specify the @code{packed} attribute attribute on the definition
6612 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6613 that does not also define the enumerated type, structure or union.
6614
6615 @item scalar_storage_order ("@var{endianness}")
6616 @cindex @code{scalar_storage_order} type attribute
6617 When attached to a @code{union} or a @code{struct}, this attribute sets
6618 the storage order, aka endianness, of the scalar fields of the type, as
6619 well as the array fields whose component is scalar. The supported
6620 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6621 has no effects on fields which are themselves a @code{union}, a @code{struct}
6622 or an array whose component is a @code{union} or a @code{struct}, and it is
6623 possible for these fields to have a different scalar storage order than the
6624 enclosing type.
6625
6626 This attribute is supported only for targets that use a uniform default
6627 scalar storage order (fortunately, most of them), i.e. targets that store
6628 the scalars either all in big-endian or all in little-endian.
6629
6630 Additional restrictions are enforced for types with the reverse scalar
6631 storage order with regard to the scalar storage order of the target:
6632
6633 @itemize
6634 @item Taking the address of a scalar field of a @code{union} or a
6635 @code{struct} with reverse scalar storage order is not permitted and yields
6636 an error.
6637 @item Taking the address of an array field, whose component is scalar, of
6638 a @code{union} or a @code{struct} with reverse scalar storage order is
6639 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6640 is specified.
6641 @item Taking the address of a @code{union} or a @code{struct} with reverse
6642 scalar storage order is permitted.
6643 @end itemize
6644
6645 These restrictions exist because the storage order attribute is lost when
6646 the address of a scalar or the address of an array with scalar component is
6647 taken, so storing indirectly through this address generally does not work.
6648 The second case is nevertheless allowed to be able to perform a block copy
6649 from or to the array.
6650
6651 Moreover, the use of type punning or aliasing to toggle the storage order
6652 is not supported; that is to say, a given scalar object cannot be accessed
6653 through distinct types that assign a different storage order to it.
6654
6655 @item transparent_union
6656 @cindex @code{transparent_union} type attribute
6657
6658 This attribute, attached to a @code{union} type definition, indicates
6659 that any function parameter having that union type causes calls to that
6660 function to be treated in a special way.
6661
6662 First, the argument corresponding to a transparent union type can be of
6663 any type in the union; no cast is required. Also, if the union contains
6664 a pointer type, the corresponding argument can be a null pointer
6665 constant or a void pointer expression; and if the union contains a void
6666 pointer type, the corresponding argument can be any pointer expression.
6667 If the union member type is a pointer, qualifiers like @code{const} on
6668 the referenced type must be respected, just as with normal pointer
6669 conversions.
6670
6671 Second, the argument is passed to the function using the calling
6672 conventions of the first member of the transparent union, not the calling
6673 conventions of the union itself. All members of the union must have the
6674 same machine representation; this is necessary for this argument passing
6675 to work properly.
6676
6677 Transparent unions are designed for library functions that have multiple
6678 interfaces for compatibility reasons. For example, suppose the
6679 @code{wait} function must accept either a value of type @code{int *} to
6680 comply with POSIX, or a value of type @code{union wait *} to comply with
6681 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6682 @code{wait} would accept both kinds of arguments, but it would also
6683 accept any other pointer type and this would make argument type checking
6684 less useful. Instead, @code{<sys/wait.h>} might define the interface
6685 as follows:
6686
6687 @smallexample
6688 typedef union __attribute__ ((__transparent_union__))
6689 @{
6690 int *__ip;
6691 union wait *__up;
6692 @} wait_status_ptr_t;
6693
6694 pid_t wait (wait_status_ptr_t);
6695 @end smallexample
6696
6697 @noindent
6698 This interface allows either @code{int *} or @code{union wait *}
6699 arguments to be passed, using the @code{int *} calling convention.
6700 The program can call @code{wait} with arguments of either type:
6701
6702 @smallexample
6703 int w1 () @{ int w; return wait (&w); @}
6704 int w2 () @{ union wait w; return wait (&w); @}
6705 @end smallexample
6706
6707 @noindent
6708 With this interface, @code{wait}'s implementation might look like this:
6709
6710 @smallexample
6711 pid_t wait (wait_status_ptr_t p)
6712 @{
6713 return waitpid (-1, p.__ip, 0);
6714 @}
6715 @end smallexample
6716
6717 @item unused
6718 @cindex @code{unused} type attribute
6719 When attached to a type (including a @code{union} or a @code{struct}),
6720 this attribute means that variables of that type are meant to appear
6721 possibly unused. GCC does not produce a warning for any variables of
6722 that type, even if the variable appears to do nothing. This is often
6723 the case with lock or thread classes, which are usually defined and then
6724 not referenced, but contain constructors and destructors that have
6725 nontrivial bookkeeping functions.
6726
6727 @item visibility
6728 @cindex @code{visibility} type attribute
6729 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6730 applied to class, struct, union and enum types. Unlike other type
6731 attributes, the attribute must appear between the initial keyword and
6732 the name of the type; it cannot appear after the body of the type.
6733
6734 Note that the type visibility is applied to vague linkage entities
6735 associated with the class (vtable, typeinfo node, etc.). In
6736 particular, if a class is thrown as an exception in one shared object
6737 and caught in another, the class must have default visibility.
6738 Otherwise the two shared objects are unable to use the same
6739 typeinfo node and exception handling will break.
6740
6741 @end table
6742
6743 To specify multiple attributes, separate them by commas within the
6744 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6745 packed))}.
6746
6747 @node ARM Type Attributes
6748 @subsection ARM Type Attributes
6749
6750 @cindex @code{notshared} type attribute, ARM
6751 On those ARM targets that support @code{dllimport} (such as Symbian
6752 OS), you can use the @code{notshared} attribute to indicate that the
6753 virtual table and other similar data for a class should not be
6754 exported from a DLL@. For example:
6755
6756 @smallexample
6757 class __declspec(notshared) C @{
6758 public:
6759 __declspec(dllimport) C();
6760 virtual void f();
6761 @}
6762
6763 __declspec(dllexport)
6764 C::C() @{@}
6765 @end smallexample
6766
6767 @noindent
6768 In this code, @code{C::C} is exported from the current DLL, but the
6769 virtual table for @code{C} is not exported. (You can use
6770 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6771 most Symbian OS code uses @code{__declspec}.)
6772
6773 @node MeP Type Attributes
6774 @subsection MeP Type Attributes
6775
6776 @cindex @code{based} type attribute, MeP
6777 @cindex @code{tiny} type attribute, MeP
6778 @cindex @code{near} type attribute, MeP
6779 @cindex @code{far} type attribute, MeP
6780 Many of the MeP variable attributes may be applied to types as well.
6781 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6782 @code{far} attributes may be applied to either. The @code{io} and
6783 @code{cb} attributes may not be applied to types.
6784
6785 @node PowerPC Type Attributes
6786 @subsection PowerPC Type Attributes
6787
6788 Three attributes currently are defined for PowerPC configurations:
6789 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6790
6791 @cindex @code{ms_struct} type attribute, PowerPC
6792 @cindex @code{gcc_struct} type attribute, PowerPC
6793 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6794 attributes please see the documentation in @ref{x86 Type Attributes}.
6795
6796 @cindex @code{altivec} type attribute, PowerPC
6797 The @code{altivec} attribute allows one to declare AltiVec vector data
6798 types supported by the AltiVec Programming Interface Manual. The
6799 attribute requires an argument to specify one of three vector types:
6800 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6801 and @code{bool__} (always followed by unsigned).
6802
6803 @smallexample
6804 __attribute__((altivec(vector__)))
6805 __attribute__((altivec(pixel__))) unsigned short
6806 __attribute__((altivec(bool__))) unsigned
6807 @end smallexample
6808
6809 These attributes mainly are intended to support the @code{__vector},
6810 @code{__pixel}, and @code{__bool} AltiVec keywords.
6811
6812 @node SPU Type Attributes
6813 @subsection SPU Type Attributes
6814
6815 @cindex @code{spu_vector} type attribute, SPU
6816 The SPU supports the @code{spu_vector} attribute for types. This attribute
6817 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6818 Language Extensions Specification. It is intended to support the
6819 @code{__vector} keyword.
6820
6821 @node x86 Type Attributes
6822 @subsection x86 Type Attributes
6823
6824 Two attributes are currently defined for x86 configurations:
6825 @code{ms_struct} and @code{gcc_struct}.
6826
6827 @table @code
6828
6829 @item ms_struct
6830 @itemx gcc_struct
6831 @cindex @code{ms_struct} type attribute, x86
6832 @cindex @code{gcc_struct} type attribute, x86
6833
6834 If @code{packed} is used on a structure, or if bit-fields are used
6835 it may be that the Microsoft ABI packs them differently
6836 than GCC normally packs them. Particularly when moving packed
6837 data between functions compiled with GCC and the native Microsoft compiler
6838 (either via function call or as data in a file), it may be necessary to access
6839 either format.
6840
6841 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6842 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6843 command-line options, respectively;
6844 see @ref{x86 Options}, for details of how structure layout is affected.
6845 @xref{x86 Variable Attributes}, for information about the corresponding
6846 attributes on variables.
6847
6848 @end table
6849
6850 @node Label Attributes
6851 @section Label Attributes
6852 @cindex Label Attributes
6853
6854 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6855 details of the exact syntax for using attributes. Other attributes are
6856 available for functions (@pxref{Function Attributes}), variables
6857 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6858 and for types (@pxref{Type Attributes}).
6859
6860 This example uses the @code{cold} label attribute to indicate the
6861 @code{ErrorHandling} branch is unlikely to be taken and that the
6862 @code{ErrorHandling} label is unused:
6863
6864 @smallexample
6865
6866 asm goto ("some asm" : : : : NoError);
6867
6868 /* This branch (the fall-through from the asm) is less commonly used */
6869 ErrorHandling:
6870 __attribute__((cold, unused)); /* Semi-colon is required here */
6871 printf("error\n");
6872 return 0;
6873
6874 NoError:
6875 printf("no error\n");
6876 return 1;
6877 @end smallexample
6878
6879 @table @code
6880 @item unused
6881 @cindex @code{unused} label attribute
6882 This feature is intended for program-generated code that may contain
6883 unused labels, but which is compiled with @option{-Wall}. It is
6884 not normally appropriate to use in it human-written code, though it
6885 could be useful in cases where the code that jumps to the label is
6886 contained within an @code{#ifdef} conditional.
6887
6888 @item hot
6889 @cindex @code{hot} label attribute
6890 The @code{hot} attribute on a label is used to inform the compiler that
6891 the path following the label is more likely than paths that are not so
6892 annotated. This attribute is used in cases where @code{__builtin_expect}
6893 cannot be used, for instance with computed goto or @code{asm goto}.
6894
6895 @item cold
6896 @cindex @code{cold} label attribute
6897 The @code{cold} attribute on labels is used to inform the compiler that
6898 the path following the label is unlikely to be executed. This attribute
6899 is used in cases where @code{__builtin_expect} cannot be used, for instance
6900 with computed goto or @code{asm goto}.
6901
6902 @end table
6903
6904 @node Enumerator Attributes
6905 @section Enumerator Attributes
6906 @cindex Enumerator Attributes
6907
6908 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6909 details of the exact syntax for using attributes. Other attributes are
6910 available for functions (@pxref{Function Attributes}), variables
6911 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6912 and for types (@pxref{Type Attributes}).
6913
6914 This example uses the @code{deprecated} enumerator attribute to indicate the
6915 @code{oldval} enumerator is deprecated:
6916
6917 @smallexample
6918 enum E @{
6919 oldval __attribute__((deprecated)),
6920 newval
6921 @};
6922
6923 int
6924 fn (void)
6925 @{
6926 return oldval;
6927 @}
6928 @end smallexample
6929
6930 @table @code
6931 @item deprecated
6932 @cindex @code{deprecated} enumerator attribute
6933 The @code{deprecated} attribute results in a warning if the enumerator
6934 is used anywhere in the source file. This is useful when identifying
6935 enumerators that are expected to be removed in a future version of a
6936 program. The warning also includes the location of the declaration
6937 of the deprecated enumerator, to enable users to easily find further
6938 information about why the enumerator is deprecated, or what they should
6939 do instead. Note that the warnings only occurs for uses.
6940
6941 @end table
6942
6943 @node Attribute Syntax
6944 @section Attribute Syntax
6945 @cindex attribute syntax
6946
6947 This section describes the syntax with which @code{__attribute__} may be
6948 used, and the constructs to which attribute specifiers bind, for the C
6949 language. Some details may vary for C++ and Objective-C@. Because of
6950 infelicities in the grammar for attributes, some forms described here
6951 may not be successfully parsed in all cases.
6952
6953 There are some problems with the semantics of attributes in C++. For
6954 example, there are no manglings for attributes, although they may affect
6955 code generation, so problems may arise when attributed types are used in
6956 conjunction with templates or overloading. Similarly, @code{typeid}
6957 does not distinguish between types with different attributes. Support
6958 for attributes in C++ may be restricted in future to attributes on
6959 declarations only, but not on nested declarators.
6960
6961 @xref{Function Attributes}, for details of the semantics of attributes
6962 applying to functions. @xref{Variable Attributes}, for details of the
6963 semantics of attributes applying to variables. @xref{Type Attributes},
6964 for details of the semantics of attributes applying to structure, union
6965 and enumerated types.
6966 @xref{Label Attributes}, for details of the semantics of attributes
6967 applying to labels.
6968 @xref{Enumerator Attributes}, for details of the semantics of attributes
6969 applying to enumerators.
6970
6971 An @dfn{attribute specifier} is of the form
6972 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6973 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6974 each attribute is one of the following:
6975
6976 @itemize @bullet
6977 @item
6978 Empty. Empty attributes are ignored.
6979
6980 @item
6981 An attribute name
6982 (which may be an identifier such as @code{unused}, or a reserved
6983 word such as @code{const}).
6984
6985 @item
6986 An attribute name followed by a parenthesized list of
6987 parameters for the attribute.
6988 These parameters take one of the following forms:
6989
6990 @itemize @bullet
6991 @item
6992 An identifier. For example, @code{mode} attributes use this form.
6993
6994 @item
6995 An identifier followed by a comma and a non-empty comma-separated list
6996 of expressions. For example, @code{format} attributes use this form.
6997
6998 @item
6999 A possibly empty comma-separated list of expressions. For example,
7000 @code{format_arg} attributes use this form with the list being a single
7001 integer constant expression, and @code{alias} attributes use this form
7002 with the list being a single string constant.
7003 @end itemize
7004 @end itemize
7005
7006 An @dfn{attribute specifier list} is a sequence of one or more attribute
7007 specifiers, not separated by any other tokens.
7008
7009 You may optionally specify attribute names with @samp{__}
7010 preceding and following the name.
7011 This allows you to use them in header files without
7012 being concerned about a possible macro of the same name. For example,
7013 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7014
7015
7016 @subsubheading Label Attributes
7017
7018 In GNU C, an attribute specifier list may appear after the colon following a
7019 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7020 attributes on labels if the attribute specifier is immediately
7021 followed by a semicolon (i.e., the label applies to an empty
7022 statement). If the semicolon is missing, C++ label attributes are
7023 ambiguous, as it is permissible for a declaration, which could begin
7024 with an attribute list, to be labelled in C++. Declarations cannot be
7025 labelled in C90 or C99, so the ambiguity does not arise there.
7026
7027 @subsubheading Enumerator Attributes
7028
7029 In GNU C, an attribute specifier list may appear as part of an enumerator.
7030 The attribute goes after the enumeration constant, before @code{=}, if
7031 present. The optional attribute in the enumerator appertains to the
7032 enumeration constant. It is not possible to place the attribute after
7033 the constant expression, if present.
7034
7035 @subsubheading Type Attributes
7036
7037 An attribute specifier list may appear as part of a @code{struct},
7038 @code{union} or @code{enum} specifier. It may go either immediately
7039 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7040 the closing brace. The former syntax is preferred.
7041 Where attribute specifiers follow the closing brace, they are considered
7042 to relate to the structure, union or enumerated type defined, not to any
7043 enclosing declaration the type specifier appears in, and the type
7044 defined is not complete until after the attribute specifiers.
7045 @c Otherwise, there would be the following problems: a shift/reduce
7046 @c conflict between attributes binding the struct/union/enum and
7047 @c binding to the list of specifiers/qualifiers; and "aligned"
7048 @c attributes could use sizeof for the structure, but the size could be
7049 @c changed later by "packed" attributes.
7050
7051
7052 @subsubheading All other attributes
7053
7054 Otherwise, an attribute specifier appears as part of a declaration,
7055 counting declarations of unnamed parameters and type names, and relates
7056 to that declaration (which may be nested in another declaration, for
7057 example in the case of a parameter declaration), or to a particular declarator
7058 within a declaration. Where an
7059 attribute specifier is applied to a parameter declared as a function or
7060 an array, it should apply to the function or array rather than the
7061 pointer to which the parameter is implicitly converted, but this is not
7062 yet correctly implemented.
7063
7064 Any list of specifiers and qualifiers at the start of a declaration may
7065 contain attribute specifiers, whether or not such a list may in that
7066 context contain storage class specifiers. (Some attributes, however,
7067 are essentially in the nature of storage class specifiers, and only make
7068 sense where storage class specifiers may be used; for example,
7069 @code{section}.) There is one necessary limitation to this syntax: the
7070 first old-style parameter declaration in a function definition cannot
7071 begin with an attribute specifier, because such an attribute applies to
7072 the function instead by syntax described below (which, however, is not
7073 yet implemented in this case). In some other cases, attribute
7074 specifiers are permitted by this grammar but not yet supported by the
7075 compiler. All attribute specifiers in this place relate to the
7076 declaration as a whole. In the obsolescent usage where a type of
7077 @code{int} is implied by the absence of type specifiers, such a list of
7078 specifiers and qualifiers may be an attribute specifier list with no
7079 other specifiers or qualifiers.
7080
7081 At present, the first parameter in a function prototype must have some
7082 type specifier that is not an attribute specifier; this resolves an
7083 ambiguity in the interpretation of @code{void f(int
7084 (__attribute__((foo)) x))}, but is subject to change. At present, if
7085 the parentheses of a function declarator contain only attributes then
7086 those attributes are ignored, rather than yielding an error or warning
7087 or implying a single parameter of type int, but this is subject to
7088 change.
7089
7090 An attribute specifier list may appear immediately before a declarator
7091 (other than the first) in a comma-separated list of declarators in a
7092 declaration of more than one identifier using a single list of
7093 specifiers and qualifiers. Such attribute specifiers apply
7094 only to the identifier before whose declarator they appear. For
7095 example, in
7096
7097 @smallexample
7098 __attribute__((noreturn)) void d0 (void),
7099 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7100 d2 (void);
7101 @end smallexample
7102
7103 @noindent
7104 the @code{noreturn} attribute applies to all the functions
7105 declared; the @code{format} attribute only applies to @code{d1}.
7106
7107 An attribute specifier list may appear immediately before the comma,
7108 @code{=} or semicolon terminating the declaration of an identifier other
7109 than a function definition. Such attribute specifiers apply
7110 to the declared object or function. Where an
7111 assembler name for an object or function is specified (@pxref{Asm
7112 Labels}), the attribute must follow the @code{asm}
7113 specification.
7114
7115 An attribute specifier list may, in future, be permitted to appear after
7116 the declarator in a function definition (before any old-style parameter
7117 declarations or the function body).
7118
7119 Attribute specifiers may be mixed with type qualifiers appearing inside
7120 the @code{[]} of a parameter array declarator, in the C99 construct by
7121 which such qualifiers are applied to the pointer to which the array is
7122 implicitly converted. Such attribute specifiers apply to the pointer,
7123 not to the array, but at present this is not implemented and they are
7124 ignored.
7125
7126 An attribute specifier list may appear at the start of a nested
7127 declarator. At present, there are some limitations in this usage: the
7128 attributes correctly apply to the declarator, but for most individual
7129 attributes the semantics this implies are not implemented.
7130 When attribute specifiers follow the @code{*} of a pointer
7131 declarator, they may be mixed with any type qualifiers present.
7132 The following describes the formal semantics of this syntax. It makes the
7133 most sense if you are familiar with the formal specification of
7134 declarators in the ISO C standard.
7135
7136 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7137 D1}, where @code{T} contains declaration specifiers that specify a type
7138 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7139 contains an identifier @var{ident}. The type specified for @var{ident}
7140 for derived declarators whose type does not include an attribute
7141 specifier is as in the ISO C standard.
7142
7143 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7144 and the declaration @code{T D} specifies the type
7145 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7146 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7147 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7148
7149 If @code{D1} has the form @code{*
7150 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7151 declaration @code{T D} specifies the type
7152 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7153 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7154 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7155 @var{ident}.
7156
7157 For example,
7158
7159 @smallexample
7160 void (__attribute__((noreturn)) ****f) (void);
7161 @end smallexample
7162
7163 @noindent
7164 specifies the type ``pointer to pointer to pointer to pointer to
7165 non-returning function returning @code{void}''. As another example,
7166
7167 @smallexample
7168 char *__attribute__((aligned(8))) *f;
7169 @end smallexample
7170
7171 @noindent
7172 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7173 Note again that this does not work with most attributes; for example,
7174 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7175 is not yet supported.
7176
7177 For compatibility with existing code written for compiler versions that
7178 did not implement attributes on nested declarators, some laxity is
7179 allowed in the placing of attributes. If an attribute that only applies
7180 to types is applied to a declaration, it is treated as applying to
7181 the type of that declaration. If an attribute that only applies to
7182 declarations is applied to the type of a declaration, it is treated
7183 as applying to that declaration; and, for compatibility with code
7184 placing the attributes immediately before the identifier declared, such
7185 an attribute applied to a function return type is treated as
7186 applying to the function type, and such an attribute applied to an array
7187 element type is treated as applying to the array type. If an
7188 attribute that only applies to function types is applied to a
7189 pointer-to-function type, it is treated as applying to the pointer
7190 target type; if such an attribute is applied to a function return type
7191 that is not a pointer-to-function type, it is treated as applying
7192 to the function type.
7193
7194 @node Function Prototypes
7195 @section Prototypes and Old-Style Function Definitions
7196 @cindex function prototype declarations
7197 @cindex old-style function definitions
7198 @cindex promotion of formal parameters
7199
7200 GNU C extends ISO C to allow a function prototype to override a later
7201 old-style non-prototype definition. Consider the following example:
7202
7203 @smallexample
7204 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7205 #ifdef __STDC__
7206 #define P(x) x
7207 #else
7208 #define P(x) ()
7209 #endif
7210
7211 /* @r{Prototype function declaration.} */
7212 int isroot P((uid_t));
7213
7214 /* @r{Old-style function definition.} */
7215 int
7216 isroot (x) /* @r{??? lossage here ???} */
7217 uid_t x;
7218 @{
7219 return x == 0;
7220 @}
7221 @end smallexample
7222
7223 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7224 not allow this example, because subword arguments in old-style
7225 non-prototype definitions are promoted. Therefore in this example the
7226 function definition's argument is really an @code{int}, which does not
7227 match the prototype argument type of @code{short}.
7228
7229 This restriction of ISO C makes it hard to write code that is portable
7230 to traditional C compilers, because the programmer does not know
7231 whether the @code{uid_t} type is @code{short}, @code{int}, or
7232 @code{long}. Therefore, in cases like these GNU C allows a prototype
7233 to override a later old-style definition. More precisely, in GNU C, a
7234 function prototype argument type overrides the argument type specified
7235 by a later old-style definition if the former type is the same as the
7236 latter type before promotion. Thus in GNU C the above example is
7237 equivalent to the following:
7238
7239 @smallexample
7240 int isroot (uid_t);
7241
7242 int
7243 isroot (uid_t x)
7244 @{
7245 return x == 0;
7246 @}
7247 @end smallexample
7248
7249 @noindent
7250 GNU C++ does not support old-style function definitions, so this
7251 extension is irrelevant.
7252
7253 @node C++ Comments
7254 @section C++ Style Comments
7255 @cindex @code{//}
7256 @cindex C++ comments
7257 @cindex comments, C++ style
7258
7259 In GNU C, you may use C++ style comments, which start with @samp{//} and
7260 continue until the end of the line. Many other C implementations allow
7261 such comments, and they are included in the 1999 C standard. However,
7262 C++ style comments are not recognized if you specify an @option{-std}
7263 option specifying a version of ISO C before C99, or @option{-ansi}
7264 (equivalent to @option{-std=c90}).
7265
7266 @node Dollar Signs
7267 @section Dollar Signs in Identifier Names
7268 @cindex $
7269 @cindex dollar signs in identifier names
7270 @cindex identifier names, dollar signs in
7271
7272 In GNU C, you may normally use dollar signs in identifier names.
7273 This is because many traditional C implementations allow such identifiers.
7274 However, dollar signs in identifiers are not supported on a few target
7275 machines, typically because the target assembler does not allow them.
7276
7277 @node Character Escapes
7278 @section The Character @key{ESC} in Constants
7279
7280 You can use the sequence @samp{\e} in a string or character constant to
7281 stand for the ASCII character @key{ESC}.
7282
7283 @node Alignment
7284 @section Inquiring on Alignment of Types or Variables
7285 @cindex alignment
7286 @cindex type alignment
7287 @cindex variable alignment
7288
7289 The keyword @code{__alignof__} allows you to inquire about how an object
7290 is aligned, or the minimum alignment usually required by a type. Its
7291 syntax is just like @code{sizeof}.
7292
7293 For example, if the target machine requires a @code{double} value to be
7294 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7295 This is true on many RISC machines. On more traditional machine
7296 designs, @code{__alignof__ (double)} is 4 or even 2.
7297
7298 Some machines never actually require alignment; they allow reference to any
7299 data type even at an odd address. For these machines, @code{__alignof__}
7300 reports the smallest alignment that GCC gives the data type, usually as
7301 mandated by the target ABI.
7302
7303 If the operand of @code{__alignof__} is an lvalue rather than a type,
7304 its value is the required alignment for its type, taking into account
7305 any minimum alignment specified with GCC's @code{__attribute__}
7306 extension (@pxref{Variable Attributes}). For example, after this
7307 declaration:
7308
7309 @smallexample
7310 struct foo @{ int x; char y; @} foo1;
7311 @end smallexample
7312
7313 @noindent
7314 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7315 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7316
7317 It is an error to ask for the alignment of an incomplete type.
7318
7319
7320 @node Inline
7321 @section An Inline Function is As Fast As a Macro
7322 @cindex inline functions
7323 @cindex integrating function code
7324 @cindex open coding
7325 @cindex macros, inline alternative
7326
7327 By declaring a function inline, you can direct GCC to make
7328 calls to that function faster. One way GCC can achieve this is to
7329 integrate that function's code into the code for its callers. This
7330 makes execution faster by eliminating the function-call overhead; in
7331 addition, if any of the actual argument values are constant, their
7332 known values may permit simplifications at compile time so that not
7333 all of the inline function's code needs to be included. The effect on
7334 code size is less predictable; object code may be larger or smaller
7335 with function inlining, depending on the particular case. You can
7336 also direct GCC to try to integrate all ``simple enough'' functions
7337 into their callers with the option @option{-finline-functions}.
7338
7339 GCC implements three different semantics of declaring a function
7340 inline. One is available with @option{-std=gnu89} or
7341 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7342 on all inline declarations, another when
7343 @option{-std=c99}, @option{-std=c11},
7344 @option{-std=gnu99} or @option{-std=gnu11}
7345 (without @option{-fgnu89-inline}), and the third
7346 is used when compiling C++.
7347
7348 To declare a function inline, use the @code{inline} keyword in its
7349 declaration, like this:
7350
7351 @smallexample
7352 static inline int
7353 inc (int *a)
7354 @{
7355 return (*a)++;
7356 @}
7357 @end smallexample
7358
7359 If you are writing a header file to be included in ISO C90 programs, write
7360 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7361
7362 The three types of inlining behave similarly in two important cases:
7363 when the @code{inline} keyword is used on a @code{static} function,
7364 like the example above, and when a function is first declared without
7365 using the @code{inline} keyword and then is defined with
7366 @code{inline}, like this:
7367
7368 @smallexample
7369 extern int inc (int *a);
7370 inline int
7371 inc (int *a)
7372 @{
7373 return (*a)++;
7374 @}
7375 @end smallexample
7376
7377 In both of these common cases, the program behaves the same as if you
7378 had not used the @code{inline} keyword, except for its speed.
7379
7380 @cindex inline functions, omission of
7381 @opindex fkeep-inline-functions
7382 When a function is both inline and @code{static}, if all calls to the
7383 function are integrated into the caller, and the function's address is
7384 never used, then the function's own assembler code is never referenced.
7385 In this case, GCC does not actually output assembler code for the
7386 function, unless you specify the option @option{-fkeep-inline-functions}.
7387 If there is a nonintegrated call, then the function is compiled to
7388 assembler code as usual. The function must also be compiled as usual if
7389 the program refers to its address, because that can't be inlined.
7390
7391 @opindex Winline
7392 Note that certain usages in a function definition can make it unsuitable
7393 for inline substitution. Among these usages are: variadic functions,
7394 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7395 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7396 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7397 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7398 function marked @code{inline} could not be substituted, and gives the
7399 reason for the failure.
7400
7401 @cindex automatic @code{inline} for C++ member fns
7402 @cindex @code{inline} automatic for C++ member fns
7403 @cindex member fns, automatically @code{inline}
7404 @cindex C++ member fns, automatically @code{inline}
7405 @opindex fno-default-inline
7406 As required by ISO C++, GCC considers member functions defined within
7407 the body of a class to be marked inline even if they are
7408 not explicitly declared with the @code{inline} keyword. You can
7409 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7410 Options,,Options Controlling C++ Dialect}.
7411
7412 GCC does not inline any functions when not optimizing unless you specify
7413 the @samp{always_inline} attribute for the function, like this:
7414
7415 @smallexample
7416 /* @r{Prototype.} */
7417 inline void foo (const char) __attribute__((always_inline));
7418 @end smallexample
7419
7420 The remainder of this section is specific to GNU C90 inlining.
7421
7422 @cindex non-static inline function
7423 When an inline function is not @code{static}, then the compiler must assume
7424 that there may be calls from other source files; since a global symbol can
7425 be defined only once in any program, the function must not be defined in
7426 the other source files, so the calls therein cannot be integrated.
7427 Therefore, a non-@code{static} inline function is always compiled on its
7428 own in the usual fashion.
7429
7430 If you specify both @code{inline} and @code{extern} in the function
7431 definition, then the definition is used only for inlining. In no case
7432 is the function compiled on its own, not even if you refer to its
7433 address explicitly. Such an address becomes an external reference, as
7434 if you had only declared the function, and had not defined it.
7435
7436 This combination of @code{inline} and @code{extern} has almost the
7437 effect of a macro. The way to use it is to put a function definition in
7438 a header file with these keywords, and put another copy of the
7439 definition (lacking @code{inline} and @code{extern}) in a library file.
7440 The definition in the header file causes most calls to the function
7441 to be inlined. If any uses of the function remain, they refer to
7442 the single copy in the library.
7443
7444 @node Volatiles
7445 @section When is a Volatile Object Accessed?
7446 @cindex accessing volatiles
7447 @cindex volatile read
7448 @cindex volatile write
7449 @cindex volatile access
7450
7451 C has the concept of volatile objects. These are normally accessed by
7452 pointers and used for accessing hardware or inter-thread
7453 communication. The standard encourages compilers to refrain from
7454 optimizations concerning accesses to volatile objects, but leaves it
7455 implementation defined as to what constitutes a volatile access. The
7456 minimum requirement is that at a sequence point all previous accesses
7457 to volatile objects have stabilized and no subsequent accesses have
7458 occurred. Thus an implementation is free to reorder and combine
7459 volatile accesses that occur between sequence points, but cannot do
7460 so for accesses across a sequence point. The use of volatile does
7461 not allow you to violate the restriction on updating objects multiple
7462 times between two sequence points.
7463
7464 Accesses to non-volatile objects are not ordered with respect to
7465 volatile accesses. You cannot use a volatile object as a memory
7466 barrier to order a sequence of writes to non-volatile memory. For
7467 instance:
7468
7469 @smallexample
7470 int *ptr = @var{something};
7471 volatile int vobj;
7472 *ptr = @var{something};
7473 vobj = 1;
7474 @end smallexample
7475
7476 @noindent
7477 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7478 that the write to @var{*ptr} occurs by the time the update
7479 of @var{vobj} happens. If you need this guarantee, you must use
7480 a stronger memory barrier such as:
7481
7482 @smallexample
7483 int *ptr = @var{something};
7484 volatile int vobj;
7485 *ptr = @var{something};
7486 asm volatile ("" : : : "memory");
7487 vobj = 1;
7488 @end smallexample
7489
7490 A scalar volatile object is read when it is accessed in a void context:
7491
7492 @smallexample
7493 volatile int *src = @var{somevalue};
7494 *src;
7495 @end smallexample
7496
7497 Such expressions are rvalues, and GCC implements this as a
7498 read of the volatile object being pointed to.
7499
7500 Assignments are also expressions and have an rvalue. However when
7501 assigning to a scalar volatile, the volatile object is not reread,
7502 regardless of whether the assignment expression's rvalue is used or
7503 not. If the assignment's rvalue is used, the value is that assigned
7504 to the volatile object. For instance, there is no read of @var{vobj}
7505 in all the following cases:
7506
7507 @smallexample
7508 int obj;
7509 volatile int vobj;
7510 vobj = @var{something};
7511 obj = vobj = @var{something};
7512 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7513 obj = (@var{something}, vobj = @var{anotherthing});
7514 @end smallexample
7515
7516 If you need to read the volatile object after an assignment has
7517 occurred, you must use a separate expression with an intervening
7518 sequence point.
7519
7520 As bit-fields are not individually addressable, volatile bit-fields may
7521 be implicitly read when written to, or when adjacent bit-fields are
7522 accessed. Bit-field operations may be optimized such that adjacent
7523 bit-fields are only partially accessed, if they straddle a storage unit
7524 boundary. For these reasons it is unwise to use volatile bit-fields to
7525 access hardware.
7526
7527 @node Using Assembly Language with C
7528 @section How to Use Inline Assembly Language in C Code
7529 @cindex @code{asm} keyword
7530 @cindex assembly language in C
7531 @cindex inline assembly language
7532 @cindex mixing assembly language and C
7533
7534 The @code{asm} keyword allows you to embed assembler instructions
7535 within C code. GCC provides two forms of inline @code{asm}
7536 statements. A @dfn{basic @code{asm}} statement is one with no
7537 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7538 statement (@pxref{Extended Asm}) includes one or more operands.
7539 The extended form is preferred for mixing C and assembly language
7540 within a function, but to include assembly language at
7541 top level you must use basic @code{asm}.
7542
7543 You can also use the @code{asm} keyword to override the assembler name
7544 for a C symbol, or to place a C variable in a specific register.
7545
7546 @menu
7547 * Basic Asm:: Inline assembler without operands.
7548 * Extended Asm:: Inline assembler with operands.
7549 * Constraints:: Constraints for @code{asm} operands
7550 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7551 * Explicit Register Variables:: Defining variables residing in specified
7552 registers.
7553 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7554 @end menu
7555
7556 @node Basic Asm
7557 @subsection Basic Asm --- Assembler Instructions Without Operands
7558 @cindex basic @code{asm}
7559 @cindex assembly language in C, basic
7560
7561 A basic @code{asm} statement has the following syntax:
7562
7563 @example
7564 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7565 @end example
7566
7567 The @code{asm} keyword is a GNU extension.
7568 When writing code that can be compiled with @option{-ansi} and the
7569 various @option{-std} options, use @code{__asm__} instead of
7570 @code{asm} (@pxref{Alternate Keywords}).
7571
7572 @subsubheading Qualifiers
7573 @table @code
7574 @item volatile
7575 The optional @code{volatile} qualifier has no effect.
7576 All basic @code{asm} blocks are implicitly volatile.
7577 @end table
7578
7579 @subsubheading Parameters
7580 @table @var
7581
7582 @item AssemblerInstructions
7583 This is a literal string that specifies the assembler code. The string can
7584 contain any instructions recognized by the assembler, including directives.
7585 GCC does not parse the assembler instructions themselves and
7586 does not know what they mean or even whether they are valid assembler input.
7587
7588 You may place multiple assembler instructions together in a single @code{asm}
7589 string, separated by the characters normally used in assembly code for the
7590 system. A combination that works in most places is a newline to break the
7591 line, plus a tab character (written as @samp{\n\t}).
7592 Some assemblers allow semicolons as a line separator. However,
7593 note that some assembler dialects use semicolons to start a comment.
7594 @end table
7595
7596 @subsubheading Remarks
7597 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7598 smaller, safer, and more efficient code, and in most cases it is a
7599 better solution than basic @code{asm}. However, there are two
7600 situations where only basic @code{asm} can be used:
7601
7602 @itemize @bullet
7603 @item
7604 Extended @code{asm} statements have to be inside a C
7605 function, so to write inline assembly language at file scope (``top-level''),
7606 outside of C functions, you must use basic @code{asm}.
7607 You can use this technique to emit assembler directives,
7608 define assembly language macros that can be invoked elsewhere in the file,
7609 or write entire functions in assembly language.
7610
7611 @item
7612 Functions declared
7613 with the @code{naked} attribute also require basic @code{asm}
7614 (@pxref{Function Attributes}).
7615 @end itemize
7616
7617 Safely accessing C data and calling functions from basic @code{asm} is more
7618 complex than it may appear. To access C data, it is better to use extended
7619 @code{asm}.
7620
7621 Do not expect a sequence of @code{asm} statements to remain perfectly
7622 consecutive after compilation. If certain instructions need to remain
7623 consecutive in the output, put them in a single multi-instruction @code{asm}
7624 statement. Note that GCC's optimizers can move @code{asm} statements
7625 relative to other code, including across jumps.
7626
7627 @code{asm} statements may not perform jumps into other @code{asm} statements.
7628 GCC does not know about these jumps, and therefore cannot take
7629 account of them when deciding how to optimize. Jumps from @code{asm} to C
7630 labels are only supported in extended @code{asm}.
7631
7632 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7633 assembly code when optimizing. This can lead to unexpected duplicate
7634 symbol errors during compilation if your assembly code defines symbols or
7635 labels.
7636
7637 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7638 making it a potential source of incompatibilities between compilers. These
7639 incompatibilities may not produce compiler warnings/errors.
7640
7641 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7642 means there is no way to communicate to the compiler what is happening
7643 inside them. GCC has no visibility of symbols in the @code{asm} and may
7644 discard them as unreferenced. It also does not know about side effects of
7645 the assembler code, such as modifications to memory or registers. Unlike
7646 some compilers, GCC assumes that no changes to general purpose registers
7647 occur. This assumption may change in a future release.
7648
7649 To avoid complications from future changes to the semantics and the
7650 compatibility issues between compilers, consider replacing basic @code{asm}
7651 with extended @code{asm}. See
7652 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7653 from basic asm to extended asm} for information about how to perform this
7654 conversion.
7655
7656 The compiler copies the assembler instructions in a basic @code{asm}
7657 verbatim to the assembly language output file, without
7658 processing dialects or any of the @samp{%} operators that are available with
7659 extended @code{asm}. This results in minor differences between basic
7660 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7661 registers you might use @samp{%eax} in basic @code{asm} and
7662 @samp{%%eax} in extended @code{asm}.
7663
7664 On targets such as x86 that support multiple assembler dialects,
7665 all basic @code{asm} blocks use the assembler dialect specified by the
7666 @option{-masm} command-line option (@pxref{x86 Options}).
7667 Basic @code{asm} provides no
7668 mechanism to provide different assembler strings for different dialects.
7669
7670 For basic @code{asm} with non-empty assembler string GCC assumes
7671 the assembler block does not change any general purpose registers,
7672 but it may read or write any globally accessible variable.
7673
7674 Here is an example of basic @code{asm} for i386:
7675
7676 @example
7677 /* Note that this code will not compile with -masm=intel */
7678 #define DebugBreak() asm("int $3")
7679 @end example
7680
7681 @node Extended Asm
7682 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7683 @cindex extended @code{asm}
7684 @cindex assembly language in C, extended
7685
7686 With extended @code{asm} you can read and write C variables from
7687 assembler and perform jumps from assembler code to C labels.
7688 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7689 the operand parameters after the assembler template:
7690
7691 @example
7692 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7693 : @var{OutputOperands}
7694 @r{[} : @var{InputOperands}
7695 @r{[} : @var{Clobbers} @r{]} @r{]})
7696
7697 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7698 :
7699 : @var{InputOperands}
7700 : @var{Clobbers}
7701 : @var{GotoLabels})
7702 @end example
7703
7704 The @code{asm} keyword is a GNU extension.
7705 When writing code that can be compiled with @option{-ansi} and the
7706 various @option{-std} options, use @code{__asm__} instead of
7707 @code{asm} (@pxref{Alternate Keywords}).
7708
7709 @subsubheading Qualifiers
7710 @table @code
7711
7712 @item volatile
7713 The typical use of extended @code{asm} statements is to manipulate input
7714 values to produce output values. However, your @code{asm} statements may
7715 also produce side effects. If so, you may need to use the @code{volatile}
7716 qualifier to disable certain optimizations. @xref{Volatile}.
7717
7718 @item goto
7719 This qualifier informs the compiler that the @code{asm} statement may
7720 perform a jump to one of the labels listed in the @var{GotoLabels}.
7721 @xref{GotoLabels}.
7722 @end table
7723
7724 @subsubheading Parameters
7725 @table @var
7726 @item AssemblerTemplate
7727 This is a literal string that is the template for the assembler code. It is a
7728 combination of fixed text and tokens that refer to the input, output,
7729 and goto parameters. @xref{AssemblerTemplate}.
7730
7731 @item OutputOperands
7732 A comma-separated list of the C variables modified by the instructions in the
7733 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7734
7735 @item InputOperands
7736 A comma-separated list of C expressions read by the instructions in the
7737 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7738
7739 @item Clobbers
7740 A comma-separated list of registers or other values changed by the
7741 @var{AssemblerTemplate}, beyond those listed as outputs.
7742 An empty list is permitted. @xref{Clobbers}.
7743
7744 @item GotoLabels
7745 When you are using the @code{goto} form of @code{asm}, this section contains
7746 the list of all C labels to which the code in the
7747 @var{AssemblerTemplate} may jump.
7748 @xref{GotoLabels}.
7749
7750 @code{asm} statements may not perform jumps into other @code{asm} statements,
7751 only to the listed @var{GotoLabels}.
7752 GCC's optimizers do not know about other jumps; therefore they cannot take
7753 account of them when deciding how to optimize.
7754 @end table
7755
7756 The total number of input + output + goto operands is limited to 30.
7757
7758 @subsubheading Remarks
7759 The @code{asm} statement allows you to include assembly instructions directly
7760 within C code. This may help you to maximize performance in time-sensitive
7761 code or to access assembly instructions that are not readily available to C
7762 programs.
7763
7764 Note that extended @code{asm} statements must be inside a function. Only
7765 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7766 Functions declared with the @code{naked} attribute also require basic
7767 @code{asm} (@pxref{Function Attributes}).
7768
7769 While the uses of @code{asm} are many and varied, it may help to think of an
7770 @code{asm} statement as a series of low-level instructions that convert input
7771 parameters to output parameters. So a simple (if not particularly useful)
7772 example for i386 using @code{asm} might look like this:
7773
7774 @example
7775 int src = 1;
7776 int dst;
7777
7778 asm ("mov %1, %0\n\t"
7779 "add $1, %0"
7780 : "=r" (dst)
7781 : "r" (src));
7782
7783 printf("%d\n", dst);
7784 @end example
7785
7786 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7787
7788 @anchor{Volatile}
7789 @subsubsection Volatile
7790 @cindex volatile @code{asm}
7791 @cindex @code{asm} volatile
7792
7793 GCC's optimizers sometimes discard @code{asm} statements if they determine
7794 there is no need for the output variables. Also, the optimizers may move
7795 code out of loops if they believe that the code will always return the same
7796 result (i.e. none of its input values change between calls). Using the
7797 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7798 that have no output operands, including @code{asm goto} statements,
7799 are implicitly volatile.
7800
7801 This i386 code demonstrates a case that does not use (or require) the
7802 @code{volatile} qualifier. If it is performing assertion checking, this code
7803 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7804 unreferenced by any code. As a result, the optimizers can discard the
7805 @code{asm} statement, which in turn removes the need for the entire
7806 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7807 isn't needed you allow the optimizers to produce the most efficient code
7808 possible.
7809
7810 @example
7811 void DoCheck(uint32_t dwSomeValue)
7812 @{
7813 uint32_t dwRes;
7814
7815 // Assumes dwSomeValue is not zero.
7816 asm ("bsfl %1,%0"
7817 : "=r" (dwRes)
7818 : "r" (dwSomeValue)
7819 : "cc");
7820
7821 assert(dwRes > 3);
7822 @}
7823 @end example
7824
7825 The next example shows a case where the optimizers can recognize that the input
7826 (@code{dwSomeValue}) never changes during the execution of the function and can
7827 therefore move the @code{asm} outside the loop to produce more efficient code.
7828 Again, using @code{volatile} disables this type of optimization.
7829
7830 @example
7831 void do_print(uint32_t dwSomeValue)
7832 @{
7833 uint32_t dwRes;
7834
7835 for (uint32_t x=0; x < 5; x++)
7836 @{
7837 // Assumes dwSomeValue is not zero.
7838 asm ("bsfl %1,%0"
7839 : "=r" (dwRes)
7840 : "r" (dwSomeValue)
7841 : "cc");
7842
7843 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7844 @}
7845 @}
7846 @end example
7847
7848 The following example demonstrates a case where you need to use the
7849 @code{volatile} qualifier.
7850 It uses the x86 @code{rdtsc} instruction, which reads
7851 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7852 the optimizers might assume that the @code{asm} block will always return the
7853 same value and therefore optimize away the second call.
7854
7855 @example
7856 uint64_t msr;
7857
7858 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7859 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7860 "or %%rdx, %0" // 'Or' in the lower bits.
7861 : "=a" (msr)
7862 :
7863 : "rdx");
7864
7865 printf("msr: %llx\n", msr);
7866
7867 // Do other work...
7868
7869 // Reprint the timestamp
7870 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7871 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7872 "or %%rdx, %0" // 'Or' in the lower bits.
7873 : "=a" (msr)
7874 :
7875 : "rdx");
7876
7877 printf("msr: %llx\n", msr);
7878 @end example
7879
7880 GCC's optimizers do not treat this code like the non-volatile code in the
7881 earlier examples. They do not move it out of loops or omit it on the
7882 assumption that the result from a previous call is still valid.
7883
7884 Note that the compiler can move even volatile @code{asm} instructions relative
7885 to other code, including across jump instructions. For example, on many
7886 targets there is a system register that controls the rounding mode of
7887 floating-point operations. Setting it with a volatile @code{asm}, as in the
7888 following PowerPC example, does not work reliably.
7889
7890 @example
7891 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7892 sum = x + y;
7893 @end example
7894
7895 The compiler may move the addition back before the volatile @code{asm}. To
7896 make it work as expected, add an artificial dependency to the @code{asm} by
7897 referencing a variable in the subsequent code, for example:
7898
7899 @example
7900 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7901 sum = x + y;
7902 @end example
7903
7904 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7905 assembly code when optimizing. This can lead to unexpected duplicate symbol
7906 errors during compilation if your asm code defines symbols or labels.
7907 Using @samp{%=}
7908 (@pxref{AssemblerTemplate}) may help resolve this problem.
7909
7910 @anchor{AssemblerTemplate}
7911 @subsubsection Assembler Template
7912 @cindex @code{asm} assembler template
7913
7914 An assembler template is a literal string containing assembler instructions.
7915 The compiler replaces tokens in the template that refer
7916 to inputs, outputs, and goto labels,
7917 and then outputs the resulting string to the assembler. The
7918 string can contain any instructions recognized by the assembler, including
7919 directives. GCC does not parse the assembler instructions
7920 themselves and does not know what they mean or even whether they are valid
7921 assembler input. However, it does count the statements
7922 (@pxref{Size of an asm}).
7923
7924 You may place multiple assembler instructions together in a single @code{asm}
7925 string, separated by the characters normally used in assembly code for the
7926 system. A combination that works in most places is a newline to break the
7927 line, plus a tab character to move to the instruction field (written as
7928 @samp{\n\t}).
7929 Some assemblers allow semicolons as a line separator. However, note
7930 that some assembler dialects use semicolons to start a comment.
7931
7932 Do not expect a sequence of @code{asm} statements to remain perfectly
7933 consecutive after compilation, even when you are using the @code{volatile}
7934 qualifier. If certain instructions need to remain consecutive in the output,
7935 put them in a single multi-instruction asm statement.
7936
7937 Accessing data from C programs without using input/output operands (such as
7938 by using global symbols directly from the assembler template) may not work as
7939 expected. Similarly, calling functions directly from an assembler template
7940 requires a detailed understanding of the target assembler and ABI.
7941
7942 Since GCC does not parse the assembler template,
7943 it has no visibility of any
7944 symbols it references. This may result in GCC discarding those symbols as
7945 unreferenced unless they are also listed as input, output, or goto operands.
7946
7947 @subsubheading Special format strings
7948
7949 In addition to the tokens described by the input, output, and goto operands,
7950 these tokens have special meanings in the assembler template:
7951
7952 @table @samp
7953 @item %%
7954 Outputs a single @samp{%} into the assembler code.
7955
7956 @item %=
7957 Outputs a number that is unique to each instance of the @code{asm}
7958 statement in the entire compilation. This option is useful when creating local
7959 labels and referring to them multiple times in a single template that
7960 generates multiple assembler instructions.
7961
7962 @item %@{
7963 @itemx %|
7964 @itemx %@}
7965 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7966 into the assembler code. When unescaped, these characters have special
7967 meaning to indicate multiple assembler dialects, as described below.
7968 @end table
7969
7970 @subsubheading Multiple assembler dialects in @code{asm} templates
7971
7972 On targets such as x86, GCC supports multiple assembler dialects.
7973 The @option{-masm} option controls which dialect GCC uses as its
7974 default for inline assembler. The target-specific documentation for the
7975 @option{-masm} option contains the list of supported dialects, as well as the
7976 default dialect if the option is not specified. This information may be
7977 important to understand, since assembler code that works correctly when
7978 compiled using one dialect will likely fail if compiled using another.
7979 @xref{x86 Options}.
7980
7981 If your code needs to support multiple assembler dialects (for example, if
7982 you are writing public headers that need to support a variety of compilation
7983 options), use constructs of this form:
7984
7985 @example
7986 @{ dialect0 | dialect1 | dialect2... @}
7987 @end example
7988
7989 This construct outputs @code{dialect0}
7990 when using dialect #0 to compile the code,
7991 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7992 braces than the number of dialects the compiler supports, the construct
7993 outputs nothing.
7994
7995 For example, if an x86 compiler supports two dialects
7996 (@samp{att}, @samp{intel}), an
7997 assembler template such as this:
7998
7999 @example
8000 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8001 @end example
8002
8003 @noindent
8004 is equivalent to one of
8005
8006 @example
8007 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8008 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8009 @end example
8010
8011 Using that same compiler, this code:
8012
8013 @example
8014 "xchg@{l@}\t@{%%@}ebx, %1"
8015 @end example
8016
8017 @noindent
8018 corresponds to either
8019
8020 @example
8021 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8022 "xchg\tebx, %1" @r{/* intel dialect */}
8023 @end example
8024
8025 There is no support for nesting dialect alternatives.
8026
8027 @anchor{OutputOperands}
8028 @subsubsection Output Operands
8029 @cindex @code{asm} output operands
8030
8031 An @code{asm} statement has zero or more output operands indicating the names
8032 of C variables modified by the assembler code.
8033
8034 In this i386 example, @code{old} (referred to in the template string as
8035 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8036 (@code{%2}) is an input:
8037
8038 @example
8039 bool old;
8040
8041 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8042 "sbb %0,%0" // Use the CF to calculate old.
8043 : "=r" (old), "+rm" (*Base)
8044 : "Ir" (Offset)
8045 : "cc");
8046
8047 return old;
8048 @end example
8049
8050 Operands are separated by commas. Each operand has this format:
8051
8052 @example
8053 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8054 @end example
8055
8056 @table @var
8057 @item asmSymbolicName
8058 Specifies a symbolic name for the operand.
8059 Reference the name in the assembler template
8060 by enclosing it in square brackets
8061 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8062 that contains the definition. Any valid C variable name is acceptable,
8063 including names already defined in the surrounding code. No two operands
8064 within the same @code{asm} statement can use the same symbolic name.
8065
8066 When not using an @var{asmSymbolicName}, use the (zero-based) position
8067 of the operand
8068 in the list of operands in the assembler template. For example if there are
8069 three output operands, use @samp{%0} in the template to refer to the first,
8070 @samp{%1} for the second, and @samp{%2} for the third.
8071
8072 @item constraint
8073 A string constant specifying constraints on the placement of the operand;
8074 @xref{Constraints}, for details.
8075
8076 Output constraints must begin with either @samp{=} (a variable overwriting an
8077 existing value) or @samp{+} (when reading and writing). When using
8078 @samp{=}, do not assume the location contains the existing value
8079 on entry to the @code{asm}, except
8080 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8081
8082 After the prefix, there must be one or more additional constraints
8083 (@pxref{Constraints}) that describe where the value resides. Common
8084 constraints include @samp{r} for register and @samp{m} for memory.
8085 When you list more than one possible location (for example, @code{"=rm"}),
8086 the compiler chooses the most efficient one based on the current context.
8087 If you list as many alternates as the @code{asm} statement allows, you permit
8088 the optimizers to produce the best possible code.
8089 If you must use a specific register, but your Machine Constraints do not
8090 provide sufficient control to select the specific register you want,
8091 local register variables may provide a solution (@pxref{Local Register
8092 Variables}).
8093
8094 @item cvariablename
8095 Specifies a C lvalue expression to hold the output, typically a variable name.
8096 The enclosing parentheses are a required part of the syntax.
8097
8098 @end table
8099
8100 When the compiler selects the registers to use to
8101 represent the output operands, it does not use any of the clobbered registers
8102 (@pxref{Clobbers}).
8103
8104 Output operand expressions must be lvalues. The compiler cannot check whether
8105 the operands have data types that are reasonable for the instruction being
8106 executed. For output expressions that are not directly addressable (for
8107 example a bit-field), the constraint must allow a register. In that case, GCC
8108 uses the register as the output of the @code{asm}, and then stores that
8109 register into the output.
8110
8111 Operands using the @samp{+} constraint modifier count as two operands
8112 (that is, both as input and output) towards the total maximum of 30 operands
8113 per @code{asm} statement.
8114
8115 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8116 operands that must not overlap an input. Otherwise,
8117 GCC may allocate the output operand in the same register as an unrelated
8118 input operand, on the assumption that the assembler code consumes its
8119 inputs before producing outputs. This assumption may be false if the assembler
8120 code actually consists of more than one instruction.
8121
8122 The same problem can occur if one output parameter (@var{a}) allows a register
8123 constraint and another output parameter (@var{b}) allows a memory constraint.
8124 The code generated by GCC to access the memory address in @var{b} can contain
8125 registers which @emph{might} be shared by @var{a}, and GCC considers those
8126 registers to be inputs to the asm. As above, GCC assumes that such input
8127 registers are consumed before any outputs are written. This assumption may
8128 result in incorrect behavior if the asm writes to @var{a} before using
8129 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8130 ensures that modifying @var{a} does not affect the address referenced by
8131 @var{b}. Otherwise, the location of @var{b}
8132 is undefined if @var{a} is modified before using @var{b}.
8133
8134 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8135 instead of simply @samp{%2}). Typically these qualifiers are hardware
8136 dependent. The list of supported modifiers for x86 is found at
8137 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8138
8139 If the C code that follows the @code{asm} makes no use of any of the output
8140 operands, use @code{volatile} for the @code{asm} statement to prevent the
8141 optimizers from discarding the @code{asm} statement as unneeded
8142 (see @ref{Volatile}).
8143
8144 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8145 references the first output operand as @code{%0} (were there a second, it
8146 would be @code{%1}, etc). The number of the first input operand is one greater
8147 than that of the last output operand. In this i386 example, that makes
8148 @code{Mask} referenced as @code{%1}:
8149
8150 @example
8151 uint32_t Mask = 1234;
8152 uint32_t Index;
8153
8154 asm ("bsfl %1, %0"
8155 : "=r" (Index)
8156 : "r" (Mask)
8157 : "cc");
8158 @end example
8159
8160 That code overwrites the variable @code{Index} (@samp{=}),
8161 placing the value in a register (@samp{r}).
8162 Using the generic @samp{r} constraint instead of a constraint for a specific
8163 register allows the compiler to pick the register to use, which can result
8164 in more efficient code. This may not be possible if an assembler instruction
8165 requires a specific register.
8166
8167 The following i386 example uses the @var{asmSymbolicName} syntax.
8168 It produces the
8169 same result as the code above, but some may consider it more readable or more
8170 maintainable since reordering index numbers is not necessary when adding or
8171 removing operands. The names @code{aIndex} and @code{aMask}
8172 are only used in this example to emphasize which
8173 names get used where.
8174 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8175
8176 @example
8177 uint32_t Mask = 1234;
8178 uint32_t Index;
8179
8180 asm ("bsfl %[aMask], %[aIndex]"
8181 : [aIndex] "=r" (Index)
8182 : [aMask] "r" (Mask)
8183 : "cc");
8184 @end example
8185
8186 Here are some more examples of output operands.
8187
8188 @example
8189 uint32_t c = 1;
8190 uint32_t d;
8191 uint32_t *e = &c;
8192
8193 asm ("mov %[e], %[d]"
8194 : [d] "=rm" (d)
8195 : [e] "rm" (*e));
8196 @end example
8197
8198 Here, @code{d} may either be in a register or in memory. Since the compiler
8199 might already have the current value of the @code{uint32_t} location
8200 pointed to by @code{e}
8201 in a register, you can enable it to choose the best location
8202 for @code{d} by specifying both constraints.
8203
8204 @anchor{FlagOutputOperands}
8205 @subsubsection Flag Output Operands
8206 @cindex @code{asm} flag output operands
8207
8208 Some targets have a special register that holds the ``flags'' for the
8209 result of an operation or comparison. Normally, the contents of that
8210 register are either unmodifed by the asm, or the asm is considered to
8211 clobber the contents.
8212
8213 On some targets, a special form of output operand exists by which
8214 conditions in the flags register may be outputs of the asm. The set of
8215 conditions supported are target specific, but the general rule is that
8216 the output variable must be a scalar integer, and the value is boolean.
8217 When supported, the target defines the preprocessor symbol
8218 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8219
8220 Because of the special nature of the flag output operands, the constraint
8221 may not include alternatives.
8222
8223 Most often, the target has only one flags register, and thus is an implied
8224 operand of many instructions. In this case, the operand should not be
8225 referenced within the assembler template via @code{%0} etc, as there's
8226 no corresponding text in the assembly language.
8227
8228 @table @asis
8229 @item x86 family
8230 The flag output constraints for the x86 family are of the form
8231 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8232 conditions defined in the ISA manual for @code{j@var{cc}} or
8233 @code{set@var{cc}}.
8234
8235 @table @code
8236 @item a
8237 ``above'' or unsigned greater than
8238 @item ae
8239 ``above or equal'' or unsigned greater than or equal
8240 @item b
8241 ``below'' or unsigned less than
8242 @item be
8243 ``below or equal'' or unsigned less than or equal
8244 @item c
8245 carry flag set
8246 @item e
8247 @itemx z
8248 ``equal'' or zero flag set
8249 @item g
8250 signed greater than
8251 @item ge
8252 signed greater than or equal
8253 @item l
8254 signed less than
8255 @item le
8256 signed less than or equal
8257 @item o
8258 overflow flag set
8259 @item p
8260 parity flag set
8261 @item s
8262 sign flag set
8263 @item na
8264 @itemx nae
8265 @itemx nb
8266 @itemx nbe
8267 @itemx nc
8268 @itemx ne
8269 @itemx ng
8270 @itemx nge
8271 @itemx nl
8272 @itemx nle
8273 @itemx no
8274 @itemx np
8275 @itemx ns
8276 @itemx nz
8277 ``not'' @var{flag}, or inverted versions of those above
8278 @end table
8279
8280 @end table
8281
8282 @anchor{InputOperands}
8283 @subsubsection Input Operands
8284 @cindex @code{asm} input operands
8285 @cindex @code{asm} expressions
8286
8287 Input operands make values from C variables and expressions available to the
8288 assembly code.
8289
8290 Operands are separated by commas. Each operand has this format:
8291
8292 @example
8293 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8294 @end example
8295
8296 @table @var
8297 @item asmSymbolicName
8298 Specifies a symbolic name for the operand.
8299 Reference the name in the assembler template
8300 by enclosing it in square brackets
8301 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8302 that contains the definition. Any valid C variable name is acceptable,
8303 including names already defined in the surrounding code. No two operands
8304 within the same @code{asm} statement can use the same symbolic name.
8305
8306 When not using an @var{asmSymbolicName}, use the (zero-based) position
8307 of the operand
8308 in the list of operands in the assembler template. For example if there are
8309 two output operands and three inputs,
8310 use @samp{%2} in the template to refer to the first input operand,
8311 @samp{%3} for the second, and @samp{%4} for the third.
8312
8313 @item constraint
8314 A string constant specifying constraints on the placement of the operand;
8315 @xref{Constraints}, for details.
8316
8317 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8318 When you list more than one possible location (for example, @samp{"irm"}),
8319 the compiler chooses the most efficient one based on the current context.
8320 If you must use a specific register, but your Machine Constraints do not
8321 provide sufficient control to select the specific register you want,
8322 local register variables may provide a solution (@pxref{Local Register
8323 Variables}).
8324
8325 Input constraints can also be digits (for example, @code{"0"}). This indicates
8326 that the specified input must be in the same place as the output constraint
8327 at the (zero-based) index in the output constraint list.
8328 When using @var{asmSymbolicName} syntax for the output operands,
8329 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8330
8331 @item cexpression
8332 This is the C variable or expression being passed to the @code{asm} statement
8333 as input. The enclosing parentheses are a required part of the syntax.
8334
8335 @end table
8336
8337 When the compiler selects the registers to use to represent the input
8338 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8339
8340 If there are no output operands but there are input operands, place two
8341 consecutive colons where the output operands would go:
8342
8343 @example
8344 __asm__ ("some instructions"
8345 : /* No outputs. */
8346 : "r" (Offset / 8));
8347 @end example
8348
8349 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8350 (except for inputs tied to outputs). The compiler assumes that on exit from
8351 the @code{asm} statement these operands contain the same values as they
8352 had before executing the statement.
8353 It is @emph{not} possible to use clobbers
8354 to inform the compiler that the values in these inputs are changing. One
8355 common work-around is to tie the changing input variable to an output variable
8356 that never gets used. Note, however, that if the code that follows the
8357 @code{asm} statement makes no use of any of the output operands, the GCC
8358 optimizers may discard the @code{asm} statement as unneeded
8359 (see @ref{Volatile}).
8360
8361 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8362 instead of simply @samp{%2}). Typically these qualifiers are hardware
8363 dependent. The list of supported modifiers for x86 is found at
8364 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8365
8366 In this example using the fictitious @code{combine} instruction, the
8367 constraint @code{"0"} for input operand 1 says that it must occupy the same
8368 location as output operand 0. Only input operands may use numbers in
8369 constraints, and they must each refer to an output operand. Only a number (or
8370 the symbolic assembler name) in the constraint can guarantee that one operand
8371 is in the same place as another. The mere fact that @code{foo} is the value of
8372 both operands is not enough to guarantee that they are in the same place in
8373 the generated assembler code.
8374
8375 @example
8376 asm ("combine %2, %0"
8377 : "=r" (foo)
8378 : "0" (foo), "g" (bar));
8379 @end example
8380
8381 Here is an example using symbolic names.
8382
8383 @example
8384 asm ("cmoveq %1, %2, %[result]"
8385 : [result] "=r"(result)
8386 : "r" (test), "r" (new), "[result]" (old));
8387 @end example
8388
8389 @anchor{Clobbers}
8390 @subsubsection Clobbers
8391 @cindex @code{asm} clobbers
8392
8393 While the compiler is aware of changes to entries listed in the output
8394 operands, the inline @code{asm} code may modify more than just the outputs. For
8395 example, calculations may require additional registers, or the processor may
8396 overwrite a register as a side effect of a particular assembler instruction.
8397 In order to inform the compiler of these changes, list them in the clobber
8398 list. Clobber list items are either register names or the special clobbers
8399 (listed below). Each clobber list item is a string constant
8400 enclosed in double quotes and separated by commas.
8401
8402 Clobber descriptions may not in any way overlap with an input or output
8403 operand. For example, you may not have an operand describing a register class
8404 with one member when listing that register in the clobber list. Variables
8405 declared to live in specific registers (@pxref{Explicit Register
8406 Variables}) and used
8407 as @code{asm} input or output operands must have no part mentioned in the
8408 clobber description. In particular, there is no way to specify that input
8409 operands get modified without also specifying them as output operands.
8410
8411 When the compiler selects which registers to use to represent input and output
8412 operands, it does not use any of the clobbered registers. As a result,
8413 clobbered registers are available for any use in the assembler code.
8414
8415 Here is a realistic example for the VAX showing the use of clobbered
8416 registers:
8417
8418 @example
8419 asm volatile ("movc3 %0, %1, %2"
8420 : /* No outputs. */
8421 : "g" (from), "g" (to), "g" (count)
8422 : "r0", "r1", "r2", "r3", "r4", "r5");
8423 @end example
8424
8425 Also, there are two special clobber arguments:
8426
8427 @table @code
8428 @item "cc"
8429 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8430 register. On some machines, GCC represents the condition codes as a specific
8431 hardware register; @code{"cc"} serves to name this register.
8432 On other machines, condition code handling is different,
8433 and specifying @code{"cc"} has no effect. But
8434 it is valid no matter what the target.
8435
8436 @item "memory"
8437 The @code{"memory"} clobber tells the compiler that the assembly code
8438 performs memory
8439 reads or writes to items other than those listed in the input and output
8440 operands (for example, accessing the memory pointed to by one of the input
8441 parameters). To ensure memory contains correct values, GCC may need to flush
8442 specific register values to memory before executing the @code{asm}. Further,
8443 the compiler does not assume that any values read from memory before an
8444 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8445 needed.
8446 Using the @code{"memory"} clobber effectively forms a read/write
8447 memory barrier for the compiler.
8448
8449 Note that this clobber does not prevent the @emph{processor} from doing
8450 speculative reads past the @code{asm} statement. To prevent that, you need
8451 processor-specific fence instructions.
8452
8453 Flushing registers to memory has performance implications and may be an issue
8454 for time-sensitive code. You can use a trick to avoid this if the size of
8455 the memory being accessed is known at compile time. For example, if accessing
8456 ten bytes of a string, use a memory input like:
8457
8458 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8459
8460 @end table
8461
8462 @anchor{GotoLabels}
8463 @subsubsection Goto Labels
8464 @cindex @code{asm} goto labels
8465
8466 @code{asm goto} allows assembly code to jump to one or more C labels. The
8467 @var{GotoLabels} section in an @code{asm goto} statement contains
8468 a comma-separated
8469 list of all C labels to which the assembler code may jump. GCC assumes that
8470 @code{asm} execution falls through to the next statement (if this is not the
8471 case, consider using the @code{__builtin_unreachable} intrinsic after the
8472 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8473 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8474 Attributes}).
8475
8476 An @code{asm goto} statement cannot have outputs.
8477 This is due to an internal restriction of
8478 the compiler: control transfer instructions cannot have outputs.
8479 If the assembler code does modify anything, use the @code{"memory"} clobber
8480 to force the
8481 optimizers to flush all register values to memory and reload them if
8482 necessary after the @code{asm} statement.
8483
8484 Also note that an @code{asm goto} statement is always implicitly
8485 considered volatile.
8486
8487 To reference a label in the assembler template,
8488 prefix it with @samp{%l} (lowercase @samp{L}) followed
8489 by its (zero-based) position in @var{GotoLabels} plus the number of input
8490 operands. For example, if the @code{asm} has three inputs and references two
8491 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8492
8493 Alternately, you can reference labels using the actual C label name enclosed
8494 in brackets. For example, to reference a label named @code{carry}, you can
8495 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8496 section when using this approach.
8497
8498 Here is an example of @code{asm goto} for i386:
8499
8500 @example
8501 asm goto (
8502 "btl %1, %0\n\t"
8503 "jc %l2"
8504 : /* No outputs. */
8505 : "r" (p1), "r" (p2)
8506 : "cc"
8507 : carry);
8508
8509 return 0;
8510
8511 carry:
8512 return 1;
8513 @end example
8514
8515 The following example shows an @code{asm goto} that uses a memory clobber.
8516
8517 @example
8518 int frob(int x)
8519 @{
8520 int y;
8521 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8522 : /* No outputs. */
8523 : "r"(x), "r"(&y)
8524 : "r5", "memory"
8525 : error);
8526 return y;
8527 error:
8528 return -1;
8529 @}
8530 @end example
8531
8532 @anchor{x86Operandmodifiers}
8533 @subsubsection x86 Operand Modifiers
8534
8535 References to input, output, and goto operands in the assembler template
8536 of extended @code{asm} statements can use
8537 modifiers to affect the way the operands are formatted in
8538 the code output to the assembler. For example, the
8539 following code uses the @samp{h} and @samp{b} modifiers for x86:
8540
8541 @example
8542 uint16_t num;
8543 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8544 @end example
8545
8546 @noindent
8547 These modifiers generate this assembler code:
8548
8549 @example
8550 xchg %ah, %al
8551 @end example
8552
8553 The rest of this discussion uses the following code for illustrative purposes.
8554
8555 @example
8556 int main()
8557 @{
8558 int iInt = 1;
8559
8560 top:
8561
8562 asm volatile goto ("some assembler instructions here"
8563 : /* No outputs. */
8564 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8565 : /* No clobbers. */
8566 : top);
8567 @}
8568 @end example
8569
8570 With no modifiers, this is what the output from the operands would be for the
8571 @samp{att} and @samp{intel} dialects of assembler:
8572
8573 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8574 @headitem Operand @tab masm=att @tab masm=intel
8575 @item @code{%0}
8576 @tab @code{%eax}
8577 @tab @code{eax}
8578 @item @code{%1}
8579 @tab @code{$2}
8580 @tab @code{2}
8581 @item @code{%2}
8582 @tab @code{$.L2}
8583 @tab @code{OFFSET FLAT:.L2}
8584 @end multitable
8585
8586 The table below shows the list of supported modifiers and their effects.
8587
8588 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8589 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8590 @item @code{z}
8591 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8592 @tab @code{%z0}
8593 @tab @code{l}
8594 @tab
8595 @item @code{b}
8596 @tab Print the QImode name of the register.
8597 @tab @code{%b0}
8598 @tab @code{%al}
8599 @tab @code{al}
8600 @item @code{h}
8601 @tab Print the QImode name for a ``high'' register.
8602 @tab @code{%h0}
8603 @tab @code{%ah}
8604 @tab @code{ah}
8605 @item @code{w}
8606 @tab Print the HImode name of the register.
8607 @tab @code{%w0}
8608 @tab @code{%ax}
8609 @tab @code{ax}
8610 @item @code{k}
8611 @tab Print the SImode name of the register.
8612 @tab @code{%k0}
8613 @tab @code{%eax}
8614 @tab @code{eax}
8615 @item @code{q}
8616 @tab Print the DImode name of the register.
8617 @tab @code{%q0}
8618 @tab @code{%rax}
8619 @tab @code{rax}
8620 @item @code{l}
8621 @tab Print the label name with no punctuation.
8622 @tab @code{%l2}
8623 @tab @code{.L2}
8624 @tab @code{.L2}
8625 @item @code{c}
8626 @tab Require a constant operand and print the constant expression with no punctuation.
8627 @tab @code{%c1}
8628 @tab @code{2}
8629 @tab @code{2}
8630 @end multitable
8631
8632 @anchor{x86floatingpointasmoperands}
8633 @subsubsection x86 Floating-Point @code{asm} Operands
8634
8635 On x86 targets, there are several rules on the usage of stack-like registers
8636 in the operands of an @code{asm}. These rules apply only to the operands
8637 that are stack-like registers:
8638
8639 @enumerate
8640 @item
8641 Given a set of input registers that die in an @code{asm}, it is
8642 necessary to know which are implicitly popped by the @code{asm}, and
8643 which must be explicitly popped by GCC@.
8644
8645 An input register that is implicitly popped by the @code{asm} must be
8646 explicitly clobbered, unless it is constrained to match an
8647 output operand.
8648
8649 @item
8650 For any input register that is implicitly popped by an @code{asm}, it is
8651 necessary to know how to adjust the stack to compensate for the pop.
8652 If any non-popped input is closer to the top of the reg-stack than
8653 the implicitly popped register, it would not be possible to know what the
8654 stack looked like---it's not clear how the rest of the stack ``slides
8655 up''.
8656
8657 All implicitly popped input registers must be closer to the top of
8658 the reg-stack than any input that is not implicitly popped.
8659
8660 It is possible that if an input dies in an @code{asm}, the compiler might
8661 use the input register for an output reload. Consider this example:
8662
8663 @smallexample
8664 asm ("foo" : "=t" (a) : "f" (b));
8665 @end smallexample
8666
8667 @noindent
8668 This code says that input @code{b} is not popped by the @code{asm}, and that
8669 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8670 deeper after the @code{asm} than it was before. But, it is possible that
8671 reload may think that it can use the same register for both the input and
8672 the output.
8673
8674 To prevent this from happening,
8675 if any input operand uses the @samp{f} constraint, all output register
8676 constraints must use the @samp{&} early-clobber modifier.
8677
8678 The example above is correctly written as:
8679
8680 @smallexample
8681 asm ("foo" : "=&t" (a) : "f" (b));
8682 @end smallexample
8683
8684 @item
8685 Some operands need to be in particular places on the stack. All
8686 output operands fall in this category---GCC has no other way to
8687 know which registers the outputs appear in unless you indicate
8688 this in the constraints.
8689
8690 Output operands must specifically indicate which register an output
8691 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8692 constraints must select a class with a single register.
8693
8694 @item
8695 Output operands may not be ``inserted'' between existing stack registers.
8696 Since no 387 opcode uses a read/write operand, all output operands
8697 are dead before the @code{asm}, and are pushed by the @code{asm}.
8698 It makes no sense to push anywhere but the top of the reg-stack.
8699
8700 Output operands must start at the top of the reg-stack: output
8701 operands may not ``skip'' a register.
8702
8703 @item
8704 Some @code{asm} statements may need extra stack space for internal
8705 calculations. This can be guaranteed by clobbering stack registers
8706 unrelated to the inputs and outputs.
8707
8708 @end enumerate
8709
8710 This @code{asm}
8711 takes one input, which is internally popped, and produces two outputs.
8712
8713 @smallexample
8714 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8715 @end smallexample
8716
8717 @noindent
8718 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8719 and replaces them with one output. The @code{st(1)} clobber is necessary
8720 for the compiler to know that @code{fyl2xp1} pops both inputs.
8721
8722 @smallexample
8723 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8724 @end smallexample
8725
8726 @lowersections
8727 @include md.texi
8728 @raisesections
8729
8730 @node Asm Labels
8731 @subsection Controlling Names Used in Assembler Code
8732 @cindex assembler names for identifiers
8733 @cindex names used in assembler code
8734 @cindex identifiers, names in assembler code
8735
8736 You can specify the name to be used in the assembler code for a C
8737 function or variable by writing the @code{asm} (or @code{__asm__})
8738 keyword after the declarator.
8739 It is up to you to make sure that the assembler names you choose do not
8740 conflict with any other assembler symbols, or reference registers.
8741
8742 @subsubheading Assembler names for data:
8743
8744 This sample shows how to specify the assembler name for data:
8745
8746 @smallexample
8747 int foo asm ("myfoo") = 2;
8748 @end smallexample
8749
8750 @noindent
8751 This specifies that the name to be used for the variable @code{foo} in
8752 the assembler code should be @samp{myfoo} rather than the usual
8753 @samp{_foo}.
8754
8755 On systems where an underscore is normally prepended to the name of a C
8756 variable, this feature allows you to define names for the
8757 linker that do not start with an underscore.
8758
8759 GCC does not support using this feature with a non-static local variable
8760 since such variables do not have assembler names. If you are
8761 trying to put the variable in a particular register, see
8762 @ref{Explicit Register Variables}.
8763
8764 @subsubheading Assembler names for functions:
8765
8766 To specify the assembler name for functions, write a declaration for the
8767 function before its definition and put @code{asm} there, like this:
8768
8769 @smallexample
8770 int func (int x, int y) asm ("MYFUNC");
8771
8772 int func (int x, int y)
8773 @{
8774 /* @r{@dots{}} */
8775 @end smallexample
8776
8777 @noindent
8778 This specifies that the name to be used for the function @code{func} in
8779 the assembler code should be @code{MYFUNC}.
8780
8781 @node Explicit Register Variables
8782 @subsection Variables in Specified Registers
8783 @anchor{Explicit Reg Vars}
8784 @cindex explicit register variables
8785 @cindex variables in specified registers
8786 @cindex specified registers
8787
8788 GNU C allows you to associate specific hardware registers with C
8789 variables. In almost all cases, allowing the compiler to assign
8790 registers produces the best code. However under certain unusual
8791 circumstances, more precise control over the variable storage is
8792 required.
8793
8794 Both global and local variables can be associated with a register. The
8795 consequences of performing this association are very different between
8796 the two, as explained in the sections below.
8797
8798 @menu
8799 * Global Register Variables:: Variables declared at global scope.
8800 * Local Register Variables:: Variables declared within a function.
8801 @end menu
8802
8803 @node Global Register Variables
8804 @subsubsection Defining Global Register Variables
8805 @anchor{Global Reg Vars}
8806 @cindex global register variables
8807 @cindex registers, global variables in
8808 @cindex registers, global allocation
8809
8810 You can define a global register variable and associate it with a specified
8811 register like this:
8812
8813 @smallexample
8814 register int *foo asm ("r12");
8815 @end smallexample
8816
8817 @noindent
8818 Here @code{r12} is the name of the register that should be used. Note that
8819 this is the same syntax used for defining local register variables, but for
8820 a global variable the declaration appears outside a function. The
8821 @code{register} keyword is required, and cannot be combined with
8822 @code{static}. The register name must be a valid register name for the
8823 target platform.
8824
8825 Registers are a scarce resource on most systems and allowing the
8826 compiler to manage their usage usually results in the best code. However,
8827 under special circumstances it can make sense to reserve some globally.
8828 For example this may be useful in programs such as programming language
8829 interpreters that have a couple of global variables that are accessed
8830 very often.
8831
8832 After defining a global register variable, for the current compilation
8833 unit:
8834
8835 @itemize @bullet
8836 @item The register is reserved entirely for this use, and will not be
8837 allocated for any other purpose.
8838 @item The register is not saved and restored by any functions.
8839 @item Stores into this register are never deleted even if they appear to be
8840 dead, but references may be deleted, moved or simplified.
8841 @end itemize
8842
8843 Note that these points @emph{only} apply to code that is compiled with the
8844 definition. The behavior of code that is merely linked in (for example
8845 code from libraries) is not affected.
8846
8847 If you want to recompile source files that do not actually use your global
8848 register variable so they do not use the specified register for any other
8849 purpose, you need not actually add the global register declaration to
8850 their source code. It suffices to specify the compiler option
8851 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8852 register.
8853
8854 @subsubheading Declaring the variable
8855
8856 Global register variables can not have initial values, because an
8857 executable file has no means to supply initial contents for a register.
8858
8859 When selecting a register, choose one that is normally saved and
8860 restored by function calls on your machine. This ensures that code
8861 which is unaware of this reservation (such as library routines) will
8862 restore it before returning.
8863
8864 On machines with register windows, be sure to choose a global
8865 register that is not affected magically by the function call mechanism.
8866
8867 @subsubheading Using the variable
8868
8869 @cindex @code{qsort}, and global register variables
8870 When calling routines that are not aware of the reservation, be
8871 cautious if those routines call back into code which uses them. As an
8872 example, if you call the system library version of @code{qsort}, it may
8873 clobber your registers during execution, but (if you have selected
8874 appropriate registers) it will restore them before returning. However
8875 it will @emph{not} restore them before calling @code{qsort}'s comparison
8876 function. As a result, global values will not reliably be available to
8877 the comparison function unless the @code{qsort} function itself is rebuilt.
8878
8879 Similarly, it is not safe to access the global register variables from signal
8880 handlers or from more than one thread of control. Unless you recompile
8881 them specially for the task at hand, the system library routines may
8882 temporarily use the register for other things.
8883
8884 @cindex register variable after @code{longjmp}
8885 @cindex global register after @code{longjmp}
8886 @cindex value after @code{longjmp}
8887 @findex longjmp
8888 @findex setjmp
8889 On most machines, @code{longjmp} restores to each global register
8890 variable the value it had at the time of the @code{setjmp}. On some
8891 machines, however, @code{longjmp} does not change the value of global
8892 register variables. To be portable, the function that called @code{setjmp}
8893 should make other arrangements to save the values of the global register
8894 variables, and to restore them in a @code{longjmp}. This way, the same
8895 thing happens regardless of what @code{longjmp} does.
8896
8897 Eventually there may be a way of asking the compiler to choose a register
8898 automatically, but first we need to figure out how it should choose and
8899 how to enable you to guide the choice. No solution is evident.
8900
8901 @node Local Register Variables
8902 @subsubsection Specifying Registers for Local Variables
8903 @anchor{Local Reg Vars}
8904 @cindex local variables, specifying registers
8905 @cindex specifying registers for local variables
8906 @cindex registers for local variables
8907
8908 You can define a local register variable and associate it with a specified
8909 register like this:
8910
8911 @smallexample
8912 register int *foo asm ("r12");
8913 @end smallexample
8914
8915 @noindent
8916 Here @code{r12} is the name of the register that should be used. Note
8917 that this is the same syntax used for defining global register variables,
8918 but for a local variable the declaration appears within a function. The
8919 @code{register} keyword is required, and cannot be combined with
8920 @code{static}. The register name must be a valid register name for the
8921 target platform.
8922
8923 As with global register variables, it is recommended that you choose
8924 a register that is normally saved and restored by function calls on your
8925 machine, so that calls to library routines will not clobber it.
8926
8927 The only supported use for this feature is to specify registers
8928 for input and output operands when calling Extended @code{asm}
8929 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8930 particular machine don't provide sufficient control to select the desired
8931 register. To force an operand into a register, create a local variable
8932 and specify the register name after the variable's declaration. Then use
8933 the local variable for the @code{asm} operand and specify any constraint
8934 letter that matches the register:
8935
8936 @smallexample
8937 register int *p1 asm ("r0") = @dots{};
8938 register int *p2 asm ("r1") = @dots{};
8939 register int *result asm ("r0");
8940 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8941 @end smallexample
8942
8943 @emph{Warning:} In the above example, be aware that a register (for example
8944 @code{r0}) can be call-clobbered by subsequent code, including function
8945 calls and library calls for arithmetic operators on other variables (for
8946 example the initialization of @code{p2}). In this case, use temporary
8947 variables for expressions between the register assignments:
8948
8949 @smallexample
8950 int t1 = @dots{};
8951 register int *p1 asm ("r0") = @dots{};
8952 register int *p2 asm ("r1") = t1;
8953 register int *result asm ("r0");
8954 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8955 @end smallexample
8956
8957 Defining a register variable does not reserve the register. Other than
8958 when invoking the Extended @code{asm}, the contents of the specified
8959 register are not guaranteed. For this reason, the following uses
8960 are explicitly @emph{not} supported. If they appear to work, it is only
8961 happenstance, and may stop working as intended due to (seemingly)
8962 unrelated changes in surrounding code, or even minor changes in the
8963 optimization of a future version of gcc:
8964
8965 @itemize @bullet
8966 @item Passing parameters to or from Basic @code{asm}
8967 @item Passing parameters to or from Extended @code{asm} without using input
8968 or output operands.
8969 @item Passing parameters to or from routines written in assembler (or
8970 other languages) using non-standard calling conventions.
8971 @end itemize
8972
8973 Some developers use Local Register Variables in an attempt to improve
8974 gcc's allocation of registers, especially in large functions. In this
8975 case the register name is essentially a hint to the register allocator.
8976 While in some instances this can generate better code, improvements are
8977 subject to the whims of the allocator/optimizers. Since there are no
8978 guarantees that your improvements won't be lost, this usage of Local
8979 Register Variables is discouraged.
8980
8981 On the MIPS platform, there is related use for local register variables
8982 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8983 Defining coprocessor specifics for MIPS targets, gccint,
8984 GNU Compiler Collection (GCC) Internals}).
8985
8986 @node Size of an asm
8987 @subsection Size of an @code{asm}
8988
8989 Some targets require that GCC track the size of each instruction used
8990 in order to generate correct code. Because the final length of the
8991 code produced by an @code{asm} statement is only known by the
8992 assembler, GCC must make an estimate as to how big it will be. It
8993 does this by counting the number of instructions in the pattern of the
8994 @code{asm} and multiplying that by the length of the longest
8995 instruction supported by that processor. (When working out the number
8996 of instructions, it assumes that any occurrence of a newline or of
8997 whatever statement separator character is supported by the assembler --
8998 typically @samp{;} --- indicates the end of an instruction.)
8999
9000 Normally, GCC's estimate is adequate to ensure that correct
9001 code is generated, but it is possible to confuse the compiler if you use
9002 pseudo instructions or assembler macros that expand into multiple real
9003 instructions, or if you use assembler directives that expand to more
9004 space in the object file than is needed for a single instruction.
9005 If this happens then the assembler may produce a diagnostic saying that
9006 a label is unreachable.
9007
9008 @node Alternate Keywords
9009 @section Alternate Keywords
9010 @cindex alternate keywords
9011 @cindex keywords, alternate
9012
9013 @option{-ansi} and the various @option{-std} options disable certain
9014 keywords. This causes trouble when you want to use GNU C extensions, or
9015 a general-purpose header file that should be usable by all programs,
9016 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9017 @code{inline} are not available in programs compiled with
9018 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9019 program compiled with @option{-std=c99} or @option{-std=c11}). The
9020 ISO C99 keyword
9021 @code{restrict} is only available when @option{-std=gnu99} (which will
9022 eventually be the default) or @option{-std=c99} (or the equivalent
9023 @option{-std=iso9899:1999}), or an option for a later standard
9024 version, is used.
9025
9026 The way to solve these problems is to put @samp{__} at the beginning and
9027 end of each problematical keyword. For example, use @code{__asm__}
9028 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9029
9030 Other C compilers won't accept these alternative keywords; if you want to
9031 compile with another compiler, you can define the alternate keywords as
9032 macros to replace them with the customary keywords. It looks like this:
9033
9034 @smallexample
9035 #ifndef __GNUC__
9036 #define __asm__ asm
9037 #endif
9038 @end smallexample
9039
9040 @findex __extension__
9041 @opindex pedantic
9042 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9043 You can
9044 prevent such warnings within one expression by writing
9045 @code{__extension__} before the expression. @code{__extension__} has no
9046 effect aside from this.
9047
9048 @node Incomplete Enums
9049 @section Incomplete @code{enum} Types
9050
9051 You can define an @code{enum} tag without specifying its possible values.
9052 This results in an incomplete type, much like what you get if you write
9053 @code{struct foo} without describing the elements. A later declaration
9054 that does specify the possible values completes the type.
9055
9056 You can't allocate variables or storage using the type while it is
9057 incomplete. However, you can work with pointers to that type.
9058
9059 This extension may not be very useful, but it makes the handling of
9060 @code{enum} more consistent with the way @code{struct} and @code{union}
9061 are handled.
9062
9063 This extension is not supported by GNU C++.
9064
9065 @node Function Names
9066 @section Function Names as Strings
9067 @cindex @code{__func__} identifier
9068 @cindex @code{__FUNCTION__} identifier
9069 @cindex @code{__PRETTY_FUNCTION__} identifier
9070
9071 GCC provides three magic constants that hold the name of the current
9072 function as a string. In C++11 and later modes, all three are treated
9073 as constant expressions and can be used in @code{constexpr} constexts.
9074 The first of these constants is @code{__func__}, which is part of
9075 the C99 standard:
9076
9077 The identifier @code{__func__} is implicitly declared by the translator
9078 as if, immediately following the opening brace of each function
9079 definition, the declaration
9080
9081 @smallexample
9082 static const char __func__[] = "function-name";
9083 @end smallexample
9084
9085 @noindent
9086 appeared, where function-name is the name of the lexically-enclosing
9087 function. This name is the unadorned name of the function. As an
9088 extension, at file (or, in C++, namespace scope), @code{__func__}
9089 evaluates to the empty string.
9090
9091 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9092 backward compatibility with old versions of GCC.
9093
9094 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9095 @code{__func__}, except that at file (or, in C++, namespace scope),
9096 it evaluates to the string @code{"top level"}. In addition, in C++,
9097 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9098 well as its bare name. For example, this program:
9099
9100 @smallexample
9101 extern "C" int printf (const char *, ...);
9102
9103 class a @{
9104 public:
9105 void sub (int i)
9106 @{
9107 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9108 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9109 @}
9110 @};
9111
9112 int
9113 main (void)
9114 @{
9115 a ax;
9116 ax.sub (0);
9117 return 0;
9118 @}
9119 @end smallexample
9120
9121 @noindent
9122 gives this output:
9123
9124 @smallexample
9125 __FUNCTION__ = sub
9126 __PRETTY_FUNCTION__ = void a::sub(int)
9127 @end smallexample
9128
9129 These identifiers are variables, not preprocessor macros, and may not
9130 be used to initialize @code{char} arrays or be concatenated with string
9131 literals.
9132
9133 @node Return Address
9134 @section Getting the Return or Frame Address of a Function
9135
9136 These functions may be used to get information about the callers of a
9137 function.
9138
9139 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9140 This function returns the return address of the current function, or of
9141 one of its callers. The @var{level} argument is number of frames to
9142 scan up the call stack. A value of @code{0} yields the return address
9143 of the current function, a value of @code{1} yields the return address
9144 of the caller of the current function, and so forth. When inlining
9145 the expected behavior is that the function returns the address of
9146 the function that is returned to. To work around this behavior use
9147 the @code{noinline} function attribute.
9148
9149 The @var{level} argument must be a constant integer.
9150
9151 On some machines it may be impossible to determine the return address of
9152 any function other than the current one; in such cases, or when the top
9153 of the stack has been reached, this function returns @code{0} or a
9154 random value. In addition, @code{__builtin_frame_address} may be used
9155 to determine if the top of the stack has been reached.
9156
9157 Additional post-processing of the returned value may be needed, see
9158 @code{__builtin_extract_return_addr}.
9159
9160 Calling this function with a nonzero argument can have unpredictable
9161 effects, including crashing the calling program. As a result, calls
9162 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9163 option is in effect. Such calls should only be made in debugging
9164 situations.
9165 @end deftypefn
9166
9167 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9168 The address as returned by @code{__builtin_return_address} may have to be fed
9169 through this function to get the actual encoded address. For example, on the
9170 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9171 platforms an offset has to be added for the true next instruction to be
9172 executed.
9173
9174 If no fixup is needed, this function simply passes through @var{addr}.
9175 @end deftypefn
9176
9177 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9178 This function does the reverse of @code{__builtin_extract_return_addr}.
9179 @end deftypefn
9180
9181 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9182 This function is similar to @code{__builtin_return_address}, but it
9183 returns the address of the function frame rather than the return address
9184 of the function. Calling @code{__builtin_frame_address} with a value of
9185 @code{0} yields the frame address of the current function, a value of
9186 @code{1} yields the frame address of the caller of the current function,
9187 and so forth.
9188
9189 The frame is the area on the stack that holds local variables and saved
9190 registers. The frame address is normally the address of the first word
9191 pushed on to the stack by the function. However, the exact definition
9192 depends upon the processor and the calling convention. If the processor
9193 has a dedicated frame pointer register, and the function has a frame,
9194 then @code{__builtin_frame_address} returns the value of the frame
9195 pointer register.
9196
9197 On some machines it may be impossible to determine the frame address of
9198 any function other than the current one; in such cases, or when the top
9199 of the stack has been reached, this function returns @code{0} if
9200 the first frame pointer is properly initialized by the startup code.
9201
9202 Calling this function with a nonzero argument can have unpredictable
9203 effects, including crashing the calling program. As a result, calls
9204 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9205 option is in effect. Such calls should only be made in debugging
9206 situations.
9207 @end deftypefn
9208
9209 @node Vector Extensions
9210 @section Using Vector Instructions through Built-in Functions
9211
9212 On some targets, the instruction set contains SIMD vector instructions which
9213 operate on multiple values contained in one large register at the same time.
9214 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9215 this way.
9216
9217 The first step in using these extensions is to provide the necessary data
9218 types. This should be done using an appropriate @code{typedef}:
9219
9220 @smallexample
9221 typedef int v4si __attribute__ ((vector_size (16)));
9222 @end smallexample
9223
9224 @noindent
9225 The @code{int} type specifies the base type, while the attribute specifies
9226 the vector size for the variable, measured in bytes. For example, the
9227 declaration above causes the compiler to set the mode for the @code{v4si}
9228 type to be 16 bytes wide and divided into @code{int} sized units. For
9229 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9230 corresponding mode of @code{foo} is @acronym{V4SI}.
9231
9232 The @code{vector_size} attribute is only applicable to integral and
9233 float scalars, although arrays, pointers, and function return values
9234 are allowed in conjunction with this construct. Only sizes that are
9235 a power of two are currently allowed.
9236
9237 All the basic integer types can be used as base types, both as signed
9238 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9239 @code{long long}. In addition, @code{float} and @code{double} can be
9240 used to build floating-point vector types.
9241
9242 Specifying a combination that is not valid for the current architecture
9243 causes GCC to synthesize the instructions using a narrower mode.
9244 For example, if you specify a variable of type @code{V4SI} and your
9245 architecture does not allow for this specific SIMD type, GCC
9246 produces code that uses 4 @code{SIs}.
9247
9248 The types defined in this manner can be used with a subset of normal C
9249 operations. Currently, GCC allows using the following operators
9250 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9251
9252 The operations behave like C++ @code{valarrays}. Addition is defined as
9253 the addition of the corresponding elements of the operands. For
9254 example, in the code below, each of the 4 elements in @var{a} is
9255 added to the corresponding 4 elements in @var{b} and the resulting
9256 vector is stored in @var{c}.
9257
9258 @smallexample
9259 typedef int v4si __attribute__ ((vector_size (16)));
9260
9261 v4si a, b, c;
9262
9263 c = a + b;
9264 @end smallexample
9265
9266 Subtraction, multiplication, division, and the logical operations
9267 operate in a similar manner. Likewise, the result of using the unary
9268 minus or complement operators on a vector type is a vector whose
9269 elements are the negative or complemented values of the corresponding
9270 elements in the operand.
9271
9272 It is possible to use shifting operators @code{<<}, @code{>>} on
9273 integer-type vectors. The operation is defined as following: @code{@{a0,
9274 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9275 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9276 elements.
9277
9278 For convenience, it is allowed to use a binary vector operation
9279 where one operand is a scalar. In that case the compiler transforms
9280 the scalar operand into a vector where each element is the scalar from
9281 the operation. The transformation happens only if the scalar could be
9282 safely converted to the vector-element type.
9283 Consider the following code.
9284
9285 @smallexample
9286 typedef int v4si __attribute__ ((vector_size (16)));
9287
9288 v4si a, b, c;
9289 long l;
9290
9291 a = b + 1; /* a = b + @{1,1,1,1@}; */
9292 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9293
9294 a = l + a; /* Error, cannot convert long to int. */
9295 @end smallexample
9296
9297 Vectors can be subscripted as if the vector were an array with
9298 the same number of elements and base type. Out of bound accesses
9299 invoke undefined behavior at run time. Warnings for out of bound
9300 accesses for vector subscription can be enabled with
9301 @option{-Warray-bounds}.
9302
9303 Vector comparison is supported with standard comparison
9304 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9305 vector expressions of integer-type or real-type. Comparison between
9306 integer-type vectors and real-type vectors are not supported. The
9307 result of the comparison is a vector of the same width and number of
9308 elements as the comparison operands with a signed integral element
9309 type.
9310
9311 Vectors are compared element-wise producing 0 when comparison is false
9312 and -1 (constant of the appropriate type where all bits are set)
9313 otherwise. Consider the following example.
9314
9315 @smallexample
9316 typedef int v4si __attribute__ ((vector_size (16)));
9317
9318 v4si a = @{1,2,3,4@};
9319 v4si b = @{3,2,1,4@};
9320 v4si c;
9321
9322 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9323 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9324 @end smallexample
9325
9326 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9327 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9328 integer vector with the same number of elements of the same size as @code{b}
9329 and @code{c}, computes all three arguments and creates a vector
9330 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9331 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9332 As in the case of binary operations, this syntax is also accepted when
9333 one of @code{b} or @code{c} is a scalar that is then transformed into a
9334 vector. If both @code{b} and @code{c} are scalars and the type of
9335 @code{true?b:c} has the same size as the element type of @code{a}, then
9336 @code{b} and @code{c} are converted to a vector type whose elements have
9337 this type and with the same number of elements as @code{a}.
9338
9339 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9340 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9341 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9342 For mixed operations between a scalar @code{s} and a vector @code{v},
9343 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9344 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9345
9346 Vector shuffling is available using functions
9347 @code{__builtin_shuffle (vec, mask)} and
9348 @code{__builtin_shuffle (vec0, vec1, mask)}.
9349 Both functions construct a permutation of elements from one or two
9350 vectors and return a vector of the same type as the input vector(s).
9351 The @var{mask} is an integral vector with the same width (@var{W})
9352 and element count (@var{N}) as the output vector.
9353
9354 The elements of the input vectors are numbered in memory ordering of
9355 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9356 elements of @var{mask} are considered modulo @var{N} in the single-operand
9357 case and modulo @math{2*@var{N}} in the two-operand case.
9358
9359 Consider the following example,
9360
9361 @smallexample
9362 typedef int v4si __attribute__ ((vector_size (16)));
9363
9364 v4si a = @{1,2,3,4@};
9365 v4si b = @{5,6,7,8@};
9366 v4si mask1 = @{0,1,1,3@};
9367 v4si mask2 = @{0,4,2,5@};
9368 v4si res;
9369
9370 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9371 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9372 @end smallexample
9373
9374 Note that @code{__builtin_shuffle} is intentionally semantically
9375 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9376
9377 You can declare variables and use them in function calls and returns, as
9378 well as in assignments and some casts. You can specify a vector type as
9379 a return type for a function. Vector types can also be used as function
9380 arguments. It is possible to cast from one vector type to another,
9381 provided they are of the same size (in fact, you can also cast vectors
9382 to and from other datatypes of the same size).
9383
9384 You cannot operate between vectors of different lengths or different
9385 signedness without a cast.
9386
9387 @node Offsetof
9388 @section Support for @code{offsetof}
9389 @findex __builtin_offsetof
9390
9391 GCC implements for both C and C++ a syntactic extension to implement
9392 the @code{offsetof} macro.
9393
9394 @smallexample
9395 primary:
9396 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9397
9398 offsetof_member_designator:
9399 @code{identifier}
9400 | offsetof_member_designator "." @code{identifier}
9401 | offsetof_member_designator "[" @code{expr} "]"
9402 @end smallexample
9403
9404 This extension is sufficient such that
9405
9406 @smallexample
9407 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9408 @end smallexample
9409
9410 @noindent
9411 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9412 may be dependent. In either case, @var{member} may consist of a single
9413 identifier, or a sequence of member accesses and array references.
9414
9415 @node __sync Builtins
9416 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9417
9418 The following built-in functions
9419 are intended to be compatible with those described
9420 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9421 section 7.4. As such, they depart from normal GCC practice by not using
9422 the @samp{__builtin_} prefix and also by being overloaded so that they
9423 work on multiple types.
9424
9425 The definition given in the Intel documentation allows only for the use of
9426 the types @code{int}, @code{long}, @code{long long} or their unsigned
9427 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9428 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9429 Operations on pointer arguments are performed as if the operands were
9430 of the @code{uintptr_t} type. That is, they are not scaled by the size
9431 of the type to which the pointer points.
9432
9433 These functions are implemented in terms of the @samp{__atomic}
9434 builtins (@pxref{__atomic Builtins}). They should not be used for new
9435 code which should use the @samp{__atomic} builtins instead.
9436
9437 Not all operations are supported by all target processors. If a particular
9438 operation cannot be implemented on the target processor, a warning is
9439 generated and a call to an external function is generated. The external
9440 function carries the same name as the built-in version,
9441 with an additional suffix
9442 @samp{_@var{n}} where @var{n} is the size of the data type.
9443
9444 @c ??? Should we have a mechanism to suppress this warning? This is almost
9445 @c useful for implementing the operation under the control of an external
9446 @c mutex.
9447
9448 In most cases, these built-in functions are considered a @dfn{full barrier}.
9449 That is,
9450 no memory operand is moved across the operation, either forward or
9451 backward. Further, instructions are issued as necessary to prevent the
9452 processor from speculating loads across the operation and from queuing stores
9453 after the operation.
9454
9455 All of the routines are described in the Intel documentation to take
9456 ``an optional list of variables protected by the memory barrier''. It's
9457 not clear what is meant by that; it could mean that @emph{only} the
9458 listed variables are protected, or it could mean a list of additional
9459 variables to be protected. The list is ignored by GCC which treats it as
9460 empty. GCC interprets an empty list as meaning that all globally
9461 accessible variables should be protected.
9462
9463 @table @code
9464 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9465 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9466 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9467 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9468 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9469 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9470 @findex __sync_fetch_and_add
9471 @findex __sync_fetch_and_sub
9472 @findex __sync_fetch_and_or
9473 @findex __sync_fetch_and_and
9474 @findex __sync_fetch_and_xor
9475 @findex __sync_fetch_and_nand
9476 These built-in functions perform the operation suggested by the name, and
9477 returns the value that had previously been in memory. That is, operations
9478 on integer operands have the following semantics. Operations on pointer
9479 arguments are performed as if the operands were of the @code{uintptr_t}
9480 type. That is, they are not scaled by the size of the type to which
9481 the pointer points.
9482
9483 @smallexample
9484 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9485 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9486 @end smallexample
9487
9488 The object pointed to by the first argument must be of integer or pointer
9489 type. It must not be a Boolean type.
9490
9491 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9492 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9493
9494 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9495 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9496 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9497 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9498 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9499 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9500 @findex __sync_add_and_fetch
9501 @findex __sync_sub_and_fetch
9502 @findex __sync_or_and_fetch
9503 @findex __sync_and_and_fetch
9504 @findex __sync_xor_and_fetch
9505 @findex __sync_nand_and_fetch
9506 These built-in functions perform the operation suggested by the name, and
9507 return the new value. That is, operations on integer operands have
9508 the following semantics. Operations on pointer operands are performed as
9509 if the operand's type were @code{uintptr_t}.
9510
9511 @smallexample
9512 @{ *ptr @var{op}= value; return *ptr; @}
9513 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9514 @end smallexample
9515
9516 The same constraints on arguments apply as for the corresponding
9517 @code{__sync_op_and_fetch} built-in functions.
9518
9519 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9520 as @code{*ptr = ~(*ptr & value)} instead of
9521 @code{*ptr = ~*ptr & value}.
9522
9523 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9524 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9525 @findex __sync_bool_compare_and_swap
9526 @findex __sync_val_compare_and_swap
9527 These built-in functions perform an atomic compare and swap.
9528 That is, if the current
9529 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9530 @code{*@var{ptr}}.
9531
9532 The ``bool'' version returns true if the comparison is successful and
9533 @var{newval} is written. The ``val'' version returns the contents
9534 of @code{*@var{ptr}} before the operation.
9535
9536 @item __sync_synchronize (...)
9537 @findex __sync_synchronize
9538 This built-in function issues a full memory barrier.
9539
9540 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9541 @findex __sync_lock_test_and_set
9542 This built-in function, as described by Intel, is not a traditional test-and-set
9543 operation, but rather an atomic exchange operation. It writes @var{value}
9544 into @code{*@var{ptr}}, and returns the previous contents of
9545 @code{*@var{ptr}}.
9546
9547 Many targets have only minimal support for such locks, and do not support
9548 a full exchange operation. In this case, a target may support reduced
9549 functionality here by which the @emph{only} valid value to store is the
9550 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9551 is implementation defined.
9552
9553 This built-in function is not a full barrier,
9554 but rather an @dfn{acquire barrier}.
9555 This means that references after the operation cannot move to (or be
9556 speculated to) before the operation, but previous memory stores may not
9557 be globally visible yet, and previous memory loads may not yet be
9558 satisfied.
9559
9560 @item void __sync_lock_release (@var{type} *ptr, ...)
9561 @findex __sync_lock_release
9562 This built-in function releases the lock acquired by
9563 @code{__sync_lock_test_and_set}.
9564 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9565
9566 This built-in function is not a full barrier,
9567 but rather a @dfn{release barrier}.
9568 This means that all previous memory stores are globally visible, and all
9569 previous memory loads have been satisfied, but following memory reads
9570 are not prevented from being speculated to before the barrier.
9571 @end table
9572
9573 @node __atomic Builtins
9574 @section Built-in Functions for Memory Model Aware Atomic Operations
9575
9576 The following built-in functions approximately match the requirements
9577 for the C++11 memory model. They are all
9578 identified by being prefixed with @samp{__atomic} and most are
9579 overloaded so that they work with multiple types.
9580
9581 These functions are intended to replace the legacy @samp{__sync}
9582 builtins. The main difference is that the memory order that is requested
9583 is a parameter to the functions. New code should always use the
9584 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9585
9586 Note that the @samp{__atomic} builtins assume that programs will
9587 conform to the C++11 memory model. In particular, they assume
9588 that programs are free of data races. See the C++11 standard for
9589 detailed requirements.
9590
9591 The @samp{__atomic} builtins can be used with any integral scalar or
9592 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9593 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9594 supported by the architecture.
9595
9596 The four non-arithmetic functions (load, store, exchange, and
9597 compare_exchange) all have a generic version as well. This generic
9598 version works on any data type. It uses the lock-free built-in function
9599 if the specific data type size makes that possible; otherwise, an
9600 external call is left to be resolved at run time. This external call is
9601 the same format with the addition of a @samp{size_t} parameter inserted
9602 as the first parameter indicating the size of the object being pointed to.
9603 All objects must be the same size.
9604
9605 There are 6 different memory orders that can be specified. These map
9606 to the C++11 memory orders with the same names, see the C++11 standard
9607 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9608 on atomic synchronization} for detailed definitions. Individual
9609 targets may also support additional memory orders for use on specific
9610 architectures. Refer to the target documentation for details of
9611 these.
9612
9613 An atomic operation can both constrain code motion and
9614 be mapped to hardware instructions for synchronization between threads
9615 (e.g., a fence). To which extent this happens is controlled by the
9616 memory orders, which are listed here in approximately ascending order of
9617 strength. The description of each memory order is only meant to roughly
9618 illustrate the effects and is not a specification; see the C++11
9619 memory model for precise semantics.
9620
9621 @table @code
9622 @item __ATOMIC_RELAXED
9623 Implies no inter-thread ordering constraints.
9624 @item __ATOMIC_CONSUME
9625 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9626 memory order because of a deficiency in C++11's semantics for
9627 @code{memory_order_consume}.
9628 @item __ATOMIC_ACQUIRE
9629 Creates an inter-thread happens-before constraint from the release (or
9630 stronger) semantic store to this acquire load. Can prevent hoisting
9631 of code to before the operation.
9632 @item __ATOMIC_RELEASE
9633 Creates an inter-thread happens-before constraint to acquire (or stronger)
9634 semantic loads that read from this release store. Can prevent sinking
9635 of code to after the operation.
9636 @item __ATOMIC_ACQ_REL
9637 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9638 @code{__ATOMIC_RELEASE}.
9639 @item __ATOMIC_SEQ_CST
9640 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9641 @end table
9642
9643 Note that in the C++11 memory model, @emph{fences} (e.g.,
9644 @samp{__atomic_thread_fence}) take effect in combination with other
9645 atomic operations on specific memory locations (e.g., atomic loads);
9646 operations on specific memory locations do not necessarily affect other
9647 operations in the same way.
9648
9649 Target architectures are encouraged to provide their own patterns for
9650 each of the atomic built-in functions. If no target is provided, the original
9651 non-memory model set of @samp{__sync} atomic built-in functions are
9652 used, along with any required synchronization fences surrounding it in
9653 order to achieve the proper behavior. Execution in this case is subject
9654 to the same restrictions as those built-in functions.
9655
9656 If there is no pattern or mechanism to provide a lock-free instruction
9657 sequence, a call is made to an external routine with the same parameters
9658 to be resolved at run time.
9659
9660 When implementing patterns for these built-in functions, the memory order
9661 parameter can be ignored as long as the pattern implements the most
9662 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9663 orders execute correctly with this memory order but they may not execute as
9664 efficiently as they could with a more appropriate implementation of the
9665 relaxed requirements.
9666
9667 Note that the C++11 standard allows for the memory order parameter to be
9668 determined at run time rather than at compile time. These built-in
9669 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9670 than invoke a runtime library call or inline a switch statement. This is
9671 standard compliant, safe, and the simplest approach for now.
9672
9673 The memory order parameter is a signed int, but only the lower 16 bits are
9674 reserved for the memory order. The remainder of the signed int is reserved
9675 for target use and should be 0. Use of the predefined atomic values
9676 ensures proper usage.
9677
9678 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9679 This built-in function implements an atomic load operation. It returns the
9680 contents of @code{*@var{ptr}}.
9681
9682 The valid memory order variants are
9683 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9684 and @code{__ATOMIC_CONSUME}.
9685
9686 @end deftypefn
9687
9688 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9689 This is the generic version of an atomic load. It returns the
9690 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9691
9692 @end deftypefn
9693
9694 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9695 This built-in function implements an atomic store operation. It writes
9696 @code{@var{val}} into @code{*@var{ptr}}.
9697
9698 The valid memory order variants are
9699 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9700
9701 @end deftypefn
9702
9703 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9704 This is the generic version of an atomic store. It stores the value
9705 of @code{*@var{val}} into @code{*@var{ptr}}.
9706
9707 @end deftypefn
9708
9709 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9710 This built-in function implements an atomic exchange operation. It writes
9711 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9712 @code{*@var{ptr}}.
9713
9714 The valid memory order variants are
9715 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9716 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9717
9718 @end deftypefn
9719
9720 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9721 This is the generic version of an atomic exchange. It stores the
9722 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9723 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9724
9725 @end deftypefn
9726
9727 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memorder, int failure_memorder)
9728 This built-in function implements an atomic compare and exchange operation.
9729 This compares the contents of @code{*@var{ptr}} with the contents of
9730 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9731 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9732 equal, the operation is a @emph{read} and the current contents of
9733 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9734 for weak compare_exchange, which may fail spuriously, and false for
9735 the strong variation, which never fails spuriously. Many targets
9736 only offer the strong variation and ignore the parameter. When in doubt, use
9737 the strong variation.
9738
9739 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9740 and memory is affected according to the
9741 memory order specified by @var{success_memorder}. There are no
9742 restrictions on what memory order can be used here.
9743
9744 Otherwise, false is returned and memory is affected according
9745 to @var{failure_memorder}. This memory order cannot be
9746 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9747 stronger order than that specified by @var{success_memorder}.
9748
9749 @end deftypefn
9750
9751 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memorder, int failure_memorder)
9752 This built-in function implements the generic version of
9753 @code{__atomic_compare_exchange}. The function is virtually identical to
9754 @code{__atomic_compare_exchange_n}, except the desired value is also a
9755 pointer.
9756
9757 @end deftypefn
9758
9759 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9760 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9761 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9762 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9763 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9764 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9765 These built-in functions perform the operation suggested by the name, and
9766 return the result of the operation. Operations on pointer arguments are
9767 performed as if the operands were of the @code{uintptr_t} type. That is,
9768 they are not scaled by the size of the type to which the pointer points.
9769
9770 @smallexample
9771 @{ *ptr @var{op}= val; return *ptr; @}
9772 @end smallexample
9773
9774 The object pointed to by the first argument must be of integer or pointer
9775 type. It must not be a Boolean type. All memory orders are valid.
9776
9777 @end deftypefn
9778
9779 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9780 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9781 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9782 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9783 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9784 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9785 These built-in functions perform the operation suggested by the name, and
9786 return the value that had previously been in @code{*@var{ptr}}. Operations
9787 on pointer arguments are performed as if the operands were of
9788 the @code{uintptr_t} type. That is, they are not scaled by the size of
9789 the type to which the pointer points.
9790
9791 @smallexample
9792 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9793 @end smallexample
9794
9795 The same constraints on arguments apply as for the corresponding
9796 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9797
9798 @end deftypefn
9799
9800 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9801
9802 This built-in function performs an atomic test-and-set operation on
9803 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9804 defined nonzero ``set'' value and the return value is @code{true} if and only
9805 if the previous contents were ``set''.
9806 It should be only used for operands of type @code{bool} or @code{char}. For
9807 other types only part of the value may be set.
9808
9809 All memory orders are valid.
9810
9811 @end deftypefn
9812
9813 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9814
9815 This built-in function performs an atomic clear operation on
9816 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9817 It should be only used for operands of type @code{bool} or @code{char} and
9818 in conjunction with @code{__atomic_test_and_set}.
9819 For other types it may only clear partially. If the type is not @code{bool}
9820 prefer using @code{__atomic_store}.
9821
9822 The valid memory order variants are
9823 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9824 @code{__ATOMIC_RELEASE}.
9825
9826 @end deftypefn
9827
9828 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9829
9830 This built-in function acts as a synchronization fence between threads
9831 based on the specified memory order.
9832
9833 All memory orders are valid.
9834
9835 @end deftypefn
9836
9837 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9838
9839 This built-in function acts as a synchronization fence between a thread
9840 and signal handlers based in the same thread.
9841
9842 All memory orders are valid.
9843
9844 @end deftypefn
9845
9846 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9847
9848 This built-in function returns true if objects of @var{size} bytes always
9849 generate lock-free atomic instructions for the target architecture.
9850 @var{size} must resolve to a compile-time constant and the result also
9851 resolves to a compile-time constant.
9852
9853 @var{ptr} is an optional pointer to the object that may be used to determine
9854 alignment. A value of 0 indicates typical alignment should be used. The
9855 compiler may also ignore this parameter.
9856
9857 @smallexample
9858 if (__atomic_always_lock_free (sizeof (long long), 0))
9859 @end smallexample
9860
9861 @end deftypefn
9862
9863 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9864
9865 This built-in function returns true if objects of @var{size} bytes always
9866 generate lock-free atomic instructions for the target architecture. If
9867 the built-in function is not known to be lock-free, a call is made to a
9868 runtime routine named @code{__atomic_is_lock_free}.
9869
9870 @var{ptr} is an optional pointer to the object that may be used to determine
9871 alignment. A value of 0 indicates typical alignment should be used. The
9872 compiler may also ignore this parameter.
9873 @end deftypefn
9874
9875 @node Integer Overflow Builtins
9876 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9877
9878 The following built-in functions allow performing simple arithmetic operations
9879 together with checking whether the operations overflowed.
9880
9881 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9882 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9883 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9884 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9885 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9886 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9887 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9888
9889 These built-in functions promote the first two operands into infinite precision signed
9890 type and perform addition on those promoted operands. The result is then
9891 cast to the type the third pointer argument points to and stored there.
9892 If the stored result is equal to the infinite precision result, the built-in
9893 functions return false, otherwise they return true. As the addition is
9894 performed in infinite signed precision, these built-in functions have fully defined
9895 behavior for all argument values.
9896
9897 The first built-in function allows arbitrary integral types for operands and
9898 the result type must be pointer to some integral type other than enumerated or
9899 Boolean type, the rest of the built-in functions have explicit integer types.
9900
9901 The compiler will attempt to use hardware instructions to implement
9902 these built-in functions where possible, like conditional jump on overflow
9903 after addition, conditional jump on carry etc.
9904
9905 @end deftypefn
9906
9907 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9908 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9909 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9910 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9911 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9912 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9913 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9914
9915 These built-in functions are similar to the add overflow checking built-in
9916 functions above, except they perform subtraction, subtract the second argument
9917 from the first one, instead of addition.
9918
9919 @end deftypefn
9920
9921 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9922 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9923 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9924 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9925 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9926 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9927 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9928
9929 These built-in functions are similar to the add overflow checking built-in
9930 functions above, except they perform multiplication, instead of addition.
9931
9932 @end deftypefn
9933
9934 The following built-in functions allow checking if simple arithmetic operation
9935 would overflow.
9936
9937 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9938 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9939 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9940
9941 These built-in functions are similar to @code{__builtin_add_overflow},
9942 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
9943 they don't store the result of the arithmetic operation anywhere and the
9944 last argument is not a pointer, but some expression with integral type other
9945 than enumerated or Boolean type.
9946
9947 The built-in functions promote the first two operands into infinite precision signed type
9948 and perform addition on those promoted operands. The result is then
9949 cast to the type of the third argument. If the cast result is equal to the infinite
9950 precision result, the built-in functions return false, otherwise they return true.
9951 The value of the third argument is ignored, just the side-effects in the third argument
9952 are evaluated, and no integral argument promotions are performed on the last argument.
9953 If the third argument is a bit-field, the type used for the result cast has the
9954 precision and signedness of the given bit-field, rather than precision and signedness
9955 of the underlying type.
9956
9957 For example, the following macro can be used to portably check, at
9958 compile-time, whether or not adding two constant integers will overflow,
9959 and perform the addition only when it is known to be safe and not to trigger
9960 a @option{-Woverflow} warning.
9961
9962 @smallexample
9963 #define INT_ADD_OVERFLOW_P(a, b) \
9964 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
9965
9966 enum @{
9967 A = INT_MAX, B = 3,
9968 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
9969 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
9970 @};
9971 @end smallexample
9972
9973 The compiler will attempt to use hardware instructions to implement
9974 these built-in functions where possible, like conditional jump on overflow
9975 after addition, conditional jump on carry etc.
9976
9977 @end deftypefn
9978
9979 @node x86 specific memory model extensions for transactional memory
9980 @section x86-Specific Memory Model Extensions for Transactional Memory
9981
9982 The x86 architecture supports additional memory ordering flags
9983 to mark lock critical sections for hardware lock elision.
9984 These must be specified in addition to an existing memory order to
9985 atomic intrinsics.
9986
9987 @table @code
9988 @item __ATOMIC_HLE_ACQUIRE
9989 Start lock elision on a lock variable.
9990 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9991 @item __ATOMIC_HLE_RELEASE
9992 End lock elision on a lock variable.
9993 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9994 @end table
9995
9996 When a lock acquire fails, it is required for good performance to abort
9997 the transaction quickly. This can be done with a @code{_mm_pause}.
9998
9999 @smallexample
10000 #include <immintrin.h> // For _mm_pause
10001
10002 int lockvar;
10003
10004 /* Acquire lock with lock elision */
10005 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10006 _mm_pause(); /* Abort failed transaction */
10007 ...
10008 /* Free lock with lock elision */
10009 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10010 @end smallexample
10011
10012 @node Object Size Checking
10013 @section Object Size Checking Built-in Functions
10014 @findex __builtin_object_size
10015 @findex __builtin___memcpy_chk
10016 @findex __builtin___mempcpy_chk
10017 @findex __builtin___memmove_chk
10018 @findex __builtin___memset_chk
10019 @findex __builtin___strcpy_chk
10020 @findex __builtin___stpcpy_chk
10021 @findex __builtin___strncpy_chk
10022 @findex __builtin___strcat_chk
10023 @findex __builtin___strncat_chk
10024 @findex __builtin___sprintf_chk
10025 @findex __builtin___snprintf_chk
10026 @findex __builtin___vsprintf_chk
10027 @findex __builtin___vsnprintf_chk
10028 @findex __builtin___printf_chk
10029 @findex __builtin___vprintf_chk
10030 @findex __builtin___fprintf_chk
10031 @findex __builtin___vfprintf_chk
10032
10033 GCC implements a limited buffer overflow protection mechanism
10034 that can prevent some buffer overflow attacks.
10035
10036 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
10037 is a built-in construct that returns a constant number of bytes from
10038 @var{ptr} to the end of the object @var{ptr} pointer points to
10039 (if known at compile time). @code{__builtin_object_size} never evaluates
10040 its arguments for side-effects. If there are any side-effects in them, it
10041 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10042 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10043 point to and all of them are known at compile time, the returned number
10044 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10045 0 and minimum if nonzero. If it is not possible to determine which objects
10046 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10047 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10048 for @var{type} 2 or 3.
10049
10050 @var{type} is an integer constant from 0 to 3. If the least significant
10051 bit is clear, objects are whole variables, if it is set, a closest
10052 surrounding subobject is considered the object a pointer points to.
10053 The second bit determines if maximum or minimum of remaining bytes
10054 is computed.
10055
10056 @smallexample
10057 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10058 char *p = &var.buf1[1], *q = &var.b;
10059
10060 /* Here the object p points to is var. */
10061 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10062 /* The subobject p points to is var.buf1. */
10063 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10064 /* The object q points to is var. */
10065 assert (__builtin_object_size (q, 0)
10066 == (char *) (&var + 1) - (char *) &var.b);
10067 /* The subobject q points to is var.b. */
10068 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10069 @end smallexample
10070 @end deftypefn
10071
10072 There are built-in functions added for many common string operation
10073 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10074 built-in is provided. This built-in has an additional last argument,
10075 which is the number of bytes remaining in object the @var{dest}
10076 argument points to or @code{(size_t) -1} if the size is not known.
10077
10078 The built-in functions are optimized into the normal string functions
10079 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10080 it is known at compile time that the destination object will not
10081 be overflown. If the compiler can determine at compile time the
10082 object will be always overflown, it issues a warning.
10083
10084 The intended use can be e.g.@:
10085
10086 @smallexample
10087 #undef memcpy
10088 #define bos0(dest) __builtin_object_size (dest, 0)
10089 #define memcpy(dest, src, n) \
10090 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10091
10092 char *volatile p;
10093 char buf[10];
10094 /* It is unknown what object p points to, so this is optimized
10095 into plain memcpy - no checking is possible. */
10096 memcpy (p, "abcde", n);
10097 /* Destination is known and length too. It is known at compile
10098 time there will be no overflow. */
10099 memcpy (&buf[5], "abcde", 5);
10100 /* Destination is known, but the length is not known at compile time.
10101 This will result in __memcpy_chk call that can check for overflow
10102 at run time. */
10103 memcpy (&buf[5], "abcde", n);
10104 /* Destination is known and it is known at compile time there will
10105 be overflow. There will be a warning and __memcpy_chk call that
10106 will abort the program at run time. */
10107 memcpy (&buf[6], "abcde", 5);
10108 @end smallexample
10109
10110 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10111 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10112 @code{strcat} and @code{strncat}.
10113
10114 There are also checking built-in functions for formatted output functions.
10115 @smallexample
10116 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10117 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10118 const char *fmt, ...);
10119 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10120 va_list ap);
10121 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10122 const char *fmt, va_list ap);
10123 @end smallexample
10124
10125 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10126 etc.@: functions and can contain implementation specific flags on what
10127 additional security measures the checking function might take, such as
10128 handling @code{%n} differently.
10129
10130 The @var{os} argument is the object size @var{s} points to, like in the
10131 other built-in functions. There is a small difference in the behavior
10132 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10133 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10134 the checking function is called with @var{os} argument set to
10135 @code{(size_t) -1}.
10136
10137 In addition to this, there are checking built-in functions
10138 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10139 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10140 These have just one additional argument, @var{flag}, right before
10141 format string @var{fmt}. If the compiler is able to optimize them to
10142 @code{fputc} etc.@: functions, it does, otherwise the checking function
10143 is called and the @var{flag} argument passed to it.
10144
10145 @node Pointer Bounds Checker builtins
10146 @section Pointer Bounds Checker Built-in Functions
10147 @cindex Pointer Bounds Checker builtins
10148 @findex __builtin___bnd_set_ptr_bounds
10149 @findex __builtin___bnd_narrow_ptr_bounds
10150 @findex __builtin___bnd_copy_ptr_bounds
10151 @findex __builtin___bnd_init_ptr_bounds
10152 @findex __builtin___bnd_null_ptr_bounds
10153 @findex __builtin___bnd_store_ptr_bounds
10154 @findex __builtin___bnd_chk_ptr_lbounds
10155 @findex __builtin___bnd_chk_ptr_ubounds
10156 @findex __builtin___bnd_chk_ptr_bounds
10157 @findex __builtin___bnd_get_ptr_lbound
10158 @findex __builtin___bnd_get_ptr_ubound
10159
10160 GCC provides a set of built-in functions to control Pointer Bounds Checker
10161 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10162 even if you compile with Pointer Bounds Checker off
10163 (@option{-fno-check-pointer-bounds}).
10164 The behavior may differ in such case as documented below.
10165
10166 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10167
10168 This built-in function returns a new pointer with the value of @var{q}, and
10169 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10170 Bounds Checker off, the built-in function just returns the first argument.
10171
10172 @smallexample
10173 extern void *__wrap_malloc (size_t n)
10174 @{
10175 void *p = (void *)__real_malloc (n);
10176 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10177 return __builtin___bnd_set_ptr_bounds (p, n);
10178 @}
10179 @end smallexample
10180
10181 @end deftypefn
10182
10183 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10184
10185 This built-in function returns a new pointer with the value of @var{p}
10186 and associates it with the narrowed bounds formed by the intersection
10187 of bounds associated with @var{q} and the bounds
10188 [@var{p}, @var{p} + @var{size} - 1].
10189 With Pointer Bounds Checker off, the built-in function just returns the first
10190 argument.
10191
10192 @smallexample
10193 void init_objects (object *objs, size_t size)
10194 @{
10195 size_t i;
10196 /* Initialize objects one-by-one passing pointers with bounds of
10197 an object, not the full array of objects. */
10198 for (i = 0; i < size; i++)
10199 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10200 sizeof(object)));
10201 @}
10202 @end smallexample
10203
10204 @end deftypefn
10205
10206 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10207
10208 This built-in function returns a new pointer with the value of @var{q},
10209 and associates it with the bounds already associated with pointer @var{r}.
10210 With Pointer Bounds Checker off, the built-in function just returns the first
10211 argument.
10212
10213 @smallexample
10214 /* Here is a way to get pointer to object's field but
10215 still with the full object's bounds. */
10216 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10217 objptr);
10218 @end smallexample
10219
10220 @end deftypefn
10221
10222 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10223
10224 This built-in function returns a new pointer with the value of @var{q}, and
10225 associates it with INIT (allowing full memory access) bounds. With Pointer
10226 Bounds Checker off, the built-in function just returns the first argument.
10227
10228 @end deftypefn
10229
10230 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10231
10232 This built-in function returns a new pointer with the value of @var{q}, and
10233 associates it with NULL (allowing no memory access) bounds. With Pointer
10234 Bounds Checker off, the built-in function just returns the first argument.
10235
10236 @end deftypefn
10237
10238 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10239
10240 This built-in function stores the bounds associated with pointer @var{ptr_val}
10241 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10242 bounds from legacy code without touching the associated pointer's memory when
10243 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10244 function call is ignored.
10245
10246 @end deftypefn
10247
10248 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10249
10250 This built-in function checks if the pointer @var{q} is within the lower
10251 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10252 function call is ignored.
10253
10254 @smallexample
10255 extern void *__wrap_memset (void *dst, int c, size_t len)
10256 @{
10257 if (len > 0)
10258 @{
10259 __builtin___bnd_chk_ptr_lbounds (dst);
10260 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10261 __real_memset (dst, c, len);
10262 @}
10263 return dst;
10264 @}
10265 @end smallexample
10266
10267 @end deftypefn
10268
10269 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10270
10271 This built-in function checks if the pointer @var{q} is within the upper
10272 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10273 function call is ignored.
10274
10275 @end deftypefn
10276
10277 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10278
10279 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10280 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10281 off, the built-in function call is ignored.
10282
10283 @smallexample
10284 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10285 @{
10286 if (n > 0)
10287 @{
10288 __bnd_chk_ptr_bounds (dst, n);
10289 __bnd_chk_ptr_bounds (src, n);
10290 __real_memcpy (dst, src, n);
10291 @}
10292 return dst;
10293 @}
10294 @end smallexample
10295
10296 @end deftypefn
10297
10298 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10299
10300 This built-in function returns the lower bound associated
10301 with the pointer @var{q}, as a pointer value.
10302 This is useful for debugging using @code{printf}.
10303 With Pointer Bounds Checker off, the built-in function returns 0.
10304
10305 @smallexample
10306 void *lb = __builtin___bnd_get_ptr_lbound (q);
10307 void *ub = __builtin___bnd_get_ptr_ubound (q);
10308 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10309 @end smallexample
10310
10311 @end deftypefn
10312
10313 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10314
10315 This built-in function returns the upper bound (which is a pointer) associated
10316 with the pointer @var{q}. With Pointer Bounds Checker off,
10317 the built-in function returns -1.
10318
10319 @end deftypefn
10320
10321 @node Cilk Plus Builtins
10322 @section Cilk Plus C/C++ Language Extension Built-in Functions
10323
10324 GCC provides support for the following built-in reduction functions if Cilk Plus
10325 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10326
10327 @itemize @bullet
10328 @item @code{__sec_implicit_index}
10329 @item @code{__sec_reduce}
10330 @item @code{__sec_reduce_add}
10331 @item @code{__sec_reduce_all_nonzero}
10332 @item @code{__sec_reduce_all_zero}
10333 @item @code{__sec_reduce_any_nonzero}
10334 @item @code{__sec_reduce_any_zero}
10335 @item @code{__sec_reduce_max}
10336 @item @code{__sec_reduce_min}
10337 @item @code{__sec_reduce_max_ind}
10338 @item @code{__sec_reduce_min_ind}
10339 @item @code{__sec_reduce_mul}
10340 @item @code{__sec_reduce_mutating}
10341 @end itemize
10342
10343 Further details and examples about these built-in functions are described
10344 in the Cilk Plus language manual which can be found at
10345 @uref{http://www.cilkplus.org}.
10346
10347 @node Other Builtins
10348 @section Other Built-in Functions Provided by GCC
10349 @cindex built-in functions
10350 @findex __builtin_alloca
10351 @findex __builtin_alloca_with_align
10352 @findex __builtin_call_with_static_chain
10353 @findex __builtin_fpclassify
10354 @findex __builtin_isfinite
10355 @findex __builtin_isnormal
10356 @findex __builtin_isgreater
10357 @findex __builtin_isgreaterequal
10358 @findex __builtin_isinf_sign
10359 @findex __builtin_isless
10360 @findex __builtin_islessequal
10361 @findex __builtin_islessgreater
10362 @findex __builtin_isunordered
10363 @findex __builtin_powi
10364 @findex __builtin_powif
10365 @findex __builtin_powil
10366 @findex _Exit
10367 @findex _exit
10368 @findex abort
10369 @findex abs
10370 @findex acos
10371 @findex acosf
10372 @findex acosh
10373 @findex acoshf
10374 @findex acoshl
10375 @findex acosl
10376 @findex alloca
10377 @findex asin
10378 @findex asinf
10379 @findex asinh
10380 @findex asinhf
10381 @findex asinhl
10382 @findex asinl
10383 @findex atan
10384 @findex atan2
10385 @findex atan2f
10386 @findex atan2l
10387 @findex atanf
10388 @findex atanh
10389 @findex atanhf
10390 @findex atanhl
10391 @findex atanl
10392 @findex bcmp
10393 @findex bzero
10394 @findex cabs
10395 @findex cabsf
10396 @findex cabsl
10397 @findex cacos
10398 @findex cacosf
10399 @findex cacosh
10400 @findex cacoshf
10401 @findex cacoshl
10402 @findex cacosl
10403 @findex calloc
10404 @findex carg
10405 @findex cargf
10406 @findex cargl
10407 @findex casin
10408 @findex casinf
10409 @findex casinh
10410 @findex casinhf
10411 @findex casinhl
10412 @findex casinl
10413 @findex catan
10414 @findex catanf
10415 @findex catanh
10416 @findex catanhf
10417 @findex catanhl
10418 @findex catanl
10419 @findex cbrt
10420 @findex cbrtf
10421 @findex cbrtl
10422 @findex ccos
10423 @findex ccosf
10424 @findex ccosh
10425 @findex ccoshf
10426 @findex ccoshl
10427 @findex ccosl
10428 @findex ceil
10429 @findex ceilf
10430 @findex ceill
10431 @findex cexp
10432 @findex cexpf
10433 @findex cexpl
10434 @findex cimag
10435 @findex cimagf
10436 @findex cimagl
10437 @findex clog
10438 @findex clogf
10439 @findex clogl
10440 @findex clog10
10441 @findex clog10f
10442 @findex clog10l
10443 @findex conj
10444 @findex conjf
10445 @findex conjl
10446 @findex copysign
10447 @findex copysignf
10448 @findex copysignl
10449 @findex cos
10450 @findex cosf
10451 @findex cosh
10452 @findex coshf
10453 @findex coshl
10454 @findex cosl
10455 @findex cpow
10456 @findex cpowf
10457 @findex cpowl
10458 @findex cproj
10459 @findex cprojf
10460 @findex cprojl
10461 @findex creal
10462 @findex crealf
10463 @findex creall
10464 @findex csin
10465 @findex csinf
10466 @findex csinh
10467 @findex csinhf
10468 @findex csinhl
10469 @findex csinl
10470 @findex csqrt
10471 @findex csqrtf
10472 @findex csqrtl
10473 @findex ctan
10474 @findex ctanf
10475 @findex ctanh
10476 @findex ctanhf
10477 @findex ctanhl
10478 @findex ctanl
10479 @findex dcgettext
10480 @findex dgettext
10481 @findex drem
10482 @findex dremf
10483 @findex dreml
10484 @findex erf
10485 @findex erfc
10486 @findex erfcf
10487 @findex erfcl
10488 @findex erff
10489 @findex erfl
10490 @findex exit
10491 @findex exp
10492 @findex exp10
10493 @findex exp10f
10494 @findex exp10l
10495 @findex exp2
10496 @findex exp2f
10497 @findex exp2l
10498 @findex expf
10499 @findex expl
10500 @findex expm1
10501 @findex expm1f
10502 @findex expm1l
10503 @findex fabs
10504 @findex fabsf
10505 @findex fabsl
10506 @findex fdim
10507 @findex fdimf
10508 @findex fdiml
10509 @findex ffs
10510 @findex floor
10511 @findex floorf
10512 @findex floorl
10513 @findex fma
10514 @findex fmaf
10515 @findex fmal
10516 @findex fmax
10517 @findex fmaxf
10518 @findex fmaxl
10519 @findex fmin
10520 @findex fminf
10521 @findex fminl
10522 @findex fmod
10523 @findex fmodf
10524 @findex fmodl
10525 @findex fprintf
10526 @findex fprintf_unlocked
10527 @findex fputs
10528 @findex fputs_unlocked
10529 @findex frexp
10530 @findex frexpf
10531 @findex frexpl
10532 @findex fscanf
10533 @findex gamma
10534 @findex gammaf
10535 @findex gammal
10536 @findex gamma_r
10537 @findex gammaf_r
10538 @findex gammal_r
10539 @findex gettext
10540 @findex hypot
10541 @findex hypotf
10542 @findex hypotl
10543 @findex ilogb
10544 @findex ilogbf
10545 @findex ilogbl
10546 @findex imaxabs
10547 @findex index
10548 @findex isalnum
10549 @findex isalpha
10550 @findex isascii
10551 @findex isblank
10552 @findex iscntrl
10553 @findex isdigit
10554 @findex isgraph
10555 @findex islower
10556 @findex isprint
10557 @findex ispunct
10558 @findex isspace
10559 @findex isupper
10560 @findex iswalnum
10561 @findex iswalpha
10562 @findex iswblank
10563 @findex iswcntrl
10564 @findex iswdigit
10565 @findex iswgraph
10566 @findex iswlower
10567 @findex iswprint
10568 @findex iswpunct
10569 @findex iswspace
10570 @findex iswupper
10571 @findex iswxdigit
10572 @findex isxdigit
10573 @findex j0
10574 @findex j0f
10575 @findex j0l
10576 @findex j1
10577 @findex j1f
10578 @findex j1l
10579 @findex jn
10580 @findex jnf
10581 @findex jnl
10582 @findex labs
10583 @findex ldexp
10584 @findex ldexpf
10585 @findex ldexpl
10586 @findex lgamma
10587 @findex lgammaf
10588 @findex lgammal
10589 @findex lgamma_r
10590 @findex lgammaf_r
10591 @findex lgammal_r
10592 @findex llabs
10593 @findex llrint
10594 @findex llrintf
10595 @findex llrintl
10596 @findex llround
10597 @findex llroundf
10598 @findex llroundl
10599 @findex log
10600 @findex log10
10601 @findex log10f
10602 @findex log10l
10603 @findex log1p
10604 @findex log1pf
10605 @findex log1pl
10606 @findex log2
10607 @findex log2f
10608 @findex log2l
10609 @findex logb
10610 @findex logbf
10611 @findex logbl
10612 @findex logf
10613 @findex logl
10614 @findex lrint
10615 @findex lrintf
10616 @findex lrintl
10617 @findex lround
10618 @findex lroundf
10619 @findex lroundl
10620 @findex malloc
10621 @findex memchr
10622 @findex memcmp
10623 @findex memcpy
10624 @findex mempcpy
10625 @findex memset
10626 @findex modf
10627 @findex modff
10628 @findex modfl
10629 @findex nearbyint
10630 @findex nearbyintf
10631 @findex nearbyintl
10632 @findex nextafter
10633 @findex nextafterf
10634 @findex nextafterl
10635 @findex nexttoward
10636 @findex nexttowardf
10637 @findex nexttowardl
10638 @findex pow
10639 @findex pow10
10640 @findex pow10f
10641 @findex pow10l
10642 @findex powf
10643 @findex powl
10644 @findex printf
10645 @findex printf_unlocked
10646 @findex putchar
10647 @findex puts
10648 @findex remainder
10649 @findex remainderf
10650 @findex remainderl
10651 @findex remquo
10652 @findex remquof
10653 @findex remquol
10654 @findex rindex
10655 @findex rint
10656 @findex rintf
10657 @findex rintl
10658 @findex round
10659 @findex roundf
10660 @findex roundl
10661 @findex scalb
10662 @findex scalbf
10663 @findex scalbl
10664 @findex scalbln
10665 @findex scalblnf
10666 @findex scalblnf
10667 @findex scalbn
10668 @findex scalbnf
10669 @findex scanfnl
10670 @findex signbit
10671 @findex signbitf
10672 @findex signbitl
10673 @findex signbitd32
10674 @findex signbitd64
10675 @findex signbitd128
10676 @findex significand
10677 @findex significandf
10678 @findex significandl
10679 @findex sin
10680 @findex sincos
10681 @findex sincosf
10682 @findex sincosl
10683 @findex sinf
10684 @findex sinh
10685 @findex sinhf
10686 @findex sinhl
10687 @findex sinl
10688 @findex snprintf
10689 @findex sprintf
10690 @findex sqrt
10691 @findex sqrtf
10692 @findex sqrtl
10693 @findex sscanf
10694 @findex stpcpy
10695 @findex stpncpy
10696 @findex strcasecmp
10697 @findex strcat
10698 @findex strchr
10699 @findex strcmp
10700 @findex strcpy
10701 @findex strcspn
10702 @findex strdup
10703 @findex strfmon
10704 @findex strftime
10705 @findex strlen
10706 @findex strncasecmp
10707 @findex strncat
10708 @findex strncmp
10709 @findex strncpy
10710 @findex strndup
10711 @findex strpbrk
10712 @findex strrchr
10713 @findex strspn
10714 @findex strstr
10715 @findex tan
10716 @findex tanf
10717 @findex tanh
10718 @findex tanhf
10719 @findex tanhl
10720 @findex tanl
10721 @findex tgamma
10722 @findex tgammaf
10723 @findex tgammal
10724 @findex toascii
10725 @findex tolower
10726 @findex toupper
10727 @findex towlower
10728 @findex towupper
10729 @findex trunc
10730 @findex truncf
10731 @findex truncl
10732 @findex vfprintf
10733 @findex vfscanf
10734 @findex vprintf
10735 @findex vscanf
10736 @findex vsnprintf
10737 @findex vsprintf
10738 @findex vsscanf
10739 @findex y0
10740 @findex y0f
10741 @findex y0l
10742 @findex y1
10743 @findex y1f
10744 @findex y1l
10745 @findex yn
10746 @findex ynf
10747 @findex ynl
10748
10749 GCC provides a large number of built-in functions other than the ones
10750 mentioned above. Some of these are for internal use in the processing
10751 of exceptions or variable-length argument lists and are not
10752 documented here because they may change from time to time; we do not
10753 recommend general use of these functions.
10754
10755 The remaining functions are provided for optimization purposes.
10756
10757 With the exception of built-ins that have library equivalents such as
10758 the standard C library functions discussed below, or that expand to
10759 library calls, GCC built-in functions are always expanded inline and
10760 thus do not have corresponding entry points and their address cannot
10761 be obtained. Attempting to use them in an expression other than
10762 a function call results in a compile-time error.
10763
10764 @opindex fno-builtin
10765 GCC includes built-in versions of many of the functions in the standard
10766 C library. These functions come in two forms: one whose names start with
10767 the @code{__builtin_} prefix, and the other without. Both forms have the
10768 same type (including prototype), the same address (when their address is
10769 taken), and the same meaning as the C library functions even if you specify
10770 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10771 functions are only optimized in certain cases; if they are not optimized in
10772 a particular case, a call to the library function is emitted.
10773
10774 @opindex ansi
10775 @opindex std
10776 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10777 @option{-std=c99} or @option{-std=c11}), the functions
10778 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10779 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10780 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10781 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10782 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10783 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10784 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10785 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10786 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10787 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10788 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10789 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10790 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10791 @code{significandl}, @code{significand}, @code{sincosf},
10792 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10793 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10794 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10795 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10796 @code{yn}
10797 may be handled as built-in functions.
10798 All these functions have corresponding versions
10799 prefixed with @code{__builtin_}, which may be used even in strict C90
10800 mode.
10801
10802 The ISO C99 functions
10803 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10804 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10805 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10806 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10807 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10808 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10809 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10810 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10811 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10812 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10813 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10814 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10815 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10816 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10817 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10818 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10819 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10820 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10821 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10822 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10823 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10824 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10825 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10826 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10827 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10828 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10829 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10830 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10831 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10832 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10833 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10834 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10835 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10836 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10837 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10838 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10839 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10840 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10841 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10842 are handled as built-in functions
10843 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10844
10845 There are also built-in versions of the ISO C99 functions
10846 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10847 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10848 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10849 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10850 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10851 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10852 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10853 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10854 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10855 that are recognized in any mode since ISO C90 reserves these names for
10856 the purpose to which ISO C99 puts them. All these functions have
10857 corresponding versions prefixed with @code{__builtin_}.
10858
10859 There are also built-in functions @code{__builtin_fabsf@var{n}},
10860 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
10861 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
10862 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
10863 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
10864 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
10865
10866 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10867 @code{clog10l} which names are reserved by ISO C99 for future use.
10868 All these functions have versions prefixed with @code{__builtin_}.
10869
10870 The ISO C94 functions
10871 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10872 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10873 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10874 @code{towupper}
10875 are handled as built-in functions
10876 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10877
10878 The ISO C90 functions
10879 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10880 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10881 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10882 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10883 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10884 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10885 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10886 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10887 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10888 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10889 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10890 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10891 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10892 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10893 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10894 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10895 are all recognized as built-in functions unless
10896 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10897 is specified for an individual function). All of these functions have
10898 corresponding versions prefixed with @code{__builtin_}.
10899
10900 GCC provides built-in versions of the ISO C99 floating-point comparison
10901 macros that avoid raising exceptions for unordered operands. They have
10902 the same names as the standard macros ( @code{isgreater},
10903 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10904 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10905 prefixed. We intend for a library implementor to be able to simply
10906 @code{#define} each standard macro to its built-in equivalent.
10907 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10908 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10909 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10910 built-in functions appear both with and without the @code{__builtin_} prefix.
10911
10912 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10913 The @code{__builtin_alloca} function must be called at block scope.
10914 The function allocates an object @var{size} bytes large on the stack
10915 of the calling function. The object is aligned on the default stack
10916 alignment boundary for the target determined by the
10917 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10918 function returns a pointer to the first byte of the allocated object.
10919 The lifetime of the allocated object ends just before the calling
10920 function returns to its caller. This is so even when
10921 @code{__builtin_alloca} is called within a nested block.
10922
10923 For example, the following function allocates eight objects of @code{n}
10924 bytes each on the stack, storing a pointer to each in consecutive elements
10925 of the array @code{a}. It then passes the array to function @code{g}
10926 which can safely use the storage pointed to by each of the array elements.
10927
10928 @smallexample
10929 void f (unsigned n)
10930 @{
10931 void *a [8];
10932 for (int i = 0; i != 8; ++i)
10933 a [i] = __builtin_alloca (n);
10934
10935 g (a, n); // @r{safe}
10936 @}
10937 @end smallexample
10938
10939 Since the @code{__builtin_alloca} function doesn't validate its argument
10940 it is the responsibility of its caller to make sure the argument doesn't
10941 cause it to exceed the stack size limit.
10942 The @code{__builtin_alloca} function is provided to make it possible to
10943 allocate on the stack arrays of bytes with an upper bound that may be
10944 computed at run time. Since C99 Variable Length Arrays offer
10945 similar functionality under a portable, more convenient, and safer
10946 interface they are recommended instead, in both C99 and C++ programs
10947 where GCC provides them as an extension.
10948 @xref{Variable Length}, for details.
10949
10950 @end deftypefn
10951
10952 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10953 The @code{__builtin_alloca_with_align} function must be called at block
10954 scope. The function allocates an object @var{size} bytes large on
10955 the stack of the calling function. The allocated object is aligned on
10956 the boundary specified by the argument @var{alignment} whose unit is given
10957 in bits (not bytes). The @var{size} argument must be positive and not
10958 exceed the stack size limit. The @var{alignment} argument must be a constant
10959 integer expression that evaluates to a power of 2 greater than or equal to
10960 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10961 with other values are rejected with an error indicating the valid bounds.
10962 The function returns a pointer to the first byte of the allocated object.
10963 The lifetime of the allocated object ends at the end of the block in which
10964 the function was called. The allocated storage is released no later than
10965 just before the calling function returns to its caller, but may be released
10966 at the end of the block in which the function was called.
10967
10968 For example, in the following function the call to @code{g} is unsafe
10969 because when @code{overalign} is non-zero, the space allocated by
10970 @code{__builtin_alloca_with_align} may have been released at the end
10971 of the @code{if} statement in which it was called.
10972
10973 @smallexample
10974 void f (unsigned n, bool overalign)
10975 @{
10976 void *p;
10977 if (overalign)
10978 p = __builtin_alloca_with_align (n, 64 /* bits */);
10979 else
10980 p = __builtin_alloc (n);
10981
10982 g (p, n); // @r{unsafe}
10983 @}
10984 @end smallexample
10985
10986 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10987 @var{size} argument it is the responsibility of its caller to make sure
10988 the argument doesn't cause it to exceed the stack size limit.
10989 The @code{__builtin_alloca_with_align} function is provided to make
10990 it possible to allocate on the stack overaligned arrays of bytes with
10991 an upper bound that may be computed at run time. Since C99
10992 Variable Length Arrays offer the same functionality under
10993 a portable, more convenient, and safer interface they are recommended
10994 instead, in both C99 and C++ programs where GCC provides them as
10995 an extension. @xref{Variable Length}, for details.
10996
10997 @end deftypefn
10998
10999 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11000
11001 You can use the built-in function @code{__builtin_types_compatible_p} to
11002 determine whether two types are the same.
11003
11004 This built-in function returns 1 if the unqualified versions of the
11005 types @var{type1} and @var{type2} (which are types, not expressions) are
11006 compatible, 0 otherwise. The result of this built-in function can be
11007 used in integer constant expressions.
11008
11009 This built-in function ignores top level qualifiers (e.g., @code{const},
11010 @code{volatile}). For example, @code{int} is equivalent to @code{const
11011 int}.
11012
11013 The type @code{int[]} and @code{int[5]} are compatible. On the other
11014 hand, @code{int} and @code{char *} are not compatible, even if the size
11015 of their types, on the particular architecture are the same. Also, the
11016 amount of pointer indirection is taken into account when determining
11017 similarity. Consequently, @code{short *} is not similar to
11018 @code{short **}. Furthermore, two types that are typedefed are
11019 considered compatible if their underlying types are compatible.
11020
11021 An @code{enum} type is not considered to be compatible with another
11022 @code{enum} type even if both are compatible with the same integer
11023 type; this is what the C standard specifies.
11024 For example, @code{enum @{foo, bar@}} is not similar to
11025 @code{enum @{hot, dog@}}.
11026
11027 You typically use this function in code whose execution varies
11028 depending on the arguments' types. For example:
11029
11030 @smallexample
11031 #define foo(x) \
11032 (@{ \
11033 typeof (x) tmp = (x); \
11034 if (__builtin_types_compatible_p (typeof (x), long double)) \
11035 tmp = foo_long_double (tmp); \
11036 else if (__builtin_types_compatible_p (typeof (x), double)) \
11037 tmp = foo_double (tmp); \
11038 else if (__builtin_types_compatible_p (typeof (x), float)) \
11039 tmp = foo_float (tmp); \
11040 else \
11041 abort (); \
11042 tmp; \
11043 @})
11044 @end smallexample
11045
11046 @emph{Note:} This construct is only available for C@.
11047
11048 @end deftypefn
11049
11050 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11051
11052 The @var{call_exp} expression must be a function call, and the
11053 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11054 is passed to the function call in the target's static chain location.
11055 The result of builtin is the result of the function call.
11056
11057 @emph{Note:} This builtin is only available for C@.
11058 This builtin can be used to call Go closures from C.
11059
11060 @end deftypefn
11061
11062 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11063
11064 You can use the built-in function @code{__builtin_choose_expr} to
11065 evaluate code depending on the value of a constant expression. This
11066 built-in function returns @var{exp1} if @var{const_exp}, which is an
11067 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11068
11069 This built-in function is analogous to the @samp{? :} operator in C,
11070 except that the expression returned has its type unaltered by promotion
11071 rules. Also, the built-in function does not evaluate the expression
11072 that is not chosen. For example, if @var{const_exp} evaluates to true,
11073 @var{exp2} is not evaluated even if it has side-effects.
11074
11075 This built-in function can return an lvalue if the chosen argument is an
11076 lvalue.
11077
11078 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11079 type. Similarly, if @var{exp2} is returned, its return type is the same
11080 as @var{exp2}.
11081
11082 Example:
11083
11084 @smallexample
11085 #define foo(x) \
11086 __builtin_choose_expr ( \
11087 __builtin_types_compatible_p (typeof (x), double), \
11088 foo_double (x), \
11089 __builtin_choose_expr ( \
11090 __builtin_types_compatible_p (typeof (x), float), \
11091 foo_float (x), \
11092 /* @r{The void expression results in a compile-time error} \
11093 @r{when assigning the result to something.} */ \
11094 (void)0))
11095 @end smallexample
11096
11097 @emph{Note:} This construct is only available for C@. Furthermore, the
11098 unused expression (@var{exp1} or @var{exp2} depending on the value of
11099 @var{const_exp}) may still generate syntax errors. This may change in
11100 future revisions.
11101
11102 @end deftypefn
11103
11104 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11105
11106 The built-in function @code{__builtin_complex} is provided for use in
11107 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11108 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11109 real binary floating-point type, and the result has the corresponding
11110 complex type with real and imaginary parts @var{real} and @var{imag}.
11111 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11112 infinities, NaNs and negative zeros are involved.
11113
11114 @end deftypefn
11115
11116 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11117 You can use the built-in function @code{__builtin_constant_p} to
11118 determine if a value is known to be constant at compile time and hence
11119 that GCC can perform constant-folding on expressions involving that
11120 value. The argument of the function is the value to test. The function
11121 returns the integer 1 if the argument is known to be a compile-time
11122 constant and 0 if it is not known to be a compile-time constant. A
11123 return of 0 does not indicate that the value is @emph{not} a constant,
11124 but merely that GCC cannot prove it is a constant with the specified
11125 value of the @option{-O} option.
11126
11127 You typically use this function in an embedded application where
11128 memory is a critical resource. If you have some complex calculation,
11129 you may want it to be folded if it involves constants, but need to call
11130 a function if it does not. For example:
11131
11132 @smallexample
11133 #define Scale_Value(X) \
11134 (__builtin_constant_p (X) \
11135 ? ((X) * SCALE + OFFSET) : Scale (X))
11136 @end smallexample
11137
11138 You may use this built-in function in either a macro or an inline
11139 function. However, if you use it in an inlined function and pass an
11140 argument of the function as the argument to the built-in, GCC
11141 never returns 1 when you call the inline function with a string constant
11142 or compound literal (@pxref{Compound Literals}) and does not return 1
11143 when you pass a constant numeric value to the inline function unless you
11144 specify the @option{-O} option.
11145
11146 You may also use @code{__builtin_constant_p} in initializers for static
11147 data. For instance, you can write
11148
11149 @smallexample
11150 static const int table[] = @{
11151 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11152 /* @r{@dots{}} */
11153 @};
11154 @end smallexample
11155
11156 @noindent
11157 This is an acceptable initializer even if @var{EXPRESSION} is not a
11158 constant expression, including the case where
11159 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11160 folded to a constant but @var{EXPRESSION} contains operands that are
11161 not otherwise permitted in a static initializer (for example,
11162 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11163 built-in in this case, because it has no opportunity to perform
11164 optimization.
11165 @end deftypefn
11166
11167 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11168 @opindex fprofile-arcs
11169 You may use @code{__builtin_expect} to provide the compiler with
11170 branch prediction information. In general, you should prefer to
11171 use actual profile feedback for this (@option{-fprofile-arcs}), as
11172 programmers are notoriously bad at predicting how their programs
11173 actually perform. However, there are applications in which this
11174 data is hard to collect.
11175
11176 The return value is the value of @var{exp}, which should be an integral
11177 expression. The semantics of the built-in are that it is expected that
11178 @var{exp} == @var{c}. For example:
11179
11180 @smallexample
11181 if (__builtin_expect (x, 0))
11182 foo ();
11183 @end smallexample
11184
11185 @noindent
11186 indicates that we do not expect to call @code{foo}, since
11187 we expect @code{x} to be zero. Since you are limited to integral
11188 expressions for @var{exp}, you should use constructions such as
11189
11190 @smallexample
11191 if (__builtin_expect (ptr != NULL, 1))
11192 foo (*ptr);
11193 @end smallexample
11194
11195 @noindent
11196 when testing pointer or floating-point values.
11197 @end deftypefn
11198
11199 @deftypefn {Built-in Function} void __builtin_trap (void)
11200 This function causes the program to exit abnormally. GCC implements
11201 this function by using a target-dependent mechanism (such as
11202 intentionally executing an illegal instruction) or by calling
11203 @code{abort}. The mechanism used may vary from release to release so
11204 you should not rely on any particular implementation.
11205 @end deftypefn
11206
11207 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11208 If control flow reaches the point of the @code{__builtin_unreachable},
11209 the program is undefined. It is useful in situations where the
11210 compiler cannot deduce the unreachability of the code.
11211
11212 One such case is immediately following an @code{asm} statement that
11213 either never terminates, or one that transfers control elsewhere
11214 and never returns. In this example, without the
11215 @code{__builtin_unreachable}, GCC issues a warning that control
11216 reaches the end of a non-void function. It also generates code
11217 to return after the @code{asm}.
11218
11219 @smallexample
11220 int f (int c, int v)
11221 @{
11222 if (c)
11223 @{
11224 return v;
11225 @}
11226 else
11227 @{
11228 asm("jmp error_handler");
11229 __builtin_unreachable ();
11230 @}
11231 @}
11232 @end smallexample
11233
11234 @noindent
11235 Because the @code{asm} statement unconditionally transfers control out
11236 of the function, control never reaches the end of the function
11237 body. The @code{__builtin_unreachable} is in fact unreachable and
11238 communicates this fact to the compiler.
11239
11240 Another use for @code{__builtin_unreachable} is following a call a
11241 function that never returns but that is not declared
11242 @code{__attribute__((noreturn))}, as in this example:
11243
11244 @smallexample
11245 void function_that_never_returns (void);
11246
11247 int g (int c)
11248 @{
11249 if (c)
11250 @{
11251 return 1;
11252 @}
11253 else
11254 @{
11255 function_that_never_returns ();
11256 __builtin_unreachable ();
11257 @}
11258 @}
11259 @end smallexample
11260
11261 @end deftypefn
11262
11263 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11264 This function returns its first argument, and allows the compiler
11265 to assume that the returned pointer is at least @var{align} bytes
11266 aligned. This built-in can have either two or three arguments,
11267 if it has three, the third argument should have integer type, and
11268 if it is nonzero means misalignment offset. For example:
11269
11270 @smallexample
11271 void *x = __builtin_assume_aligned (arg, 16);
11272 @end smallexample
11273
11274 @noindent
11275 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11276 16-byte aligned, while:
11277
11278 @smallexample
11279 void *x = __builtin_assume_aligned (arg, 32, 8);
11280 @end smallexample
11281
11282 @noindent
11283 means that the compiler can assume for @code{x}, set to @code{arg}, that
11284 @code{(char *) x - 8} is 32-byte aligned.
11285 @end deftypefn
11286
11287 @deftypefn {Built-in Function} int __builtin_LINE ()
11288 This function is the equivalent of the preprocessor @code{__LINE__}
11289 macro and returns a constant integer expression that evaluates to
11290 the line number of the invocation of the built-in. When used as a C++
11291 default argument for a function @var{F}, it returns the line number
11292 of the call to @var{F}.
11293 @end deftypefn
11294
11295 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11296 This function is the equivalent of the @code{__FUNCTION__} symbol
11297 and returns an address constant pointing to the name of the function
11298 from which the built-in was invoked, or the empty string if
11299 the invocation is not at function scope. When used as a C++ default
11300 argument for a function @var{F}, it returns the name of @var{F}'s
11301 caller or the empty string if the call was not made at function
11302 scope.
11303 @end deftypefn
11304
11305 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11306 This function is the equivalent of the preprocessor @code{__FILE__}
11307 macro and returns an address constant pointing to the file name
11308 containing the invocation of the built-in, or the empty string if
11309 the invocation is not at function scope. When used as a C++ default
11310 argument for a function @var{F}, it returns the file name of the call
11311 to @var{F} or the empty string if the call was not made at function
11312 scope.
11313
11314 For example, in the following, each call to function @code{foo} will
11315 print a line similar to @code{"file.c:123: foo: message"} with the name
11316 of the file and the line number of the @code{printf} call, the name of
11317 the function @code{foo}, followed by the word @code{message}.
11318
11319 @smallexample
11320 const char*
11321 function (const char *func = __builtin_FUNCTION ())
11322 @{
11323 return func;
11324 @}
11325
11326 void foo (void)
11327 @{
11328 printf ("%s:%i: %s: message\n", file (), line (), function ());
11329 @}
11330 @end smallexample
11331
11332 @end deftypefn
11333
11334 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11335 This function is used to flush the processor's instruction cache for
11336 the region of memory between @var{begin} inclusive and @var{end}
11337 exclusive. Some targets require that the instruction cache be
11338 flushed, after modifying memory containing code, in order to obtain
11339 deterministic behavior.
11340
11341 If the target does not require instruction cache flushes,
11342 @code{__builtin___clear_cache} has no effect. Otherwise either
11343 instructions are emitted in-line to clear the instruction cache or a
11344 call to the @code{__clear_cache} function in libgcc is made.
11345 @end deftypefn
11346
11347 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11348 This function is used to minimize cache-miss latency by moving data into
11349 a cache before it is accessed.
11350 You can insert calls to @code{__builtin_prefetch} into code for which
11351 you know addresses of data in memory that is likely to be accessed soon.
11352 If the target supports them, data prefetch instructions are generated.
11353 If the prefetch is done early enough before the access then the data will
11354 be in the cache by the time it is accessed.
11355
11356 The value of @var{addr} is the address of the memory to prefetch.
11357 There are two optional arguments, @var{rw} and @var{locality}.
11358 The value of @var{rw} is a compile-time constant one or zero; one
11359 means that the prefetch is preparing for a write to the memory address
11360 and zero, the default, means that the prefetch is preparing for a read.
11361 The value @var{locality} must be a compile-time constant integer between
11362 zero and three. A value of zero means that the data has no temporal
11363 locality, so it need not be left in the cache after the access. A value
11364 of three means that the data has a high degree of temporal locality and
11365 should be left in all levels of cache possible. Values of one and two
11366 mean, respectively, a low or moderate degree of temporal locality. The
11367 default is three.
11368
11369 @smallexample
11370 for (i = 0; i < n; i++)
11371 @{
11372 a[i] = a[i] + b[i];
11373 __builtin_prefetch (&a[i+j], 1, 1);
11374 __builtin_prefetch (&b[i+j], 0, 1);
11375 /* @r{@dots{}} */
11376 @}
11377 @end smallexample
11378
11379 Data prefetch does not generate faults if @var{addr} is invalid, but
11380 the address expression itself must be valid. For example, a prefetch
11381 of @code{p->next} does not fault if @code{p->next} is not a valid
11382 address, but evaluation faults if @code{p} is not a valid address.
11383
11384 If the target does not support data prefetch, the address expression
11385 is evaluated if it includes side effects but no other code is generated
11386 and GCC does not issue a warning.
11387 @end deftypefn
11388
11389 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11390 Returns a positive infinity, if supported by the floating-point format,
11391 else @code{DBL_MAX}. This function is suitable for implementing the
11392 ISO C macro @code{HUGE_VAL}.
11393 @end deftypefn
11394
11395 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11396 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11397 @end deftypefn
11398
11399 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11400 Similar to @code{__builtin_huge_val}, except the return
11401 type is @code{long double}.
11402 @end deftypefn
11403
11404 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11405 Similar to @code{__builtin_huge_val}, except the return type is
11406 @code{_Float@var{n}}.
11407 @end deftypefn
11408
11409 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11410 Similar to @code{__builtin_huge_val}, except the return type is
11411 @code{_Float@var{n}x}.
11412 @end deftypefn
11413
11414 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11415 This built-in implements the C99 fpclassify functionality. The first
11416 five int arguments should be the target library's notion of the
11417 possible FP classes and are used for return values. They must be
11418 constant values and they must appear in this order: @code{FP_NAN},
11419 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11420 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11421 to classify. GCC treats the last argument as type-generic, which
11422 means it does not do default promotion from float to double.
11423 @end deftypefn
11424
11425 @deftypefn {Built-in Function} double __builtin_inf (void)
11426 Similar to @code{__builtin_huge_val}, except a warning is generated
11427 if the target floating-point format does not support infinities.
11428 @end deftypefn
11429
11430 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11431 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11432 @end deftypefn
11433
11434 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11435 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11436 @end deftypefn
11437
11438 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11439 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11440 @end deftypefn
11441
11442 @deftypefn {Built-in Function} float __builtin_inff (void)
11443 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11444 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11445 @end deftypefn
11446
11447 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11448 Similar to @code{__builtin_inf}, except the return
11449 type is @code{long double}.
11450 @end deftypefn
11451
11452 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11453 Similar to @code{__builtin_inf}, except the return
11454 type is @code{_Float@var{n}}.
11455 @end deftypefn
11456
11457 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11458 Similar to @code{__builtin_inf}, except the return
11459 type is @code{_Float@var{n}x}.
11460 @end deftypefn
11461
11462 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11463 Similar to @code{isinf}, except the return value is -1 for
11464 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11465 Note while the parameter list is an
11466 ellipsis, this function only accepts exactly one floating-point
11467 argument. GCC treats this parameter as type-generic, which means it
11468 does not do default promotion from float to double.
11469 @end deftypefn
11470
11471 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11472 This is an implementation of the ISO C99 function @code{nan}.
11473
11474 Since ISO C99 defines this function in terms of @code{strtod}, which we
11475 do not implement, a description of the parsing is in order. The string
11476 is parsed as by @code{strtol}; that is, the base is recognized by
11477 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11478 in the significand such that the least significant bit of the number
11479 is at the least significant bit of the significand. The number is
11480 truncated to fit the significand field provided. The significand is
11481 forced to be a quiet NaN@.
11482
11483 This function, if given a string literal all of which would have been
11484 consumed by @code{strtol}, is evaluated early enough that it is considered a
11485 compile-time constant.
11486 @end deftypefn
11487
11488 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11489 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11490 @end deftypefn
11491
11492 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11493 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11494 @end deftypefn
11495
11496 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11497 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11498 @end deftypefn
11499
11500 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11501 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11502 @end deftypefn
11503
11504 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11505 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11506 @end deftypefn
11507
11508 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11509 Similar to @code{__builtin_nan}, except the return type is
11510 @code{_Float@var{n}}.
11511 @end deftypefn
11512
11513 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11514 Similar to @code{__builtin_nan}, except the return type is
11515 @code{_Float@var{n}x}.
11516 @end deftypefn
11517
11518 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11519 Similar to @code{__builtin_nan}, except the significand is forced
11520 to be a signaling NaN@. The @code{nans} function is proposed by
11521 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11522 @end deftypefn
11523
11524 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11525 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11526 @end deftypefn
11527
11528 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11529 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11530 @end deftypefn
11531
11532 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11533 Similar to @code{__builtin_nans}, except the return type is
11534 @code{_Float@var{n}}.
11535 @end deftypefn
11536
11537 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11538 Similar to @code{__builtin_nans}, except the return type is
11539 @code{_Float@var{n}x}.
11540 @end deftypefn
11541
11542 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11543 Returns one plus the index of the least significant 1-bit of @var{x}, or
11544 if @var{x} is zero, returns zero.
11545 @end deftypefn
11546
11547 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11548 Returns the number of leading 0-bits in @var{x}, starting at the most
11549 significant bit position. If @var{x} is 0, the result is undefined.
11550 @end deftypefn
11551
11552 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11553 Returns the number of trailing 0-bits in @var{x}, starting at the least
11554 significant bit position. If @var{x} is 0, the result is undefined.
11555 @end deftypefn
11556
11557 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11558 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11559 number of bits following the most significant bit that are identical
11560 to it. There are no special cases for 0 or other values.
11561 @end deftypefn
11562
11563 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11564 Returns the number of 1-bits in @var{x}.
11565 @end deftypefn
11566
11567 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11568 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11569 modulo 2.
11570 @end deftypefn
11571
11572 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11573 Similar to @code{__builtin_ffs}, except the argument type is
11574 @code{long}.
11575 @end deftypefn
11576
11577 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11578 Similar to @code{__builtin_clz}, except the argument type is
11579 @code{unsigned long}.
11580 @end deftypefn
11581
11582 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11583 Similar to @code{__builtin_ctz}, except the argument type is
11584 @code{unsigned long}.
11585 @end deftypefn
11586
11587 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11588 Similar to @code{__builtin_clrsb}, except the argument type is
11589 @code{long}.
11590 @end deftypefn
11591
11592 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11593 Similar to @code{__builtin_popcount}, except the argument type is
11594 @code{unsigned long}.
11595 @end deftypefn
11596
11597 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11598 Similar to @code{__builtin_parity}, except the argument type is
11599 @code{unsigned long}.
11600 @end deftypefn
11601
11602 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11603 Similar to @code{__builtin_ffs}, except the argument type is
11604 @code{long long}.
11605 @end deftypefn
11606
11607 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11608 Similar to @code{__builtin_clz}, except the argument type is
11609 @code{unsigned long long}.
11610 @end deftypefn
11611
11612 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11613 Similar to @code{__builtin_ctz}, except the argument type is
11614 @code{unsigned long long}.
11615 @end deftypefn
11616
11617 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11618 Similar to @code{__builtin_clrsb}, except the argument type is
11619 @code{long long}.
11620 @end deftypefn
11621
11622 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11623 Similar to @code{__builtin_popcount}, except the argument type is
11624 @code{unsigned long long}.
11625 @end deftypefn
11626
11627 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11628 Similar to @code{__builtin_parity}, except the argument type is
11629 @code{unsigned long long}.
11630 @end deftypefn
11631
11632 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11633 Returns the first argument raised to the power of the second. Unlike the
11634 @code{pow} function no guarantees about precision and rounding are made.
11635 @end deftypefn
11636
11637 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11638 Similar to @code{__builtin_powi}, except the argument and return types
11639 are @code{float}.
11640 @end deftypefn
11641
11642 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11643 Similar to @code{__builtin_powi}, except the argument and return types
11644 are @code{long double}.
11645 @end deftypefn
11646
11647 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11648 Returns @var{x} with the order of the bytes reversed; for example,
11649 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11650 exactly 8 bits.
11651 @end deftypefn
11652
11653 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11654 Similar to @code{__builtin_bswap16}, except the argument and return types
11655 are 32 bit.
11656 @end deftypefn
11657
11658 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11659 Similar to @code{__builtin_bswap32}, except the argument and return types
11660 are 64 bit.
11661 @end deftypefn
11662
11663 @node Target Builtins
11664 @section Built-in Functions Specific to Particular Target Machines
11665
11666 On some target machines, GCC supports many built-in functions specific
11667 to those machines. Generally these generate calls to specific machine
11668 instructions, but allow the compiler to schedule those calls.
11669
11670 @menu
11671 * AArch64 Built-in Functions::
11672 * Alpha Built-in Functions::
11673 * Altera Nios II Built-in Functions::
11674 * ARC Built-in Functions::
11675 * ARC SIMD Built-in Functions::
11676 * ARM iWMMXt Built-in Functions::
11677 * ARM C Language Extensions (ACLE)::
11678 * ARM Floating Point Status and Control Intrinsics::
11679 * AVR Built-in Functions::
11680 * Blackfin Built-in Functions::
11681 * FR-V Built-in Functions::
11682 * MIPS DSP Built-in Functions::
11683 * MIPS Paired-Single Support::
11684 * MIPS Loongson Built-in Functions::
11685 * MIPS SIMD Architecture (MSA) Support::
11686 * Other MIPS Built-in Functions::
11687 * MSP430 Built-in Functions::
11688 * NDS32 Built-in Functions::
11689 * picoChip Built-in Functions::
11690 * PowerPC Built-in Functions::
11691 * PowerPC AltiVec/VSX Built-in Functions::
11692 * PowerPC Hardware Transactional Memory Built-in Functions::
11693 * RX Built-in Functions::
11694 * S/390 System z Built-in Functions::
11695 * SH Built-in Functions::
11696 * SPARC VIS Built-in Functions::
11697 * SPU Built-in Functions::
11698 * TI C6X Built-in Functions::
11699 * TILE-Gx Built-in Functions::
11700 * TILEPro Built-in Functions::
11701 * x86 Built-in Functions::
11702 * x86 transactional memory intrinsics::
11703 @end menu
11704
11705 @node AArch64 Built-in Functions
11706 @subsection AArch64 Built-in Functions
11707
11708 These built-in functions are available for the AArch64 family of
11709 processors.
11710 @smallexample
11711 unsigned int __builtin_aarch64_get_fpcr ()
11712 void __builtin_aarch64_set_fpcr (unsigned int)
11713 unsigned int __builtin_aarch64_get_fpsr ()
11714 void __builtin_aarch64_set_fpsr (unsigned int)
11715 @end smallexample
11716
11717 @node Alpha Built-in Functions
11718 @subsection Alpha Built-in Functions
11719
11720 These built-in functions are available for the Alpha family of
11721 processors, depending on the command-line switches used.
11722
11723 The following built-in functions are always available. They
11724 all generate the machine instruction that is part of the name.
11725
11726 @smallexample
11727 long __builtin_alpha_implver (void)
11728 long __builtin_alpha_rpcc (void)
11729 long __builtin_alpha_amask (long)
11730 long __builtin_alpha_cmpbge (long, long)
11731 long __builtin_alpha_extbl (long, long)
11732 long __builtin_alpha_extwl (long, long)
11733 long __builtin_alpha_extll (long, long)
11734 long __builtin_alpha_extql (long, long)
11735 long __builtin_alpha_extwh (long, long)
11736 long __builtin_alpha_extlh (long, long)
11737 long __builtin_alpha_extqh (long, long)
11738 long __builtin_alpha_insbl (long, long)
11739 long __builtin_alpha_inswl (long, long)
11740 long __builtin_alpha_insll (long, long)
11741 long __builtin_alpha_insql (long, long)
11742 long __builtin_alpha_inswh (long, long)
11743 long __builtin_alpha_inslh (long, long)
11744 long __builtin_alpha_insqh (long, long)
11745 long __builtin_alpha_mskbl (long, long)
11746 long __builtin_alpha_mskwl (long, long)
11747 long __builtin_alpha_mskll (long, long)
11748 long __builtin_alpha_mskql (long, long)
11749 long __builtin_alpha_mskwh (long, long)
11750 long __builtin_alpha_msklh (long, long)
11751 long __builtin_alpha_mskqh (long, long)
11752 long __builtin_alpha_umulh (long, long)
11753 long __builtin_alpha_zap (long, long)
11754 long __builtin_alpha_zapnot (long, long)
11755 @end smallexample
11756
11757 The following built-in functions are always with @option{-mmax}
11758 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11759 later. They all generate the machine instruction that is part
11760 of the name.
11761
11762 @smallexample
11763 long __builtin_alpha_pklb (long)
11764 long __builtin_alpha_pkwb (long)
11765 long __builtin_alpha_unpkbl (long)
11766 long __builtin_alpha_unpkbw (long)
11767 long __builtin_alpha_minub8 (long, long)
11768 long __builtin_alpha_minsb8 (long, long)
11769 long __builtin_alpha_minuw4 (long, long)
11770 long __builtin_alpha_minsw4 (long, long)
11771 long __builtin_alpha_maxub8 (long, long)
11772 long __builtin_alpha_maxsb8 (long, long)
11773 long __builtin_alpha_maxuw4 (long, long)
11774 long __builtin_alpha_maxsw4 (long, long)
11775 long __builtin_alpha_perr (long, long)
11776 @end smallexample
11777
11778 The following built-in functions are always with @option{-mcix}
11779 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11780 later. They all generate the machine instruction that is part
11781 of the name.
11782
11783 @smallexample
11784 long __builtin_alpha_cttz (long)
11785 long __builtin_alpha_ctlz (long)
11786 long __builtin_alpha_ctpop (long)
11787 @end smallexample
11788
11789 The following built-in functions are available on systems that use the OSF/1
11790 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11791 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11792 @code{rdval} and @code{wrval}.
11793
11794 @smallexample
11795 void *__builtin_thread_pointer (void)
11796 void __builtin_set_thread_pointer (void *)
11797 @end smallexample
11798
11799 @node Altera Nios II Built-in Functions
11800 @subsection Altera Nios II Built-in Functions
11801
11802 These built-in functions are available for the Altera Nios II
11803 family of processors.
11804
11805 The following built-in functions are always available. They
11806 all generate the machine instruction that is part of the name.
11807
11808 @example
11809 int __builtin_ldbio (volatile const void *)
11810 int __builtin_ldbuio (volatile const void *)
11811 int __builtin_ldhio (volatile const void *)
11812 int __builtin_ldhuio (volatile const void *)
11813 int __builtin_ldwio (volatile const void *)
11814 void __builtin_stbio (volatile void *, int)
11815 void __builtin_sthio (volatile void *, int)
11816 void __builtin_stwio (volatile void *, int)
11817 void __builtin_sync (void)
11818 int __builtin_rdctl (int)
11819 int __builtin_rdprs (int, int)
11820 void __builtin_wrctl (int, int)
11821 void __builtin_flushd (volatile void *)
11822 void __builtin_flushda (volatile void *)
11823 int __builtin_wrpie (int);
11824 void __builtin_eni (int);
11825 int __builtin_ldex (volatile const void *)
11826 int __builtin_stex (volatile void *, int)
11827 int __builtin_ldsex (volatile const void *)
11828 int __builtin_stsex (volatile void *, int)
11829 @end example
11830
11831 The following built-in functions are always available. They
11832 all generate a Nios II Custom Instruction. The name of the
11833 function represents the types that the function takes and
11834 returns. The letter before the @code{n} is the return type
11835 or void if absent. The @code{n} represents the first parameter
11836 to all the custom instructions, the custom instruction number.
11837 The two letters after the @code{n} represent the up to two
11838 parameters to the function.
11839
11840 The letters represent the following data types:
11841 @table @code
11842 @item <no letter>
11843 @code{void} for return type and no parameter for parameter types.
11844
11845 @item i
11846 @code{int} for return type and parameter type
11847
11848 @item f
11849 @code{float} for return type and parameter type
11850
11851 @item p
11852 @code{void *} for return type and parameter type
11853
11854 @end table
11855
11856 And the function names are:
11857 @example
11858 void __builtin_custom_n (void)
11859 void __builtin_custom_ni (int)
11860 void __builtin_custom_nf (float)
11861 void __builtin_custom_np (void *)
11862 void __builtin_custom_nii (int, int)
11863 void __builtin_custom_nif (int, float)
11864 void __builtin_custom_nip (int, void *)
11865 void __builtin_custom_nfi (float, int)
11866 void __builtin_custom_nff (float, float)
11867 void __builtin_custom_nfp (float, void *)
11868 void __builtin_custom_npi (void *, int)
11869 void __builtin_custom_npf (void *, float)
11870 void __builtin_custom_npp (void *, void *)
11871 int __builtin_custom_in (void)
11872 int __builtin_custom_ini (int)
11873 int __builtin_custom_inf (float)
11874 int __builtin_custom_inp (void *)
11875 int __builtin_custom_inii (int, int)
11876 int __builtin_custom_inif (int, float)
11877 int __builtin_custom_inip (int, void *)
11878 int __builtin_custom_infi (float, int)
11879 int __builtin_custom_inff (float, float)
11880 int __builtin_custom_infp (float, void *)
11881 int __builtin_custom_inpi (void *, int)
11882 int __builtin_custom_inpf (void *, float)
11883 int __builtin_custom_inpp (void *, void *)
11884 float __builtin_custom_fn (void)
11885 float __builtin_custom_fni (int)
11886 float __builtin_custom_fnf (float)
11887 float __builtin_custom_fnp (void *)
11888 float __builtin_custom_fnii (int, int)
11889 float __builtin_custom_fnif (int, float)
11890 float __builtin_custom_fnip (int, void *)
11891 float __builtin_custom_fnfi (float, int)
11892 float __builtin_custom_fnff (float, float)
11893 float __builtin_custom_fnfp (float, void *)
11894 float __builtin_custom_fnpi (void *, int)
11895 float __builtin_custom_fnpf (void *, float)
11896 float __builtin_custom_fnpp (void *, void *)
11897 void * __builtin_custom_pn (void)
11898 void * __builtin_custom_pni (int)
11899 void * __builtin_custom_pnf (float)
11900 void * __builtin_custom_pnp (void *)
11901 void * __builtin_custom_pnii (int, int)
11902 void * __builtin_custom_pnif (int, float)
11903 void * __builtin_custom_pnip (int, void *)
11904 void * __builtin_custom_pnfi (float, int)
11905 void * __builtin_custom_pnff (float, float)
11906 void * __builtin_custom_pnfp (float, void *)
11907 void * __builtin_custom_pnpi (void *, int)
11908 void * __builtin_custom_pnpf (void *, float)
11909 void * __builtin_custom_pnpp (void *, void *)
11910 @end example
11911
11912 @node ARC Built-in Functions
11913 @subsection ARC Built-in Functions
11914
11915 The following built-in functions are provided for ARC targets. The
11916 built-ins generate the corresponding assembly instructions. In the
11917 examples given below, the generated code often requires an operand or
11918 result to be in a register. Where necessary further code will be
11919 generated to ensure this is true, but for brevity this is not
11920 described in each case.
11921
11922 @emph{Note:} Using a built-in to generate an instruction not supported
11923 by a target may cause problems. At present the compiler is not
11924 guaranteed to detect such misuse, and as a result an internal compiler
11925 error may be generated.
11926
11927 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11928 Return 1 if @var{val} is known to have the byte alignment given
11929 by @var{alignval}, otherwise return 0.
11930 Note that this is different from
11931 @smallexample
11932 __alignof__(*(char *)@var{val}) >= alignval
11933 @end smallexample
11934 because __alignof__ sees only the type of the dereference, whereas
11935 __builtin_arc_align uses alignment information from the pointer
11936 as well as from the pointed-to type.
11937 The information available will depend on optimization level.
11938 @end deftypefn
11939
11940 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11941 Generates
11942 @example
11943 brk
11944 @end example
11945 @end deftypefn
11946
11947 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11948 The operand is the number of a register to be read. Generates:
11949 @example
11950 mov @var{dest}, r@var{regno}
11951 @end example
11952 where the value in @var{dest} will be the result returned from the
11953 built-in.
11954 @end deftypefn
11955
11956 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11957 The first operand is the number of a register to be written, the
11958 second operand is a compile time constant to write into that
11959 register. Generates:
11960 @example
11961 mov r@var{regno}, @var{val}
11962 @end example
11963 @end deftypefn
11964
11965 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11966 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11967 Generates:
11968 @example
11969 divaw @var{dest}, @var{a}, @var{b}
11970 @end example
11971 where the value in @var{dest} will be the result returned from the
11972 built-in.
11973 @end deftypefn
11974
11975 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11976 Generates
11977 @example
11978 flag @var{a}
11979 @end example
11980 @end deftypefn
11981
11982 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11983 The operand, @var{auxv}, is the address of an auxiliary register and
11984 must be a compile time constant. Generates:
11985 @example
11986 lr @var{dest}, [@var{auxr}]
11987 @end example
11988 Where the value in @var{dest} will be the result returned from the
11989 built-in.
11990 @end deftypefn
11991
11992 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11993 Only available with @option{-mmul64}. Generates:
11994 @example
11995 mul64 @var{a}, @var{b}
11996 @end example
11997 @end deftypefn
11998
11999 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12000 Only available with @option{-mmul64}. Generates:
12001 @example
12002 mulu64 @var{a}, @var{b}
12003 @end example
12004 @end deftypefn
12005
12006 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12007 Generates:
12008 @example
12009 nop
12010 @end example
12011 @end deftypefn
12012
12013 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12014 Only valid if the @samp{norm} instruction is available through the
12015 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12016 Generates:
12017 @example
12018 norm @var{dest}, @var{src}
12019 @end example
12020 Where the value in @var{dest} will be the result returned from the
12021 built-in.
12022 @end deftypefn
12023
12024 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12025 Only valid if the @samp{normw} instruction is available through the
12026 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12027 Generates:
12028 @example
12029 normw @var{dest}, @var{src}
12030 @end example
12031 Where the value in @var{dest} will be the result returned from the
12032 built-in.
12033 @end deftypefn
12034
12035 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12036 Generates:
12037 @example
12038 rtie
12039 @end example
12040 @end deftypefn
12041
12042 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12043 Generates:
12044 @example
12045 sleep @var{a}
12046 @end example
12047 @end deftypefn
12048
12049 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12050 The first argument, @var{auxv}, is the address of an auxiliary
12051 register, the second argument, @var{val}, is a compile time constant
12052 to be written to the register. Generates:
12053 @example
12054 sr @var{auxr}, [@var{val}]
12055 @end example
12056 @end deftypefn
12057
12058 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12059 Only valid with @option{-mswap}. Generates:
12060 @example
12061 swap @var{dest}, @var{src}
12062 @end example
12063 Where the value in @var{dest} will be the result returned from the
12064 built-in.
12065 @end deftypefn
12066
12067 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12068 Generates:
12069 @example
12070 swi
12071 @end example
12072 @end deftypefn
12073
12074 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12075 Only available with @option{-mcpu=ARC700}. Generates:
12076 @example
12077 sync
12078 @end example
12079 @end deftypefn
12080
12081 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12082 Only available with @option{-mcpu=ARC700}. Generates:
12083 @example
12084 trap_s @var{c}
12085 @end example
12086 @end deftypefn
12087
12088 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12089 Only available with @option{-mcpu=ARC700}. Generates:
12090 @example
12091 unimp_s
12092 @end example
12093 @end deftypefn
12094
12095 The instructions generated by the following builtins are not
12096 considered as candidates for scheduling. They are not moved around by
12097 the compiler during scheduling, and thus can be expected to appear
12098 where they are put in the C code:
12099 @example
12100 __builtin_arc_brk()
12101 __builtin_arc_core_read()
12102 __builtin_arc_core_write()
12103 __builtin_arc_flag()
12104 __builtin_arc_lr()
12105 __builtin_arc_sleep()
12106 __builtin_arc_sr()
12107 __builtin_arc_swi()
12108 @end example
12109
12110 @node ARC SIMD Built-in Functions
12111 @subsection ARC SIMD Built-in Functions
12112
12113 SIMD builtins provided by the compiler can be used to generate the
12114 vector instructions. This section describes the available builtins
12115 and their usage in programs. With the @option{-msimd} option, the
12116 compiler provides 128-bit vector types, which can be specified using
12117 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12118 can be included to use the following predefined types:
12119 @example
12120 typedef int __v4si __attribute__((vector_size(16)));
12121 typedef short __v8hi __attribute__((vector_size(16)));
12122 @end example
12123
12124 These types can be used to define 128-bit variables. The built-in
12125 functions listed in the following section can be used on these
12126 variables to generate the vector operations.
12127
12128 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12129 @file{arc-simd.h} also provides equivalent macros called
12130 @code{_@var{someinsn}} that can be used for programming ease and
12131 improved readability. The following macros for DMA control are also
12132 provided:
12133 @example
12134 #define _setup_dma_in_channel_reg _vdiwr
12135 #define _setup_dma_out_channel_reg _vdowr
12136 @end example
12137
12138 The following is a complete list of all the SIMD built-ins provided
12139 for ARC, grouped by calling signature.
12140
12141 The following take two @code{__v8hi} arguments and return a
12142 @code{__v8hi} result:
12143 @example
12144 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12145 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12146 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12147 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12148 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12149 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12150 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12151 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12152 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12153 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12154 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12155 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12156 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12157 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12158 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12159 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12160 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12161 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12162 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12163 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12164 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12165 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12166 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12167 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12168 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12169 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12170 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12171 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12172 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12173 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12174 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12175 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12176 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12177 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12178 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12179 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12180 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12181 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12182 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12183 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12184 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12185 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12186 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12187 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12188 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12189 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12190 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12191 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12192 @end example
12193
12194 The following take one @code{__v8hi} and one @code{int} argument and return a
12195 @code{__v8hi} result:
12196
12197 @example
12198 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12199 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12200 __v8hi __builtin_arc_vbminw (__v8hi, int)
12201 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12202 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12203 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12204 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12205 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12206 @end example
12207
12208 The following take one @code{__v8hi} argument and one @code{int} argument which
12209 must be a 3-bit compile time constant indicating a register number
12210 I0-I7. They return a @code{__v8hi} result.
12211 @example
12212 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12213 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12214 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12215 @end example
12216
12217 The following take one @code{__v8hi} argument and one @code{int}
12218 argument which must be a 6-bit compile time constant. They return a
12219 @code{__v8hi} result.
12220 @example
12221 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12222 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12223 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12224 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12225 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12226 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12227 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12228 @end example
12229
12230 The following take one @code{__v8hi} argument and one @code{int} argument which
12231 must be a 8-bit compile time constant. They return a @code{__v8hi}
12232 result.
12233 @example
12234 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12235 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12236 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12237 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12238 @end example
12239
12240 The following take two @code{int} arguments, the second of which which
12241 must be a 8-bit compile time constant. They return a @code{__v8hi}
12242 result:
12243 @example
12244 __v8hi __builtin_arc_vmovaw (int, const int)
12245 __v8hi __builtin_arc_vmovw (int, const int)
12246 __v8hi __builtin_arc_vmovzw (int, const int)
12247 @end example
12248
12249 The following take a single @code{__v8hi} argument and return a
12250 @code{__v8hi} result:
12251 @example
12252 __v8hi __builtin_arc_vabsaw (__v8hi)
12253 __v8hi __builtin_arc_vabsw (__v8hi)
12254 __v8hi __builtin_arc_vaddsuw (__v8hi)
12255 __v8hi __builtin_arc_vexch1 (__v8hi)
12256 __v8hi __builtin_arc_vexch2 (__v8hi)
12257 __v8hi __builtin_arc_vexch4 (__v8hi)
12258 __v8hi __builtin_arc_vsignw (__v8hi)
12259 __v8hi __builtin_arc_vupbaw (__v8hi)
12260 __v8hi __builtin_arc_vupbw (__v8hi)
12261 __v8hi __builtin_arc_vupsbaw (__v8hi)
12262 __v8hi __builtin_arc_vupsbw (__v8hi)
12263 @end example
12264
12265 The following take two @code{int} arguments and return no result:
12266 @example
12267 void __builtin_arc_vdirun (int, int)
12268 void __builtin_arc_vdorun (int, int)
12269 @end example
12270
12271 The following take two @code{int} arguments and return no result. The
12272 first argument must a 3-bit compile time constant indicating one of
12273 the DR0-DR7 DMA setup channels:
12274 @example
12275 void __builtin_arc_vdiwr (const int, int)
12276 void __builtin_arc_vdowr (const int, int)
12277 @end example
12278
12279 The following take an @code{int} argument and return no result:
12280 @example
12281 void __builtin_arc_vendrec (int)
12282 void __builtin_arc_vrec (int)
12283 void __builtin_arc_vrecrun (int)
12284 void __builtin_arc_vrun (int)
12285 @end example
12286
12287 The following take a @code{__v8hi} argument and two @code{int}
12288 arguments and return a @code{__v8hi} result. The second argument must
12289 be a 3-bit compile time constants, indicating one the registers I0-I7,
12290 and the third argument must be an 8-bit compile time constant.
12291
12292 @emph{Note:} Although the equivalent hardware instructions do not take
12293 an SIMD register as an operand, these builtins overwrite the relevant
12294 bits of the @code{__v8hi} register provided as the first argument with
12295 the value loaded from the @code{[Ib, u8]} location in the SDM.
12296
12297 @example
12298 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12299 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12300 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12301 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12302 @end example
12303
12304 The following take two @code{int} arguments and return a @code{__v8hi}
12305 result. The first argument must be a 3-bit compile time constants,
12306 indicating one the registers I0-I7, and the second argument must be an
12307 8-bit compile time constant.
12308
12309 @example
12310 __v8hi __builtin_arc_vld128 (const int, const int)
12311 __v8hi __builtin_arc_vld64w (const int, const int)
12312 @end example
12313
12314 The following take a @code{__v8hi} argument and two @code{int}
12315 arguments and return no result. The second argument must be a 3-bit
12316 compile time constants, indicating one the registers I0-I7, and the
12317 third argument must be an 8-bit compile time constant.
12318
12319 @example
12320 void __builtin_arc_vst128 (__v8hi, const int, const int)
12321 void __builtin_arc_vst64 (__v8hi, const int, const int)
12322 @end example
12323
12324 The following take a @code{__v8hi} argument and three @code{int}
12325 arguments and return no result. The second argument must be a 3-bit
12326 compile-time constant, identifying the 16-bit sub-register to be
12327 stored, the third argument must be a 3-bit compile time constants,
12328 indicating one the registers I0-I7, and the fourth argument must be an
12329 8-bit compile time constant.
12330
12331 @example
12332 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12333 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12334 @end example
12335
12336 @node ARM iWMMXt Built-in Functions
12337 @subsection ARM iWMMXt Built-in Functions
12338
12339 These built-in functions are available for the ARM family of
12340 processors when the @option{-mcpu=iwmmxt} switch is used:
12341
12342 @smallexample
12343 typedef int v2si __attribute__ ((vector_size (8)));
12344 typedef short v4hi __attribute__ ((vector_size (8)));
12345 typedef char v8qi __attribute__ ((vector_size (8)));
12346
12347 int __builtin_arm_getwcgr0 (void)
12348 void __builtin_arm_setwcgr0 (int)
12349 int __builtin_arm_getwcgr1 (void)
12350 void __builtin_arm_setwcgr1 (int)
12351 int __builtin_arm_getwcgr2 (void)
12352 void __builtin_arm_setwcgr2 (int)
12353 int __builtin_arm_getwcgr3 (void)
12354 void __builtin_arm_setwcgr3 (int)
12355 int __builtin_arm_textrmsb (v8qi, int)
12356 int __builtin_arm_textrmsh (v4hi, int)
12357 int __builtin_arm_textrmsw (v2si, int)
12358 int __builtin_arm_textrmub (v8qi, int)
12359 int __builtin_arm_textrmuh (v4hi, int)
12360 int __builtin_arm_textrmuw (v2si, int)
12361 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12362 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12363 v2si __builtin_arm_tinsrw (v2si, int, int)
12364 long long __builtin_arm_tmia (long long, int, int)
12365 long long __builtin_arm_tmiabb (long long, int, int)
12366 long long __builtin_arm_tmiabt (long long, int, int)
12367 long long __builtin_arm_tmiaph (long long, int, int)
12368 long long __builtin_arm_tmiatb (long long, int, int)
12369 long long __builtin_arm_tmiatt (long long, int, int)
12370 int __builtin_arm_tmovmskb (v8qi)
12371 int __builtin_arm_tmovmskh (v4hi)
12372 int __builtin_arm_tmovmskw (v2si)
12373 long long __builtin_arm_waccb (v8qi)
12374 long long __builtin_arm_wacch (v4hi)
12375 long long __builtin_arm_waccw (v2si)
12376 v8qi __builtin_arm_waddb (v8qi, v8qi)
12377 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12378 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12379 v4hi __builtin_arm_waddh (v4hi, v4hi)
12380 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12381 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12382 v2si __builtin_arm_waddw (v2si, v2si)
12383 v2si __builtin_arm_waddwss (v2si, v2si)
12384 v2si __builtin_arm_waddwus (v2si, v2si)
12385 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12386 long long __builtin_arm_wand(long long, long long)
12387 long long __builtin_arm_wandn (long long, long long)
12388 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12389 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12390 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12391 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12392 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12393 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12394 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12395 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12396 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12397 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12398 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12399 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12400 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12401 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12402 long long __builtin_arm_wmacsz (v4hi, v4hi)
12403 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12404 long long __builtin_arm_wmacuz (v4hi, v4hi)
12405 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12406 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12407 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12408 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12409 v2si __builtin_arm_wmaxsw (v2si, v2si)
12410 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12411 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12412 v2si __builtin_arm_wmaxuw (v2si, v2si)
12413 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12414 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12415 v2si __builtin_arm_wminsw (v2si, v2si)
12416 v8qi __builtin_arm_wminub (v8qi, v8qi)
12417 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12418 v2si __builtin_arm_wminuw (v2si, v2si)
12419 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12420 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12421 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12422 long long __builtin_arm_wor (long long, long long)
12423 v2si __builtin_arm_wpackdss (long long, long long)
12424 v2si __builtin_arm_wpackdus (long long, long long)
12425 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12426 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12427 v4hi __builtin_arm_wpackwss (v2si, v2si)
12428 v4hi __builtin_arm_wpackwus (v2si, v2si)
12429 long long __builtin_arm_wrord (long long, long long)
12430 long long __builtin_arm_wrordi (long long, int)
12431 v4hi __builtin_arm_wrorh (v4hi, long long)
12432 v4hi __builtin_arm_wrorhi (v4hi, int)
12433 v2si __builtin_arm_wrorw (v2si, long long)
12434 v2si __builtin_arm_wrorwi (v2si, int)
12435 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12436 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12437 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12438 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12439 v4hi __builtin_arm_wshufh (v4hi, int)
12440 long long __builtin_arm_wslld (long long, long long)
12441 long long __builtin_arm_wslldi (long long, int)
12442 v4hi __builtin_arm_wsllh (v4hi, long long)
12443 v4hi __builtin_arm_wsllhi (v4hi, int)
12444 v2si __builtin_arm_wsllw (v2si, long long)
12445 v2si __builtin_arm_wsllwi (v2si, int)
12446 long long __builtin_arm_wsrad (long long, long long)
12447 long long __builtin_arm_wsradi (long long, int)
12448 v4hi __builtin_arm_wsrah (v4hi, long long)
12449 v4hi __builtin_arm_wsrahi (v4hi, int)
12450 v2si __builtin_arm_wsraw (v2si, long long)
12451 v2si __builtin_arm_wsrawi (v2si, int)
12452 long long __builtin_arm_wsrld (long long, long long)
12453 long long __builtin_arm_wsrldi (long long, int)
12454 v4hi __builtin_arm_wsrlh (v4hi, long long)
12455 v4hi __builtin_arm_wsrlhi (v4hi, int)
12456 v2si __builtin_arm_wsrlw (v2si, long long)
12457 v2si __builtin_arm_wsrlwi (v2si, int)
12458 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12459 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12460 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12461 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12462 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12463 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12464 v2si __builtin_arm_wsubw (v2si, v2si)
12465 v2si __builtin_arm_wsubwss (v2si, v2si)
12466 v2si __builtin_arm_wsubwus (v2si, v2si)
12467 v4hi __builtin_arm_wunpckehsb (v8qi)
12468 v2si __builtin_arm_wunpckehsh (v4hi)
12469 long long __builtin_arm_wunpckehsw (v2si)
12470 v4hi __builtin_arm_wunpckehub (v8qi)
12471 v2si __builtin_arm_wunpckehuh (v4hi)
12472 long long __builtin_arm_wunpckehuw (v2si)
12473 v4hi __builtin_arm_wunpckelsb (v8qi)
12474 v2si __builtin_arm_wunpckelsh (v4hi)
12475 long long __builtin_arm_wunpckelsw (v2si)
12476 v4hi __builtin_arm_wunpckelub (v8qi)
12477 v2si __builtin_arm_wunpckeluh (v4hi)
12478 long long __builtin_arm_wunpckeluw (v2si)
12479 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12480 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12481 v2si __builtin_arm_wunpckihw (v2si, v2si)
12482 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12483 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12484 v2si __builtin_arm_wunpckilw (v2si, v2si)
12485 long long __builtin_arm_wxor (long long, long long)
12486 long long __builtin_arm_wzero ()
12487 @end smallexample
12488
12489
12490 @node ARM C Language Extensions (ACLE)
12491 @subsection ARM C Language Extensions (ACLE)
12492
12493 GCC implements extensions for C as described in the ARM C Language
12494 Extensions (ACLE) specification, which can be found at
12495 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12496
12497 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12498 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12499 intrinsics can be found at
12500 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12501 The built-in intrinsics for the Advanced SIMD extension are available when
12502 NEON is enabled.
12503
12504 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12505 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12506 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12507 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12508 intrinsics yet.
12509
12510 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12511 availability of extensions.
12512
12513 @node ARM Floating Point Status and Control Intrinsics
12514 @subsection ARM Floating Point Status and Control Intrinsics
12515
12516 These built-in functions are available for the ARM family of
12517 processors with floating-point unit.
12518
12519 @smallexample
12520 unsigned int __builtin_arm_get_fpscr ()
12521 void __builtin_arm_set_fpscr (unsigned int)
12522 @end smallexample
12523
12524 @node AVR Built-in Functions
12525 @subsection AVR Built-in Functions
12526
12527 For each built-in function for AVR, there is an equally named,
12528 uppercase built-in macro defined. That way users can easily query if
12529 or if not a specific built-in is implemented or not. For example, if
12530 @code{__builtin_avr_nop} is available the macro
12531 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12532
12533 The following built-in functions map to the respective machine
12534 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12535 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12536 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12537 as library call if no hardware multiplier is available.
12538
12539 @smallexample
12540 void __builtin_avr_nop (void)
12541 void __builtin_avr_sei (void)
12542 void __builtin_avr_cli (void)
12543 void __builtin_avr_sleep (void)
12544 void __builtin_avr_wdr (void)
12545 unsigned char __builtin_avr_swap (unsigned char)
12546 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12547 int __builtin_avr_fmuls (char, char)
12548 int __builtin_avr_fmulsu (char, unsigned char)
12549 @end smallexample
12550
12551 In order to delay execution for a specific number of cycles, GCC
12552 implements
12553 @smallexample
12554 void __builtin_avr_delay_cycles (unsigned long ticks)
12555 @end smallexample
12556
12557 @noindent
12558 @code{ticks} is the number of ticks to delay execution. Note that this
12559 built-in does not take into account the effect of interrupts that
12560 might increase delay time. @code{ticks} must be a compile-time
12561 integer constant; delays with a variable number of cycles are not supported.
12562
12563 @smallexample
12564 char __builtin_avr_flash_segment (const __memx void*)
12565 @end smallexample
12566
12567 @noindent
12568 This built-in takes a byte address to the 24-bit
12569 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12570 the number of the flash segment (the 64 KiB chunk) where the address
12571 points to. Counting starts at @code{0}.
12572 If the address does not point to flash memory, return @code{-1}.
12573
12574 @smallexample
12575 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12576 @end smallexample
12577
12578 @noindent
12579 Insert bits from @var{bits} into @var{val} and return the resulting
12580 value. The nibbles of @var{map} determine how the insertion is
12581 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12582 @enumerate
12583 @item If @var{X} is @code{0xf},
12584 then the @var{n}-th bit of @var{val} is returned unaltered.
12585
12586 @item If X is in the range 0@dots{}7,
12587 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12588
12589 @item If X is in the range 8@dots{}@code{0xe},
12590 then the @var{n}-th result bit is undefined.
12591 @end enumerate
12592
12593 @noindent
12594 One typical use case for this built-in is adjusting input and
12595 output values to non-contiguous port layouts. Some examples:
12596
12597 @smallexample
12598 // same as val, bits is unused
12599 __builtin_avr_insert_bits (0xffffffff, bits, val)
12600 @end smallexample
12601
12602 @smallexample
12603 // same as bits, val is unused
12604 __builtin_avr_insert_bits (0x76543210, bits, val)
12605 @end smallexample
12606
12607 @smallexample
12608 // same as rotating bits by 4
12609 __builtin_avr_insert_bits (0x32107654, bits, 0)
12610 @end smallexample
12611
12612 @smallexample
12613 // high nibble of result is the high nibble of val
12614 // low nibble of result is the low nibble of bits
12615 __builtin_avr_insert_bits (0xffff3210, bits, val)
12616 @end smallexample
12617
12618 @smallexample
12619 // reverse the bit order of bits
12620 __builtin_avr_insert_bits (0x01234567, bits, 0)
12621 @end smallexample
12622
12623 @smallexample
12624 void __builtin_avr_nops (unsigned count)
12625 @end smallexample
12626
12627 @noindent
12628 Insert @code{count} @code{NOP} instructions.
12629 The number of instructions must be a compile-time integer constant.
12630
12631 @node Blackfin Built-in Functions
12632 @subsection Blackfin Built-in Functions
12633
12634 Currently, there are two Blackfin-specific built-in functions. These are
12635 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12636 using inline assembly; by using these built-in functions the compiler can
12637 automatically add workarounds for hardware errata involving these
12638 instructions. These functions are named as follows:
12639
12640 @smallexample
12641 void __builtin_bfin_csync (void)
12642 void __builtin_bfin_ssync (void)
12643 @end smallexample
12644
12645 @node FR-V Built-in Functions
12646 @subsection FR-V Built-in Functions
12647
12648 GCC provides many FR-V-specific built-in functions. In general,
12649 these functions are intended to be compatible with those described
12650 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12651 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12652 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12653 pointer rather than by value.
12654
12655 Most of the functions are named after specific FR-V instructions.
12656 Such functions are said to be ``directly mapped'' and are summarized
12657 here in tabular form.
12658
12659 @menu
12660 * Argument Types::
12661 * Directly-mapped Integer Functions::
12662 * Directly-mapped Media Functions::
12663 * Raw read/write Functions::
12664 * Other Built-in Functions::
12665 @end menu
12666
12667 @node Argument Types
12668 @subsubsection Argument Types
12669
12670 The arguments to the built-in functions can be divided into three groups:
12671 register numbers, compile-time constants and run-time values. In order
12672 to make this classification clear at a glance, the arguments and return
12673 values are given the following pseudo types:
12674
12675 @multitable @columnfractions .20 .30 .15 .35
12676 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12677 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12678 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12679 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12680 @item @code{uw2} @tab @code{unsigned long long} @tab No
12681 @tab an unsigned doubleword
12682 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12683 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12684 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12685 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12686 @end multitable
12687
12688 These pseudo types are not defined by GCC, they are simply a notational
12689 convenience used in this manual.
12690
12691 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12692 and @code{sw2} are evaluated at run time. They correspond to
12693 register operands in the underlying FR-V instructions.
12694
12695 @code{const} arguments represent immediate operands in the underlying
12696 FR-V instructions. They must be compile-time constants.
12697
12698 @code{acc} arguments are evaluated at compile time and specify the number
12699 of an accumulator register. For example, an @code{acc} argument of 2
12700 selects the ACC2 register.
12701
12702 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12703 number of an IACC register. See @pxref{Other Built-in Functions}
12704 for more details.
12705
12706 @node Directly-mapped Integer Functions
12707 @subsubsection Directly-Mapped Integer Functions
12708
12709 The functions listed below map directly to FR-V I-type instructions.
12710
12711 @multitable @columnfractions .45 .32 .23
12712 @item Function prototype @tab Example usage @tab Assembly output
12713 @item @code{sw1 __ADDSS (sw1, sw1)}
12714 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12715 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12716 @item @code{sw1 __SCAN (sw1, sw1)}
12717 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12718 @tab @code{SCAN @var{a},@var{b},@var{c}}
12719 @item @code{sw1 __SCUTSS (sw1)}
12720 @tab @code{@var{b} = __SCUTSS (@var{a})}
12721 @tab @code{SCUTSS @var{a},@var{b}}
12722 @item @code{sw1 __SLASS (sw1, sw1)}
12723 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12724 @tab @code{SLASS @var{a},@var{b},@var{c}}
12725 @item @code{void __SMASS (sw1, sw1)}
12726 @tab @code{__SMASS (@var{a}, @var{b})}
12727 @tab @code{SMASS @var{a},@var{b}}
12728 @item @code{void __SMSSS (sw1, sw1)}
12729 @tab @code{__SMSSS (@var{a}, @var{b})}
12730 @tab @code{SMSSS @var{a},@var{b}}
12731 @item @code{void __SMU (sw1, sw1)}
12732 @tab @code{__SMU (@var{a}, @var{b})}
12733 @tab @code{SMU @var{a},@var{b}}
12734 @item @code{sw2 __SMUL (sw1, sw1)}
12735 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12736 @tab @code{SMUL @var{a},@var{b},@var{c}}
12737 @item @code{sw1 __SUBSS (sw1, sw1)}
12738 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12739 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12740 @item @code{uw2 __UMUL (uw1, uw1)}
12741 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12742 @tab @code{UMUL @var{a},@var{b},@var{c}}
12743 @end multitable
12744
12745 @node Directly-mapped Media Functions
12746 @subsubsection Directly-Mapped Media Functions
12747
12748 The functions listed below map directly to FR-V M-type instructions.
12749
12750 @multitable @columnfractions .45 .32 .23
12751 @item Function prototype @tab Example usage @tab Assembly output
12752 @item @code{uw1 __MABSHS (sw1)}
12753 @tab @code{@var{b} = __MABSHS (@var{a})}
12754 @tab @code{MABSHS @var{a},@var{b}}
12755 @item @code{void __MADDACCS (acc, acc)}
12756 @tab @code{__MADDACCS (@var{b}, @var{a})}
12757 @tab @code{MADDACCS @var{a},@var{b}}
12758 @item @code{sw1 __MADDHSS (sw1, sw1)}
12759 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12760 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12761 @item @code{uw1 __MADDHUS (uw1, uw1)}
12762 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12763 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12764 @item @code{uw1 __MAND (uw1, uw1)}
12765 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12766 @tab @code{MAND @var{a},@var{b},@var{c}}
12767 @item @code{void __MASACCS (acc, acc)}
12768 @tab @code{__MASACCS (@var{b}, @var{a})}
12769 @tab @code{MASACCS @var{a},@var{b}}
12770 @item @code{uw1 __MAVEH (uw1, uw1)}
12771 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12772 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12773 @item @code{uw2 __MBTOH (uw1)}
12774 @tab @code{@var{b} = __MBTOH (@var{a})}
12775 @tab @code{MBTOH @var{a},@var{b}}
12776 @item @code{void __MBTOHE (uw1 *, uw1)}
12777 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12778 @tab @code{MBTOHE @var{a},@var{b}}
12779 @item @code{void __MCLRACC (acc)}
12780 @tab @code{__MCLRACC (@var{a})}
12781 @tab @code{MCLRACC @var{a}}
12782 @item @code{void __MCLRACCA (void)}
12783 @tab @code{__MCLRACCA ()}
12784 @tab @code{MCLRACCA}
12785 @item @code{uw1 __Mcop1 (uw1, uw1)}
12786 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12787 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12788 @item @code{uw1 __Mcop2 (uw1, uw1)}
12789 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12790 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12791 @item @code{uw1 __MCPLHI (uw2, const)}
12792 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12793 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12794 @item @code{uw1 __MCPLI (uw2, const)}
12795 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12796 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12797 @item @code{void __MCPXIS (acc, sw1, sw1)}
12798 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12799 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12800 @item @code{void __MCPXIU (acc, uw1, uw1)}
12801 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12802 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12803 @item @code{void __MCPXRS (acc, sw1, sw1)}
12804 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12805 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12806 @item @code{void __MCPXRU (acc, uw1, uw1)}
12807 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12808 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12809 @item @code{uw1 __MCUT (acc, uw1)}
12810 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12811 @tab @code{MCUT @var{a},@var{b},@var{c}}
12812 @item @code{uw1 __MCUTSS (acc, sw1)}
12813 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12814 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12815 @item @code{void __MDADDACCS (acc, acc)}
12816 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12817 @tab @code{MDADDACCS @var{a},@var{b}}
12818 @item @code{void __MDASACCS (acc, acc)}
12819 @tab @code{__MDASACCS (@var{b}, @var{a})}
12820 @tab @code{MDASACCS @var{a},@var{b}}
12821 @item @code{uw2 __MDCUTSSI (acc, const)}
12822 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12823 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12824 @item @code{uw2 __MDPACKH (uw2, uw2)}
12825 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12826 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12827 @item @code{uw2 __MDROTLI (uw2, const)}
12828 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12829 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12830 @item @code{void __MDSUBACCS (acc, acc)}
12831 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12832 @tab @code{MDSUBACCS @var{a},@var{b}}
12833 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12834 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12835 @tab @code{MDUNPACKH @var{a},@var{b}}
12836 @item @code{uw2 __MEXPDHD (uw1, const)}
12837 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12838 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12839 @item @code{uw1 __MEXPDHW (uw1, const)}
12840 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12841 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12842 @item @code{uw1 __MHDSETH (uw1, const)}
12843 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12844 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12845 @item @code{sw1 __MHDSETS (const)}
12846 @tab @code{@var{b} = __MHDSETS (@var{a})}
12847 @tab @code{MHDSETS #@var{a},@var{b}}
12848 @item @code{uw1 __MHSETHIH (uw1, const)}
12849 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12850 @tab @code{MHSETHIH #@var{a},@var{b}}
12851 @item @code{sw1 __MHSETHIS (sw1, const)}
12852 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12853 @tab @code{MHSETHIS #@var{a},@var{b}}
12854 @item @code{uw1 __MHSETLOH (uw1, const)}
12855 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12856 @tab @code{MHSETLOH #@var{a},@var{b}}
12857 @item @code{sw1 __MHSETLOS (sw1, const)}
12858 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12859 @tab @code{MHSETLOS #@var{a},@var{b}}
12860 @item @code{uw1 __MHTOB (uw2)}
12861 @tab @code{@var{b} = __MHTOB (@var{a})}
12862 @tab @code{MHTOB @var{a},@var{b}}
12863 @item @code{void __MMACHS (acc, sw1, sw1)}
12864 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12865 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12866 @item @code{void __MMACHU (acc, uw1, uw1)}
12867 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12868 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12869 @item @code{void __MMRDHS (acc, sw1, sw1)}
12870 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12871 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12872 @item @code{void __MMRDHU (acc, uw1, uw1)}
12873 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12874 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12875 @item @code{void __MMULHS (acc, sw1, sw1)}
12876 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12877 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12878 @item @code{void __MMULHU (acc, uw1, uw1)}
12879 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12880 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12881 @item @code{void __MMULXHS (acc, sw1, sw1)}
12882 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12883 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12884 @item @code{void __MMULXHU (acc, uw1, uw1)}
12885 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12886 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12887 @item @code{uw1 __MNOT (uw1)}
12888 @tab @code{@var{b} = __MNOT (@var{a})}
12889 @tab @code{MNOT @var{a},@var{b}}
12890 @item @code{uw1 __MOR (uw1, uw1)}
12891 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12892 @tab @code{MOR @var{a},@var{b},@var{c}}
12893 @item @code{uw1 __MPACKH (uh, uh)}
12894 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12895 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12896 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12897 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12898 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12899 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12900 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12901 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12902 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12903 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12904 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12905 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12906 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12907 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12908 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12909 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12910 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12911 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12912 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12913 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12914 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12915 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12916 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12917 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12918 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12919 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12920 @item @code{void __MQMACHS (acc, sw2, sw2)}
12921 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12922 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12923 @item @code{void __MQMACHU (acc, uw2, uw2)}
12924 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12925 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12926 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12927 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12928 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12929 @item @code{void __MQMULHS (acc, sw2, sw2)}
12930 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12931 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12932 @item @code{void __MQMULHU (acc, uw2, uw2)}
12933 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12934 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12935 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12936 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12937 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12938 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12939 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12940 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12941 @item @code{sw2 __MQSATHS (sw2, sw2)}
12942 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12943 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12944 @item @code{uw2 __MQSLLHI (uw2, int)}
12945 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12946 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12947 @item @code{sw2 __MQSRAHI (sw2, int)}
12948 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12949 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12950 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12951 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12952 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12953 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12954 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12955 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12956 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12957 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12958 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12959 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12960 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12961 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12962 @item @code{uw1 __MRDACC (acc)}
12963 @tab @code{@var{b} = __MRDACC (@var{a})}
12964 @tab @code{MRDACC @var{a},@var{b}}
12965 @item @code{uw1 __MRDACCG (acc)}
12966 @tab @code{@var{b} = __MRDACCG (@var{a})}
12967 @tab @code{MRDACCG @var{a},@var{b}}
12968 @item @code{uw1 __MROTLI (uw1, const)}
12969 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12970 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12971 @item @code{uw1 __MROTRI (uw1, const)}
12972 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12973 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12974 @item @code{sw1 __MSATHS (sw1, sw1)}
12975 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12976 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12977 @item @code{uw1 __MSATHU (uw1, uw1)}
12978 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12979 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12980 @item @code{uw1 __MSLLHI (uw1, const)}
12981 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12982 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12983 @item @code{sw1 __MSRAHI (sw1, const)}
12984 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12985 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12986 @item @code{uw1 __MSRLHI (uw1, const)}
12987 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12988 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12989 @item @code{void __MSUBACCS (acc, acc)}
12990 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12991 @tab @code{MSUBACCS @var{a},@var{b}}
12992 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12993 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12994 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12995 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12996 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12997 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12998 @item @code{void __MTRAP (void)}
12999 @tab @code{__MTRAP ()}
13000 @tab @code{MTRAP}
13001 @item @code{uw2 __MUNPACKH (uw1)}
13002 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13003 @tab @code{MUNPACKH @var{a},@var{b}}
13004 @item @code{uw1 __MWCUT (uw2, uw1)}
13005 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13006 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13007 @item @code{void __MWTACC (acc, uw1)}
13008 @tab @code{__MWTACC (@var{b}, @var{a})}
13009 @tab @code{MWTACC @var{a},@var{b}}
13010 @item @code{void __MWTACCG (acc, uw1)}
13011 @tab @code{__MWTACCG (@var{b}, @var{a})}
13012 @tab @code{MWTACCG @var{a},@var{b}}
13013 @item @code{uw1 __MXOR (uw1, uw1)}
13014 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13015 @tab @code{MXOR @var{a},@var{b},@var{c}}
13016 @end multitable
13017
13018 @node Raw read/write Functions
13019 @subsubsection Raw Read/Write Functions
13020
13021 This sections describes built-in functions related to read and write
13022 instructions to access memory. These functions generate
13023 @code{membar} instructions to flush the I/O load and stores where
13024 appropriate, as described in Fujitsu's manual described above.
13025
13026 @table @code
13027
13028 @item unsigned char __builtin_read8 (void *@var{data})
13029 @item unsigned short __builtin_read16 (void *@var{data})
13030 @item unsigned long __builtin_read32 (void *@var{data})
13031 @item unsigned long long __builtin_read64 (void *@var{data})
13032
13033 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13034 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13035 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13036 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13037 @end table
13038
13039 @node Other Built-in Functions
13040 @subsubsection Other Built-in Functions
13041
13042 This section describes built-in functions that are not named after
13043 a specific FR-V instruction.
13044
13045 @table @code
13046 @item sw2 __IACCreadll (iacc @var{reg})
13047 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13048 for future expansion and must be 0.
13049
13050 @item sw1 __IACCreadl (iacc @var{reg})
13051 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13052 Other values of @var{reg} are rejected as invalid.
13053
13054 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13055 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13056 is reserved for future expansion and must be 0.
13057
13058 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13059 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13060 is 1. Other values of @var{reg} are rejected as invalid.
13061
13062 @item void __data_prefetch0 (const void *@var{x})
13063 Use the @code{dcpl} instruction to load the contents of address @var{x}
13064 into the data cache.
13065
13066 @item void __data_prefetch (const void *@var{x})
13067 Use the @code{nldub} instruction to load the contents of address @var{x}
13068 into the data cache. The instruction is issued in slot I1@.
13069 @end table
13070
13071 @node MIPS DSP Built-in Functions
13072 @subsection MIPS DSP Built-in Functions
13073
13074 The MIPS DSP Application-Specific Extension (ASE) includes new
13075 instructions that are designed to improve the performance of DSP and
13076 media applications. It provides instructions that operate on packed
13077 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13078
13079 GCC supports MIPS DSP operations using both the generic
13080 vector extensions (@pxref{Vector Extensions}) and a collection of
13081 MIPS-specific built-in functions. Both kinds of support are
13082 enabled by the @option{-mdsp} command-line option.
13083
13084 Revision 2 of the ASE was introduced in the second half of 2006.
13085 This revision adds extra instructions to the original ASE, but is
13086 otherwise backwards-compatible with it. You can select revision 2
13087 using the command-line option @option{-mdspr2}; this option implies
13088 @option{-mdsp}.
13089
13090 The SCOUNT and POS bits of the DSP control register are global. The
13091 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13092 POS bits. During optimization, the compiler does not delete these
13093 instructions and it does not delete calls to functions containing
13094 these instructions.
13095
13096 At present, GCC only provides support for operations on 32-bit
13097 vectors. The vector type associated with 8-bit integer data is
13098 usually called @code{v4i8}, the vector type associated with Q7
13099 is usually called @code{v4q7}, the vector type associated with 16-bit
13100 integer data is usually called @code{v2i16}, and the vector type
13101 associated with Q15 is usually called @code{v2q15}. They can be
13102 defined in C as follows:
13103
13104 @smallexample
13105 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13106 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13107 typedef short v2i16 __attribute__ ((vector_size(4)));
13108 typedef short v2q15 __attribute__ ((vector_size(4)));
13109 @end smallexample
13110
13111 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13112 initialized in the same way as aggregates. For example:
13113
13114 @smallexample
13115 v4i8 a = @{1, 2, 3, 4@};
13116 v4i8 b;
13117 b = (v4i8) @{5, 6, 7, 8@};
13118
13119 v2q15 c = @{0x0fcb, 0x3a75@};
13120 v2q15 d;
13121 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13122 @end smallexample
13123
13124 @emph{Note:} The CPU's endianness determines the order in which values
13125 are packed. On little-endian targets, the first value is the least
13126 significant and the last value is the most significant. The opposite
13127 order applies to big-endian targets. For example, the code above
13128 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13129 and @code{4} on big-endian targets.
13130
13131 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13132 representation. As shown in this example, the integer representation
13133 of a Q7 value can be obtained by multiplying the fractional value by
13134 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13135 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13136 @code{0x1.0p31}.
13137
13138 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13139 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13140 and @code{c} and @code{d} are @code{v2q15} values.
13141
13142 @multitable @columnfractions .50 .50
13143 @item C code @tab MIPS instruction
13144 @item @code{a + b} @tab @code{addu.qb}
13145 @item @code{c + d} @tab @code{addq.ph}
13146 @item @code{a - b} @tab @code{subu.qb}
13147 @item @code{c - d} @tab @code{subq.ph}
13148 @end multitable
13149
13150 The table below lists the @code{v2i16} operation for which
13151 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13152 @code{v2i16} values.
13153
13154 @multitable @columnfractions .50 .50
13155 @item C code @tab MIPS instruction
13156 @item @code{e * f} @tab @code{mul.ph}
13157 @end multitable
13158
13159 It is easier to describe the DSP built-in functions if we first define
13160 the following types:
13161
13162 @smallexample
13163 typedef int q31;
13164 typedef int i32;
13165 typedef unsigned int ui32;
13166 typedef long long a64;
13167 @end smallexample
13168
13169 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13170 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13171 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13172 @code{long long}, but we use @code{a64} to indicate values that are
13173 placed in one of the four DSP accumulators (@code{$ac0},
13174 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13175
13176 Also, some built-in functions prefer or require immediate numbers as
13177 parameters, because the corresponding DSP instructions accept both immediate
13178 numbers and register operands, or accept immediate numbers only. The
13179 immediate parameters are listed as follows.
13180
13181 @smallexample
13182 imm0_3: 0 to 3.
13183 imm0_7: 0 to 7.
13184 imm0_15: 0 to 15.
13185 imm0_31: 0 to 31.
13186 imm0_63: 0 to 63.
13187 imm0_255: 0 to 255.
13188 imm_n32_31: -32 to 31.
13189 imm_n512_511: -512 to 511.
13190 @end smallexample
13191
13192 The following built-in functions map directly to a particular MIPS DSP
13193 instruction. Please refer to the architecture specification
13194 for details on what each instruction does.
13195
13196 @smallexample
13197 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13198 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13199 q31 __builtin_mips_addq_s_w (q31, q31)
13200 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13201 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13202 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13203 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13204 q31 __builtin_mips_subq_s_w (q31, q31)
13205 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13206 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13207 i32 __builtin_mips_addsc (i32, i32)
13208 i32 __builtin_mips_addwc (i32, i32)
13209 i32 __builtin_mips_modsub (i32, i32)
13210 i32 __builtin_mips_raddu_w_qb (v4i8)
13211 v2q15 __builtin_mips_absq_s_ph (v2q15)
13212 q31 __builtin_mips_absq_s_w (q31)
13213 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13214 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13215 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13216 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13217 q31 __builtin_mips_preceq_w_phl (v2q15)
13218 q31 __builtin_mips_preceq_w_phr (v2q15)
13219 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13220 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13221 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13222 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13223 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13224 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13225 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13226 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13227 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13228 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13229 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13230 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13231 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13232 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13233 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13234 q31 __builtin_mips_shll_s_w (q31, i32)
13235 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13236 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13237 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13238 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13239 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13240 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13241 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13242 q31 __builtin_mips_shra_r_w (q31, i32)
13243 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13244 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13245 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13246 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13247 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13248 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13249 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13250 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13251 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13252 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13253 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13254 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13255 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13256 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13257 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13258 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13259 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13260 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13261 i32 __builtin_mips_bitrev (i32)
13262 i32 __builtin_mips_insv (i32, i32)
13263 v4i8 __builtin_mips_repl_qb (imm0_255)
13264 v4i8 __builtin_mips_repl_qb (i32)
13265 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13266 v2q15 __builtin_mips_repl_ph (i32)
13267 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13268 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13269 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13270 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13271 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13272 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13273 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13274 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13275 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13276 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13277 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13278 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13279 i32 __builtin_mips_extr_w (a64, imm0_31)
13280 i32 __builtin_mips_extr_w (a64, i32)
13281 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13282 i32 __builtin_mips_extr_s_h (a64, i32)
13283 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13284 i32 __builtin_mips_extr_rs_w (a64, i32)
13285 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13286 i32 __builtin_mips_extr_r_w (a64, i32)
13287 i32 __builtin_mips_extp (a64, imm0_31)
13288 i32 __builtin_mips_extp (a64, i32)
13289 i32 __builtin_mips_extpdp (a64, imm0_31)
13290 i32 __builtin_mips_extpdp (a64, i32)
13291 a64 __builtin_mips_shilo (a64, imm_n32_31)
13292 a64 __builtin_mips_shilo (a64, i32)
13293 a64 __builtin_mips_mthlip (a64, i32)
13294 void __builtin_mips_wrdsp (i32, imm0_63)
13295 i32 __builtin_mips_rddsp (imm0_63)
13296 i32 __builtin_mips_lbux (void *, i32)
13297 i32 __builtin_mips_lhx (void *, i32)
13298 i32 __builtin_mips_lwx (void *, i32)
13299 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13300 i32 __builtin_mips_bposge32 (void)
13301 a64 __builtin_mips_madd (a64, i32, i32);
13302 a64 __builtin_mips_maddu (a64, ui32, ui32);
13303 a64 __builtin_mips_msub (a64, i32, i32);
13304 a64 __builtin_mips_msubu (a64, ui32, ui32);
13305 a64 __builtin_mips_mult (i32, i32);
13306 a64 __builtin_mips_multu (ui32, ui32);
13307 @end smallexample
13308
13309 The following built-in functions map directly to a particular MIPS DSP REV 2
13310 instruction. Please refer to the architecture specification
13311 for details on what each instruction does.
13312
13313 @smallexample
13314 v4q7 __builtin_mips_absq_s_qb (v4q7);
13315 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13316 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13317 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13318 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13319 i32 __builtin_mips_append (i32, i32, imm0_31);
13320 i32 __builtin_mips_balign (i32, i32, imm0_3);
13321 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13322 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13323 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13324 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13325 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13326 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13327 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13328 q31 __builtin_mips_mulq_rs_w (q31, q31);
13329 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13330 q31 __builtin_mips_mulq_s_w (q31, q31);
13331 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13332 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13333 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13334 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13335 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13336 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13337 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13338 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13339 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13340 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13341 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13342 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13343 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13344 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13345 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13346 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13347 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13348 q31 __builtin_mips_addqh_w (q31, q31);
13349 q31 __builtin_mips_addqh_r_w (q31, q31);
13350 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13351 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13352 q31 __builtin_mips_subqh_w (q31, q31);
13353 q31 __builtin_mips_subqh_r_w (q31, q31);
13354 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13355 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13356 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13357 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13358 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13359 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13360 @end smallexample
13361
13362
13363 @node MIPS Paired-Single Support
13364 @subsection MIPS Paired-Single Support
13365
13366 The MIPS64 architecture includes a number of instructions that
13367 operate on pairs of single-precision floating-point values.
13368 Each pair is packed into a 64-bit floating-point register,
13369 with one element being designated the ``upper half'' and
13370 the other being designated the ``lower half''.
13371
13372 GCC supports paired-single operations using both the generic
13373 vector extensions (@pxref{Vector Extensions}) and a collection of
13374 MIPS-specific built-in functions. Both kinds of support are
13375 enabled by the @option{-mpaired-single} command-line option.
13376
13377 The vector type associated with paired-single values is usually
13378 called @code{v2sf}. It can be defined in C as follows:
13379
13380 @smallexample
13381 typedef float v2sf __attribute__ ((vector_size (8)));
13382 @end smallexample
13383
13384 @code{v2sf} values are initialized in the same way as aggregates.
13385 For example:
13386
13387 @smallexample
13388 v2sf a = @{1.5, 9.1@};
13389 v2sf b;
13390 float e, f;
13391 b = (v2sf) @{e, f@};
13392 @end smallexample
13393
13394 @emph{Note:} The CPU's endianness determines which value is stored in
13395 the upper half of a register and which value is stored in the lower half.
13396 On little-endian targets, the first value is the lower one and the second
13397 value is the upper one. The opposite order applies to big-endian targets.
13398 For example, the code above sets the lower half of @code{a} to
13399 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13400
13401 @node MIPS Loongson Built-in Functions
13402 @subsection MIPS Loongson Built-in Functions
13403
13404 GCC provides intrinsics to access the SIMD instructions provided by the
13405 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13406 available after inclusion of the @code{loongson.h} header file,
13407 operate on the following 64-bit vector types:
13408
13409 @itemize
13410 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13411 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13412 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13413 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13414 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13415 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13416 @end itemize
13417
13418 The intrinsics provided are listed below; each is named after the
13419 machine instruction to which it corresponds, with suffixes added as
13420 appropriate to distinguish intrinsics that expand to the same machine
13421 instruction yet have different argument types. Refer to the architecture
13422 documentation for a description of the functionality of each
13423 instruction.
13424
13425 @smallexample
13426 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13427 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13428 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13429 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13430 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13431 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13432 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13433 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13434 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13435 uint64_t paddd_u (uint64_t s, uint64_t t);
13436 int64_t paddd_s (int64_t s, int64_t t);
13437 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13438 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13439 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13440 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13441 uint64_t pandn_ud (uint64_t s, uint64_t t);
13442 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13443 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13444 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13445 int64_t pandn_sd (int64_t s, int64_t t);
13446 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13447 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13448 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13449 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13450 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13451 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13452 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13453 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13454 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13455 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13456 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13457 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13458 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13459 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13460 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13461 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13462 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13463 uint16x4_t pextrh_u (uint16x4_t s, int field);
13464 int16x4_t pextrh_s (int16x4_t s, int field);
13465 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13466 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13467 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13468 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13469 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13470 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13471 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13472 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13473 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13474 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13475 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13476 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13477 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13478 uint8x8_t pmovmskb_u (uint8x8_t s);
13479 int8x8_t pmovmskb_s (int8x8_t s);
13480 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13481 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13482 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13483 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13484 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13485 uint16x4_t biadd (uint8x8_t s);
13486 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13487 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13488 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13489 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13490 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13491 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13492 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13493 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13494 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13495 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13496 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13497 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13498 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13499 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13500 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13501 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13502 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13503 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13504 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13505 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13506 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13507 uint64_t psubd_u (uint64_t s, uint64_t t);
13508 int64_t psubd_s (int64_t s, int64_t t);
13509 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13510 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13511 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13512 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13513 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13514 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13515 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13516 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13517 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13518 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13519 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13520 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13521 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13522 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13523 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13524 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13525 @end smallexample
13526
13527 @menu
13528 * Paired-Single Arithmetic::
13529 * Paired-Single Built-in Functions::
13530 * MIPS-3D Built-in Functions::
13531 @end menu
13532
13533 @node Paired-Single Arithmetic
13534 @subsubsection Paired-Single Arithmetic
13535
13536 The table below lists the @code{v2sf} operations for which hardware
13537 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13538 values and @code{x} is an integral value.
13539
13540 @multitable @columnfractions .50 .50
13541 @item C code @tab MIPS instruction
13542 @item @code{a + b} @tab @code{add.ps}
13543 @item @code{a - b} @tab @code{sub.ps}
13544 @item @code{-a} @tab @code{neg.ps}
13545 @item @code{a * b} @tab @code{mul.ps}
13546 @item @code{a * b + c} @tab @code{madd.ps}
13547 @item @code{a * b - c} @tab @code{msub.ps}
13548 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13549 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13550 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13551 @end multitable
13552
13553 Note that the multiply-accumulate instructions can be disabled
13554 using the command-line option @code{-mno-fused-madd}.
13555
13556 @node Paired-Single Built-in Functions
13557 @subsubsection Paired-Single Built-in Functions
13558
13559 The following paired-single functions map directly to a particular
13560 MIPS instruction. Please refer to the architecture specification
13561 for details on what each instruction does.
13562
13563 @table @code
13564 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13565 Pair lower lower (@code{pll.ps}).
13566
13567 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13568 Pair upper lower (@code{pul.ps}).
13569
13570 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13571 Pair lower upper (@code{plu.ps}).
13572
13573 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13574 Pair upper upper (@code{puu.ps}).
13575
13576 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13577 Convert pair to paired single (@code{cvt.ps.s}).
13578
13579 @item float __builtin_mips_cvt_s_pl (v2sf)
13580 Convert pair lower to single (@code{cvt.s.pl}).
13581
13582 @item float __builtin_mips_cvt_s_pu (v2sf)
13583 Convert pair upper to single (@code{cvt.s.pu}).
13584
13585 @item v2sf __builtin_mips_abs_ps (v2sf)
13586 Absolute value (@code{abs.ps}).
13587
13588 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13589 Align variable (@code{alnv.ps}).
13590
13591 @emph{Note:} The value of the third parameter must be 0 or 4
13592 modulo 8, otherwise the result is unpredictable. Please read the
13593 instruction description for details.
13594 @end table
13595
13596 The following multi-instruction functions are also available.
13597 In each case, @var{cond} can be any of the 16 floating-point conditions:
13598 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13599 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13600 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13601
13602 @table @code
13603 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13604 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13605 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13606 @code{movt.ps}/@code{movf.ps}).
13607
13608 The @code{movt} functions return the value @var{x} computed by:
13609
13610 @smallexample
13611 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13612 mov.ps @var{x},@var{c}
13613 movt.ps @var{x},@var{d},@var{cc}
13614 @end smallexample
13615
13616 The @code{movf} functions are similar but use @code{movf.ps} instead
13617 of @code{movt.ps}.
13618
13619 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13620 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13621 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13622 @code{bc1t}/@code{bc1f}).
13623
13624 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13625 and return either the upper or lower half of the result. For example:
13626
13627 @smallexample
13628 v2sf a, b;
13629 if (__builtin_mips_upper_c_eq_ps (a, b))
13630 upper_halves_are_equal ();
13631 else
13632 upper_halves_are_unequal ();
13633
13634 if (__builtin_mips_lower_c_eq_ps (a, b))
13635 lower_halves_are_equal ();
13636 else
13637 lower_halves_are_unequal ();
13638 @end smallexample
13639 @end table
13640
13641 @node MIPS-3D Built-in Functions
13642 @subsubsection MIPS-3D Built-in Functions
13643
13644 The MIPS-3D Application-Specific Extension (ASE) includes additional
13645 paired-single instructions that are designed to improve the performance
13646 of 3D graphics operations. Support for these instructions is controlled
13647 by the @option{-mips3d} command-line option.
13648
13649 The functions listed below map directly to a particular MIPS-3D
13650 instruction. Please refer to the architecture specification for
13651 more details on what each instruction does.
13652
13653 @table @code
13654 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13655 Reduction add (@code{addr.ps}).
13656
13657 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13658 Reduction multiply (@code{mulr.ps}).
13659
13660 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13661 Convert paired single to paired word (@code{cvt.pw.ps}).
13662
13663 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13664 Convert paired word to paired single (@code{cvt.ps.pw}).
13665
13666 @item float __builtin_mips_recip1_s (float)
13667 @itemx double __builtin_mips_recip1_d (double)
13668 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13669 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13670
13671 @item float __builtin_mips_recip2_s (float, float)
13672 @itemx double __builtin_mips_recip2_d (double, double)
13673 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13674 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13675
13676 @item float __builtin_mips_rsqrt1_s (float)
13677 @itemx double __builtin_mips_rsqrt1_d (double)
13678 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13679 Reduced-precision reciprocal square root (sequence step 1)
13680 (@code{rsqrt1.@var{fmt}}).
13681
13682 @item float __builtin_mips_rsqrt2_s (float, float)
13683 @itemx double __builtin_mips_rsqrt2_d (double, double)
13684 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13685 Reduced-precision reciprocal square root (sequence step 2)
13686 (@code{rsqrt2.@var{fmt}}).
13687 @end table
13688
13689 The following multi-instruction functions are also available.
13690 In each case, @var{cond} can be any of the 16 floating-point conditions:
13691 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13692 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13693 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13694
13695 @table @code
13696 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13697 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13698 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13699 @code{bc1t}/@code{bc1f}).
13700
13701 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13702 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13703 For example:
13704
13705 @smallexample
13706 float a, b;
13707 if (__builtin_mips_cabs_eq_s (a, b))
13708 true ();
13709 else
13710 false ();
13711 @end smallexample
13712
13713 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13714 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13715 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13716 @code{bc1t}/@code{bc1f}).
13717
13718 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13719 and return either the upper or lower half of the result. For example:
13720
13721 @smallexample
13722 v2sf a, b;
13723 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13724 upper_halves_are_equal ();
13725 else
13726 upper_halves_are_unequal ();
13727
13728 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13729 lower_halves_are_equal ();
13730 else
13731 lower_halves_are_unequal ();
13732 @end smallexample
13733
13734 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13735 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13736 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13737 @code{movt.ps}/@code{movf.ps}).
13738
13739 The @code{movt} functions return the value @var{x} computed by:
13740
13741 @smallexample
13742 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13743 mov.ps @var{x},@var{c}
13744 movt.ps @var{x},@var{d},@var{cc}
13745 @end smallexample
13746
13747 The @code{movf} functions are similar but use @code{movf.ps} instead
13748 of @code{movt.ps}.
13749
13750 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13751 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13752 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13753 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13754 Comparison of two paired-single values
13755 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13756 @code{bc1any2t}/@code{bc1any2f}).
13757
13758 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13759 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13760 result is true and the @code{all} forms return true if both results are true.
13761 For example:
13762
13763 @smallexample
13764 v2sf a, b;
13765 if (__builtin_mips_any_c_eq_ps (a, b))
13766 one_is_true ();
13767 else
13768 both_are_false ();
13769
13770 if (__builtin_mips_all_c_eq_ps (a, b))
13771 both_are_true ();
13772 else
13773 one_is_false ();
13774 @end smallexample
13775
13776 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13777 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13778 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13779 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13780 Comparison of four paired-single values
13781 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13782 @code{bc1any4t}/@code{bc1any4f}).
13783
13784 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13785 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13786 The @code{any} forms return true if any of the four results are true
13787 and the @code{all} forms return true if all four results are true.
13788 For example:
13789
13790 @smallexample
13791 v2sf a, b, c, d;
13792 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13793 some_are_true ();
13794 else
13795 all_are_false ();
13796
13797 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13798 all_are_true ();
13799 else
13800 some_are_false ();
13801 @end smallexample
13802 @end table
13803
13804 @node MIPS SIMD Architecture (MSA) Support
13805 @subsection MIPS SIMD Architecture (MSA) Support
13806
13807 @menu
13808 * MIPS SIMD Architecture Built-in Functions::
13809 @end menu
13810
13811 GCC provides intrinsics to access the SIMD instructions provided by the
13812 MSA MIPS SIMD Architecture. The interface is made available by including
13813 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13814 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13815 @code{__msa_*}.
13816
13817 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13818 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13819 data elements. The following vectors typedefs are included in @code{msa.h}:
13820 @itemize
13821 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13822 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13823 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13824 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13825 @item @code{v4i32}, a vector of four signed 32-bit integers;
13826 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13827 @item @code{v2i64}, a vector of two signed 64-bit integers;
13828 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13829 @item @code{v4f32}, a vector of four 32-bit floats;
13830 @item @code{v2f64}, a vector of two 64-bit doubles.
13831 @end itemize
13832
13833 Intructions and corresponding built-ins may have additional restrictions and/or
13834 input/output values manipulated:
13835 @itemize
13836 @item @code{imm0_1}, an integer literal in range 0 to 1;
13837 @item @code{imm0_3}, an integer literal in range 0 to 3;
13838 @item @code{imm0_7}, an integer literal in range 0 to 7;
13839 @item @code{imm0_15}, an integer literal in range 0 to 15;
13840 @item @code{imm0_31}, an integer literal in range 0 to 31;
13841 @item @code{imm0_63}, an integer literal in range 0 to 63;
13842 @item @code{imm0_255}, an integer literal in range 0 to 255;
13843 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
13844 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
13845 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
13846 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
13847 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
13848 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
13849 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
13850 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
13851 @item @code{imm1_4}, an integer literal in range 1 to 4;
13852 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
13853 @end itemize
13854
13855 @smallexample
13856 @{
13857 typedef int i32;
13858 #if __LONG_MAX__ == __LONG_LONG_MAX__
13859 typedef long i64;
13860 #else
13861 typedef long long i64;
13862 #endif
13863
13864 typedef unsigned int u32;
13865 #if __LONG_MAX__ == __LONG_LONG_MAX__
13866 typedef unsigned long u64;
13867 #else
13868 typedef unsigned long long u64;
13869 #endif
13870
13871 typedef double f64;
13872 typedef float f32;
13873 @}
13874 @end smallexample
13875
13876 @node MIPS SIMD Architecture Built-in Functions
13877 @subsubsection MIPS SIMD Architecture Built-in Functions
13878
13879 The intrinsics provided are listed below; each is named after the
13880 machine instruction.
13881
13882 @smallexample
13883 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
13884 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
13885 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
13886 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
13887
13888 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
13889 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
13890 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
13891 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
13892
13893 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
13894 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
13895 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
13896 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
13897
13898 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
13899 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
13900 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
13901 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
13902
13903 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
13904 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
13905 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
13906 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
13907
13908 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
13909 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
13910 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
13911 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
13912
13913 v16u8 __builtin_msa_and_v (v16u8, v16u8);
13914
13915 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
13916
13917 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
13918 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
13919 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
13920 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
13921
13922 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
13923 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
13924 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
13925 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
13926
13927 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
13928 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
13929 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
13930 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
13931
13932 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
13933 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
13934 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
13935 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
13936
13937 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
13938 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
13939 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
13940 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
13941
13942 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
13943 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
13944 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
13945 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
13946
13947 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
13948 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
13949 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
13950 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
13951
13952 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
13953 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
13954 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
13955 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
13956
13957 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
13958 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
13959 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
13960 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
13961
13962 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
13963 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
13964 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
13965 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
13966
13967 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
13968 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
13969 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
13970 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
13971
13972 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
13973 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
13974 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
13975 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
13976
13977 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
13978
13979 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
13980
13981 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
13982
13983 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
13984
13985 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
13986 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
13987 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
13988 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
13989
13990 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
13991 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
13992 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
13993 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
13994
13995 i32 __builtin_msa_bnz_b (v16u8);
13996 i32 __builtin_msa_bnz_h (v8u16);
13997 i32 __builtin_msa_bnz_w (v4u32);
13998 i32 __builtin_msa_bnz_d (v2u64);
13999
14000 i32 __builtin_msa_bnz_v (v16u8);
14001
14002 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14003
14004 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14005
14006 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14007 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14008 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14009 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14010
14011 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14012 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14013 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14014 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14015
14016 i32 __builtin_msa_bz_b (v16u8);
14017 i32 __builtin_msa_bz_h (v8u16);
14018 i32 __builtin_msa_bz_w (v4u32);
14019 i32 __builtin_msa_bz_d (v2u64);
14020
14021 i32 __builtin_msa_bz_v (v16u8);
14022
14023 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14024 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14025 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14026 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14027
14028 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14029 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14030 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14031 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14032
14033 i32 __builtin_msa_cfcmsa (imm0_31);
14034
14035 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14036 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14037 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14038 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14039
14040 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14041 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14042 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14043 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14044
14045 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14046 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14047 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14048 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14049
14050 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14051 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14052 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14053 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14054
14055 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14056 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14057 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14058 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14059
14060 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14061 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14062 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14063 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14064
14065 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14066 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14067 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14068 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14069
14070 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14071 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14072 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14073 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14074
14075 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14076 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14077 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14078 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14079
14080 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14081 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14082 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14083 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14084
14085 void __builtin_msa_ctcmsa (imm0_31, i32);
14086
14087 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14088 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14089 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14090 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14091
14092 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14093 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14094 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14095 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14096
14097 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14098 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14099 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14100
14101 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14102 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14103 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14104
14105 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14106 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14107 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14108
14109 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14110 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14111 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14112
14113 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14114 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14115 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14116
14117 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14118 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14119 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14120
14121 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14122 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14123
14124 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14125 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14126
14127 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14128 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14129
14130 v4i32 __builtin_msa_fclass_w (v4f32);
14131 v2i64 __builtin_msa_fclass_d (v2f64);
14132
14133 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14134 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14135
14136 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14137 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14138
14139 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14140 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14141
14142 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14143 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14144
14145 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14146 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14147
14148 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14149 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14150
14151 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14152 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14153
14154 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14155 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14156
14157 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14158 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14159
14160 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14161 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14162
14163 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14164 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14165
14166 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14167 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14168
14169 v4f32 __builtin_msa_fexupl_w (v8i16);
14170 v2f64 __builtin_msa_fexupl_d (v4f32);
14171
14172 v4f32 __builtin_msa_fexupr_w (v8i16);
14173 v2f64 __builtin_msa_fexupr_d (v4f32);
14174
14175 v4f32 __builtin_msa_ffint_s_w (v4i32);
14176 v2f64 __builtin_msa_ffint_s_d (v2i64);
14177
14178 v4f32 __builtin_msa_ffint_u_w (v4u32);
14179 v2f64 __builtin_msa_ffint_u_d (v2u64);
14180
14181 v4f32 __builtin_msa_ffql_w (v8i16);
14182 v2f64 __builtin_msa_ffql_d (v4i32);
14183
14184 v4f32 __builtin_msa_ffqr_w (v8i16);
14185 v2f64 __builtin_msa_ffqr_d (v4i32);
14186
14187 v16i8 __builtin_msa_fill_b (i32);
14188 v8i16 __builtin_msa_fill_h (i32);
14189 v4i32 __builtin_msa_fill_w (i32);
14190 v2i64 __builtin_msa_fill_d (i64);
14191
14192 v4f32 __builtin_msa_flog2_w (v4f32);
14193 v2f64 __builtin_msa_flog2_d (v2f64);
14194
14195 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14196 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14197
14198 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14199 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14200
14201 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14202 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14203
14204 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14205 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14206
14207 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14208 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14209
14210 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14211 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14212
14213 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14214 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14215
14216 v4f32 __builtin_msa_frint_w (v4f32);
14217 v2f64 __builtin_msa_frint_d (v2f64);
14218
14219 v4f32 __builtin_msa_frcp_w (v4f32);
14220 v2f64 __builtin_msa_frcp_d (v2f64);
14221
14222 v4f32 __builtin_msa_frsqrt_w (v4f32);
14223 v2f64 __builtin_msa_frsqrt_d (v2f64);
14224
14225 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14226 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14227
14228 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14229 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14230
14231 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14232 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14233
14234 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14235 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14236
14237 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14238 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14239
14240 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14241 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14242
14243 v4f32 __builtin_msa_fsqrt_w (v4f32);
14244 v2f64 __builtin_msa_fsqrt_d (v2f64);
14245
14246 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14247 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14248
14249 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14250 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14251
14252 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14253 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14254
14255 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14256 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14257
14258 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14259 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14260
14261 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14262 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14263
14264 v4i32 __builtin_msa_ftint_s_w (v4f32);
14265 v2i64 __builtin_msa_ftint_s_d (v2f64);
14266
14267 v4u32 __builtin_msa_ftint_u_w (v4f32);
14268 v2u64 __builtin_msa_ftint_u_d (v2f64);
14269
14270 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14271 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14272
14273 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14274 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14275
14276 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14277 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14278
14279 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14280 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14281 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14282
14283 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14284 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14285 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14286
14287 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14288 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14289 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14290
14291 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14292 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14293 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14294
14295 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14296 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14297 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14298 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14299
14300 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14301 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14302 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14303 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14304
14305 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14306 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14307 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14308 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14309
14310 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14311 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14312 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14313 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14314
14315 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14316 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14317 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14318 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14319
14320 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14321 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14322 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14323 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14324
14325 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14326 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14327 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14328 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14329
14330 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14331 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14332 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14333 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14334
14335 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14336 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14337
14338 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14339 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14340
14341 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14342 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14343 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14344 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14345
14346 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14347 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14348 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14349 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14350
14351 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14352 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14353 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14354 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14355
14356 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14357 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14358 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14359 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14360
14361 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14362 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14363 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14364 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14365
14366 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14367 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14368 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14369 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14370
14371 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14372 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14373 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14374 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14375
14376 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14377 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14378 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14379 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14380
14381 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14382 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14383 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14384 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14385
14386 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14387 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14388 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14389 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14390
14391 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14392 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14393 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14394 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14395
14396 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14397 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14398 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14399 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14400
14401 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14402 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14403 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14404 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14405
14406 v16i8 __builtin_msa_move_v (v16i8);
14407
14408 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14409 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14410
14411 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14412 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14413
14414 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14415 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14416 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14417 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14418
14419 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14420 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14421
14422 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14423 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14424
14425 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14426 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14427 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14428 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14429
14430 v16i8 __builtin_msa_nloc_b (v16i8);
14431 v8i16 __builtin_msa_nloc_h (v8i16);
14432 v4i32 __builtin_msa_nloc_w (v4i32);
14433 v2i64 __builtin_msa_nloc_d (v2i64);
14434
14435 v16i8 __builtin_msa_nlzc_b (v16i8);
14436 v8i16 __builtin_msa_nlzc_h (v8i16);
14437 v4i32 __builtin_msa_nlzc_w (v4i32);
14438 v2i64 __builtin_msa_nlzc_d (v2i64);
14439
14440 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14441
14442 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14443
14444 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14445
14446 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14447
14448 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14449 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14450 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14451 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14452
14453 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14454 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14455 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14456 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14457
14458 v16i8 __builtin_msa_pcnt_b (v16i8);
14459 v8i16 __builtin_msa_pcnt_h (v8i16);
14460 v4i32 __builtin_msa_pcnt_w (v4i32);
14461 v2i64 __builtin_msa_pcnt_d (v2i64);
14462
14463 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14464 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14465 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14466 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14467
14468 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14469 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14470 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14471 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14472
14473 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14474 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14475 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14476
14477 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14478 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14479 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14480 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14481
14482 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14483 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14484 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14485 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14486
14487 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14488 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14489 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14490 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14491
14492 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14493 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14494 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14495 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14496
14497 v16i8 __builtin_msa_splat_b (v16i8, i32);
14498 v8i16 __builtin_msa_splat_h (v8i16, i32);
14499 v4i32 __builtin_msa_splat_w (v4i32, i32);
14500 v2i64 __builtin_msa_splat_d (v2i64, i32);
14501
14502 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14503 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14504 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14505 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14506
14507 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14508 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14509 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14510 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14511
14512 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14513 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14514 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14515 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14516
14517 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14518 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14519 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14520 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14521
14522 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14523 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14524 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14525 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14526
14527 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14528 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14529 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14530 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14531
14532 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14533 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14534 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14535 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14536
14537 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14538 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14539 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14540 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14541
14542 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14543 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14544 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14545 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14546
14547 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14548 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14549 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14550 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14551
14552 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14553 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14554 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14555 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14556
14557 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14558 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14559 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14560 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14561
14562 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14563 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14564 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14565 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14566
14567 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14568 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14569 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14570 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14571
14572 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14573 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14574 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14575 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14576
14577 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14578 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14579 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14580 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14581
14582 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14583 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14584 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14585 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14586
14587 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14588
14589 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14590 @end smallexample
14591
14592 @node Other MIPS Built-in Functions
14593 @subsection Other MIPS Built-in Functions
14594
14595 GCC provides other MIPS-specific built-in functions:
14596
14597 @table @code
14598 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14599 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14600 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14601 when this function is available.
14602
14603 @item unsigned int __builtin_mips_get_fcsr (void)
14604 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14605 Get and set the contents of the floating-point control and status register
14606 (FPU control register 31). These functions are only available in hard-float
14607 code but can be called in both MIPS16 and non-MIPS16 contexts.
14608
14609 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14610 register except the condition codes, which GCC assumes are preserved.
14611 @end table
14612
14613 @node MSP430 Built-in Functions
14614 @subsection MSP430 Built-in Functions
14615
14616 GCC provides a couple of special builtin functions to aid in the
14617 writing of interrupt handlers in C.
14618
14619 @table @code
14620 @item __bic_SR_register_on_exit (int @var{mask})
14621 This clears the indicated bits in the saved copy of the status register
14622 currently residing on the stack. This only works inside interrupt
14623 handlers and the changes to the status register will only take affect
14624 once the handler returns.
14625
14626 @item __bis_SR_register_on_exit (int @var{mask})
14627 This sets the indicated bits in the saved copy of the status register
14628 currently residing on the stack. This only works inside interrupt
14629 handlers and the changes to the status register will only take affect
14630 once the handler returns.
14631
14632 @item __delay_cycles (long long @var{cycles})
14633 This inserts an instruction sequence that takes exactly @var{cycles}
14634 cycles (between 0 and about 17E9) to complete. The inserted sequence
14635 may use jumps, loops, or no-ops, and does not interfere with any other
14636 instructions. Note that @var{cycles} must be a compile-time constant
14637 integer - that is, you must pass a number, not a variable that may be
14638 optimized to a constant later. The number of cycles delayed by this
14639 builtin is exact.
14640 @end table
14641
14642 @node NDS32 Built-in Functions
14643 @subsection NDS32 Built-in Functions
14644
14645 These built-in functions are available for the NDS32 target:
14646
14647 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14648 Insert an ISYNC instruction into the instruction stream where
14649 @var{addr} is an instruction address for serialization.
14650 @end deftypefn
14651
14652 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14653 Insert an ISB instruction into the instruction stream.
14654 @end deftypefn
14655
14656 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14657 Return the content of a system register which is mapped by @var{sr}.
14658 @end deftypefn
14659
14660 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14661 Return the content of a user space register which is mapped by @var{usr}.
14662 @end deftypefn
14663
14664 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14665 Move the @var{value} to a system register which is mapped by @var{sr}.
14666 @end deftypefn
14667
14668 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14669 Move the @var{value} to a user space register which is mapped by @var{usr}.
14670 @end deftypefn
14671
14672 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14673 Enable global interrupt.
14674 @end deftypefn
14675
14676 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14677 Disable global interrupt.
14678 @end deftypefn
14679
14680 @node picoChip Built-in Functions
14681 @subsection picoChip Built-in Functions
14682
14683 GCC provides an interface to selected machine instructions from the
14684 picoChip instruction set.
14685
14686 @table @code
14687 @item int __builtin_sbc (int @var{value})
14688 Sign bit count. Return the number of consecutive bits in @var{value}
14689 that have the same value as the sign bit. The result is the number of
14690 leading sign bits minus one, giving the number of redundant sign bits in
14691 @var{value}.
14692
14693 @item int __builtin_byteswap (int @var{value})
14694 Byte swap. Return the result of swapping the upper and lower bytes of
14695 @var{value}.
14696
14697 @item int __builtin_brev (int @var{value})
14698 Bit reversal. Return the result of reversing the bits in
14699 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14700 and so on.
14701
14702 @item int __builtin_adds (int @var{x}, int @var{y})
14703 Saturating addition. Return the result of adding @var{x} and @var{y},
14704 storing the value 32767 if the result overflows.
14705
14706 @item int __builtin_subs (int @var{x}, int @var{y})
14707 Saturating subtraction. Return the result of subtracting @var{y} from
14708 @var{x}, storing the value @minus{}32768 if the result overflows.
14709
14710 @item void __builtin_halt (void)
14711 Halt. The processor stops execution. This built-in is useful for
14712 implementing assertions.
14713
14714 @end table
14715
14716 @node PowerPC Built-in Functions
14717 @subsection PowerPC Built-in Functions
14718
14719 The following built-in functions are always available and can be used to
14720 check the PowerPC target platform type:
14721
14722 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14723 This function is a @code{nop} on the PowerPC platform and is included solely
14724 to maintain API compatibility with the x86 builtins.
14725 @end deftypefn
14726
14727 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14728 This function returns a value of @code{1} if the run-time CPU is of type
14729 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14730 detected:
14731
14732 @table @samp
14733 @item power9
14734 IBM POWER9 Server CPU.
14735 @item power8
14736 IBM POWER8 Server CPU.
14737 @item power7
14738 IBM POWER7 Server CPU.
14739 @item power6x
14740 IBM POWER6 Server CPU (RAW mode).
14741 @item power6
14742 IBM POWER6 Server CPU (Architected mode).
14743 @item power5+
14744 IBM POWER5+ Server CPU.
14745 @item power5
14746 IBM POWER5 Server CPU.
14747 @item ppc970
14748 IBM 970 Server CPU (ie, Apple G5).
14749 @item power4
14750 IBM POWER4 Server CPU.
14751 @item ppca2
14752 IBM A2 64-bit Embedded CPU
14753 @item ppc476
14754 IBM PowerPC 476FP 32-bit Embedded CPU.
14755 @item ppc464
14756 IBM PowerPC 464 32-bit Embedded CPU.
14757 @item ppc440
14758 PowerPC 440 32-bit Embedded CPU.
14759 @item ppc405
14760 PowerPC 405 32-bit Embedded CPU.
14761 @item ppc-cell-be
14762 IBM PowerPC Cell Broadband Engine Architecture CPU.
14763 @end table
14764
14765 Here is an example:
14766 @smallexample
14767 if (__builtin_cpu_is ("power8"))
14768 @{
14769 do_power8 (); // POWER8 specific implementation.
14770 @}
14771 else
14772 @{
14773 do_generic (); // Generic implementation.
14774 @}
14775 @end smallexample
14776 @end deftypefn
14777
14778 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14779 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14780 feature @var{feature} and returns @code{0} otherwise. The following features can be
14781 detected:
14782
14783 @table @samp
14784 @item 4xxmac
14785 4xx CPU has a Multiply Accumulator.
14786 @item altivec
14787 CPU has a SIMD/Vector Unit.
14788 @item arch_2_05
14789 CPU supports ISA 2.05 (eg, POWER6)
14790 @item arch_2_06
14791 CPU supports ISA 2.06 (eg, POWER7)
14792 @item arch_2_07
14793 CPU supports ISA 2.07 (eg, POWER8)
14794 @item arch_3_00
14795 CPU supports ISA 3.0 (eg, POWER9)
14796 @item archpmu
14797 CPU supports the set of compatible performance monitoring events.
14798 @item booke
14799 CPU supports the Embedded ISA category.
14800 @item cellbe
14801 CPU has a CELL broadband engine.
14802 @item dfp
14803 CPU has a decimal floating point unit.
14804 @item dscr
14805 CPU supports the data stream control register.
14806 @item ebb
14807 CPU supports event base branching.
14808 @item efpdouble
14809 CPU has a SPE double precision floating point unit.
14810 @item efpsingle
14811 CPU has a SPE single precision floating point unit.
14812 @item fpu
14813 CPU has a floating point unit.
14814 @item htm
14815 CPU has hardware transaction memory instructions.
14816 @item htm-nosc
14817 Kernel aborts hardware transactions when a syscall is made.
14818 @item ic_snoop
14819 CPU supports icache snooping capabilities.
14820 @item ieee128
14821 CPU supports 128-bit IEEE binary floating point instructions.
14822 @item isel
14823 CPU supports the integer select instruction.
14824 @item mmu
14825 CPU has a memory management unit.
14826 @item notb
14827 CPU does not have a timebase (eg, 601 and 403gx).
14828 @item pa6t
14829 CPU supports the PA Semi 6T CORE ISA.
14830 @item power4
14831 CPU supports ISA 2.00 (eg, POWER4)
14832 @item power5
14833 CPU supports ISA 2.02 (eg, POWER5)
14834 @item power5+
14835 CPU supports ISA 2.03 (eg, POWER5+)
14836 @item power6x
14837 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
14838 @item ppc32
14839 CPU supports 32-bit mode execution.
14840 @item ppc601
14841 CPU supports the old POWER ISA (eg, 601)
14842 @item ppc64
14843 CPU supports 64-bit mode execution.
14844 @item ppcle
14845 CPU supports a little-endian mode that uses address swizzling.
14846 @item smt
14847 CPU support simultaneous multi-threading.
14848 @item spe
14849 CPU has a signal processing extension unit.
14850 @item tar
14851 CPU supports the target address register.
14852 @item true_le
14853 CPU supports true little-endian mode.
14854 @item ucache
14855 CPU has unified I/D cache.
14856 @item vcrypto
14857 CPU supports the vector cryptography instructions.
14858 @item vsx
14859 CPU supports the vector-scalar extension.
14860 @end table
14861
14862 Here is an example:
14863 @smallexample
14864 if (__builtin_cpu_supports ("fpu"))
14865 @{
14866 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
14867 @}
14868 else
14869 @{
14870 dst = __fadd (src1, src2); // Software FP addition function.
14871 @}
14872 @end smallexample
14873 @end deftypefn
14874
14875 These built-in functions are available for the PowerPC family of
14876 processors:
14877 @smallexample
14878 float __builtin_recipdivf (float, float);
14879 float __builtin_rsqrtf (float);
14880 double __builtin_recipdiv (double, double);
14881 double __builtin_rsqrt (double);
14882 uint64_t __builtin_ppc_get_timebase ();
14883 unsigned long __builtin_ppc_mftb ();
14884 double __builtin_unpack_longdouble (long double, int);
14885 long double __builtin_pack_longdouble (double, double);
14886 @end smallexample
14887
14888 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
14889 @code{__builtin_rsqrtf} functions generate multiple instructions to
14890 implement the reciprocal sqrt functionality using reciprocal sqrt
14891 estimate instructions.
14892
14893 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
14894 functions generate multiple instructions to implement division using
14895 the reciprocal estimate instructions.
14896
14897 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
14898 functions generate instructions to read the Time Base Register. The
14899 @code{__builtin_ppc_get_timebase} function may generate multiple
14900 instructions and always returns the 64 bits of the Time Base Register.
14901 The @code{__builtin_ppc_mftb} function always generates one instruction and
14902 returns the Time Base Register value as an unsigned long, throwing away
14903 the most significant word on 32-bit environments.
14904
14905 Additional built-in functions are available for the 64-bit PowerPC
14906 family of processors, for efficient use of 128-bit floating point
14907 (@code{__float128}) values.
14908
14909 The following floating-point built-in functions are available with
14910 @code{-mfloat128} and Altivec support. All of them implement the
14911 function that is part of the name.
14912
14913 @smallexample
14914 __float128 __builtin_fabsq (__float128)
14915 __float128 __builtin_copysignq (__float128, __float128)
14916 @end smallexample
14917
14918 The following built-in functions are available with @code{-mfloat128}
14919 and Altivec support.
14920
14921 @table @code
14922 @item __float128 __builtin_infq (void)
14923 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
14924 @findex __builtin_infq
14925
14926 @item __float128 __builtin_huge_valq (void)
14927 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
14928 @findex __builtin_huge_valq
14929
14930 @item __float128 __builtin_nanq (void)
14931 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
14932 @findex __builtin_nanq
14933
14934 @item __float128 __builtin_nansq (void)
14935 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
14936 @findex __builtin_nansq
14937 @end table
14938
14939 The following built-in functions are available for the PowerPC family
14940 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
14941 or @option{-mpopcntd}):
14942 @smallexample
14943 long __builtin_bpermd (long, long);
14944 int __builtin_divwe (int, int);
14945 int __builtin_divweo (int, int);
14946 unsigned int __builtin_divweu (unsigned int, unsigned int);
14947 unsigned int __builtin_divweuo (unsigned int, unsigned int);
14948 long __builtin_divde (long, long);
14949 long __builtin_divdeo (long, long);
14950 unsigned long __builtin_divdeu (unsigned long, unsigned long);
14951 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
14952 unsigned int cdtbcd (unsigned int);
14953 unsigned int cbcdtd (unsigned int);
14954 unsigned int addg6s (unsigned int, unsigned int);
14955 @end smallexample
14956
14957 The @code{__builtin_divde}, @code{__builtin_divdeo},
14958 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
14959 64-bit environment support ISA 2.06 or later.
14960
14961 The following built-in functions are available for the PowerPC family
14962 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
14963 @smallexample
14964 long long __builtin_darn (void);
14965 long long __builtin_darn_raw (void);
14966 int __builtin_darn_32 (void);
14967
14968 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
14969 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
14970 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
14971 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
14972
14973 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
14974 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
14975 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
14976 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
14977
14978 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
14979 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
14980 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
14981 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
14982
14983 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
14984 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
14985 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
14986 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
14987
14988 unsigned int scalar_extract_exp (double source);
14989 unsigned long long int scalar_extract_sig (double source);
14990
14991 double
14992 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
14993
14994 int scalar_cmp_exp_gt (double arg1, double arg2);
14995 int scalar_cmp_exp_lt (double arg1, double arg2);
14996 int scalar_cmp_exp_eq (double arg1, double arg2);
14997 int scalar_cmp_exp_unordered (double arg1, double arg2);
14998
14999 int scalar_test_data_class (float source, unsigned int condition);
15000 int scalar_test_data_class (double source, unsigned int condition);
15001
15002 int scalar_test_neg (float source);
15003 int scalar_test_neg (double source);
15004 @end smallexample
15005
15006 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15007 functions require a
15008 64-bit environment supporting ISA 3.0 or later.
15009 The @code{__builtin_darn} function provides a 64-bit conditioned
15010 random number. The @code{__builtin_darn_raw} function provides a
15011 64-bit raw random number. The @code{__builtin_darn_32} function
15012 provides a 32-bit random number.
15013
15014 The @code{scalar_extract_sig} and @code{scalar_insert_exp}
15015 functions require a 64-bit environment supporting ISA 3.0 or later.
15016 The @code{scalar_extract_exp} and @code{vec_extract_sig} built-in
15017 functions return the significand and exponent respectively of their
15018 @code{source} arguments. The
15019 @code{scalar_insert_exp} built-in function returns a double-precision
15020 floating point value that is constructed by assembling the values of its
15021 @code{significand} and @code{exponent} arguments. The sign of the
15022 result is copied from the most significant bit of the
15023 @code{significand} argument. The significand and exponent components
15024 of the result are composed of the least significant 11 bits of the
15025 @code{significand} argument and the least significant 52 bits of the
15026 @code{exponent} argument.
15027
15028 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15029 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15030 functions return a non-zero value if @code{arg1} is greater than, less
15031 than, equal to, or not comparable to @code{arg2} respectively. The
15032 arguments are not comparable if one or the other equals NaN (not a
15033 number).
15034
15035 The @code{scalar_test_data_class} built-in functions return a non-zero
15036 value if any of the condition tests enabled by the value of the
15037 @code{condition} variable are true. The
15038 @code{condition} argument must be an unsigned integer with value not
15039 exceeding 127. The
15040 @code{condition} argument is encoded as a bitmask with each bit
15041 enabling the testing of a different condition, as characterized by the
15042 following:
15043 @smallexample
15044 0x40 Test for NaN
15045 0x20 Test for +Infinity
15046 0x10 Test for -Infinity
15047 0x08 Test for +Zero
15048 0x04 Test for -Zero
15049 0x02 Test for +Denormal
15050 0x01 Test for -Denormal
15051 @end smallexample
15052
15053 If all of the enabled test conditions are false, the return value is 0.
15054
15055 The @code{scalar_test_neg} built-in functions return a non-zero value
15056 if their @code{source} argument holds a negative value.
15057
15058 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15059 if and only if the number of signficant digits of its @code{value} argument
15060 is less than its @code{comparison} argument. The
15061 @code{__builtin_dfp_dtstsfi_lt_dd} and
15062 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15063 require that the type of the @code{value} argument be
15064 @code{__Decimal64} and @code{__Decimal128} respectively.
15065
15066 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15067 if and only if the number of signficant digits of its @code{value} argument
15068 is greater than its @code{comparison} argument. The
15069 @code{__builtin_dfp_dtstsfi_gt_dd} and
15070 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15071 require that the type of the @code{value} argument be
15072 @code{__Decimal64} and @code{__Decimal128} respectively.
15073
15074 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15075 if and only if the number of signficant digits of its @code{value} argument
15076 equals its @code{comparison} argument. The
15077 @code{__builtin_dfp_dtstsfi_eq_dd} and
15078 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15079 require that the type of the @code{value} argument be
15080 @code{__Decimal64} and @code{__Decimal128} respectively.
15081
15082 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15083 if and only if its @code{value} argument has an undefined number of
15084 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15085 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15086 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15087 require that the type of the @code{value} argument be
15088 @code{__Decimal64} and @code{__Decimal128} respectively.
15089
15090 The following built-in functions are available for the PowerPC family
15091 of processors when hardware decimal floating point
15092 (@option{-mhard-dfp}) is available:
15093 @smallexample
15094 _Decimal64 __builtin_dxex (_Decimal64);
15095 _Decimal128 __builtin_dxexq (_Decimal128);
15096 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15097 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15098 _Decimal64 __builtin_denbcd (int, _Decimal64);
15099 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15100 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
15101 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
15102 _Decimal64 __builtin_dscli (_Decimal64, int);
15103 _Decimal128 __builtin_dscliq (_Decimal128, int);
15104 _Decimal64 __builtin_dscri (_Decimal64, int);
15105 _Decimal128 __builtin_dscriq (_Decimal128, int);
15106 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15107 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15108 @end smallexample
15109
15110 The following built-in functions are available for the PowerPC family
15111 of processors when the Vector Scalar (vsx) instruction set is
15112 available:
15113 @smallexample
15114 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15115 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15116 unsigned long long);
15117 @end smallexample
15118
15119 @node PowerPC AltiVec/VSX Built-in Functions
15120 @subsection PowerPC AltiVec Built-in Functions
15121
15122 GCC provides an interface for the PowerPC family of processors to access
15123 the AltiVec operations described in Motorola's AltiVec Programming
15124 Interface Manual. The interface is made available by including
15125 @code{<altivec.h>} and using @option{-maltivec} and
15126 @option{-mabi=altivec}. The interface supports the following vector
15127 types.
15128
15129 @smallexample
15130 vector unsigned char
15131 vector signed char
15132 vector bool char
15133
15134 vector unsigned short
15135 vector signed short
15136 vector bool short
15137 vector pixel
15138
15139 vector unsigned int
15140 vector signed int
15141 vector bool int
15142 vector float
15143 @end smallexample
15144
15145 If @option{-mvsx} is used the following additional vector types are
15146 implemented.
15147
15148 @smallexample
15149 vector unsigned long
15150 vector signed long
15151 vector double
15152 @end smallexample
15153
15154 The long types are only implemented for 64-bit code generation, and
15155 the long type is only used in the floating point/integer conversion
15156 instructions.
15157
15158 GCC's implementation of the high-level language interface available from
15159 C and C++ code differs from Motorola's documentation in several ways.
15160
15161 @itemize @bullet
15162
15163 @item
15164 A vector constant is a list of constant expressions within curly braces.
15165
15166 @item
15167 A vector initializer requires no cast if the vector constant is of the
15168 same type as the variable it is initializing.
15169
15170 @item
15171 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15172 vector type is the default signedness of the base type. The default
15173 varies depending on the operating system, so a portable program should
15174 always specify the signedness.
15175
15176 @item
15177 Compiling with @option{-maltivec} adds keywords @code{__vector},
15178 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15179 @code{bool}. When compiling ISO C, the context-sensitive substitution
15180 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15181 disabled. To use them, you must include @code{<altivec.h>} instead.
15182
15183 @item
15184 GCC allows using a @code{typedef} name as the type specifier for a
15185 vector type.
15186
15187 @item
15188 For C, overloaded functions are implemented with macros so the following
15189 does not work:
15190
15191 @smallexample
15192 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15193 @end smallexample
15194
15195 @noindent
15196 Since @code{vec_add} is a macro, the vector constant in the example
15197 is treated as four separate arguments. Wrap the entire argument in
15198 parentheses for this to work.
15199 @end itemize
15200
15201 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15202 Internally, GCC uses built-in functions to achieve the functionality in
15203 the aforementioned header file, but they are not supported and are
15204 subject to change without notice.
15205
15206 The following interfaces are supported for the generic and specific
15207 AltiVec operations and the AltiVec predicates. In cases where there
15208 is a direct mapping between generic and specific operations, only the
15209 generic names are shown here, although the specific operations can also
15210 be used.
15211
15212 Arguments that are documented as @code{const int} require literal
15213 integral values within the range required for that operation.
15214
15215 @smallexample
15216 vector signed char vec_abs (vector signed char);
15217 vector signed short vec_abs (vector signed short);
15218 vector signed int vec_abs (vector signed int);
15219 vector float vec_abs (vector float);
15220
15221 vector signed char vec_abss (vector signed char);
15222 vector signed short vec_abss (vector signed short);
15223 vector signed int vec_abss (vector signed int);
15224
15225 vector signed char vec_add (vector bool char, vector signed char);
15226 vector signed char vec_add (vector signed char, vector bool char);
15227 vector signed char vec_add (vector signed char, vector signed char);
15228 vector unsigned char vec_add (vector bool char, vector unsigned char);
15229 vector unsigned char vec_add (vector unsigned char, vector bool char);
15230 vector unsigned char vec_add (vector unsigned char,
15231 vector unsigned char);
15232 vector signed short vec_add (vector bool short, vector signed short);
15233 vector signed short vec_add (vector signed short, vector bool short);
15234 vector signed short vec_add (vector signed short, vector signed short);
15235 vector unsigned short vec_add (vector bool short,
15236 vector unsigned short);
15237 vector unsigned short vec_add (vector unsigned short,
15238 vector bool short);
15239 vector unsigned short vec_add (vector unsigned short,
15240 vector unsigned short);
15241 vector signed int vec_add (vector bool int, vector signed int);
15242 vector signed int vec_add (vector signed int, vector bool int);
15243 vector signed int vec_add (vector signed int, vector signed int);
15244 vector unsigned int vec_add (vector bool int, vector unsigned int);
15245 vector unsigned int vec_add (vector unsigned int, vector bool int);
15246 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15247 vector float vec_add (vector float, vector float);
15248
15249 vector float vec_vaddfp (vector float, vector float);
15250
15251 vector signed int vec_vadduwm (vector bool int, vector signed int);
15252 vector signed int vec_vadduwm (vector signed int, vector bool int);
15253 vector signed int vec_vadduwm (vector signed int, vector signed int);
15254 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15255 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15256 vector unsigned int vec_vadduwm (vector unsigned int,
15257 vector unsigned int);
15258
15259 vector signed short vec_vadduhm (vector bool short,
15260 vector signed short);
15261 vector signed short vec_vadduhm (vector signed short,
15262 vector bool short);
15263 vector signed short vec_vadduhm (vector signed short,
15264 vector signed short);
15265 vector unsigned short vec_vadduhm (vector bool short,
15266 vector unsigned short);
15267 vector unsigned short vec_vadduhm (vector unsigned short,
15268 vector bool short);
15269 vector unsigned short vec_vadduhm (vector unsigned short,
15270 vector unsigned short);
15271
15272 vector signed char vec_vaddubm (vector bool char, vector signed char);
15273 vector signed char vec_vaddubm (vector signed char, vector bool char);
15274 vector signed char vec_vaddubm (vector signed char, vector signed char);
15275 vector unsigned char vec_vaddubm (vector bool char,
15276 vector unsigned char);
15277 vector unsigned char vec_vaddubm (vector unsigned char,
15278 vector bool char);
15279 vector unsigned char vec_vaddubm (vector unsigned char,
15280 vector unsigned char);
15281
15282 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15283
15284 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15285 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15286 vector unsigned char vec_adds (vector unsigned char,
15287 vector unsigned char);
15288 vector signed char vec_adds (vector bool char, vector signed char);
15289 vector signed char vec_adds (vector signed char, vector bool char);
15290 vector signed char vec_adds (vector signed char, vector signed char);
15291 vector unsigned short vec_adds (vector bool short,
15292 vector unsigned short);
15293 vector unsigned short vec_adds (vector unsigned short,
15294 vector bool short);
15295 vector unsigned short vec_adds (vector unsigned short,
15296 vector unsigned short);
15297 vector signed short vec_adds (vector bool short, vector signed short);
15298 vector signed short vec_adds (vector signed short, vector bool short);
15299 vector signed short vec_adds (vector signed short, vector signed short);
15300 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15301 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15302 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15303 vector signed int vec_adds (vector bool int, vector signed int);
15304 vector signed int vec_adds (vector signed int, vector bool int);
15305 vector signed int vec_adds (vector signed int, vector signed int);
15306
15307 vector signed int vec_vaddsws (vector bool int, vector signed int);
15308 vector signed int vec_vaddsws (vector signed int, vector bool int);
15309 vector signed int vec_vaddsws (vector signed int, vector signed int);
15310
15311 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15312 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15313 vector unsigned int vec_vadduws (vector unsigned int,
15314 vector unsigned int);
15315
15316 vector signed short vec_vaddshs (vector bool short,
15317 vector signed short);
15318 vector signed short vec_vaddshs (vector signed short,
15319 vector bool short);
15320 vector signed short vec_vaddshs (vector signed short,
15321 vector signed short);
15322
15323 vector unsigned short vec_vadduhs (vector bool short,
15324 vector unsigned short);
15325 vector unsigned short vec_vadduhs (vector unsigned short,
15326 vector bool short);
15327 vector unsigned short vec_vadduhs (vector unsigned short,
15328 vector unsigned short);
15329
15330 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15331 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15332 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15333
15334 vector unsigned char vec_vaddubs (vector bool char,
15335 vector unsigned char);
15336 vector unsigned char vec_vaddubs (vector unsigned char,
15337 vector bool char);
15338 vector unsigned char vec_vaddubs (vector unsigned char,
15339 vector unsigned char);
15340
15341 vector float vec_and (vector float, vector float);
15342 vector float vec_and (vector float, vector bool int);
15343 vector float vec_and (vector bool int, vector float);
15344 vector bool int vec_and (vector bool int, vector bool int);
15345 vector signed int vec_and (vector bool int, vector signed int);
15346 vector signed int vec_and (vector signed int, vector bool int);
15347 vector signed int vec_and (vector signed int, vector signed int);
15348 vector unsigned int vec_and (vector bool int, vector unsigned int);
15349 vector unsigned int vec_and (vector unsigned int, vector bool int);
15350 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15351 vector bool short vec_and (vector bool short, vector bool short);
15352 vector signed short vec_and (vector bool short, vector signed short);
15353 vector signed short vec_and (vector signed short, vector bool short);
15354 vector signed short vec_and (vector signed short, vector signed short);
15355 vector unsigned short vec_and (vector bool short,
15356 vector unsigned short);
15357 vector unsigned short vec_and (vector unsigned short,
15358 vector bool short);
15359 vector unsigned short vec_and (vector unsigned short,
15360 vector unsigned short);
15361 vector signed char vec_and (vector bool char, vector signed char);
15362 vector bool char vec_and (vector bool char, vector bool char);
15363 vector signed char vec_and (vector signed char, vector bool char);
15364 vector signed char vec_and (vector signed char, vector signed char);
15365 vector unsigned char vec_and (vector bool char, vector unsigned char);
15366 vector unsigned char vec_and (vector unsigned char, vector bool char);
15367 vector unsigned char vec_and (vector unsigned char,
15368 vector unsigned char);
15369
15370 vector float vec_andc (vector float, vector float);
15371 vector float vec_andc (vector float, vector bool int);
15372 vector float vec_andc (vector bool int, vector float);
15373 vector bool int vec_andc (vector bool int, vector bool int);
15374 vector signed int vec_andc (vector bool int, vector signed int);
15375 vector signed int vec_andc (vector signed int, vector bool int);
15376 vector signed int vec_andc (vector signed int, vector signed int);
15377 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15378 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15379 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15380 vector bool short vec_andc (vector bool short, vector bool short);
15381 vector signed short vec_andc (vector bool short, vector signed short);
15382 vector signed short vec_andc (vector signed short, vector bool short);
15383 vector signed short vec_andc (vector signed short, vector signed short);
15384 vector unsigned short vec_andc (vector bool short,
15385 vector unsigned short);
15386 vector unsigned short vec_andc (vector unsigned short,
15387 vector bool short);
15388 vector unsigned short vec_andc (vector unsigned short,
15389 vector unsigned short);
15390 vector signed char vec_andc (vector bool char, vector signed char);
15391 vector bool char vec_andc (vector bool char, vector bool char);
15392 vector signed char vec_andc (vector signed char, vector bool char);
15393 vector signed char vec_andc (vector signed char, vector signed char);
15394 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15395 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15396 vector unsigned char vec_andc (vector unsigned char,
15397 vector unsigned char);
15398
15399 vector unsigned char vec_avg (vector unsigned char,
15400 vector unsigned char);
15401 vector signed char vec_avg (vector signed char, vector signed char);
15402 vector unsigned short vec_avg (vector unsigned short,
15403 vector unsigned short);
15404 vector signed short vec_avg (vector signed short, vector signed short);
15405 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15406 vector signed int vec_avg (vector signed int, vector signed int);
15407
15408 vector signed int vec_vavgsw (vector signed int, vector signed int);
15409
15410 vector unsigned int vec_vavguw (vector unsigned int,
15411 vector unsigned int);
15412
15413 vector signed short vec_vavgsh (vector signed short,
15414 vector signed short);
15415
15416 vector unsigned short vec_vavguh (vector unsigned short,
15417 vector unsigned short);
15418
15419 vector signed char vec_vavgsb (vector signed char, vector signed char);
15420
15421 vector unsigned char vec_vavgub (vector unsigned char,
15422 vector unsigned char);
15423
15424 vector float vec_copysign (vector float);
15425
15426 vector float vec_ceil (vector float);
15427
15428 vector signed int vec_cmpb (vector float, vector float);
15429
15430 vector bool char vec_cmpeq (vector signed char, vector signed char);
15431 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15432 vector bool short vec_cmpeq (vector signed short, vector signed short);
15433 vector bool short vec_cmpeq (vector unsigned short,
15434 vector unsigned short);
15435 vector bool int vec_cmpeq (vector signed int, vector signed int);
15436 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15437 vector bool int vec_cmpeq (vector float, vector float);
15438
15439 vector bool int vec_vcmpeqfp (vector float, vector float);
15440
15441 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15442 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15443
15444 vector bool short vec_vcmpequh (vector signed short,
15445 vector signed short);
15446 vector bool short vec_vcmpequh (vector unsigned short,
15447 vector unsigned short);
15448
15449 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15450 vector bool char vec_vcmpequb (vector unsigned char,
15451 vector unsigned char);
15452
15453 vector bool int vec_cmpge (vector float, vector float);
15454
15455 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15456 vector bool char vec_cmpgt (vector signed char, vector signed char);
15457 vector bool short vec_cmpgt (vector unsigned short,
15458 vector unsigned short);
15459 vector bool short vec_cmpgt (vector signed short, vector signed short);
15460 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15461 vector bool int vec_cmpgt (vector signed int, vector signed int);
15462 vector bool int vec_cmpgt (vector float, vector float);
15463
15464 vector bool int vec_vcmpgtfp (vector float, vector float);
15465
15466 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15467
15468 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15469
15470 vector bool short vec_vcmpgtsh (vector signed short,
15471 vector signed short);
15472
15473 vector bool short vec_vcmpgtuh (vector unsigned short,
15474 vector unsigned short);
15475
15476 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15477
15478 vector bool char vec_vcmpgtub (vector unsigned char,
15479 vector unsigned char);
15480
15481 vector bool int vec_cmple (vector float, vector float);
15482
15483 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15484 vector bool char vec_cmplt (vector signed char, vector signed char);
15485 vector bool short vec_cmplt (vector unsigned short,
15486 vector unsigned short);
15487 vector bool short vec_cmplt (vector signed short, vector signed short);
15488 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15489 vector bool int vec_cmplt (vector signed int, vector signed int);
15490 vector bool int vec_cmplt (vector float, vector float);
15491
15492 vector float vec_cpsgn (vector float, vector float);
15493
15494 vector float vec_ctf (vector unsigned int, const int);
15495 vector float vec_ctf (vector signed int, const int);
15496 vector double vec_ctf (vector unsigned long, const int);
15497 vector double vec_ctf (vector signed long, const int);
15498
15499 vector float vec_vcfsx (vector signed int, const int);
15500
15501 vector float vec_vcfux (vector unsigned int, const int);
15502
15503 vector signed int vec_cts (vector float, const int);
15504 vector signed long vec_cts (vector double, const int);
15505
15506 vector unsigned int vec_ctu (vector float, const int);
15507 vector unsigned long vec_ctu (vector double, const int);
15508
15509 void vec_dss (const int);
15510
15511 void vec_dssall (void);
15512
15513 void vec_dst (const vector unsigned char *, int, const int);
15514 void vec_dst (const vector signed char *, int, const int);
15515 void vec_dst (const vector bool char *, int, const int);
15516 void vec_dst (const vector unsigned short *, int, const int);
15517 void vec_dst (const vector signed short *, int, const int);
15518 void vec_dst (const vector bool short *, int, const int);
15519 void vec_dst (const vector pixel *, int, const int);
15520 void vec_dst (const vector unsigned int *, int, const int);
15521 void vec_dst (const vector signed int *, int, const int);
15522 void vec_dst (const vector bool int *, int, const int);
15523 void vec_dst (const vector float *, int, const int);
15524 void vec_dst (const unsigned char *, int, const int);
15525 void vec_dst (const signed char *, int, const int);
15526 void vec_dst (const unsigned short *, int, const int);
15527 void vec_dst (const short *, int, const int);
15528 void vec_dst (const unsigned int *, int, const int);
15529 void vec_dst (const int *, int, const int);
15530 void vec_dst (const unsigned long *, int, const int);
15531 void vec_dst (const long *, int, const int);
15532 void vec_dst (const float *, int, const int);
15533
15534 void vec_dstst (const vector unsigned char *, int, const int);
15535 void vec_dstst (const vector signed char *, int, const int);
15536 void vec_dstst (const vector bool char *, int, const int);
15537 void vec_dstst (const vector unsigned short *, int, const int);
15538 void vec_dstst (const vector signed short *, int, const int);
15539 void vec_dstst (const vector bool short *, int, const int);
15540 void vec_dstst (const vector pixel *, int, const int);
15541 void vec_dstst (const vector unsigned int *, int, const int);
15542 void vec_dstst (const vector signed int *, int, const int);
15543 void vec_dstst (const vector bool int *, int, const int);
15544 void vec_dstst (const vector float *, int, const int);
15545 void vec_dstst (const unsigned char *, int, const int);
15546 void vec_dstst (const signed char *, int, const int);
15547 void vec_dstst (const unsigned short *, int, const int);
15548 void vec_dstst (const short *, int, const int);
15549 void vec_dstst (const unsigned int *, int, const int);
15550 void vec_dstst (const int *, int, const int);
15551 void vec_dstst (const unsigned long *, int, const int);
15552 void vec_dstst (const long *, int, const int);
15553 void vec_dstst (const float *, int, const int);
15554
15555 void vec_dststt (const vector unsigned char *, int, const int);
15556 void vec_dststt (const vector signed char *, int, const int);
15557 void vec_dststt (const vector bool char *, int, const int);
15558 void vec_dststt (const vector unsigned short *, int, const int);
15559 void vec_dststt (const vector signed short *, int, const int);
15560 void vec_dststt (const vector bool short *, int, const int);
15561 void vec_dststt (const vector pixel *, int, const int);
15562 void vec_dststt (const vector unsigned int *, int, const int);
15563 void vec_dststt (const vector signed int *, int, const int);
15564 void vec_dststt (const vector bool int *, int, const int);
15565 void vec_dststt (const vector float *, int, const int);
15566 void vec_dststt (const unsigned char *, int, const int);
15567 void vec_dststt (const signed char *, int, const int);
15568 void vec_dststt (const unsigned short *, int, const int);
15569 void vec_dststt (const short *, int, const int);
15570 void vec_dststt (const unsigned int *, int, const int);
15571 void vec_dststt (const int *, int, const int);
15572 void vec_dststt (const unsigned long *, int, const int);
15573 void vec_dststt (const long *, int, const int);
15574 void vec_dststt (const float *, int, const int);
15575
15576 void vec_dstt (const vector unsigned char *, int, const int);
15577 void vec_dstt (const vector signed char *, int, const int);
15578 void vec_dstt (const vector bool char *, int, const int);
15579 void vec_dstt (const vector unsigned short *, int, const int);
15580 void vec_dstt (const vector signed short *, int, const int);
15581 void vec_dstt (const vector bool short *, int, const int);
15582 void vec_dstt (const vector pixel *, int, const int);
15583 void vec_dstt (const vector unsigned int *, int, const int);
15584 void vec_dstt (const vector signed int *, int, const int);
15585 void vec_dstt (const vector bool int *, int, const int);
15586 void vec_dstt (const vector float *, int, const int);
15587 void vec_dstt (const unsigned char *, int, const int);
15588 void vec_dstt (const signed char *, int, const int);
15589 void vec_dstt (const unsigned short *, int, const int);
15590 void vec_dstt (const short *, int, const int);
15591 void vec_dstt (const unsigned int *, int, const int);
15592 void vec_dstt (const int *, int, const int);
15593 void vec_dstt (const unsigned long *, int, const int);
15594 void vec_dstt (const long *, int, const int);
15595 void vec_dstt (const float *, int, const int);
15596
15597 vector float vec_expte (vector float);
15598
15599 vector float vec_floor (vector float);
15600
15601 vector float vec_ld (int, const vector float *);
15602 vector float vec_ld (int, const float *);
15603 vector bool int vec_ld (int, const vector bool int *);
15604 vector signed int vec_ld (int, const vector signed int *);
15605 vector signed int vec_ld (int, const int *);
15606 vector signed int vec_ld (int, const long *);
15607 vector unsigned int vec_ld (int, const vector unsigned int *);
15608 vector unsigned int vec_ld (int, const unsigned int *);
15609 vector unsigned int vec_ld (int, const unsigned long *);
15610 vector bool short vec_ld (int, const vector bool short *);
15611 vector pixel vec_ld (int, const vector pixel *);
15612 vector signed short vec_ld (int, const vector signed short *);
15613 vector signed short vec_ld (int, const short *);
15614 vector unsigned short vec_ld (int, const vector unsigned short *);
15615 vector unsigned short vec_ld (int, const unsigned short *);
15616 vector bool char vec_ld (int, const vector bool char *);
15617 vector signed char vec_ld (int, const vector signed char *);
15618 vector signed char vec_ld (int, const signed char *);
15619 vector unsigned char vec_ld (int, const vector unsigned char *);
15620 vector unsigned char vec_ld (int, const unsigned char *);
15621
15622 vector signed char vec_lde (int, const signed char *);
15623 vector unsigned char vec_lde (int, const unsigned char *);
15624 vector signed short vec_lde (int, const short *);
15625 vector unsigned short vec_lde (int, const unsigned short *);
15626 vector float vec_lde (int, const float *);
15627 vector signed int vec_lde (int, const int *);
15628 vector unsigned int vec_lde (int, const unsigned int *);
15629 vector signed int vec_lde (int, const long *);
15630 vector unsigned int vec_lde (int, const unsigned long *);
15631
15632 vector float vec_lvewx (int, float *);
15633 vector signed int vec_lvewx (int, int *);
15634 vector unsigned int vec_lvewx (int, unsigned int *);
15635 vector signed int vec_lvewx (int, long *);
15636 vector unsigned int vec_lvewx (int, unsigned long *);
15637
15638 vector signed short vec_lvehx (int, short *);
15639 vector unsigned short vec_lvehx (int, unsigned short *);
15640
15641 vector signed char vec_lvebx (int, char *);
15642 vector unsigned char vec_lvebx (int, unsigned char *);
15643
15644 vector float vec_ldl (int, const vector float *);
15645 vector float vec_ldl (int, const float *);
15646 vector bool int vec_ldl (int, const vector bool int *);
15647 vector signed int vec_ldl (int, const vector signed int *);
15648 vector signed int vec_ldl (int, const int *);
15649 vector signed int vec_ldl (int, const long *);
15650 vector unsigned int vec_ldl (int, const vector unsigned int *);
15651 vector unsigned int vec_ldl (int, const unsigned int *);
15652 vector unsigned int vec_ldl (int, const unsigned long *);
15653 vector bool short vec_ldl (int, const vector bool short *);
15654 vector pixel vec_ldl (int, const vector pixel *);
15655 vector signed short vec_ldl (int, const vector signed short *);
15656 vector signed short vec_ldl (int, const short *);
15657 vector unsigned short vec_ldl (int, const vector unsigned short *);
15658 vector unsigned short vec_ldl (int, const unsigned short *);
15659 vector bool char vec_ldl (int, const vector bool char *);
15660 vector signed char vec_ldl (int, const vector signed char *);
15661 vector signed char vec_ldl (int, const signed char *);
15662 vector unsigned char vec_ldl (int, const vector unsigned char *);
15663 vector unsigned char vec_ldl (int, const unsigned char *);
15664
15665 vector float vec_loge (vector float);
15666
15667 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
15668 vector unsigned char vec_lvsl (int, const volatile signed char *);
15669 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
15670 vector unsigned char vec_lvsl (int, const volatile short *);
15671 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
15672 vector unsigned char vec_lvsl (int, const volatile int *);
15673 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
15674 vector unsigned char vec_lvsl (int, const volatile long *);
15675 vector unsigned char vec_lvsl (int, const volatile float *);
15676
15677 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
15678 vector unsigned char vec_lvsr (int, const volatile signed char *);
15679 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
15680 vector unsigned char vec_lvsr (int, const volatile short *);
15681 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
15682 vector unsigned char vec_lvsr (int, const volatile int *);
15683 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
15684 vector unsigned char vec_lvsr (int, const volatile long *);
15685 vector unsigned char vec_lvsr (int, const volatile float *);
15686
15687 vector float vec_madd (vector float, vector float, vector float);
15688
15689 vector signed short vec_madds (vector signed short,
15690 vector signed short,
15691 vector signed short);
15692
15693 vector unsigned char vec_max (vector bool char, vector unsigned char);
15694 vector unsigned char vec_max (vector unsigned char, vector bool char);
15695 vector unsigned char vec_max (vector unsigned char,
15696 vector unsigned char);
15697 vector signed char vec_max (vector bool char, vector signed char);
15698 vector signed char vec_max (vector signed char, vector bool char);
15699 vector signed char vec_max (vector signed char, vector signed char);
15700 vector unsigned short vec_max (vector bool short,
15701 vector unsigned short);
15702 vector unsigned short vec_max (vector unsigned short,
15703 vector bool short);
15704 vector unsigned short vec_max (vector unsigned short,
15705 vector unsigned short);
15706 vector signed short vec_max (vector bool short, vector signed short);
15707 vector signed short vec_max (vector signed short, vector bool short);
15708 vector signed short vec_max (vector signed short, vector signed short);
15709 vector unsigned int vec_max (vector bool int, vector unsigned int);
15710 vector unsigned int vec_max (vector unsigned int, vector bool int);
15711 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
15712 vector signed int vec_max (vector bool int, vector signed int);
15713 vector signed int vec_max (vector signed int, vector bool int);
15714 vector signed int vec_max (vector signed int, vector signed int);
15715 vector float vec_max (vector float, vector float);
15716
15717 vector float vec_vmaxfp (vector float, vector float);
15718
15719 vector signed int vec_vmaxsw (vector bool int, vector signed int);
15720 vector signed int vec_vmaxsw (vector signed int, vector bool int);
15721 vector signed int vec_vmaxsw (vector signed int, vector signed int);
15722
15723 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
15724 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
15725 vector unsigned int vec_vmaxuw (vector unsigned int,
15726 vector unsigned int);
15727
15728 vector signed short vec_vmaxsh (vector bool short, vector signed short);
15729 vector signed short vec_vmaxsh (vector signed short, vector bool short);
15730 vector signed short vec_vmaxsh (vector signed short,
15731 vector signed short);
15732
15733 vector unsigned short vec_vmaxuh (vector bool short,
15734 vector unsigned short);
15735 vector unsigned short vec_vmaxuh (vector unsigned short,
15736 vector bool short);
15737 vector unsigned short vec_vmaxuh (vector unsigned short,
15738 vector unsigned short);
15739
15740 vector signed char vec_vmaxsb (vector bool char, vector signed char);
15741 vector signed char vec_vmaxsb (vector signed char, vector bool char);
15742 vector signed char vec_vmaxsb (vector signed char, vector signed char);
15743
15744 vector unsigned char vec_vmaxub (vector bool char,
15745 vector unsigned char);
15746 vector unsigned char vec_vmaxub (vector unsigned char,
15747 vector bool char);
15748 vector unsigned char vec_vmaxub (vector unsigned char,
15749 vector unsigned char);
15750
15751 vector bool char vec_mergeh (vector bool char, vector bool char);
15752 vector signed char vec_mergeh (vector signed char, vector signed char);
15753 vector unsigned char vec_mergeh (vector unsigned char,
15754 vector unsigned char);
15755 vector bool short vec_mergeh (vector bool short, vector bool short);
15756 vector pixel vec_mergeh (vector pixel, vector pixel);
15757 vector signed short vec_mergeh (vector signed short,
15758 vector signed short);
15759 vector unsigned short vec_mergeh (vector unsigned short,
15760 vector unsigned short);
15761 vector float vec_mergeh (vector float, vector float);
15762 vector bool int vec_mergeh (vector bool int, vector bool int);
15763 vector signed int vec_mergeh (vector signed int, vector signed int);
15764 vector unsigned int vec_mergeh (vector unsigned int,
15765 vector unsigned int);
15766
15767 vector float vec_vmrghw (vector float, vector float);
15768 vector bool int vec_vmrghw (vector bool int, vector bool int);
15769 vector signed int vec_vmrghw (vector signed int, vector signed int);
15770 vector unsigned int vec_vmrghw (vector unsigned int,
15771 vector unsigned int);
15772
15773 vector bool short vec_vmrghh (vector bool short, vector bool short);
15774 vector signed short vec_vmrghh (vector signed short,
15775 vector signed short);
15776 vector unsigned short vec_vmrghh (vector unsigned short,
15777 vector unsigned short);
15778 vector pixel vec_vmrghh (vector pixel, vector pixel);
15779
15780 vector bool char vec_vmrghb (vector bool char, vector bool char);
15781 vector signed char vec_vmrghb (vector signed char, vector signed char);
15782 vector unsigned char vec_vmrghb (vector unsigned char,
15783 vector unsigned char);
15784
15785 vector bool char vec_mergel (vector bool char, vector bool char);
15786 vector signed char vec_mergel (vector signed char, vector signed char);
15787 vector unsigned char vec_mergel (vector unsigned char,
15788 vector unsigned char);
15789 vector bool short vec_mergel (vector bool short, vector bool short);
15790 vector pixel vec_mergel (vector pixel, vector pixel);
15791 vector signed short vec_mergel (vector signed short,
15792 vector signed short);
15793 vector unsigned short vec_mergel (vector unsigned short,
15794 vector unsigned short);
15795 vector float vec_mergel (vector float, vector float);
15796 vector bool int vec_mergel (vector bool int, vector bool int);
15797 vector signed int vec_mergel (vector signed int, vector signed int);
15798 vector unsigned int vec_mergel (vector unsigned int,
15799 vector unsigned int);
15800
15801 vector float vec_vmrglw (vector float, vector float);
15802 vector signed int vec_vmrglw (vector signed int, vector signed int);
15803 vector unsigned int vec_vmrglw (vector unsigned int,
15804 vector unsigned int);
15805 vector bool int vec_vmrglw (vector bool int, vector bool int);
15806
15807 vector bool short vec_vmrglh (vector bool short, vector bool short);
15808 vector signed short vec_vmrglh (vector signed short,
15809 vector signed short);
15810 vector unsigned short vec_vmrglh (vector unsigned short,
15811 vector unsigned short);
15812 vector pixel vec_vmrglh (vector pixel, vector pixel);
15813
15814 vector bool char vec_vmrglb (vector bool char, vector bool char);
15815 vector signed char vec_vmrglb (vector signed char, vector signed char);
15816 vector unsigned char vec_vmrglb (vector unsigned char,
15817 vector unsigned char);
15818
15819 vector unsigned short vec_mfvscr (void);
15820
15821 vector unsigned char vec_min (vector bool char, vector unsigned char);
15822 vector unsigned char vec_min (vector unsigned char, vector bool char);
15823 vector unsigned char vec_min (vector unsigned char,
15824 vector unsigned char);
15825 vector signed char vec_min (vector bool char, vector signed char);
15826 vector signed char vec_min (vector signed char, vector bool char);
15827 vector signed char vec_min (vector signed char, vector signed char);
15828 vector unsigned short vec_min (vector bool short,
15829 vector unsigned short);
15830 vector unsigned short vec_min (vector unsigned short,
15831 vector bool short);
15832 vector unsigned short vec_min (vector unsigned short,
15833 vector unsigned short);
15834 vector signed short vec_min (vector bool short, vector signed short);
15835 vector signed short vec_min (vector signed short, vector bool short);
15836 vector signed short vec_min (vector signed short, vector signed short);
15837 vector unsigned int vec_min (vector bool int, vector unsigned int);
15838 vector unsigned int vec_min (vector unsigned int, vector bool int);
15839 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
15840 vector signed int vec_min (vector bool int, vector signed int);
15841 vector signed int vec_min (vector signed int, vector bool int);
15842 vector signed int vec_min (vector signed int, vector signed int);
15843 vector float vec_min (vector float, vector float);
15844
15845 vector float vec_vminfp (vector float, vector float);
15846
15847 vector signed int vec_vminsw (vector bool int, vector signed int);
15848 vector signed int vec_vminsw (vector signed int, vector bool int);
15849 vector signed int vec_vminsw (vector signed int, vector signed int);
15850
15851 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
15852 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
15853 vector unsigned int vec_vminuw (vector unsigned int,
15854 vector unsigned int);
15855
15856 vector signed short vec_vminsh (vector bool short, vector signed short);
15857 vector signed short vec_vminsh (vector signed short, vector bool short);
15858 vector signed short vec_vminsh (vector signed short,
15859 vector signed short);
15860
15861 vector unsigned short vec_vminuh (vector bool short,
15862 vector unsigned short);
15863 vector unsigned short vec_vminuh (vector unsigned short,
15864 vector bool short);
15865 vector unsigned short vec_vminuh (vector unsigned short,
15866 vector unsigned short);
15867
15868 vector signed char vec_vminsb (vector bool char, vector signed char);
15869 vector signed char vec_vminsb (vector signed char, vector bool char);
15870 vector signed char vec_vminsb (vector signed char, vector signed char);
15871
15872 vector unsigned char vec_vminub (vector bool char,
15873 vector unsigned char);
15874 vector unsigned char vec_vminub (vector unsigned char,
15875 vector bool char);
15876 vector unsigned char vec_vminub (vector unsigned char,
15877 vector unsigned char);
15878
15879 vector signed short vec_mladd (vector signed short,
15880 vector signed short,
15881 vector signed short);
15882 vector signed short vec_mladd (vector signed short,
15883 vector unsigned short,
15884 vector unsigned short);
15885 vector signed short vec_mladd (vector unsigned short,
15886 vector signed short,
15887 vector signed short);
15888 vector unsigned short vec_mladd (vector unsigned short,
15889 vector unsigned short,
15890 vector unsigned short);
15891
15892 vector signed short vec_mradds (vector signed short,
15893 vector signed short,
15894 vector signed short);
15895
15896 vector unsigned int vec_msum (vector unsigned char,
15897 vector unsigned char,
15898 vector unsigned int);
15899 vector signed int vec_msum (vector signed char,
15900 vector unsigned char,
15901 vector signed int);
15902 vector unsigned int vec_msum (vector unsigned short,
15903 vector unsigned short,
15904 vector unsigned int);
15905 vector signed int vec_msum (vector signed short,
15906 vector signed short,
15907 vector signed int);
15908
15909 vector signed int vec_vmsumshm (vector signed short,
15910 vector signed short,
15911 vector signed int);
15912
15913 vector unsigned int vec_vmsumuhm (vector unsigned short,
15914 vector unsigned short,
15915 vector unsigned int);
15916
15917 vector signed int vec_vmsummbm (vector signed char,
15918 vector unsigned char,
15919 vector signed int);
15920
15921 vector unsigned int vec_vmsumubm (vector unsigned char,
15922 vector unsigned char,
15923 vector unsigned int);
15924
15925 vector unsigned int vec_msums (vector unsigned short,
15926 vector unsigned short,
15927 vector unsigned int);
15928 vector signed int vec_msums (vector signed short,
15929 vector signed short,
15930 vector signed int);
15931
15932 vector signed int vec_vmsumshs (vector signed short,
15933 vector signed short,
15934 vector signed int);
15935
15936 vector unsigned int vec_vmsumuhs (vector unsigned short,
15937 vector unsigned short,
15938 vector unsigned int);
15939
15940 void vec_mtvscr (vector signed int);
15941 void vec_mtvscr (vector unsigned int);
15942 void vec_mtvscr (vector bool int);
15943 void vec_mtvscr (vector signed short);
15944 void vec_mtvscr (vector unsigned short);
15945 void vec_mtvscr (vector bool short);
15946 void vec_mtvscr (vector pixel);
15947 void vec_mtvscr (vector signed char);
15948 void vec_mtvscr (vector unsigned char);
15949 void vec_mtvscr (vector bool char);
15950
15951 vector unsigned short vec_mule (vector unsigned char,
15952 vector unsigned char);
15953 vector signed short vec_mule (vector signed char,
15954 vector signed char);
15955 vector unsigned int vec_mule (vector unsigned short,
15956 vector unsigned short);
15957 vector signed int vec_mule (vector signed short, vector signed short);
15958
15959 vector signed int vec_vmulesh (vector signed short,
15960 vector signed short);
15961
15962 vector unsigned int vec_vmuleuh (vector unsigned short,
15963 vector unsigned short);
15964
15965 vector signed short vec_vmulesb (vector signed char,
15966 vector signed char);
15967
15968 vector unsigned short vec_vmuleub (vector unsigned char,
15969 vector unsigned char);
15970
15971 vector unsigned short vec_mulo (vector unsigned char,
15972 vector unsigned char);
15973 vector signed short vec_mulo (vector signed char, vector signed char);
15974 vector unsigned int vec_mulo (vector unsigned short,
15975 vector unsigned short);
15976 vector signed int vec_mulo (vector signed short, vector signed short);
15977
15978 vector signed int vec_vmulosh (vector signed short,
15979 vector signed short);
15980
15981 vector unsigned int vec_vmulouh (vector unsigned short,
15982 vector unsigned short);
15983
15984 vector signed short vec_vmulosb (vector signed char,
15985 vector signed char);
15986
15987 vector unsigned short vec_vmuloub (vector unsigned char,
15988 vector unsigned char);
15989
15990 vector float vec_nmsub (vector float, vector float, vector float);
15991
15992 vector float vec_nor (vector float, vector float);
15993 vector signed int vec_nor (vector signed int, vector signed int);
15994 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
15995 vector bool int vec_nor (vector bool int, vector bool int);
15996 vector signed short vec_nor (vector signed short, vector signed short);
15997 vector unsigned short vec_nor (vector unsigned short,
15998 vector unsigned short);
15999 vector bool short vec_nor (vector bool short, vector bool short);
16000 vector signed char vec_nor (vector signed char, vector signed char);
16001 vector unsigned char vec_nor (vector unsigned char,
16002 vector unsigned char);
16003 vector bool char vec_nor (vector bool char, vector bool char);
16004
16005 vector float vec_or (vector float, vector float);
16006 vector float vec_or (vector float, vector bool int);
16007 vector float vec_or (vector bool int, vector float);
16008 vector bool int vec_or (vector bool int, vector bool int);
16009 vector signed int vec_or (vector bool int, vector signed int);
16010 vector signed int vec_or (vector signed int, vector bool int);
16011 vector signed int vec_or (vector signed int, vector signed int);
16012 vector unsigned int vec_or (vector bool int, vector unsigned int);
16013 vector unsigned int vec_or (vector unsigned int, vector bool int);
16014 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16015 vector bool short vec_or (vector bool short, vector bool short);
16016 vector signed short vec_or (vector bool short, vector signed short);
16017 vector signed short vec_or (vector signed short, vector bool short);
16018 vector signed short vec_or (vector signed short, vector signed short);
16019 vector unsigned short vec_or (vector bool short, vector unsigned short);
16020 vector unsigned short vec_or (vector unsigned short, vector bool short);
16021 vector unsigned short vec_or (vector unsigned short,
16022 vector unsigned short);
16023 vector signed char vec_or (vector bool char, vector signed char);
16024 vector bool char vec_or (vector bool char, vector bool char);
16025 vector signed char vec_or (vector signed char, vector bool char);
16026 vector signed char vec_or (vector signed char, vector signed char);
16027 vector unsigned char vec_or (vector bool char, vector unsigned char);
16028 vector unsigned char vec_or (vector unsigned char, vector bool char);
16029 vector unsigned char vec_or (vector unsigned char,
16030 vector unsigned char);
16031
16032 vector signed char vec_pack (vector signed short, vector signed short);
16033 vector unsigned char vec_pack (vector unsigned short,
16034 vector unsigned short);
16035 vector bool char vec_pack (vector bool short, vector bool short);
16036 vector signed short vec_pack (vector signed int, vector signed int);
16037 vector unsigned short vec_pack (vector unsigned int,
16038 vector unsigned int);
16039 vector bool short vec_pack (vector bool int, vector bool int);
16040
16041 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16042 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16043 vector unsigned short vec_vpkuwum (vector unsigned int,
16044 vector unsigned int);
16045
16046 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16047 vector signed char vec_vpkuhum (vector signed short,
16048 vector signed short);
16049 vector unsigned char vec_vpkuhum (vector unsigned short,
16050 vector unsigned short);
16051
16052 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16053
16054 vector unsigned char vec_packs (vector unsigned short,
16055 vector unsigned short);
16056 vector signed char vec_packs (vector signed short, vector signed short);
16057 vector unsigned short vec_packs (vector unsigned int,
16058 vector unsigned int);
16059 vector signed short vec_packs (vector signed int, vector signed int);
16060
16061 vector signed short vec_vpkswss (vector signed int, vector signed int);
16062
16063 vector unsigned short vec_vpkuwus (vector unsigned int,
16064 vector unsigned int);
16065
16066 vector signed char vec_vpkshss (vector signed short,
16067 vector signed short);
16068
16069 vector unsigned char vec_vpkuhus (vector unsigned short,
16070 vector unsigned short);
16071
16072 vector unsigned char vec_packsu (vector unsigned short,
16073 vector unsigned short);
16074 vector unsigned char vec_packsu (vector signed short,
16075 vector signed short);
16076 vector unsigned short vec_packsu (vector unsigned int,
16077 vector unsigned int);
16078 vector unsigned short vec_packsu (vector signed int, vector signed int);
16079
16080 vector unsigned short vec_vpkswus (vector signed int,
16081 vector signed int);
16082
16083 vector unsigned char vec_vpkshus (vector signed short,
16084 vector signed short);
16085
16086 vector float vec_perm (vector float,
16087 vector float,
16088 vector unsigned char);
16089 vector signed int vec_perm (vector signed int,
16090 vector signed int,
16091 vector unsigned char);
16092 vector unsigned int vec_perm (vector unsigned int,
16093 vector unsigned int,
16094 vector unsigned char);
16095 vector bool int vec_perm (vector bool int,
16096 vector bool int,
16097 vector unsigned char);
16098 vector signed short vec_perm (vector signed short,
16099 vector signed short,
16100 vector unsigned char);
16101 vector unsigned short vec_perm (vector unsigned short,
16102 vector unsigned short,
16103 vector unsigned char);
16104 vector bool short vec_perm (vector bool short,
16105 vector bool short,
16106 vector unsigned char);
16107 vector pixel vec_perm (vector pixel,
16108 vector pixel,
16109 vector unsigned char);
16110 vector signed char vec_perm (vector signed char,
16111 vector signed char,
16112 vector unsigned char);
16113 vector unsigned char vec_perm (vector unsigned char,
16114 vector unsigned char,
16115 vector unsigned char);
16116 vector bool char vec_perm (vector bool char,
16117 vector bool char,
16118 vector unsigned char);
16119
16120 vector float vec_re (vector float);
16121
16122 vector signed char vec_rl (vector signed char,
16123 vector unsigned char);
16124 vector unsigned char vec_rl (vector unsigned char,
16125 vector unsigned char);
16126 vector signed short vec_rl (vector signed short, vector unsigned short);
16127 vector unsigned short vec_rl (vector unsigned short,
16128 vector unsigned short);
16129 vector signed int vec_rl (vector signed int, vector unsigned int);
16130 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16131
16132 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16133 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16134
16135 vector signed short vec_vrlh (vector signed short,
16136 vector unsigned short);
16137 vector unsigned short vec_vrlh (vector unsigned short,
16138 vector unsigned short);
16139
16140 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16141 vector unsigned char vec_vrlb (vector unsigned char,
16142 vector unsigned char);
16143
16144 vector float vec_round (vector float);
16145
16146 vector float vec_recip (vector float, vector float);
16147
16148 vector float vec_rsqrt (vector float);
16149
16150 vector float vec_rsqrte (vector float);
16151
16152 vector float vec_sel (vector float, vector float, vector bool int);
16153 vector float vec_sel (vector float, vector float, vector unsigned int);
16154 vector signed int vec_sel (vector signed int,
16155 vector signed int,
16156 vector bool int);
16157 vector signed int vec_sel (vector signed int,
16158 vector signed int,
16159 vector unsigned int);
16160 vector unsigned int vec_sel (vector unsigned int,
16161 vector unsigned int,
16162 vector bool int);
16163 vector unsigned int vec_sel (vector unsigned int,
16164 vector unsigned int,
16165 vector unsigned int);
16166 vector bool int vec_sel (vector bool int,
16167 vector bool int,
16168 vector bool int);
16169 vector bool int vec_sel (vector bool int,
16170 vector bool int,
16171 vector unsigned int);
16172 vector signed short vec_sel (vector signed short,
16173 vector signed short,
16174 vector bool short);
16175 vector signed short vec_sel (vector signed short,
16176 vector signed short,
16177 vector unsigned short);
16178 vector unsigned short vec_sel (vector unsigned short,
16179 vector unsigned short,
16180 vector bool short);
16181 vector unsigned short vec_sel (vector unsigned short,
16182 vector unsigned short,
16183 vector unsigned short);
16184 vector bool short vec_sel (vector bool short,
16185 vector bool short,
16186 vector bool short);
16187 vector bool short vec_sel (vector bool short,
16188 vector bool short,
16189 vector unsigned short);
16190 vector signed char vec_sel (vector signed char,
16191 vector signed char,
16192 vector bool char);
16193 vector signed char vec_sel (vector signed char,
16194 vector signed char,
16195 vector unsigned char);
16196 vector unsigned char vec_sel (vector unsigned char,
16197 vector unsigned char,
16198 vector bool char);
16199 vector unsigned char vec_sel (vector unsigned char,
16200 vector unsigned char,
16201 vector unsigned char);
16202 vector bool char vec_sel (vector bool char,
16203 vector bool char,
16204 vector bool char);
16205 vector bool char vec_sel (vector bool char,
16206 vector bool char,
16207 vector unsigned char);
16208
16209 vector signed char vec_sl (vector signed char,
16210 vector unsigned char);
16211 vector unsigned char vec_sl (vector unsigned char,
16212 vector unsigned char);
16213 vector signed short vec_sl (vector signed short, vector unsigned short);
16214 vector unsigned short vec_sl (vector unsigned short,
16215 vector unsigned short);
16216 vector signed int vec_sl (vector signed int, vector unsigned int);
16217 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16218
16219 vector signed int vec_vslw (vector signed int, vector unsigned int);
16220 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16221
16222 vector signed short vec_vslh (vector signed short,
16223 vector unsigned short);
16224 vector unsigned short vec_vslh (vector unsigned short,
16225 vector unsigned short);
16226
16227 vector signed char vec_vslb (vector signed char, vector unsigned char);
16228 vector unsigned char vec_vslb (vector unsigned char,
16229 vector unsigned char);
16230
16231 vector float vec_sld (vector float, vector float, const int);
16232 vector signed int vec_sld (vector signed int,
16233 vector signed int,
16234 const int);
16235 vector unsigned int vec_sld (vector unsigned int,
16236 vector unsigned int,
16237 const int);
16238 vector bool int vec_sld (vector bool int,
16239 vector bool int,
16240 const int);
16241 vector signed short vec_sld (vector signed short,
16242 vector signed short,
16243 const int);
16244 vector unsigned short vec_sld (vector unsigned short,
16245 vector unsigned short,
16246 const int);
16247 vector bool short vec_sld (vector bool short,
16248 vector bool short,
16249 const int);
16250 vector pixel vec_sld (vector pixel,
16251 vector pixel,
16252 const int);
16253 vector signed char vec_sld (vector signed char,
16254 vector signed char,
16255 const int);
16256 vector unsigned char vec_sld (vector unsigned char,
16257 vector unsigned char,
16258 const int);
16259 vector bool char vec_sld (vector bool char,
16260 vector bool char,
16261 const int);
16262
16263 vector signed int vec_sll (vector signed int,
16264 vector unsigned int);
16265 vector signed int vec_sll (vector signed int,
16266 vector unsigned short);
16267 vector signed int vec_sll (vector signed int,
16268 vector unsigned char);
16269 vector unsigned int vec_sll (vector unsigned int,
16270 vector unsigned int);
16271 vector unsigned int vec_sll (vector unsigned int,
16272 vector unsigned short);
16273 vector unsigned int vec_sll (vector unsigned int,
16274 vector unsigned char);
16275 vector bool int vec_sll (vector bool int,
16276 vector unsigned int);
16277 vector bool int vec_sll (vector bool int,
16278 vector unsigned short);
16279 vector bool int vec_sll (vector bool int,
16280 vector unsigned char);
16281 vector signed short vec_sll (vector signed short,
16282 vector unsigned int);
16283 vector signed short vec_sll (vector signed short,
16284 vector unsigned short);
16285 vector signed short vec_sll (vector signed short,
16286 vector unsigned char);
16287 vector unsigned short vec_sll (vector unsigned short,
16288 vector unsigned int);
16289 vector unsigned short vec_sll (vector unsigned short,
16290 vector unsigned short);
16291 vector unsigned short vec_sll (vector unsigned short,
16292 vector unsigned char);
16293 vector bool short vec_sll (vector bool short, vector unsigned int);
16294 vector bool short vec_sll (vector bool short, vector unsigned short);
16295 vector bool short vec_sll (vector bool short, vector unsigned char);
16296 vector pixel vec_sll (vector pixel, vector unsigned int);
16297 vector pixel vec_sll (vector pixel, vector unsigned short);
16298 vector pixel vec_sll (vector pixel, vector unsigned char);
16299 vector signed char vec_sll (vector signed char, vector unsigned int);
16300 vector signed char vec_sll (vector signed char, vector unsigned short);
16301 vector signed char vec_sll (vector signed char, vector unsigned char);
16302 vector unsigned char vec_sll (vector unsigned char,
16303 vector unsigned int);
16304 vector unsigned char vec_sll (vector unsigned char,
16305 vector unsigned short);
16306 vector unsigned char vec_sll (vector unsigned char,
16307 vector unsigned char);
16308 vector bool char vec_sll (vector bool char, vector unsigned int);
16309 vector bool char vec_sll (vector bool char, vector unsigned short);
16310 vector bool char vec_sll (vector bool char, vector unsigned char);
16311
16312 vector float vec_slo (vector float, vector signed char);
16313 vector float vec_slo (vector float, vector unsigned char);
16314 vector signed int vec_slo (vector signed int, vector signed char);
16315 vector signed int vec_slo (vector signed int, vector unsigned char);
16316 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16317 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16318 vector signed short vec_slo (vector signed short, vector signed char);
16319 vector signed short vec_slo (vector signed short, vector unsigned char);
16320 vector unsigned short vec_slo (vector unsigned short,
16321 vector signed char);
16322 vector unsigned short vec_slo (vector unsigned short,
16323 vector unsigned char);
16324 vector pixel vec_slo (vector pixel, vector signed char);
16325 vector pixel vec_slo (vector pixel, vector unsigned char);
16326 vector signed char vec_slo (vector signed char, vector signed char);
16327 vector signed char vec_slo (vector signed char, vector unsigned char);
16328 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16329 vector unsigned char vec_slo (vector unsigned char,
16330 vector unsigned char);
16331
16332 vector signed char vec_splat (vector signed char, const int);
16333 vector unsigned char vec_splat (vector unsigned char, const int);
16334 vector bool char vec_splat (vector bool char, const int);
16335 vector signed short vec_splat (vector signed short, const int);
16336 vector unsigned short vec_splat (vector unsigned short, const int);
16337 vector bool short vec_splat (vector bool short, const int);
16338 vector pixel vec_splat (vector pixel, const int);
16339 vector float vec_splat (vector float, const int);
16340 vector signed int vec_splat (vector signed int, const int);
16341 vector unsigned int vec_splat (vector unsigned int, const int);
16342 vector bool int vec_splat (vector bool int, const int);
16343 vector signed long vec_splat (vector signed long, const int);
16344 vector unsigned long vec_splat (vector unsigned long, const int);
16345
16346 vector signed char vec_splats (signed char);
16347 vector unsigned char vec_splats (unsigned char);
16348 vector signed short vec_splats (signed short);
16349 vector unsigned short vec_splats (unsigned short);
16350 vector signed int vec_splats (signed int);
16351 vector unsigned int vec_splats (unsigned int);
16352 vector float vec_splats (float);
16353
16354 vector float vec_vspltw (vector float, const int);
16355 vector signed int vec_vspltw (vector signed int, const int);
16356 vector unsigned int vec_vspltw (vector unsigned int, const int);
16357 vector bool int vec_vspltw (vector bool int, const int);
16358
16359 vector bool short vec_vsplth (vector bool short, const int);
16360 vector signed short vec_vsplth (vector signed short, const int);
16361 vector unsigned short vec_vsplth (vector unsigned short, const int);
16362 vector pixel vec_vsplth (vector pixel, const int);
16363
16364 vector signed char vec_vspltb (vector signed char, const int);
16365 vector unsigned char vec_vspltb (vector unsigned char, const int);
16366 vector bool char vec_vspltb (vector bool char, const int);
16367
16368 vector signed char vec_splat_s8 (const int);
16369
16370 vector signed short vec_splat_s16 (const int);
16371
16372 vector signed int vec_splat_s32 (const int);
16373
16374 vector unsigned char vec_splat_u8 (const int);
16375
16376 vector unsigned short vec_splat_u16 (const int);
16377
16378 vector unsigned int vec_splat_u32 (const int);
16379
16380 vector signed char vec_sr (vector signed char, vector unsigned char);
16381 vector unsigned char vec_sr (vector unsigned char,
16382 vector unsigned char);
16383 vector signed short vec_sr (vector signed short,
16384 vector unsigned short);
16385 vector unsigned short vec_sr (vector unsigned short,
16386 vector unsigned short);
16387 vector signed int vec_sr (vector signed int, vector unsigned int);
16388 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16389
16390 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16391 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16392
16393 vector signed short vec_vsrh (vector signed short,
16394 vector unsigned short);
16395 vector unsigned short vec_vsrh (vector unsigned short,
16396 vector unsigned short);
16397
16398 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16399 vector unsigned char vec_vsrb (vector unsigned char,
16400 vector unsigned char);
16401
16402 vector signed char vec_sra (vector signed char, vector unsigned char);
16403 vector unsigned char vec_sra (vector unsigned char,
16404 vector unsigned char);
16405 vector signed short vec_sra (vector signed short,
16406 vector unsigned short);
16407 vector unsigned short vec_sra (vector unsigned short,
16408 vector unsigned short);
16409 vector signed int vec_sra (vector signed int, vector unsigned int);
16410 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16411
16412 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16413 vector unsigned int vec_vsraw (vector unsigned int,
16414 vector unsigned int);
16415
16416 vector signed short vec_vsrah (vector signed short,
16417 vector unsigned short);
16418 vector unsigned short vec_vsrah (vector unsigned short,
16419 vector unsigned short);
16420
16421 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16422 vector unsigned char vec_vsrab (vector unsigned char,
16423 vector unsigned char);
16424
16425 vector signed int vec_srl (vector signed int, vector unsigned int);
16426 vector signed int vec_srl (vector signed int, vector unsigned short);
16427 vector signed int vec_srl (vector signed int, vector unsigned char);
16428 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16429 vector unsigned int vec_srl (vector unsigned int,
16430 vector unsigned short);
16431 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16432 vector bool int vec_srl (vector bool int, vector unsigned int);
16433 vector bool int vec_srl (vector bool int, vector unsigned short);
16434 vector bool int vec_srl (vector bool int, vector unsigned char);
16435 vector signed short vec_srl (vector signed short, vector unsigned int);
16436 vector signed short vec_srl (vector signed short,
16437 vector unsigned short);
16438 vector signed short vec_srl (vector signed short, vector unsigned char);
16439 vector unsigned short vec_srl (vector unsigned short,
16440 vector unsigned int);
16441 vector unsigned short vec_srl (vector unsigned short,
16442 vector unsigned short);
16443 vector unsigned short vec_srl (vector unsigned short,
16444 vector unsigned char);
16445 vector bool short vec_srl (vector bool short, vector unsigned int);
16446 vector bool short vec_srl (vector bool short, vector unsigned short);
16447 vector bool short vec_srl (vector bool short, vector unsigned char);
16448 vector pixel vec_srl (vector pixel, vector unsigned int);
16449 vector pixel vec_srl (vector pixel, vector unsigned short);
16450 vector pixel vec_srl (vector pixel, vector unsigned char);
16451 vector signed char vec_srl (vector signed char, vector unsigned int);
16452 vector signed char vec_srl (vector signed char, vector unsigned short);
16453 vector signed char vec_srl (vector signed char, vector unsigned char);
16454 vector unsigned char vec_srl (vector unsigned char,
16455 vector unsigned int);
16456 vector unsigned char vec_srl (vector unsigned char,
16457 vector unsigned short);
16458 vector unsigned char vec_srl (vector unsigned char,
16459 vector unsigned char);
16460 vector bool char vec_srl (vector bool char, vector unsigned int);
16461 vector bool char vec_srl (vector bool char, vector unsigned short);
16462 vector bool char vec_srl (vector bool char, vector unsigned char);
16463
16464 vector float vec_sro (vector float, vector signed char);
16465 vector float vec_sro (vector float, vector unsigned char);
16466 vector signed int vec_sro (vector signed int, vector signed char);
16467 vector signed int vec_sro (vector signed int, vector unsigned char);
16468 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16469 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16470 vector signed short vec_sro (vector signed short, vector signed char);
16471 vector signed short vec_sro (vector signed short, vector unsigned char);
16472 vector unsigned short vec_sro (vector unsigned short,
16473 vector signed char);
16474 vector unsigned short vec_sro (vector unsigned short,
16475 vector unsigned char);
16476 vector pixel vec_sro (vector pixel, vector signed char);
16477 vector pixel vec_sro (vector pixel, vector unsigned char);
16478 vector signed char vec_sro (vector signed char, vector signed char);
16479 vector signed char vec_sro (vector signed char, vector unsigned char);
16480 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16481 vector unsigned char vec_sro (vector unsigned char,
16482 vector unsigned char);
16483
16484 void vec_st (vector float, int, vector float *);
16485 void vec_st (vector float, int, float *);
16486 void vec_st (vector signed int, int, vector signed int *);
16487 void vec_st (vector signed int, int, int *);
16488 void vec_st (vector unsigned int, int, vector unsigned int *);
16489 void vec_st (vector unsigned int, int, unsigned int *);
16490 void vec_st (vector bool int, int, vector bool int *);
16491 void vec_st (vector bool int, int, unsigned int *);
16492 void vec_st (vector bool int, int, int *);
16493 void vec_st (vector signed short, int, vector signed short *);
16494 void vec_st (vector signed short, int, short *);
16495 void vec_st (vector unsigned short, int, vector unsigned short *);
16496 void vec_st (vector unsigned short, int, unsigned short *);
16497 void vec_st (vector bool short, int, vector bool short *);
16498 void vec_st (vector bool short, int, unsigned short *);
16499 void vec_st (vector pixel, int, vector pixel *);
16500 void vec_st (vector pixel, int, unsigned short *);
16501 void vec_st (vector pixel, int, short *);
16502 void vec_st (vector bool short, int, short *);
16503 void vec_st (vector signed char, int, vector signed char *);
16504 void vec_st (vector signed char, int, signed char *);
16505 void vec_st (vector unsigned char, int, vector unsigned char *);
16506 void vec_st (vector unsigned char, int, unsigned char *);
16507 void vec_st (vector bool char, int, vector bool char *);
16508 void vec_st (vector bool char, int, unsigned char *);
16509 void vec_st (vector bool char, int, signed char *);
16510
16511 void vec_ste (vector signed char, int, signed char *);
16512 void vec_ste (vector unsigned char, int, unsigned char *);
16513 void vec_ste (vector bool char, int, signed char *);
16514 void vec_ste (vector bool char, int, unsigned char *);
16515 void vec_ste (vector signed short, int, short *);
16516 void vec_ste (vector unsigned short, int, unsigned short *);
16517 void vec_ste (vector bool short, int, short *);
16518 void vec_ste (vector bool short, int, unsigned short *);
16519 void vec_ste (vector pixel, int, short *);
16520 void vec_ste (vector pixel, int, unsigned short *);
16521 void vec_ste (vector float, int, float *);
16522 void vec_ste (vector signed int, int, int *);
16523 void vec_ste (vector unsigned int, int, unsigned int *);
16524 void vec_ste (vector bool int, int, int *);
16525 void vec_ste (vector bool int, int, unsigned int *);
16526
16527 void vec_stvewx (vector float, int, float *);
16528 void vec_stvewx (vector signed int, int, int *);
16529 void vec_stvewx (vector unsigned int, int, unsigned int *);
16530 void vec_stvewx (vector bool int, int, int *);
16531 void vec_stvewx (vector bool int, int, unsigned int *);
16532
16533 void vec_stvehx (vector signed short, int, short *);
16534 void vec_stvehx (vector unsigned short, int, unsigned short *);
16535 void vec_stvehx (vector bool short, int, short *);
16536 void vec_stvehx (vector bool short, int, unsigned short *);
16537 void vec_stvehx (vector pixel, int, short *);
16538 void vec_stvehx (vector pixel, int, unsigned short *);
16539
16540 void vec_stvebx (vector signed char, int, signed char *);
16541 void vec_stvebx (vector unsigned char, int, unsigned char *);
16542 void vec_stvebx (vector bool char, int, signed char *);
16543 void vec_stvebx (vector bool char, int, unsigned char *);
16544
16545 void vec_stl (vector float, int, vector float *);
16546 void vec_stl (vector float, int, float *);
16547 void vec_stl (vector signed int, int, vector signed int *);
16548 void vec_stl (vector signed int, int, int *);
16549 void vec_stl (vector unsigned int, int, vector unsigned int *);
16550 void vec_stl (vector unsigned int, int, unsigned int *);
16551 void vec_stl (vector bool int, int, vector bool int *);
16552 void vec_stl (vector bool int, int, unsigned int *);
16553 void vec_stl (vector bool int, int, int *);
16554 void vec_stl (vector signed short, int, vector signed short *);
16555 void vec_stl (vector signed short, int, short *);
16556 void vec_stl (vector unsigned short, int, vector unsigned short *);
16557 void vec_stl (vector unsigned short, int, unsigned short *);
16558 void vec_stl (vector bool short, int, vector bool short *);
16559 void vec_stl (vector bool short, int, unsigned short *);
16560 void vec_stl (vector bool short, int, short *);
16561 void vec_stl (vector pixel, int, vector pixel *);
16562 void vec_stl (vector pixel, int, unsigned short *);
16563 void vec_stl (vector pixel, int, short *);
16564 void vec_stl (vector signed char, int, vector signed char *);
16565 void vec_stl (vector signed char, int, signed char *);
16566 void vec_stl (vector unsigned char, int, vector unsigned char *);
16567 void vec_stl (vector unsigned char, int, unsigned char *);
16568 void vec_stl (vector bool char, int, vector bool char *);
16569 void vec_stl (vector bool char, int, unsigned char *);
16570 void vec_stl (vector bool char, int, signed char *);
16571
16572 vector signed char vec_sub (vector bool char, vector signed char);
16573 vector signed char vec_sub (vector signed char, vector bool char);
16574 vector signed char vec_sub (vector signed char, vector signed char);
16575 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16576 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16577 vector unsigned char vec_sub (vector unsigned char,
16578 vector unsigned char);
16579 vector signed short vec_sub (vector bool short, vector signed short);
16580 vector signed short vec_sub (vector signed short, vector bool short);
16581 vector signed short vec_sub (vector signed short, vector signed short);
16582 vector unsigned short vec_sub (vector bool short,
16583 vector unsigned short);
16584 vector unsigned short vec_sub (vector unsigned short,
16585 vector bool short);
16586 vector unsigned short vec_sub (vector unsigned short,
16587 vector unsigned short);
16588 vector signed int vec_sub (vector bool int, vector signed int);
16589 vector signed int vec_sub (vector signed int, vector bool int);
16590 vector signed int vec_sub (vector signed int, vector signed int);
16591 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16592 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16593 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16594 vector float vec_sub (vector float, vector float);
16595
16596 vector float vec_vsubfp (vector float, vector float);
16597
16598 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16599 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16600 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16601 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16602 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16603 vector unsigned int vec_vsubuwm (vector unsigned int,
16604 vector unsigned int);
16605
16606 vector signed short vec_vsubuhm (vector bool short,
16607 vector signed short);
16608 vector signed short vec_vsubuhm (vector signed short,
16609 vector bool short);
16610 vector signed short vec_vsubuhm (vector signed short,
16611 vector signed short);
16612 vector unsigned short vec_vsubuhm (vector bool short,
16613 vector unsigned short);
16614 vector unsigned short vec_vsubuhm (vector unsigned short,
16615 vector bool short);
16616 vector unsigned short vec_vsubuhm (vector unsigned short,
16617 vector unsigned short);
16618
16619 vector signed char vec_vsububm (vector bool char, vector signed char);
16620 vector signed char vec_vsububm (vector signed char, vector bool char);
16621 vector signed char vec_vsububm (vector signed char, vector signed char);
16622 vector unsigned char vec_vsububm (vector bool char,
16623 vector unsigned char);
16624 vector unsigned char vec_vsububm (vector unsigned char,
16625 vector bool char);
16626 vector unsigned char vec_vsububm (vector unsigned char,
16627 vector unsigned char);
16628
16629 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16630
16631 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16632 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16633 vector unsigned char vec_subs (vector unsigned char,
16634 vector unsigned char);
16635 vector signed char vec_subs (vector bool char, vector signed char);
16636 vector signed char vec_subs (vector signed char, vector bool char);
16637 vector signed char vec_subs (vector signed char, vector signed char);
16638 vector unsigned short vec_subs (vector bool short,
16639 vector unsigned short);
16640 vector unsigned short vec_subs (vector unsigned short,
16641 vector bool short);
16642 vector unsigned short vec_subs (vector unsigned short,
16643 vector unsigned short);
16644 vector signed short vec_subs (vector bool short, vector signed short);
16645 vector signed short vec_subs (vector signed short, vector bool short);
16646 vector signed short vec_subs (vector signed short, vector signed short);
16647 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16648 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16649 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16650 vector signed int vec_subs (vector bool int, vector signed int);
16651 vector signed int vec_subs (vector signed int, vector bool int);
16652 vector signed int vec_subs (vector signed int, vector signed int);
16653
16654 vector signed int vec_vsubsws (vector bool int, vector signed int);
16655 vector signed int vec_vsubsws (vector signed int, vector bool int);
16656 vector signed int vec_vsubsws (vector signed int, vector signed int);
16657
16658 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16659 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
16660 vector unsigned int vec_vsubuws (vector unsigned int,
16661 vector unsigned int);
16662
16663 vector signed short vec_vsubshs (vector bool short,
16664 vector signed short);
16665 vector signed short vec_vsubshs (vector signed short,
16666 vector bool short);
16667 vector signed short vec_vsubshs (vector signed short,
16668 vector signed short);
16669
16670 vector unsigned short vec_vsubuhs (vector bool short,
16671 vector unsigned short);
16672 vector unsigned short vec_vsubuhs (vector unsigned short,
16673 vector bool short);
16674 vector unsigned short vec_vsubuhs (vector unsigned short,
16675 vector unsigned short);
16676
16677 vector signed char vec_vsubsbs (vector bool char, vector signed char);
16678 vector signed char vec_vsubsbs (vector signed char, vector bool char);
16679 vector signed char vec_vsubsbs (vector signed char, vector signed char);
16680
16681 vector unsigned char vec_vsububs (vector bool char,
16682 vector unsigned char);
16683 vector unsigned char vec_vsububs (vector unsigned char,
16684 vector bool char);
16685 vector unsigned char vec_vsububs (vector unsigned char,
16686 vector unsigned char);
16687
16688 vector unsigned int vec_sum4s (vector unsigned char,
16689 vector unsigned int);
16690 vector signed int vec_sum4s (vector signed char, vector signed int);
16691 vector signed int vec_sum4s (vector signed short, vector signed int);
16692
16693 vector signed int vec_vsum4shs (vector signed short, vector signed int);
16694
16695 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
16696
16697 vector unsigned int vec_vsum4ubs (vector unsigned char,
16698 vector unsigned int);
16699
16700 vector signed int vec_sum2s (vector signed int, vector signed int);
16701
16702 vector signed int vec_sums (vector signed int, vector signed int);
16703
16704 vector float vec_trunc (vector float);
16705
16706 vector signed short vec_unpackh (vector signed char);
16707 vector bool short vec_unpackh (vector bool char);
16708 vector signed int vec_unpackh (vector signed short);
16709 vector bool int vec_unpackh (vector bool short);
16710 vector unsigned int vec_unpackh (vector pixel);
16711
16712 vector bool int vec_vupkhsh (vector bool short);
16713 vector signed int vec_vupkhsh (vector signed short);
16714
16715 vector unsigned int vec_vupkhpx (vector pixel);
16716
16717 vector bool short vec_vupkhsb (vector bool char);
16718 vector signed short vec_vupkhsb (vector signed char);
16719
16720 vector signed short vec_unpackl (vector signed char);
16721 vector bool short vec_unpackl (vector bool char);
16722 vector unsigned int vec_unpackl (vector pixel);
16723 vector signed int vec_unpackl (vector signed short);
16724 vector bool int vec_unpackl (vector bool short);
16725
16726 vector unsigned int vec_vupklpx (vector pixel);
16727
16728 vector bool int vec_vupklsh (vector bool short);
16729 vector signed int vec_vupklsh (vector signed short);
16730
16731 vector bool short vec_vupklsb (vector bool char);
16732 vector signed short vec_vupklsb (vector signed char);
16733
16734 vector float vec_xor (vector float, vector float);
16735 vector float vec_xor (vector float, vector bool int);
16736 vector float vec_xor (vector bool int, vector float);
16737 vector bool int vec_xor (vector bool int, vector bool int);
16738 vector signed int vec_xor (vector bool int, vector signed int);
16739 vector signed int vec_xor (vector signed int, vector bool int);
16740 vector signed int vec_xor (vector signed int, vector signed int);
16741 vector unsigned int vec_xor (vector bool int, vector unsigned int);
16742 vector unsigned int vec_xor (vector unsigned int, vector bool int);
16743 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
16744 vector bool short vec_xor (vector bool short, vector bool short);
16745 vector signed short vec_xor (vector bool short, vector signed short);
16746 vector signed short vec_xor (vector signed short, vector bool short);
16747 vector signed short vec_xor (vector signed short, vector signed short);
16748 vector unsigned short vec_xor (vector bool short,
16749 vector unsigned short);
16750 vector unsigned short vec_xor (vector unsigned short,
16751 vector bool short);
16752 vector unsigned short vec_xor (vector unsigned short,
16753 vector unsigned short);
16754 vector signed char vec_xor (vector bool char, vector signed char);
16755 vector bool char vec_xor (vector bool char, vector bool char);
16756 vector signed char vec_xor (vector signed char, vector bool char);
16757 vector signed char vec_xor (vector signed char, vector signed char);
16758 vector unsigned char vec_xor (vector bool char, vector unsigned char);
16759 vector unsigned char vec_xor (vector unsigned char, vector bool char);
16760 vector unsigned char vec_xor (vector unsigned char,
16761 vector unsigned char);
16762
16763 int vec_all_eq (vector signed char, vector bool char);
16764 int vec_all_eq (vector signed char, vector signed char);
16765 int vec_all_eq (vector unsigned char, vector bool char);
16766 int vec_all_eq (vector unsigned char, vector unsigned char);
16767 int vec_all_eq (vector bool char, vector bool char);
16768 int vec_all_eq (vector bool char, vector unsigned char);
16769 int vec_all_eq (vector bool char, vector signed char);
16770 int vec_all_eq (vector signed short, vector bool short);
16771 int vec_all_eq (vector signed short, vector signed short);
16772 int vec_all_eq (vector unsigned short, vector bool short);
16773 int vec_all_eq (vector unsigned short, vector unsigned short);
16774 int vec_all_eq (vector bool short, vector bool short);
16775 int vec_all_eq (vector bool short, vector unsigned short);
16776 int vec_all_eq (vector bool short, vector signed short);
16777 int vec_all_eq (vector pixel, vector pixel);
16778 int vec_all_eq (vector signed int, vector bool int);
16779 int vec_all_eq (vector signed int, vector signed int);
16780 int vec_all_eq (vector unsigned int, vector bool int);
16781 int vec_all_eq (vector unsigned int, vector unsigned int);
16782 int vec_all_eq (vector bool int, vector bool int);
16783 int vec_all_eq (vector bool int, vector unsigned int);
16784 int vec_all_eq (vector bool int, vector signed int);
16785 int vec_all_eq (vector float, vector float);
16786
16787 int vec_all_ge (vector bool char, vector unsigned char);
16788 int vec_all_ge (vector unsigned char, vector bool char);
16789 int vec_all_ge (vector unsigned char, vector unsigned char);
16790 int vec_all_ge (vector bool char, vector signed char);
16791 int vec_all_ge (vector signed char, vector bool char);
16792 int vec_all_ge (vector signed char, vector signed char);
16793 int vec_all_ge (vector bool short, vector unsigned short);
16794 int vec_all_ge (vector unsigned short, vector bool short);
16795 int vec_all_ge (vector unsigned short, vector unsigned short);
16796 int vec_all_ge (vector signed short, vector signed short);
16797 int vec_all_ge (vector bool short, vector signed short);
16798 int vec_all_ge (vector signed short, vector bool short);
16799 int vec_all_ge (vector bool int, vector unsigned int);
16800 int vec_all_ge (vector unsigned int, vector bool int);
16801 int vec_all_ge (vector unsigned int, vector unsigned int);
16802 int vec_all_ge (vector bool int, vector signed int);
16803 int vec_all_ge (vector signed int, vector bool int);
16804 int vec_all_ge (vector signed int, vector signed int);
16805 int vec_all_ge (vector float, vector float);
16806
16807 int vec_all_gt (vector bool char, vector unsigned char);
16808 int vec_all_gt (vector unsigned char, vector bool char);
16809 int vec_all_gt (vector unsigned char, vector unsigned char);
16810 int vec_all_gt (vector bool char, vector signed char);
16811 int vec_all_gt (vector signed char, vector bool char);
16812 int vec_all_gt (vector signed char, vector signed char);
16813 int vec_all_gt (vector bool short, vector unsigned short);
16814 int vec_all_gt (vector unsigned short, vector bool short);
16815 int vec_all_gt (vector unsigned short, vector unsigned short);
16816 int vec_all_gt (vector bool short, vector signed short);
16817 int vec_all_gt (vector signed short, vector bool short);
16818 int vec_all_gt (vector signed short, vector signed short);
16819 int vec_all_gt (vector bool int, vector unsigned int);
16820 int vec_all_gt (vector unsigned int, vector bool int);
16821 int vec_all_gt (vector unsigned int, vector unsigned int);
16822 int vec_all_gt (vector bool int, vector signed int);
16823 int vec_all_gt (vector signed int, vector bool int);
16824 int vec_all_gt (vector signed int, vector signed int);
16825 int vec_all_gt (vector float, vector float);
16826
16827 int vec_all_in (vector float, vector float);
16828
16829 int vec_all_le (vector bool char, vector unsigned char);
16830 int vec_all_le (vector unsigned char, vector bool char);
16831 int vec_all_le (vector unsigned char, vector unsigned char);
16832 int vec_all_le (vector bool char, vector signed char);
16833 int vec_all_le (vector signed char, vector bool char);
16834 int vec_all_le (vector signed char, vector signed char);
16835 int vec_all_le (vector bool short, vector unsigned short);
16836 int vec_all_le (vector unsigned short, vector bool short);
16837 int vec_all_le (vector unsigned short, vector unsigned short);
16838 int vec_all_le (vector bool short, vector signed short);
16839 int vec_all_le (vector signed short, vector bool short);
16840 int vec_all_le (vector signed short, vector signed short);
16841 int vec_all_le (vector bool int, vector unsigned int);
16842 int vec_all_le (vector unsigned int, vector bool int);
16843 int vec_all_le (vector unsigned int, vector unsigned int);
16844 int vec_all_le (vector bool int, vector signed int);
16845 int vec_all_le (vector signed int, vector bool int);
16846 int vec_all_le (vector signed int, vector signed int);
16847 int vec_all_le (vector float, vector float);
16848
16849 int vec_all_lt (vector bool char, vector unsigned char);
16850 int vec_all_lt (vector unsigned char, vector bool char);
16851 int vec_all_lt (vector unsigned char, vector unsigned char);
16852 int vec_all_lt (vector bool char, vector signed char);
16853 int vec_all_lt (vector signed char, vector bool char);
16854 int vec_all_lt (vector signed char, vector signed char);
16855 int vec_all_lt (vector bool short, vector unsigned short);
16856 int vec_all_lt (vector unsigned short, vector bool short);
16857 int vec_all_lt (vector unsigned short, vector unsigned short);
16858 int vec_all_lt (vector bool short, vector signed short);
16859 int vec_all_lt (vector signed short, vector bool short);
16860 int vec_all_lt (vector signed short, vector signed short);
16861 int vec_all_lt (vector bool int, vector unsigned int);
16862 int vec_all_lt (vector unsigned int, vector bool int);
16863 int vec_all_lt (vector unsigned int, vector unsigned int);
16864 int vec_all_lt (vector bool int, vector signed int);
16865 int vec_all_lt (vector signed int, vector bool int);
16866 int vec_all_lt (vector signed int, vector signed int);
16867 int vec_all_lt (vector float, vector float);
16868
16869 int vec_all_nan (vector float);
16870
16871 int vec_all_ne (vector signed char, vector bool char);
16872 int vec_all_ne (vector signed char, vector signed char);
16873 int vec_all_ne (vector unsigned char, vector bool char);
16874 int vec_all_ne (vector unsigned char, vector unsigned char);
16875 int vec_all_ne (vector bool char, vector bool char);
16876 int vec_all_ne (vector bool char, vector unsigned char);
16877 int vec_all_ne (vector bool char, vector signed char);
16878 int vec_all_ne (vector signed short, vector bool short);
16879 int vec_all_ne (vector signed short, vector signed short);
16880 int vec_all_ne (vector unsigned short, vector bool short);
16881 int vec_all_ne (vector unsigned short, vector unsigned short);
16882 int vec_all_ne (vector bool short, vector bool short);
16883 int vec_all_ne (vector bool short, vector unsigned short);
16884 int vec_all_ne (vector bool short, vector signed short);
16885 int vec_all_ne (vector pixel, vector pixel);
16886 int vec_all_ne (vector signed int, vector bool int);
16887 int vec_all_ne (vector signed int, vector signed int);
16888 int vec_all_ne (vector unsigned int, vector bool int);
16889 int vec_all_ne (vector unsigned int, vector unsigned int);
16890 int vec_all_ne (vector bool int, vector bool int);
16891 int vec_all_ne (vector bool int, vector unsigned int);
16892 int vec_all_ne (vector bool int, vector signed int);
16893 int vec_all_ne (vector float, vector float);
16894
16895 int vec_all_nge (vector float, vector float);
16896
16897 int vec_all_ngt (vector float, vector float);
16898
16899 int vec_all_nle (vector float, vector float);
16900
16901 int vec_all_nlt (vector float, vector float);
16902
16903 int vec_all_numeric (vector float);
16904
16905 int vec_any_eq (vector signed char, vector bool char);
16906 int vec_any_eq (vector signed char, vector signed char);
16907 int vec_any_eq (vector unsigned char, vector bool char);
16908 int vec_any_eq (vector unsigned char, vector unsigned char);
16909 int vec_any_eq (vector bool char, vector bool char);
16910 int vec_any_eq (vector bool char, vector unsigned char);
16911 int vec_any_eq (vector bool char, vector signed char);
16912 int vec_any_eq (vector signed short, vector bool short);
16913 int vec_any_eq (vector signed short, vector signed short);
16914 int vec_any_eq (vector unsigned short, vector bool short);
16915 int vec_any_eq (vector unsigned short, vector unsigned short);
16916 int vec_any_eq (vector bool short, vector bool short);
16917 int vec_any_eq (vector bool short, vector unsigned short);
16918 int vec_any_eq (vector bool short, vector signed short);
16919 int vec_any_eq (vector pixel, vector pixel);
16920 int vec_any_eq (vector signed int, vector bool int);
16921 int vec_any_eq (vector signed int, vector signed int);
16922 int vec_any_eq (vector unsigned int, vector bool int);
16923 int vec_any_eq (vector unsigned int, vector unsigned int);
16924 int vec_any_eq (vector bool int, vector bool int);
16925 int vec_any_eq (vector bool int, vector unsigned int);
16926 int vec_any_eq (vector bool int, vector signed int);
16927 int vec_any_eq (vector float, vector float);
16928
16929 int vec_any_ge (vector signed char, vector bool char);
16930 int vec_any_ge (vector unsigned char, vector bool char);
16931 int vec_any_ge (vector unsigned char, vector unsigned char);
16932 int vec_any_ge (vector signed char, vector signed char);
16933 int vec_any_ge (vector bool char, vector unsigned char);
16934 int vec_any_ge (vector bool char, vector signed char);
16935 int vec_any_ge (vector unsigned short, vector bool short);
16936 int vec_any_ge (vector unsigned short, vector unsigned short);
16937 int vec_any_ge (vector signed short, vector signed short);
16938 int vec_any_ge (vector signed short, vector bool short);
16939 int vec_any_ge (vector bool short, vector unsigned short);
16940 int vec_any_ge (vector bool short, vector signed short);
16941 int vec_any_ge (vector signed int, vector bool int);
16942 int vec_any_ge (vector unsigned int, vector bool int);
16943 int vec_any_ge (vector unsigned int, vector unsigned int);
16944 int vec_any_ge (vector signed int, vector signed int);
16945 int vec_any_ge (vector bool int, vector unsigned int);
16946 int vec_any_ge (vector bool int, vector signed int);
16947 int vec_any_ge (vector float, vector float);
16948
16949 int vec_any_gt (vector bool char, vector unsigned char);
16950 int vec_any_gt (vector unsigned char, vector bool char);
16951 int vec_any_gt (vector unsigned char, vector unsigned char);
16952 int vec_any_gt (vector bool char, vector signed char);
16953 int vec_any_gt (vector signed char, vector bool char);
16954 int vec_any_gt (vector signed char, vector signed char);
16955 int vec_any_gt (vector bool short, vector unsigned short);
16956 int vec_any_gt (vector unsigned short, vector bool short);
16957 int vec_any_gt (vector unsigned short, vector unsigned short);
16958 int vec_any_gt (vector bool short, vector signed short);
16959 int vec_any_gt (vector signed short, vector bool short);
16960 int vec_any_gt (vector signed short, vector signed short);
16961 int vec_any_gt (vector bool int, vector unsigned int);
16962 int vec_any_gt (vector unsigned int, vector bool int);
16963 int vec_any_gt (vector unsigned int, vector unsigned int);
16964 int vec_any_gt (vector bool int, vector signed int);
16965 int vec_any_gt (vector signed int, vector bool int);
16966 int vec_any_gt (vector signed int, vector signed int);
16967 int vec_any_gt (vector float, vector float);
16968
16969 int vec_any_le (vector bool char, vector unsigned char);
16970 int vec_any_le (vector unsigned char, vector bool char);
16971 int vec_any_le (vector unsigned char, vector unsigned char);
16972 int vec_any_le (vector bool char, vector signed char);
16973 int vec_any_le (vector signed char, vector bool char);
16974 int vec_any_le (vector signed char, vector signed char);
16975 int vec_any_le (vector bool short, vector unsigned short);
16976 int vec_any_le (vector unsigned short, vector bool short);
16977 int vec_any_le (vector unsigned short, vector unsigned short);
16978 int vec_any_le (vector bool short, vector signed short);
16979 int vec_any_le (vector signed short, vector bool short);
16980 int vec_any_le (vector signed short, vector signed short);
16981 int vec_any_le (vector bool int, vector unsigned int);
16982 int vec_any_le (vector unsigned int, vector bool int);
16983 int vec_any_le (vector unsigned int, vector unsigned int);
16984 int vec_any_le (vector bool int, vector signed int);
16985 int vec_any_le (vector signed int, vector bool int);
16986 int vec_any_le (vector signed int, vector signed int);
16987 int vec_any_le (vector float, vector float);
16988
16989 int vec_any_lt (vector bool char, vector unsigned char);
16990 int vec_any_lt (vector unsigned char, vector bool char);
16991 int vec_any_lt (vector unsigned char, vector unsigned char);
16992 int vec_any_lt (vector bool char, vector signed char);
16993 int vec_any_lt (vector signed char, vector bool char);
16994 int vec_any_lt (vector signed char, vector signed char);
16995 int vec_any_lt (vector bool short, vector unsigned short);
16996 int vec_any_lt (vector unsigned short, vector bool short);
16997 int vec_any_lt (vector unsigned short, vector unsigned short);
16998 int vec_any_lt (vector bool short, vector signed short);
16999 int vec_any_lt (vector signed short, vector bool short);
17000 int vec_any_lt (vector signed short, vector signed short);
17001 int vec_any_lt (vector bool int, vector unsigned int);
17002 int vec_any_lt (vector unsigned int, vector bool int);
17003 int vec_any_lt (vector unsigned int, vector unsigned int);
17004 int vec_any_lt (vector bool int, vector signed int);
17005 int vec_any_lt (vector signed int, vector bool int);
17006 int vec_any_lt (vector signed int, vector signed int);
17007 int vec_any_lt (vector float, vector float);
17008
17009 int vec_any_nan (vector float);
17010
17011 int vec_any_ne (vector signed char, vector bool char);
17012 int vec_any_ne (vector signed char, vector signed char);
17013 int vec_any_ne (vector unsigned char, vector bool char);
17014 int vec_any_ne (vector unsigned char, vector unsigned char);
17015 int vec_any_ne (vector bool char, vector bool char);
17016 int vec_any_ne (vector bool char, vector unsigned char);
17017 int vec_any_ne (vector bool char, vector signed char);
17018 int vec_any_ne (vector signed short, vector bool short);
17019 int vec_any_ne (vector signed short, vector signed short);
17020 int vec_any_ne (vector unsigned short, vector bool short);
17021 int vec_any_ne (vector unsigned short, vector unsigned short);
17022 int vec_any_ne (vector bool short, vector bool short);
17023 int vec_any_ne (vector bool short, vector unsigned short);
17024 int vec_any_ne (vector bool short, vector signed short);
17025 int vec_any_ne (vector pixel, vector pixel);
17026 int vec_any_ne (vector signed int, vector bool int);
17027 int vec_any_ne (vector signed int, vector signed int);
17028 int vec_any_ne (vector unsigned int, vector bool int);
17029 int vec_any_ne (vector unsigned int, vector unsigned int);
17030 int vec_any_ne (vector bool int, vector bool int);
17031 int vec_any_ne (vector bool int, vector unsigned int);
17032 int vec_any_ne (vector bool int, vector signed int);
17033 int vec_any_ne (vector float, vector float);
17034
17035 int vec_any_nge (vector float, vector float);
17036
17037 int vec_any_ngt (vector float, vector float);
17038
17039 int vec_any_nle (vector float, vector float);
17040
17041 int vec_any_nlt (vector float, vector float);
17042
17043 int vec_any_numeric (vector float);
17044
17045 int vec_any_out (vector float, vector float);
17046 @end smallexample
17047
17048 If the vector/scalar (VSX) instruction set is available, the following
17049 additional functions are available:
17050
17051 @smallexample
17052 vector double vec_abs (vector double);
17053 vector double vec_add (vector double, vector double);
17054 vector double vec_and (vector double, vector double);
17055 vector double vec_and (vector double, vector bool long);
17056 vector double vec_and (vector bool long, vector double);
17057 vector long vec_and (vector long, vector long);
17058 vector long vec_and (vector long, vector bool long);
17059 vector long vec_and (vector bool long, vector long);
17060 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17061 vector unsigned long vec_and (vector unsigned long, vector bool long);
17062 vector unsigned long vec_and (vector bool long, vector unsigned long);
17063 vector double vec_andc (vector double, vector double);
17064 vector double vec_andc (vector double, vector bool long);
17065 vector double vec_andc (vector bool long, vector double);
17066 vector long vec_andc (vector long, vector long);
17067 vector long vec_andc (vector long, vector bool long);
17068 vector long vec_andc (vector bool long, vector long);
17069 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17070 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17071 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17072 vector double vec_ceil (vector double);
17073 vector bool long vec_cmpeq (vector double, vector double);
17074 vector bool long vec_cmpge (vector double, vector double);
17075 vector bool long vec_cmpgt (vector double, vector double);
17076 vector bool long vec_cmple (vector double, vector double);
17077 vector bool long vec_cmplt (vector double, vector double);
17078 vector double vec_cpsgn (vector double, vector double);
17079 vector float vec_div (vector float, vector float);
17080 vector double vec_div (vector double, vector double);
17081 vector long vec_div (vector long, vector long);
17082 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17083 vector double vec_floor (vector double);
17084 vector double vec_ld (int, const vector double *);
17085 vector double vec_ld (int, const double *);
17086 vector double vec_ldl (int, const vector double *);
17087 vector double vec_ldl (int, const double *);
17088 vector unsigned char vec_lvsl (int, const volatile double *);
17089 vector unsigned char vec_lvsr (int, const volatile double *);
17090 vector double vec_madd (vector double, vector double, vector double);
17091 vector double vec_max (vector double, vector double);
17092 vector signed long vec_mergeh (vector signed long, vector signed long);
17093 vector signed long vec_mergeh (vector signed long, vector bool long);
17094 vector signed long vec_mergeh (vector bool long, vector signed long);
17095 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17096 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17097 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17098 vector signed long vec_mergel (vector signed long, vector signed long);
17099 vector signed long vec_mergel (vector signed long, vector bool long);
17100 vector signed long vec_mergel (vector bool long, vector signed long);
17101 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17102 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17103 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17104 vector double vec_min (vector double, vector double);
17105 vector float vec_msub (vector float, vector float, vector float);
17106 vector double vec_msub (vector double, vector double, vector double);
17107 vector float vec_mul (vector float, vector float);
17108 vector double vec_mul (vector double, vector double);
17109 vector long vec_mul (vector long, vector long);
17110 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17111 vector float vec_nearbyint (vector float);
17112 vector double vec_nearbyint (vector double);
17113 vector float vec_nmadd (vector float, vector float, vector float);
17114 vector double vec_nmadd (vector double, vector double, vector double);
17115 vector double vec_nmsub (vector double, vector double, vector double);
17116 vector double vec_nor (vector double, vector double);
17117 vector long vec_nor (vector long, vector long);
17118 vector long vec_nor (vector long, vector bool long);
17119 vector long vec_nor (vector bool long, vector long);
17120 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17121 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17122 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17123 vector double vec_or (vector double, vector double);
17124 vector double vec_or (vector double, vector bool long);
17125 vector double vec_or (vector bool long, vector double);
17126 vector long vec_or (vector long, vector long);
17127 vector long vec_or (vector long, vector bool long);
17128 vector long vec_or (vector bool long, vector long);
17129 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17130 vector unsigned long vec_or (vector unsigned long, vector bool long);
17131 vector unsigned long vec_or (vector bool long, vector unsigned long);
17132 vector double vec_perm (vector double, vector double, vector unsigned char);
17133 vector long vec_perm (vector long, vector long, vector unsigned char);
17134 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17135 vector unsigned char);
17136 vector double vec_rint (vector double);
17137 vector double vec_recip (vector double, vector double);
17138 vector double vec_rsqrt (vector double);
17139 vector double vec_rsqrte (vector double);
17140 vector double vec_sel (vector double, vector double, vector bool long);
17141 vector double vec_sel (vector double, vector double, vector unsigned long);
17142 vector long vec_sel (vector long, vector long, vector long);
17143 vector long vec_sel (vector long, vector long, vector unsigned long);
17144 vector long vec_sel (vector long, vector long, vector bool long);
17145 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17146 vector long);
17147 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17148 vector unsigned long);
17149 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17150 vector bool long);
17151 vector double vec_splats (double);
17152 vector signed long vec_splats (signed long);
17153 vector unsigned long vec_splats (unsigned long);
17154 vector float vec_sqrt (vector float);
17155 vector double vec_sqrt (vector double);
17156 void vec_st (vector double, int, vector double *);
17157 void vec_st (vector double, int, double *);
17158 vector double vec_sub (vector double, vector double);
17159 vector double vec_trunc (vector double);
17160 vector double vec_xl (int, vector double *);
17161 vector double vec_xl (int, double *);
17162 vector long long vec_xl (int, vector long long *);
17163 vector long long vec_xl (int, long long *);
17164 vector unsigned long long vec_xl (int, vector unsigned long long *);
17165 vector unsigned long long vec_xl (int, unsigned long long *);
17166 vector float vec_xl (int, vector float *);
17167 vector float vec_xl (int, float *);
17168 vector int vec_xl (int, vector int *);
17169 vector int vec_xl (int, int *);
17170 vector unsigned int vec_xl (int, vector unsigned int *);
17171 vector unsigned int vec_xl (int, unsigned int *);
17172 vector double vec_xor (vector double, vector double);
17173 vector double vec_xor (vector double, vector bool long);
17174 vector double vec_xor (vector bool long, vector double);
17175 vector long vec_xor (vector long, vector long);
17176 vector long vec_xor (vector long, vector bool long);
17177 vector long vec_xor (vector bool long, vector long);
17178 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17179 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17180 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17181 void vec_xst (vector double, int, vector double *);
17182 void vec_xst (vector double, int, double *);
17183 void vec_xst (vector long long, int, vector long long *);
17184 void vec_xst (vector long long, int, long long *);
17185 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17186 void vec_xst (vector unsigned long long, int, unsigned long long *);
17187 void vec_xst (vector float, int, vector float *);
17188 void vec_xst (vector float, int, float *);
17189 void vec_xst (vector int, int, vector int *);
17190 void vec_xst (vector int, int, int *);
17191 void vec_xst (vector unsigned int, int, vector unsigned int *);
17192 void vec_xst (vector unsigned int, int, unsigned int *);
17193 int vec_all_eq (vector double, vector double);
17194 int vec_all_ge (vector double, vector double);
17195 int vec_all_gt (vector double, vector double);
17196 int vec_all_le (vector double, vector double);
17197 int vec_all_lt (vector double, vector double);
17198 int vec_all_nan (vector double);
17199 int vec_all_ne (vector double, vector double);
17200 int vec_all_nge (vector double, vector double);
17201 int vec_all_ngt (vector double, vector double);
17202 int vec_all_nle (vector double, vector double);
17203 int vec_all_nlt (vector double, vector double);
17204 int vec_all_numeric (vector double);
17205 int vec_any_eq (vector double, vector double);
17206 int vec_any_ge (vector double, vector double);
17207 int vec_any_gt (vector double, vector double);
17208 int vec_any_le (vector double, vector double);
17209 int vec_any_lt (vector double, vector double);
17210 int vec_any_nan (vector double);
17211 int vec_any_ne (vector double, vector double);
17212 int vec_any_nge (vector double, vector double);
17213 int vec_any_ngt (vector double, vector double);
17214 int vec_any_nle (vector double, vector double);
17215 int vec_any_nlt (vector double, vector double);
17216 int vec_any_numeric (vector double);
17217
17218 vector double vec_vsx_ld (int, const vector double *);
17219 vector double vec_vsx_ld (int, const double *);
17220 vector float vec_vsx_ld (int, const vector float *);
17221 vector float vec_vsx_ld (int, const float *);
17222 vector bool int vec_vsx_ld (int, const vector bool int *);
17223 vector signed int vec_vsx_ld (int, const vector signed int *);
17224 vector signed int vec_vsx_ld (int, const int *);
17225 vector signed int vec_vsx_ld (int, const long *);
17226 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17227 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17228 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17229 vector bool short vec_vsx_ld (int, const vector bool short *);
17230 vector pixel vec_vsx_ld (int, const vector pixel *);
17231 vector signed short vec_vsx_ld (int, const vector signed short *);
17232 vector signed short vec_vsx_ld (int, const short *);
17233 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17234 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17235 vector bool char vec_vsx_ld (int, const vector bool char *);
17236 vector signed char vec_vsx_ld (int, const vector signed char *);
17237 vector signed char vec_vsx_ld (int, const signed char *);
17238 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17239 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17240
17241 void vec_vsx_st (vector double, int, vector double *);
17242 void vec_vsx_st (vector double, int, double *);
17243 void vec_vsx_st (vector float, int, vector float *);
17244 void vec_vsx_st (vector float, int, float *);
17245 void vec_vsx_st (vector signed int, int, vector signed int *);
17246 void vec_vsx_st (vector signed int, int, int *);
17247 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17248 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17249 void vec_vsx_st (vector bool int, int, vector bool int *);
17250 void vec_vsx_st (vector bool int, int, unsigned int *);
17251 void vec_vsx_st (vector bool int, int, int *);
17252 void vec_vsx_st (vector signed short, int, vector signed short *);
17253 void vec_vsx_st (vector signed short, int, short *);
17254 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17255 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17256 void vec_vsx_st (vector bool short, int, vector bool short *);
17257 void vec_vsx_st (vector bool short, int, unsigned short *);
17258 void vec_vsx_st (vector pixel, int, vector pixel *);
17259 void vec_vsx_st (vector pixel, int, unsigned short *);
17260 void vec_vsx_st (vector pixel, int, short *);
17261 void vec_vsx_st (vector bool short, int, short *);
17262 void vec_vsx_st (vector signed char, int, vector signed char *);
17263 void vec_vsx_st (vector signed char, int, signed char *);
17264 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17265 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17266 void vec_vsx_st (vector bool char, int, vector bool char *);
17267 void vec_vsx_st (vector bool char, int, unsigned char *);
17268 void vec_vsx_st (vector bool char, int, signed char *);
17269
17270 vector double vec_xxpermdi (vector double, vector double, int);
17271 vector float vec_xxpermdi (vector float, vector float, int);
17272 vector long long vec_xxpermdi (vector long long, vector long long, int);
17273 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17274 vector unsigned long long, int);
17275 vector int vec_xxpermdi (vector int, vector int, int);
17276 vector unsigned int vec_xxpermdi (vector unsigned int,
17277 vector unsigned int, int);
17278 vector short vec_xxpermdi (vector short, vector short, int);
17279 vector unsigned short vec_xxpermdi (vector unsigned short,
17280 vector unsigned short, int);
17281 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
17282 vector unsigned char vec_xxpermdi (vector unsigned char,
17283 vector unsigned char, int);
17284
17285 vector double vec_xxsldi (vector double, vector double, int);
17286 vector float vec_xxsldi (vector float, vector float, int);
17287 vector long long vec_xxsldi (vector long long, vector long long, int);
17288 vector unsigned long long vec_xxsldi (vector unsigned long long,
17289 vector unsigned long long, int);
17290 vector int vec_xxsldi (vector int, vector int, int);
17291 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17292 vector short vec_xxsldi (vector short, vector short, int);
17293 vector unsigned short vec_xxsldi (vector unsigned short,
17294 vector unsigned short, int);
17295 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17296 vector unsigned char vec_xxsldi (vector unsigned char,
17297 vector unsigned char, int);
17298 @end smallexample
17299
17300 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17301 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17302 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
17303 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17304 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17305
17306 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17307 instruction set are available, the following additional functions are
17308 available for both 32-bit and 64-bit targets. For 64-bit targets, you
17309 can use @var{vector long} instead of @var{vector long long},
17310 @var{vector bool long} instead of @var{vector bool long long}, and
17311 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17312
17313 @smallexample
17314 vector long long vec_abs (vector long long);
17315
17316 vector long long vec_add (vector long long, vector long long);
17317 vector unsigned long long vec_add (vector unsigned long long,
17318 vector unsigned long long);
17319
17320 int vec_all_eq (vector long long, vector long long);
17321 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17322 int vec_all_ge (vector long long, vector long long);
17323 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17324 int vec_all_gt (vector long long, vector long long);
17325 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17326 int vec_all_le (vector long long, vector long long);
17327 int vec_all_le (vector unsigned long long, vector unsigned long long);
17328 int vec_all_lt (vector long long, vector long long);
17329 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17330 int vec_all_ne (vector long long, vector long long);
17331 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17332
17333 int vec_any_eq (vector long long, vector long long);
17334 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17335 int vec_any_ge (vector long long, vector long long);
17336 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17337 int vec_any_gt (vector long long, vector long long);
17338 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17339 int vec_any_le (vector long long, vector long long);
17340 int vec_any_le (vector unsigned long long, vector unsigned long long);
17341 int vec_any_lt (vector long long, vector long long);
17342 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17343 int vec_any_ne (vector long long, vector long long);
17344 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17345
17346 vector long long vec_eqv (vector long long, vector long long);
17347 vector long long vec_eqv (vector bool long long, vector long long);
17348 vector long long vec_eqv (vector long long, vector bool long long);
17349 vector unsigned long long vec_eqv (vector unsigned long long,
17350 vector unsigned long long);
17351 vector unsigned long long vec_eqv (vector bool long long,
17352 vector unsigned long long);
17353 vector unsigned long long vec_eqv (vector unsigned long long,
17354 vector bool long long);
17355 vector int vec_eqv (vector int, vector int);
17356 vector int vec_eqv (vector bool int, vector int);
17357 vector int vec_eqv (vector int, vector bool int);
17358 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17359 vector unsigned int vec_eqv (vector bool unsigned int,
17360 vector unsigned int);
17361 vector unsigned int vec_eqv (vector unsigned int,
17362 vector bool unsigned int);
17363 vector short vec_eqv (vector short, vector short);
17364 vector short vec_eqv (vector bool short, vector short);
17365 vector short vec_eqv (vector short, vector bool short);
17366 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17367 vector unsigned short vec_eqv (vector bool unsigned short,
17368 vector unsigned short);
17369 vector unsigned short vec_eqv (vector unsigned short,
17370 vector bool unsigned short);
17371 vector signed char vec_eqv (vector signed char, vector signed char);
17372 vector signed char vec_eqv (vector bool signed char, vector signed char);
17373 vector signed char vec_eqv (vector signed char, vector bool signed char);
17374 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17375 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17376 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17377
17378 vector long long vec_max (vector long long, vector long long);
17379 vector unsigned long long vec_max (vector unsigned long long,
17380 vector unsigned long long);
17381
17382 vector signed int vec_mergee (vector signed int, vector signed int);
17383 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17384 vector bool int vec_mergee (vector bool int, vector bool int);
17385
17386 vector signed int vec_mergeo (vector signed int, vector signed int);
17387 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17388 vector bool int vec_mergeo (vector bool int, vector bool int);
17389
17390 vector long long vec_min (vector long long, vector long long);
17391 vector unsigned long long vec_min (vector unsigned long long,
17392 vector unsigned long long);
17393
17394 vector long long vec_nand (vector long long, vector long long);
17395 vector long long vec_nand (vector bool long long, vector long long);
17396 vector long long vec_nand (vector long long, vector bool long long);
17397 vector unsigned long long vec_nand (vector unsigned long long,
17398 vector unsigned long long);
17399 vector unsigned long long vec_nand (vector bool long long,
17400 vector unsigned long long);
17401 vector unsigned long long vec_nand (vector unsigned long long,
17402 vector bool long long);
17403 vector int vec_nand (vector int, vector int);
17404 vector int vec_nand (vector bool int, vector int);
17405 vector int vec_nand (vector int, vector bool int);
17406 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17407 vector unsigned int vec_nand (vector bool unsigned int,
17408 vector unsigned int);
17409 vector unsigned int vec_nand (vector unsigned int,
17410 vector bool unsigned int);
17411 vector short vec_nand (vector short, vector short);
17412 vector short vec_nand (vector bool short, vector short);
17413 vector short vec_nand (vector short, vector bool short);
17414 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17415 vector unsigned short vec_nand (vector bool unsigned short,
17416 vector unsigned short);
17417 vector unsigned short vec_nand (vector unsigned short,
17418 vector bool unsigned short);
17419 vector signed char vec_nand (vector signed char, vector signed char);
17420 vector signed char vec_nand (vector bool signed char, vector signed char);
17421 vector signed char vec_nand (vector signed char, vector bool signed char);
17422 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17423 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17424 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17425
17426 vector long long vec_orc (vector long long, vector long long);
17427 vector long long vec_orc (vector bool long long, vector long long);
17428 vector long long vec_orc (vector long long, vector bool long long);
17429 vector unsigned long long vec_orc (vector unsigned long long,
17430 vector unsigned long long);
17431 vector unsigned long long vec_orc (vector bool long long,
17432 vector unsigned long long);
17433 vector unsigned long long vec_orc (vector unsigned long long,
17434 vector bool long long);
17435 vector int vec_orc (vector int, vector int);
17436 vector int vec_orc (vector bool int, vector int);
17437 vector int vec_orc (vector int, vector bool int);
17438 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17439 vector unsigned int vec_orc (vector bool unsigned int,
17440 vector unsigned int);
17441 vector unsigned int vec_orc (vector unsigned int,
17442 vector bool unsigned int);
17443 vector short vec_orc (vector short, vector short);
17444 vector short vec_orc (vector bool short, vector short);
17445 vector short vec_orc (vector short, vector bool short);
17446 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17447 vector unsigned short vec_orc (vector bool unsigned short,
17448 vector unsigned short);
17449 vector unsigned short vec_orc (vector unsigned short,
17450 vector bool unsigned short);
17451 vector signed char vec_orc (vector signed char, vector signed char);
17452 vector signed char vec_orc (vector bool signed char, vector signed char);
17453 vector signed char vec_orc (vector signed char, vector bool signed char);
17454 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17455 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17456 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17457
17458 vector int vec_pack (vector long long, vector long long);
17459 vector unsigned int vec_pack (vector unsigned long long,
17460 vector unsigned long long);
17461 vector bool int vec_pack (vector bool long long, vector bool long long);
17462
17463 vector int vec_packs (vector long long, vector long long);
17464 vector unsigned int vec_packs (vector unsigned long long,
17465 vector unsigned long long);
17466
17467 vector unsigned int vec_packsu (vector long long, vector long long);
17468 vector unsigned int vec_packsu (vector unsigned long long,
17469 vector unsigned long long);
17470
17471 vector long long vec_rl (vector long long,
17472 vector unsigned long long);
17473 vector long long vec_rl (vector unsigned long long,
17474 vector unsigned long long);
17475
17476 vector long long vec_sl (vector long long, vector unsigned long long);
17477 vector long long vec_sl (vector unsigned long long,
17478 vector unsigned long long);
17479
17480 vector long long vec_sr (vector long long, vector unsigned long long);
17481 vector unsigned long long char vec_sr (vector unsigned long long,
17482 vector unsigned long long);
17483
17484 vector long long vec_sra (vector long long, vector unsigned long long);
17485 vector unsigned long long vec_sra (vector unsigned long long,
17486 vector unsigned long long);
17487
17488 vector long long vec_sub (vector long long, vector long long);
17489 vector unsigned long long vec_sub (vector unsigned long long,
17490 vector unsigned long long);
17491
17492 vector long long vec_unpackh (vector int);
17493 vector unsigned long long vec_unpackh (vector unsigned int);
17494
17495 vector long long vec_unpackl (vector int);
17496 vector unsigned long long vec_unpackl (vector unsigned int);
17497
17498 vector long long vec_vaddudm (vector long long, vector long long);
17499 vector long long vec_vaddudm (vector bool long long, vector long long);
17500 vector long long vec_vaddudm (vector long long, vector bool long long);
17501 vector unsigned long long vec_vaddudm (vector unsigned long long,
17502 vector unsigned long long);
17503 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17504 vector unsigned long long);
17505 vector unsigned long long vec_vaddudm (vector unsigned long long,
17506 vector bool unsigned long long);
17507
17508 vector long long vec_vbpermq (vector signed char, vector signed char);
17509 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17510
17511 vector long long vec_cntlz (vector long long);
17512 vector unsigned long long vec_cntlz (vector unsigned long long);
17513 vector int vec_cntlz (vector int);
17514 vector unsigned int vec_cntlz (vector int);
17515 vector short vec_cntlz (vector short);
17516 vector unsigned short vec_cntlz (vector unsigned short);
17517 vector signed char vec_cntlz (vector signed char);
17518 vector unsigned char vec_cntlz (vector unsigned char);
17519
17520 vector long long vec_vclz (vector long long);
17521 vector unsigned long long vec_vclz (vector unsigned long long);
17522 vector int vec_vclz (vector int);
17523 vector unsigned int vec_vclz (vector int);
17524 vector short vec_vclz (vector short);
17525 vector unsigned short vec_vclz (vector unsigned short);
17526 vector signed char vec_vclz (vector signed char);
17527 vector unsigned char vec_vclz (vector unsigned char);
17528
17529 vector signed char vec_vclzb (vector signed char);
17530 vector unsigned char vec_vclzb (vector unsigned char);
17531
17532 vector long long vec_vclzd (vector long long);
17533 vector unsigned long long vec_vclzd (vector unsigned long long);
17534
17535 vector short vec_vclzh (vector short);
17536 vector unsigned short vec_vclzh (vector unsigned short);
17537
17538 vector int vec_vclzw (vector int);
17539 vector unsigned int vec_vclzw (vector int);
17540
17541 vector signed char vec_vgbbd (vector signed char);
17542 vector unsigned char vec_vgbbd (vector unsigned char);
17543
17544 vector long long vec_vmaxsd (vector long long, vector long long);
17545
17546 vector unsigned long long vec_vmaxud (vector unsigned long long,
17547 unsigned vector long long);
17548
17549 vector long long vec_vminsd (vector long long, vector long long);
17550
17551 vector unsigned long long vec_vminud (vector long long,
17552 vector long long);
17553
17554 vector int vec_vpksdss (vector long long, vector long long);
17555 vector unsigned int vec_vpksdss (vector long long, vector long long);
17556
17557 vector unsigned int vec_vpkudus (vector unsigned long long,
17558 vector unsigned long long);
17559
17560 vector int vec_vpkudum (vector long long, vector long long);
17561 vector unsigned int vec_vpkudum (vector unsigned long long,
17562 vector unsigned long long);
17563 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17564
17565 vector long long vec_vpopcnt (vector long long);
17566 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17567 vector int vec_vpopcnt (vector int);
17568 vector unsigned int vec_vpopcnt (vector int);
17569 vector short vec_vpopcnt (vector short);
17570 vector unsigned short vec_vpopcnt (vector unsigned short);
17571 vector signed char vec_vpopcnt (vector signed char);
17572 vector unsigned char vec_vpopcnt (vector unsigned char);
17573
17574 vector signed char vec_vpopcntb (vector signed char);
17575 vector unsigned char vec_vpopcntb (vector unsigned char);
17576
17577 vector long long vec_vpopcntd (vector long long);
17578 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17579
17580 vector short vec_vpopcnth (vector short);
17581 vector unsigned short vec_vpopcnth (vector unsigned short);
17582
17583 vector int vec_vpopcntw (vector int);
17584 vector unsigned int vec_vpopcntw (vector int);
17585
17586 vector long long vec_vrld (vector long long, vector unsigned long long);
17587 vector unsigned long long vec_vrld (vector unsigned long long,
17588 vector unsigned long long);
17589
17590 vector long long vec_vsld (vector long long, vector unsigned long long);
17591 vector long long vec_vsld (vector unsigned long long,
17592 vector unsigned long long);
17593
17594 vector long long vec_vsrad (vector long long, vector unsigned long long);
17595 vector unsigned long long vec_vsrad (vector unsigned long long,
17596 vector unsigned long long);
17597
17598 vector long long vec_vsrd (vector long long, vector unsigned long long);
17599 vector unsigned long long char vec_vsrd (vector unsigned long long,
17600 vector unsigned long long);
17601
17602 vector long long vec_vsubudm (vector long long, vector long long);
17603 vector long long vec_vsubudm (vector bool long long, vector long long);
17604 vector long long vec_vsubudm (vector long long, vector bool long long);
17605 vector unsigned long long vec_vsubudm (vector unsigned long long,
17606 vector unsigned long long);
17607 vector unsigned long long vec_vsubudm (vector bool long long,
17608 vector unsigned long long);
17609 vector unsigned long long vec_vsubudm (vector unsigned long long,
17610 vector bool long long);
17611
17612 vector long long vec_vupkhsw (vector int);
17613 vector unsigned long long vec_vupkhsw (vector unsigned int);
17614
17615 vector long long vec_vupklsw (vector int);
17616 vector unsigned long long vec_vupklsw (vector int);
17617 @end smallexample
17618
17619 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17620 instruction set are available, the following additional functions are
17621 available for 64-bit targets. New vector types
17622 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17623 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17624 builtins.
17625
17626 The normal vector extract, and set operations work on
17627 @var{vector __int128_t} and @var{vector __uint128_t} types,
17628 but the index value must be 0.
17629
17630 @smallexample
17631 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17632 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17633
17634 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17635 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17636
17637 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17638 vector __int128_t);
17639 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17640 vector __uint128_t);
17641
17642 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17643 vector __int128_t);
17644 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17645 vector __uint128_t);
17646
17647 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17648 vector __int128_t);
17649 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17650 vector __uint128_t);
17651
17652 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
17653 vector __int128_t);
17654 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
17655 vector __uint128_t);
17656
17657 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
17658 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
17659
17660 __int128_t vec_vsubuqm (__int128_t, __int128_t);
17661 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
17662
17663 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
17664 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
17665 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
17666 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
17667 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
17668 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
17669 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
17670 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
17671 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
17672 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
17673 @end smallexample
17674
17675 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
17676 are available:
17677
17678 @smallexample
17679 vector long long vec_vctz (vector long long);
17680 vector unsigned long long vec_vctz (vector unsigned long long);
17681 vector int vec_vctz (vector int);
17682 vector unsigned int vec_vctz (vector int);
17683 vector short vec_vctz (vector short);
17684 vector unsigned short vec_vctz (vector unsigned short);
17685 vector signed char vec_vctz (vector signed char);
17686 vector unsigned char vec_vctz (vector unsigned char);
17687
17688 vector signed char vec_vctzb (vector signed char);
17689 vector unsigned char vec_vctzb (vector unsigned char);
17690
17691 vector long long vec_vctzd (vector long long);
17692 vector unsigned long long vec_vctzd (vector unsigned long long);
17693
17694 vector short vec_vctzh (vector short);
17695 vector unsigned short vec_vctzh (vector unsigned short);
17696
17697 vector int vec_vctzw (vector int);
17698 vector unsigned int vec_vctzw (vector int);
17699
17700 vector int vec_vprtyb (vector int);
17701 vector unsigned int vec_vprtyb (vector unsigned int);
17702 vector long long vec_vprtyb (vector long long);
17703 vector unsigned long long vec_vprtyb (vector unsigned long long);
17704
17705 vector int vec_vprtybw (vector int);
17706 vector unsigned int vec_vprtybw (vector unsigned int);
17707
17708 vector long long vec_vprtybd (vector long long);
17709 vector unsigned long long vec_vprtybd (vector unsigned long long);
17710 @end smallexample
17711
17712 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
17713 are available:
17714
17715 @smallexample
17716 vector long vec_vprtyb (vector long);
17717 vector unsigned long vec_vprtyb (vector unsigned long);
17718 vector __int128_t vec_vprtyb (vector __int128_t);
17719 vector __uint128_t vec_vprtyb (vector __uint128_t);
17720
17721 vector long vec_vprtybd (vector long);
17722 vector unsigned long vec_vprtybd (vector unsigned long);
17723
17724 vector __int128_t vec_vprtybq (vector __int128_t);
17725 vector __uint128_t vec_vprtybd (vector __uint128_t);
17726 @end smallexample
17727
17728 The following built-in vector functions are available for the PowerPC family
17729 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17730 @smallexample
17731 __vector unsigned char
17732 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
17733 __vector unsigned char
17734 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
17735 @end smallexample
17736
17737 The @code{vec_slv} and @code{vec_srv} functions operate on
17738 all of the bytes of their @code{src} and @code{shift_distance}
17739 arguments in parallel. The behavior of the @code{vec_slv} is as if
17740 there existed a temporary array of 17 unsigned characters
17741 @code{slv_array} within which elements 0 through 15 are the same as
17742 the entries in the @code{src} array and element 16 equals 0. The
17743 result returned from the @code{vec_slv} function is a
17744 @code{__vector} of 16 unsigned characters within which element
17745 @code{i} is computed using the C expression
17746 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
17747 shift_distance[i]))},
17748 with this resulting value coerced to the @code{unsigned char} type.
17749 The behavior of the @code{vec_srv} is as if
17750 there existed a temporary array of 17 unsigned characters
17751 @code{srv_array} within which element 0 equals zero and
17752 elements 1 through 16 equal the elements 0 through 15 of
17753 the @code{src} array. The
17754 result returned from the @code{vec_srv} function is a
17755 @code{__vector} of 16 unsigned characters within which element
17756 @code{i} is computed using the C expression
17757 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
17758 (0x07 & shift_distance[i]))},
17759 with this resulting value coerced to the @code{unsigned char} type.
17760
17761 The following built-in functions are available for the PowerPC family
17762 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17763 @smallexample
17764 __vector unsigned char
17765 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
17766 __vector unsigned short
17767 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
17768 __vector unsigned int
17769 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
17770
17771 __vector unsigned char
17772 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
17773 __vector unsigned short
17774 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
17775 __vector unsigned int
17776 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
17777 @end smallexample
17778
17779 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
17780 @code{vec_absdw} built-in functions each computes the absolute
17781 differences of the pairs of vector elements supplied in its two vector
17782 arguments, placing the absolute differences into the corresponding
17783 elements of the vector result.
17784
17785 The following built-in functions are available for the PowerPC family
17786 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17787 @smallexample
17788 __vector int
17789 vec_extract_exp (__vector float source);
17790 __vector long long int
17791 vec_extract_exp (__vector double source);
17792
17793 __vector int
17794 vec_extract_sig (__vector float source);
17795 __vector long long int
17796 vec_extract_sig (__vector double source);
17797
17798 __vector float
17799 vec_insert_exp (__vector unsigned int significands, __vector unsigned int exponents);
17800 __vector double
17801 vec_insert_exp (__vector unsigned long long int significands,
17802 __vector unsigned long long int exponents);
17803
17804 __vector int vec_test_data_class (__vector float source, unsigned int condition);
17805 __vector long long int vec_test_data_class (__vector double source, unsigned int condition);
17806 @end smallexample
17807
17808 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
17809 functions return vectors representing the significands and exponents
17810 of their @code{source} arguments respectively. The
17811 @code{vec_insert_exp} built-in functions return a vector of single- or
17812 double-precision floating
17813 point values constructed by assembling the values of their
17814 @code{significands} and @code{exponents} arguments into the
17815 corresponding elements of the returned vector. The sign of each
17816 element of the result is copied from the most significant bit of the
17817 corresponding entry within the @code{significands} argument. The
17818 significand and exponent components of each element of the result are
17819 composed of the least significant bits of the corresponding
17820 @code{significands} element and the least significant bits of the
17821 corresponding @code{exponents} element.
17822
17823 The @code{vec_test_data_class} built-in function returns a vector
17824 representing the results of testing the @code{source} vector for the
17825 condition selected by the @code{condition} argument. The
17826 @code{condition} argument must be an unsigned integer with value not
17827 exceeding 127. The
17828 @code{condition} argument is encoded as a bitmask with each bit
17829 enabling the testing of a different condition, as characterized by the
17830 following:
17831 @smallexample
17832 0x40 Test for NaN
17833 0x20 Test for +Infinity
17834 0x10 Test for -Infinity
17835 0x08 Test for +Zero
17836 0x04 Test for -Zero
17837 0x02 Test for +Denormal
17838 0x01 Test for -Denormal
17839 @end smallexample
17840
17841 If any of the enabled test conditions is true, the corresponding entry
17842 in the result vector is -1. Otherwise (all of the enabled test
17843 conditions are false), the corresponding entry of the result vector is 0.
17844
17845 If the cryptographic instructions are enabled (@option{-mcrypto} or
17846 @option{-mcpu=power8}), the following builtins are enabled.
17847
17848 @smallexample
17849 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
17850
17851 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
17852 vector unsigned long long);
17853
17854 vector unsigned long long __builtin_crypto_vcipherlast
17855 (vector unsigned long long,
17856 vector unsigned long long);
17857
17858 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
17859 vector unsigned long long);
17860
17861 vector unsigned long long __builtin_crypto_vncipherlast
17862 (vector unsigned long long,
17863 vector unsigned long long);
17864
17865 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
17866 vector unsigned char,
17867 vector unsigned char);
17868
17869 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
17870 vector unsigned short,
17871 vector unsigned short);
17872
17873 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
17874 vector unsigned int,
17875 vector unsigned int);
17876
17877 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
17878 vector unsigned long long,
17879 vector unsigned long long);
17880
17881 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
17882 vector unsigned char);
17883
17884 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
17885 vector unsigned short);
17886
17887 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
17888 vector unsigned int);
17889
17890 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
17891 vector unsigned long long);
17892
17893 vector unsigned long long __builtin_crypto_vshasigmad
17894 (vector unsigned long long, int, int);
17895
17896 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
17897 int, int);
17898 @end smallexample
17899
17900 The second argument to the @var{__builtin_crypto_vshasigmad} and
17901 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
17902 integer that is 0 or 1. The third argument to these builtin functions
17903 must be a constant integer in the range of 0 to 15.
17904
17905 If the ISA 3.0 instruction set additions
17906 are enabled (@option{-mcpu=power9}), the following additional
17907 functions are available for both 32-bit and 64-bit targets.
17908
17909 vector short vec_xl (int, vector short *);
17910 vector short vec_xl (int, short *);
17911 vector unsigned short vec_xl (int, vector unsigned short *);
17912 vector unsigned short vec_xl (int, unsigned short *);
17913 vector char vec_xl (int, vector char *);
17914 vector char vec_xl (int, char *);
17915 vector unsigned char vec_xl (int, vector unsigned char *);
17916 vector unsigned char vec_xl (int, unsigned char *);
17917
17918 void vec_xst (vector short, int, vector short *);
17919 void vec_xst (vector short, int, short *);
17920 void vec_xst (vector unsigned short, int, vector unsigned short *);
17921 void vec_xst (vector unsigned short, int, unsigned short *);
17922 void vec_xst (vector char, int, vector char *);
17923 void vec_xst (vector char, int, char *);
17924 void vec_xst (vector unsigned char, int, vector unsigned char *);
17925 void vec_xst (vector unsigned char, int, unsigned char *);
17926
17927 @node PowerPC Hardware Transactional Memory Built-in Functions
17928 @subsection PowerPC Hardware Transactional Memory Built-in Functions
17929 GCC provides two interfaces for accessing the Hardware Transactional
17930 Memory (HTM) instructions available on some of the PowerPC family
17931 of processors (eg, POWER8). The two interfaces come in a low level
17932 interface, consisting of built-in functions specific to PowerPC and a
17933 higher level interface consisting of inline functions that are common
17934 between PowerPC and S/390.
17935
17936 @subsubsection PowerPC HTM Low Level Built-in Functions
17937
17938 The following low level built-in functions are available with
17939 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
17940 They all generate the machine instruction that is part of the name.
17941
17942 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
17943 the full 4-bit condition register value set by their associated hardware
17944 instruction. The header file @code{htmintrin.h} defines some macros that can
17945 be used to decipher the return value. The @code{__builtin_tbegin} builtin
17946 returns a simple true or false value depending on whether a transaction was
17947 successfully started or not. The arguments of the builtins match exactly the
17948 type and order of the associated hardware instruction's operands, except for
17949 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
17950 Refer to the ISA manual for a description of each instruction's operands.
17951
17952 @smallexample
17953 unsigned int __builtin_tbegin (unsigned int)
17954 unsigned int __builtin_tend (unsigned int)
17955
17956 unsigned int __builtin_tabort (unsigned int)
17957 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
17958 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
17959 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
17960 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
17961
17962 unsigned int __builtin_tcheck (void)
17963 unsigned int __builtin_treclaim (unsigned int)
17964 unsigned int __builtin_trechkpt (void)
17965 unsigned int __builtin_tsr (unsigned int)
17966 @end smallexample
17967
17968 In addition to the above HTM built-ins, we have added built-ins for
17969 some common extended mnemonics of the HTM instructions:
17970
17971 @smallexample
17972 unsigned int __builtin_tendall (void)
17973 unsigned int __builtin_tresume (void)
17974 unsigned int __builtin_tsuspend (void)
17975 @end smallexample
17976
17977 Note that the semantics of the above HTM builtins are required to mimic
17978 the locking semantics used for critical sections. Builtins that are used
17979 to create a new transaction or restart a suspended transaction must have
17980 lock acquisition like semantics while those builtins that end or suspend a
17981 transaction must have lock release like semantics. Specifically, this must
17982 mimic lock semantics as specified by C++11, for example: Lock acquisition is
17983 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
17984 that returns 0, and lock release is as-if an execution of
17985 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
17986 implicit implementation-defined lock used for all transactions. The HTM
17987 instructions associated with with the builtins inherently provide the
17988 correct acquisition and release hardware barriers required. However,
17989 the compiler must also be prohibited from moving loads and stores across
17990 the builtins in a way that would violate their semantics. This has been
17991 accomplished by adding memory barriers to the associated HTM instructions
17992 (which is a conservative approach to provide acquire and release semantics).
17993 Earlier versions of the compiler did not treat the HTM instructions as
17994 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
17995 be used to determine whether the current compiler treats HTM instructions
17996 as memory barriers or not. This allows the user to explicitly add memory
17997 barriers to their code when using an older version of the compiler.
17998
17999 The following set of built-in functions are available to gain access
18000 to the HTM specific special purpose registers.
18001
18002 @smallexample
18003 unsigned long __builtin_get_texasr (void)
18004 unsigned long __builtin_get_texasru (void)
18005 unsigned long __builtin_get_tfhar (void)
18006 unsigned long __builtin_get_tfiar (void)
18007
18008 void __builtin_set_texasr (unsigned long);
18009 void __builtin_set_texasru (unsigned long);
18010 void __builtin_set_tfhar (unsigned long);
18011 void __builtin_set_tfiar (unsigned long);
18012 @end smallexample
18013
18014 Example usage of these low level built-in functions may look like:
18015
18016 @smallexample
18017 #include <htmintrin.h>
18018
18019 int num_retries = 10;
18020
18021 while (1)
18022 @{
18023 if (__builtin_tbegin (0))
18024 @{
18025 /* Transaction State Initiated. */
18026 if (is_locked (lock))
18027 __builtin_tabort (0);
18028 ... transaction code...
18029 __builtin_tend (0);
18030 break;
18031 @}
18032 else
18033 @{
18034 /* Transaction State Failed. Use locks if the transaction
18035 failure is "persistent" or we've tried too many times. */
18036 if (num_retries-- <= 0
18037 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18038 @{
18039 acquire_lock (lock);
18040 ... non transactional fallback path...
18041 release_lock (lock);
18042 break;
18043 @}
18044 @}
18045 @}
18046 @end smallexample
18047
18048 One final built-in function has been added that returns the value of
18049 the 2-bit Transaction State field of the Machine Status Register (MSR)
18050 as stored in @code{CR0}.
18051
18052 @smallexample
18053 unsigned long __builtin_ttest (void)
18054 @end smallexample
18055
18056 This built-in can be used to determine the current transaction state
18057 using the following code example:
18058
18059 @smallexample
18060 #include <htmintrin.h>
18061
18062 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18063
18064 if (tx_state == _HTM_TRANSACTIONAL)
18065 @{
18066 /* Code to use in transactional state. */
18067 @}
18068 else if (tx_state == _HTM_NONTRANSACTIONAL)
18069 @{
18070 /* Code to use in non-transactional state. */
18071 @}
18072 else if (tx_state == _HTM_SUSPENDED)
18073 @{
18074 /* Code to use in transaction suspended state. */
18075 @}
18076 @end smallexample
18077
18078 @subsubsection PowerPC HTM High Level Inline Functions
18079
18080 The following high level HTM interface is made available by including
18081 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18082 where CPU is `power8' or later. This interface is common between PowerPC
18083 and S/390, allowing users to write one HTM source implementation that
18084 can be compiled and executed on either system.
18085
18086 @smallexample
18087 long __TM_simple_begin (void)
18088 long __TM_begin (void* const TM_buff)
18089 long __TM_end (void)
18090 void __TM_abort (void)
18091 void __TM_named_abort (unsigned char const code)
18092 void __TM_resume (void)
18093 void __TM_suspend (void)
18094
18095 long __TM_is_user_abort (void* const TM_buff)
18096 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18097 long __TM_is_illegal (void* const TM_buff)
18098 long __TM_is_footprint_exceeded (void* const TM_buff)
18099 long __TM_nesting_depth (void* const TM_buff)
18100 long __TM_is_nested_too_deep(void* const TM_buff)
18101 long __TM_is_conflict(void* const TM_buff)
18102 long __TM_is_failure_persistent(void* const TM_buff)
18103 long __TM_failure_address(void* const TM_buff)
18104 long long __TM_failure_code(void* const TM_buff)
18105 @end smallexample
18106
18107 Using these common set of HTM inline functions, we can create
18108 a more portable version of the HTM example in the previous
18109 section that will work on either PowerPC or S/390:
18110
18111 @smallexample
18112 #include <htmxlintrin.h>
18113
18114 int num_retries = 10;
18115 TM_buff_type TM_buff;
18116
18117 while (1)
18118 @{
18119 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18120 @{
18121 /* Transaction State Initiated. */
18122 if (is_locked (lock))
18123 __TM_abort ();
18124 ... transaction code...
18125 __TM_end ();
18126 break;
18127 @}
18128 else
18129 @{
18130 /* Transaction State Failed. Use locks if the transaction
18131 failure is "persistent" or we've tried too many times. */
18132 if (num_retries-- <= 0
18133 || __TM_is_failure_persistent (TM_buff))
18134 @{
18135 acquire_lock (lock);
18136 ... non transactional fallback path...
18137 release_lock (lock);
18138 break;
18139 @}
18140 @}
18141 @}
18142 @end smallexample
18143
18144 @node RX Built-in Functions
18145 @subsection RX Built-in Functions
18146 GCC supports some of the RX instructions which cannot be expressed in
18147 the C programming language via the use of built-in functions. The
18148 following functions are supported:
18149
18150 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
18151 Generates the @code{brk} machine instruction.
18152 @end deftypefn
18153
18154 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
18155 Generates the @code{clrpsw} machine instruction to clear the specified
18156 bit in the processor status word.
18157 @end deftypefn
18158
18159 @deftypefn {Built-in Function} void __builtin_rx_int (int)
18160 Generates the @code{int} machine instruction to generate an interrupt
18161 with the specified value.
18162 @end deftypefn
18163
18164 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
18165 Generates the @code{machi} machine instruction to add the result of
18166 multiplying the top 16 bits of the two arguments into the
18167 accumulator.
18168 @end deftypefn
18169
18170 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
18171 Generates the @code{maclo} machine instruction to add the result of
18172 multiplying the bottom 16 bits of the two arguments into the
18173 accumulator.
18174 @end deftypefn
18175
18176 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
18177 Generates the @code{mulhi} machine instruction to place the result of
18178 multiplying the top 16 bits of the two arguments into the
18179 accumulator.
18180 @end deftypefn
18181
18182 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
18183 Generates the @code{mullo} machine instruction to place the result of
18184 multiplying the bottom 16 bits of the two arguments into the
18185 accumulator.
18186 @end deftypefn
18187
18188 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
18189 Generates the @code{mvfachi} machine instruction to read the top
18190 32 bits of the accumulator.
18191 @end deftypefn
18192
18193 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
18194 Generates the @code{mvfacmi} machine instruction to read the middle
18195 32 bits of the accumulator.
18196 @end deftypefn
18197
18198 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
18199 Generates the @code{mvfc} machine instruction which reads the control
18200 register specified in its argument and returns its value.
18201 @end deftypefn
18202
18203 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
18204 Generates the @code{mvtachi} machine instruction to set the top
18205 32 bits of the accumulator.
18206 @end deftypefn
18207
18208 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
18209 Generates the @code{mvtaclo} machine instruction to set the bottom
18210 32 bits of the accumulator.
18211 @end deftypefn
18212
18213 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
18214 Generates the @code{mvtc} machine instruction which sets control
18215 register number @code{reg} to @code{val}.
18216 @end deftypefn
18217
18218 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
18219 Generates the @code{mvtipl} machine instruction set the interrupt
18220 priority level.
18221 @end deftypefn
18222
18223 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
18224 Generates the @code{racw} machine instruction to round the accumulator
18225 according to the specified mode.
18226 @end deftypefn
18227
18228 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
18229 Generates the @code{revw} machine instruction which swaps the bytes in
18230 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18231 and also bits 16--23 occupy bits 24--31 and vice versa.
18232 @end deftypefn
18233
18234 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
18235 Generates the @code{rmpa} machine instruction which initiates a
18236 repeated multiply and accumulate sequence.
18237 @end deftypefn
18238
18239 @deftypefn {Built-in Function} void __builtin_rx_round (float)
18240 Generates the @code{round} machine instruction which returns the
18241 floating-point argument rounded according to the current rounding mode
18242 set in the floating-point status word register.
18243 @end deftypefn
18244
18245 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
18246 Generates the @code{sat} machine instruction which returns the
18247 saturated value of the argument.
18248 @end deftypefn
18249
18250 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
18251 Generates the @code{setpsw} machine instruction to set the specified
18252 bit in the processor status word.
18253 @end deftypefn
18254
18255 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
18256 Generates the @code{wait} machine instruction.
18257 @end deftypefn
18258
18259 @node S/390 System z Built-in Functions
18260 @subsection S/390 System z Built-in Functions
18261 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18262 Generates the @code{tbegin} machine instruction starting a
18263 non-constrained hardware transaction. If the parameter is non-NULL the
18264 memory area is used to store the transaction diagnostic buffer and
18265 will be passed as first operand to @code{tbegin}. This buffer can be
18266 defined using the @code{struct __htm_tdb} C struct defined in
18267 @code{htmintrin.h} and must reside on a double-word boundary. The
18268 second tbegin operand is set to @code{0xff0c}. This enables
18269 save/restore of all GPRs and disables aborts for FPR and AR
18270 manipulations inside the transaction body. The condition code set by
18271 the tbegin instruction is returned as integer value. The tbegin
18272 instruction by definition overwrites the content of all FPRs. The
18273 compiler will generate code which saves and restores the FPRs. For
18274 soft-float code it is recommended to used the @code{*_nofloat}
18275 variant. In order to prevent a TDB from being written it is required
18276 to pass a constant zero value as parameter. Passing a zero value
18277 through a variable is not sufficient. Although modifications of
18278 access registers inside the transaction will not trigger an
18279 transaction abort it is not supported to actually modify them. Access
18280 registers do not get saved when entering a transaction. They will have
18281 undefined state when reaching the abort code.
18282 @end deftypefn
18283
18284 Macros for the possible return codes of tbegin are defined in the
18285 @code{htmintrin.h} header file:
18286
18287 @table @code
18288 @item _HTM_TBEGIN_STARTED
18289 @code{tbegin} has been executed as part of normal processing. The
18290 transaction body is supposed to be executed.
18291 @item _HTM_TBEGIN_INDETERMINATE
18292 The transaction was aborted due to an indeterminate condition which
18293 might be persistent.
18294 @item _HTM_TBEGIN_TRANSIENT
18295 The transaction aborted due to a transient failure. The transaction
18296 should be re-executed in that case.
18297 @item _HTM_TBEGIN_PERSISTENT
18298 The transaction aborted due to a persistent failure. Re-execution
18299 under same circumstances will not be productive.
18300 @end table
18301
18302 @defmac _HTM_FIRST_USER_ABORT_CODE
18303 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18304 specifies the first abort code which can be used for
18305 @code{__builtin_tabort}. Values below this threshold are reserved for
18306 machine use.
18307 @end defmac
18308
18309 @deftp {Data type} {struct __htm_tdb}
18310 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18311 the structure of the transaction diagnostic block as specified in the
18312 Principles of Operation manual chapter 5-91.
18313 @end deftp
18314
18315 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18316 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18317 Using this variant in code making use of FPRs will leave the FPRs in
18318 undefined state when entering the transaction abort handler code.
18319 @end deftypefn
18320
18321 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18322 In addition to @code{__builtin_tbegin} a loop for transient failures
18323 is generated. If tbegin returns a condition code of 2 the transaction
18324 will be retried as often as specified in the second argument. The
18325 perform processor assist instruction is used to tell the CPU about the
18326 number of fails so far.
18327 @end deftypefn
18328
18329 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18330 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18331 restores. Using this variant in code making use of FPRs will leave
18332 the FPRs in undefined state when entering the transaction abort
18333 handler code.
18334 @end deftypefn
18335
18336 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18337 Generates the @code{tbeginc} machine instruction starting a constrained
18338 hardware transaction. The second operand is set to @code{0xff08}.
18339 @end deftypefn
18340
18341 @deftypefn {Built-in Function} int __builtin_tend (void)
18342 Generates the @code{tend} machine instruction finishing a transaction
18343 and making the changes visible to other threads. The condition code
18344 generated by tend is returned as integer value.
18345 @end deftypefn
18346
18347 @deftypefn {Built-in Function} void __builtin_tabort (int)
18348 Generates the @code{tabort} machine instruction with the specified
18349 abort code. Abort codes from 0 through 255 are reserved and will
18350 result in an error message.
18351 @end deftypefn
18352
18353 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18354 Generates the @code{ppa rX,rY,1} machine instruction. Where the
18355 integer parameter is loaded into rX and a value of zero is loaded into
18356 rY. The integer parameter specifies the number of times the
18357 transaction repeatedly aborted.
18358 @end deftypefn
18359
18360 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18361 Generates the @code{etnd} machine instruction. The current nesting
18362 depth is returned as integer value. For a nesting depth of 0 the code
18363 is not executed as part of an transaction.
18364 @end deftypefn
18365
18366 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18367
18368 Generates the @code{ntstg} machine instruction. The second argument
18369 is written to the first arguments location. The store operation will
18370 not be rolled-back in case of an transaction abort.
18371 @end deftypefn
18372
18373 @node SH Built-in Functions
18374 @subsection SH Built-in Functions
18375 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18376 families of processors:
18377
18378 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18379 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
18380 used by system code that manages threads and execution contexts. The compiler
18381 normally does not generate code that modifies the contents of @samp{GBR} and
18382 thus the value is preserved across function calls. Changing the @samp{GBR}
18383 value in user code must be done with caution, since the compiler might use
18384 @samp{GBR} in order to access thread local variables.
18385
18386 @end deftypefn
18387
18388 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18389 Returns the value that is currently set in the @samp{GBR} register.
18390 Memory loads and stores that use the thread pointer as a base address are
18391 turned into @samp{GBR} based displacement loads and stores, if possible.
18392 For example:
18393 @smallexample
18394 struct my_tcb
18395 @{
18396 int a, b, c, d, e;
18397 @};
18398
18399 int get_tcb_value (void)
18400 @{
18401 // Generate @samp{mov.l @@(8,gbr),r0} instruction
18402 return ((my_tcb*)__builtin_thread_pointer ())->c;
18403 @}
18404
18405 @end smallexample
18406 @end deftypefn
18407
18408 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18409 Returns the value that is currently set in the @samp{FPSCR} register.
18410 @end deftypefn
18411
18412 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18413 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18414 preserving the current values of the FR, SZ and PR bits.
18415 @end deftypefn
18416
18417 @node SPARC VIS Built-in Functions
18418 @subsection SPARC VIS Built-in Functions
18419
18420 GCC supports SIMD operations on the SPARC using both the generic vector
18421 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18422 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
18423 switch, the VIS extension is exposed as the following built-in functions:
18424
18425 @smallexample
18426 typedef int v1si __attribute__ ((vector_size (4)));
18427 typedef int v2si __attribute__ ((vector_size (8)));
18428 typedef short v4hi __attribute__ ((vector_size (8)));
18429 typedef short v2hi __attribute__ ((vector_size (4)));
18430 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18431 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18432
18433 void __builtin_vis_write_gsr (int64_t);
18434 int64_t __builtin_vis_read_gsr (void);
18435
18436 void * __builtin_vis_alignaddr (void *, long);
18437 void * __builtin_vis_alignaddrl (void *, long);
18438 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18439 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18440 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18441 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18442
18443 v4hi __builtin_vis_fexpand (v4qi);
18444
18445 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18446 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18447 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18448 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18449 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18450 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18451 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18452
18453 v4qi __builtin_vis_fpack16 (v4hi);
18454 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18455 v2hi __builtin_vis_fpackfix (v2si);
18456 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18457
18458 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18459
18460 long __builtin_vis_edge8 (void *, void *);
18461 long __builtin_vis_edge8l (void *, void *);
18462 long __builtin_vis_edge16 (void *, void *);
18463 long __builtin_vis_edge16l (void *, void *);
18464 long __builtin_vis_edge32 (void *, void *);
18465 long __builtin_vis_edge32l (void *, void *);
18466
18467 long __builtin_vis_fcmple16 (v4hi, v4hi);
18468 long __builtin_vis_fcmple32 (v2si, v2si);
18469 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18470 long __builtin_vis_fcmpne32 (v2si, v2si);
18471 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18472 long __builtin_vis_fcmpgt32 (v2si, v2si);
18473 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18474 long __builtin_vis_fcmpeq32 (v2si, v2si);
18475
18476 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18477 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18478 v2si __builtin_vis_fpadd32 (v2si, v2si);
18479 v1si __builtin_vis_fpadd32s (v1si, v1si);
18480 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18481 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18482 v2si __builtin_vis_fpsub32 (v2si, v2si);
18483 v1si __builtin_vis_fpsub32s (v1si, v1si);
18484
18485 long __builtin_vis_array8 (long, long);
18486 long __builtin_vis_array16 (long, long);
18487 long __builtin_vis_array32 (long, long);
18488 @end smallexample
18489
18490 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18491 functions also become available:
18492
18493 @smallexample
18494 long __builtin_vis_bmask (long, long);
18495 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18496 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18497 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18498 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18499
18500 long __builtin_vis_edge8n (void *, void *);
18501 long __builtin_vis_edge8ln (void *, void *);
18502 long __builtin_vis_edge16n (void *, void *);
18503 long __builtin_vis_edge16ln (void *, void *);
18504 long __builtin_vis_edge32n (void *, void *);
18505 long __builtin_vis_edge32ln (void *, void *);
18506 @end smallexample
18507
18508 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18509 functions also become available:
18510
18511 @smallexample
18512 void __builtin_vis_cmask8 (long);
18513 void __builtin_vis_cmask16 (long);
18514 void __builtin_vis_cmask32 (long);
18515
18516 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18517
18518 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18519 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18520 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18521 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18522 v2si __builtin_vis_fsll16 (v2si, v2si);
18523 v2si __builtin_vis_fslas16 (v2si, v2si);
18524 v2si __builtin_vis_fsrl16 (v2si, v2si);
18525 v2si __builtin_vis_fsra16 (v2si, v2si);
18526
18527 long __builtin_vis_pdistn (v8qi, v8qi);
18528
18529 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18530
18531 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18532 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18533
18534 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18535 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18536 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18537 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18538 v2si __builtin_vis_fpadds32 (v2si, v2si);
18539 v1si __builtin_vis_fpadds32s (v1si, v1si);
18540 v2si __builtin_vis_fpsubs32 (v2si, v2si);
18541 v1si __builtin_vis_fpsubs32s (v1si, v1si);
18542
18543 long __builtin_vis_fucmple8 (v8qi, v8qi);
18544 long __builtin_vis_fucmpne8 (v8qi, v8qi);
18545 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
18546 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
18547
18548 float __builtin_vis_fhadds (float, float);
18549 double __builtin_vis_fhaddd (double, double);
18550 float __builtin_vis_fhsubs (float, float);
18551 double __builtin_vis_fhsubd (double, double);
18552 float __builtin_vis_fnhadds (float, float);
18553 double __builtin_vis_fnhaddd (double, double);
18554
18555 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
18556 int64_t __builtin_vis_xmulx (int64_t, int64_t);
18557 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
18558 @end smallexample
18559
18560 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
18561 functions also become available:
18562
18563 @smallexample
18564 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
18565 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
18566 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
18567 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
18568
18569 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
18570 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
18571 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
18572 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
18573
18574 long __builtin_vis_fpcmple8 (v8qi, v8qi);
18575 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
18576 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
18577 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
18578 long __builtin_vis_fpcmpule32 (v2si, v2si);
18579 long __builtin_vis_fpcmpugt32 (v2si, v2si);
18580
18581 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
18582 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
18583 v2si __builtin_vis_fpmax32 (v2si, v2si);
18584
18585 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
18586 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
18587 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
18588
18589
18590 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
18591 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
18592 v2si __builtin_vis_fpmin32 (v2si, v2si);
18593
18594 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
18595 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
18596 v2si __builtin_vis_fpminu32 (v2si, v2si);
18597 @end smallexample
18598
18599 @node SPU Built-in Functions
18600 @subsection SPU Built-in Functions
18601
18602 GCC provides extensions for the SPU processor as described in the
18603 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
18604 implementation differs in several ways.
18605
18606 @itemize @bullet
18607
18608 @item
18609 The optional extension of specifying vector constants in parentheses is
18610 not supported.
18611
18612 @item
18613 A vector initializer requires no cast if the vector constant is of the
18614 same type as the variable it is initializing.
18615
18616 @item
18617 If @code{signed} or @code{unsigned} is omitted, the signedness of the
18618 vector type is the default signedness of the base type. The default
18619 varies depending on the operating system, so a portable program should
18620 always specify the signedness.
18621
18622 @item
18623 By default, the keyword @code{__vector} is added. The macro
18624 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
18625 undefined.
18626
18627 @item
18628 GCC allows using a @code{typedef} name as the type specifier for a
18629 vector type.
18630
18631 @item
18632 For C, overloaded functions are implemented with macros so the following
18633 does not work:
18634
18635 @smallexample
18636 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
18637 @end smallexample
18638
18639 @noindent
18640 Since @code{spu_add} is a macro, the vector constant in the example
18641 is treated as four separate arguments. Wrap the entire argument in
18642 parentheses for this to work.
18643
18644 @item
18645 The extended version of @code{__builtin_expect} is not supported.
18646
18647 @end itemize
18648
18649 @emph{Note:} Only the interface described in the aforementioned
18650 specification is supported. Internally, GCC uses built-in functions to
18651 implement the required functionality, but these are not supported and
18652 are subject to change without notice.
18653
18654 @node TI C6X Built-in Functions
18655 @subsection TI C6X Built-in Functions
18656
18657 GCC provides intrinsics to access certain instructions of the TI C6X
18658 processors. These intrinsics, listed below, are available after
18659 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
18660 to C6X instructions.
18661
18662 @smallexample
18663
18664 int _sadd (int, int)
18665 int _ssub (int, int)
18666 int _sadd2 (int, int)
18667 int _ssub2 (int, int)
18668 long long _mpy2 (int, int)
18669 long long _smpy2 (int, int)
18670 int _add4 (int, int)
18671 int _sub4 (int, int)
18672 int _saddu4 (int, int)
18673
18674 int _smpy (int, int)
18675 int _smpyh (int, int)
18676 int _smpyhl (int, int)
18677 int _smpylh (int, int)
18678
18679 int _sshl (int, int)
18680 int _subc (int, int)
18681
18682 int _avg2 (int, int)
18683 int _avgu4 (int, int)
18684
18685 int _clrr (int, int)
18686 int _extr (int, int)
18687 int _extru (int, int)
18688 int _abs (int)
18689 int _abs2 (int)
18690
18691 @end smallexample
18692
18693 @node TILE-Gx Built-in Functions
18694 @subsection TILE-Gx Built-in Functions
18695
18696 GCC provides intrinsics to access every instruction of the TILE-Gx
18697 processor. The intrinsics are of the form:
18698
18699 @smallexample
18700
18701 unsigned long long __insn_@var{op} (...)
18702
18703 @end smallexample
18704
18705 Where @var{op} is the name of the instruction. Refer to the ISA manual
18706 for the complete list of instructions.
18707
18708 GCC also provides intrinsics to directly access the network registers.
18709 The intrinsics are:
18710
18711 @smallexample
18712
18713 unsigned long long __tile_idn0_receive (void)
18714 unsigned long long __tile_idn1_receive (void)
18715 unsigned long long __tile_udn0_receive (void)
18716 unsigned long long __tile_udn1_receive (void)
18717 unsigned long long __tile_udn2_receive (void)
18718 unsigned long long __tile_udn3_receive (void)
18719 void __tile_idn_send (unsigned long long)
18720 void __tile_udn_send (unsigned long long)
18721
18722 @end smallexample
18723
18724 The intrinsic @code{void __tile_network_barrier (void)} is used to
18725 guarantee that no network operations before it are reordered with
18726 those after it.
18727
18728 @node TILEPro Built-in Functions
18729 @subsection TILEPro Built-in Functions
18730
18731 GCC provides intrinsics to access every instruction of the TILEPro
18732 processor. The intrinsics are of the form:
18733
18734 @smallexample
18735
18736 unsigned __insn_@var{op} (...)
18737
18738 @end smallexample
18739
18740 @noindent
18741 where @var{op} is the name of the instruction. Refer to the ISA manual
18742 for the complete list of instructions.
18743
18744 GCC also provides intrinsics to directly access the network registers.
18745 The intrinsics are:
18746
18747 @smallexample
18748
18749 unsigned __tile_idn0_receive (void)
18750 unsigned __tile_idn1_receive (void)
18751 unsigned __tile_sn_receive (void)
18752 unsigned __tile_udn0_receive (void)
18753 unsigned __tile_udn1_receive (void)
18754 unsigned __tile_udn2_receive (void)
18755 unsigned __tile_udn3_receive (void)
18756 void __tile_idn_send (unsigned)
18757 void __tile_sn_send (unsigned)
18758 void __tile_udn_send (unsigned)
18759
18760 @end smallexample
18761
18762 The intrinsic @code{void __tile_network_barrier (void)} is used to
18763 guarantee that no network operations before it are reordered with
18764 those after it.
18765
18766 @node x86 Built-in Functions
18767 @subsection x86 Built-in Functions
18768
18769 These built-in functions are available for the x86-32 and x86-64 family
18770 of computers, depending on the command-line switches used.
18771
18772 If you specify command-line switches such as @option{-msse},
18773 the compiler could use the extended instruction sets even if the built-ins
18774 are not used explicitly in the program. For this reason, applications
18775 that perform run-time CPU detection must compile separate files for each
18776 supported architecture, using the appropriate flags. In particular,
18777 the file containing the CPU detection code should be compiled without
18778 these options.
18779
18780 The following machine modes are available for use with MMX built-in functions
18781 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
18782 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
18783 vector of eight 8-bit integers. Some of the built-in functions operate on
18784 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
18785
18786 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
18787 of two 32-bit floating-point values.
18788
18789 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
18790 floating-point values. Some instructions use a vector of four 32-bit
18791 integers, these use @code{V4SI}. Finally, some instructions operate on an
18792 entire vector register, interpreting it as a 128-bit integer, these use mode
18793 @code{TI}.
18794
18795 The x86-32 and x86-64 family of processors use additional built-in
18796 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
18797 floating point and @code{TC} 128-bit complex floating-point values.
18798
18799 The following floating-point built-in functions are always available. All
18800 of them implement the function that is part of the name.
18801
18802 @smallexample
18803 __float128 __builtin_fabsq (__float128)
18804 __float128 __builtin_copysignq (__float128, __float128)
18805 @end smallexample
18806
18807 The following built-in functions are always available.
18808
18809 @table @code
18810 @item __float128 __builtin_infq (void)
18811 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
18812 @findex __builtin_infq
18813
18814 @item __float128 __builtin_huge_valq (void)
18815 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
18816 @findex __builtin_huge_valq
18817
18818 @item __float128 __builtin_nanq (void)
18819 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
18820 @findex __builtin_nanq
18821
18822 @item __float128 __builtin_nansq (void)
18823 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
18824 @findex __builtin_nansq
18825 @end table
18826
18827 The following built-in function is always available.
18828
18829 @table @code
18830 @item void __builtin_ia32_pause (void)
18831 Generates the @code{pause} machine instruction with a compiler memory
18832 barrier.
18833 @end table
18834
18835 The following built-in functions are always available and can be used to
18836 check the target platform type.
18837
18838 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
18839 This function runs the CPU detection code to check the type of CPU and the
18840 features supported. This built-in function needs to be invoked along with the built-in functions
18841 to check CPU type and features, @code{__builtin_cpu_is} and
18842 @code{__builtin_cpu_supports}, only when used in a function that is
18843 executed before any constructors are called. The CPU detection code is
18844 automatically executed in a very high priority constructor.
18845
18846 For example, this function has to be used in @code{ifunc} resolvers that
18847 check for CPU type using the built-in functions @code{__builtin_cpu_is}
18848 and @code{__builtin_cpu_supports}, or in constructors on targets that
18849 don't support constructor priority.
18850 @smallexample
18851
18852 static void (*resolve_memcpy (void)) (void)
18853 @{
18854 // ifunc resolvers fire before constructors, explicitly call the init
18855 // function.
18856 __builtin_cpu_init ();
18857 if (__builtin_cpu_supports ("ssse3"))
18858 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
18859 else
18860 return default_memcpy;
18861 @}
18862
18863 void *memcpy (void *, const void *, size_t)
18864 __attribute__ ((ifunc ("resolve_memcpy")));
18865 @end smallexample
18866
18867 @end deftypefn
18868
18869 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
18870 This function returns a positive integer if the run-time CPU
18871 is of type @var{cpuname}
18872 and returns @code{0} otherwise. The following CPU names can be detected:
18873
18874 @table @samp
18875 @item intel
18876 Intel CPU.
18877
18878 @item atom
18879 Intel Atom CPU.
18880
18881 @item core2
18882 Intel Core 2 CPU.
18883
18884 @item corei7
18885 Intel Core i7 CPU.
18886
18887 @item nehalem
18888 Intel Core i7 Nehalem CPU.
18889
18890 @item westmere
18891 Intel Core i7 Westmere CPU.
18892
18893 @item sandybridge
18894 Intel Core i7 Sandy Bridge CPU.
18895
18896 @item amd
18897 AMD CPU.
18898
18899 @item amdfam10h
18900 AMD Family 10h CPU.
18901
18902 @item barcelona
18903 AMD Family 10h Barcelona CPU.
18904
18905 @item shanghai
18906 AMD Family 10h Shanghai CPU.
18907
18908 @item istanbul
18909 AMD Family 10h Istanbul CPU.
18910
18911 @item btver1
18912 AMD Family 14h CPU.
18913
18914 @item amdfam15h
18915 AMD Family 15h CPU.
18916
18917 @item bdver1
18918 AMD Family 15h Bulldozer version 1.
18919
18920 @item bdver2
18921 AMD Family 15h Bulldozer version 2.
18922
18923 @item bdver3
18924 AMD Family 15h Bulldozer version 3.
18925
18926 @item bdver4
18927 AMD Family 15h Bulldozer version 4.
18928
18929 @item btver2
18930 AMD Family 16h CPU.
18931
18932 @item znver1
18933 AMD Family 17h CPU.
18934 @end table
18935
18936 Here is an example:
18937 @smallexample
18938 if (__builtin_cpu_is ("corei7"))
18939 @{
18940 do_corei7 (); // Core i7 specific implementation.
18941 @}
18942 else
18943 @{
18944 do_generic (); // Generic implementation.
18945 @}
18946 @end smallexample
18947 @end deftypefn
18948
18949 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
18950 This function returns a positive integer if the run-time CPU
18951 supports @var{feature}
18952 and returns @code{0} otherwise. The following features can be detected:
18953
18954 @table @samp
18955 @item cmov
18956 CMOV instruction.
18957 @item mmx
18958 MMX instructions.
18959 @item popcnt
18960 POPCNT instruction.
18961 @item sse
18962 SSE instructions.
18963 @item sse2
18964 SSE2 instructions.
18965 @item sse3
18966 SSE3 instructions.
18967 @item ssse3
18968 SSSE3 instructions.
18969 @item sse4.1
18970 SSE4.1 instructions.
18971 @item sse4.2
18972 SSE4.2 instructions.
18973 @item avx
18974 AVX instructions.
18975 @item avx2
18976 AVX2 instructions.
18977 @item avx512f
18978 AVX512F instructions.
18979 @end table
18980
18981 Here is an example:
18982 @smallexample
18983 if (__builtin_cpu_supports ("popcnt"))
18984 @{
18985 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
18986 @}
18987 else
18988 @{
18989 count = generic_countbits (n); //generic implementation.
18990 @}
18991 @end smallexample
18992 @end deftypefn
18993
18994
18995 The following built-in functions are made available by @option{-mmmx}.
18996 All of them generate the machine instruction that is part of the name.
18997
18998 @smallexample
18999 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19000 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19001 v2si __builtin_ia32_paddd (v2si, v2si)
19002 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19003 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19004 v2si __builtin_ia32_psubd (v2si, v2si)
19005 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19006 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19007 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19008 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19009 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19010 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19011 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19012 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19013 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19014 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19015 di __builtin_ia32_pand (di, di)
19016 di __builtin_ia32_pandn (di,di)
19017 di __builtin_ia32_por (di, di)
19018 di __builtin_ia32_pxor (di, di)
19019 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19020 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19021 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19022 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19023 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19024 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19025 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19026 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19027 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19028 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19029 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19030 v2si __builtin_ia32_punpckldq (v2si, v2si)
19031 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19032 v4hi __builtin_ia32_packssdw (v2si, v2si)
19033 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19034
19035 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19036 v2si __builtin_ia32_pslld (v2si, v2si)
19037 v1di __builtin_ia32_psllq (v1di, v1di)
19038 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19039 v2si __builtin_ia32_psrld (v2si, v2si)
19040 v1di __builtin_ia32_psrlq (v1di, v1di)
19041 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19042 v2si __builtin_ia32_psrad (v2si, v2si)
19043 v4hi __builtin_ia32_psllwi (v4hi, int)
19044 v2si __builtin_ia32_pslldi (v2si, int)
19045 v1di __builtin_ia32_psllqi (v1di, int)
19046 v4hi __builtin_ia32_psrlwi (v4hi, int)
19047 v2si __builtin_ia32_psrldi (v2si, int)
19048 v1di __builtin_ia32_psrlqi (v1di, int)
19049 v4hi __builtin_ia32_psrawi (v4hi, int)
19050 v2si __builtin_ia32_psradi (v2si, int)
19051
19052 @end smallexample
19053
19054 The following built-in functions are made available either with
19055 @option{-msse}, or with a combination of @option{-m3dnow} and
19056 @option{-march=athlon}. All of them generate the machine
19057 instruction that is part of the name.
19058
19059 @smallexample
19060 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19061 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19062 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19063 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19064 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19065 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19066 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19067 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19068 int __builtin_ia32_pmovmskb (v8qi)
19069 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19070 void __builtin_ia32_movntq (di *, di)
19071 void __builtin_ia32_sfence (void)
19072 @end smallexample
19073
19074 The following built-in functions are available when @option{-msse} is used.
19075 All of them generate the machine instruction that is part of the name.
19076
19077 @smallexample
19078 int __builtin_ia32_comieq (v4sf, v4sf)
19079 int __builtin_ia32_comineq (v4sf, v4sf)
19080 int __builtin_ia32_comilt (v4sf, v4sf)
19081 int __builtin_ia32_comile (v4sf, v4sf)
19082 int __builtin_ia32_comigt (v4sf, v4sf)
19083 int __builtin_ia32_comige (v4sf, v4sf)
19084 int __builtin_ia32_ucomieq (v4sf, v4sf)
19085 int __builtin_ia32_ucomineq (v4sf, v4sf)
19086 int __builtin_ia32_ucomilt (v4sf, v4sf)
19087 int __builtin_ia32_ucomile (v4sf, v4sf)
19088 int __builtin_ia32_ucomigt (v4sf, v4sf)
19089 int __builtin_ia32_ucomige (v4sf, v4sf)
19090 v4sf __builtin_ia32_addps (v4sf, v4sf)
19091 v4sf __builtin_ia32_subps (v4sf, v4sf)
19092 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19093 v4sf __builtin_ia32_divps (v4sf, v4sf)
19094 v4sf __builtin_ia32_addss (v4sf, v4sf)
19095 v4sf __builtin_ia32_subss (v4sf, v4sf)
19096 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19097 v4sf __builtin_ia32_divss (v4sf, v4sf)
19098 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19099 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19100 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19101 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19102 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19103 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19104 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19105 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19106 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19107 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19108 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19109 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19110 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19111 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19112 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19113 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19114 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19115 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19116 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19117 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19118 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19119 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19120 v4sf __builtin_ia32_minps (v4sf, v4sf)
19121 v4sf __builtin_ia32_minss (v4sf, v4sf)
19122 v4sf __builtin_ia32_andps (v4sf, v4sf)
19123 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19124 v4sf __builtin_ia32_orps (v4sf, v4sf)
19125 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19126 v4sf __builtin_ia32_movss (v4sf, v4sf)
19127 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19128 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19129 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19130 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19131 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19132 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19133 v2si __builtin_ia32_cvtps2pi (v4sf)
19134 int __builtin_ia32_cvtss2si (v4sf)
19135 v2si __builtin_ia32_cvttps2pi (v4sf)
19136 int __builtin_ia32_cvttss2si (v4sf)
19137 v4sf __builtin_ia32_rcpps (v4sf)
19138 v4sf __builtin_ia32_rsqrtps (v4sf)
19139 v4sf __builtin_ia32_sqrtps (v4sf)
19140 v4sf __builtin_ia32_rcpss (v4sf)
19141 v4sf __builtin_ia32_rsqrtss (v4sf)
19142 v4sf __builtin_ia32_sqrtss (v4sf)
19143 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19144 void __builtin_ia32_movntps (float *, v4sf)
19145 int __builtin_ia32_movmskps (v4sf)
19146 @end smallexample
19147
19148 The following built-in functions are available when @option{-msse} is used.
19149
19150 @table @code
19151 @item v4sf __builtin_ia32_loadups (float *)
19152 Generates the @code{movups} machine instruction as a load from memory.
19153 @item void __builtin_ia32_storeups (float *, v4sf)
19154 Generates the @code{movups} machine instruction as a store to memory.
19155 @item v4sf __builtin_ia32_loadss (float *)
19156 Generates the @code{movss} machine instruction as a load from memory.
19157 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19158 Generates the @code{movhps} machine instruction as a load from memory.
19159 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19160 Generates the @code{movlps} machine instruction as a load from memory
19161 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19162 Generates the @code{movhps} machine instruction as a store to memory.
19163 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19164 Generates the @code{movlps} machine instruction as a store to memory.
19165 @end table
19166
19167 The following built-in functions are available when @option{-msse2} is used.
19168 All of them generate the machine instruction that is part of the name.
19169
19170 @smallexample
19171 int __builtin_ia32_comisdeq (v2df, v2df)
19172 int __builtin_ia32_comisdlt (v2df, v2df)
19173 int __builtin_ia32_comisdle (v2df, v2df)
19174 int __builtin_ia32_comisdgt (v2df, v2df)
19175 int __builtin_ia32_comisdge (v2df, v2df)
19176 int __builtin_ia32_comisdneq (v2df, v2df)
19177 int __builtin_ia32_ucomisdeq (v2df, v2df)
19178 int __builtin_ia32_ucomisdlt (v2df, v2df)
19179 int __builtin_ia32_ucomisdle (v2df, v2df)
19180 int __builtin_ia32_ucomisdgt (v2df, v2df)
19181 int __builtin_ia32_ucomisdge (v2df, v2df)
19182 int __builtin_ia32_ucomisdneq (v2df, v2df)
19183 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19184 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19185 v2df __builtin_ia32_cmplepd (v2df, v2df)
19186 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19187 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19188 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19189 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19190 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19191 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19192 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19193 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19194 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19195 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19196 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19197 v2df __builtin_ia32_cmplesd (v2df, v2df)
19198 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19199 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19200 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19201 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19202 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19203 v2di __builtin_ia32_paddq (v2di, v2di)
19204 v2di __builtin_ia32_psubq (v2di, v2di)
19205 v2df __builtin_ia32_addpd (v2df, v2df)
19206 v2df __builtin_ia32_subpd (v2df, v2df)
19207 v2df __builtin_ia32_mulpd (v2df, v2df)
19208 v2df __builtin_ia32_divpd (v2df, v2df)
19209 v2df __builtin_ia32_addsd (v2df, v2df)
19210 v2df __builtin_ia32_subsd (v2df, v2df)
19211 v2df __builtin_ia32_mulsd (v2df, v2df)
19212 v2df __builtin_ia32_divsd (v2df, v2df)
19213 v2df __builtin_ia32_minpd (v2df, v2df)
19214 v2df __builtin_ia32_maxpd (v2df, v2df)
19215 v2df __builtin_ia32_minsd (v2df, v2df)
19216 v2df __builtin_ia32_maxsd (v2df, v2df)
19217 v2df __builtin_ia32_andpd (v2df, v2df)
19218 v2df __builtin_ia32_andnpd (v2df, v2df)
19219 v2df __builtin_ia32_orpd (v2df, v2df)
19220 v2df __builtin_ia32_xorpd (v2df, v2df)
19221 v2df __builtin_ia32_movsd (v2df, v2df)
19222 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19223 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19224 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19225 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19226 v4si __builtin_ia32_paddd128 (v4si, v4si)
19227 v2di __builtin_ia32_paddq128 (v2di, v2di)
19228 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19229 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19230 v4si __builtin_ia32_psubd128 (v4si, v4si)
19231 v2di __builtin_ia32_psubq128 (v2di, v2di)
19232 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19233 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19234 v2di __builtin_ia32_pand128 (v2di, v2di)
19235 v2di __builtin_ia32_pandn128 (v2di, v2di)
19236 v2di __builtin_ia32_por128 (v2di, v2di)
19237 v2di __builtin_ia32_pxor128 (v2di, v2di)
19238 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19239 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19240 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19241 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19242 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19243 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19244 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19245 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19246 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19247 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19248 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19249 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19250 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19251 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19252 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19253 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19254 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19255 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19256 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19257 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19258 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19259 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19260 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19261 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19262 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19263 v2df __builtin_ia32_loadupd (double *)
19264 void __builtin_ia32_storeupd (double *, v2df)
19265 v2df __builtin_ia32_loadhpd (v2df, double const *)
19266 v2df __builtin_ia32_loadlpd (v2df, double const *)
19267 int __builtin_ia32_movmskpd (v2df)
19268 int __builtin_ia32_pmovmskb128 (v16qi)
19269 void __builtin_ia32_movnti (int *, int)
19270 void __builtin_ia32_movnti64 (long long int *, long long int)
19271 void __builtin_ia32_movntpd (double *, v2df)
19272 void __builtin_ia32_movntdq (v2df *, v2df)
19273 v4si __builtin_ia32_pshufd (v4si, int)
19274 v8hi __builtin_ia32_pshuflw (v8hi, int)
19275 v8hi __builtin_ia32_pshufhw (v8hi, int)
19276 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19277 v2df __builtin_ia32_sqrtpd (v2df)
19278 v2df __builtin_ia32_sqrtsd (v2df)
19279 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19280 v2df __builtin_ia32_cvtdq2pd (v4si)
19281 v4sf __builtin_ia32_cvtdq2ps (v4si)
19282 v4si __builtin_ia32_cvtpd2dq (v2df)
19283 v2si __builtin_ia32_cvtpd2pi (v2df)
19284 v4sf __builtin_ia32_cvtpd2ps (v2df)
19285 v4si __builtin_ia32_cvttpd2dq (v2df)
19286 v2si __builtin_ia32_cvttpd2pi (v2df)
19287 v2df __builtin_ia32_cvtpi2pd (v2si)
19288 int __builtin_ia32_cvtsd2si (v2df)
19289 int __builtin_ia32_cvttsd2si (v2df)
19290 long long __builtin_ia32_cvtsd2si64 (v2df)
19291 long long __builtin_ia32_cvttsd2si64 (v2df)
19292 v4si __builtin_ia32_cvtps2dq (v4sf)
19293 v2df __builtin_ia32_cvtps2pd (v4sf)
19294 v4si __builtin_ia32_cvttps2dq (v4sf)
19295 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19296 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19297 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19298 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19299 void __builtin_ia32_clflush (const void *)
19300 void __builtin_ia32_lfence (void)
19301 void __builtin_ia32_mfence (void)
19302 v16qi __builtin_ia32_loaddqu (const char *)
19303 void __builtin_ia32_storedqu (char *, v16qi)
19304 v1di __builtin_ia32_pmuludq (v2si, v2si)
19305 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19306 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19307 v4si __builtin_ia32_pslld128 (v4si, v4si)
19308 v2di __builtin_ia32_psllq128 (v2di, v2di)
19309 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19310 v4si __builtin_ia32_psrld128 (v4si, v4si)
19311 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19312 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19313 v4si __builtin_ia32_psrad128 (v4si, v4si)
19314 v2di __builtin_ia32_pslldqi128 (v2di, int)
19315 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19316 v4si __builtin_ia32_pslldi128 (v4si, int)
19317 v2di __builtin_ia32_psllqi128 (v2di, int)
19318 v2di __builtin_ia32_psrldqi128 (v2di, int)
19319 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19320 v4si __builtin_ia32_psrldi128 (v4si, int)
19321 v2di __builtin_ia32_psrlqi128 (v2di, int)
19322 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19323 v4si __builtin_ia32_psradi128 (v4si, int)
19324 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19325 v2di __builtin_ia32_movq128 (v2di)
19326 @end smallexample
19327
19328 The following built-in functions are available when @option{-msse3} is used.
19329 All of them generate the machine instruction that is part of the name.
19330
19331 @smallexample
19332 v2df __builtin_ia32_addsubpd (v2df, v2df)
19333 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19334 v2df __builtin_ia32_haddpd (v2df, v2df)
19335 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19336 v2df __builtin_ia32_hsubpd (v2df, v2df)
19337 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19338 v16qi __builtin_ia32_lddqu (char const *)
19339 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19340 v4sf __builtin_ia32_movshdup (v4sf)
19341 v4sf __builtin_ia32_movsldup (v4sf)
19342 void __builtin_ia32_mwait (unsigned int, unsigned int)
19343 @end smallexample
19344
19345 The following built-in functions are available when @option{-mssse3} is used.
19346 All of them generate the machine instruction that is part of the name.
19347
19348 @smallexample
19349 v2si __builtin_ia32_phaddd (v2si, v2si)
19350 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19351 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19352 v2si __builtin_ia32_phsubd (v2si, v2si)
19353 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19354 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19355 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19356 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19357 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19358 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19359 v2si __builtin_ia32_psignd (v2si, v2si)
19360 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19361 v1di __builtin_ia32_palignr (v1di, v1di, int)
19362 v8qi __builtin_ia32_pabsb (v8qi)
19363 v2si __builtin_ia32_pabsd (v2si)
19364 v4hi __builtin_ia32_pabsw (v4hi)
19365 @end smallexample
19366
19367 The following built-in functions are available when @option{-mssse3} is used.
19368 All of them generate the machine instruction that is part of the name.
19369
19370 @smallexample
19371 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19372 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19373 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19374 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19375 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19376 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19377 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19378 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19379 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19380 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19381 v4si __builtin_ia32_psignd128 (v4si, v4si)
19382 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19383 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19384 v16qi __builtin_ia32_pabsb128 (v16qi)
19385 v4si __builtin_ia32_pabsd128 (v4si)
19386 v8hi __builtin_ia32_pabsw128 (v8hi)
19387 @end smallexample
19388
19389 The following built-in functions are available when @option{-msse4.1} is
19390 used. All of them generate the machine instruction that is part of the
19391 name.
19392
19393 @smallexample
19394 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19395 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19396 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19397 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19398 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19399 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19400 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19401 v2di __builtin_ia32_movntdqa (v2di *);
19402 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19403 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19404 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19405 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19406 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19407 v8hi __builtin_ia32_phminposuw128 (v8hi)
19408 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19409 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19410 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19411 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19412 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19413 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19414 v4si __builtin_ia32_pminud128 (v4si, v4si)
19415 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19416 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19417 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19418 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19419 v2di __builtin_ia32_pmovsxdq128 (v4si)
19420 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19421 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19422 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19423 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19424 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19425 v2di __builtin_ia32_pmovzxdq128 (v4si)
19426 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19427 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19428 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19429 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19430 int __builtin_ia32_ptestc128 (v2di, v2di)
19431 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19432 int __builtin_ia32_ptestz128 (v2di, v2di)
19433 v2df __builtin_ia32_roundpd (v2df, const int)
19434 v4sf __builtin_ia32_roundps (v4sf, const int)
19435 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19436 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19437 @end smallexample
19438
19439 The following built-in functions are available when @option{-msse4.1} is
19440 used.
19441
19442 @table @code
19443 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19444 Generates the @code{insertps} machine instruction.
19445 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19446 Generates the @code{pextrb} machine instruction.
19447 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19448 Generates the @code{pinsrb} machine instruction.
19449 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19450 Generates the @code{pinsrd} machine instruction.
19451 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19452 Generates the @code{pinsrq} machine instruction in 64bit mode.
19453 @end table
19454
19455 The following built-in functions are changed to generate new SSE4.1
19456 instructions when @option{-msse4.1} is used.
19457
19458 @table @code
19459 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19460 Generates the @code{extractps} machine instruction.
19461 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19462 Generates the @code{pextrd} machine instruction.
19463 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19464 Generates the @code{pextrq} machine instruction in 64bit mode.
19465 @end table
19466
19467 The following built-in functions are available when @option{-msse4.2} is
19468 used. All of them generate the machine instruction that is part of the
19469 name.
19470
19471 @smallexample
19472 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19473 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19474 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19475 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19476 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19477 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19478 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19479 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19480 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19481 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19482 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19483 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19484 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19485 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19486 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19487 @end smallexample
19488
19489 The following built-in functions are available when @option{-msse4.2} is
19490 used.
19491
19492 @table @code
19493 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19494 Generates the @code{crc32b} machine instruction.
19495 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19496 Generates the @code{crc32w} machine instruction.
19497 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19498 Generates the @code{crc32l} machine instruction.
19499 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19500 Generates the @code{crc32q} machine instruction.
19501 @end table
19502
19503 The following built-in functions are changed to generate new SSE4.2
19504 instructions when @option{-msse4.2} is used.
19505
19506 @table @code
19507 @item int __builtin_popcount (unsigned int)
19508 Generates the @code{popcntl} machine instruction.
19509 @item int __builtin_popcountl (unsigned long)
19510 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19511 depending on the size of @code{unsigned long}.
19512 @item int __builtin_popcountll (unsigned long long)
19513 Generates the @code{popcntq} machine instruction.
19514 @end table
19515
19516 The following built-in functions are available when @option{-mavx} is
19517 used. All of them generate the machine instruction that is part of the
19518 name.
19519
19520 @smallexample
19521 v4df __builtin_ia32_addpd256 (v4df,v4df)
19522 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19523 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19524 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19525 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19526 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19527 v4df __builtin_ia32_andpd256 (v4df,v4df)
19528 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19529 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19530 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19531 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19532 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19533 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19534 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19535 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19536 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19537 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19538 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
19539 v4df __builtin_ia32_cvtdq2pd256 (v4si)
19540 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
19541 v4si __builtin_ia32_cvtpd2dq256 (v4df)
19542 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
19543 v8si __builtin_ia32_cvtps2dq256 (v8sf)
19544 v4df __builtin_ia32_cvtps2pd256 (v4sf)
19545 v4si __builtin_ia32_cvttpd2dq256 (v4df)
19546 v8si __builtin_ia32_cvttps2dq256 (v8sf)
19547 v4df __builtin_ia32_divpd256 (v4df,v4df)
19548 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
19549 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
19550 v4df __builtin_ia32_haddpd256 (v4df,v4df)
19551 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
19552 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
19553 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
19554 v32qi __builtin_ia32_lddqu256 (pcchar)
19555 v32qi __builtin_ia32_loaddqu256 (pcchar)
19556 v4df __builtin_ia32_loadupd256 (pcdouble)
19557 v8sf __builtin_ia32_loadups256 (pcfloat)
19558 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
19559 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
19560 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
19561 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
19562 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
19563 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
19564 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
19565 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
19566 v4df __builtin_ia32_maxpd256 (v4df,v4df)
19567 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
19568 v4df __builtin_ia32_minpd256 (v4df,v4df)
19569 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
19570 v4df __builtin_ia32_movddup256 (v4df)
19571 int __builtin_ia32_movmskpd256 (v4df)
19572 int __builtin_ia32_movmskps256 (v8sf)
19573 v8sf __builtin_ia32_movshdup256 (v8sf)
19574 v8sf __builtin_ia32_movsldup256 (v8sf)
19575 v4df __builtin_ia32_mulpd256 (v4df,v4df)
19576 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
19577 v4df __builtin_ia32_orpd256 (v4df,v4df)
19578 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
19579 v2df __builtin_ia32_pd_pd256 (v4df)
19580 v4df __builtin_ia32_pd256_pd (v2df)
19581 v4sf __builtin_ia32_ps_ps256 (v8sf)
19582 v8sf __builtin_ia32_ps256_ps (v4sf)
19583 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
19584 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
19585 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
19586 v8sf __builtin_ia32_rcpps256 (v8sf)
19587 v4df __builtin_ia32_roundpd256 (v4df,int)
19588 v8sf __builtin_ia32_roundps256 (v8sf,int)
19589 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
19590 v8sf __builtin_ia32_rsqrtps256 (v8sf)
19591 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
19592 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
19593 v4si __builtin_ia32_si_si256 (v8si)
19594 v8si __builtin_ia32_si256_si (v4si)
19595 v4df __builtin_ia32_sqrtpd256 (v4df)
19596 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
19597 v8sf __builtin_ia32_sqrtps256 (v8sf)
19598 void __builtin_ia32_storedqu256 (pchar,v32qi)
19599 void __builtin_ia32_storeupd256 (pdouble,v4df)
19600 void __builtin_ia32_storeups256 (pfloat,v8sf)
19601 v4df __builtin_ia32_subpd256 (v4df,v4df)
19602 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
19603 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
19604 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
19605 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
19606 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
19607 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
19608 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
19609 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
19610 v4sf __builtin_ia32_vbroadcastss (pcfloat)
19611 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
19612 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
19613 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
19614 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
19615 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
19616 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
19617 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
19618 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
19619 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
19620 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
19621 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
19622 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
19623 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
19624 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
19625 v2df __builtin_ia32_vpermilpd (v2df,int)
19626 v4df __builtin_ia32_vpermilpd256 (v4df,int)
19627 v4sf __builtin_ia32_vpermilps (v4sf,int)
19628 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
19629 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
19630 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
19631 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
19632 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
19633 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
19634 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
19635 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
19636 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
19637 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
19638 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
19639 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
19640 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
19641 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
19642 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
19643 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
19644 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
19645 void __builtin_ia32_vzeroall (void)
19646 void __builtin_ia32_vzeroupper (void)
19647 v4df __builtin_ia32_xorpd256 (v4df,v4df)
19648 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
19649 @end smallexample
19650
19651 The following built-in functions are available when @option{-mavx2} is
19652 used. All of them generate the machine instruction that is part of the
19653 name.
19654
19655 @smallexample
19656 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
19657 v32qi __builtin_ia32_pabsb256 (v32qi)
19658 v16hi __builtin_ia32_pabsw256 (v16hi)
19659 v8si __builtin_ia32_pabsd256 (v8si)
19660 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
19661 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
19662 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
19663 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
19664 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
19665 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
19666 v8si __builtin_ia32_paddd256 (v8si,v8si)
19667 v4di __builtin_ia32_paddq256 (v4di,v4di)
19668 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
19669 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
19670 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
19671 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
19672 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
19673 v4di __builtin_ia32_andsi256 (v4di,v4di)
19674 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
19675 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
19676 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
19677 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
19678 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
19679 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
19680 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
19681 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
19682 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
19683 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
19684 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
19685 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
19686 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
19687 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
19688 v8si __builtin_ia32_phaddd256 (v8si,v8si)
19689 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
19690 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
19691 v8si __builtin_ia32_phsubd256 (v8si,v8si)
19692 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
19693 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
19694 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
19695 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
19696 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
19697 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
19698 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
19699 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
19700 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
19701 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
19702 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
19703 v8si __builtin_ia32_pminsd256 (v8si,v8si)
19704 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
19705 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
19706 v8si __builtin_ia32_pminud256 (v8si,v8si)
19707 int __builtin_ia32_pmovmskb256 (v32qi)
19708 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
19709 v8si __builtin_ia32_pmovsxbd256 (v16qi)
19710 v4di __builtin_ia32_pmovsxbq256 (v16qi)
19711 v8si __builtin_ia32_pmovsxwd256 (v8hi)
19712 v4di __builtin_ia32_pmovsxwq256 (v8hi)
19713 v4di __builtin_ia32_pmovsxdq256 (v4si)
19714 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
19715 v8si __builtin_ia32_pmovzxbd256 (v16qi)
19716 v4di __builtin_ia32_pmovzxbq256 (v16qi)
19717 v8si __builtin_ia32_pmovzxwd256 (v8hi)
19718 v4di __builtin_ia32_pmovzxwq256 (v8hi)
19719 v4di __builtin_ia32_pmovzxdq256 (v4si)
19720 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
19721 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
19722 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
19723 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
19724 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
19725 v8si __builtin_ia32_pmulld256 (v8si,v8si)
19726 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
19727 v4di __builtin_ia32_por256 (v4di,v4di)
19728 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
19729 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
19730 v8si __builtin_ia32_pshufd256 (v8si,int)
19731 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
19732 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
19733 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
19734 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
19735 v8si __builtin_ia32_psignd256 (v8si,v8si)
19736 v4di __builtin_ia32_pslldqi256 (v4di,int)
19737 v16hi __builtin_ia32_psllwi256 (16hi,int)
19738 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
19739 v8si __builtin_ia32_pslldi256 (v8si,int)
19740 v8si __builtin_ia32_pslld256(v8si,v4si)
19741 v4di __builtin_ia32_psllqi256 (v4di,int)
19742 v4di __builtin_ia32_psllq256(v4di,v2di)
19743 v16hi __builtin_ia32_psrawi256 (v16hi,int)
19744 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
19745 v8si __builtin_ia32_psradi256 (v8si,int)
19746 v8si __builtin_ia32_psrad256 (v8si,v4si)
19747 v4di __builtin_ia32_psrldqi256 (v4di, int)
19748 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
19749 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
19750 v8si __builtin_ia32_psrldi256 (v8si,int)
19751 v8si __builtin_ia32_psrld256 (v8si,v4si)
19752 v4di __builtin_ia32_psrlqi256 (v4di,int)
19753 v4di __builtin_ia32_psrlq256(v4di,v2di)
19754 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
19755 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
19756 v8si __builtin_ia32_psubd256 (v8si,v8si)
19757 v4di __builtin_ia32_psubq256 (v4di,v4di)
19758 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
19759 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
19760 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
19761 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
19762 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
19763 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
19764 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
19765 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
19766 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
19767 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
19768 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
19769 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
19770 v4di __builtin_ia32_pxor256 (v4di,v4di)
19771 v4di __builtin_ia32_movntdqa256 (pv4di)
19772 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
19773 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
19774 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
19775 v4di __builtin_ia32_vbroadcastsi256 (v2di)
19776 v4si __builtin_ia32_pblendd128 (v4si,v4si)
19777 v8si __builtin_ia32_pblendd256 (v8si,v8si)
19778 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
19779 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
19780 v8si __builtin_ia32_pbroadcastd256 (v4si)
19781 v4di __builtin_ia32_pbroadcastq256 (v2di)
19782 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
19783 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
19784 v4si __builtin_ia32_pbroadcastd128 (v4si)
19785 v2di __builtin_ia32_pbroadcastq128 (v2di)
19786 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
19787 v4df __builtin_ia32_permdf256 (v4df,int)
19788 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
19789 v4di __builtin_ia32_permdi256 (v4di,int)
19790 v4di __builtin_ia32_permti256 (v4di,v4di,int)
19791 v4di __builtin_ia32_extract128i256 (v4di,int)
19792 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
19793 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
19794 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
19795 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
19796 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
19797 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
19798 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
19799 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
19800 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
19801 v8si __builtin_ia32_psllv8si (v8si,v8si)
19802 v4si __builtin_ia32_psllv4si (v4si,v4si)
19803 v4di __builtin_ia32_psllv4di (v4di,v4di)
19804 v2di __builtin_ia32_psllv2di (v2di,v2di)
19805 v8si __builtin_ia32_psrav8si (v8si,v8si)
19806 v4si __builtin_ia32_psrav4si (v4si,v4si)
19807 v8si __builtin_ia32_psrlv8si (v8si,v8si)
19808 v4si __builtin_ia32_psrlv4si (v4si,v4si)
19809 v4di __builtin_ia32_psrlv4di (v4di,v4di)
19810 v2di __builtin_ia32_psrlv2di (v2di,v2di)
19811 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
19812 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
19813 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
19814 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
19815 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
19816 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
19817 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
19818 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
19819 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
19820 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
19821 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
19822 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
19823 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
19824 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
19825 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
19826 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
19827 @end smallexample
19828
19829 The following built-in functions are available when @option{-maes} is
19830 used. All of them generate the machine instruction that is part of the
19831 name.
19832
19833 @smallexample
19834 v2di __builtin_ia32_aesenc128 (v2di, v2di)
19835 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
19836 v2di __builtin_ia32_aesdec128 (v2di, v2di)
19837 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
19838 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
19839 v2di __builtin_ia32_aesimc128 (v2di)
19840 @end smallexample
19841
19842 The following built-in function is available when @option{-mpclmul} is
19843 used.
19844
19845 @table @code
19846 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
19847 Generates the @code{pclmulqdq} machine instruction.
19848 @end table
19849
19850 The following built-in function is available when @option{-mfsgsbase} is
19851 used. All of them generate the machine instruction that is part of the
19852 name.
19853
19854 @smallexample
19855 unsigned int __builtin_ia32_rdfsbase32 (void)
19856 unsigned long long __builtin_ia32_rdfsbase64 (void)
19857 unsigned int __builtin_ia32_rdgsbase32 (void)
19858 unsigned long long __builtin_ia32_rdgsbase64 (void)
19859 void _writefsbase_u32 (unsigned int)
19860 void _writefsbase_u64 (unsigned long long)
19861 void _writegsbase_u32 (unsigned int)
19862 void _writegsbase_u64 (unsigned long long)
19863 @end smallexample
19864
19865 The following built-in function is available when @option{-mrdrnd} is
19866 used. All of them generate the machine instruction that is part of the
19867 name.
19868
19869 @smallexample
19870 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
19871 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
19872 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
19873 @end smallexample
19874
19875 The following built-in functions are available when @option{-msse4a} is used.
19876 All of them generate the machine instruction that is part of the name.
19877
19878 @smallexample
19879 void __builtin_ia32_movntsd (double *, v2df)
19880 void __builtin_ia32_movntss (float *, v4sf)
19881 v2di __builtin_ia32_extrq (v2di, v16qi)
19882 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
19883 v2di __builtin_ia32_insertq (v2di, v2di)
19884 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
19885 @end smallexample
19886
19887 The following built-in functions are available when @option{-mxop} is used.
19888 @smallexample
19889 v2df __builtin_ia32_vfrczpd (v2df)
19890 v4sf __builtin_ia32_vfrczps (v4sf)
19891 v2df __builtin_ia32_vfrczsd (v2df)
19892 v4sf __builtin_ia32_vfrczss (v4sf)
19893 v4df __builtin_ia32_vfrczpd256 (v4df)
19894 v8sf __builtin_ia32_vfrczps256 (v8sf)
19895 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
19896 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
19897 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
19898 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
19899 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
19900 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
19901 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
19902 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
19903 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
19904 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
19905 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
19906 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
19907 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
19908 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
19909 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19910 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
19911 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
19912 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
19913 v4si __builtin_ia32_vpcomequd (v4si, v4si)
19914 v2di __builtin_ia32_vpcomequq (v2di, v2di)
19915 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
19916 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19917 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
19918 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
19919 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
19920 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
19921 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
19922 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
19923 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
19924 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
19925 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
19926 v4si __builtin_ia32_vpcomged (v4si, v4si)
19927 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
19928 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
19929 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
19930 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
19931 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
19932 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
19933 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
19934 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
19935 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
19936 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
19937 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
19938 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
19939 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
19940 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
19941 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
19942 v4si __builtin_ia32_vpcomled (v4si, v4si)
19943 v2di __builtin_ia32_vpcomleq (v2di, v2di)
19944 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
19945 v4si __builtin_ia32_vpcomleud (v4si, v4si)
19946 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
19947 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
19948 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
19949 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
19950 v4si __builtin_ia32_vpcomltd (v4si, v4si)
19951 v2di __builtin_ia32_vpcomltq (v2di, v2di)
19952 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
19953 v4si __builtin_ia32_vpcomltud (v4si, v4si)
19954 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
19955 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
19956 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
19957 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
19958 v4si __builtin_ia32_vpcomned (v4si, v4si)
19959 v2di __builtin_ia32_vpcomneq (v2di, v2di)
19960 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
19961 v4si __builtin_ia32_vpcomneud (v4si, v4si)
19962 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
19963 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
19964 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
19965 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
19966 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
19967 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
19968 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
19969 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
19970 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
19971 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
19972 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
19973 v4si __builtin_ia32_vphaddbd (v16qi)
19974 v2di __builtin_ia32_vphaddbq (v16qi)
19975 v8hi __builtin_ia32_vphaddbw (v16qi)
19976 v2di __builtin_ia32_vphadddq (v4si)
19977 v4si __builtin_ia32_vphaddubd (v16qi)
19978 v2di __builtin_ia32_vphaddubq (v16qi)
19979 v8hi __builtin_ia32_vphaddubw (v16qi)
19980 v2di __builtin_ia32_vphaddudq (v4si)
19981 v4si __builtin_ia32_vphadduwd (v8hi)
19982 v2di __builtin_ia32_vphadduwq (v8hi)
19983 v4si __builtin_ia32_vphaddwd (v8hi)
19984 v2di __builtin_ia32_vphaddwq (v8hi)
19985 v8hi __builtin_ia32_vphsubbw (v16qi)
19986 v2di __builtin_ia32_vphsubdq (v4si)
19987 v4si __builtin_ia32_vphsubwd (v8hi)
19988 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
19989 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
19990 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
19991 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
19992 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
19993 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
19994 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
19995 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
19996 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
19997 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
19998 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
19999 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20000 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20001 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20002 v4si __builtin_ia32_vprotd (v4si, v4si)
20003 v2di __builtin_ia32_vprotq (v2di, v2di)
20004 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20005 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20006 v4si __builtin_ia32_vpshad (v4si, v4si)
20007 v2di __builtin_ia32_vpshaq (v2di, v2di)
20008 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20009 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20010 v4si __builtin_ia32_vpshld (v4si, v4si)
20011 v2di __builtin_ia32_vpshlq (v2di, v2di)
20012 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20013 @end smallexample
20014
20015 The following built-in functions are available when @option{-mfma4} is used.
20016 All of them generate the machine instruction that is part of the name.
20017
20018 @smallexample
20019 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20020 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20021 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20022 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20023 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20024 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20025 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20026 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20027 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20028 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20029 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20030 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20031 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20032 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20033 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20034 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20035 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
20036 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
20037 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
20038 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
20039 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20040 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20041 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20042 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20043 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20044 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20045 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20046 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20047 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20048 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20049 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20050 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20051
20052 @end smallexample
20053
20054 The following built-in functions are available when @option{-mlwp} is used.
20055
20056 @smallexample
20057 void __builtin_ia32_llwpcb16 (void *);
20058 void __builtin_ia32_llwpcb32 (void *);
20059 void __builtin_ia32_llwpcb64 (void *);
20060 void * __builtin_ia32_llwpcb16 (void);
20061 void * __builtin_ia32_llwpcb32 (void);
20062 void * __builtin_ia32_llwpcb64 (void);
20063 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20064 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20065 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20066 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20067 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20068 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20069 @end smallexample
20070
20071 The following built-in functions are available when @option{-mbmi} is used.
20072 All of them generate the machine instruction that is part of the name.
20073 @smallexample
20074 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20075 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20076 @end smallexample
20077
20078 The following built-in functions are available when @option{-mbmi2} is used.
20079 All of them generate the machine instruction that is part of the name.
20080 @smallexample
20081 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20082 unsigned int _pdep_u32 (unsigned int, unsigned int)
20083 unsigned int _pext_u32 (unsigned int, unsigned int)
20084 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20085 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20086 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20087 @end smallexample
20088
20089 The following built-in functions are available when @option{-mlzcnt} is used.
20090 All of them generate the machine instruction that is part of the name.
20091 @smallexample
20092 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20093 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20094 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20095 @end smallexample
20096
20097 The following built-in functions are available when @option{-mfxsr} is used.
20098 All of them generate the machine instruction that is part of the name.
20099 @smallexample
20100 void __builtin_ia32_fxsave (void *)
20101 void __builtin_ia32_fxrstor (void *)
20102 void __builtin_ia32_fxsave64 (void *)
20103 void __builtin_ia32_fxrstor64 (void *)
20104 @end smallexample
20105
20106 The following built-in functions are available when @option{-mxsave} is used.
20107 All of them generate the machine instruction that is part of the name.
20108 @smallexample
20109 void __builtin_ia32_xsave (void *, long long)
20110 void __builtin_ia32_xrstor (void *, long long)
20111 void __builtin_ia32_xsave64 (void *, long long)
20112 void __builtin_ia32_xrstor64 (void *, long long)
20113 @end smallexample
20114
20115 The following built-in functions are available when @option{-mxsaveopt} is used.
20116 All of them generate the machine instruction that is part of the name.
20117 @smallexample
20118 void __builtin_ia32_xsaveopt (void *, long long)
20119 void __builtin_ia32_xsaveopt64 (void *, long long)
20120 @end smallexample
20121
20122 The following built-in functions are available when @option{-mtbm} is used.
20123 Both of them generate the immediate form of the bextr machine instruction.
20124 @smallexample
20125 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
20126 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
20127 @end smallexample
20128
20129
20130 The following built-in functions are available when @option{-m3dnow} is used.
20131 All of them generate the machine instruction that is part of the name.
20132
20133 @smallexample
20134 void __builtin_ia32_femms (void)
20135 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20136 v2si __builtin_ia32_pf2id (v2sf)
20137 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20138 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20139 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20140 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20141 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20142 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20143 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20144 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20145 v2sf __builtin_ia32_pfrcp (v2sf)
20146 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20147 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20148 v2sf __builtin_ia32_pfrsqrt (v2sf)
20149 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20150 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20151 v2sf __builtin_ia32_pi2fd (v2si)
20152 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20153 @end smallexample
20154
20155 The following built-in functions are available when both @option{-m3dnow}
20156 and @option{-march=athlon} are used. All of them generate the machine
20157 instruction that is part of the name.
20158
20159 @smallexample
20160 v2si __builtin_ia32_pf2iw (v2sf)
20161 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20162 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20163 v2sf __builtin_ia32_pi2fw (v2si)
20164 v2sf __builtin_ia32_pswapdsf (v2sf)
20165 v2si __builtin_ia32_pswapdsi (v2si)
20166 @end smallexample
20167
20168 The following built-in functions are available when @option{-mrtm} is used
20169 They are used for restricted transactional memory. These are the internal
20170 low level functions. Normally the functions in
20171 @ref{x86 transactional memory intrinsics} should be used instead.
20172
20173 @smallexample
20174 int __builtin_ia32_xbegin ()
20175 void __builtin_ia32_xend ()
20176 void __builtin_ia32_xabort (status)
20177 int __builtin_ia32_xtest ()
20178 @end smallexample
20179
20180 The following built-in functions are available when @option{-mmwaitx} is used.
20181 All of them generate the machine instruction that is part of the name.
20182 @smallexample
20183 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20184 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20185 @end smallexample
20186
20187 The following built-in functions are available when @option{-mclzero} is used.
20188 All of them generate the machine instruction that is part of the name.
20189 @smallexample
20190 void __builtin_i32_clzero (void *)
20191 @end smallexample
20192
20193 The following built-in functions are available when @option{-mpku} is used.
20194 They generate reads and writes to PKRU.
20195 @smallexample
20196 void __builtin_ia32_wrpkru (unsigned int)
20197 unsigned int __builtin_ia32_rdpkru ()
20198 @end smallexample
20199
20200 @node x86 transactional memory intrinsics
20201 @subsection x86 Transactional Memory Intrinsics
20202
20203 These hardware transactional memory intrinsics for x86 allow you to use
20204 memory transactions with RTM (Restricted Transactional Memory).
20205 This support is enabled with the @option{-mrtm} option.
20206 For using HLE (Hardware Lock Elision) see
20207 @ref{x86 specific memory model extensions for transactional memory} instead.
20208
20209 A memory transaction commits all changes to memory in an atomic way,
20210 as visible to other threads. If the transaction fails it is rolled back
20211 and all side effects discarded.
20212
20213 Generally there is no guarantee that a memory transaction ever succeeds
20214 and suitable fallback code always needs to be supplied.
20215
20216 @deftypefn {RTM Function} {unsigned} _xbegin ()
20217 Start a RTM (Restricted Transactional Memory) transaction.
20218 Returns @code{_XBEGIN_STARTED} when the transaction
20219 started successfully (note this is not 0, so the constant has to be
20220 explicitly tested).
20221
20222 If the transaction aborts, all side-effects
20223 are undone and an abort code encoded as a bit mask is returned.
20224 The following macros are defined:
20225
20226 @table @code
20227 @item _XABORT_EXPLICIT
20228 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
20229 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20230 @item _XABORT_RETRY
20231 Transaction retry is possible.
20232 @item _XABORT_CONFLICT
20233 Transaction abort due to a memory conflict with another thread.
20234 @item _XABORT_CAPACITY
20235 Transaction abort due to the transaction using too much memory.
20236 @item _XABORT_DEBUG
20237 Transaction abort due to a debug trap.
20238 @item _XABORT_NESTED
20239 Transaction abort in an inner nested transaction.
20240 @end table
20241
20242 There is no guarantee
20243 any transaction ever succeeds, so there always needs to be a valid
20244 fallback path.
20245 @end deftypefn
20246
20247 @deftypefn {RTM Function} {void} _xend ()
20248 Commit the current transaction. When no transaction is active this faults.
20249 All memory side-effects of the transaction become visible
20250 to other threads in an atomic manner.
20251 @end deftypefn
20252
20253 @deftypefn {RTM Function} {int} _xtest ()
20254 Return a nonzero value if a transaction is currently active, otherwise 0.
20255 @end deftypefn
20256
20257 @deftypefn {RTM Function} {void} _xabort (status)
20258 Abort the current transaction. When no transaction is active this is a no-op.
20259 The @var{status} is an 8-bit constant; its value is encoded in the return
20260 value from @code{_xbegin}.
20261 @end deftypefn
20262
20263 Here is an example showing handling for @code{_XABORT_RETRY}
20264 and a fallback path for other failures:
20265
20266 @smallexample
20267 #include <immintrin.h>
20268
20269 int n_tries, max_tries;
20270 unsigned status = _XABORT_EXPLICIT;
20271 ...
20272
20273 for (n_tries = 0; n_tries < max_tries; n_tries++)
20274 @{
20275 status = _xbegin ();
20276 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20277 break;
20278 @}
20279 if (status == _XBEGIN_STARTED)
20280 @{
20281 ... transaction code...
20282 _xend ();
20283 @}
20284 else
20285 @{
20286 ... non-transactional fallback path...
20287 @}
20288 @end smallexample
20289
20290 @noindent
20291 Note that, in most cases, the transactional and non-transactional code
20292 must synchronize together to ensure consistency.
20293
20294 @node Target Format Checks
20295 @section Format Checks Specific to Particular Target Machines
20296
20297 For some target machines, GCC supports additional options to the
20298 format attribute
20299 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20300
20301 @menu
20302 * Solaris Format Checks::
20303 * Darwin Format Checks::
20304 @end menu
20305
20306 @node Solaris Format Checks
20307 @subsection Solaris Format Checks
20308
20309 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20310 check. @code{cmn_err} accepts a subset of the standard @code{printf}
20311 conversions, and the two-argument @code{%b} conversion for displaying
20312 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
20313
20314 @node Darwin Format Checks
20315 @subsection Darwin Format Checks
20316
20317 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20318 attribute context. Declarations made with such attribution are parsed for correct syntax
20319 and format argument types. However, parsing of the format string itself is currently undefined
20320 and is not carried out by this version of the compiler.
20321
20322 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20323 also be used as format arguments. Note that the relevant headers are only likely to be
20324 available on Darwin (OSX) installations. On such installations, the XCode and system
20325 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20326 associated functions.
20327
20328 @node Pragmas
20329 @section Pragmas Accepted by GCC
20330 @cindex pragmas
20331 @cindex @code{#pragma}
20332
20333 GCC supports several types of pragmas, primarily in order to compile
20334 code originally written for other compilers. Note that in general
20335 we do not recommend the use of pragmas; @xref{Function Attributes},
20336 for further explanation.
20337
20338 @menu
20339 * AArch64 Pragmas::
20340 * ARM Pragmas::
20341 * M32C Pragmas::
20342 * MeP Pragmas::
20343 * RS/6000 and PowerPC Pragmas::
20344 * S/390 Pragmas::
20345 * Darwin Pragmas::
20346 * Solaris Pragmas::
20347 * Symbol-Renaming Pragmas::
20348 * Structure-Layout Pragmas::
20349 * Weak Pragmas::
20350 * Diagnostic Pragmas::
20351 * Visibility Pragmas::
20352 * Push/Pop Macro Pragmas::
20353 * Function Specific Option Pragmas::
20354 * Loop-Specific Pragmas::
20355 @end menu
20356
20357 @node AArch64 Pragmas
20358 @subsection AArch64 Pragmas
20359
20360 The pragmas defined by the AArch64 target correspond to the AArch64
20361 target function attributes. They can be specified as below:
20362 @smallexample
20363 #pragma GCC target("string")
20364 @end smallexample
20365
20366 where @code{@var{string}} can be any string accepted as an AArch64 target
20367 attribute. @xref{AArch64 Function Attributes}, for more details
20368 on the permissible values of @code{string}.
20369
20370 @node ARM Pragmas
20371 @subsection ARM Pragmas
20372
20373 The ARM target defines pragmas for controlling the default addition of
20374 @code{long_call} and @code{short_call} attributes to functions.
20375 @xref{Function Attributes}, for information about the effects of these
20376 attributes.
20377
20378 @table @code
20379 @item long_calls
20380 @cindex pragma, long_calls
20381 Set all subsequent functions to have the @code{long_call} attribute.
20382
20383 @item no_long_calls
20384 @cindex pragma, no_long_calls
20385 Set all subsequent functions to have the @code{short_call} attribute.
20386
20387 @item long_calls_off
20388 @cindex pragma, long_calls_off
20389 Do not affect the @code{long_call} or @code{short_call} attributes of
20390 subsequent functions.
20391 @end table
20392
20393 @node M32C Pragmas
20394 @subsection M32C Pragmas
20395
20396 @table @code
20397 @item GCC memregs @var{number}
20398 @cindex pragma, memregs
20399 Overrides the command-line option @code{-memregs=} for the current
20400 file. Use with care! This pragma must be before any function in the
20401 file, and mixing different memregs values in different objects may
20402 make them incompatible. This pragma is useful when a
20403 performance-critical function uses a memreg for temporary values,
20404 as it may allow you to reduce the number of memregs used.
20405
20406 @item ADDRESS @var{name} @var{address}
20407 @cindex pragma, address
20408 For any declared symbols matching @var{name}, this does three things
20409 to that symbol: it forces the symbol to be located at the given
20410 address (a number), it forces the symbol to be volatile, and it
20411 changes the symbol's scope to be static. This pragma exists for
20412 compatibility with other compilers, but note that the common
20413 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20414 instead). Example:
20415
20416 @smallexample
20417 #pragma ADDRESS port3 0x103
20418 char port3;
20419 @end smallexample
20420
20421 @end table
20422
20423 @node MeP Pragmas
20424 @subsection MeP Pragmas
20425
20426 @table @code
20427
20428 @item custom io_volatile (on|off)
20429 @cindex pragma, custom io_volatile
20430 Overrides the command-line option @code{-mio-volatile} for the current
20431 file. Note that for compatibility with future GCC releases, this
20432 option should only be used once before any @code{io} variables in each
20433 file.
20434
20435 @item GCC coprocessor available @var{registers}
20436 @cindex pragma, coprocessor available
20437 Specifies which coprocessor registers are available to the register
20438 allocator. @var{registers} may be a single register, register range
20439 separated by ellipses, or comma-separated list of those. Example:
20440
20441 @smallexample
20442 #pragma GCC coprocessor available $c0...$c10, $c28
20443 @end smallexample
20444
20445 @item GCC coprocessor call_saved @var{registers}
20446 @cindex pragma, coprocessor call_saved
20447 Specifies which coprocessor registers are to be saved and restored by
20448 any function using them. @var{registers} may be a single register,
20449 register range separated by ellipses, or comma-separated list of
20450 those. Example:
20451
20452 @smallexample
20453 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20454 @end smallexample
20455
20456 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20457 @cindex pragma, coprocessor subclass
20458 Creates and defines a register class. These register classes can be
20459 used by inline @code{asm} constructs. @var{registers} may be a single
20460 register, register range separated by ellipses, or comma-separated
20461 list of those. Example:
20462
20463 @smallexample
20464 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20465
20466 asm ("cpfoo %0" : "=B" (x));
20467 @end smallexample
20468
20469 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20470 @cindex pragma, disinterrupt
20471 For the named functions, the compiler adds code to disable interrupts
20472 for the duration of those functions. If any functions so named
20473 are not encountered in the source, a warning is emitted that the pragma is
20474 not used. Examples:
20475
20476 @smallexample
20477 #pragma disinterrupt foo
20478 #pragma disinterrupt bar, grill
20479 int foo () @{ @dots{} @}
20480 @end smallexample
20481
20482 @item GCC call @var{name} , @var{name} @dots{}
20483 @cindex pragma, call
20484 For the named functions, the compiler always uses a register-indirect
20485 call model when calling the named functions. Examples:
20486
20487 @smallexample
20488 extern int foo ();
20489 #pragma call foo
20490 @end smallexample
20491
20492 @end table
20493
20494 @node RS/6000 and PowerPC Pragmas
20495 @subsection RS/6000 and PowerPC Pragmas
20496
20497 The RS/6000 and PowerPC targets define one pragma for controlling
20498 whether or not the @code{longcall} attribute is added to function
20499 declarations by default. This pragma overrides the @option{-mlongcall}
20500 option, but not the @code{longcall} and @code{shortcall} attributes.
20501 @xref{RS/6000 and PowerPC Options}, for more information about when long
20502 calls are and are not necessary.
20503
20504 @table @code
20505 @item longcall (1)
20506 @cindex pragma, longcall
20507 Apply the @code{longcall} attribute to all subsequent function
20508 declarations.
20509
20510 @item longcall (0)
20511 Do not apply the @code{longcall} attribute to subsequent function
20512 declarations.
20513 @end table
20514
20515 @c Describe h8300 pragmas here.
20516 @c Describe sh pragmas here.
20517 @c Describe v850 pragmas here.
20518
20519 @node S/390 Pragmas
20520 @subsection S/390 Pragmas
20521
20522 The pragmas defined by the S/390 target correspond to the S/390
20523 target function attributes and some the additional options:
20524
20525 @table @samp
20526 @item zvector
20527 @itemx no-zvector
20528 @end table
20529
20530 Note that options of the pragma, unlike options of the target
20531 attribute, do change the value of preprocessor macros like
20532 @code{__VEC__}. They can be specified as below:
20533
20534 @smallexample
20535 #pragma GCC target("string[,string]...")
20536 #pragma GCC target("string"[,"string"]...)
20537 @end smallexample
20538
20539 @node Darwin Pragmas
20540 @subsection Darwin Pragmas
20541
20542 The following pragmas are available for all architectures running the
20543 Darwin operating system. These are useful for compatibility with other
20544 Mac OS compilers.
20545
20546 @table @code
20547 @item mark @var{tokens}@dots{}
20548 @cindex pragma, mark
20549 This pragma is accepted, but has no effect.
20550
20551 @item options align=@var{alignment}
20552 @cindex pragma, options align
20553 This pragma sets the alignment of fields in structures. The values of
20554 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
20555 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
20556 properly; to restore the previous setting, use @code{reset} for the
20557 @var{alignment}.
20558
20559 @item segment @var{tokens}@dots{}
20560 @cindex pragma, segment
20561 This pragma is accepted, but has no effect.
20562
20563 @item unused (@var{var} [, @var{var}]@dots{})
20564 @cindex pragma, unused
20565 This pragma declares variables to be possibly unused. GCC does not
20566 produce warnings for the listed variables. The effect is similar to
20567 that of the @code{unused} attribute, except that this pragma may appear
20568 anywhere within the variables' scopes.
20569 @end table
20570
20571 @node Solaris Pragmas
20572 @subsection Solaris Pragmas
20573
20574 The Solaris target supports @code{#pragma redefine_extname}
20575 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
20576 @code{#pragma} directives for compatibility with the system compiler.
20577
20578 @table @code
20579 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
20580 @cindex pragma, align
20581
20582 Increase the minimum alignment of each @var{variable} to @var{alignment}.
20583 This is the same as GCC's @code{aligned} attribute @pxref{Variable
20584 Attributes}). Macro expansion occurs on the arguments to this pragma
20585 when compiling C and Objective-C@. It does not currently occur when
20586 compiling C++, but this is a bug which may be fixed in a future
20587 release.
20588
20589 @item fini (@var{function} [, @var{function}]...)
20590 @cindex pragma, fini
20591
20592 This pragma causes each listed @var{function} to be called after
20593 main, or during shared module unloading, by adding a call to the
20594 @code{.fini} section.
20595
20596 @item init (@var{function} [, @var{function}]...)
20597 @cindex pragma, init
20598
20599 This pragma causes each listed @var{function} to be called during
20600 initialization (before @code{main}) or during shared module loading, by
20601 adding a call to the @code{.init} section.
20602
20603 @end table
20604
20605 @node Symbol-Renaming Pragmas
20606 @subsection Symbol-Renaming Pragmas
20607
20608 GCC supports a @code{#pragma} directive that changes the name used in
20609 assembly for a given declaration. While this pragma is supported on all
20610 platforms, it is intended primarily to provide compatibility with the
20611 Solaris system headers. This effect can also be achieved using the asm
20612 labels extension (@pxref{Asm Labels}).
20613
20614 @table @code
20615 @item redefine_extname @var{oldname} @var{newname}
20616 @cindex pragma, redefine_extname
20617
20618 This pragma gives the C function @var{oldname} the assembly symbol
20619 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
20620 is defined if this pragma is available (currently on all platforms).
20621 @end table
20622
20623 This pragma and the asm labels extension interact in a complicated
20624 manner. Here are some corner cases you may want to be aware of:
20625
20626 @enumerate
20627 @item This pragma silently applies only to declarations with external
20628 linkage. Asm labels do not have this restriction.
20629
20630 @item In C++, this pragma silently applies only to declarations with
20631 ``C'' linkage. Again, asm labels do not have this restriction.
20632
20633 @item If either of the ways of changing the assembly name of a
20634 declaration are applied to a declaration whose assembly name has
20635 already been determined (either by a previous use of one of these
20636 features, or because the compiler needed the assembly name in order to
20637 generate code), and the new name is different, a warning issues and
20638 the name does not change.
20639
20640 @item The @var{oldname} used by @code{#pragma redefine_extname} is
20641 always the C-language name.
20642 @end enumerate
20643
20644 @node Structure-Layout Pragmas
20645 @subsection Structure-Layout Pragmas
20646
20647 For compatibility with Microsoft Windows compilers, GCC supports a
20648 set of @code{#pragma} directives that change the maximum alignment of
20649 members of structures (other than zero-width bit-fields), unions, and
20650 classes subsequently defined. The @var{n} value below always is required
20651 to be a small power of two and specifies the new alignment in bytes.
20652
20653 @enumerate
20654 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
20655 @item @code{#pragma pack()} sets the alignment to the one that was in
20656 effect when compilation started (see also command-line option
20657 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
20658 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
20659 setting on an internal stack and then optionally sets the new alignment.
20660 @item @code{#pragma pack(pop)} restores the alignment setting to the one
20661 saved at the top of the internal stack (and removes that stack entry).
20662 Note that @code{#pragma pack([@var{n}])} does not influence this internal
20663 stack; thus it is possible to have @code{#pragma pack(push)} followed by
20664 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
20665 @code{#pragma pack(pop)}.
20666 @end enumerate
20667
20668 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
20669 directive which lays out structures and unions subsequently defined as the
20670 documented @code{__attribute__ ((ms_struct))}.
20671
20672 @enumerate
20673 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
20674 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
20675 @item @code{#pragma ms_struct reset} goes back to the default layout.
20676 @end enumerate
20677
20678 Most targets also support the @code{#pragma scalar_storage_order} directive
20679 which lays out structures and unions subsequently defined as the documented
20680 @code{__attribute__ ((scalar_storage_order))}.
20681
20682 @enumerate
20683 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
20684 of the scalar fields to big-endian.
20685 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
20686 of the scalar fields to little-endian.
20687 @item @code{#pragma scalar_storage_order default} goes back to the endianness
20688 that was in effect when compilation started (see also command-line option
20689 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
20690 @end enumerate
20691
20692 @node Weak Pragmas
20693 @subsection Weak Pragmas
20694
20695 For compatibility with SVR4, GCC supports a set of @code{#pragma}
20696 directives for declaring symbols to be weak, and defining weak
20697 aliases.
20698
20699 @table @code
20700 @item #pragma weak @var{symbol}
20701 @cindex pragma, weak
20702 This pragma declares @var{symbol} to be weak, as if the declaration
20703 had the attribute of the same name. The pragma may appear before
20704 or after the declaration of @var{symbol}. It is not an error for
20705 @var{symbol} to never be defined at all.
20706
20707 @item #pragma weak @var{symbol1} = @var{symbol2}
20708 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
20709 It is an error if @var{symbol2} is not defined in the current
20710 translation unit.
20711 @end table
20712
20713 @node Diagnostic Pragmas
20714 @subsection Diagnostic Pragmas
20715
20716 GCC allows the user to selectively enable or disable certain types of
20717 diagnostics, and change the kind of the diagnostic. For example, a
20718 project's policy might require that all sources compile with
20719 @option{-Werror} but certain files might have exceptions allowing
20720 specific types of warnings. Or, a project might selectively enable
20721 diagnostics and treat them as errors depending on which preprocessor
20722 macros are defined.
20723
20724 @table @code
20725 @item #pragma GCC diagnostic @var{kind} @var{option}
20726 @cindex pragma, diagnostic
20727
20728 Modifies the disposition of a diagnostic. Note that not all
20729 diagnostics are modifiable; at the moment only warnings (normally
20730 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
20731 Use @option{-fdiagnostics-show-option} to determine which diagnostics
20732 are controllable and which option controls them.
20733
20734 @var{kind} is @samp{error} to treat this diagnostic as an error,
20735 @samp{warning} to treat it like a warning (even if @option{-Werror} is
20736 in effect), or @samp{ignored} if the diagnostic is to be ignored.
20737 @var{option} is a double quoted string that matches the command-line
20738 option.
20739
20740 @smallexample
20741 #pragma GCC diagnostic warning "-Wformat"
20742 #pragma GCC diagnostic error "-Wformat"
20743 #pragma GCC diagnostic ignored "-Wformat"
20744 @end smallexample
20745
20746 Note that these pragmas override any command-line options. GCC keeps
20747 track of the location of each pragma, and issues diagnostics according
20748 to the state as of that point in the source file. Thus, pragmas occurring
20749 after a line do not affect diagnostics caused by that line.
20750
20751 @item #pragma GCC diagnostic push
20752 @itemx #pragma GCC diagnostic pop
20753
20754 Causes GCC to remember the state of the diagnostics as of each
20755 @code{push}, and restore to that point at each @code{pop}. If a
20756 @code{pop} has no matching @code{push}, the command-line options are
20757 restored.
20758
20759 @smallexample
20760 #pragma GCC diagnostic error "-Wuninitialized"
20761 foo(a); /* error is given for this one */
20762 #pragma GCC diagnostic push
20763 #pragma GCC diagnostic ignored "-Wuninitialized"
20764 foo(b); /* no diagnostic for this one */
20765 #pragma GCC diagnostic pop
20766 foo(c); /* error is given for this one */
20767 #pragma GCC diagnostic pop
20768 foo(d); /* depends on command-line options */
20769 @end smallexample
20770
20771 @end table
20772
20773 GCC also offers a simple mechanism for printing messages during
20774 compilation.
20775
20776 @table @code
20777 @item #pragma message @var{string}
20778 @cindex pragma, diagnostic
20779
20780 Prints @var{string} as a compiler message on compilation. The message
20781 is informational only, and is neither a compilation warning nor an error.
20782
20783 @smallexample
20784 #pragma message "Compiling " __FILE__ "..."
20785 @end smallexample
20786
20787 @var{string} may be parenthesized, and is printed with location
20788 information. For example,
20789
20790 @smallexample
20791 #define DO_PRAGMA(x) _Pragma (#x)
20792 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
20793
20794 TODO(Remember to fix this)
20795 @end smallexample
20796
20797 @noindent
20798 prints @samp{/tmp/file.c:4: note: #pragma message:
20799 TODO - Remember to fix this}.
20800
20801 @end table
20802
20803 @node Visibility Pragmas
20804 @subsection Visibility Pragmas
20805
20806 @table @code
20807 @item #pragma GCC visibility push(@var{visibility})
20808 @itemx #pragma GCC visibility pop
20809 @cindex pragma, visibility
20810
20811 This pragma allows the user to set the visibility for multiple
20812 declarations without having to give each a visibility attribute
20813 (@pxref{Function Attributes}).
20814
20815 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
20816 declarations. Class members and template specializations are not
20817 affected; if you want to override the visibility for a particular
20818 member or instantiation, you must use an attribute.
20819
20820 @end table
20821
20822
20823 @node Push/Pop Macro Pragmas
20824 @subsection Push/Pop Macro Pragmas
20825
20826 For compatibility with Microsoft Windows compilers, GCC supports
20827 @samp{#pragma push_macro(@var{"macro_name"})}
20828 and @samp{#pragma pop_macro(@var{"macro_name"})}.
20829
20830 @table @code
20831 @item #pragma push_macro(@var{"macro_name"})
20832 @cindex pragma, push_macro
20833 This pragma saves the value of the macro named as @var{macro_name} to
20834 the top of the stack for this macro.
20835
20836 @item #pragma pop_macro(@var{"macro_name"})
20837 @cindex pragma, pop_macro
20838 This pragma sets the value of the macro named as @var{macro_name} to
20839 the value on top of the stack for this macro. If the stack for
20840 @var{macro_name} is empty, the value of the macro remains unchanged.
20841 @end table
20842
20843 For example:
20844
20845 @smallexample
20846 #define X 1
20847 #pragma push_macro("X")
20848 #undef X
20849 #define X -1
20850 #pragma pop_macro("X")
20851 int x [X];
20852 @end smallexample
20853
20854 @noindent
20855 In this example, the definition of X as 1 is saved by @code{#pragma
20856 push_macro} and restored by @code{#pragma pop_macro}.
20857
20858 @node Function Specific Option Pragmas
20859 @subsection Function Specific Option Pragmas
20860
20861 @table @code
20862 @item #pragma GCC target (@var{"string"}...)
20863 @cindex pragma GCC target
20864
20865 This pragma allows you to set target specific options for functions
20866 defined later in the source file. One or more strings can be
20867 specified. Each function that is defined after this point is as
20868 if @code{attribute((target("STRING")))} was specified for that
20869 function. The parenthesis around the options is optional.
20870 @xref{Function Attributes}, for more information about the
20871 @code{target} attribute and the attribute syntax.
20872
20873 The @code{#pragma GCC target} pragma is presently implemented for
20874 x86, PowerPC, and Nios II targets only.
20875 @end table
20876
20877 @table @code
20878 @item #pragma GCC optimize (@var{"string"}...)
20879 @cindex pragma GCC optimize
20880
20881 This pragma allows you to set global optimization options for functions
20882 defined later in the source file. One or more strings can be
20883 specified. Each function that is defined after this point is as
20884 if @code{attribute((optimize("STRING")))} was specified for that
20885 function. The parenthesis around the options is optional.
20886 @xref{Function Attributes}, for more information about the
20887 @code{optimize} attribute and the attribute syntax.
20888 @end table
20889
20890 @table @code
20891 @item #pragma GCC push_options
20892 @itemx #pragma GCC pop_options
20893 @cindex pragma GCC push_options
20894 @cindex pragma GCC pop_options
20895
20896 These pragmas maintain a stack of the current target and optimization
20897 options. It is intended for include files where you temporarily want
20898 to switch to using a different @samp{#pragma GCC target} or
20899 @samp{#pragma GCC optimize} and then to pop back to the previous
20900 options.
20901 @end table
20902
20903 @table @code
20904 @item #pragma GCC reset_options
20905 @cindex pragma GCC reset_options
20906
20907 This pragma clears the current @code{#pragma GCC target} and
20908 @code{#pragma GCC optimize} to use the default switches as specified
20909 on the command line.
20910 @end table
20911
20912 @node Loop-Specific Pragmas
20913 @subsection Loop-Specific Pragmas
20914
20915 @table @code
20916 @item #pragma GCC ivdep
20917 @cindex pragma GCC ivdep
20918 @end table
20919
20920 With this pragma, the programmer asserts that there are no loop-carried
20921 dependencies which would prevent consecutive iterations of
20922 the following loop from executing concurrently with SIMD
20923 (single instruction multiple data) instructions.
20924
20925 For example, the compiler can only unconditionally vectorize the following
20926 loop with the pragma:
20927
20928 @smallexample
20929 void foo (int n, int *a, int *b, int *c)
20930 @{
20931 int i, j;
20932 #pragma GCC ivdep
20933 for (i = 0; i < n; ++i)
20934 a[i] = b[i] + c[i];
20935 @}
20936 @end smallexample
20937
20938 @noindent
20939 In this example, using the @code{restrict} qualifier had the same
20940 effect. In the following example, that would not be possible. Assume
20941 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
20942 that it can unconditionally vectorize the following loop:
20943
20944 @smallexample
20945 void ignore_vec_dep (int *a, int k, int c, int m)
20946 @{
20947 #pragma GCC ivdep
20948 for (int i = 0; i < m; i++)
20949 a[i] = a[i + k] * c;
20950 @}
20951 @end smallexample
20952
20953
20954 @node Unnamed Fields
20955 @section Unnamed Structure and Union Fields
20956 @cindex @code{struct}
20957 @cindex @code{union}
20958
20959 As permitted by ISO C11 and for compatibility with other compilers,
20960 GCC allows you to define
20961 a structure or union that contains, as fields, structures and unions
20962 without names. For example:
20963
20964 @smallexample
20965 struct @{
20966 int a;
20967 union @{
20968 int b;
20969 float c;
20970 @};
20971 int d;
20972 @} foo;
20973 @end smallexample
20974
20975 @noindent
20976 In this example, you are able to access members of the unnamed
20977 union with code like @samp{foo.b}. Note that only unnamed structs and
20978 unions are allowed, you may not have, for example, an unnamed
20979 @code{int}.
20980
20981 You must never create such structures that cause ambiguous field definitions.
20982 For example, in this structure:
20983
20984 @smallexample
20985 struct @{
20986 int a;
20987 struct @{
20988 int a;
20989 @};
20990 @} foo;
20991 @end smallexample
20992
20993 @noindent
20994 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
20995 The compiler gives errors for such constructs.
20996
20997 @opindex fms-extensions
20998 Unless @option{-fms-extensions} is used, the unnamed field must be a
20999 structure or union definition without a tag (for example, @samp{struct
21000 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
21001 also be a definition with a tag such as @samp{struct foo @{ int a;
21002 @};}, a reference to a previously defined structure or union such as
21003 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21004 previously defined structure or union type.
21005
21006 @opindex fplan9-extensions
21007 The option @option{-fplan9-extensions} enables
21008 @option{-fms-extensions} as well as two other extensions. First, a
21009 pointer to a structure is automatically converted to a pointer to an
21010 anonymous field for assignments and function calls. For example:
21011
21012 @smallexample
21013 struct s1 @{ int a; @};
21014 struct s2 @{ struct s1; @};
21015 extern void f1 (struct s1 *);
21016 void f2 (struct s2 *p) @{ f1 (p); @}
21017 @end smallexample
21018
21019 @noindent
21020 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21021 converted into a pointer to the anonymous field.
21022
21023 Second, when the type of an anonymous field is a @code{typedef} for a
21024 @code{struct} or @code{union}, code may refer to the field using the
21025 name of the @code{typedef}.
21026
21027 @smallexample
21028 typedef struct @{ int a; @} s1;
21029 struct s2 @{ s1; @};
21030 s1 f1 (struct s2 *p) @{ return p->s1; @}
21031 @end smallexample
21032
21033 These usages are only permitted when they are not ambiguous.
21034
21035 @node Thread-Local
21036 @section Thread-Local Storage
21037 @cindex Thread-Local Storage
21038 @cindex @acronym{TLS}
21039 @cindex @code{__thread}
21040
21041 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21042 are allocated such that there is one instance of the variable per extant
21043 thread. The runtime model GCC uses to implement this originates
21044 in the IA-64 processor-specific ABI, but has since been migrated
21045 to other processors as well. It requires significant support from
21046 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21047 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21048 is not available everywhere.
21049
21050 At the user level, the extension is visible with a new storage
21051 class keyword: @code{__thread}. For example:
21052
21053 @smallexample
21054 __thread int i;
21055 extern __thread struct state s;
21056 static __thread char *p;
21057 @end smallexample
21058
21059 The @code{__thread} specifier may be used alone, with the @code{extern}
21060 or @code{static} specifiers, but with no other storage class specifier.
21061 When used with @code{extern} or @code{static}, @code{__thread} must appear
21062 immediately after the other storage class specifier.
21063
21064 The @code{__thread} specifier may be applied to any global, file-scoped
21065 static, function-scoped static, or static data member of a class. It may
21066 not be applied to block-scoped automatic or non-static data member.
21067
21068 When the address-of operator is applied to a thread-local variable, it is
21069 evaluated at run time and returns the address of the current thread's
21070 instance of that variable. An address so obtained may be used by any
21071 thread. When a thread terminates, any pointers to thread-local variables
21072 in that thread become invalid.
21073
21074 No static initialization may refer to the address of a thread-local variable.
21075
21076 In C++, if an initializer is present for a thread-local variable, it must
21077 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21078 standard.
21079
21080 See @uref{http://www.akkadia.org/drepper/tls.pdf,
21081 ELF Handling For Thread-Local Storage} for a detailed explanation of
21082 the four thread-local storage addressing models, and how the runtime
21083 is expected to function.
21084
21085 @menu
21086 * C99 Thread-Local Edits::
21087 * C++98 Thread-Local Edits::
21088 @end menu
21089
21090 @node C99 Thread-Local Edits
21091 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21092
21093 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21094 that document the exact semantics of the language extension.
21095
21096 @itemize @bullet
21097 @item
21098 @cite{5.1.2 Execution environments}
21099
21100 Add new text after paragraph 1
21101
21102 @quotation
21103 Within either execution environment, a @dfn{thread} is a flow of
21104 control within a program. It is implementation defined whether
21105 or not there may be more than one thread associated with a program.
21106 It is implementation defined how threads beyond the first are
21107 created, the name and type of the function called at thread
21108 startup, and how threads may be terminated. However, objects
21109 with thread storage duration shall be initialized before thread
21110 startup.
21111 @end quotation
21112
21113 @item
21114 @cite{6.2.4 Storage durations of objects}
21115
21116 Add new text before paragraph 3
21117
21118 @quotation
21119 An object whose identifier is declared with the storage-class
21120 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21121 Its lifetime is the entire execution of the thread, and its
21122 stored value is initialized only once, prior to thread startup.
21123 @end quotation
21124
21125 @item
21126 @cite{6.4.1 Keywords}
21127
21128 Add @code{__thread}.
21129
21130 @item
21131 @cite{6.7.1 Storage-class specifiers}
21132
21133 Add @code{__thread} to the list of storage class specifiers in
21134 paragraph 1.
21135
21136 Change paragraph 2 to
21137
21138 @quotation
21139 With the exception of @code{__thread}, at most one storage-class
21140 specifier may be given [@dots{}]. The @code{__thread} specifier may
21141 be used alone, or immediately following @code{extern} or
21142 @code{static}.
21143 @end quotation
21144
21145 Add new text after paragraph 6
21146
21147 @quotation
21148 The declaration of an identifier for a variable that has
21149 block scope that specifies @code{__thread} shall also
21150 specify either @code{extern} or @code{static}.
21151
21152 The @code{__thread} specifier shall be used only with
21153 variables.
21154 @end quotation
21155 @end itemize
21156
21157 @node C++98 Thread-Local Edits
21158 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21159
21160 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21161 that document the exact semantics of the language extension.
21162
21163 @itemize @bullet
21164 @item
21165 @b{[intro.execution]}
21166
21167 New text after paragraph 4
21168
21169 @quotation
21170 A @dfn{thread} is a flow of control within the abstract machine.
21171 It is implementation defined whether or not there may be more than
21172 one thread.
21173 @end quotation
21174
21175 New text after paragraph 7
21176
21177 @quotation
21178 It is unspecified whether additional action must be taken to
21179 ensure when and whether side effects are visible to other threads.
21180 @end quotation
21181
21182 @item
21183 @b{[lex.key]}
21184
21185 Add @code{__thread}.
21186
21187 @item
21188 @b{[basic.start.main]}
21189
21190 Add after paragraph 5
21191
21192 @quotation
21193 The thread that begins execution at the @code{main} function is called
21194 the @dfn{main thread}. It is implementation defined how functions
21195 beginning threads other than the main thread are designated or typed.
21196 A function so designated, as well as the @code{main} function, is called
21197 a @dfn{thread startup function}. It is implementation defined what
21198 happens if a thread startup function returns. It is implementation
21199 defined what happens to other threads when any thread calls @code{exit}.
21200 @end quotation
21201
21202 @item
21203 @b{[basic.start.init]}
21204
21205 Add after paragraph 4
21206
21207 @quotation
21208 The storage for an object of thread storage duration shall be
21209 statically initialized before the first statement of the thread startup
21210 function. An object of thread storage duration shall not require
21211 dynamic initialization.
21212 @end quotation
21213
21214 @item
21215 @b{[basic.start.term]}
21216
21217 Add after paragraph 3
21218
21219 @quotation
21220 The type of an object with thread storage duration shall not have a
21221 non-trivial destructor, nor shall it be an array type whose elements
21222 (directly or indirectly) have non-trivial destructors.
21223 @end quotation
21224
21225 @item
21226 @b{[basic.stc]}
21227
21228 Add ``thread storage duration'' to the list in paragraph 1.
21229
21230 Change paragraph 2
21231
21232 @quotation
21233 Thread, static, and automatic storage durations are associated with
21234 objects introduced by declarations [@dots{}].
21235 @end quotation
21236
21237 Add @code{__thread} to the list of specifiers in paragraph 3.
21238
21239 @item
21240 @b{[basic.stc.thread]}
21241
21242 New section before @b{[basic.stc.static]}
21243
21244 @quotation
21245 The keyword @code{__thread} applied to a non-local object gives the
21246 object thread storage duration.
21247
21248 A local variable or class data member declared both @code{static}
21249 and @code{__thread} gives the variable or member thread storage
21250 duration.
21251 @end quotation
21252
21253 @item
21254 @b{[basic.stc.static]}
21255
21256 Change paragraph 1
21257
21258 @quotation
21259 All objects that have neither thread storage duration, dynamic
21260 storage duration nor are local [@dots{}].
21261 @end quotation
21262
21263 @item
21264 @b{[dcl.stc]}
21265
21266 Add @code{__thread} to the list in paragraph 1.
21267
21268 Change paragraph 1
21269
21270 @quotation
21271 With the exception of @code{__thread}, at most one
21272 @var{storage-class-specifier} shall appear in a given
21273 @var{decl-specifier-seq}. The @code{__thread} specifier may
21274 be used alone, or immediately following the @code{extern} or
21275 @code{static} specifiers. [@dots{}]
21276 @end quotation
21277
21278 Add after paragraph 5
21279
21280 @quotation
21281 The @code{__thread} specifier can be applied only to the names of objects
21282 and to anonymous unions.
21283 @end quotation
21284
21285 @item
21286 @b{[class.mem]}
21287
21288 Add after paragraph 6
21289
21290 @quotation
21291 Non-@code{static} members shall not be @code{__thread}.
21292 @end quotation
21293 @end itemize
21294
21295 @node Binary constants
21296 @section Binary Constants using the @samp{0b} Prefix
21297 @cindex Binary constants using the @samp{0b} prefix
21298
21299 Integer constants can be written as binary constants, consisting of a
21300 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21301 @samp{0B}. This is particularly useful in environments that operate a
21302 lot on the bit level (like microcontrollers).
21303
21304 The following statements are identical:
21305
21306 @smallexample
21307 i = 42;
21308 i = 0x2a;
21309 i = 052;
21310 i = 0b101010;
21311 @end smallexample
21312
21313 The type of these constants follows the same rules as for octal or
21314 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21315 can be applied.
21316
21317 @node C++ Extensions
21318 @chapter Extensions to the C++ Language
21319 @cindex extensions, C++ language
21320 @cindex C++ language extensions
21321
21322 The GNU compiler provides these extensions to the C++ language (and you
21323 can also use most of the C language extensions in your C++ programs). If you
21324 want to write code that checks whether these features are available, you can
21325 test for the GNU compiler the same way as for C programs: check for a
21326 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
21327 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21328 Predefined Macros,cpp,The GNU C Preprocessor}).
21329
21330 @menu
21331 * C++ Volatiles:: What constitutes an access to a volatile object.
21332 * Restricted Pointers:: C99 restricted pointers and references.
21333 * Vague Linkage:: Where G++ puts inlines, vtables and such.
21334 * C++ Interface:: You can use a single C++ header file for both
21335 declarations and definitions.
21336 * Template Instantiation:: Methods for ensuring that exactly one copy of
21337 each needed template instantiation is emitted.
21338 * Bound member functions:: You can extract a function pointer to the
21339 method denoted by a @samp{->*} or @samp{.*} expression.
21340 * C++ Attributes:: Variable, function, and type attributes for C++ only.
21341 * Function Multiversioning:: Declaring multiple function versions.
21342 * Namespace Association:: Strong using-directives for namespace association.
21343 * Type Traits:: Compiler support for type traits.
21344 * C++ Concepts:: Improved support for generic programming.
21345 * Java Exceptions:: Tweaking exception handling to work with Java.
21346 * Deprecated Features:: Things will disappear from G++.
21347 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21348 @end menu
21349
21350 @node C++ Volatiles
21351 @section When is a Volatile C++ Object Accessed?
21352 @cindex accessing volatiles
21353 @cindex volatile read
21354 @cindex volatile write
21355 @cindex volatile access
21356
21357 The C++ standard differs from the C standard in its treatment of
21358 volatile objects. It fails to specify what constitutes a volatile
21359 access, except to say that C++ should behave in a similar manner to C
21360 with respect to volatiles, where possible. However, the different
21361 lvalueness of expressions between C and C++ complicate the behavior.
21362 G++ behaves the same as GCC for volatile access, @xref{C
21363 Extensions,,Volatiles}, for a description of GCC's behavior.
21364
21365 The C and C++ language specifications differ when an object is
21366 accessed in a void context:
21367
21368 @smallexample
21369 volatile int *src = @var{somevalue};
21370 *src;
21371 @end smallexample
21372
21373 The C++ standard specifies that such expressions do not undergo lvalue
21374 to rvalue conversion, and that the type of the dereferenced object may
21375 be incomplete. The C++ standard does not specify explicitly that it
21376 is lvalue to rvalue conversion that is responsible for causing an
21377 access. There is reason to believe that it is, because otherwise
21378 certain simple expressions become undefined. However, because it
21379 would surprise most programmers, G++ treats dereferencing a pointer to
21380 volatile object of complete type as GCC would do for an equivalent
21381 type in C@. When the object has incomplete type, G++ issues a
21382 warning; if you wish to force an error, you must force a conversion to
21383 rvalue with, for instance, a static cast.
21384
21385 When using a reference to volatile, G++ does not treat equivalent
21386 expressions as accesses to volatiles, but instead issues a warning that
21387 no volatile is accessed. The rationale for this is that otherwise it
21388 becomes difficult to determine where volatile access occur, and not
21389 possible to ignore the return value from functions returning volatile
21390 references. Again, if you wish to force a read, cast the reference to
21391 an rvalue.
21392
21393 G++ implements the same behavior as GCC does when assigning to a
21394 volatile object---there is no reread of the assigned-to object, the
21395 assigned rvalue is reused. Note that in C++ assignment expressions
21396 are lvalues, and if used as an lvalue, the volatile object is
21397 referred to. For instance, @var{vref} refers to @var{vobj}, as
21398 expected, in the following example:
21399
21400 @smallexample
21401 volatile int vobj;
21402 volatile int &vref = vobj = @var{something};
21403 @end smallexample
21404
21405 @node Restricted Pointers
21406 @section Restricting Pointer Aliasing
21407 @cindex restricted pointers
21408 @cindex restricted references
21409 @cindex restricted this pointer
21410
21411 As with the C front end, G++ understands the C99 feature of restricted pointers,
21412 specified with the @code{__restrict__}, or @code{__restrict} type
21413 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
21414 language flag, @code{restrict} is not a keyword in C++.
21415
21416 In addition to allowing restricted pointers, you can specify restricted
21417 references, which indicate that the reference is not aliased in the local
21418 context.
21419
21420 @smallexample
21421 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21422 @{
21423 /* @r{@dots{}} */
21424 @}
21425 @end smallexample
21426
21427 @noindent
21428 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21429 @var{rref} refers to a (different) unaliased integer.
21430
21431 You may also specify whether a member function's @var{this} pointer is
21432 unaliased by using @code{__restrict__} as a member function qualifier.
21433
21434 @smallexample
21435 void T::fn () __restrict__
21436 @{
21437 /* @r{@dots{}} */
21438 @}
21439 @end smallexample
21440
21441 @noindent
21442 Within the body of @code{T::fn}, @var{this} has the effective
21443 definition @code{T *__restrict__ const this}. Notice that the
21444 interpretation of a @code{__restrict__} member function qualifier is
21445 different to that of @code{const} or @code{volatile} qualifier, in that it
21446 is applied to the pointer rather than the object. This is consistent with
21447 other compilers that implement restricted pointers.
21448
21449 As with all outermost parameter qualifiers, @code{__restrict__} is
21450 ignored in function definition matching. This means you only need to
21451 specify @code{__restrict__} in a function definition, rather than
21452 in a function prototype as well.
21453
21454 @node Vague Linkage
21455 @section Vague Linkage
21456 @cindex vague linkage
21457
21458 There are several constructs in C++ that require space in the object
21459 file but are not clearly tied to a single translation unit. We say that
21460 these constructs have ``vague linkage''. Typically such constructs are
21461 emitted wherever they are needed, though sometimes we can be more
21462 clever.
21463
21464 @table @asis
21465 @item Inline Functions
21466 Inline functions are typically defined in a header file which can be
21467 included in many different compilations. Hopefully they can usually be
21468 inlined, but sometimes an out-of-line copy is necessary, if the address
21469 of the function is taken or if inlining fails. In general, we emit an
21470 out-of-line copy in all translation units where one is needed. As an
21471 exception, we only emit inline virtual functions with the vtable, since
21472 it always requires a copy.
21473
21474 Local static variables and string constants used in an inline function
21475 are also considered to have vague linkage, since they must be shared
21476 between all inlined and out-of-line instances of the function.
21477
21478 @item VTables
21479 @cindex vtable
21480 C++ virtual functions are implemented in most compilers using a lookup
21481 table, known as a vtable. The vtable contains pointers to the virtual
21482 functions provided by a class, and each object of the class contains a
21483 pointer to its vtable (or vtables, in some multiple-inheritance
21484 situations). If the class declares any non-inline, non-pure virtual
21485 functions, the first one is chosen as the ``key method'' for the class,
21486 and the vtable is only emitted in the translation unit where the key
21487 method is defined.
21488
21489 @emph{Note:} If the chosen key method is later defined as inline, the
21490 vtable is still emitted in every translation unit that defines it.
21491 Make sure that any inline virtuals are declared inline in the class
21492 body, even if they are not defined there.
21493
21494 @item @code{type_info} objects
21495 @cindex @code{type_info}
21496 @cindex RTTI
21497 C++ requires information about types to be written out in order to
21498 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21499 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21500 object is written out along with the vtable so that @samp{dynamic_cast}
21501 can determine the dynamic type of a class object at run time. For all
21502 other types, we write out the @samp{type_info} object when it is used: when
21503 applying @samp{typeid} to an expression, throwing an object, or
21504 referring to a type in a catch clause or exception specification.
21505
21506 @item Template Instantiations
21507 Most everything in this section also applies to template instantiations,
21508 but there are other options as well.
21509 @xref{Template Instantiation,,Where's the Template?}.
21510
21511 @end table
21512
21513 When used with GNU ld version 2.8 or later on an ELF system such as
21514 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21515 these constructs will be discarded at link time. This is known as
21516 COMDAT support.
21517
21518 On targets that don't support COMDAT, but do support weak symbols, GCC
21519 uses them. This way one copy overrides all the others, but
21520 the unused copies still take up space in the executable.
21521
21522 For targets that do not support either COMDAT or weak symbols,
21523 most entities with vague linkage are emitted as local symbols to
21524 avoid duplicate definition errors from the linker. This does not happen
21525 for local statics in inlines, however, as having multiple copies
21526 almost certainly breaks things.
21527
21528 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21529 another way to control placement of these constructs.
21530
21531 @node C++ Interface
21532 @section C++ Interface and Implementation Pragmas
21533
21534 @cindex interface and implementation headers, C++
21535 @cindex C++ interface and implementation headers
21536 @cindex pragmas, interface and implementation
21537
21538 @code{#pragma interface} and @code{#pragma implementation} provide the
21539 user with a way of explicitly directing the compiler to emit entities
21540 with vague linkage (and debugging information) in a particular
21541 translation unit.
21542
21543 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
21544 by COMDAT support and the ``key method'' heuristic
21545 mentioned in @ref{Vague Linkage}. Using them can actually cause your
21546 program to grow due to unnecessary out-of-line copies of inline
21547 functions.
21548
21549 @table @code
21550 @item #pragma interface
21551 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
21552 @kindex #pragma interface
21553 Use this directive in @emph{header files} that define object classes, to save
21554 space in most of the object files that use those classes. Normally,
21555 local copies of certain information (backup copies of inline member
21556 functions, debugging information, and the internal tables that implement
21557 virtual functions) must be kept in each object file that includes class
21558 definitions. You can use this pragma to avoid such duplication. When a
21559 header file containing @samp{#pragma interface} is included in a
21560 compilation, this auxiliary information is not generated (unless
21561 the main input source file itself uses @samp{#pragma implementation}).
21562 Instead, the object files contain references to be resolved at link
21563 time.
21564
21565 The second form of this directive is useful for the case where you have
21566 multiple headers with the same name in different directories. If you
21567 use this form, you must specify the same string to @samp{#pragma
21568 implementation}.
21569
21570 @item #pragma implementation
21571 @itemx #pragma implementation "@var{objects}.h"
21572 @kindex #pragma implementation
21573 Use this pragma in a @emph{main input file}, when you want full output from
21574 included header files to be generated (and made globally visible). The
21575 included header file, in turn, should use @samp{#pragma interface}.
21576 Backup copies of inline member functions, debugging information, and the
21577 internal tables used to implement virtual functions are all generated in
21578 implementation files.
21579
21580 @cindex implied @code{#pragma implementation}
21581 @cindex @code{#pragma implementation}, implied
21582 @cindex naming convention, implementation headers
21583 If you use @samp{#pragma implementation} with no argument, it applies to
21584 an include file with the same basename@footnote{A file's @dfn{basename}
21585 is the name stripped of all leading path information and of trailing
21586 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
21587 file. For example, in @file{allclass.cc}, giving just
21588 @samp{#pragma implementation}
21589 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
21590
21591 Use the string argument if you want a single implementation file to
21592 include code from multiple header files. (You must also use
21593 @samp{#include} to include the header file; @samp{#pragma
21594 implementation} only specifies how to use the file---it doesn't actually
21595 include it.)
21596
21597 There is no way to split up the contents of a single header file into
21598 multiple implementation files.
21599 @end table
21600
21601 @cindex inlining and C++ pragmas
21602 @cindex C++ pragmas, effect on inlining
21603 @cindex pragmas in C++, effect on inlining
21604 @samp{#pragma implementation} and @samp{#pragma interface} also have an
21605 effect on function inlining.
21606
21607 If you define a class in a header file marked with @samp{#pragma
21608 interface}, the effect on an inline function defined in that class is
21609 similar to an explicit @code{extern} declaration---the compiler emits
21610 no code at all to define an independent version of the function. Its
21611 definition is used only for inlining with its callers.
21612
21613 @opindex fno-implement-inlines
21614 Conversely, when you include the same header file in a main source file
21615 that declares it as @samp{#pragma implementation}, the compiler emits
21616 code for the function itself; this defines a version of the function
21617 that can be found via pointers (or by callers compiled without
21618 inlining). If all calls to the function can be inlined, you can avoid
21619 emitting the function by compiling with @option{-fno-implement-inlines}.
21620 If any calls are not inlined, you will get linker errors.
21621
21622 @node Template Instantiation
21623 @section Where's the Template?
21624 @cindex template instantiation
21625
21626 C++ templates were the first language feature to require more
21627 intelligence from the environment than was traditionally found on a UNIX
21628 system. Somehow the compiler and linker have to make sure that each
21629 template instance occurs exactly once in the executable if it is needed,
21630 and not at all otherwise. There are two basic approaches to this
21631 problem, which are referred to as the Borland model and the Cfront model.
21632
21633 @table @asis
21634 @item Borland model
21635 Borland C++ solved the template instantiation problem by adding the code
21636 equivalent of common blocks to their linker; the compiler emits template
21637 instances in each translation unit that uses them, and the linker
21638 collapses them together. The advantage of this model is that the linker
21639 only has to consider the object files themselves; there is no external
21640 complexity to worry about. The disadvantage is that compilation time
21641 is increased because the template code is being compiled repeatedly.
21642 Code written for this model tends to include definitions of all
21643 templates in the header file, since they must be seen to be
21644 instantiated.
21645
21646 @item Cfront model
21647 The AT&T C++ translator, Cfront, solved the template instantiation
21648 problem by creating the notion of a template repository, an
21649 automatically maintained place where template instances are stored. A
21650 more modern version of the repository works as follows: As individual
21651 object files are built, the compiler places any template definitions and
21652 instantiations encountered in the repository. At link time, the link
21653 wrapper adds in the objects in the repository and compiles any needed
21654 instances that were not previously emitted. The advantages of this
21655 model are more optimal compilation speed and the ability to use the
21656 system linker; to implement the Borland model a compiler vendor also
21657 needs to replace the linker. The disadvantages are vastly increased
21658 complexity, and thus potential for error; for some code this can be
21659 just as transparent, but in practice it can been very difficult to build
21660 multiple programs in one directory and one program in multiple
21661 directories. Code written for this model tends to separate definitions
21662 of non-inline member templates into a separate file, which should be
21663 compiled separately.
21664 @end table
21665
21666 G++ implements the Borland model on targets where the linker supports it,
21667 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
21668 Otherwise G++ implements neither automatic model.
21669
21670 You have the following options for dealing with template instantiations:
21671
21672 @enumerate
21673 @item
21674 Do nothing. Code written for the Borland model works fine, but
21675 each translation unit contains instances of each of the templates it
21676 uses. The duplicate instances will be discarded by the linker, but in
21677 a large program, this can lead to an unacceptable amount of code
21678 duplication in object files or shared libraries.
21679
21680 Duplicate instances of a template can be avoided by defining an explicit
21681 instantiation in one object file, and preventing the compiler from doing
21682 implicit instantiations in any other object files by using an explicit
21683 instantiation declaration, using the @code{extern template} syntax:
21684
21685 @smallexample
21686 extern template int max (int, int);
21687 @end smallexample
21688
21689 This syntax is defined in the C++ 2011 standard, but has been supported by
21690 G++ and other compilers since well before 2011.
21691
21692 Explicit instantiations can be used for the largest or most frequently
21693 duplicated instances, without having to know exactly which other instances
21694 are used in the rest of the program. You can scatter the explicit
21695 instantiations throughout your program, perhaps putting them in the
21696 translation units where the instances are used or the translation units
21697 that define the templates themselves; you can put all of the explicit
21698 instantiations you need into one big file; or you can create small files
21699 like
21700
21701 @smallexample
21702 #include "Foo.h"
21703 #include "Foo.cc"
21704
21705 template class Foo<int>;
21706 template ostream& operator <<
21707 (ostream&, const Foo<int>&);
21708 @end smallexample
21709
21710 @noindent
21711 for each of the instances you need, and create a template instantiation
21712 library from those.
21713
21714 This is the simplest option, but also offers flexibility and
21715 fine-grained control when necessary. It is also the most portable
21716 alternative and programs using this approach will work with most modern
21717 compilers.
21718
21719 @item
21720 @opindex frepo
21721 Compile your template-using code with @option{-frepo}. The compiler
21722 generates files with the extension @samp{.rpo} listing all of the
21723 template instantiations used in the corresponding object files that
21724 could be instantiated there; the link wrapper, @samp{collect2},
21725 then updates the @samp{.rpo} files to tell the compiler where to place
21726 those instantiations and rebuild any affected object files. The
21727 link-time overhead is negligible after the first pass, as the compiler
21728 continues to place the instantiations in the same files.
21729
21730 This can be a suitable option for application code written for the Borland
21731 model, as it usually just works. Code written for the Cfront model
21732 needs to be modified so that the template definitions are available at
21733 one or more points of instantiation; usually this is as simple as adding
21734 @code{#include <tmethods.cc>} to the end of each template header.
21735
21736 For library code, if you want the library to provide all of the template
21737 instantiations it needs, just try to link all of its object files
21738 together; the link will fail, but cause the instantiations to be
21739 generated as a side effect. Be warned, however, that this may cause
21740 conflicts if multiple libraries try to provide the same instantiations.
21741 For greater control, use explicit instantiation as described in the next
21742 option.
21743
21744 @item
21745 @opindex fno-implicit-templates
21746 Compile your code with @option{-fno-implicit-templates} to disable the
21747 implicit generation of template instances, and explicitly instantiate
21748 all the ones you use. This approach requires more knowledge of exactly
21749 which instances you need than do the others, but it's less
21750 mysterious and allows greater control if you want to ensure that only
21751 the intended instances are used.
21752
21753 If you are using Cfront-model code, you can probably get away with not
21754 using @option{-fno-implicit-templates} when compiling files that don't
21755 @samp{#include} the member template definitions.
21756
21757 If you use one big file to do the instantiations, you may want to
21758 compile it without @option{-fno-implicit-templates} so you get all of the
21759 instances required by your explicit instantiations (but not by any
21760 other files) without having to specify them as well.
21761
21762 In addition to forward declaration of explicit instantiations
21763 (with @code{extern}), G++ has extended the template instantiation
21764 syntax to support instantiation of the compiler support data for a
21765 template class (i.e.@: the vtable) without instantiating any of its
21766 members (with @code{inline}), and instantiation of only the static data
21767 members of a template class, without the support data or member
21768 functions (with @code{static}):
21769
21770 @smallexample
21771 inline template class Foo<int>;
21772 static template class Foo<int>;
21773 @end smallexample
21774 @end enumerate
21775
21776 @node Bound member functions
21777 @section Extracting the Function Pointer from a Bound Pointer to Member Function
21778 @cindex pmf
21779 @cindex pointer to member function
21780 @cindex bound pointer to member function
21781
21782 In C++, pointer to member functions (PMFs) are implemented using a wide
21783 pointer of sorts to handle all the possible call mechanisms; the PMF
21784 needs to store information about how to adjust the @samp{this} pointer,
21785 and if the function pointed to is virtual, where to find the vtable, and
21786 where in the vtable to look for the member function. If you are using
21787 PMFs in an inner loop, you should really reconsider that decision. If
21788 that is not an option, you can extract the pointer to the function that
21789 would be called for a given object/PMF pair and call it directly inside
21790 the inner loop, to save a bit of time.
21791
21792 Note that you still pay the penalty for the call through a
21793 function pointer; on most modern architectures, such a call defeats the
21794 branch prediction features of the CPU@. This is also true of normal
21795 virtual function calls.
21796
21797 The syntax for this extension is
21798
21799 @smallexample
21800 extern A a;
21801 extern int (A::*fp)();
21802 typedef int (*fptr)(A *);
21803
21804 fptr p = (fptr)(a.*fp);
21805 @end smallexample
21806
21807 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
21808 no object is needed to obtain the address of the function. They can be
21809 converted to function pointers directly:
21810
21811 @smallexample
21812 fptr p1 = (fptr)(&A::foo);
21813 @end smallexample
21814
21815 @opindex Wno-pmf-conversions
21816 You must specify @option{-Wno-pmf-conversions} to use this extension.
21817
21818 @node C++ Attributes
21819 @section C++-Specific Variable, Function, and Type Attributes
21820
21821 Some attributes only make sense for C++ programs.
21822
21823 @table @code
21824 @item abi_tag ("@var{tag}", ...)
21825 @cindex @code{abi_tag} function attribute
21826 @cindex @code{abi_tag} variable attribute
21827 @cindex @code{abi_tag} type attribute
21828 The @code{abi_tag} attribute can be applied to a function, variable, or class
21829 declaration. It modifies the mangled name of the entity to
21830 incorporate the tag name, in order to distinguish the function or
21831 class from an earlier version with a different ABI; perhaps the class
21832 has changed size, or the function has a different return type that is
21833 not encoded in the mangled name.
21834
21835 The attribute can also be applied to an inline namespace, but does not
21836 affect the mangled name of the namespace; in this case it is only used
21837 for @option{-Wabi-tag} warnings and automatic tagging of functions and
21838 variables. Tagging inline namespaces is generally preferable to
21839 tagging individual declarations, but the latter is sometimes
21840 necessary, such as when only certain members of a class need to be
21841 tagged.
21842
21843 The argument can be a list of strings of arbitrary length. The
21844 strings are sorted on output, so the order of the list is
21845 unimportant.
21846
21847 A redeclaration of an entity must not add new ABI tags,
21848 since doing so would change the mangled name.
21849
21850 The ABI tags apply to a name, so all instantiations and
21851 specializations of a template have the same tags. The attribute will
21852 be ignored if applied to an explicit specialization or instantiation.
21853
21854 The @option{-Wabi-tag} flag enables a warning about a class which does
21855 not have all the ABI tags used by its subobjects and virtual functions; for users with code
21856 that needs to coexist with an earlier ABI, using this option can help
21857 to find all affected types that need to be tagged.
21858
21859 When a type involving an ABI tag is used as the type of a variable or
21860 return type of a function where that tag is not already present in the
21861 signature of the function, the tag is automatically applied to the
21862 variable or function. @option{-Wabi-tag} also warns about this
21863 situation; this warning can be avoided by explicitly tagging the
21864 variable or function or moving it into a tagged inline namespace.
21865
21866 @item init_priority (@var{priority})
21867 @cindex @code{init_priority} variable attribute
21868
21869 In Standard C++, objects defined at namespace scope are guaranteed to be
21870 initialized in an order in strict accordance with that of their definitions
21871 @emph{in a given translation unit}. No guarantee is made for initializations
21872 across translation units. However, GNU C++ allows users to control the
21873 order of initialization of objects defined at namespace scope with the
21874 @code{init_priority} attribute by specifying a relative @var{priority},
21875 a constant integral expression currently bounded between 101 and 65535
21876 inclusive. Lower numbers indicate a higher priority.
21877
21878 In the following example, @code{A} would normally be created before
21879 @code{B}, but the @code{init_priority} attribute reverses that order:
21880
21881 @smallexample
21882 Some_Class A __attribute__ ((init_priority (2000)));
21883 Some_Class B __attribute__ ((init_priority (543)));
21884 @end smallexample
21885
21886 @noindent
21887 Note that the particular values of @var{priority} do not matter; only their
21888 relative ordering.
21889
21890 @item java_interface
21891 @cindex @code{java_interface} type attribute
21892
21893 This type attribute informs C++ that the class is a Java interface. It may
21894 only be applied to classes declared within an @code{extern "Java"} block.
21895 Calls to methods declared in this interface are dispatched using GCJ's
21896 interface table mechanism, instead of regular virtual table dispatch.
21897
21898 @item warn_unused
21899 @cindex @code{warn_unused} type attribute
21900
21901 For C++ types with non-trivial constructors and/or destructors it is
21902 impossible for the compiler to determine whether a variable of this
21903 type is truly unused if it is not referenced. This type attribute
21904 informs the compiler that variables of this type should be warned
21905 about if they appear to be unused, just like variables of fundamental
21906 types.
21907
21908 This attribute is appropriate for types which just represent a value,
21909 such as @code{std::string}; it is not appropriate for types which
21910 control a resource, such as @code{std::lock_guard}.
21911
21912 This attribute is also accepted in C, but it is unnecessary because C
21913 does not have constructors or destructors.
21914
21915 @end table
21916
21917 See also @ref{Namespace Association}.
21918
21919 @node Function Multiversioning
21920 @section Function Multiversioning
21921 @cindex function versions
21922
21923 With the GNU C++ front end, for x86 targets, you may specify multiple
21924 versions of a function, where each function is specialized for a
21925 specific target feature. At runtime, the appropriate version of the
21926 function is automatically executed depending on the characteristics of
21927 the execution platform. Here is an example.
21928
21929 @smallexample
21930 __attribute__ ((target ("default")))
21931 int foo ()
21932 @{
21933 // The default version of foo.
21934 return 0;
21935 @}
21936
21937 __attribute__ ((target ("sse4.2")))
21938 int foo ()
21939 @{
21940 // foo version for SSE4.2
21941 return 1;
21942 @}
21943
21944 __attribute__ ((target ("arch=atom")))
21945 int foo ()
21946 @{
21947 // foo version for the Intel ATOM processor
21948 return 2;
21949 @}
21950
21951 __attribute__ ((target ("arch=amdfam10")))
21952 int foo ()
21953 @{
21954 // foo version for the AMD Family 0x10 processors.
21955 return 3;
21956 @}
21957
21958 int main ()
21959 @{
21960 int (*p)() = &foo;
21961 assert ((*p) () == foo ());
21962 return 0;
21963 @}
21964 @end smallexample
21965
21966 In the above example, four versions of function foo are created. The
21967 first version of foo with the target attribute "default" is the default
21968 version. This version gets executed when no other target specific
21969 version qualifies for execution on a particular platform. A new version
21970 of foo is created by using the same function signature but with a
21971 different target string. Function foo is called or a pointer to it is
21972 taken just like a regular function. GCC takes care of doing the
21973 dispatching to call the right version at runtime. Refer to the
21974 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
21975 Function Multiversioning} for more details.
21976
21977 @node Namespace Association
21978 @section Namespace Association
21979
21980 @strong{Caution:} The semantics of this extension are equivalent
21981 to C++ 2011 inline namespaces. Users should use inline namespaces
21982 instead as this extension will be removed in future versions of G++.
21983
21984 A using-directive with @code{__attribute ((strong))} is stronger
21985 than a normal using-directive in two ways:
21986
21987 @itemize @bullet
21988 @item
21989 Templates from the used namespace can be specialized and explicitly
21990 instantiated as though they were members of the using namespace.
21991
21992 @item
21993 The using namespace is considered an associated namespace of all
21994 templates in the used namespace for purposes of argument-dependent
21995 name lookup.
21996 @end itemize
21997
21998 The used namespace must be nested within the using namespace so that
21999 normal unqualified lookup works properly.
22000
22001 This is useful for composing a namespace transparently from
22002 implementation namespaces. For example:
22003
22004 @smallexample
22005 namespace std @{
22006 namespace debug @{
22007 template <class T> struct A @{ @};
22008 @}
22009 using namespace debug __attribute ((__strong__));
22010 template <> struct A<int> @{ @}; // @r{OK to specialize}
22011
22012 template <class T> void f (A<T>);
22013 @}
22014
22015 int main()
22016 @{
22017 f (std::A<float>()); // @r{lookup finds} std::f
22018 f (std::A<int>());
22019 @}
22020 @end smallexample
22021
22022 @node Type Traits
22023 @section Type Traits
22024
22025 The C++ front end implements syntactic extensions that allow
22026 compile-time determination of
22027 various characteristics of a type (or of a
22028 pair of types).
22029
22030 @table @code
22031 @item __has_nothrow_assign (type)
22032 If @code{type} is const qualified or is a reference type then the trait is
22033 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22034 is true, else if @code{type} is a cv class or union type with copy assignment
22035 operators that are known not to throw an exception then the trait is true,
22036 else it is false. Requires: @code{type} shall be a complete type,
22037 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22038
22039 @item __has_nothrow_copy (type)
22040 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22041 @code{type} is a cv class or union type with copy constructors that
22042 are known not to throw an exception then the trait is true, else it is false.
22043 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22044 @code{void}, or an array of unknown bound.
22045
22046 @item __has_nothrow_constructor (type)
22047 If @code{__has_trivial_constructor (type)} is true then the trait is
22048 true, else if @code{type} is a cv class or union type (or array
22049 thereof) with a default constructor that is known not to throw an
22050 exception then the trait is true, else it is false. Requires:
22051 @code{type} shall be a complete type, (possibly cv-qualified)
22052 @code{void}, or an array of unknown bound.
22053
22054 @item __has_trivial_assign (type)
22055 If @code{type} is const qualified or is a reference type then the trait is
22056 false. Otherwise if @code{__is_pod (type)} is true then the trait is
22057 true, else if @code{type} is a cv class or union type with a trivial
22058 copy assignment ([class.copy]) then the trait is true, else it is
22059 false. Requires: @code{type} shall be a complete type, (possibly
22060 cv-qualified) @code{void}, or an array of unknown bound.
22061
22062 @item __has_trivial_copy (type)
22063 If @code{__is_pod (type)} is true or @code{type} is a reference type
22064 then the trait is true, else if @code{type} is a cv class or union type
22065 with a trivial copy constructor ([class.copy]) then the trait
22066 is true, else it is false. Requires: @code{type} shall be a complete
22067 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22068
22069 @item __has_trivial_constructor (type)
22070 If @code{__is_pod (type)} is true then the trait is true, else if
22071 @code{type} is a cv class or union type (or array thereof) with a
22072 trivial default constructor ([class.ctor]) then the trait is true,
22073 else it is false. Requires: @code{type} shall be a complete
22074 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22075
22076 @item __has_trivial_destructor (type)
22077 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22078 the trait is true, else if @code{type} is a cv class or union type (or
22079 array thereof) with a trivial destructor ([class.dtor]) then the trait
22080 is true, else it is false. Requires: @code{type} shall be a complete
22081 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22082
22083 @item __has_virtual_destructor (type)
22084 If @code{type} is a class type with a virtual destructor
22085 ([class.dtor]) then the trait is true, else it is false. Requires:
22086 @code{type} shall be a complete type, (possibly cv-qualified)
22087 @code{void}, or an array of unknown bound.
22088
22089 @item __is_abstract (type)
22090 If @code{type} is an abstract class ([class.abstract]) then the trait
22091 is true, else it is false. Requires: @code{type} shall be a complete
22092 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22093
22094 @item __is_base_of (base_type, derived_type)
22095 If @code{base_type} is a base class of @code{derived_type}
22096 ([class.derived]) then the trait is true, otherwise it is false.
22097 Top-level cv qualifications of @code{base_type} and
22098 @code{derived_type} are ignored. For the purposes of this trait, a
22099 class type is considered is own base. Requires: if @code{__is_class
22100 (base_type)} and @code{__is_class (derived_type)} are true and
22101 @code{base_type} and @code{derived_type} are not the same type
22102 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22103 type. A diagnostic is produced if this requirement is not met.
22104
22105 @item __is_class (type)
22106 If @code{type} is a cv class type, and not a union type
22107 ([basic.compound]) the trait is true, else it is false.
22108
22109 @item __is_empty (type)
22110 If @code{__is_class (type)} is false then the trait is false.
22111 Otherwise @code{type} is considered empty if and only if: @code{type}
22112 has no non-static data members, or all non-static data members, if
22113 any, are bit-fields of length 0, and @code{type} has no virtual
22114 members, and @code{type} has no virtual base classes, and @code{type}
22115 has no base classes @code{base_type} for which
22116 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
22117 be a complete type, (possibly cv-qualified) @code{void}, or an array
22118 of unknown bound.
22119
22120 @item __is_enum (type)
22121 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22122 true, else it is false.
22123
22124 @item __is_literal_type (type)
22125 If @code{type} is a literal type ([basic.types]) the trait is
22126 true, else it is false. Requires: @code{type} shall be a complete type,
22127 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22128
22129 @item __is_pod (type)
22130 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22131 else it is false. Requires: @code{type} shall be a complete type,
22132 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22133
22134 @item __is_polymorphic (type)
22135 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22136 is true, else it is false. Requires: @code{type} shall be a complete
22137 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22138
22139 @item __is_standard_layout (type)
22140 If @code{type} is a standard-layout type ([basic.types]) the trait is
22141 true, else it is false. Requires: @code{type} shall be a complete
22142 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22143
22144 @item __is_trivial (type)
22145 If @code{type} is a trivial type ([basic.types]) the trait is
22146 true, else it is false. Requires: @code{type} shall be a complete
22147 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22148
22149 @item __is_union (type)
22150 If @code{type} is a cv union type ([basic.compound]) the trait is
22151 true, else it is false.
22152
22153 @item __underlying_type (type)
22154 The underlying type of @code{type}. Requires: @code{type} shall be
22155 an enumeration type ([dcl.enum]).
22156
22157 @end table
22158
22159
22160 @node C++ Concepts
22161 @section C++ Concepts
22162
22163 C++ concepts provide much-improved support for generic programming. In
22164 particular, they allow the specification of constraints on template arguments.
22165 The constraints are used to extend the usual overloading and partial
22166 specialization capabilities of the language, allowing generic data structures
22167 and algorithms to be ``refined'' based on their properties rather than their
22168 type names.
22169
22170 The following keywords are reserved for concepts.
22171
22172 @table @code
22173 @item assumes
22174 States an expression as an assumption, and if possible, verifies that the
22175 assumption is valid. For example, @code{assume(n > 0)}.
22176
22177 @item axiom
22178 Introduces an axiom definition. Axioms introduce requirements on values.
22179
22180 @item forall
22181 Introduces a universally quantified object in an axiom. For example,
22182 @code{forall (int n) n + 0 == n}).
22183
22184 @item concept
22185 Introduces a concept definition. Concepts are sets of syntactic and semantic
22186 requirements on types and their values.
22187
22188 @item requires
22189 Introduces constraints on template arguments or requirements for a member
22190 function of a class template.
22191
22192 @end table
22193
22194 The front end also exposes a number of internal mechanism that can be used
22195 to simplify the writing of type traits. Note that some of these traits are
22196 likely to be removed in the future.
22197
22198 @table @code
22199 @item __is_same (type1, type2)
22200 A binary type trait: true whenever the type arguments are the same.
22201
22202 @end table
22203
22204
22205 @node Java Exceptions
22206 @section Java Exceptions
22207
22208 The Java language uses a slightly different exception handling model
22209 from C++. Normally, GNU C++ automatically detects when you are
22210 writing C++ code that uses Java exceptions, and handle them
22211 appropriately. However, if C++ code only needs to execute destructors
22212 when Java exceptions are thrown through it, GCC guesses incorrectly.
22213 Sample problematic code is:
22214
22215 @smallexample
22216 struct S @{ ~S(); @};
22217 extern void bar(); // @r{is written in Java, and may throw exceptions}
22218 void foo()
22219 @{
22220 S s;
22221 bar();
22222 @}
22223 @end smallexample
22224
22225 @noindent
22226 The usual effect of an incorrect guess is a link failure, complaining of
22227 a missing routine called @samp{__gxx_personality_v0}.
22228
22229 You can inform the compiler that Java exceptions are to be used in a
22230 translation unit, irrespective of what it might think, by writing
22231 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
22232 @samp{#pragma} must appear before any functions that throw or catch
22233 exceptions, or run destructors when exceptions are thrown through them.
22234
22235 You cannot mix Java and C++ exceptions in the same translation unit. It
22236 is believed to be safe to throw a C++ exception from one file through
22237 another file compiled for the Java exception model, or vice versa, but
22238 there may be bugs in this area.
22239
22240 @node Deprecated Features
22241 @section Deprecated Features
22242
22243 In the past, the GNU C++ compiler was extended to experiment with new
22244 features, at a time when the C++ language was still evolving. Now that
22245 the C++ standard is complete, some of those features are superseded by
22246 superior alternatives. Using the old features might cause a warning in
22247 some cases that the feature will be dropped in the future. In other
22248 cases, the feature might be gone already.
22249
22250 While the list below is not exhaustive, it documents some of the options
22251 that are now deprecated:
22252
22253 @table @code
22254 @item -fexternal-templates
22255 @itemx -falt-external-templates
22256 These are two of the many ways for G++ to implement template
22257 instantiation. @xref{Template Instantiation}. The C++ standard clearly
22258 defines how template definitions have to be organized across
22259 implementation units. G++ has an implicit instantiation mechanism that
22260 should work just fine for standard-conforming code.
22261
22262 @item -fstrict-prototype
22263 @itemx -fno-strict-prototype
22264 Previously it was possible to use an empty prototype parameter list to
22265 indicate an unspecified number of parameters (like C), rather than no
22266 parameters, as C++ demands. This feature has been removed, except where
22267 it is required for backwards compatibility. @xref{Backwards Compatibility}.
22268 @end table
22269
22270 G++ allows a virtual function returning @samp{void *} to be overridden
22271 by one returning a different pointer type. This extension to the
22272 covariant return type rules is now deprecated and will be removed from a
22273 future version.
22274
22275 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22276 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22277 and are now removed from G++. Code using these operators should be
22278 modified to use @code{std::min} and @code{std::max} instead.
22279
22280 The named return value extension has been deprecated, and is now
22281 removed from G++.
22282
22283 The use of initializer lists with new expressions has been deprecated,
22284 and is now removed from G++.
22285
22286 Floating and complex non-type template parameters have been deprecated,
22287 and are now removed from G++.
22288
22289 The implicit typename extension has been deprecated and is now
22290 removed from G++.
22291
22292 The use of default arguments in function pointers, function typedefs
22293 and other places where they are not permitted by the standard is
22294 deprecated and will be removed from a future version of G++.
22295
22296 G++ allows floating-point literals to appear in integral constant expressions,
22297 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22298 This extension is deprecated and will be removed from a future version.
22299
22300 G++ allows static data members of const floating-point type to be declared
22301 with an initializer in a class definition. The standard only allows
22302 initializers for static members of const integral types and const
22303 enumeration types so this extension has been deprecated and will be removed
22304 from a future version.
22305
22306 @node Backwards Compatibility
22307 @section Backwards Compatibility
22308 @cindex Backwards Compatibility
22309 @cindex ARM [Annotated C++ Reference Manual]
22310
22311 Now that there is a definitive ISO standard C++, G++ has a specification
22312 to adhere to. The C++ language evolved over time, and features that
22313 used to be acceptable in previous drafts of the standard, such as the ARM
22314 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
22315 compilation of C++ written to such drafts, G++ contains some backwards
22316 compatibilities. @emph{All such backwards compatibility features are
22317 liable to disappear in future versions of G++.} They should be considered
22318 deprecated. @xref{Deprecated Features}.
22319
22320 @table @code
22321 @item For scope
22322 If a variable is declared at for scope, it used to remain in scope until
22323 the end of the scope that contained the for statement (rather than just
22324 within the for scope). G++ retains this, but issues a warning, if such a
22325 variable is accessed outside the for scope.
22326
22327 @item Implicit C language
22328 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22329 scope to set the language. On such systems, all header files are
22330 implicitly scoped inside a C language scope. Also, an empty prototype
22331 @code{()} is treated as an unspecified number of arguments, rather
22332 than no arguments, as C++ demands.
22333 @end table
22334
22335 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
22336 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr